CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTBitAnalyzer.cc
Go to the documentation of this file.
1 // File: HLTBitAnalyzer.cc
2 // Description: Example of Analysis driver originally from Jeremy Mans,
3 // Date: 13-October-2006
4 
5 #include <boost/foreach.hpp>
6 
8 #include "HLTMessages.h"
11 
12 typedef std::pair<const char *, const edm::InputTag *> MissingCollectionInfo;
13 
14 template <class T>
15 static inline
16 bool getCollection(const edm::Event & event, std::vector<MissingCollectionInfo> & missing, edm::Handle<T> & handle, const edm::InputTag & name, const char * description)
17 {
18  event.getByLabel(name, handle);
19  bool valid = handle.isValid();
20  if (not valid) {
21  missing.push_back( std::make_pair(description, & name) );
22  handle.clear();
23  }
24  return valid;
25 }
26 
27 // Boiler-plate constructor definition of an analyzer module:
29 
30  // If your module takes parameters, here is where you would define
31  // their names and types, and access them to initialize internal
32  // variables. Example as follows:
33  std::cout << " Beginning HLTBitAnalyzer Analysis " << std::endl;
34 
35  l1extramu_ = conf.getParameter<std::string> ("l1extramu");
37 
38  // read the L1Extra collection name, and add the instance names as needed
39  l1extramc_ = conf.getParameter<std::string> ("l1extramc");
40  m_l1extraemi = edm::InputTag(l1extramc_, "Isolated");
41  m_l1extraemn = edm::InputTag(l1extramc_, "NonIsolated");
44  m_l1extrajet = edm::InputTag("gctInternJetProducer","Internal","ANALYSIS");
48 
49  mctruth_ = conf.getParameter<edm::InputTag> ("mctruth");
50  genEventInfo_ = conf.getParameter<edm::InputTag> ("genEventInfo");
51  VertexTagOffline0_ = conf.getParameter<edm::InputTag> ("OfflinePrimaryVertices0");
52  simhits_ = conf.getParameter<edm::InputTag> ("simhits");
53 
54  hltresults_ = conf.getParameter<edm::InputTag> ("hltresults");
55  gtReadoutRecord_ = conf.getParameter<edm::InputTag> ("l1GtReadoutRecord");
56  gtObjectMap_ = conf.getParameter<edm::InputTag> ("l1GtObjectMapRecord");
57 
58  gctBitCounts_ = edm::InputTag( conf.getParameter<edm::InputTag>("l1GctHFBitCounts").label(), "" );
59  gctRingSums_ = edm::InputTag( conf.getParameter<edm::InputTag>("l1GctHFRingSums").label(), "" );
60 
61  pileupInfo_ = edm::InputTag("addPileupInfo");
62 
63  _UseTFileService = conf.getUntrackedParameter<bool>("UseTFileService",false);
64 
65  m_file = 0; // set to null
66  errCnt = 0;
67 
68  // read run parameters with a default value
70  _HistName = runParameters.getUntrackedParameter<std::string>("HistogramFile", "test.root");
71 
72  // open the tree file and initialize the tree
73  if(_UseTFileService){
75  HltTree = fs->make<TTree>("HltTree", "");
76  }else{
77  m_file = new TFile(_HistName.c_str(), "RECREATE");
78  if (m_file)
79  m_file->cd();
80  HltTree = new TTree("HltTree", "");
81  }
82 
83  // Setup the different analysis
86  vrt_analysisOffline0_.setup(conf, HltTree, "Offline0");
88 }
89 
90 // Boiler-plate "analyze" method declaration for an analyzer module.
92 
96  edm::Handle<l1extra::L1JetParticleCollection> l1extjetc, l1extjetf, l1extjet, l1exttaujet;
103 
108  edm::Handle<reco::VertexCollection> recoVertexsOffline0;
110 
111  // extract the collections from the event, check their validity and log which are missing
112  std::vector<MissingCollectionInfo> missing;
113 
114  getCollection( iEvent, missing, hltresults, hltresults_, kHltresults );
115  getCollection( iEvent, missing, l1extemi, m_l1extraemi, kL1extemi );
116  getCollection( iEvent, missing, l1extemn, m_l1extraemn, kL1extemn );
117  getCollection( iEvent, missing, l1extmu, m_l1extramu, kL1extmu );
118  getCollection( iEvent, missing, l1extjetc, m_l1extrajetc, kL1extjetc );
119  getCollection( iEvent, missing, l1extjetf, m_l1extrajetf, kL1extjetf );
120  getCollection( iEvent, missing, l1extjet, m_l1extrajet, kL1extjet );
121  getCollection( iEvent, missing, l1exttaujet, m_l1extrataujet, kL1exttaujet );
122  getCollection( iEvent, missing, l1extmet, m_l1extramet, kL1extmet );
123  getCollection( iEvent, missing, l1extmht, m_l1extramht, kL1extmht );
124  getCollection( iEvent, missing, l1GtRR, gtReadoutRecord_, kL1GtRR );
125  getCollection( iEvent, missing, l1GtOMRec, gtObjectMap_, kL1GtOMRec );
126  getCollection( iEvent, missing, gctBitCounts, gctBitCounts_, kL1GctBitCounts );
127  getCollection( iEvent, missing, gctRingSums, gctRingSums_, kL1GctRingSums );
128 
129  getCollection( iEvent, missing, mctruth, mctruth_, kMctruth );
130  getCollection( iEvent, missing, simTracks, simhits_, kSimhit );
131  getCollection( iEvent, missing, simVertices, simhits_, kSimhit );
132  getCollection( iEvent, missing, genEventInfo, genEventInfo_, kGenEventInfo );
133  getCollection( iEvent, missing, pupInfo, pileupInfo_, kPileupInfo );
134 
135  getCollection( iEvent, missing, recoVertexsOffline0, VertexTagOffline0_, kRecoVerticesOffline0 );
136  double ptHat=-1.;
137  if (genEventInfo.isValid()) {ptHat=genEventInfo->qScale();}
138 
139  //edm::ESHandle<LumiCorrectionParam> lumicorrdatahandle; //get LumiCorrectionParam object from event setup
140  //iSetup.getData(lumicorrdatahandle);
141 
142  // print missing collections
143  if (not missing.empty() and (errCnt < errMax())) {
144  errCnt++;
145  std::stringstream out;
146  out << "OpenHLT analyser - missing collections:";
147  BOOST_FOREACH(const MissingCollectionInfo & entry, missing)
148  out << "\n\t" << entry.first << ": " << entry.second->encode();
149  edm::LogPrint("OpenHLT") << out.str() << std::endl;
150  if (errCnt == errMax())
151  edm::LogWarning("OpenHLT") << "Maximum error count reached -- No more messages will be printed.";
152  }
153 
154  // run the analysis, passing required event fragments
156  hltresults,
157  l1extemi,
158  l1extemn,
159  l1extmu,
160  l1extjetc,
161  l1extjetf,
162  l1extjet,
163  l1exttaujet,
164  l1extmet,
165  l1extmht,
166  l1GtRR,
167  gctBitCounts,
168  gctRingSums,
169  iSetup,
170  iEvent,
171  HltTree);
172 
173  //evt_header_.analyze(iEvent, lumicorrdatahandle, HltTree);
174  evt_header_.analyze(iEvent, HltTree);
175 
177  mctruth,
178  ptHat,
179  simTracks,
180  simVertices,
181  pupInfo,
182  HltTree);
183 
185  recoVertexsOffline0,
186  HltTree);
187 
188 
189  // std::cout << " Ending Event Analysis" << std::endl;
190  // After analysis, fill the variables tree
191  if (m_file)
192  m_file->cd();
193  HltTree->Fill();
194 }
195 
196 // ------------ method called when starting to processes a run ------------
197 void
199 {
200  hlt_analysis_.beginRun(run, es);
201 }
202 
203 // "endJob" is an inherited method that you may implement to do post-EOF processing and produce final output.
205 
206  if(!_UseTFileService){
207  if (m_file)
208  m_file->cd();
209 
210  HltTree->Write();
211  delete HltTree;
212  HltTree = 0;
213 
214  if (m_file) { // if there was a tree file...
215  m_file->Write(); // write out the branches
216  delete m_file; // close and delete the file
217  m_file = 0; // set to zero to clean up
218  }
219  }
220 }
const char * kL1extjet
Definition: HLTMessages.cc:40
T getParameter(std::string const &) const
dictionary missing
Definition: combine.py:4
void analyze(edm::Event const &iEvent, TTree *tree)
Definition: EventHeader.cc:45
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag gctRingSums_
edm::InputTag VertexTagOffline0_
const char * kL1exttaujet
Definition: HLTMessages.cc:41
edm::InputTag m_l1extrajet
edm::InputTag m_l1extraemn
const char * kHltresults
Definition: HLTMessages.cc:34
void setup(const edm::ParameterSet &pSet, TTree *tree)
Definition: HLTInfo.cc:55
virtual void endJob()
edm::InputTag m_l1extrataujet
const char * kL1extmht
Definition: HLTMessages.cc:43
edm::InputTag m_l1extraemi
std::string l1extramc_
const char * kSimhit
Definition: HLTMessages.cc:49
edm::InputTag gctBitCounts_
void analyze(const edm::Handle< edm::TriggerResults > &hltresults, const edm::Handle< l1extra::L1EmParticleCollection > &l1extemi, const edm::Handle< l1extra::L1EmParticleCollection > &l1extemn, const edm::Handle< l1extra::L1MuonParticleCollection > &l1extmu, const edm::Handle< l1extra::L1JetParticleCollection > &l1extjetc, const edm::Handle< l1extra::L1JetParticleCollection > &l1extjetf, const edm::Handle< l1extra::L1JetParticleCollection > &l1extjet, const edm::Handle< l1extra::L1JetParticleCollection > &l1exttaujet, const edm::Handle< l1extra::L1EtMissParticleCollection > &l1extmet, const edm::Handle< l1extra::L1EtMissParticleCollection > &l1extmht, const edm::Handle< L1GlobalTriggerReadoutRecord > &l1GTRR, const edm::Handle< L1GctHFBitCountsCollection > &gctBitCounts, const edm::Handle< L1GctHFRingEtSumsCollection > &gctRingSums, edm::EventSetup const &eventSetup, edm::Event const &iEvent, TTree *tree)
Definition: HLTInfo.cc:191
edm::InputTag hltresults_
edm::InputTag gtReadoutRecord_
const char * kL1GctRingSums
Definition: HLTMessages.cc:47
const char * kL1extemi
Definition: HLTMessages.cc:35
const char * kL1extmet
Definition: HLTMessages.cc:42
edm::InputTag m_l1extramet
const char * kL1extemn
Definition: HLTMessages.cc:36
RECOVertex vrt_analysisOffline0_
static bool getCollection(const edm::Event &event, std::vector< MissingCollectionInfo > &missing, edm::Handle< T > &handle, const edm::InputTag &name, const char *description)
edm::InputTag genEventInfo_
int iEvent
Definition: GenABIO.cc:243
void setup(TTree *tree)
Definition: EventHeader.cc:26
void setup(const edm::ParameterSet &pSet, TTree *tree, std::string vertexType)
Definition: RECOVertex.cc:49
std::string l1extramu_
std::pair< std::string, MonitorElement * > entry
Definition: ME_MAP.h:8
EventHeader evt_header_
Default analyses.
tuple handle
Definition: patZpeak.py:22
const char * kMctruth
Definition: HLTMessages.cc:48
static int errMax()
edm::InputTag m_l1extramu
void analyze(edm::Handle< reco::VertexCollection > recoVertexs, TTree *tree)
Definition: RECOVertex.cc:92
void beginRun(const edm::Run &, const edm::EventSetup &)
Definition: HLTInfo.cc:34
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool isValid() const
Definition: HandleBase.h:76
std::pair< const char *, const edm::InputTag * > MissingCollectionInfo
Definition: HLTAnalyzer.cc:10
tuple conf
Definition: dbtoconf.py:185
const char * kL1extmu
Definition: HLTMessages.cc:37
tuple out
Definition: dbtoconf.py:99
void analyze(const edm::Handle< reco::CandidateView > &mctruth, const double &pthat, const edm::Handle< std::vector< SimTrack > > &simTracks, const edm::Handle< std::vector< SimVertex > > &simVertices, const edm::Handle< std::vector< PileupSummaryInfo > > &PupInfo, TTree *tree)
Definition: HLTMCtruth.cc:70
std::string _HistName
tuple description
Definition: idDealer.py:66
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
virtual void analyze(edm::Event const &e, edm::EventSetup const &iSetup)
HLTMCtruth mct_analysis_
const char * kL1extjetc
Definition: HLTMessages.cc:38
const char * kL1GtRR
Definition: HLTMessages.cc:44
const char * kL1GctBitCounts
Definition: HLTMessages.cc:46
edm::InputTag m_l1extramht
edm::InputTag mctruth_
std::string const & label() const
Definition: InputTag.h:25
const char * kRecoVerticesOffline0
Definition: HLTMessages.cc:127
edm::InputTag m_l1extrajetf
edm::InputTag gtObjectMap_
const char * kL1extjetf
Definition: HLTMessages.cc:39
const char * kGenEventInfo
Definition: HLTMessages.cc:50
edm::InputTag simhits_
T * make() const
make new ROOT object
void setup(const edm::ParameterSet &pSet, TTree *tree)
Definition: HLTMCtruth.cc:23
const char * kL1GtOMRec
Definition: HLTMessages.cc:45
tuple cout
Definition: gather_cfg.py:121
edm::InputTag pileupInfo_
HLTInfo hlt_analysis_
HLTBitAnalyzer(edm::ParameterSet const &conf)
Definition: Run.h:33
const char * kPileupInfo
Definition: HLTMessages.cc:136
edm::InputTag m_l1extrajetc