Fork me on GitHub

Changeset 55 in svn for trunk/Delphes.cpp


Ignore:
Timestamp:
Nov 27, 2008, 3:05:11 PM (16 years ago)
Author:
severine ovyn
Message:

1file ->several

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Delphes.cpp

    r49 r55  
    1919#include "Utilities/ExRootAnalysis/interface/ExRootTreeBranch.h"
    2020
    21 #include "H_BeamParticle.h"
    22 #include "H_BeamLine.h"
    23 #include "H_RomanPot.h"
    24 
    2521#include "interface/DataConverter.h"
    2622#include "interface/HEPEVTConverter.h"
     
    2925
    3026#include "interface/SmearUtil.h"
    31 #include "Utilities/Fastjet/include/fastjet/PseudoJet.hh"
    32 #include "Utilities/Fastjet/include/fastjet/ClusterSequence.hh"
    33 
    34 // get info on how fastjet was configured
    35 #include "Utilities/Fastjet/include/fastjet/config.h"
    36 
    37 // make sure we have what is needed
    38 #ifdef ENABLE_PLUGIN_SISCONE
    39 #  include "Utilities/Fastjet/plugins/SISCone/SISConePlugin.hh"
    40 #endif
    41 #ifdef ENABLE_PLUGIN_CDFCONES
    42 #  include "Utilities/Fastjet/plugins/CDFCones/CDFMidPointPlugin.hh"
    43 #  include "Utilities/Fastjet/plugins/CDFCones/CDFJetCluPlugin.hh"
    44 #endif
    45 
    46 #include<vector>
    47 #include<iostream>
    48 
    49 
     27#include "interface/BFieldProp.h"
     28#include "interface/TriggerUtil.h"
     29#include "interface/VeryForward.h"
     30#include "interface/JetUtils.h"
     31
     32#include <vector>
     33#include <iostream>
    5034
    5135using namespace std;
     
    6852{
    6953  int appargc = 2;
    70   char *appName = "JetsSim";
     54  char *appName = "Delphes";
    7155  char *appargv[] = {appName, "-b"};
    7256  TApplication app(appName, &appargc, appargv);
     
    10387  string DetDatacard("");
    10488  if(argc==4)  DetDatacard =argv[3];
     89
     90  //Smearing information
    10591  RESOLution *DET = new RESOLution();
    10692  DET->ReadDataCard(DetDatacard);
    10793  DET->Logfile(LogName);
    10894
    109   todo(LogName.c_str());
     95  //Trigger information
     96  Trigger *TRIG = new Trigger();
     97  TRIG->TriggerReader("data/trigger.dat");
     98
     99  //Propagation of tracks in the B field
     100  TrackPropagation *TRACP = new TrackPropagation();
     101
     102  //Jet information
     103  JetsUtil *JETRUN = new JetsUtil();
     104
     105  //VFD information
     106  VeryForward * VFD = new VeryForward();
     107
     108  //todo(LogName.c_str());
    110109 
    111110  DataConverter *converter=0;
     
    163162  TRootMuon *elementMu;
    164163  TRootPhoton *elementPhoton;
    165   TRootJet *elementJet;
    166   TRootTauJet *elementTauJet;
    167164  TRootTracks *elementTracks;
    168165  TRootCalo *elementCalo;
    169   TRootZdcHits *elementZdc;
    170   TRootRomanPotHits *elementRP220, *elementFP420;
    171166 
    172167  TLorentzVector genMomentum(0,0,0,0);
    173168  TLorentzVector genMomentumCalo(0,0,0,0);
    174169  LorentzVector jetMomentum;
     170 
     171  vector<fastjet::PseudoJet> input_particles;//for FastJet algorithm
     172  vector<fastjet::PseudoJet> sorted_jets;
     173
    175174  vector<TLorentzVector> TrackCentral; 
    176175  vector<PhysicsTower> towers;
    177   vector<fastjet::PseudoJet> input_particles;//for FastJet algorithm
    178   vector<fastjet::PseudoJet> inclusive_jets;
    179   vector<fastjet::PseudoJet> sorted_jets;
    180176 
    181177  vector<TLorentzVector> electron;
     
    185181  TSimpleArray<TRootGenParticle> NFCentralQ;
    186182 
    187   //Initialisation of Hector
    188   extern bool relative_energy;
    189   relative_energy = true; // should always be true
    190   extern int kickers_on;
    191   kickers_on = 1;         // should always be 1
    192  
    193   // user should provide : (1) optics file for each beamline, and IPname,
    194   // and offset data (s,x) for optical elements
    195   H_BeamLine* beamline1 = new H_BeamLine(1,500.);
    196   beamline1->fill("data/LHCB1IR5_v6.500.tfs",1,"IP5");
    197   beamline1->offsetElements(120,-0.097);
    198   H_RomanPot * rp220_1 = new H_RomanPot("rp220_1",220,2000); // RP 220m, 2mm, beam 1
    199   H_RomanPot * rp420_1 = new H_RomanPot("rp420_1",420,4000); // RP 420m, 4mm, beam 1
    200   beamline1->add(rp220_1);
    201   beamline1->add(rp420_1);
    202  
    203   H_BeamLine* beamline2 = new H_BeamLine(1,500.);
    204   beamline2->fill("data/LHCB1IR5_v6.500.tfs",-1,"IP5");
    205   beamline2->offsetElements(120,+0.097);
    206   H_RomanPot * rp220_2 = new H_RomanPot("rp220_2",220,2000);// RP 220m, 2mm, beam 2
    207   H_RomanPot * rp420_2 = new H_RomanPot("rp420_2",420,4000);// RP 420m, 4mm, beam 2
    208   beamline2->add(rp220_2);
    209   beamline2->add(rp420_2);
    210  
    211   // we will have four jet definitions, and the first three will be
    212   // plugins
    213   fastjet::JetDefinition jet_def;
    214   fastjet::JetDefinition::Plugin * plugins;
    215  
    216   switch(DET->JETALGO) {
    217   default:
    218   case 1: {
    219    
    220     // set up a CDF midpoint jet definition
    221 #ifdef ENABLE_PLUGIN_CDFCONES
    222     plugins = new fastjet::CDFJetCluPlugin(DET->SEEDTHRESHOLD,DET->CONERADIUS,DET->C_ADJACENCYCUT,DET->C_MAXITERATIONS,DET->C_IRATCH,DET->OVERLAPTHRESHOLD);
    223     jet_def = fastjet::JetDefinition(plugins);
    224 #else
    225     plugins = NULL;
    226 #endif
    227   }
    228     break;
    229    
    230   case 2: {
    231    
    232     // set up a CDF midpoint jet definition
    233 #ifdef ENABLE_PLUGIN_CDFCONES
    234     plugins = new fastjet::CDFMidPointPlugin (DET->SEEDTHRESHOLD,DET->CONERADIUS,DET->M_CONEAREAFRACTION,DET->M_MAXPAIRSIZE,DET->M_MAXITERATIONS,DET->OVERLAPTHRESHOLD);
    235     jet_def = fastjet::JetDefinition(plugins);
    236 #else
    237     plugins = NULL;
    238 #endif
    239   }
    240     break;
    241   case 3: {
    242     // set up a siscone jet definition
    243 #ifdef ENABLE_PLUGIN_SISCONE
    244     plugins = new fastjet::SISConePlugin (DET->CONERADIUS,DET->OVERLAPTHRESHOLD,DET->NPASS, DET->PROTOJET_PTMIN);
    245     jet_def = fastjet::JetDefinition(plugins);
    246 #else
    247     plugins = NULL;
    248 #endif
    249   }
    250     break;
    251    
    252   case 4: {
    253     jet_def = fastjet::JetDefinition(fastjet::kt_algorithm, DET->CONERADIUS);
    254   }
    255     break;
    256    
    257   case 5: {
    258     jet_def = fastjet::JetDefinition(fastjet::cambridge_algorithm,DET->CONERADIUS);
    259   }
    260     break;
    261    
    262   case 6: {
    263     jet_def = fastjet::JetDefinition(fastjet::antikt_algorithm,DET->CONERADIUS);
    264   }
    265     break;
    266   }
    267  
     183
     184
    268185  // Loop over all events
    269186  Long64_t entry, allEntries = treeReader->GetEntries();
     
    286203      towers.clear();
    287204      input_particles.clear();
    288       inclusive_jets.clear();
    289       sorted_jets.clear();
    290205     
    291206      // Loop over all particles in event
     
    294209          genMomentum.SetPxPyPzE(particle->Px, particle->Py, particle->Pz, particle->E);
    295210         
    296           int pid = abs(particle->PID);
    297           float eta = fabs(particle->Eta);
    298          
     211          int pid = abs(particle->PID);
     212          float eta = fabs(genMomentum.Eta());
     213
    299214          //subarray of the quarks (i.e. not final particles, i.e status not equal to 1)
    300215          // in the tracker (i.e. for those we know the tracks)
     
    312227          // keeps only final particles, visible by the central detector, including the fiducial volume
    313228          // the ordering of conditions have been optimised for speed : put first the STATUS condition
     229          //
     230          //
    314231          if( (particle->Status == 1)    &&
    315232              (
     
    318235                )
    319236              ) {
    320             switch(pid) {
     237          //  TRACP->Propagation(particle,genMomentum);
     238            eta = fabs(genMomentum.Eta());
     239            switch(pid) {
    321240             
    322241            case pE: // all electrons with eta < DET->MAX_CALO_FWD
     
    363282            }
    364283           
    365            
    366284            // all final charged particles
    367285            if(
    368286               ((rand()%100) < DET->TRACKING_EFF)  &&
    369287               (genMomentum.E()!=0) &&
    370                (fabs(particle->Eta) < DET->MAX_TRACKER) &&
     288               (fabs(genMomentum.Eta()) < DET->MAX_TRACKER) &&
    371289               (genMomentum.Pt() > DET->PT_TRACKS_MIN ) &&     // pt too small to be taken into account
    372290               (pid != pGAMMA)    &&
     
    386304          } // switch
    387305         
    388           // Forward particles in CASTOR ?
    389           /*      if (particle->Status == 1 && (fabs(particle->Eta) > DET->MIN_CALO_VFWD)
    390                   && (fabs(particle->Eta) < DET->MAX_CALO_VFWD)) {
    391                  
    392                  
    393                   } // CASTOR
    394           */
    395           // Zero degree calorimeter, for forward neutrons and photons
    396           if (particle->Status ==1 && (pid == pN || pid == pGAMMA ) && eta > DET->MIN_ZDC ) {
    397             // !!!!!!!!! vérifier que particle->Z est bien en micromÚtres!!!
    398             // !!!!!!!!! vérifier que particle->T est bien en secondes!!!
    399             // !!!!!!!!! pas de smearing ! on garde trop d'info !
    400             elementZdc = (TRootZdcHits*) branchZDC->NewEntry();
    401             elementZdc->Set(genMomentum);
    402            
    403             // time of flight t is t = T + d/[ cos(theta) v ]
    404             //double tx = acos(particle->Px/particle->Pz);
    405             //double ty = acos(particle->Py/particle->Pz);
    406             //double theta = (1E-6)*sqrt( pow(tx,2) + pow(ty,2) );
    407             //double flight_distance = (DET->ZDC_S - particle->Z*(1E-6))/cos(theta) ; // assumes that Z is in micrometers
    408             double flight_distance = (DET->ZDC_S - particle->Z*(1E-6));
    409             // assumes also that the emission angle is so small that 1/(cos theta) = 1
    410             elementZdc->T = 0*particle->T + flight_distance/speed_of_light; // assumes highly relativistic particles
    411             elementZdc->side = sign(particle->Eta);
    412            
    413           }
    414          
    415           // if forward proton
    416           if( (pid == pP)  && (particle->Status == 1) &&  (fabs(particle->Eta) > DET->MAX_CALO_FWD) )
    417             {
    418               // !!!!!!!! put here particle->CHARGE and particle->MASS
    419               H_BeamParticle p1; /// put here particle->CHARGE and particle->MASS
    420               p1.smearAng();
    421               p1.smearPos();
    422               p1.setPosition(p1.getX()-500.,p1.getY(),p1.getTX()-1*kickers_on*CRANG,p1.getTY(),0);
    423               p1.set4Momentum(particle->Px,particle->Py,particle->Pz,particle->E);
    424              
    425               H_BeamLine *beamline;
    426               if(particle->Eta >0) beamline = beamline1;
    427               else beamline = beamline2;
    428              
    429               p1.computePath(beamline,1);
    430              
    431               if(p1.stopped(beamline)) {
    432                 if (p1.getStoppingElement()->getName()=="rp220_1" || p1.getStoppingElement()->getName()=="rp220_2") {
    433                   p1.propagate(DET->RP220_S);
    434                   elementRP220 = (TRootRomanPotHits*) branchRP220->NewEntry();
    435                   elementRP220->X  = (1E-6)*p1.getX();  // [m]
    436                   elementRP220->Y  = (1E-6)*p1.getY();  // [m]
    437                   elementRP220->Tx = (1E-6)*p1.getTX(); // [rad]
    438                   elementRP220->Ty = (1E-6)*p1.getTY(); // [rad]
    439                   elementRP220->S = p1.getS();          // [m]
    440                   elementRP220->T = -1;                 // not yet implemented
    441                   elementRP220->E = p1.getE();  // not yet implemented
    442                   elementRP220->q2 = -1;                // not yet implemented
    443                   elementRP220->side = sign(particle->Eta);
    444                  
    445                 } else if (p1.getStoppingElement()->getName()=="rp420_1" || p1.getStoppingElement()->getName()=="rp420_2") {
    446                   p1.propagate(DET->FP420_S);
    447                   elementFP420 = (TRootRomanPotHits*) branchFP420->NewEntry();
    448                   elementFP420->X  = (1E-6)*p1.getX();  // [m]
    449                   elementFP420->Y  = (1E-6)*p1.getY();  // [m]
    450                   elementFP420->Tx = (1E-6)*p1.getTX(); // [rad]
    451                   elementFP420->Ty = (1E-6)*p1.getTY(); // [rad]
    452                   elementFP420->S = p1.getS();        // [m]
    453                   elementFP420->T = -1;                       // not yet implemented
    454                   elementFP420->E = p1.getE();          // not yet implemented
    455                   elementFP420->q2 = -1;                // not yet implemented
    456                   elementFP420->side = sign(particle->Eta);
    457                 }
    458               }
    459              
    460               //                if(p1.stopped(beamline) && (p1.getStoppingElement()->getS() > 100))
    461               //                        cout << "Eloss ="  << 7000.-p1.getE() << " ; " << p1.getStoppingElement()->getName() << endl;
    462             } // if forward proton
     306          VFD->ZDC(treeWriter,branchZDC,particle);
     307          VFD->RomanPots(treeWriter,branchRP220,branchFP420,particle);
    463308         
    464309        } // while
     
    497342      //*****************************
    498343     
    499       // run the jet clustering with the above jet definition
    500       if(input_particles.size()!=0)
    501         {
    502           fastjet::ClusterSequence clust_seq(input_particles, jet_def);
    503           // extract the inclusive jets with pt > 5 GeV
    504           double ptmin = 5.0;
    505           inclusive_jets = clust_seq.inclusive_jets(ptmin);
    506           // sort jets into increasing pt
    507           sorted_jets = sorted_by_pt(inclusive_jets);
    508         }
    509       for (unsigned int i = 0; i < sorted_jets.size(); i++) {
    510         TLorentzVector JET;
    511         JET.SetPxPyPzE(sorted_jets[i].px(),sorted_jets[i].py(),sorted_jets[i].pz(),sorted_jets[i].E());
    512         // Tau jet identification : 1! track and electromagnetic collimation
    513         if(fabs(JET.Eta()) < (DET->MAX_TRACKER - DET->TAU_CONE_TRACKS)) {
    514           double Energie_tau_central = DET->EnergySmallCone(towers,JET.Eta(),JET.Phi());
    515           if(
    516              ( Energie_tau_central/JET.E() > DET->TAU_EM_COLLIMATION ) &&
    517              ( DET->NumTracks(TrackCentral,DET->PT_TRACK_TAU,JET.Eta(),JET.Phi()) == 1 ) &&
    518              ( JET.Pt() > DET->TAUJET_pt)
    519              ) {
    520             elementTauJet = (TRootTauJet*) branchTauJet->NewEntry();
    521             elementTauJet->Set(JET);
    522           } // if tau jet
    523         } // if JET.eta < tracker - tau_cone : Tau jet identification
    524        
    525         if(JET.Pt() > DET->JET_pt)
    526           {
    527             elementJet = (TRootJet*) branchJet->NewEntry();
    528             elementJet->Set(JET);
    529             // b-jets
    530             bool btag=false;
    531             if((fabs(JET.Eta()) < DET->MAX_TRACKER && DET->Btaggedjet(JET, NFCentralQ)))btag=true;
    532             elementJet->Btag = btag;
    533           }
    534       } // for itJet : loop on all jets
    535      
     344      sorted_jets=JETRUN->RunJets(input_particles);
     345      JETRUN->RunJetBtagging(treeWriter, branchJet,sorted_jets,NFCentralQ);
     346      JETRUN->RunTauJets(treeWriter,branchTauJet,sorted_jets,towers, TrackCentral);
     347
     348
    536349      treeWriter->Fill();
     350
    537351      // Add here the trigger
    538352      // Should test all the trigger table on the event, based on reconstructed objects
     353     
     354 //     Trigger *TRIG = new Trigger();
     355 //     TRIG->TriggerReader("data/trigger.dat");
     356     
    539357    } // Loop over all events
     358
    540359  treeWriter->Write();
    541360 
Note: See TracChangeset for help on using the changeset viewer.