CMS 3D CMS Logo

ECALpedestalPCLworker.cc
Go to the documentation of this file.
1 
9 #include <iostream>
10 #include <sstream>
11 
13 
14 {
15  edm::InputTag digiTagEB = iConfig.getParameter<edm::InputTag>("BarrelDigis");
16  edm::InputTag digiTagEE = iConfig.getParameter<edm::InputTag>("EndcapDigis");
17 
18  digiTokenEB_ = consumes<EBDigiCollection>(digiTagEB);
19  digiTokenEE_ = consumes<EEDigiCollection>(digiTagEE);
20 
21  pedestalSamples_ = iConfig.getParameter<uint32_t>("pedestalSamples");
22  checkSignal_ = iConfig.getParameter<bool>("checkSignal");
23  sThresholdEB_ = iConfig.getParameter<uint32_t>("sThresholdEB");
24  sThresholdEE_ = iConfig.getParameter<uint32_t>("sThresholdEE");
25 
26  dynamicBooking_ = iConfig.getParameter<bool>("dynamicBooking");
27  fixedBookingCenterBin_ = iConfig.getParameter<int>("fixedBookingCenterBin");
28  nBins_ = iConfig.getParameter<int>("nBins");
29  dqmDir_ = iConfig.getParameter<std::string>("dqmDir");
30 
31  edm::InputTag tcdsRecord = iConfig.getParameter<edm::InputTag>("tcdsRecord");
32  tcdsToken_ = consumes<TCDSRecord>(tcdsRecord);
33  requireStableBeam_ = iConfig.getParameter<bool>("requireStableBeam");
34 }
35 
36 // ------------ method called for each event ------------
38  using namespace edm;
39 
41  iEvent.getByToken(digiTokenEB_, pDigiEB);
42 
44  iEvent.getByToken(digiTokenEE_, pDigiEE);
45 
46  // Only Events with stable beam
47 
48  if (requireStableBeam_) {
49  edm::Handle<TCDSRecord> tcdsData;
50  iEvent.getByToken(tcdsToken_, tcdsData);
51  int beamMode = tcdsData->getBST().getBeamMode();
52  if (beamMode != BSTRecord::BeamMode::STABLE)
53  return;
54  }
55 
56  for (EBDigiCollection::const_iterator pDigi = pDigiEB->begin(); pDigi != pDigiEB->end(); ++pDigi) {
57  EBDetId id = pDigi->id();
58  uint32_t hashedId = id.hashedIndex();
59 
60  EBDataFrame digi(*pDigi);
61 
62  if (checkSignal_) {
63  uint16_t maxdiff = *std::max_element(digi.frame().begin(), digi.frame().end(), adc_compare) -
64  *std::min_element(digi.frame().begin(), digi.frame().end(), adc_compare);
65  if (maxdiff > sThresholdEB_)
66  continue; // assume there is signal in this frame
67  }
68 
69  //for (auto& mgpasample : digi.frame()) meEB_[hashedId]->Fill(mgpasample&0xFFF);
70  for (edm::DataFrame::iterator mgpasample = digi.frame().begin();
71  mgpasample != digi.frame().begin() + pedestalSamples_;
72  ++mgpasample)
73  meEB_[hashedId]->Fill(*mgpasample & 0xFFF);
74 
75  } // eb digis
76 
77  for (EEDigiCollection::const_iterator pDigi = pDigiEE->begin(); pDigi != pDigiEE->end(); ++pDigi) {
78  EEDetId id = pDigi->id();
79  uint32_t hashedId = id.hashedIndex();
80 
81  EEDataFrame digi(*pDigi);
82 
83  if (checkSignal_) {
84  uint16_t maxdiff = *std::max_element(digi.frame().begin(), digi.frame().end(), adc_compare) -
85  *std::min_element(digi.frame().begin(), digi.frame().end(), adc_compare);
86  if (maxdiff > sThresholdEE_)
87  continue; // assume there is signal in this frame
88  }
89 
90  //for (auto& mgpasample : digi.frame()) meEE_[hashedId]->Fill(mgpasample&0xFFF);
91  for (edm::DataFrame::iterator mgpasample = digi.frame().begin();
92  mgpasample != digi.frame().begin() + pedestalSamples_;
93  ++mgpasample)
94  meEE_[hashedId]->Fill(*mgpasample & 0xFFF);
95 
96  } // ee digis
97 }
98 
101  desc.setUnknown();
102  descriptions.addDefault(desc);
103 }
104 
106  ibooker.cd();
107  ibooker.setCurrentFolder(dqmDir_);
108 
110  es.get<EcalPedestalsRcd>().get(peds);
111 
112  for (uint32_t i = 0; i < EBDetId::kSizeForDenseIndexing; ++i) {
113  ibooker.setCurrentFolder(dqmDir_ + "/EB/" + std::to_string(int(i / 100)));
114 
115  std::string hname = "eb_" + std::to_string(i);
117  int centralBin = fixedBookingCenterBin_;
118 
119  if (dynamicBooking_) {
120  centralBin = int((peds->find(id))->mean_x12);
121  }
122 
123  int min = centralBin - nBins_ / 2;
124  int max = centralBin + nBins_ / 2;
125 
126  meEB_.push_back(ibooker.book1D(hname, hname, nBins_, min, max));
127  }
128 
129  for (uint32_t i = 0; i < EEDetId::kSizeForDenseIndexing; ++i) {
130  ibooker.setCurrentFolder(dqmDir_ + "/EE/" + std::to_string(int(i / 100)));
131 
132  std::string hname = "ee_" + std::to_string(i);
133 
135  int centralBin = fixedBookingCenterBin_;
136 
137  if (dynamicBooking_) {
138  centralBin = int((peds->find(id))->mean_x12);
139  }
140 
141  int min = centralBin - nBins_ / 2;
142  int max = centralBin + nBins_ / 2;
143 
144  meEE_.push_back(ibooker.book1D(hname, hname, nBins_, min, max));
145  }
146 }
EBDetId::hashedIndex
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:82
mps_fire.i
i
Definition: mps_fire.py:428
EcalPedestals.h
EcalDataFrame::frame
edm::DataFrame const & frame() const
Definition: EcalDataFrame.h:50
ECALpedestalPCLworker::nBins_
int nBins_
Definition: ECALpedestalPCLworker.h:59
ESHandle.h
edm::DataFrameContainer::const_iterator
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: DataFrameContainer.h:61
edm::Run
Definition: Run.h:45
min
T min(T a, T b)
Definition: MathUtil.h:58
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
EBDataFrame
Definition: EBDataFrame.h:11
EBDetId.h
EEDetId.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
ECALpedestalPCLworker.h
ECALpedestalPCLworker::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: ECALpedestalPCLworker.cc:99
edm::Handle< EBDigiCollection >
ECALpedestalPCLworker::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: ECALpedestalPCLworker.cc:105
EEDetId::detIdFromDenseIndex
static EEDetId detIdFromDenseIndex(uint32_t din)
Definition: EEDetId.h:220
DetId
Definition: DetId.h:17
ECALpedestalPCLworker::digiTokenEB_
edm::EDGetTokenT< EBDigiCollection > digiTokenEB_
Definition: ECALpedestalPCLworker.h:43
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
BSTRecord::getBeamMode
const uint16_t getBeamMode() const
Definition: BSTRecord.h:70
EEDetId::kSizeForDenseIndexing
Definition: EEDetId.h:329
edm::ESHandle
Definition: DTSurvey.h:22
ECALpedestalPCLworker::tcdsToken_
edm::EDGetTokenT< TCDSRecord > tcdsToken_
Definition: ECALpedestalPCLworker.h:45
dqm::implementation::NavigatorBase::cd
virtual void cd()
Definition: DQMStore.cc:29
EcalCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: EcalCondObjectContainer.h:53
edm::DataFrame::iterator
data_type * iterator
Definition: DataFrame.h:20
ECALpedestalPCLworker::meEE_
std::vector< MonitorElement * > meEE_
Definition: ECALpedestalPCLworker.h:48
EEDetId
Definition: EEDetId.h:14
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ECALpedestalPCLworker::meEB_
std::vector< MonitorElement * > meEB_
Definition: ECALpedestalPCLworker.h:47
edm::ParameterSet
Definition: ParameterSet.h:47
ECALpedestalPCLworker::adc_compare
static bool adc_compare(uint16_t a, uint16_t b)
Definition: ECALpedestalPCLworker.h:65
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
EBDetId::detIdFromDenseIndex
static EBDetId detIdFromDenseIndex(uint32_t di)
Definition: EBDetId.h:107
ECALpedestalPCLworker::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: ECALpedestalPCLworker.cc:37
ECALpedestalPCLworker::sThresholdEB_
uint32_t sThresholdEB_
Definition: ECALpedestalPCLworker.h:52
EEDetId::hashedIndex
int hashedIndex() const
Definition: EEDetId.h:183
ECALpedestalPCLworker::requireStableBeam_
bool requireStableBeam_
Definition: ECALpedestalPCLworker.h:62
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::DataFrameContainer::begin
const_iterator begin() const
The iterator returned can not safely be used across threads.
Definition: DataFrameContainer.h:149
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
HcalObjRepresent::Fill
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Definition: HcalObjRepresent.h:1053
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
ECALpedestalPCLworker::sThresholdEE_
uint32_t sThresholdEE_
Definition: ECALpedestalPCLworker.h:55
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::DataFrame::end
constexpr iterator end()
Definition: DataFrame.h:35
ECALpedestalPCLworker::dqmDir_
std::string dqmDir_
Definition: ECALpedestalPCLworker.h:60
ECALpedestalPCLworker::fixedBookingCenterBin_
int fixedBookingCenterBin_
Definition: ECALpedestalPCLworker.h:58
EventSetup.h
EBDetId::kSizeForDenseIndexing
Definition: EBDetId.h:155
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqm::implementation::IBooker
Definition: DQMStore.h:43
ECALpedestalPCLworker::dynamicBooking_
bool dynamicBooking_
Definition: ECALpedestalPCLworker.h:57
TCDSRecord::getBST
const BSTRecord & getBST() const
Definition: TCDSRecord.h:100
EcalPedestalsRcd.h
EcalPedestalsRcd
Definition: EcalPedestalsRcd.h:5
EEDataFrame
Definition: EEDataFrame.h:12
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
edm::DataFrameContainer::end
const_iterator end() const
Definition: DataFrameContainer.h:152
edm::InputTag
Definition: InputTag.h:15
ECALpedestalPCLworker::pedestalSamples_
uint32_t pedestalSamples_
Definition: ECALpedestalPCLworker.h:50
ECALpedestalPCLworker::checkSignal_
bool checkSignal_
Definition: ECALpedestalPCLworker.h:51
edm::DataFrame::begin
constexpr iterator begin()
Definition: DataFrame.h:33
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
ECALpedestalPCLworker::digiTokenEE_
edm::EDGetTokenT< EEDigiCollection > digiTokenEE_
Definition: ECALpedestalPCLworker.h:44
ECALpedestalPCLworker::ECALpedestalPCLworker
ECALpedestalPCLworker(const edm::ParameterSet &)
Definition: ECALpedestalPCLworker.cc:12