Fork me on GitHub

Changeset fbb617b in git for examples


Ignore:
Timestamp:
Dec 14, 2014, 12:06:59 AM (10 years ago)
Author:
Pavel Demin <pavel.demin@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
cf1ff2c
Parents:
57e1804
Message:

improve formatting and remove trailing spaces

Location:
examples
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • examples/Example1.C

    r57e1804 rfbb617b  
    22Simple macro showing how to access branches from the delphes output root file,
    33loop over events, and plot simple quantities such as the jet pt and the di-electron invariant
    4 mass. 
     4mass.
    55
    66root -l examples/Example1.C'("delphes_output.root")'
     
    1616  TChain chain("Delphes");
    1717  chain.Add(inputFile);
    18  
     18
    1919  // Create object of class ExRootTreeReader
    2020  ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
    2121  Long64_t numberOfEntries = treeReader->GetEntries();
    22  
     22
    2323  // Get pointers to branches used in this analysis
    2424  TClonesArray *branchJet = treeReader->UseBranch("Jet");
    2525  TClonesArray *branchElectron = treeReader->UseBranch("Electron");
    26  
     26
    2727  // Book histograms
    2828  TH1 *histJetPT = new TH1F("jet_pt", "jet P_{T}", 100, 0.0, 100.0);
     
    3434    // Load selected branches with data from specified event
    3535    treeReader->ReadEntry(entry);
    36  
     36
    3737    // If event contains at least 1 jet
    3838    if(branchJet->GetEntries() > 0)
     
    4040      // Take first jet
    4141      Jet *jet = (Jet*) branchJet->At(0);
    42      
     42
    4343      // Plot jet transverse momentum
    4444      histJetPT->Fill(jet->PT);
    45      
     45
    4646      // Print jet transverse momentum
    4747      cout << "Jet pt: "<<jet->PT << endl;
  • examples/Example1.cpp

    r57e1804 rfbb617b  
    22 *  Delphes: a framework for fast simulation of a generic collider experiment
    33 *  Copyright (C) 2012-2014  Universite catholique de Louvain (UCL), Belgium
    4  * 
     4 *
    55 *  This program is free software: you can redistribute it and/or modify
    66 *  it under the terms of the GNU General Public License as published by
    77 *  the Free Software Foundation, either version 3 of the License, or
    88 *  (at your option) any later version.
    9  * 
     9 *
    1010 *  This program is distributed in the hope that it will be useful,
    1111 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    1212 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1313 *  GNU General Public License for more details.
    14  * 
     14 *
    1515 *  You should have received a copy of the GNU General Public License
    1616 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    7373//------------------------------------------------------------------------------
    7474
    75 // Here you call your macro's main function 
     75// Here you call your macro's main function
    7676
    7777  Example1(inputFile);
  • examples/Example1.py

    r57e1804 rfbb617b  
    3838    # Take first jet
    3939    jet = branchJet.At(0)
    40    
     40
    4141    # Plot jet transverse momentum
    4242    histJetPT.Fill(jet.PT)
    43    
     43
    4444    # Print jet transverse momentum
    4545    print jet.PT
  • examples/Example2.C

    r57e1804 rfbb617b  
    11/*
    22Simple macro showing how to access branches from the delphes output root file,
    3 loop over events, store histograms in a root file and print them as image files. 
     3loop over events, store histograms in a root file and print them as image files.
    44
    55root -l examples/Example2.C'("delphes_output.root")'
  • examples/Example3.C

    r57e1804 rfbb617b  
    11/*
    22This macro shows how to access the particle-level reference for reconstructed objects.
    3 It is also shown how to loop over the jet constituents. 
     3It is also shown how to loop over the jet constituents.
    44
    55root -l examples/Example3.C'("delphes_output.root")'
     
    182182    }
    183183
    184   //  cout<<"--  New event -- "<<endl;
     184    // cout << "--  New event -- " << endl;
    185185
    186186    // Loop over all jets in event
     
    191191      momentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0);
    192192
    193       //cout<<"Looping over jet constituents. Jet pt: "<<jet->PT<<", eta: "<<jet->Eta<<", phi: "<<jet->Phi<<endl;     
     193      // cout<<"Looping over jet constituents. Jet pt: "<<jet->PT<<", eta: "<<jet->Eta<<", phi: "<<jet->Phi<<endl;
    194194
    195195      // Loop over all jet's constituents
     
    204204        {
    205205          particle = (GenParticle*) object;
    206           //cout << "    GenPart pt: " << particle->PT << ", eta: " << particle->Eta << ", phi: " << particle->Phi << endl;
     206          // cout << "    GenPart pt: " << particle->PT << ", eta: " << particle->Eta << ", phi: " << particle->Phi << endl;
    207207          momentum += particle->P4();
    208208        }
     
    210210        {
    211211          track = (Track*) object;
    212           //cout << "    Track pt: " << track->PT << ", eta: " << track->Eta << ", phi: " << track->Phi << endl;
     212          // cout << "    Track pt: " << track->PT << ", eta: " << track->Eta << ", phi: " << track->Phi << endl;
    213213          momentum += track->P4();
    214214        }
     
    216216        {
    217217          tower = (Tower*) object;
    218           //cout << "    Tower pt: " << tower->ET << ", eta: " << tower->Eta << ", phi: " << tower->Phi << endl;
     218          // cout << "    Tower pt: " << tower->ET << ", eta: " << tower->Eta << ", phi: " << tower->Phi << endl;
    219219          momentum += tower->P4();
    220220        }
  • examples/Example4.C

    r57e1804 rfbb617b  
    11/*
    22
    3 This macro shows how to compute jet energy scale. 
     3This macro shows how to compute jet energy scale.
    44root -l examples/Example4.C'("delphes_output.root", "plots.root")'
    55
    6 The output rootfile contains the pT(MC)/pT(Reco) distributions for various pT(Reco) and |eta| bins.
    7 The peak value of such distribution is interpreted as the jet energy correction to be applied for that given pT(Reco), |eta| bin. 
     6The output ROOT file contains the pT(MC)/pT(Reco) distributions for various pT(Reco) and |eta| bins.
     7The peak value of such distribution is interpreted as the jet energy correction to be applied for that given pT(Reco), |eta| bin.
    88
    99This can be done by modifying the "ScaleFormula" input parameter to the JetEnergyScale module in the delphes_card_XXX.tcl
     
    1515
    1616  set ScaleFormula { sqrt(3.0 - 0.1*(abs(eta)))^2 / pt + 1.0 ) }
    17  
    18  
     17
     18
    1919or a binned function:
    20  
    21  
    22  set ScaleFormula { (abs(eta) > 0.0 && abs(eta) <= 2.5) * (pt > 20.0 && pt <= 50.0)  * (1.10) + \
    23                     (abs(eta) > 0.0 && abs(eta) <= 2.5) * (pt > 50.0 && pt <= 100.0) * (1.05) + \
    24                     (abs(eta) > 0.0 && abs(eta) <= 2.5) * (pt > 100.0)               * (1.00) + \
    25                     (abs(eta) > 2.5 && abs(eta) <= 5.0) * (pt > 20.0 && pt <= 50.0)  * (1.10) + \
    26                     (abs(eta) > 2.5 && abs(eta) <= 5.0) * (pt > 50.0 && pt <= 100.0) * (1.05) + \
     20
     21
     22  set ScaleFormula {(abs(eta) > 0.0 && abs(eta) <= 2.5) * (pt > 20.0 && pt <= 50.0)  * (1.10) +
     23                    (abs(eta) > 0.0 && abs(eta) <= 2.5) * (pt > 50.0 && pt <= 100.0) * (1.05) +
     24                    (abs(eta) > 0.0 && abs(eta) <= 2.5) * (pt > 100.0)               * (1.00) +
     25                    (abs(eta) > 2.5 && abs(eta) <= 5.0) * (pt > 20.0 && pt <= 50.0)  * (1.10) +
     26                    (abs(eta) > 2.5 && abs(eta) <= 5.0) * (pt > 50.0 && pt <= 100.0) * (1.05) +
    2727                    (abs(eta) > 2.5 && abs(eta) <= 5.0) * (pt > 100.0)               * (1.00)}
    2828
     
    3131
    3232
    33  
     33
    3434*/
    3535
     
    3939{
    4040  TH1 *fJetPT;
    41  
     41
    4242  TH1 *fJetRes_Pt_20_50_Eta_0_25;
    4343  TH1 *fJetRes_Pt_20_50_Eta_25_5;
     
    7272    "jet_pt", "p_{T}^{jet}",
    7373    "p_{T}^{jet}  GeV/c", "number of jets",
    74     100, 0.0, 1000.0);   
    75  
     74    100, 0.0, 1000.0);
     75
    7676  plots->fJetRes_Pt_20_50_Eta_0_25 = result->AddHist1D(
    7777    "jet_delta_pt_20_50_cen", "p_{T}^{truth,parton}/p_{T}^{jet} , 20 < p_{T} < 50 , 0 < | #eta | < 2.5 ",
     
    144144
    145145  plots->fJetRes_Pt_500_inf_Eta_25_5->SetStats();
    146  
     146
    147147
    148148}
     
    166166  TLorentzVector JetMom, GenJetMom, BestGenJetMom;
    167167
    168   Float_t Dr; 
     168  Float_t Dr;
    169169  Float_t pt, eta;
    170170  Long64_t entry;
     
    178178    treeReader->ReadEntry(entry);
    179179    //  cout<<"--  New event -- "<<endl;
    180    
     180
    181181    if(entry%500 == 0) cout << "Event number: "<< entry <<endl;
    182    
     182
    183183    // Loop over all reconstructed jets in event
    184184    for(i = 0; i < branchJet->GetEntriesFast(); ++i)
    185185    {
    186      
     186
    187187      jet = (Jet*) branchJet->At(i);
    188188      JetMom = jet-> P4();
    189      
     189
    190190      plots->fJetPT->Fill(JetMom.Pt());
    191      
     191
    192192      Dr = 999;
    193          
     193
    194194     // Loop over all hard partons in event
    195195     for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
    196196     {
    197                
     197
    198198        part = (GenParticle*) branchParticle->At(j);
    199199
    200200        GenJetMom = part -> P4();
    201        
     201
    202202        //this is simply to avoid warnings from initial state particle having infite rapidity ...
    203203        if(GenJetMom.Px() == 0 && GenJetMom.Py() == 0) continue;
    204        
     204
    205205        //take the closest parton candidate
    206206        if( GenJetMom.DeltaR(JetMom) < Dr )
     
    208208           Dr = GenJetMom.DeltaR(JetMom);
    209209           BestGenJetMom = GenJetMom;
    210         }   
    211        
     210        }
     211
    212212      }
    213213
    214      if(Dr < 0.3) 
     214     if(Dr < 0.3)
    215215     {
    216216       pt  = JetMom.Pt();
    217217       eta = TMath::Abs(JetMom.Eta());
    218      
    219        
     218
     219
    220220       if( pt > 20.0 && pt < 50.0 && eta > 0.0 && eta < 2.5 ) plots -> fJetRes_Pt_20_50_Eta_0_25->Fill(BestGenJetMom.Pt()/JetMom.Pt());
    221221       if( pt > 20.0 && pt < 50.0 && eta > 2.5 && eta < 5.0 ) plots -> fJetRes_Pt_20_50_Eta_25_5->Fill(BestGenJetMom.Pt()/JetMom.Pt());
    222        
     222
    223223       if( pt > 50.0 && pt < 100.0 && eta > 0.0 && eta < 2.5 ) plots -> fJetRes_Pt_50_100_Eta_0_25->Fill(BestGenJetMom.Pt()/JetMom.Pt());
    224224       if( pt > 50.0 && pt < 100.0 && eta > 2.5 && eta < 5.0 ) plots -> fJetRes_Pt_50_100_Eta_25_5->Fill(BestGenJetMom.Pt()/JetMom.Pt());
    225        
     225
    226226       if( pt > 100.0 && pt < 200.0 && eta > 0.0 && eta < 2.5 ) plots -> fJetRes_Pt_100_200_Eta_0_25->Fill(BestGenJetMom.Pt()/JetMom.Pt());
    227227       if( pt > 100.0 && pt < 200.0 && eta > 2.5 && eta < 5.0 ) plots -> fJetRes_Pt_100_200_Eta_25_5->Fill(BestGenJetMom.Pt()/JetMom.Pt());
    228        
     228
    229229       if( pt > 200.0 && pt < 500.0 && eta > 0.0 && eta < 2.5 ) plots -> fJetRes_Pt_200_500_Eta_0_25->Fill(BestGenJetMom.Pt()/JetMom.Pt());
    230230       if( pt > 200.0 && pt < 500.0 && eta > 2.5 && eta < 5.0 ) plots -> fJetRes_Pt_200_500_Eta_25_5->Fill(BestGenJetMom.Pt()/JetMom.Pt());
    231      
     231
    232232       if( pt > 500.0               && eta > 0.0 && eta < 2.5 ) plots -> fJetRes_Pt_500_inf_Eta_0_25->Fill(BestGenJetMom.Pt()/JetMom.Pt());
    233233       if( pt > 500.0               && eta > 2.5 && eta < 5.0 ) plots -> fJetRes_Pt_500_inf_Eta_25_5->Fill(BestGenJetMom.Pt()/JetMom.Pt());
    234        
    235    
     234
     235
    236236     }
    237      
    238    
    239     } 
     237
     238
     239    }
    240240  }
    241241}
Note: See TracChangeset for help on using the changeset viewer.