CMS 3D CMS Logo

ECALpedestalPCLworker.cc
Go to the documentation of this file.
1 
9 #include <iostream>
10 #include <sstream>
11 
12 
13 
15 
16 {
17  digiTagEB_= iConfig.getParameter<edm::InputTag>("BarrelDigis");
18  digiTagEE_= iConfig.getParameter<edm::InputTag>("EndcapDigis");
19 
20  digiTokenEB_ = consumes<EBDigiCollection>(digiTagEB_);
21  digiTokenEE_ = consumes<EEDigiCollection>(digiTagEE_);
22 
23  pedestalSamples_ = iConfig.getParameter<uint32_t>("pedestalSamples");
24  checkSignal_ = iConfig.getParameter<bool>("checkSignal");
25  sThresholdEB_ = iConfig.getParameter<uint32_t>("sThresholdEB");
26  sThresholdEE_ = iConfig.getParameter<uint32_t>("sThresholdEE");
27 
28  dynamicBooking_ = iConfig.getParameter<bool>("dynamicBooking");
29  fixedBookingCenterBin_ = iConfig.getParameter<int>("fixedBookingCenterBin");
30  nBins_ = iConfig.getParameter<int>("nBins");
31  dqmDir_ = iConfig.getParameter<std::string>("dqmDir");
32 }
33 
34 
35 
36 // ------------ method called for each event ------------
37 void
39 {
40  using namespace edm;
41 
43  iEvent.getByLabel(digiTagEB_,pDigiEB);
44 
46  iEvent.getByLabel(digiTagEE_,pDigiEE);
47 
48 
49 
50  for (EBDigiCollection::const_iterator pDigi=pDigiEB->begin(); pDigi!=pDigiEB->end(); ++pDigi){
51 
52  EBDetId id = pDigi->id();
53  uint32_t hashedId = id.hashedIndex();
54 
55  EBDataFrame digi( *pDigi );
56 
57  if (checkSignal_){
58  uint16_t maxdiff = *std::max_element(digi.frame().begin(), digi.frame().end(), adc_compare ) -
59  *std::min_element(digi.frame().begin(), digi.frame().end(), adc_compare );
60  if ( maxdiff> sThresholdEB_ ) continue; // assume there is signal in this frame
61  }
62 
63  //for (auto& mgpasample : digi.frame()) meEB_[hashedId]->Fill(mgpasample&0xFFF);
64  for (edm::DataFrame::iterator mgpasample = digi.frame().begin();
65  mgpasample!=digi.frame().begin()+pedestalSamples_;
66  ++mgpasample )
67  meEB_[hashedId]->Fill(*mgpasample&0xFFF);
68 
69  } // eb digis
70 
71 
72 
73  for (EEDigiCollection::const_iterator pDigi=pDigiEE->begin(); pDigi!=pDigiEE->end(); ++pDigi){
74 
75  EEDetId id = pDigi->id();
76  uint32_t hashedId = id.hashedIndex();
77 
78  EEDataFrame digi( *pDigi );
79 
80  if (checkSignal_){
81  uint16_t maxdiff = *std::max_element(digi.frame().begin(), digi.frame().end(), adc_compare ) -
82  *std::min_element(digi.frame().begin(), digi.frame().end(), adc_compare );
83  if ( maxdiff> sThresholdEE_ ) continue; // assume there is signal in this frame
84  }
85 
86  //for (auto& mgpasample : digi.frame()) meEE_[hashedId]->Fill(mgpasample&0xFFF);
87  for (edm::DataFrame::iterator mgpasample = digi.frame().begin();
88  mgpasample!=digi.frame().begin()+pedestalSamples_;
89  ++mgpasample )
90  meEE_[hashedId]->Fill(*mgpasample&0xFFF);
91 
92  } // ee digis
93 
94 
95 
96 
97 }
98 
99 
100 void
102 {
103 }
104 
105 
106 void
108 {
109 }
110 
111 
112 void
115  desc.setUnknown();
116  descriptions.addDefault(desc);
117 }
118 
119 
120 void
122 
123  ibooker.cd();
124  ibooker.setCurrentFolder(dqmDir_);
125 
127  es.get<EcalPedestalsRcd>().get(peds);
128 
129 
130  for ( uint32_t i = 0 ; i< EBDetId::kSizeForDenseIndexing; ++i){
131 
132  std::string hname = "eb_" + std::to_string(i);
134  int centralBin = fixedBookingCenterBin_;
135 
136  if (dynamicBooking_){
137  centralBin = int ((peds->find(id))->mean_x12) ;
138  }
139 
140  int min = centralBin - nBins_/2;
141  int max = centralBin + nBins_/2;
142 
143  meEB_.push_back(ibooker.book1D(hname,hname,nBins_,min,max));
144  }
145 
146  for ( uint32_t i = 0 ; i< EEDetId::kSizeForDenseIndexing; ++i){
147 
148  std::string hname = "ee_" + std::to_string(i);
149 
151  int centralBin = fixedBookingCenterBin_;
152 
153  if (dynamicBooking_){
154  centralBin = int ((peds->find(id))->mean_x12) ;
155  }
156 
157  int min = centralBin - nBins_/2;
158  int max = centralBin + nBins_/2;
159 
160  meEE_.push_back(ibooker.book1D(hname,hname,nBins_,min,max));
161 
162  }
163 
164 }
static EEDetId detIdFromDenseIndex(uint32_t din)
Definition: EEDetId.h:220
T getParameter(std::string const &) const
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:86
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< EEDigiCollection > digiTokenEE_
void cd(void)
Definition: DQMStore.cc:269
const_iterator begin() const
iterator begin()
Definition: DataFrame.h:48
static EBDetId detIdFromDenseIndex(uint32_t di)
Definition: EBDetId.h:111
std::vector< MonitorElement * > meEE_
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
static bool adc_compare(uint16_t a, uint16_t b)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
T min(T a, T b)
Definition: MathUtil.h:58
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:416
iterator end()
Definition: DataFrame.h:51
Definition: DetId.h:18
ECALpedestalPCLworker(const edm::ParameterSet &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
int hashedIndex() const
Definition: EEDetId.h:182
const T & get() const
Definition: EventSetup.h:56
edm::DataFrame const & frame() const
Definition: EcalDataFrame.h:50
virtual void analyze(const edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< EBDigiCollection > digiTokenEB_
const_iterator end() const
std::vector< MonitorElement * > meEB_
HLT enums.
data_type * iterator
Definition: DataFrame.h:21
const_iterator find(uint32_t rawId) const
Definition: Run.h:42