107 myInfo() { theMB0 = theMB1 = theMB2 = theMB3 = theMB4 = runcheck = 0; }
129 usesResource(
"TFileService");
166 std::ifstream infile(cfile.c_str());
167 if (!infile.is_open()) {
169 edm::LogWarning(
"RecAnalyzer") <<
"Cannot open '" << cfile <<
"' for the correction file";
171 unsigned int ndets(0), nrec(0);
175 infile >>
id >> cfac;
180 std::map<DetId, double>::iterator itr =
corrFactor_.find(detId);
187 edm::LogInfo(
"RecAnalyzer") <<
"Reads " << nrec <<
" correction factors for " << ndets <<
" detIds";
191 edm::LogInfo(
"RecAnalyzer") <<
" Flags (ReCalib): " <<
theRecalib_ <<
" (IgnoreL1): " << ignoreL1_ <<
" (NZS) " 192 <<
runNZS_ <<
" and with " << ieta.size() <<
" detId for full histogram";
193 edm::LogInfo(
"RecAnalyzer") <<
"Thresholds for HB " << eLowHB_ <<
":" << eHighHB_ <<
" for HE " << eLowHE_ <<
":" 194 << eHighHE_ <<
" for HF " << eLowHF_ <<
":" <<
eHighHF_;
195 for (
unsigned int k = 0;
k < ieta.size(); ++
k) {
199 : ((
std::abs(ieta[k]) == 16) && (depth[
k] == 3))
202 unsigned int id = (
HcalDetId(subd, ieta[k], iphi[k], depth[k])).rawId();
206 edm::LogInfo(
"RecAnalyzer") <<
"Select on " << trigbit_.size() <<
" L1 Trigger selection";
207 for (
unsigned int k = 0;
k < trigbit_.size(); ++
k)
208 edm::LogInfo(
"RecAnalyzer") <<
"Bit[" <<
k <<
"] " << trigbit_[
k];
214 std::vector<int> iarray;
216 desc.
add<
bool>(
"runNZS",
true);
217 desc.
add<
bool>(
"noise",
false);
218 desc.
add<
double>(
"eLowHB", 4);
219 desc.
add<
double>(
"eHighHB", 100);
220 desc.
add<
double>(
"eLowHE", 4);
221 desc.
add<
double>(
"eHighHE", 150);
222 desc.
add<
double>(
"eLowHF", 10);
223 desc.
add<
double>(
"eHighHF", 150);
229 desc.
addUntracked<std::vector<int>>(
"triggerBits", iarray);
234 desc.
addUntracked<std::vector<int>>(
"hcalIeta", iarray);
235 desc.
addUntracked<std::vector<int>>(
"hcalIphi", iarray);
236 desc.
addUntracked<std::vector<int>>(
"hcalDepth", iarray);
241 descriptions.
add(
"recAnalyzerMinbias", desc);
247 hbhe_ =
fs_->
make<TH2D>(
"hbhe",
"Noise in HB/HE", 61, -30.5, 30.5, 72, 0.5, 72.5);
248 hb_ =
fs_->
make<TH2D>(
"hb",
"Noise in HB", 61, -16.5, 16.5, 72, 0.5, 72.5);
249 he_ =
fs_->
make<TH2D>(
"he",
"Noise in HE", 61, -30.5, 30.5, 72, 0.5, 72.5);
250 hf_ =
fs_->
make<TH2D>(
"hf",
"Noise in HF", 82, -41.5, 41.5, 72, 0.5, 72.5);
252 sprintf(title,
"Fraction of channels in HB/HE with E > %4.1f GeV vs Run number",
eMin_);
254 sprintf(title,
"Fraction of channels in HB with E > %4.1f GeV vs Run number",
eMin_);
256 sprintf(title,
"Fraction of channels in HE with E > %4.1f GeV vs Run number",
eMin_);
258 sprintf(title,
"Fraction of channels in HF with E > %4.1f GeV vs Run number",
eMin_);
260 for (
int idet = 1; idet <= 4; idet++) {
261 sprintf(name,
"%s", hc[idet].c_str());
262 sprintf(title,
"Noise distribution for %s", hc[idet].c_str());
266 for (
const auto& hcalid :
hcalID_) {
268 int subdet =
id.subdetId();
269 sprintf(name,
"%s%d_%d_%d", hc[subdet].c_str(),
id.
ieta(),
id.
iphi(),
id.
depth());
271 "Energy Distribution for %s ieta %d iphi %d depth %d",
276 double xmin = (subdet == 4) ? -10 : -1;
277 double xmax = (subdet == 4) ? 90 : 9;
319 for (
const auto& itr :
myMap_) {
320 edm::LogVerbatim(
"RecAnalyzer") <<
"Fired trigger bit number " << itr.first.first;
330 mysubd = itr.first.second.subdet();
331 depth = itr.first.second.depth();
332 iphi = itr.first.second.iphi();
333 ieta = itr.first.second.ieta();
345 edm::LogVerbatim(
"RecAnalyzer") <<
"Exiting from RecAnalyzerMinbias::endjob";
362 double x_min = (
Noise_) ? -3. : 0.;
368 if (hcaltopology->
valid(cell)) {
369 sprintf(name,
"HBeta%dphi%ddep%d",
eta,
phi,
depth);
370 sprintf(title,
"HB #eta %d #phi %d depth %d",
eta,
phi,
depth);
380 x_min = (
Noise_) ? -3. : 0.;
386 if (hcaltopology->
valid(cell)) {
387 sprintf(name,
"HEeta%dphi%ddep%d",
eta,
phi,
depth);
388 sprintf(title,
"HE #eta %d #phi %d depth %d",
eta,
phi,
depth);
398 x_min = (
Noise_) ? -10. : 0.;
404 if (hcaltopology->
valid(cell)) {
405 sprintf(name,
"HFeta%dphi%ddep%d",
eta,
phi,
depth);
406 sprintf(title,
"Energy (HF #eta %d #phi %d depth %d)",
eta,
phi,
depth);
427 double amplitudefullHB(0), amplitudefullHE(0), amplitudefullHF(0);
431 for (
auto const& digi : *(hbhedigi.
product())) {
432 int nTS = digi.size();
433 double amplitudefullTSs = 0.;
436 for (
int i = 0;
i < nTS;
i++)
437 amplitudefullTSs += digi.sample(
i).adc();
439 amplitudefullHB += amplitudefullTSs;
444 for (
int i = 0;
i < nTS;
i++)
445 amplitudefullTSs += digi.sample(
i).adc();
447 amplitudefullHE += amplitudefullTSs;
457 double amplitudefullTSs = 0.;
459 for (
int i = 0;
i < digi.samples();
i++)
460 amplitudefullTSs += digi[
i].
adc();
462 amplitudefullHB += amplitudefullTSs;
465 for (
int i = 0;
i < digi.samples();
i++)
466 amplitudefullTSs += digi[
i].
adc();
468 amplitudefullHE += amplitudefullTSs;
476 for (
auto const& digi : *(hfdigi.
product())) {
477 int nTS = digi.size();
478 double amplitudefullTSs = 0.;
481 for (
int i = 0;
i < nTS;
i++)
482 amplitudefullTSs += digi.sample(
i).adc();
484 amplitudefullHF += amplitudefullTSs;
494 double amplitudefullTSs = 0.;
496 for (
int i = 0;
i < digi.samples();
i++)
497 amplitudefullTSs += digi[
i].
adc();
499 amplitudefullHF += amplitudefullTSs;
512 edm::LogWarning(
"RecAnalyzer") <<
"HcalCalibAlgos: Error! can't get hbhe product!";
525 edm::LogWarning(
"RecAnalyzer") <<
"HcalCalibAlgos: Error! can't get hf product!";
539 if (gtObjectMapRecord.
isValid()) {
540 const std::vector<L1GlobalTriggerObjectMap>& objMapVec = gtObjectMapRecord->
gtObjectMap();
541 for (std::vector<L1GlobalTriggerObjectMap>::const_iterator itMap = objMapVec.begin(); itMap != objMapVec.end();
543 bool resultGt = (*itMap).algoGtlResult();
545 int algoBit = (*itMap).algoBitNumber();
559 double eventWeight = 1.0;
563 eventWeight = genEventInfo->
weight();
566 << select <<
":" <<
ignoreL1_ <<
" Wt " << eventWeight;
569 analyzeHcal(HithbheMB, HithfMB, 1,
true, eventWeight);
573 if (gtObjectMapRecord.
isValid()) {
574 const std::vector<L1GlobalTriggerObjectMap>& objMapVec = gtObjectMapRecord->
gtObjectMap();
576 for (std::vector<L1GlobalTriggerObjectMap>::const_iterator itMap = objMapVec.begin(); itMap != objMapVec.end();
578 bool resultGt = (*itMap).algoGtlResult();
580 int algoBit = (*itMap).algoBitNumber();
581 analyzeHcal(HithbheMB, HithfMB, algoBit, (!ok), eventWeight);
586 edm::LogInfo(
"RecAnalyzer") <<
"No passed L1 Trigger found";
595 int count(0), countHB(0), countHE(0), count2(0), count2HB(0), count2HE(0);
599 double icalconst(1.);
601 std::map<DetId, double>::iterator itr =
corrFactor_.find(mydetid);
603 icalconst = itr->second;
605 HBHERecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time());
606 double energyhit = aHit.
energy();
607 DetId id = (*hbheItr).detid();
617 for (
unsigned int i = 0;
i <
hcalID_.size();
i++) {
624 std::map<HcalDetId, TH1D*>::iterator itr1 =
histHC_.find(hid);
626 itr1->second->Fill(energyhit);
628 h_[hid.
subdet() - 1]->Fill(energyhit);
629 if (energyhit >
eMin_) {
642 if (
Noise_ ||
runNZS_ || (energyhit >= eLow && energyhit <= eHigh)) {
643 std::map<std::pair<int, HcalDetId>,
myInfo>::iterator itr1 =
644 myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
645 if (itr1 ==
myMap_.end()) {
647 myMap_[std::pair<int, HcalDetId>(algoBit, hid)] = info;
648 itr1 =
myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
650 itr1->second.theMB0 +=
weight;
651 itr1->second.theMB1 += (weight * energyhit);
652 itr1->second.theMB2 += (weight * energyhit * energyhit);
653 itr1->second.theMB3 += (weight * energyhit * energyhit * energyhit);
654 itr1->second.theMB4 += (weight * energyhit * energyhit * energyhit * energyhit);
655 itr1->second.runcheck =
rnnum_;
669 << count2HB <<
":" << countHB <<
":" << (double)(count2HB) / countHB <<
"\t HE " 670 << count2HE <<
":" << countHE <<
":" << (double)(count2HE) / countHE;
672 int countHF(0), count2HF(0);
677 double icalconst(1.);
679 std::map<DetId, double>::iterator itr =
corrFactor_.find(mydetid);
681 icalconst = itr->second;
683 HFRecHit aHit(hfItr->id(), hfItr->energy() * icalconst, hfItr->time());
685 double energyhit = aHit.
energy();
686 DetId id = (*hfItr).detid();
690 for (
unsigned int i = 0;
i <
hcalID_.size();
i++) {
697 std::map<HcalDetId, TH1D*>::iterator itr1 =
histHC_.find(hid);
699 itr1->second->Fill(energyhit);
701 h_[hid.
subdet() - 1]->Fill(energyhit);
702 if (energyhit >
eMin_) {
713 std::map<std::pair<int, HcalDetId>,
myInfo>::iterator itr1 =
714 myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
715 if (itr1 ==
myMap_.end()) {
717 myMap_[std::pair<int, HcalDetId>(algoBit, hid)] = info;
718 itr1 =
myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
720 itr1->second.theMB0 +=
weight;
721 itr1->second.theMB1 += (weight * energyhit);
722 itr1->second.theMB2 += (weight * energyhit * energyhit);
723 itr1->second.theMB3 += (weight * energyhit * energyhit * energyhit);
724 itr1->second.theMB4 += (weight * energyhit * energyhit * energyhit * energyhit);
725 itr1->second.runcheck =
rnnum_;
729 if (fill && countHF > 0)
733 edm::LogVerbatim(
"RecAnalyzer") <<
"HF " << count2HF <<
":" << countHF <<
":" << (double)(count2HF) / countHF;
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.
bool valid(const DetId &id) const override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TH1D * h_AmplitudeHFtest_
edm::EDGetTokenT< GenEventInfoProduct > tok_ew_
constexpr uint32_t rawId() const
get the raw id
std::vector< T >::const_iterator const_iterator
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)
std::map< HcalDetId, TH1D * > histHC_
const std::vector< L1GlobalTriggerObjectMap > & gtObjectMap() const
get / set the vector of object maps
std::vector< TH1D * > histo_
edm::EDGetTokenT< QIE10DigiCollection > tok_qie10digi_
#define DEFINE_FWK_MODULE(type)
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
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
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)
std::map< std::pair< int, HcalDetId >, myInfo > myMap_
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > tok_gtRec_
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
std::map< DetId, double > corrFactor_