72 void endJob()
override;
84 double theMB0, theMB1, theMB2, theMB3,
theMB4;
85 double theNS0, theNS1, theNS2, theNS3,
theNS4;
86 double theDif0, theDif1,
theDif2, runcheck;
88 theMB0 = theMB1 = theMB2 = theMB3 = theMB4 = 0;
89 theNS0 = theNS1 = theNS2 = theNS3 = theNS4 = 0;
90 theDif0 = theDif1 = theDif2 = runcheck = 0;
99 TH1D *h_Noise[4], *h_Signal[4];
107 float mom0_MB, mom1_MB, mom2_MB, mom3_MB, mom4_MB,
occup;
108 float mom0_Noise, mom1_Noise, mom2_Noise, mom3_Noise,
mom4_Noise;
109 float mom0_Diff, mom1_Diff, mom2_Diff, mom3_Diff,
mom4_Diff;
136 tok_hbheNormal_ = consumes<HBHERecHitCollection>(
edm::InputTag(
"hbhereco"));
137 tok_hltL1GtMap_ = consumes<L1GlobalTriggerObjectMapRecord>(
edm::InputTag(
"hltL1GtObjectMap"));
145 for (
int subd = 0; subd < 4; ++subd) {
146 sprintf(name,
"Noise_%s", det[subd].c_str());
147 sprintf(title,
"Energy Distribution for Noise in %s", det[subd].c_str());
148 h_Noise[subd] =
new TH1D(name, title, 100, -10., 10.);
149 sprintf(name,
"Signal_%s", det[subd].c_str());
150 sprintf(title,
"Energy Distribution for Signal in %s", det[subd].c_str());
151 h_Signal[subd] =
new TH1D(name, title, 100, -10., 10.);
154 hOutputFile =
new TFile(fOutputFileName.c_str(),
"RECREATE");
155 myTree =
new TTree(
"RecJet",
"RecJet Tree");
156 myTree->Branch(
"mydet", &mydet,
"mydet/I");
157 myTree->Branch(
"mysubd", &mysubd,
"mysubd/I");
158 myTree->Branch(
"cells", &
cells,
"cells");
159 myTree->Branch(
"depth", &
depth,
"depth/I");
160 myTree->Branch(
"ieta", &ieta,
"ieta/I");
161 myTree->Branch(
"iphi", &iphi,
"iphi/I");
162 myTree->Branch(
"eta", &
eta,
"eta/F");
163 myTree->Branch(
"phi", &phi,
"phi/F");
164 myTree->Branch(
"mom0_MB", &mom0_MB,
"mom0_MB/F");
165 myTree->Branch(
"mom1_MB", &mom1_MB,
"mom1_MB/F");
166 myTree->Branch(
"mom2_MB", &mom2_MB,
"mom2_MB/F");
167 myTree->Branch(
"mom3_MB", &mom3_MB,
"mom3_MB/F");
168 myTree->Branch(
"mom4_MB", &mom4_MB,
"mom4_MB/F");
169 myTree->Branch(
"mom0_Noise", &mom0_Noise,
"mom0_Noise/F");
170 myTree->Branch(
"mom1_Noise", &mom1_Noise,
"mom1_Noise/F");
171 myTree->Branch(
"mom2_Noise", &mom2_Noise,
"mom2_Noise/F");
172 myTree->Branch(
"mom3_Noise", &mom3_Noise,
"mom3_Noise/F");
173 myTree->Branch(
"mom4_Noise", &mom4_Noise,
"mom4_Noise/F");
174 myTree->Branch(
"mom0_Diff", &mom0_Diff,
"mom0_Diff/F");
175 myTree->Branch(
"mom1_Diff", &mom1_Diff,
"mom1_Diff/F");
176 myTree->Branch(
"mom2_Diff", &mom2_Diff,
"mom2_Diff/F");
177 myTree->Branch(
"occup", &occup,
"occup/F");
178 myTree->Branch(
"trigbit", &trigbit,
"trigbit/I");
179 myTree->Branch(
"rnnumber", &rnnumber,
"rnnumber/D");
188 for (
std::map<std::pair<int, HcalDetId>,
myInfo>::const_iterator itr = myMap_.begin(); itr != myMap_.end(); ++itr) {
189 LogDebug(
"AnalyzerMB") <<
"Fired trigger bit number " << itr->first.first;
206 trigbit = itr->first.first;
207 mysubd = itr->first.second.subdet();
208 depth = itr->first.second.depth();
209 ieta = itr->first.second.ieta();
210 iphi = itr->first.second.iphi();
212 LogDebug(
"AnalyzerMB") <<
" Result= " << trigbit <<
" " << mysubd <<
" " << ieta <<
" " << iphi <<
" mom0 " 213 << mom0_MB <<
" mom1 " << mom1_MB <<
" mom2 " << mom2_MB <<
" mom3 " << mom3_MB <<
" mom4 " 214 << mom4_MB <<
" mom0_Noise " << mom0_Noise <<
" mom1_Noise " << mom1_Noise
215 <<
" mom2_Noise " << mom2_Noise <<
" mom3_Noise " << mom3_Noise <<
" mom4_Noise " 216 << mom4_Noise <<
" mom0_Diff " << mom0_Diff <<
" mom1_Diff " << mom1_Diff <<
" mom2_Diff " 225 hOutputFile->Write();
228 for (
int i = 0;
i < 4;
i++) {
230 h_Signal[
i]->Write();
232 hOutputFile->Close();
247 myRecalib = recalibCorrs.
product();
251 iEvent.
getByToken(tok_hbheNormal_, hbheNormal);
255 edm::LogInfo(
"AnalyzerMB") <<
" The size of the normal collection " << hbheNormal->
size();
259 iEvent.
getByToken(tok_hbherecoNoise_, hbheNS);
261 edm::LogWarning(
"AnalyzerMB") <<
"HcalCalibAlgos: Error! can't get hbheNoise product!";
265 edm::LogInfo(
"AnalyzerMB") <<
"HBHE NS size of collection " << HithbheNS.
size();
266 if (runNZS_ && HithbheNS.
size() != 5184) {
267 edm::LogWarning(
"AnalyzerMB") <<
"HBHE NS problem " << rnnum <<
" size " << HithbheNS.
size();
274 edm::LogWarning(
"AnalyzerMB") <<
"HcalCalibAlgos: Error! can't get hbhe product!";
278 edm::LogInfo(
"AnalyzerMB") <<
"HBHE MB size of collection " << HithbheMB.
size();
279 if (runNZS_ && HithbheMB.
size() != 5184) {
287 edm::LogWarning(
"AnalyzerMB") <<
"HcalCalibAlgos: Error! can't get hfNoise product!";
291 edm::LogInfo(
"AnalyzerMB") <<
"HF NS size of collection " << HithfNS.
size();
292 if (runNZS_ && HithfNS.
size() != 1728) {
300 edm::LogWarning(
"AnalyzerMB") <<
"HcalCalibAlgos: Error! can't get hf product!";
304 edm::LogInfo(
"AnalyzerMB") <<
"HF MB size of collection " << HithfMB.
size();
305 if (runNZS_ && HithfMB.
size() != 1728) {
311 analyzeHcal(myRecalib, HithbheNS, HithbheMB, HithfNS, HithfMB, 1,
true);
314 iEvent.
getByToken(tok_hltL1GtMap_, gtObjectMapRecord);
315 if (gtObjectMapRecord.
isValid()) {
316 const std::vector<L1GlobalTriggerObjectMap>& objMapVec = gtObjectMapRecord->
gtObjectMap();
318 bool ok(
false),
fill(
true);
319 for (std::vector<L1GlobalTriggerObjectMap>::const_iterator itMap = objMapVec.begin(); itMap != objMapVec.end();
321 bool resultGt = (*itMap).algoGtlResult();
324 int algoBit = (*itMap).algoBitNumber();
325 analyzeHcal(myRecalib, HithbheNS, HithbheMB, HithfNS, HithfMB, algoBit, fill);
328 LogDebug(
"AnalyzerMB") <<
"Trigger[" << ii <<
"] " << algoNameStr <<
" bit " << algoBit <<
" entered";
345 std::map<std::pair<int, HcalDetId>,
myInfo> tmpMap;
350 float icalconst = 1.;
355 HBHERecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time());
356 double energyhit = aHit.
energy();
358 DetId id = (*hbheItr).detid();
360 std::map<std::pair<int, HcalDetId>,
myInfo>::iterator itr1 = myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
361 if (itr1 == myMap_.end()) {
363 myMap_[std::pair<int, HcalDetId>(algoBit, hid)] = info;
364 itr1 = myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
367 itr1->second.theNS1 += energyhit;
368 itr1->second.theNS2 += (energyhit * energyhit);
369 itr1->second.theNS3 += (energyhit * energyhit * energyhit);
370 itr1->second.theNS4 += (energyhit * energyhit * energyhit * energyhit);
371 itr1->second.runcheck = rnnum;
373 h_Noise[hid.
subdet() - 1]->Fill(energyhit);
375 std::map<std::pair<int, HcalDetId>,
myInfo>::iterator itr2 = tmpMap.find(std::pair<int, HcalDetId>(algoBit, hid));
376 if (itr2 == tmpMap.end()) {
378 tmpMap[std::pair<int, HcalDetId>(algoBit, hid)] = info;
379 itr2 = tmpMap.find(std::pair<int, HcalDetId>(algoBit, hid));
382 itr2->second.theNS1 += energyhit;
383 itr2->second.theNS2 += (energyhit * energyhit);
384 itr2->second.theNS3 += (energyhit * energyhit * energyhit);
385 itr2->second.theNS4 += (energyhit * energyhit * energyhit * energyhit);
386 itr2->second.runcheck = rnnum;
394 float icalconst = 1.;
399 HBHERecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time());
400 double energyhit = aHit.
energy();
402 DetId id = (*hbheItr).detid();
405 std::map<std::pair<int, HcalDetId>,
myInfo>::iterator itr1 = myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
406 std::map<std::pair<int, HcalDetId>,
myInfo>::iterator itr2 = tmpMap.find(std::pair<int, HcalDetId>(algoBit, hid));
408 if (itr1 == myMap_.end()) {
410 myMap_[std::pair<int, HcalDetId>(algoBit, hid)] = info;
411 itr1 = myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
414 itr1->second.theDif0 = 0;
415 itr1->second.theMB1 += energyhit;
416 itr1->second.theMB2 += (energyhit * energyhit);
417 itr1->second.theMB3 += (energyhit * energyhit * energyhit);
418 itr1->second.theMB4 += (energyhit * energyhit * energyhit * energyhit);
419 itr1->second.runcheck = rnnum;
421 if (itr2 != tmpMap.end()) {
422 mydiff = energyhit - (itr2->second.theNS1);
423 itr1->second.theDif0++;
424 itr1->second.theDif1 += mydiff;
425 itr1->second.theDif2 += (mydiff * mydiff);
427 h_Signal[hid.
subdet() - 1]->Fill(mydiff);
435 float icalconst = 1.;
440 HFRecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time());
441 double energyhit = aHit.
energy();
443 if (fabs(energyhit) > 40.)
445 DetId id = (*hbheItr).detid();
448 std::map<std::pair<int, HcalDetId>,
myInfo>::iterator itr1 = myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
450 if (itr1 == myMap_.end()) {
452 myMap_[std::pair<int, HcalDetId>(algoBit, hid)] = info;
453 itr1 = myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
456 itr1->second.theNS1 += energyhit;
457 itr1->second.theNS2 += (energyhit * energyhit);
458 itr1->second.theNS3 += (energyhit * energyhit * energyhit);
459 itr1->second.theNS4 += (energyhit * energyhit * energyhit * energyhit);
460 itr1->second.runcheck = rnnum;
462 h_Noise[hid.
subdet() - 1]->Fill(energyhit);
464 std::map<std::pair<int, HcalDetId>,
myInfo>::iterator itr2 = tmpMap.find(std::pair<int, HcalDetId>(algoBit, hid));
465 if (itr2 == tmpMap.end()) {
467 tmpMap[std::pair<int, HcalDetId>(algoBit, hid)] = info;
468 itr2 = tmpMap.find(std::pair<int, HcalDetId>(algoBit, hid));
471 itr2->second.theNS1 += energyhit;
472 itr2->second.theNS2 += (energyhit * energyhit);
473 itr2->second.theNS3 += (energyhit * energyhit * energyhit);
474 itr2->second.theNS4 += (energyhit * energyhit * energyhit * energyhit);
475 itr2->second.runcheck = rnnum;
483 float icalconst = 1.;
487 HFRecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time());
489 double energyhit = aHit.
energy();
491 if (fabs(energyhit) > 40.)
494 DetId id = (*hbheItr).detid();
497 std::map<std::pair<int, HcalDetId>,
myInfo>::iterator itr1 = myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
498 std::map<std::pair<int, HcalDetId>,
myInfo>::iterator itr2 = tmpMap.find(std::pair<int, HcalDetId>(algoBit, hid));
500 if (itr1 == myMap_.end()) {
502 myMap_[std::pair<int, HcalDetId>(algoBit, hid)] = info;
503 itr1 = myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
506 itr1->second.theDif0 = 0;
507 itr1->second.theMB1 += energyhit;
508 itr1->second.theMB2 += (energyhit * energyhit);
509 itr1->second.theMB3 += (energyhit * energyhit * energyhit);
510 itr1->second.theMB4 += (energyhit * energyhit * energyhit * energyhit);
511 itr1->second.runcheck = rnnum;
513 if (itr2 != tmpMap.end()) {
514 mydiff = energyhit - (itr2->second.theNS1);
515 itr1->second.theDif0++;
516 itr1->second.theDif1 += mydiff;
517 itr1->second.theDif2 += (mydiff * mydiff);
519 h_Signal[hid.
subdet() - 1]->Fill(mydiff);
constexpr float energy() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< HBHERecHitCollection > tok_hbheNormal_
edm::EDGetTokenT< HFRecHitCollection > tok_hfrecoNoise_
HcalSubdetector subdet() const
get the subdetector
~AnalyzerMinbias() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
constexpr uint32_t rawId() const
get the raw id
std::vector< T >::const_iterator const_iterator
const Item * getValues(DetId fId, bool throwOnFail=true) const
AnalyzerMinbias(const edm::ParameterSet &)
edm::EDGetTokenT< HORecHitCollection > tok_horecoNoise_
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
const std::vector< L1GlobalTriggerObjectMap > & gtObjectMap() const
get / set the vector of object maps
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< L1GlobalTriggerObjectMapRecord > tok_hltL1GtMap_
std::ofstream * myout_hcal
const_iterator end() const
T const * product() const
std::map< std::pair< int, HcalDetId >, myInfo > myMap_
void analyzeHcal(const HcalRespCorrs *myRecalib, const HBHERecHitCollection &HithbheNS, const HBHERecHitCollection &HithbheMB, const HFRecHitCollection &HithfNS, const HFRecHitCollection &HithfMB, int algoBit, bool fill)
T const * product() const
edm::EDGetTokenT< HBHERecHitCollection > tok_hbherecoNoise_
void analyze(const edm::Event &, const edm::EventSetup &) override
const_iterator begin() const