109 theMB0 = theMB1 = theMB2 = theMB3 = theMB4 = runcheck = 0;
134 usesResource(
"TFileService");
171 std::ifstream infile(cfile.c_str());
172 if (!infile.is_open()) {
175 <<
"' for the correction file";
177 unsigned int ndets(0), nrec(0);
181 infile >>
id >> cfac;
182 if (!infile.good())
break;
185 std::map<DetId,double>::iterator itr =
corrFactor_.find(detId);
193 <<
" correction factors for " << ndets
199 <<
" (IgnoreL1): " << ignoreL1_ <<
" (NZS) " 200 <<
runNZS_ <<
" and with " << ieta.size()
201 <<
" detId for full histogram";
202 edm::LogInfo(
"RecAnalyzer") <<
"Thresholds for HB " << eLowHB_ <<
":" 203 << eHighHB_ <<
" for HE " << eLowHE_ <<
":" 204 << eHighHE_ <<
" for HF " << eLowHF_ <<
":" 206 for (
unsigned int k=0;
k<ieta.size(); ++
k) {
211 unsigned int id = (
HcalDetId(subd,ieta[k],iphi[k],depth[k])).rawId();
215 edm::LogInfo(
"RecAnalyzer") <<
"Select on " << trigbit_.size()
216 <<
" L1 Trigger selection";
217 for (
unsigned int k=0;
k<trigbit_.size(); ++
k)
218 edm::LogInfo(
"RecAnalyzer") <<
"Bit[" <<
k <<
"] " << trigbit_[
k];
225 std::vector<int> iarray;
227 desc.
add<
bool>(
"runNZS",
true);
228 desc.
add<
bool>(
"noise",
false);
229 desc.
add<
double>(
"eLowHB", 4);
230 desc.
add<
double>(
"eHighHB", 100);
231 desc.
add<
double>(
"eLowHE", 4);
232 desc.
add<
double>(
"eHighHE", 150);
233 desc.
add<
double>(
"eLowHF", 10);
234 desc.
add<
double>(
"eHighHF", 150);
240 desc.
addUntracked<std::vector<int> >(
"triggerBits", iarray);
245 desc.
addUntracked<std::vector<int> >(
"hcalIeta", iarray);
246 desc.
addUntracked<std::vector<int> >(
"hcalIphi", iarray);
247 desc.
addUntracked<std::vector<int> >(
"hcalDepth", iarray);
252 descriptions.
add(
"recAnalyzerMinbias",desc);
259 hbhe_ =
fs_->
make<TH2D>(
"hbhe",
"Noise in HB/HE",61,-30.5,30.5,72,0.5,72.5);
260 hb_ =
fs_->
make<TH2D>(
"hb",
"Noise in HB",61,-16.5,16.5,72,0.5,72.5);
261 he_ =
fs_->
make<TH2D>(
"he",
"Noise in HE",61,-30.5,30.5,72,0.5,72.5);
262 hf_ =
fs_->
make<TH2D>(
"hf",
"Noise in HF",82,-41.5,41.5,72,0.5,72.5);
264 sprintf (title,
"Fraction of channels in HB/HE with E > %4.1f GeV vs Run number",
eMin_);
266 sprintf (title,
"Fraction of channels in HB with E > %4.1f GeV vs Run number",
eMin_);
268 sprintf (title,
"Fraction of channels in HE with E > %4.1f GeV vs Run number",
eMin_);
270 sprintf (title,
"Fraction of channels in HF with E > %4.1f GeV vs Run number",
eMin_);
272 for(
int idet=1; idet<=4; idet++){
273 sprintf(name,
"%s", hc[idet].c_str());
274 sprintf (title,
"Noise distribution for %s", hc[idet].c_str());
278 for (
const auto & hcalid :
hcalID_) {
280 int subdet =
id.subdetId();
281 sprintf (name,
"%s%d_%d_%d", hc[subdet].c_str(),
id.
ieta(),
id.
iphi(),
id.
depth());
282 sprintf (title,
"Energy Distribution for %s ieta %d iphi %d depth %d", hc[subdet].c_str(),
id.
ieta(),
id.
iphi(),
id.
depth());
283 double xmin = (subdet == 4) ? -10 : -1;
284 double xmax = (subdet == 4) ? 90 : 9;
327 for (
const auto& itr :
myMap_) {
339 mysubd = itr.first.second.subdet();
340 depth = itr.first.second.depth();
341 iphi = itr.first.second.iphi();
342 ieta = itr.first.second.ieta();
345 <<
" mom0 " <<
mom0_MB <<
" mom1 " 347 <<
" mom3 " <<
mom3_MB <<
" mom4 " 356 edm::LogVerbatim(
"RecAnalyzer") <<
"Exiting from RecAnalyzerMinbias::endjob";
374 double x_min = (
Noise_) ? -3. : 0.;
380 if (hcaltopology->
valid(cell)) {
381 sprintf (name,
"HBeta%dphi%ddep%d",
eta,
phi,
depth);
382 sprintf (title,
"HB #eta %d #phi %d depth %d",
eta,
phi,
depth);
392 x_min = (
Noise_) ? -3. : 0.;
398 if (hcaltopology->
valid(cell)) {
399 sprintf (name,
"HEeta%dphi%ddep%d",
eta,
phi,
depth);
400 sprintf (title,
"HE #eta %d #phi %d depth %d",
eta,
phi,
depth);
410 x_min = (
Noise_) ? -10. : 0.;
416 if (hcaltopology->
valid(cell)) {
417 sprintf (name,
"HFeta%dphi%ddep%d",
eta,
phi,
depth);
418 sprintf (title,
"Energy (HF #eta %d #phi %d depth %d)",
eta,
phi,
depth);
440 double amplitudefullHB(0), amplitudefullHE(0), amplitudefullHF(0);
444 for (
auto const& digi : *(hbhedigi.
product())) {
445 int nTS = digi.size();
446 double amplitudefullTSs = 0.;
449 for (
int i=0;
i<nTS;
i++)
450 amplitudefullTSs += digi.sample(
i).adc();
452 amplitudefullHB += amplitudefullTSs;
457 for (
int i=0;
i<nTS;
i++)
458 amplitudefullTSs += digi.sample(
i).adc();
460 amplitudefullHE += amplitudefullTSs;
470 double amplitudefullTSs = 0.;
472 for (
int i=0;
i<digi.samples();
i++)
473 amplitudefullTSs += digi[
i].
adc();
475 amplitudefullHB += amplitudefullTSs;
478 for (
int i=0;
i<digi.samples();
i++)
479 amplitudefullTSs += digi[
i].
adc();
481 amplitudefullHE += amplitudefullTSs;
489 for (
auto const& digi : *(hfdigi.
product())) {
490 int nTS = digi.size();
491 double amplitudefullTSs = 0.;
494 for (
int i=0;
i<nTS;
i++)
495 amplitudefullTSs += digi.sample(
i).adc();
497 amplitudefullHF += amplitudefullTSs;
507 double amplitudefullTSs = 0.;
509 for (
int i=0;
i<digi.samples();
i++)
510 amplitudefullTSs += digi[
i].
adc();
512 amplitudefullHF += amplitudefullTSs;
525 edm::LogWarning(
"RecAnalyzer") <<
"HcalCalibAlgos: Error! can't get hbhe product!";
540 edm::LogWarning(
"RecAnalyzer") <<
"HcalCalibAlgos: Error! can't get hf product!";
556 if (gtObjectMapRecord.
isValid()) {
557 const std::vector<L1GlobalTriggerObjectMap>& objMapVec = gtObjectMapRecord->
gtObjectMap();
558 for (std::vector<L1GlobalTriggerObjectMap>::const_iterator itMap = objMapVec.begin();
559 itMap != objMapVec.end(); ++itMap) {
560 bool resultGt = (*itMap).algoGtlResult();
562 int algoBit = (*itMap).algoBitNumber();
576 double eventWeight = 1.0;
579 if (genEventInfo.
isValid()) eventWeight = genEventInfo->
weight();
584 <<
" Wt " << eventWeight;
587 analyzeHcal(HithbheMB, HithfMB, 1,
true, eventWeight);
591 if (gtObjectMapRecord.
isValid()) {
592 const std::vector<L1GlobalTriggerObjectMap>& objMapVec = gtObjectMapRecord->
gtObjectMap();
594 for (std::vector<L1GlobalTriggerObjectMap>::const_iterator itMap = objMapVec.begin();
595 itMap != objMapVec.end(); ++itMap) {
596 bool resultGt = (*itMap).algoGtlResult();
598 int algoBit = (*itMap).algoBitNumber();
599 analyzeHcal(HithbheMB, HithfMB, algoBit, (!ok), eventWeight);
604 edm::LogInfo(
"RecAnalyzer") <<
"No passed L1 Trigger found";
614 int count(0), countHB(0), countHE(0), count2(0), count2HB(0), count2HE(0);
616 hbheItr!=HithbheMB.
end(); hbheItr++) {
619 double icalconst(1.);
621 std::map<DetId,double>::iterator itr =
corrFactor_.find(mydetid);
622 if (itr !=
corrFactor_.end()) icalconst = itr->second;
624 HBHERecHit aHit(hbheItr->id(),hbheItr->energy()*icalconst,hbheItr->time());
625 double energyhit = aHit.
energy();
626 DetId id = (*hbheItr).detid();
634 for (
unsigned int i = 0;
i <
hcalID_.size();
i++) {
641 std::map<HcalDetId,TH1D*>::iterator itr1 =
histHC_.find(hid);
642 if (itr1 !=
histHC_.end()) itr1->second->Fill(energyhit);
644 h_[hid.
subdet()-1]->Fill(energyhit);
645 if (energyhit >
eMin_) {
658 if (
Noise_ ||
runNZS_ || (energyhit >= eLow && energyhit <= eHigh)) {
659 std::map<std::pair<int,HcalDetId>,
myInfo>::iterator itr1 =
myMap_.find(std::pair<int,HcalDetId>(algoBit,hid));
660 if (itr1 ==
myMap_.end()) {
662 myMap_[std::pair<int,HcalDetId>(algoBit,hid)] = info;
663 itr1 =
myMap_.find(std::pair<int,HcalDetId>(algoBit,hid));
665 itr1->second.theMB0 +=
weight;
666 itr1->second.theMB1 += (weight*energyhit);
667 itr1->second.theMB2 += (weight*energyhit*energyhit);
668 itr1->second.theMB3 += (weight*energyhit*energyhit*energyhit);
669 itr1->second.theMB4 += (weight*energyhit*energyhit*energyhit*energyhit);
670 itr1->second.runcheck =
rnnum_;
676 if (countHB > 0)
hbrun_->Fill(
rnnum_ ,(
double)(count2HB)/countHB);
677 if (countHE > 0)
herun_->Fill(
rnnum_ ,(
double)(count2HE)/countHE);
681 << (double)(count2)/
count <<
"\t HB " 682 << count2HB <<
":" << countHB <<
":" 683 << (double)(count2HB)/countHB <<
"\t HE " 684 << count2HE <<
":" << countHE <<
":" 685 << (double)(count2HE)/countHE;
687 int countHF(0), count2HF(0);
690 hfItr!=HithfMB.
end(); hfItr++) {
693 double icalconst(1.);
695 std::map<DetId,double>::iterator itr =
corrFactor_.find(mydetid);
696 if (itr !=
corrFactor_.end()) icalconst = itr->second;
698 HFRecHit aHit(hfItr->id(),hfItr->energy()*icalconst,hfItr->time());
700 double energyhit = aHit.
energy();
701 DetId id = (*hfItr).detid();
705 for (
unsigned int i = 0;
i <
hcalID_.size();
i++) {
712 std::map<HcalDetId,TH1D*>::iterator itr1 =
histHC_.find(hid);
713 if (itr1 !=
histHC_.end()) itr1->second->Fill(energyhit);
715 h_[hid.
subdet()-1]->Fill(energyhit);
716 if (energyhit >
eMin_) {
728 std::map<std::pair<int,HcalDetId>,
myInfo>::iterator itr1 =
myMap_.find(std::pair<int,HcalDetId>(algoBit,hid));
729 if (itr1 ==
myMap_.end()) {
731 myMap_[std::pair<int,HcalDetId>(algoBit,hid)] = info;
732 itr1 =
myMap_.find(std::pair<int,HcalDetId>(algoBit,hid));
734 itr1->second.theMB0 +=
weight;
735 itr1->second.theMB1 += (weight*energyhit);
736 itr1->second.theMB2 += (weight*energyhit*energyhit);
737 itr1->second.theMB3 += (weight*energyhit*energyhit*energyhit);
738 itr1->second.theMB4 += (weight*energyhit*energyhit*energyhit*energyhit);
739 itr1->second.runcheck =
rnnum_;
743 if (fill && countHF > 0)
hfrun_->Fill(
rnnum_ ,(
double)(count2HF)/countHF);
747 <<
":" << (double)(count2HF)/countHF;
int adc(sample_type sample)
get the ADC sample (12 bits)
constexpr float energy() const
~RecAnalyzerMinbias() override
T getParameter(std::string const &) const
RecAnalyzerMinbias(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
std::vector< int > trigbit_
edm::EDGetTokenT< HFDigiCollection > tok_hfdigi_
HcalSubdetector subdet() const
get the subdetector
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
std::map< HcalDetId, TH1D * > histHC_
bool valid(const DetId &id) const override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TH1D * h_AmplitudeHFtest_
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< GenEventInfoProduct > tok_ew_
constexpr uint32_t rawId() const
get the raw id
std::vector< HBHERecHit >::const_iterator const_iterator
std::map< DetId, double > corrFactor_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< QIE11DigiCollection > tok_qie11digi_
T * make(const Args &...args) const
make new ROOT object
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const std::vector< L1GlobalTriggerObjectMap > & gtObjectMap() const
get / set the vector of object maps
std::vector< TH1D * > histo_
edm::EDGetTokenT< QIE10DigiCollection > tok_qie10digi_
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhedigi_
int ieta() const
get the cell ieta
edm::EDGetTokenT< HFRecHitCollection > tok_hfrecoMB_
Abs< T >::type abs(const T &t)
void analyze(edm::Event const &, edm::EventSetup const &) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const_iterator end() const
void analyzeHcal(const HBHERecHitCollection &, const HFRecHitCollection &, int, bool, double)
edm::EDGetTokenT< HODigiCollection > tok_hodigi_
int iphi() const
get the cell iphi
TH1D * h_AmplitudeHBtest_
void endRun(edm::Run const &, edm::EventSetup const &) override
edm::Service< TFileService > fs_
T const * product() const
std::vector< unsigned int > hcalID_
edm::EDGetTokenT< HBHERecHitCollection > tok_hbherecoMB_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > tok_gtRec_
std::map< std::pair< int, HcalDetId >, myInfo > myMap_
edm::EDGetTokenT< L1GlobalTriggerObjectMapRecord > tok_hltL1GtMap_
TH1D * h_AmplitudeHEtest_
T const * product() const
void beginRun(edm::Run const &, edm::EventSetup const &) override
const_iterator begin() const