129 usesResource(
"TFileService");
165 tok_htopo_ = esConsumes<HcalTopology, HcalRecNumberingRecord, edm::Transition::BeginRun>();
168 std::ifstream
infile(cfile.c_str());
171 edm::LogWarning(
"RecAnalyzer") <<
"Cannot open '" << cfile <<
"' for the correction file";
173 unsigned int ndets(0), nrec(0);
182 std::map<DetId, double>::iterator itr =
corrFactor_.find(detId);
189 edm::LogVerbatim(
"RecAnalyzer") <<
"Reads " << nrec <<
" correction factors for " << ndets <<
" detIds";
194 <<
runNZS_ <<
" and with " << ieta.size() <<
" detId for full histogram";
195 edm::LogVerbatim(
"RecAnalyzer") <<
"Thresholds for HB " << eLowHB_ <<
":" << eHighHB_ <<
" for HE " << eLowHE_ <<
":"
196 << eHighHE_ <<
" for HF " << eLowHF_ <<
":" <<
eHighHF_;
197 for (
unsigned int k = 0;
k < ieta.size(); ++
k) {
203 unsigned int id = (
HcalDetId(subd, ieta[k], iphi[k], depth[k])).rawId();
207 edm::LogVerbatim(
"RecAnalyzer") <<
"Select on " << trigbit_.size() <<
" L1 Trigger selection";
208 for (
unsigned int k = 0;
k < trigbit_.size(); ++
k)
215 std::vector<int> iarray;
217 desc.
add<
bool>(
"runNZS",
true);
218 desc.
add<
bool>(
"noise",
false);
219 desc.
add<
double>(
"eLowHB", 4);
220 desc.
add<
double>(
"eHighHB", 100);
221 desc.
add<
double>(
"eLowHE", 4);
222 desc.
add<
double>(
"eHighHE", 150);
223 desc.
add<
double>(
"eLowHF", 10);
224 desc.
add<
double>(
"eHighHF", 150);
230 desc.
addUntracked<std::vector<int>>(
"triggerBits", iarray);
235 desc.
addUntracked<std::vector<int>>(
"hcalIeta", iarray);
236 desc.
addUntracked<std::vector<int>>(
"hcalIphi", iarray);
237 desc.
addUntracked<std::vector<int>>(
"hcalDepth", iarray);
242 descriptions.
add(
"recAnalyzerMinbias", desc);
246 std::string hc[5] = {
"Empty",
"HB",
"HE",
"HO",
"HF"};
248 hbhe_ =
fs_->
make<TH2D>(
"hbhe",
"Noise in HB/HE", 61, -30.5, 30.5, 72, 0.5, 72.5);
249 hb_ =
fs_->
make<TH2D>(
"hb",
"Noise in HB", 61, -16.5, 16.5, 72, 0.5, 72.5);
250 he_ =
fs_->
make<TH2D>(
"he",
"Noise in HE", 61, -30.5, 30.5, 72, 0.5, 72.5);
251 hf_ =
fs_->
make<TH2D>(
"hf",
"Noise in HF", 82, -41.5, 41.5, 72, 0.5, 72.5);
253 sprintf(title,
"Fraction of channels in HB/HE with E > %4.1f GeV vs Run number",
eMin_);
255 sprintf(title,
"Fraction of channels in HB with E > %4.1f GeV vs Run number",
eMin_);
257 sprintf(title,
"Fraction of channels in HE with E > %4.1f GeV vs Run number",
eMin_);
259 sprintf(title,
"Fraction of channels in HF with E > %4.1f GeV vs Run number",
eMin_);
261 for (
int idet = 1; idet <= 4; idet++) {
262 sprintf(name,
"%s", hc[idet].c_str());
263 sprintf(title,
"Noise distribution for %s", hc[idet].c_str());
267 for (
const auto& hcalid :
hcalID_) {
269 int subdet =
id.subdetId();
270 sprintf(name,
"%s%d_%d_%d", hc[subdet].c_str(),
id.
ieta(),
id.
iphi(),
id.
depth());
272 "Energy Distribution for %s ieta %d iphi %d depth %d",
277 double xmin = (subdet == 4) ? -10 : -1;
278 double xmax = (subdet == 4) ? 90 : 9;
320 for (
const auto& itr :
myMap_) {
321 edm::LogVerbatim(
"RecAnalyzer") <<
"Fired trigger bit number " << itr.first.first;
331 mysubd = itr.first.second.subdet();
332 depth = itr.first.second.depth();
333 iphi = itr.first.second.iphi();
334 ieta = itr.first.second.ieta();
346 edm::LogVerbatim(
"RecAnalyzer") <<
"Exiting from RecAnalyzerMinbias::endjob";
360 double x_min = (
Noise_) ? -3. : 0.;
366 if (hcaltopology->
valid(cell)) {
367 sprintf(name,
"HBeta%dphi%ddep%d",
eta,
phi,
depth);
368 sprintf(title,
"HB #eta %d #phi %d depth %d",
eta,
phi,
depth);
378 x_min = (
Noise_) ? -3. : 0.;
384 if (hcaltopology->
valid(cell)) {
385 sprintf(name,
"HEeta%dphi%ddep%d",
eta,
phi,
depth);
386 sprintf(title,
"HE #eta %d #phi %d depth %d",
eta,
phi,
depth);
396 x_min = (
Noise_) ? -10. : 0.;
402 if (hcaltopology->
valid(cell)) {
403 sprintf(name,
"HFeta%dphi%ddep%d",
eta,
phi,
depth);
404 sprintf(title,
"Energy (HF #eta %d #phi %d depth %d)",
eta,
phi,
depth);
424 double amplitudefullHB(0), amplitudefullHE(0), amplitudefullHF(0);
428 for (
auto const& digi : *(hbhedigi.
product())) {
429 int nTS = digi.size();
430 double amplitudefullTSs = 0.;
433 for (
int i = 0;
i < nTS;
i++)
434 amplitudefullTSs += digi.sample(
i).adc();
436 amplitudefullHB += amplitudefullTSs;
441 for (
int i = 0;
i < nTS;
i++)
442 amplitudefullTSs += digi.sample(
i).adc();
444 amplitudefullHE += amplitudefullTSs;
454 double amplitudefullTSs = 0.;
456 for (
int i = 0;
i < digi.samples();
i++)
457 amplitudefullTSs += digi[
i].
adc();
459 amplitudefullHB += amplitudefullTSs;
462 for (
int i = 0;
i < digi.samples();
i++)
463 amplitudefullTSs += digi[
i].
adc();
465 amplitudefullHE += amplitudefullTSs;
473 for (
auto const& digi : *(hfdigi.
product())) {
474 int nTS = digi.size();
475 double amplitudefullTSs = 0.;
478 for (
int i = 0;
i < nTS;
i++)
479 amplitudefullTSs += digi.sample(
i).adc();
481 amplitudefullHF += amplitudefullTSs;
491 double amplitudefullTSs = 0.;
493 for (
int i = 0;
i < digi.samples();
i++)
494 amplitudefullTSs += digi[
i].
adc();
496 amplitudefullHF += amplitudefullTSs;
509 edm::LogWarning(
"RecAnalyzer") <<
"HcalCalibAlgos: Error! can't get hbhe product!";
522 edm::LogWarning(
"RecAnalyzer") <<
"HcalCalibAlgos: Error! can't get hf product!";
536 if (gtObjectMapRecord.
isValid()) {
537 const std::vector<L1GlobalTriggerObjectMap>& objMapVec = gtObjectMapRecord->gtObjectMap();
538 for (std::vector<L1GlobalTriggerObjectMap>::const_iterator itMap = objMapVec.begin(); itMap != objMapVec.end();
540 bool resultGt = (*itMap).algoGtlResult();
542 int algoBit = (*itMap).algoBitNumber();
556 double eventWeight = 1.0;
560 eventWeight = genEventInfo->weight();
563 << select <<
":" <<
ignoreL1_ <<
" Wt " << eventWeight;
566 analyzeHcal(HithbheMB, HithfMB, 1,
true, eventWeight);
570 if (gtObjectMapRecord.
isValid()) {
571 const std::vector<L1GlobalTriggerObjectMap>& objMapVec = gtObjectMapRecord->gtObjectMap();
573 for (std::vector<L1GlobalTriggerObjectMap>::const_iterator itMap = objMapVec.begin(); itMap != objMapVec.end();
575 bool resultGt = (*itMap).algoGtlResult();
577 int algoBit = (*itMap).algoBitNumber();
578 analyzeHcal(HithbheMB, HithfMB, algoBit, (!ok), eventWeight);
592 int count(0), countHB(0), countHE(0), count2(0), count2HB(0), count2HE(0);
596 double icalconst(1.);
598 std::map<DetId, double>::iterator itr =
corrFactor_.find(mydetid);
600 icalconst = itr->second;
602 HBHERecHit aHit(hbheItr->id(), hbheItr->energy() * icalconst, hbheItr->time());
603 double energyhit = aHit.
energy();
604 DetId id = (*hbheItr).detid();
614 for (
unsigned int i = 0;
i <
hcalID_.size();
i++) {
621 std::map<HcalDetId, TH1D*>::iterator itr1 =
histHC_.find(hid);
623 itr1->second->Fill(energyhit);
625 h_[hid.
subdet() - 1]->Fill(energyhit);
626 if (energyhit >
eMin_) {
639 if (
Noise_ ||
runNZS_ || (energyhit >= eLow && energyhit <= eHigh)) {
640 std::map<std::pair<int, HcalDetId>,
myInfo>::iterator itr1 =
641 myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
642 if (itr1 ==
myMap_.end()) {
644 myMap_[std::pair<int, HcalDetId>(algoBit, hid)] = info;
645 itr1 =
myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
647 itr1->second.theMB0 +=
weight;
648 itr1->second.theMB1 += (weight * energyhit);
649 itr1->second.theMB2 += (weight * energyhit * energyhit);
650 itr1->second.theMB3 += (weight * energyhit * energyhit * energyhit);
651 itr1->second.theMB4 += (weight * energyhit * energyhit * energyhit * energyhit);
652 itr1->second.runcheck =
rnnum_;
666 << count2HB <<
":" << countHB <<
":" << (double)(count2HB) / countHB <<
"\t HE "
667 << count2HE <<
":" << countHE <<
":" << (double)(count2HE) / countHE;
669 int countHF(0), count2HF(0);
674 double icalconst(1.);
676 std::map<DetId, double>::iterator itr =
corrFactor_.find(mydetid);
678 icalconst = itr->second;
680 HFRecHit aHit(hfItr->id(), hfItr->energy() * icalconst, hfItr->time());
682 double energyhit = aHit.
energy();
683 DetId id = (*hfItr).detid();
687 for (
unsigned int i = 0;
i <
hcalID_.size();
i++) {
694 std::map<HcalDetId, TH1D*>::iterator itr1 =
histHC_.find(hid);
696 itr1->second->Fill(energyhit);
698 h_[hid.
subdet() - 1]->Fill(energyhit);
699 if (energyhit >
eMin_) {
710 std::map<std::pair<int, HcalDetId>,
myInfo>::iterator itr1 =
711 myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
712 if (itr1 ==
myMap_.end()) {
714 myMap_[std::pair<int, HcalDetId>(algoBit, hid)] = info;
715 itr1 =
myMap_.find(std::pair<int, HcalDetId>(algoBit, hid));
717 itr1->second.theMB0 +=
weight;
718 itr1->second.theMB1 += (weight * energyhit);
719 itr1->second.theMB2 += (weight * energyhit * energyhit);
720 itr1->second.theMB3 += (weight * energyhit * energyhit * energyhit);
721 itr1->second.theMB4 += (weight * energyhit * energyhit * energyhit * energyhit);
722 itr1->second.runcheck =
rnnum_;
726 if (fill && countHF > 0)
730 edm::LogVerbatim(
"RecAnalyzer") <<
"HF " << count2HF <<
":" << countHF <<
":" << (double)(count2HF) / countHF;
constexpr float energy() const
~RecAnalyzerMinbias() override
Log< level::Info, true > LogVerbatim
RecAnalyzerMinbias(const edm::ParameterSet &)
T getUntrackedParameter(std::string const &, T const &) const
std::vector< int > trigbit_
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > tok_htopo_
edm::EDGetTokenT< HFDigiCollection > tok_hfdigi_
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
uint16_t *__restrict__ id
bool getByToken(EDGetToken token, Handle< PROD > &result) const
TH1D * h_AmplitudeHFtest_
#define DEFINE_FWK_MODULE(type)
bool valid(const DetId &id) const override
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_
std::vector< TH1D * > histo_
edm::EDGetTokenT< QIE10DigiCollection > tok_qie10digi_
bool getData(T &iHolder) const
constexpr HcalSubdetector subdet() const
get the subdetector
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhedigi_
constexpr int iphi() const
get the cell iphi
edm::EDGetTokenT< HFRecHitCollection > tok_hfrecoMB_
Abs< T >::type abs(const T &t)
constexpr int ieta() const
get the cell ieta
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_
TH1D * h_AmplitudeHBtest_
void fill(std::map< std::string, TH1 * > &h, const std::string &s, double x)
void endRun(edm::Run const &, edm::EventSetup const &) override
edm::Service< TFileService > fs_
T const * product() const
std::vector< unsigned int > hcalID_
T getParameter(std::string const &) const
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_
Log< level::Warning, false > LogWarning
edm::EDGetTokenT< L1GlobalTriggerObjectMapRecord > tok_hltL1GtMap_
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
TH1D * h_AmplitudeHEtest_
void beginRun(edm::Run const &, edm::EventSetup const &) override
const_iterator begin() const
std::map< DetId, double > corrFactor_
uint16_t *__restrict__ uint16_t const *__restrict__ adc