74 virtual void endJob()
override;
85 double theMB0, theMB1, theMB2, theMB3,
theMB4;
86 double theNS0, theNS1, theNS2, theNS3,
theNS4;
87 double theDif0, theDif1,
theDif2, runcheck;
89 theMB0 = theMB1 = theMB2 = theMB3 = theMB4 = 0;
90 theNS0 = theNS1 = theNS2 = theNS3 = theNS4 = 0;
91 theDif0 = theDif1 = theDif2 = runcheck = 0;
100 TH1D *h_Noise[4], *h_Signal[4];
108 float mom0_MB, mom1_MB, mom2_MB, mom3_MB, mom4_MB,
occup;
109 float mom0_Noise, mom1_Noise, mom2_Noise, mom3_Noise,
mom4_Noise;
110 float mom0_Diff, mom1_Diff, mom2_Diff, mom3_Diff,
mom4_Diff;
139 tok_hbheNormal_ = consumes<HBHERecHitCollection>(
edm::InputTag(
"hbhereco"));
140 tok_hltL1GtMap_ = consumes<L1GlobalTriggerObjectMapRecord>(
edm::InputTag(
"hltL1GtObjectMap"));
149 for (
int subd=0; subd<4; ++subd) {
150 sprintf(name,
"Noise_%s",det[subd].c_str());
151 sprintf(title,
"Energy Distribution for Noise in %s",det[subd].c_str());
152 h_Noise[subd] =
new TH1D(name,title,100,-10.,10.);
153 sprintf(name,
"Signal_%s",det[subd].c_str());
154 sprintf(title,
"Energy Distribution for Signal in %s",det[subd].c_str());
155 h_Signal[subd] =
new TH1D(name,title,100,-10.,10.);
158 hOutputFile =
new TFile(fOutputFileName.c_str(),
"RECREATE") ;
159 myTree =
new TTree(
"RecJet",
"RecJet Tree");
160 myTree->Branch(
"mydet", &mydet,
"mydet/I");
161 myTree->Branch(
"mysubd", &mysubd,
"mysubd/I");
162 myTree->Branch(
"cells", &cells,
"cells");
163 myTree->Branch(
"depth", &
depth,
"depth/I");
164 myTree->Branch(
"ieta", &ieta,
"ieta/I");
165 myTree->Branch(
"iphi", &iphi,
"iphi/I");
166 myTree->Branch(
"eta", &
eta,
"eta/F");
167 myTree->Branch(
"phi", &phi,
"phi/F");
168 myTree->Branch(
"mom0_MB", &mom0_MB,
"mom0_MB/F");
169 myTree->Branch(
"mom1_MB", &mom1_MB,
"mom1_MB/F");
170 myTree->Branch(
"mom2_MB", &mom2_MB,
"mom2_MB/F");
171 myTree->Branch(
"mom3_MB", &mom3_MB,
"mom3_MB/F");
172 myTree->Branch(
"mom4_MB", &mom4_MB,
"mom4_MB/F");
173 myTree->Branch(
"mom0_Noise", &mom0_Noise,
"mom0_Noise/F");
174 myTree->Branch(
"mom1_Noise", &mom1_Noise,
"mom1_Noise/F");
175 myTree->Branch(
"mom2_Noise", &mom2_Noise,
"mom2_Noise/F");
176 myTree->Branch(
"mom3_Noise", &mom3_Noise,
"mom3_Noise/F");
177 myTree->Branch(
"mom4_Noise", &mom4_Noise,
"mom4_Noise/F");
178 myTree->Branch(
"mom0_Diff", &mom0_Diff,
"mom0_Diff/F");
179 myTree->Branch(
"mom1_Diff", &mom1_Diff,
"mom1_Diff/F");
180 myTree->Branch(
"mom2_Diff", &mom2_Diff,
"mom2_Diff/F");
181 myTree->Branch(
"occup", &occup,
"occup/F");
182 myTree->Branch(
"trigbit", &trigbit,
"trigbit/I");
183 myTree->Branch(
"rnnumber", &rnnumber,
"rnnumber/D");
193 for (
std::map<std::pair<int,HcalDetId>,
myInfo>::const_iterator itr=myMap_.begin(); itr != myMap_.end(); ++itr) {
194 LogDebug(
"AnalyzerMB") <<
"Fired trigger bit number " << itr->first.first;
211 trigbit = itr->first.first;
212 mysubd = itr->first.second.subdet();
213 depth = itr->first.second.depth();
214 ieta = itr->first.second.ieta();
215 iphi = itr->first.second.iphi();
217 LogDebug(
"AnalyzerMB") <<
" Result= " << trigbit <<
" " << mysubd
218 <<
" " << ieta <<
" " << iphi <<
" mom0 " 219 << mom0_MB <<
" mom1 " << mom1_MB <<
" mom2 " 220 << mom2_MB <<
" mom3 " << mom3_MB <<
" mom4 " 221 << mom4_MB <<
" mom0_Noise " << mom0_Noise
222 <<
" mom1_Noise " << mom1_Noise <<
" mom2_Noise " 223 << mom2_Noise <<
" mom3_Noise " << mom3_Noise
224 <<
" mom4_Noise " << mom4_Noise <<
" mom0_Diff " 225 << mom0_Diff <<
" mom1_Diff " << mom1_Diff
226 <<
" mom2_Diff " << mom2_Diff;
232 LogDebug(
"AnalyzerMB") <<
"cells" <<
" " << cells;
233 hOutputFile->Write();
236 for(
int i=0;
i<4;
i++){
238 h_Signal[
i]->Write();
240 hOutputFile->Close() ;
257 myRecalib = recalibCorrs.
product();
261 iEvent.
getByToken(tok_hbheNormal_, hbheNormal);
265 edm::LogInfo(
"AnalyzerMB") <<
" The size of the normal collection " 266 << hbheNormal->
size();
270 iEvent.
getByToken(tok_hbherecoNoise_, hbheNS);
272 edm::LogWarning(
"AnalyzerMB") <<
"HcalCalibAlgos: Error! can't get hbheNoise product!";
276 edm::LogInfo(
"AnalyzerMB") <<
"HBHE NS size of collection " << HithbheNS.
size();
277 if (runNZS_ && HithbheNS.
size() != 5184) {
278 edm::LogWarning(
"AnalyzerMB") <<
"HBHE NS problem " << rnnum <<
" size " 286 edm::LogWarning(
"AnalyzerMB") <<
"HcalCalibAlgos: Error! can't get hbhe product!";
290 edm::LogInfo(
"AnalyzerMB") <<
"HBHE MB size of collection " << HithbheMB.
size();
291 if (runNZS_ && HithbheMB.
size() != 5184) {
300 edm::LogWarning(
"AnalyzerMB") <<
"HcalCalibAlgos: Error! can't get hfNoise product!";
305 if (runNZS_ && HithfNS.
size() != 1728) {
314 edm::LogWarning(
"AnalyzerMB") <<
"HcalCalibAlgos: Error! can't get hf product!";
318 edm::LogInfo(
"AnalyzerMB") <<
"HF MB size of collection " << HithfMB.
size();
319 if(runNZS_ && HithfMB.
size() != 1728) {
326 analyzeHcal(myRecalib,HithbheNS,HithbheMB,HithfNS,HithfMB,1,
true);
329 iEvent.
getByToken(tok_hltL1GtMap_, gtObjectMapRecord);
330 if (gtObjectMapRecord.
isValid()) {
331 const std::vector<L1GlobalTriggerObjectMap>& objMapVec = gtObjectMapRecord->
gtObjectMap();
333 bool ok(
false),
fill(
true);
334 for (std::vector<L1GlobalTriggerObjectMap>::const_iterator itMap = objMapVec.begin();
335 itMap != objMapVec.end(); ++itMap, ++
ii) {
336 bool resultGt = (*itMap).algoGtlResult();
339 int algoBit = (*itMap).algoBitNumber();
340 analyzeHcal(myRecalib,HithbheNS,HithbheMB,HithfNS,HithfMB,algoBit,fill);
343 LogDebug(
"AnalyzerMB") <<
"Trigger[" << ii <<
"] " << algoNameStr
344 <<
" bit " << algoBit <<
" entered";
357 int algoBit,
bool fill) {
360 std::map<std::pair<int,HcalDetId>,
myInfo> tmpMap;
364 hbheItr!=HithbheNS.
end(); hbheItr++) {
371 HBHERecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time());
372 double energyhit = aHit.
energy();
374 DetId id = (*hbheItr).detid();
376 std::map<std::pair<int,HcalDetId>,
myInfo>::iterator itr1 = myMap_.find(std::pair<int,HcalDetId>(algoBit,hid));
377 if (itr1 == myMap_.end()) {
379 myMap_[std::pair<int,HcalDetId>(algoBit,hid)] = info;
380 itr1 = myMap_.find(std::pair<int,HcalDetId>(algoBit,hid));
383 itr1->second.theNS1 += energyhit;
384 itr1->second.theNS2 += (energyhit*energyhit);
385 itr1->second.theNS3 += (energyhit*energyhit*energyhit);
386 itr1->second.theNS4 += (energyhit*energyhit*energyhit*energyhit);
387 itr1->second.runcheck = rnnum;
388 if (fill) h_Noise[hid.
subdet()-1]->Fill(energyhit);
390 std::map<std::pair<int,HcalDetId>,
myInfo>::iterator itr2 = tmpMap.find(std::pair<int,HcalDetId>(algoBit,hid));
391 if (itr2 == tmpMap.end()) {
393 tmpMap[std::pair<int,HcalDetId>(algoBit,hid)] = info;
394 itr2 = tmpMap.find(std::pair<int,HcalDetId>(algoBit,hid));
397 itr2->second.theNS1 += energyhit;
398 itr2->second.theNS2 += (energyhit*energyhit);
399 itr2->second.theNS3 += (energyhit*energyhit*energyhit);
400 itr2->second.theNS4 += (energyhit*energyhit*energyhit*energyhit);
401 itr2->second.runcheck = rnnum;
408 hbheItr!=HithbheMB.
end(); hbheItr++) {
414 HBHERecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time());
415 double energyhit = aHit.
energy();
417 DetId id = (*hbheItr).detid();
420 std::map<std::pair<int,HcalDetId>,
myInfo>::iterator itr1 = myMap_.find(std::pair<int,HcalDetId>(algoBit,hid));
421 std::map<std::pair<int,HcalDetId>,
myInfo>::iterator itr2 = tmpMap.find(std::pair<int,HcalDetId>(algoBit,hid));
423 if (itr1 == myMap_.end()) {
425 myMap_[std::pair<int,HcalDetId>(algoBit,hid)] = info;
426 itr1 = myMap_.find(std::pair<int,HcalDetId>(algoBit,hid));
429 itr1->second.theDif0 = 0;
430 itr1->second.theMB1 += energyhit;
431 itr1->second.theMB2 += (energyhit*energyhit);
432 itr1->second.theMB3 += (energyhit*energyhit*energyhit);
433 itr1->second.theMB4 += (energyhit*energyhit*energyhit*energyhit);
434 itr1->second.runcheck = rnnum;
436 if (itr2 !=tmpMap.end()) {
437 mydiff = energyhit - (itr2->second.theNS1);
438 itr1->second.theDif0++;
439 itr1->second.theDif1 += mydiff;
440 itr1->second.theDif2 += (mydiff*mydiff);
441 if (fill) h_Signal[hid.
subdet()-1]->Fill(mydiff);
448 hbheItr!=HithfNS.
end(); hbheItr++) {
454 HFRecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time());
455 double energyhit = aHit.
energy();
457 if(fabs(energyhit) > 40. )
continue;
458 DetId id = (*hbheItr).detid();
461 std::map<std::pair<int,HcalDetId>,
myInfo>::iterator itr1 = myMap_.find(std::pair<int,HcalDetId>(algoBit,hid));
463 if (itr1 == myMap_.end()) {
465 myMap_[std::pair<int,HcalDetId>(algoBit,hid)] = info;
466 itr1 = myMap_.find(std::pair<int,HcalDetId>(algoBit,hid));
469 itr1->second.theNS1 += energyhit;
470 itr1->second.theNS2 += (energyhit*energyhit);
471 itr1->second.theNS3 += (energyhit*energyhit*energyhit);
472 itr1->second.theNS4 += (energyhit*energyhit*energyhit*energyhit);
473 itr1->second.runcheck = rnnum;
474 if (fill) h_Noise[hid.
subdet()-1]->Fill(energyhit);
476 std::map<std::pair<int,HcalDetId>,
myInfo>::iterator itr2 = tmpMap.find(std::pair<int,HcalDetId>(algoBit,hid));
477 if (itr2 == tmpMap.end()) {
479 tmpMap[std::pair<int,HcalDetId>(algoBit,hid)] = info;
480 itr2 = tmpMap.find(std::pair<int,HcalDetId>(algoBit,hid));
483 itr2->second.theNS1 += energyhit;
484 itr2->second.theNS2 += (energyhit*energyhit);
485 itr2->second.theNS3 += (energyhit*energyhit*energyhit);
486 itr2->second.theNS4 += (energyhit*energyhit*energyhit*energyhit);
487 itr2->second.runcheck = rnnum;
495 hbheItr!=HithfMB.
end(); hbheItr++) {
500 HFRecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time());
502 double energyhit = aHit.
energy();
504 if(fabs(energyhit) > 40. )
continue;
506 DetId id = (*hbheItr).detid();
509 std::map<std::pair<int,HcalDetId>,
myInfo>::iterator itr1 = myMap_.find(std::pair<int,HcalDetId>(algoBit,hid));
510 std::map<std::pair<int,HcalDetId>,
myInfo>::iterator itr2 = tmpMap.find(std::pair<int,HcalDetId>(algoBit,hid));
512 if (itr1 == myMap_.end()) {
514 myMap_[std::pair<int,HcalDetId>(algoBit,hid)] = info;
515 itr1 = myMap_.find(std::pair<int,HcalDetId>(algoBit,hid));
518 itr1->second.theDif0 = 0;
519 itr1->second.theMB1 += energyhit;
520 itr1->second.theMB2 += (energyhit*energyhit);
521 itr1->second.theMB3 += (energyhit*energyhit*energyhit);
522 itr1->second.theMB4 += (energyhit*energyhit*energyhit*energyhit);
523 itr1->second.runcheck = rnnum;
525 if (itr2 !=tmpMap.end()) {
526 mydiff = energyhit - (itr2->second.theNS1);
527 itr1->second.theDif0++;
528 itr1->second.theDif1 += mydiff;
529 itr1->second.theDif2 += (mydiff*mydiff);
530 if (fill) h_Signal[hid.
subdet()-1]->Fill(mydiff);
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
bool getByToken(EDGetToken token, Handle< PROD > &result) const
def analyze(function, filename, filter=None)
#define DEFINE_FWK_MODULE(type)
std::vector< HBHERecHit >::const_iterator const_iterator
const Item * getValues(DetId fId, bool throwOnFail=true) const
AnalyzerMinbias(const edm::ParameterSet &)
edm::EDGetTokenT< HORecHitCollection > tok_horecoNoise_
virtual void beginJob() override
const std::vector< L1GlobalTriggerObjectMap > & gtObjectMap() const
get / set the vector of object maps
uint32_t rawId() const
get the raw id
std::map< std::pair< int, HcalDetId >, myInfo > myMap_
edm::EDGetTokenT< L1GlobalTriggerObjectMapRecord > tok_hltL1GtMap_
std::ofstream * myout_hcal
const_iterator end() const
T const * product() const
return(e1-e2)*(e1-e2)+dp *dp
virtual void endJob() override
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_
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
const_iterator begin() const