CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/HLTrigger/HLTanalyzers/src/HLTAnalyzer.cc

Go to the documentation of this file.
00001 // File: HLTAnalyzer.cc
00002 // Description:  Example of Analysis driver originally from Jeremy Mans, 
00003 // Date:  13-October-2006
00004 
00005 #include <boost/foreach.hpp>
00006 
00007 #include "HLTrigger/HLTanalyzers/interface/HLTAnalyzer.h"
00008 #include "HLTMessages.h"
00009 
00010 typedef std::pair<const char *, const edm::InputTag *> MissingCollectionInfo;
00011 
00012 template <class T>
00013 static inline
00014 bool getCollection(const edm::Event & event, std::vector<MissingCollectionInfo> & missing, edm::Handle<T> & handle, const edm::InputTag & name, const char * description) 
00015 {
00016     event.getByLabel(name, handle);
00017     bool valid = handle.isValid();
00018     if (not valid) {
00019         missing.push_back( std::make_pair(description, & name) );
00020         handle.clear();
00021     }
00022     return valid;
00023 }
00024 
00025 // Boiler-plate constructor definition of an analyzer module:
00026 HLTAnalyzer::HLTAnalyzer(edm::ParameterSet const& conf) {
00027     
00028     // If your module takes parameters, here is where you would define
00029     // their names and types, and access them to initialize internal
00030     // variables. Example as follows:
00031     std::cout << " Beginning HLTAnalyzer Analysis " << std::endl;
00032     
00033     recjets_          = conf.getParameter<edm::InputTag> ("recjets");
00034     reccorjets_       = conf.getParameter<edm::InputTag> ("reccorjets");
00035     genjets_          = conf.getParameter<edm::InputTag> ("genjets");
00036     recmet_           = conf.getParameter<edm::InputTag> ("recmet");
00037     genmet_           = conf.getParameter<edm::InputTag> ("genmet");
00038     ht_               = conf.getParameter<edm::InputTag> ("ht");
00039     recoPFJets_       = conf.getParameter<edm::InputTag> ("recoPFJets"); 
00040     calotowers_       = conf.getParameter<edm::InputTag> ("calotowers");
00041     muon_             = conf.getParameter<edm::InputTag> ("muon");
00042     mctruth_          = conf.getParameter<edm::InputTag> ("mctruth");
00043     genEventInfo_     = conf.getParameter<edm::InputTag> ("genEventInfo");
00044     simhits_          = conf.getParameter<edm::InputTag> ("simhits");
00045     xSection_         = conf.getUntrackedParameter<double> ("xSection",1.);
00046     filterEff_        = conf.getUntrackedParameter<double> ("filterEff",1.);
00047     firstLumi_        = conf.getUntrackedParameter<int> ("firstLumi",0);
00048     lastLumi_         = conf.getUntrackedParameter<int> ("lastLumi",-1);
00049     towerThreshold_   = conf.getParameter<double>("caloTowerThreshold");
00050        
00051     // keep this separate from l1extramc_ as needed by FastSim:
00052     //    This is purposefully done this way to allow FastSim to run with OpenHLT: 
00053     //    The {FastSim+OpenHLT} package runs on the head of HLTrigger/HLTanalyzers 
00054     //    where there is purposefully this duplication because FastSim does the 
00055     //    simulation of muons seperately, and needs the same collection. 
00056     l1extramu_        = conf.getParameter<std::string>   ("l1extramu");
00057     m_l1extramu       = edm::InputTag(l1extramu_, "");
00058     
00059     // read the L1Extra collection name, and add the instance names as needed
00060     l1extramc_        = conf.getParameter<std::string>   ("l1extramc");
00061     m_l1extraemi      = edm::InputTag(l1extramc_, "Isolated");
00062     m_l1extraemn      = edm::InputTag(l1extramc_, "NonIsolated");
00063     m_l1extrajetc     = edm::InputTag(l1extramc_, "Central");
00064     m_l1extrajetf     = edm::InputTag(l1extramc_, "Forward");
00065     m_l1extrataujet   = edm::InputTag(l1extramc_, "Tau");
00066     m_l1extramet      = edm::InputTag(l1extramc_, "MET");
00067     m_l1extramht      = edm::InputTag(l1extramc_, "MHT");
00068     
00069     hltresults_       = conf.getParameter<edm::InputTag> ("hltresults");
00070     gtReadoutRecord_  = conf.getParameter<edm::InputTag> ("l1GtReadoutRecord");
00071     
00072     gctBitCounts_        = edm::InputTag( conf.getParameter<edm::InputTag>("l1GctHFBitCounts").label(), "" );
00073     gctRingSums_         = edm::InputTag( conf.getParameter<edm::InputTag>("l1GctHFRingSums").label(), "" );
00074     
00075     MuCandTag2_          = conf.getParameter<edm::InputTag> ("MuCandTag2");
00076     MuIsolTag2_          = conf.getParameter<edm::InputTag> ("MuIsolTag2");
00077     MuNoVtxCandTag2_     = conf.getParameter<edm::InputTag> ("MuNoVtxCandTag2");
00078     MuCandTag3_          = conf.getParameter<edm::InputTag> ("MuCandTag3");
00079     MuIsolTag3_          = conf.getParameter<edm::InputTag> ("MuIsolTag3");
00080     oniaPixelTag_        = conf.getParameter<edm::InputTag> ("OniaPixelTag");
00081     oniaTrackTag_        = conf.getParameter<edm::InputTag> ("OniaTrackTag");
00082     HLTTau_              = conf.getParameter<edm::InputTag> ("HLTTau");
00083     PFTau_               = conf.getParameter<edm::InputTag> ("HLTPFTau");
00084     _MinPtChargedHadrons = conf.getParameter<double>("minPtChargedHadronsForTaus");
00085     _MinPtGammas         = conf.getParameter<double>("minPtGammassForTaus");
00086 
00087     PFJets_          = conf.getParameter<edm::InputTag> ("HLTPFJet");
00088     
00089     // offline reco tau collection and discriminators
00090     RecoPFTau_                          = conf.getParameter<edm::InputTag> ("RecoPFTau");
00091     RecoPFTauDiscrByTanCOnePercent_     = conf.getParameter<edm::InputTag> ("RecoPFTauDiscrByTanCOnePercent"); 
00092     RecoPFTauDiscrByTanCHalfPercent_    = conf.getParameter<edm::InputTag> ("RecoPFTauDiscrByTanCHalfPercent");  
00093     RecoPFTauDiscrByTanCQuarterPercent_ = conf.getParameter<edm::InputTag> ("RecoPFTauDiscrByTanCQuarterPercent");
00094     RecoPFTauDiscrByTanCTenthPercent_   = conf.getParameter<edm::InputTag> ("RecoPFTauDiscrByTanCTenthPercent");
00095     RecoPFTauDiscrByIso_                = conf.getParameter<edm::InputTag> ("RecoPFTauDiscrByIso");  
00096     RecoPFTauAgainstMuon_               = conf.getParameter<edm::InputTag> ("RecoPFTauAgainstMuon");  
00097     RecoPFTauAgainstElec_               = conf.getParameter<edm::InputTag> ("RecoPFTauAgainstElec");  
00098    
00099     
00100     // btag OpenHLT input collections
00101     m_rawBJets                = conf.getParameter<edm::InputTag>("CommonBJetsL2");
00102     m_correctedBJets          = conf.getParameter<edm::InputTag>("CorrectedBJetsL2");
00103     m_lifetimeBJetsL25        = conf.getParameter<edm::InputTag>("LifetimeBJetsL25");
00104     m_lifetimeBJetsL3         = conf.getParameter<edm::InputTag>("LifetimeBJetsL3");
00105     m_softmuonBJetsL25        = conf.getParameter<edm::InputTag>("SoftmuonBJetsL25");
00106     m_softmuonBJetsL3         = conf.getParameter<edm::InputTag>("SoftmuonBJetsL3");
00107     m_performanceBJetsL25     = conf.getParameter<edm::InputTag>("PerformanceBJetsL25");
00108     m_performanceBJetsL3      = conf.getParameter<edm::InputTag>("PerformanceBJetsL3");
00109     
00110     // egamma OpenHLT input collections
00111     Electron_                 = conf.getParameter<edm::InputTag> ("Electron");
00112     Photon_                   = conf.getParameter<edm::InputTag> ("Photon");
00113     CandIso_                  = conf.getParameter<edm::InputTag> ("CandIso");
00114     CandNonIso_               = conf.getParameter<edm::InputTag> ("CandNonIso");
00115     EcalIso_                  = conf.getParameter<edm::InputTag> ("EcalIso");
00116     EcalNonIso_               = conf.getParameter<edm::InputTag> ("EcalNonIso");
00117     HcalIsoPho_               = conf.getParameter<edm::InputTag> ("HcalIsoPho");
00118     HcalNonIsoPho_            = conf.getParameter<edm::InputTag> ("HcalNonIsoPho");
00119     IsoPhoTrackIsol_          = conf.getParameter<edm::InputTag> ("IsoPhoTrackIsol");
00120     NonIsoPhoTrackIsol_       = conf.getParameter<edm::InputTag> ("NonIsoPhoTrackIsol");
00121     IsoElectron_              = conf.getParameter<edm::InputTag> ("IsoElectrons");
00122     NonIsoElectron_           = conf.getParameter<edm::InputTag> ("NonIsoElectrons");
00123     IsoEleHcal_               = conf.getParameter<edm::InputTag> ("HcalIsoEle");
00124     NonIsoEleHcal_            = conf.getParameter<edm::InputTag> ("HcalNonIsoEle");
00125     IsoEleTrackIsol_          = conf.getParameter<edm::InputTag> ("IsoEleTrackIsol");
00126     NonIsoEleTrackIsol_       = conf.getParameter<edm::InputTag> ("NonIsoEleTrackIsol");
00127     L1IsoPixelSeeds_          = conf.getParameter<edm::InputTag> ("PixelSeedL1Iso");
00128     L1NonIsoPixelSeeds_       = conf.getParameter<edm::InputTag> ("PixelSeedL1NonIso");
00129     IsoR9_                    = conf.getParameter<edm::InputTag> ("SpikeCleaningIsol");  
00130     NonIsoR9_                 = conf.getParameter<edm::InputTag> ("SpikeCleaningNonIsol");   
00131     IsoHoverEH_               = conf.getParameter<edm::InputTag> ("HcalForHoverEIsol");
00132     NonIsoHoverEH_            = conf.getParameter<edm::InputTag> ("HcalForHoverENonIsol"); 
00133     IsoR9ID_                  = conf.getParameter<edm::InputTag> ("R9IDIsol");
00134     NonIsoR9ID_               = conf.getParameter<edm::InputTag> ("R9IDNonIsol");
00135     HFECALClusters_           = conf.getParameter<edm::InputTag> ("HFECALClusters"); 
00136     HFElectrons_              = conf.getParameter<edm::InputTag> ("HFElectrons"); 
00137 
00138     // AlCa OpenHLT input collections  
00139     EERecHitTag_              = conf.getParameter<edm::InputTag> ("EERecHits"); 
00140     EBRecHitTag_              = conf.getParameter<edm::InputTag> ("EBRecHits"); 
00141     pi0EBRecHitTag_           = conf.getParameter<edm::InputTag> ("pi0EBRecHits");  
00142     pi0EERecHitTag_           = conf.getParameter<edm::InputTag> ("pi0EERecHits");  
00143     HBHERecHitTag_            = conf.getParameter<edm::InputTag> ("HBHERecHits");  
00144     HORecHitTag_              = conf.getParameter<edm::InputTag> ("HORecHits");  
00145     HFRecHitTag_              = conf.getParameter<edm::InputTag> ("HFRecHits");  
00146     IsoPixelTrackTagL3_       = conf.getParameter<edm::InputTag> ("IsoPixelTracksL3"); 
00147     IsoPixelTrackTagL2_       = conf.getParameter<edm::InputTag> ("IsoPixelTracksL2");
00148     IsoPixelTrackVerticesTag_       = conf.getParameter<edm::InputTag> ("IsoPixelTrackVertices");
00149     
00150     // Track OpenHLT input collections
00151     PixelTracksTagL3_         = conf.getParameter<edm::InputTag> ("PixelTracksL3"); 
00152     
00153     // Reco Vertex collection
00154     VertexTag_                = conf.getParameter<edm::InputTag> ("PrimaryVertices");  
00155     
00156     m_file = 0;   // set to null
00157     errCnt = 0;
00158     
00159     // read run parameters with a default value 
00160     edm::ParameterSet runParameters = conf.getParameter<edm::ParameterSet>("RunParameters");
00161     _HistName = runParameters.getUntrackedParameter<std::string>("HistogramFile", "test.root");
00162     _EtaMin   = runParameters.getUntrackedParameter<double>("EtaMin", -5.2);
00163     _EtaMax   = runParameters.getUntrackedParameter<double>("EtaMax",  5.2);
00164     
00165     
00166     
00167     // open the tree file
00168     m_file = new TFile(_HistName.c_str(), "RECREATE");
00169     if (m_file)
00170         m_file->cd();
00171     
00172     // Initialize the tree
00173     HltTree = new TTree("HltTree", "");
00174     
00175     treeWeight=xSection_*filterEff_;
00176     std::cout << "\n Setting HltTree weight to " << treeWeight << " = " << xSection_ << "*" << filterEff_ << " (cross section * gen filter efficiency)\n" << std::endl;
00177     
00178     // Setup the different analysis
00179     jet_analysis_.setup(conf, HltTree);
00180     bjet_analysis_.setup(conf, HltTree);
00181     elm_analysis_.setup(conf, HltTree);
00182     muon_analysis_.setup(conf, HltTree);
00183     track_analysis_.setup(conf, HltTree);
00184     mct_analysis_.setup(conf, HltTree);
00185     hlt_analysis_.setup(conf, HltTree);
00186     vrt_analysis_.setup(conf, HltTree);
00187     evt_header_.setup(HltTree);
00188 }
00189 
00190 void HLTAnalyzer::beginRun(const edm::Run& run, const edm::EventSetup& c){ 
00191     
00192     hlt_analysis_.beginRun(run, c);
00193 }
00194 
00195 // Boiler-plate "analyze" method declaration for an analyzer module.
00196 void HLTAnalyzer::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) {
00197     
00198     // To get information from the event setup, you must request the "Record"
00199     // which contains it and then extract the object you need
00200     //edm::ESHandle<CaloGeometry> geometry;
00201     //iSetup.get<IdealGeometryRecord>().get(geometry);
00202     
00203     int iLumi = iEvent.luminosityBlock();
00204     if (iLumi<firstLumi_) return;
00205     if (lastLumi_ != -1 && iLumi>lastLumi_) return;
00206     
00207     // These declarations create handles to the types of records that you want
00208     // to retrieve from event "iEvent".
00209     edm::Handle<reco::CaloJetCollection>              recjets;
00210     edm::Handle<reco::CaloJetCollection>              reccorjets;
00211     edm::Handle<reco::GenJetCollection>               genjets;
00212     edm::Handle<CaloTowerCollection>                  caloTowers;
00213     edm::Handle<reco::CaloMETCollection>              recmet;
00214     edm::Handle<reco::GenMETCollection>               genmet;
00215     edm::Handle<reco::METCollection>                  ht;
00216     edm::Handle<reco::PFJetCollection>                recoPFJets; 
00217     edm::Handle<reco::CandidateView>                  mctruth;
00218     edm::Handle<GenEventInfoProduct>                  genEventInfo;
00219     edm::Handle<std::vector<SimTrack> >               simTracks;
00220     edm::Handle<std::vector<SimVertex> >              simVertices;
00221     edm::Handle<reco::MuonCollection>                 muon;
00222     edm::Handle<edm::TriggerResults>                  hltresults;
00223     edm::Handle<l1extra::L1EmParticleCollection>      l1extemi, l1extemn;
00224     edm::Handle<l1extra::L1MuonParticleCollection>    l1extmu;
00225     edm::Handle<l1extra::L1JetParticleCollection>     l1extjetc, l1extjetf, l1exttaujet;
00226     edm::Handle<l1extra::L1EtMissParticleCollection>  l1extmet,l1extmht;
00227     edm::Handle<L1GlobalTriggerReadoutRecord>         l1GtRR;
00228     edm::Handle< L1GctHFBitCountsCollection >         gctBitCounts ;
00229     edm::Handle< L1GctHFRingEtSumsCollection >        gctRingSums ;
00230     
00231     edm::Handle<reco::RecoChargedCandidateCollection> mucands2, mucands3, munovtxcands2;
00232     edm::Handle<reco::RecoChargedCandidateCollection> oniaPixelCands, oniaTrackCands;
00233     edm::Handle<edm::ValueMap<bool> >                 isoMap2,  isoMap3;
00234     edm::Handle<reco::HLTTauCollection>               taus;
00235     edm::Handle<reco::PFTauCollection>               pftaus;
00236     edm::Handle<reco::PFJetCollection>               pfjets;
00237     
00238     // offline reco tau collection and discriminators
00239     edm::Handle<reco::PFTauCollection>  recoPftaus;
00240     edm::Handle<reco::PFTauDiscriminator> theRecoPFTauDiscrByTanCOnePercent;
00241     edm::Handle<reco::PFTauDiscriminator> theRecoPFTauDiscrByTanCHalfPercent; 
00242     edm::Handle<reco::PFTauDiscriminator> theRecoPFTauDiscrByTanCQuarterPercent;
00243     edm::Handle<reco::PFTauDiscriminator> theRecoPFTauDiscrByTanCTenthPercent;
00244     edm::Handle<reco::PFTauDiscriminator> theRecoPFTauDiscrByIsolation;
00245     edm::Handle<reco::PFTauDiscriminator> theRecoPFTauDiscrAgainstMuon;
00246     edm::Handle<reco::PFTauDiscriminator> theRecoPFTauDiscrAgainstElec;
00247    
00248     
00249     // btag OpenHLT input collections
00250     edm::Handle<edm::View<reco::Jet> >                hRawBJets;
00251     edm::Handle<edm::View<reco::Jet> >                hCorrectedBJets;
00252     edm::Handle<reco::JetTagCollection>               hLifetimeBJetsL25;
00253     edm::Handle<reco::JetTagCollection>               hLifetimeBJetsL3;
00254     edm::Handle<reco::JetTagCollection>               hSoftmuonBJetsL25;
00255     edm::Handle<reco::JetTagCollection>               hSoftmuonBJetsL3;
00256     edm::Handle<reco::JetTagCollection>               hPerformanceBJetsL25;
00257     edm::Handle<reco::JetTagCollection>               hPerformanceBJetsL3;
00258     
00259     // egamma OpenHLT input collections
00260     edm::Handle<reco::GsfElectronCollection>          electrons;
00261     edm::Handle<reco::PhotonCollection>               photons;
00262     edm::Handle<reco::RecoEcalCandidateIsolationMap>    photonR9IsoHandle; 
00263     edm::Handle<reco::RecoEcalCandidateIsolationMap>    photonR9NonIsoHandle;
00264     edm::Handle<reco::RecoEcalCandidateIsolationMap>    photonR9IDIsoHandle;
00265     edm::Handle<reco::RecoEcalCandidateIsolationMap>    photonR9IDNonIsoHandle;
00266     edm::Handle<reco::RecoEcalCandidateIsolationMap>  photonHoverEHIsoHandle;   
00267     edm::Handle<reco::RecoEcalCandidateIsolationMap>  photonHoverEHNonIsoHandle;    
00268     edm::Handle<reco::ElectronCollection>             electronIsoHandle;
00269     edm::Handle<reco::ElectronCollection>             electronNonIsoHandle;
00270     edm::Handle<reco::RecoEcalCandidateIsolationMap>    electronR9IsoHandle; 
00271     edm::Handle<reco::RecoEcalCandidateIsolationMap>    electronR9NonIsoHandle;  
00272     edm::Handle<reco::RecoEcalCandidateIsolationMap>    electronR9IDIsoHandle;
00273     edm::Handle<reco::RecoEcalCandidateIsolationMap>    electronR9IDNonIsoHandle;
00274     edm::Handle<reco::ElectronIsolationMap>           NonIsoTrackEleIsolMap;
00275     edm::Handle<reco::ElectronIsolationMap>           TrackEleIsolMap;
00276     edm::Handle<reco::ElectronSeedCollection>         L1IsoPixelSeedsMap;
00277     edm::Handle<reco::ElectronSeedCollection>         L1NonIsoPixelSeedsMap;
00278     edm::Handle<reco::RecoEcalCandidateCollection>    recoIsolecalcands;
00279     edm::Handle<reco::RecoEcalCandidateCollection>    recoNonIsolecalcands;
00280     edm::Handle<reco::RecoEcalCandidateIsolationMap>  EcalIsolMap;
00281     edm::Handle<reco::RecoEcalCandidateIsolationMap>  EcalNonIsolMap;
00282     edm::Handle<reco::RecoEcalCandidateIsolationMap>  HcalEleIsolMap;
00283     edm::Handle<reco::RecoEcalCandidateIsolationMap>  HcalEleNonIsolMap;
00284     edm::Handle<reco::RecoEcalCandidateIsolationMap>  HcalIsolMap;
00285     edm::Handle<reco::RecoEcalCandidateIsolationMap>  HcalNonIsolMap;
00286     edm::Handle<reco::RecoEcalCandidateIsolationMap>  TrackIsolMap;
00287     edm::Handle<reco::RecoEcalCandidateIsolationMap>  TrackNonIsolMap;
00288     edm::Handle<reco::SuperClusterCollection>         electronHFClusterHandle; 
00289     edm::Handle<reco::RecoEcalCandidateCollection>    electronHFElectronHandle;  
00290     
00291     // AlCa OpenHLT input collections   
00292     edm::Handle<EBRecHitCollection>             ebrechits;  
00293     edm::Handle<EERecHitCollection>             eerechits;   
00294     edm::Handle<EBRecHitCollection>             pi0ebrechits;   
00295     edm::Handle<EERecHitCollection>             pi0eerechits;    
00296     edm::Handle<HBHERecHitCollection>           hbherechits;   
00297     edm::Handle<HORecHitCollection>             horechits;   
00298     edm::Handle<HFRecHitCollection>             hfrechits;   
00299     edm::Handle<reco::IsolatedPixelTrackCandidateCollection> isopixeltracksL3; 
00300     edm::Handle<reco::IsolatedPixelTrackCandidateCollection> isopixeltracksL2;  
00301     edm::Handle<reco::VertexCollection>         isopixeltrackPixVertices;
00302     edm::Handle<reco::RecoChargedCandidateCollection> pixeltracksL3; 
00303     
00304     // Reco vertex collection
00305     edm::Handle<reco::VertexCollection> recoVertexs;
00306     
00307     // new stuff for the egamma EleId
00308     edm::InputTag ecalRechitEBTag (std::string("hltEcalRegionalEgammaRecHit:EcalRecHitsEB"));
00309     edm::InputTag ecalRechitEETag (std::string("hltEcalRegionalEgammaRecHit:EcalRecHitsEE"));
00310     EcalClusterLazyTools lazyTools( iEvent, iSetup, ecalRechitEBTag, ecalRechitEETag);
00311     
00312     edm::ESHandle<MagneticField>                theMagField;
00313     iSetup.get<IdealMagneticFieldRecord>().get(theMagField);
00314     
00315     edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00316     edm::InputTag BSProducer_(std::string("hltOnlineBeamSpot"));
00317     
00318     // get EventSetup stuff needed for the AlCa pi0 path
00319     edm::ESHandle< EcalElectronicsMapping > ecalmapping;
00320     iSetup.get< EcalMappingRcd >().get(ecalmapping);
00321     
00322     edm::ESHandle<CaloGeometry> geoHandle;
00323     iSetup.get<CaloGeometryRecord>().get(geoHandle); 
00324     
00325     edm::ESHandle<CaloTopology> pTopology;
00326     iSetup.get<CaloTopologyRecord>().get(pTopology);
00327     
00328     edm::ESHandle<L1CaloGeometry> l1CaloGeom ;
00329     iSetup.get<L1CaloGeometryRecord>().get(l1CaloGeom) ;
00330     
00331     
00332     // extract the collections from the event, check their validity and log which are missing
00333     std::vector<MissingCollectionInfo> missing;
00334     
00335     //get the BeamSpot
00336     getCollection( iEvent, missing, recoBeamSpotHandle,       BSProducer_ ,          "Beam Spot handle");
00337     // gets its position
00338     reco::BeamSpot::Point BSPosition(0,0,0);
00339     BSPosition = recoBeamSpotHandle->position();
00340     
00341     getCollection( iEvent, missing, recjets,         recjets_,           kRecjets );
00342     getCollection( iEvent, missing, reccorjets,      reccorjets_,        kRecCorjets );
00343     getCollection( iEvent, missing, genjets,         genjets_,           kGenjets );
00344     getCollection( iEvent, missing, recmet,          recmet_,            kRecmet );
00345     getCollection( iEvent, missing, genmet,          genmet_,            kGenmet );
00346     getCollection( iEvent, missing, caloTowers,      calotowers_,        kCaloTowers );
00347     getCollection( iEvent, missing, ht,              ht_,                kHt );
00348     getCollection( iEvent, missing, recoPFJets,      recoPFJets_,        kRecoPFJets );   
00349     getCollection( iEvent, missing, muon,            muon_,              kMuon );
00350     getCollection( iEvent, missing, taus,            HLTTau_,            kTaus );
00351     getCollection( iEvent, missing, pftaus,          PFTau_,             kPFTaus );
00352     getCollection( iEvent, missing, pfjets,          PFJets_,            kPFJets );  
00353     getCollection( iEvent, missing, recoPftaus,                            RecoPFTau_,                          kRecoPFTaus );
00354     getCollection( iEvent, missing, theRecoPFTauDiscrByTanCOnePercent,     RecoPFTauDiscrByTanCOnePercent_,     ktheRecoPFTauDiscrByTanCOnePercent); 
00355     getCollection( iEvent, missing, theRecoPFTauDiscrByTanCHalfPercent,    RecoPFTauDiscrByTanCHalfPercent_,    ktheRecoPFTauDiscrByTanCHalfPercent); 
00356     getCollection( iEvent, missing, theRecoPFTauDiscrByTanCQuarterPercent, RecoPFTauDiscrByTanCQuarterPercent_, ktheRecoPFTauDiscrByTanCQuarterPercent); 
00357     getCollection( iEvent, missing, theRecoPFTauDiscrByTanCTenthPercent,   RecoPFTauDiscrByTanCTenthPercent_,   ktheRecoPFTauDiscrByTanCTenthPercent);     
00358     getCollection( iEvent, missing, theRecoPFTauDiscrByIsolation,          RecoPFTauDiscrByIso_,                ktheRecoPFTauDiscrByIsolation); 
00359     getCollection( iEvent, missing, theRecoPFTauDiscrAgainstMuon,          RecoPFTauAgainstMuon_,               ktheRecoPFTauDiscrAgainstMuon); 
00360     getCollection( iEvent, missing, theRecoPFTauDiscrAgainstElec,          RecoPFTauAgainstElec_,               ktheRecoPFTauDiscrAgainstElec); 
00361     getCollection( iEvent, missing, hltresults,      hltresults_,        kHltresults );
00362     getCollection( iEvent, missing, l1extemi,        m_l1extraemi,       kL1extemi );
00363     getCollection( iEvent, missing, l1extemn,        m_l1extraemn,       kL1extemn );
00364     getCollection( iEvent, missing, l1extmu,         m_l1extramu,        kL1extmu );
00365     getCollection( iEvent, missing, l1extjetc,       m_l1extrajetc,      kL1extjetc );
00366     getCollection( iEvent, missing, l1extjetf,       m_l1extrajetf,      kL1extjetf );
00367     getCollection( iEvent, missing, l1exttaujet,     m_l1extrataujet,    kL1exttaujet );
00368     getCollection( iEvent, missing, l1extmet,        m_l1extramet,       kL1extmet );
00369     getCollection( iEvent, missing, l1extmht,        m_l1extramht,       kL1extmht );
00370     getCollection( iEvent, missing, l1GtRR,          gtReadoutRecord_,   kL1GtRR );
00371     getCollection( iEvent, missing, gctBitCounts,     gctBitCounts_,      kL1GctBitCounts );
00372     getCollection( iEvent, missing, gctRingSums,      gctRingSums_,       kL1GctRingSums );
00373     getCollection( iEvent, missing, mctruth,         mctruth_,           kMctruth );
00374     getCollection( iEvent, missing, simTracks,       simhits_,           kSimhit );
00375     getCollection( iEvent, missing, simVertices,     simhits_,           kSimhit );
00376     getCollection( iEvent, missing, genEventInfo,    genEventInfo_,      kGenEventInfo );
00377     getCollection( iEvent, missing, mucands2,        MuCandTag2_,        kMucands2 );
00378     getCollection( iEvent, missing, munovtxcands2,   MuNoVtxCandTag2_,   kMunovtxcands2 ); 
00379     getCollection( iEvent, missing, mucands3,        MuCandTag3_,        kMucands3 );
00380     getCollection( iEvent, missing, oniaPixelCands,        oniaPixelTag_,        kOniaPixelCands );
00381     getCollection( iEvent, missing, oniaTrackCands,        oniaTrackTag_,        kOniaTrackCands );
00382     getCollection( iEvent, missing, isoMap2,         MuIsolTag2_,        kIsoMap2 );
00383     getCollection( iEvent, missing, isoMap3,         MuIsolTag3_,        kIsoMap3 );
00384     getCollection( iEvent, missing, hRawBJets,                m_rawBJets,                 kBTagJets );
00385     getCollection( iEvent, missing, hCorrectedBJets,          m_correctedBJets,           kBTagCorrectedJets );
00386     getCollection( iEvent, missing, hLifetimeBJetsL25,        m_lifetimeBJetsL25,         kBTagLifetimeBJetsL25 );
00387     getCollection( iEvent, missing, hLifetimeBJetsL3,         m_lifetimeBJetsL3,          kBTagLifetimeBJetsL3 );
00388     getCollection( iEvent, missing, hSoftmuonBJetsL25,        m_softmuonBJetsL25,         kBTagSoftmuonBJetsL25 );
00389     getCollection( iEvent, missing, hSoftmuonBJetsL3,         m_softmuonBJetsL3,          kBTagSoftmuonBJetsL3 );
00390     getCollection( iEvent, missing, hPerformanceBJetsL25,     m_performanceBJetsL25,      kBTagPerformanceBJetsL25 );
00391     getCollection( iEvent, missing, hPerformanceBJetsL3,      m_performanceBJetsL3,       kBTagPerformanceBJetsL3 );
00392     getCollection( iEvent, missing, electrons,                Electron_,                  kElectrons );
00393     getCollection( iEvent, missing, photons,                  Photon_,                    kPhotons );
00394     
00395     //Read offline eleID results
00396     std::vector<edm::Handle<edm::ValueMap<float> > > eIDValueMap(4); 
00397     //   edm::InputTag electronLabelRobustTight_(std::string("eidRobustTight"));
00398     //   edm::InputTag electronLabelTight_(std::string("eidTight"));
00399     //   edm::InputTag electronLabelRobustLoose_(std::string("eidRobustLoose"));
00400     //   edm::InputTag electronLabelLoose_(std::string("eidLoose"));
00401     //   getCollection( iEvent, missing, eIDValueMap[0],   electronLabelRobustLoose_      ,       "EleId Robust-Loose");
00402     //   getCollection( iEvent, missing, eIDValueMap[1],   electronLabelRobustTight_      ,       "EleId Robust-Tight");
00403     //   getCollection( iEvent, missing, eIDValueMap[2],   electronLabelLoose_      ,       "EleId Loose");
00404     //   getCollection( iEvent, missing, eIDValueMap[3],   electronLabelTight_      ,       "EleId Tight");
00405     
00406     //read all the OpenHLT egamma collections
00407     getCollection( iEvent, missing, recoIsolecalcands,        CandIso_,                   kCandIso);
00408     getCollection( iEvent, missing, recoNonIsolecalcands,     CandNonIso_,                kCandNonIso);
00409     getCollection( iEvent, missing, EcalIsolMap,              EcalIso_,                   kEcalIso);
00410     getCollection( iEvent, missing, EcalNonIsolMap,           EcalNonIso_,                kEcalNonIso);
00411     getCollection( iEvent, missing, HcalIsolMap,              HcalIsoPho_,                kHcalIsoPho);
00412     getCollection( iEvent, missing, HcalNonIsolMap,           HcalNonIsoPho_,             kHcalNonIsoPho);
00413     getCollection( iEvent, missing, photonR9IsoHandle,        IsoR9_,                     kIsoR9); 
00414     getCollection( iEvent, missing, photonR9NonIsoHandle,     NonIsoR9_,                  kNonIsoR9);  
00415     getCollection( iEvent, missing, photonR9IDIsoHandle,      IsoR9ID_,                   kIsoR9ID);
00416     getCollection( iEvent, missing, photonR9IDNonIsoHandle,   NonIsoR9ID_,                kNonIsoR9ID);
00417     getCollection( iEvent, missing, photonHoverEHIsoHandle,   IsoHoverEH_,                kIsoHoverEH);    
00418     getCollection( iEvent, missing, photonHoverEHNonIsoHandle,NonIsoHoverEH_,             kNonIsoHoverEH);   
00419     getCollection( iEvent, missing, electronIsoHandle,        IsoElectron_,               kIsoElectron);
00420     getCollection( iEvent, missing, HcalEleIsolMap,           IsoEleHcal_,                kIsoEleHcal);
00421     getCollection( iEvent, missing, TrackEleIsolMap,          IsoEleTrackIsol_,           kIsoEleTrackIsol);
00422     getCollection( iEvent, missing, L1IsoPixelSeedsMap,       L1IsoPixelSeeds_,           kL1IsoPixelSeeds);
00423     getCollection( iEvent, missing, L1NonIsoPixelSeedsMap,    L1NonIsoPixelSeeds_,        kL1NonIsoPixelSeeds);
00424     getCollection( iEvent, missing, electronNonIsoHandle,     NonIsoElectron_,            kNonIsoElectron);
00425     getCollection( iEvent, missing, HcalEleNonIsolMap,        NonIsoEleHcal_,             kIsoEleHcal);
00426     getCollection( iEvent, missing, NonIsoTrackEleIsolMap,    NonIsoEleTrackIsol_,        kNonIsoEleTrackIsol);
00427     getCollection( iEvent, missing, TrackNonIsolMap,          NonIsoPhoTrackIsol_,        kNonIsoPhoTrackIsol);
00428     getCollection( iEvent, missing, TrackIsolMap,             IsoPhoTrackIsol_,           kIsoPhoTrackIsol);
00429     getCollection( iEvent, missing, electronR9IsoHandle,      IsoR9_,                     kIsoR9);  
00430     getCollection( iEvent, missing, electronR9NonIsoHandle,   NonIsoR9_,                  kNonIsoR9);   
00431     getCollection( iEvent, missing, electronR9IDIsoHandle,    IsoR9ID_,                   kIsoR9ID);
00432     getCollection( iEvent, missing, electronR9IDNonIsoHandle, NonIsoR9ID_,                kNonIsoR9ID);
00433     getCollection( iEvent, missing, electronHFClusterHandle,  HFECALClusters_,            kHFECALClusters); 
00434     getCollection( iEvent, missing, electronHFElectronHandle, HFElectrons_,               kHFElectrons); 
00435     getCollection( iEvent, missing, eerechits,                EERecHitTag_,               kEErechits ); 
00436     getCollection( iEvent, missing, ebrechits,                EBRecHitTag_,               kEBrechits );  
00437     getCollection( iEvent, missing, pi0eerechits,             pi0EERecHitTag_,            kpi0EErechits );  
00438     getCollection( iEvent, missing, pi0ebrechits,             pi0EBRecHitTag_,            kpi0EBrechits );   
00439     getCollection( iEvent, missing, hbherechits,              HBHERecHitTag_,             kHBHErechits );   
00440     getCollection( iEvent, missing, horechits,                HORecHitTag_,               kHOrechits );   
00441     getCollection( iEvent, missing, hfrechits,                HFRecHitTag_,               kHFrechits );   
00442     getCollection( iEvent, missing, isopixeltracksL3,         IsoPixelTrackTagL3_,        kIsoPixelTracksL3 ); 
00443     getCollection( iEvent, missing, isopixeltracksL2,         IsoPixelTrackTagL2_,        kIsoPixelTracksL2 );
00444     getCollection( iEvent, missing, isopixeltrackPixVertices, IsoPixelTrackVerticesTag_,   kIsoPixelTrackVertices );
00445     getCollection( iEvent, missing, pixeltracksL3,            PixelTracksTagL3_,          kPixelTracksL3 ); 
00446     getCollection( iEvent, missing, recoVertexs,              VertexTag_,                 kRecoVertices ); 
00447     
00448   
00449     
00450     double ptHat=-1.;
00451     if (genEventInfo.isValid()) {ptHat=genEventInfo->qScale();}
00452     
00453     
00454     // print missing collections
00455     if (not missing.empty() and (errCnt < errMax())) {
00456         errCnt++;
00457         std::stringstream out;       
00458         out <<  "OpenHLT analyser - missing collections:";
00459         BOOST_FOREACH(const MissingCollectionInfo & entry, missing)
00460         out << "\n\t" << entry.first << ": " << entry.second->encode();
00461         edm::LogPrint("OpenHLT") << out.str() << std::endl; 
00462         if (errCnt == errMax())
00463             edm::LogWarning("OpenHLT") << "Maximum error count reached -- No more messages will be printed.";
00464     }
00465     
00466     // run the analysis, passing required event fragments
00467     jet_analysis_.analyze(
00468                           recjets,
00469                           reccorjets,
00470                           genjets,
00471                           recmet,
00472                           genmet,
00473                           ht,
00474                           taus,
00475                           pftaus,
00476                           pfjets,
00477                           recoPftaus,
00478                           theRecoPFTauDiscrByTanCOnePercent,
00479                           theRecoPFTauDiscrByTanCHalfPercent,
00480                           theRecoPFTauDiscrByTanCQuarterPercent,
00481                           theRecoPFTauDiscrByTanCTenthPercent,
00482                           theRecoPFTauDiscrByIsolation,
00483                           theRecoPFTauDiscrAgainstMuon,
00484                           theRecoPFTauDiscrAgainstElec,
00485                           recoPFJets, 
00486                           caloTowers,
00487                           towerThreshold_,
00488                           _MinPtGammas,
00489                           _MinPtChargedHadrons,
00490                           HltTree);
00491     
00492     muon_analysis_.analyze(
00493                            muon,
00494                            l1extmu,
00495                            mucands2,
00496                            isoMap2,
00497                            mucands3,
00498                            isoMap3,
00499                            oniaPixelCands,
00500                            oniaTrackCands,
00501                            munovtxcands2,
00502                            BSPosition,
00503                            HltTree);
00504     
00505     elm_analysis_.analyze(
00506                           electrons,
00507                           photons,
00508                           electronIsoHandle,
00509                           electronNonIsoHandle,
00510                           NonIsoTrackEleIsolMap,
00511                           TrackEleIsolMap,
00512                           L1IsoPixelSeedsMap,
00513                           L1NonIsoPixelSeedsMap,
00514                           recoIsolecalcands,
00515                           recoNonIsolecalcands,
00516                           EcalIsolMap,
00517                           EcalNonIsolMap,
00518                           HcalEleIsolMap,
00519                           HcalEleNonIsolMap,
00520                           HcalIsolMap,
00521                           HcalNonIsolMap,
00522                           TrackIsolMap,
00523                           TrackNonIsolMap,
00524                           lazyTools,
00525                           theMagField,
00526                           BSPosition,
00527                           eIDValueMap,
00528                           photonR9IsoHandle, 
00529                           photonR9NonIsoHandle, 
00530                           electronR9IsoHandle, 
00531                           electronR9NonIsoHandle, 
00532                           photonHoverEHIsoHandle,  
00533                           photonHoverEHNonIsoHandle,  
00534                           photonR9IDIsoHandle,
00535                           photonR9IDNonIsoHandle,
00536                           electronR9IDIsoHandle,
00537                           electronR9IDNonIsoHandle,
00538                           electronHFClusterHandle,
00539                           electronHFElectronHandle,
00540                           HltTree);
00541     
00542     mct_analysis_.analyze(
00543                           mctruth,
00544                           ptHat,
00545                           simTracks,
00546                           simVertices,
00547                           HltTree);
00548     
00549     track_analysis_.analyze( 
00550                             isopixeltracksL3, 
00551                             isopixeltracksL2,
00552                             isopixeltrackPixVertices,                     
00553                             pixeltracksL3, 
00554                             HltTree); 
00555     
00556     hlt_analysis_.analyze(
00557                           hltresults,
00558                           l1extemi,
00559                           l1extemn,
00560                           l1extmu,
00561                           l1extjetc,
00562                           l1extjetf,
00563                           l1exttaujet,
00564                           l1extmet,
00565                           l1extmht,
00566                           l1GtRR,
00567                           gctBitCounts,
00568                           gctRingSums,
00569                           iSetup,
00570                           iEvent,
00571                           HltTree);
00572     
00573     bjet_analysis_.analyze(
00574                            hRawBJets, 
00575                            hCorrectedBJets,
00576                            hLifetimeBJetsL25,
00577                            hLifetimeBJetsL3,
00578                            hSoftmuonBJetsL25,
00579                            hSoftmuonBJetsL3,
00580                            hPerformanceBJetsL25,
00581                            hPerformanceBJetsL3,
00582                            HltTree);
00583     
00584     vrt_analysis_.analyze(
00585                           recoVertexs, 
00586                           HltTree);
00587     
00588     evt_header_.analyze(iEvent, HltTree);
00589     
00590     
00591     // std::cout << " Ending Event Analysis" << std::endl;
00592     // After analysis, fill the variables tree
00593     if (m_file)
00594         m_file->cd();
00595     HltTree->Fill();
00596 }
00597 
00598 // "endJob" is an inherited method that you may implement to do post-EOF processing and produce final output.
00599 void HLTAnalyzer::endJob() {
00600     
00601     if (m_file)
00602         m_file->cd();
00603     
00604     const edm::ParameterSet &thepset = edm::getProcessParameterSet();   
00605     TList *list = HltTree->GetUserInfo();   
00606     list->Add(new TObjString(thepset.dump().c_str()));   
00607     
00608     HltTree->SetWeight(treeWeight);
00609     HltTree->Write();
00610     delete HltTree;
00611     HltTree = 0;
00612     
00613     if (m_file) {         // if there was a tree file...
00614         m_file->Write();    // write out the branches
00615         delete m_file;      // close and delete the file
00616         m_file = 0;         // set to zero to clean up
00617     }
00618     
00619 }