CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/SLHCUpgradeSimulations/L1CaloTrigger/plugins/CaloTriggerAnalyzerOnDataTrees.cc

Go to the documentation of this file.
00001 
00002 #include "SLHCUpgradeSimulations/L1CaloTrigger/plugins/CaloTriggerAnalyzerOnDataTrees.h"
00003 #include "Math/GenVector/VectorUtil.h"
00004 #include <iostream>
00005 #include <iomanip>
00006 
00007 
00008 CaloTriggerAnalyzerOnDataTrees::CaloTriggerAnalyzerOnDataTrees(const edm::ParameterSet& iConfig):
00009   vertices_(iConfig.getParameter<edm::InputTag>("VertexCollection")),
00010   SLHCsrc_(iConfig.getParameter<edm::InputTag>("SLHCsrc")),
00011   LHCsrc_(iConfig.getParameter<edm::InputTag>("LHCsrc")),
00012   LHCisosrc_(iConfig.getParameter<edm::InputTag>("LHCisosrc")),
00013   electrons_(iConfig.getParameter<edm::InputTag>("electrons")),
00014   iso_(iConfig.getParameter<double>("iso")),
00015   DR_(iConfig.getParameter<double>("deltaR")),
00016   threshold_(iConfig.getParameter<double>("threshold"))
00017 {
00018   //now do what ever initialization is needed
00019 
00020   edm::Service<TFileService> fs;
00021 
00022   RRTree = fs->make<TTree>("RRTree","Tree containing RAW RECO info");
00023 
00024   RRTree->Branch("RecoEpt",&RecoEpt);
00025   RRTree->Branch("RecoEeta",&RecoEeta);
00026   RRTree->Branch("RecoEphi",&RecoEphi);
00027 
00028   RRTree->Branch("LHCL1pt",&LHCL1pt);
00029   RRTree->Branch("LHCL1eta",&LHCL1eta);
00030   RRTree->Branch("LHCL1phi",&LHCL1phi);
00031 
00032   RRTree->Branch("SLHCL1pt",&SLHCL1pt);
00033   RRTree->Branch("SLHCL1eta",&SLHCL1eta);
00034   RRTree->Branch("SLHCL1phi",&SLHCL1phi);
00035   RRTree->Branch("Vertices",&numVertices);
00036 
00037   RECOpt       = fs->make<TH1F>( "RECOpt"   , "RECOpt",  20  ,  0. , 100. );
00038   LHCpt       = fs->make<TH1F>( "LHCpt"   , "LHCpt",  20  ,  0. , 100. );
00039   SLHCpt       = fs->make<TH1F>( "SLHCpt" , "SLHCpt", 20  ,  0. , 100. );
00040   pt       = fs->make<TH1F>( "pt"      , "pt", 20  ,  0. , 100. );
00041   highestPt= fs->make<TH1F>( "highestPt"      , "highestPt", 50  ,  0. , 100. );
00042 
00043 
00044   SLHChighestPt= fs->make<TH1F>( "SLHChighestPt"      , "SLHChighestPt", 50  ,  0. , 100. );
00045   SLHCsecondPt = fs->make<TH1F>( "SLHCsecondHighestPt", "SLHCsecondHighestPt", 50  ,  0. , 100. );
00046   LHChighestPt= fs->make<TH1F>( "LHChighestPt"      , "LHChighestPt", 50  ,  0. , 100. );
00047   LHCsecondPt = fs->make<TH1F>( "LHCsecondHighestPt", "LHCsecondHighestPt", 50  ,  0. , 100. );
00048 
00049   
00050 }
00051 
00052 
00053 CaloTriggerAnalyzerOnDataTrees::~CaloTriggerAnalyzerOnDataTrees()
00054 {
00055 
00056   // do anything here that needs to be done at destruction time
00057   // (e.g. close files, deallocate resources etc.)
00058 
00059 }
00060 
00061 
00062 //
00063 // member functions
00064 //
00065 
00066 // ------------ method called to for each event  ------------
00067 void
00068 CaloTriggerAnalyzerOnDataTrees::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00069 {
00070   edm::Handle<edm::View<reco::Candidate> > LHCsrc;
00071   edm::Handle<edm::View<reco::Candidate> > SLHCsrc;
00072   edm::Handle<edm::View<reco::Candidate> > LHCisosrc;
00073 
00074   edm::Handle<reco::GsfElectronCollection> electrons;
00075   edm::Handle<reco::VertexCollection> vertices;
00076   iEvent.getByLabel(vertices_, vertices);
00077   
00078   bool gotLHCsrc = iEvent.getByLabel(LHCsrc_,LHCsrc);
00079   bool gotSLHCsrc = iEvent.getByLabel(SLHCsrc_,SLHCsrc);
00080   bool gotLHCisosrc = iEvent.getByLabel(LHCisosrc_,LHCisosrc);
00081   bool gotRecoE = iEvent.getByLabel(electrons_,electrons);
00082 
00083     
00085   
00086   if(gotRecoE) {
00087     highRecoPt=0;
00088     //    secondPtf=0;
00089 
00090     numVertices = vertices->size();
00091     printf("Vertices: %f \n",numVertices);
00092     for(unsigned int i=1; i<electrons->size();++i){
00093       RecoEpt = -50;      
00094       RecoEeta = -50;
00095       RecoEphi = -50;
00096       
00097       bool passID = false;
00098       
00099       if((electrons->at(i).dr04TkSumPt() + electrons->at(i).dr04EcalRecHitSumEt() + electrons->at(i).dr04HcalTowerSumEt())/(electrons->at(i).pt())<0.15)//
00100         if(electrons->at(i).isEB()||electrons->at(i).isEE()) 
00101           if(fabs(electrons->at(i).sigmaIetaIeta())<0.025)  //sigmaEtaEta_[type]) 
00102             if(fabs(electrons->at(i).deltaEtaSuperClusterTrackAtVtx())<0.02)  //deltaEta_[type]) 
00103               if(fabs(electrons->at(i).deltaPhiSuperClusterTrackAtVtx())<0.1)//deltaPhi_[type]) 
00104                 if(fabs(electrons->at(i).hcalOverEcal())<0.01)    //hoE_[type])
00105                   {printf("\n Electrons pass ID\n");
00106                     if((electrons->at(i).dr03TkSumPt()+electrons->at(i).dr03EcalRecHitSumEt()+electrons->at(i).dr03HcalDepth1TowerSumEt())/electrons->at(i).pt()<0.15)
00107                       {
00108                         passID=true;
00109                         printf("\n Electrons Isolated!\n");}
00110                   }
00111       
00112       
00113             if(passID == true){
00114               RECOpt->Fill(electrons->at(i).pt());
00115               RecoEpt=electrons->at(i).pt();
00116               
00117               RecoEeta=electrons->at(i).eta();
00118               RecoEphi=electrons->at(i).phi();
00119               //printf("RecoPt=%f\n",RecoEpt);
00120               //printf("RecoEta=%f\n",RecoEeta);
00121               //printf("RecoPhi=%f\n",RecoEphi);
00122               LHCL1pt=-20;
00123               LHCL1eta=-20;
00124               LHCL1phi=-20;
00125               SLHCL1pt=-20;
00126               SLHCL1eta=-20;
00127               SLHCL1phi=-20;
00128               
00129               highPt=0;
00130               highEta=0;
00131               highPhi=0;
00133           
00134               if(gotSLHCsrc) {
00135         
00136                 secondPtf=0;
00137                 for(edm::View<reco::Candidate>::const_iterator j = SLHCsrc->begin(); j!= SLHCsrc->end();++j)
00138                   {
00139                     if(ROOT::Math::VectorUtil::DeltaR(electrons->at(i).p4(),j->p4())<DR_) {
00140                       if (j->pt()>highPt){
00141                         secondPtf=highPt;
00142                         highPt = j->pt();
00143                         SLHCL1pt=j->pt();
00144                         SLHCL1eta=j->eta();
00145                         SLHCL1phi=j->phi();
00146 
00147                       } 
00148                       else if (j->pt()>secondPtf){
00149                         secondPtf=j->pt();
00150                       }
00151                     }
00152         
00153                     SLHCpt->Fill(j->pt());
00154                   }
00155 
00156               }
00157 
00158               LHCL1pt =0;          
00159               LHCL1eta = 0;
00160               LHCL1phi = 0;
00161 
00162               if(gotLHCisosrc||gotLHCsrc) {
00163                 highPt = 0;
00164                 highPhi= -30;
00165                 highEta= -30;
00166                 secondPtf=0;
00167                 for(edm::View<reco::Candidate>::const_iterator l = LHCisosrc->begin(); l!= LHCisosrc->end();++l)
00168                   {
00169                     if(ROOT::Math::VectorUtil::DeltaR(electrons->at(i).p4(),l->p4())<DR_) {
00170                       if (l->pt()>highPt)
00171                         {
00172                           secondPtf = highPt;
00173                           highPt=l->pt();
00174                           LHCL1pt  = l->pt();
00175                           LHCL1eta = l->eta();
00176                           LHCL1phi = l->phi();
00177                           //printf("LHCiso_highpt=%f\n",highPt);
00178                         } 
00179                     }
00180                     //LHCpt->Fill(l->pt());
00181                     
00182                   }
00183 
00184                 if(iso_==0){
00185                 for(edm::View<reco::Candidate>::const_iterator j = LHCsrc->begin(); j!= LHCsrc->end();++j)
00186                   {
00187                     if(ROOT::Math::VectorUtil::DeltaR(electrons->at(i).p4(),j->p4())<DR_) {
00188                       if (j->pt()>highPt)
00189                         {
00190                           secondPtf = highPt;
00191                           highPt = j->pt();
00192                           LHCL1pt  = j->pt();
00193                           LHCL1eta = j->eta();
00194                           LHCL1phi = j->phi();
00195                           // printf("LHCnonIsohighpt=%f\n",highPt);
00196                         } 
00197                       else if (j->pt()>secondPtf){
00198                         secondPtf=j->pt();
00199                       }
00200                     }
00201                     LHCpt->Fill(j->pt());
00202                   }
00203                 }
00204               }//gotLHCisosrc
00205 
00206 
00207               if(RecoEpt>0){
00208                 //if(iso_==1){printf("Isolated Particles\n");}
00209 
00210                 //printf("\n reco pt: %f \n reco eta: %f \n reco phi: %f \n LHC pt: %f \n LHC eta: %f \n LHC phi: %f \n SLHC pt: %f \n SLHC eta: %f \n SLHC phi: %f \n",RecoEpt,RecoEeta,RecoEphi,LHCL1pt,LHCL1eta,LHCL1phi,SLHCL1pt,SLHCL1eta,SLHCL1phi);
00211               }
00212               RRTree->Fill();         
00213             }//passID==true
00214 
00215 
00216             //printf("\n Filling!!\n");
00217     }//electron Cands
00218 
00219   }
00220   
00221   
00222   else
00223         RECOpt->Fill(0.0);
00224   
00225 }
00226 
00227 
00228 
00229 void CaloTriggerAnalyzerOnDataTrees::matchSLHC(const reco::Candidate * recoCAND){
00232   // (To be completed)
00233 
00234 
00235 
00236 
00237 }
00238 
00239 DEFINE_FWK_MODULE(CaloTriggerAnalyzerOnDataTrees);