Fork me on GitHub

Changeset dc883b4 in git


Ignore:
Timestamp:
Mar 4, 2021, 2:36:16 PM (4 years ago)
Author:
Pavel Demin <pavel.demin@…>
Branches:
master
Children:
4658ca4
Parents:
f9517a5
Message:

add info to TreeWriter

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • cards/delphes_card_IDEAtrkCov.tcl

    rf9517a5 rdc883b4  
    88#        michele.selvaggi@cern.ch
    99#####################################################################
    10 #
     10
     11set B 2.0
     12
    1113#######################################
    1214# Order of execution of various modules
     
    5961  TreeWriter
    6062}
    61 
    6263
    6364#################################
     
    8081
    8182  # magnetic field, in T
    82   set Bz 2.0
     83  set Bz $B
    8384}
    8485
     
    310311    }
    311312
    312     set Bz 2.0
    313 }
    314 
     313    set Bz $B
     314}
    315315
    316316##############
     
    767767    add Branch MissingET/momentum MissingET MissingET
    768768    add Branch ScalarHT/energy ScalarHT ScalarHT
    769 }
     769
     770    # add Info InfoName InfoValue
     771    add Info Bz $B
     772}
  • classes/DelphesModule.cc

    rf9517a5 rdc883b4  
    130130//------------------------------------------------------------------------------
    131131
     132void DelphesModule::AddInfo(const char *name, Double_t value)
     133{
     134  stringstream message;
     135  if(!fTreeWriter)
     136  {
     137    fTreeWriter = static_cast<ExRootTreeWriter *>(GetObject("TreeWriter", ExRootTreeWriter::Class()));
     138    if(!fTreeWriter)
     139    {
     140      message << "can't access access tree writer";
     141      throw runtime_error(message.str());
     142    }
     143  }
     144  fTreeWriter->AddInfo(name, value);
     145}
     146
     147//------------------------------------------------------------------------------
     148
    132149ExRootResult *DelphesModule::GetPlots()
    133150{
  • classes/DelphesModule.h

    rf9517a5 rdc883b4  
    5555
    5656  ExRootTreeBranch *NewBranch(const char *name, TClass *cl);
     57  void AddInfo(const char *name, Double_t value);
    5758
    5859  ExRootResult *GetPlots();
  • examples/Example6.C

    rf9517a5 rdc883b4  
    6464        // CEntral track over min Pt
    6565        TH1* histPtgenC = new TH1F("h_PtgenC", "Generated Pt - Central", 500, 0., 50.);         // pt for central tracks;
    66         TH1* histPtobsC = new TH1F("h_PtobsC", "Reconstructed Pt - Central", 500, 0., 50.);     // pt for central 
     66        TH1* histPtobsC = new TH1F("h_PtobsC", "Reconstructed Pt - Central", 500, 0., 50.);     // pt for central
    6767        TH1* histCtgenH = new TH1F("h_CtgenH", "Generateded Cotangent", 100, -10., 10.);                // cot(theta) for high pt tracks;
    6868        TH1* histCtobsH = new TH1F("h_CtobsH", "Reconstructed Cotangent", 100, -10., 10.);      // cot(theta) for high pt tracks
     
    7777        //
    7878        // Get magnetifc field
    79         Double_t Bz = 2.0;
     79        Double_t Bz = treeReader->GetInfo("Bz");
    8080
    8181        // Loop over all events
     
    107107                                histCtobs->Fill(obsCtg);
    108108                                //
    109                                 // Get associated generated particle 
     109                                // Get associated generated particle
    110110                                GenParticle* gp = (GenParticle*)trk->Particle.GetObject();
    111111                                //
     
    162162                                        GenParticle* gpart = (GenParticle*)branchGenPart->At(it);
    163163                                        //
    164                                         // Plot charged particle parameters 
     164                                        // Plot charged particle parameters
    165165                                        // Only final state particles (Status = 1)
    166166                                        if (gpart->Status == 1 && TMath::Abs(gpart->Charge) > 0) {
     
    290290        histAccCtgH->Draw();
    291291        Cnv5->cd(3); gPad->SetLogy(1);
    292         histPtgenC->Draw(); 
     292        histPtgenC->Draw();
    293293        histPtobsC->SetLineColor(kRed);
    294294        histPtobsC->Draw("SAME");
  • external/ExRootAnalysis/ExRootTreeReader.cc

    rf9517a5 rdc883b4  
    1212#include "TBranchElement.h"
    1313#include "TCanvas.h"
     14#include "TParameter.h"
    1415#include "TClonesArray.h"
    1516#include "TH2.h"
     
    119120//------------------------------------------------------------------------------
    120121
     122Double_t ExRootTreeReader::GetInfo(const char *name)
     123{
     124  TTree *tree = NULL;
     125  TParameter<Double_t> *param = NULL;
     126  Double_t result = -999.9;
     127  if(fChain) tree = fChain->GetTree();
     128  if(tree) param = static_cast<TParameter<Double_t> *>(tree->GetUserInfo()->FindObject(name));
     129  if(param) result = param->GetVal();
     130  return result;
     131}
     132
     133//------------------------------------------------------------------------------
     134
    121135Bool_t ExRootTreeReader::Notify()
    122136{
  • external/ExRootAnalysis/ExRootTreeReader.h

    rf9517a5 rdc883b4  
    2929
    3030  TClonesArray *UseBranch(const char *branchName);
     31  Double_t GetInfo(const char *name);
    3132
    3233private:
  • external/ExRootAnalysis/ExRootTreeWriter.cc

    rf9517a5 rdc883b4  
    1111#include "ExRootAnalysis/ExRootTreeBranch.h"
    1212
     13#include "TParameter.h"
    1314#include "TClonesArray.h"
    1415#include "TFile.h"
     
    4849  fBranches.insert(branch);
    4950  return branch;
     51}
     52
     53//------------------------------------------------------------------------------
     54
     55void ExRootTreeWriter::AddInfo(const char *name, Double_t value)
     56{
     57  if(!fTree) fTree = NewTree();
     58  fTree->GetUserInfo()->Add(new TParameter<Double_t>(name, value));
    5059}
    5160
  • external/ExRootAnalysis/ExRootTreeWriter.h

    rf9517a5 rdc883b4  
    2929
    3030  ExRootTreeBranch *NewBranch(const char *name, TClass *cl);
     31  void AddInfo(const char *name, Double_t value);
    3132
    3233  void Clear();
  • modules/TreeWriter.cc

    rf9517a5 rdc883b4  
    123123    fBranchMap.insert(make_pair(branch, make_pair(itClassMap->second, array)));
    124124  }
     125
     126  param = GetParam("Info");
     127  TString infoName;
     128  Double_t infoValue;
     129
     130  size = param.GetSize();
     131  for(i = 0; i < size / 2; ++i)
     132  {
     133    infoName = param[i * 2].GetString();
     134    infoValue = param[i * 2 + 1].GetDouble();
     135
     136    AddInfo(infoName, infoValue);
     137  }
    125138}
    126139
     
    138151  it1.Reset();
    139152  array->Clear();
    140  
     153
    141154  while((candidate = static_cast<Candidate *>(it1.Next())))
    142155  {
     
    537550    entry->CtgTheta = ctgTheta;
    538551    entry->C = candidate->C;
    539    
     552
    540553    particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
    541554    const TLorentzVector &initialPosition = particle->Position;
Note: See TracChangeset for help on using the changeset viewer.