CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 
00002 #include "SLHCUpgradeSimulations/L1CaloTrigger/plugins/CaloTriggerAnalyzerOnData.h"
00003 #include "Math/GenVector/VectorUtil.h"
00004 #include <iostream>
00005 #include <iomanip>
00006 
00007 
00008 CaloTriggerAnalyzerOnData::CaloTriggerAnalyzerOnData(const edm::ParameterSet& iConfig):
00009   SLHCsrc_(iConfig.getParameter<edm::InputTag>("SLHCsrc")),
00010   LHCsrc_(iConfig.getParameter<edm::InputTag>("LHCsrc")),
00011   LHCisosrc_(iConfig.getParameter<edm::InputTag>("LHCisosrc")),
00012   iso_(iConfig.getParameter<double>("iso"))
00013 {
00014   //now do what ever initialization is needed
00015 
00016   edm::Service<TFileService> fs;
00017 
00018   LHCpt       = fs->make<TH1F>( "LHCpt"   , "LHCpt",  20  ,  0. , 100. );
00019   SLHCpt       = fs->make<TH1F>( "SLHCpt" , "SLHCpt", 20  ,  0. , 100. );
00020   pt       = fs->make<TH1F>( "pt"      , "pt", 20  ,  0. , 100. );
00021   highestPt= fs->make<TH1F>( "highestPt"      , "highestPt", 50  ,  0. , 100. );
00022   secondPt = fs->make<TH1F>( "secondHighestPt", "secondHighestPt", 50  ,  0. , 100. );
00023 
00024   SLHChighestPt= fs->make<TH1F>( "SLHChighestPt"      , "SLHChighestPt", 50  ,  0. , 100. );
00025   SLHCsecondPt = fs->make<TH1F>( "SLHCsecondHighestPt", "SLHCsecondHighestPt", 50  ,  0. , 100. );
00026   LHChighestPt= fs->make<TH1F>( "LHChighestPt"      , "LHChighestPt", 50  ,  0. , 100. );
00027   LHCsecondPt = fs->make<TH1F>( "LHCsecondHighestPt", "LHCsecondHighestPt", 50  ,  0. , 100. );
00028 
00029   
00030 }
00031 
00032 
00033 CaloTriggerAnalyzerOnData::~CaloTriggerAnalyzerOnData()
00034 {
00035 
00036    // do anything here that needs to be done at destruction time
00037    // (e.g. close files, deallocate resources etc.)
00038 
00039 }
00040 
00041 
00042 //
00043 // member functions
00044 //
00045 
00046 // ------------ method called to for each event  ------------
00047 void
00048 CaloTriggerAnalyzerOnData::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00049 {
00050   //  std::cout << src_ << std::endl;
00051   //  edm::Handle<edm::View<reco::Candidate> > ref;
00052   //edm::Handle<edm::View<reco::Candidate> > src;
00053   edm::Handle<edm::View<reco::Candidate> > LHCsrc;
00054   edm::Handle<edm::View<reco::Candidate> > SLHCsrc;
00055   edm::Handle<edm::View<reco::Candidate> > LHCisosrc;
00056 
00057 
00058   //bool gotRef = iEvent.getByLabel(ref_,ref);
00059   //Bool gotSrc = iEvent.getByLabel(src_,src);
00060   bool gotLHCsrc = iEvent.getByLabel(LHCsrc_,LHCsrc);
00061   bool gotSLHCsrc = iEvent.getByLabel(SLHCsrc_,SLHCsrc);
00062   bool gotLHCisosrc = iEvent.getByLabel(LHCisosrc_,LHCisosrc);
00063 
00064 
00065   if(iso_==1){
00066     if(gotLHCisosrc) {
00067       highPt=0;
00068       secondPtf=0;
00069       for(edm::View<reco::Candidate>::const_iterator i = LHCisosrc->begin(); i!= LHCisosrc->end();++i)
00070         {
00071           LHCpt->Fill(i->pt());
00072           if (i->pt()>highPt){
00073             secondPtf=highPt;
00074             highPt=i->pt();
00075           } else if (i->pt()>secondPtf){
00076             secondPtf=i->pt();
00077           }
00078         }
00079     
00080       if(LHCisosrc->size()>0){
00081         LHChighestPt->Fill(highPt);
00082         printf("LHCsrc highpt= %f \n",highPt);
00083       }
00084         else
00085         LHChighestPt->Fill(0.0);
00086 
00087       if(LHCisosrc->size()>1)
00088         LHCsecondPt->Fill(secondPtf);
00089       else
00090         LHCsecondPt->Fill(0.0);
00091     }
00092   }
00093 
00094 
00095   if(iso_==0){
00096       highPt=0;
00097       secondPtf=0;
00098 
00099       if(gotLHCsrc) {
00100         for(edm::View<reco::Candidate>::const_iterator i = LHCsrc->begin(); i!= LHCsrc->end();++i)
00101           {
00102             LHCpt->Fill(i->pt());
00103             if (i->pt()>highPt){
00104               secondPtf=highPt;
00105               highPt=i->pt();
00106               //printf("LHCsrc highpt= %f \n",highPt);
00107             } else if (i->pt()>secondPtf){
00108               secondPtf=i->pt();
00109             }
00110           }
00111       }
00112 
00113       if(gotLHCisosrc) {
00114         //printf("Got Isolated LHC \n");
00115         for(edm::View<reco::Candidate>::const_iterator j = LHCisosrc->begin(); j!= LHCisosrc->end();++j)
00116           {
00117             //printf("LHCisosrc highpt= %f \n",highPt);
00118             if (j->pt()>highPt){
00119               secondPtf=highPt;
00120               highPt=j->pt();
00121 
00122             } else if (j->pt()>secondPtf){
00123               secondPtf=j->pt();
00124             }
00125           }
00126       }
00127       
00128       LHChighestPt->Fill(highPt);
00129       //printf("LHCsrc highpt= %f \n",highPt);
00130 
00131       LHCsecondPt->Fill(secondPtf);
00132   }
00133 
00134   if(iso_ == 1 )
00135     printf("\n LHC ISO highPT:%f \n",highPt);
00136   else
00137     printf("\n LHC highPT:%f \n",highPt);
00138   
00139   if(gotSLHCsrc){
00140     highPt=0;
00141     secondPtf=0;
00142     for(edm::View<reco::Candidate>::const_iterator i = SLHCsrc->begin(); i!= SLHCsrc->end();++i)
00143       {
00144         SLHCpt->Fill(i->pt());
00145         if (i->pt()>highPt){
00146           secondPtf=highPt;
00147           highPt=i->pt();
00148         } else if (i->pt()>secondPtf){
00149           secondPtf=i->pt();
00150         }
00151       }
00152 
00153 
00154     //if(highPt != highPtold){
00155     if(SLHCsrc->size()>0){
00156       SLHChighestPt->Fill(highPt);
00157     }
00158     else
00159       SLHChighestPt->Fill(0.0);
00160 
00161 
00162     if(SLHCsrc->size()>1)
00163       SLHCsecondPt->Fill(secondPtf);
00164     else
00165       SLHCsecondPt->Fill(0.0);
00166     
00167       if(iso_ == 1 )
00168         printf("\n SLHC ISO highPT:%f \n",highPt);
00169       else
00170         printf("\n SLHC highPT:%f \n",highPt);
00171 
00172   }
00173     
00174   
00175 
00176 
00177 }
00178 
00179 DEFINE_FWK_MODULE(CaloTriggerAnalyzerOnData);