CMS 3D CMS Logo

EcalTBValidation.cc
Go to the documentation of this file.
1 // Ecal H4 tesbeam analysis
11 
12 #include <iostream>
13 #include <string>
14 
16  data_ = config.getUntrackedParameter<int>("data", -1000);
17  xtalInBeam_ = config.getUntrackedParameter<int>("xtalInBeam", -1000);
18 
19  digiCollection_ = config.getParameter<std::string>("digiCollection");
20  digiProducer_ = config.getParameter<std::string>("digiProducer");
21  hitCollection_ = config.getParameter<std::string>("hitCollection");
22  hitProducer_ = config.getParameter<std::string>("hitProducer");
23  hodoRecInfoCollection_ = config.getParameter<std::string>("hodoRecInfoCollection");
24  hodoRecInfoProducer_ = config.getParameter<std::string>("hodoRecInfoProducer");
25  tdcRecInfoCollection_ = config.getParameter<std::string>("tdcRecInfoCollection");
26  tdcRecInfoProducer_ = config.getParameter<std::string>("tdcRecInfoProducer");
27  eventHeaderCollection_ = config.getParameter<std::string>("eventHeaderCollection");
28  eventHeaderProducer_ = config.getParameter<std::string>("eventHeaderProducer");
29 
30  digi_Token_ = consumes<EBDigiCollection>(edm::InputTag(digiProducer_, digiCollection_));
31  hit_Token_ = consumes<EBUncalibratedRecHitCollection>(edm::InputTag(hitProducer_, hitCollection_));
32  hodoRec_Token_ = consumes<EcalTBHodoscopeRecInfo>(edm::InputTag(hodoRecInfoProducer_, hodoRecInfoCollection_));
34  eventHeader_Token_ = consumes<EcalTBEventHeader>(edm::InputTag(eventHeaderProducer_));
35  // rootfile_ =
36  // config.getUntrackedParameter<std::string>("rootfile","EcalTBValidation.root");
37 
38  // verbosity...
39  verbose_ = config.getUntrackedParameter<bool>("verbose", false);
40 
41  meETBxib_ = nullptr;
42  meETBampltdc_ = nullptr;
43  meETBShape_ = nullptr;
44  meETBhodoX_ = nullptr;
45  meETBhodoY_ = nullptr;
46  meETBe1x1_ = nullptr;
47  meETBe3x3_ = nullptr;
48  meETBe5x5_ = nullptr;
49  meETBe1e9_ = nullptr;
50  meETBe1e25_ = nullptr;
51  meETBe9e25_ = nullptr;
52  meETBe1x1_center_ = nullptr;
53  meETBe3x3_center_ = nullptr;
54  meETBe5x5_center_ = nullptr;
55  meETBe1vsX_ = nullptr;
56  meETBe1vsY_ = nullptr;
57  meETBe1e9vsX_ = nullptr;
58  meETBe1e9vsY_ = nullptr;
59  meETBe1e25vsX_ = nullptr;
60  meETBe1e25vsY_ = nullptr;
61  meETBe9e25vsX_ = nullptr;
62  meETBe9e25vsY_ = nullptr;
63 }
64 
66 
68  std::string hname;
69  ibooker.setCurrentFolder("EcalRecHitsV/EcalTBValidationTask");
70 
71  hname = "xtal in beam position";
72  meETBxib_ = ibooker.book2D(hname, hname, 85, 0., 85., 20, 0., 20.);
73  hname = "Max Amplitude vs TDC offset";
74  meETBampltdc_ = ibooker.book2D(hname, hname, 100, 0., 1., 1000, 0., 4000.);
75  hname = "Beam Profile X";
76  meETBhodoX_ = ibooker.book1D(hname, hname, 100, -20., 20.);
77  hname = "Beam Profile Y";
78  meETBhodoY_ = ibooker.book1D(hname, hname, 100, -20., 20.);
79  hname = "E1x1 energy";
80  meETBe1x1_ = ibooker.book1D(hname, hname, 1000, 0., 4000.);
81  hname = "E3x3 energy";
82  meETBe3x3_ = ibooker.book1D(hname, hname, 1000, 0., 4000.);
83  hname = "E5x5 energy";
84  meETBe5x5_ = ibooker.book1D(hname, hname, 1000, 0., 4000.);
85  hname = "E1x1 energy center";
86  meETBe1x1_center_ = ibooker.book1D(hname, hname, 1000, 0., 4000.);
87  hname = "E3x3 energy center";
88  meETBe3x3_center_ = ibooker.book1D(hname, hname, 1000, 0., 4000.);
89  hname = "E5x5 energy center";
90  meETBe5x5_center_ = ibooker.book1D(hname, hname, 1000, 0., 4000.);
91  hname = "E1 over E9 ratio";
92  meETBe1e9_ = ibooker.book1D(hname, hname, 600, 0., 1.2);
93  hname = "E1 over E25 ratio";
94  meETBe1e25_ = ibooker.book1D(hname, hname, 600, 0., 1.2);
95  hname = "E9 over E25 ratio";
96  meETBe9e25_ = ibooker.book1D(hname, hname, 600, 0., 1.2);
97  hname = "E1 vs X";
98  meETBe1vsX_ = ibooker.book2D(hname, hname, 80, -20, 20, 1000, 0., 4000.);
99  hname = "E1 vs Y";
100  meETBe1vsY_ = ibooker.book2D(hname, hname, 80, -20, 20, 1000, 0., 4000.);
101  hname = "E1 over E9 vs X";
102  meETBe1e9vsX_ = ibooker.book2D(hname, hname, 80, -20, 20, 600, 0., 1.2);
103  hname = "E1 over E9 vs Y";
104  meETBe1e9vsY_ = ibooker.book2D(hname, hname, 80, -20, 20, 600, 0., 1.2);
105  hname = "E1 over E25 vs X";
106  meETBe1e25vsX_ = ibooker.book2D(hname, hname, 80, -20, 20, 600, 0., 1.2);
107  hname = "E1 over E25 vs Y";
108  meETBe1e25vsY_ = ibooker.book2D(hname, hname, 80, -20, 20, 600, 0., 1.2);
109  hname = "E9 over E25 vs X";
110  meETBe9e25vsX_ = ibooker.book2D(hname, hname, 80, -20, 20, 600, 0., 1.2);
111  hname = "E9 over E25 vs Y";
112  meETBe9e25vsY_ = ibooker.book2D(hname, hname, 80, -20, 20, 600, 0., 1.2);
113  hname = "Xtal in Beam Shape";
114  meETBShape_ = ibooker.book2D(hname, hname, 250, 0, 10, 350, 0, 3500);
115 }
116 
118  using namespace edm;
119  using namespace cms;
120 
121  // digis
122  const EBDigiCollection *theDigis = nullptr;
124  event.getByToken(digi_Token_, pdigis);
125  if (pdigis.isValid()) {
126  theDigis = pdigis.product();
127  } else {
128  std::cerr << "Error! can't get the product " << digiCollection_.c_str() << std::endl;
129  return;
130  }
131 
132  // rechits
133  const EBUncalibratedRecHitCollection *theHits = nullptr;
135  event.getByToken(hit_Token_, phits);
136  if (phits.isValid()) {
137  theHits = phits.product();
138  } else {
139  std::cerr << "Error! can't get the product " << hitCollection_.c_str() << std::endl;
140  return;
141  }
142 
143  // hodoscopes
144  const EcalTBHodoscopeRecInfo *theHodo = nullptr;
146  event.getByToken(hodoRec_Token_, pHodo);
147  if (pHodo.isValid()) {
148  theHodo = pHodo.product();
149  } else {
150  std::cerr << "Error! can't get the product " << hodoRecInfoCollection_.c_str() << std::endl;
151  return;
152  }
153 
154  // tdc
155  const EcalTBTDCRecInfo *theTDC = nullptr;
157  event.getByToken(tdcRec_Token_, pTDC);
158  if (pTDC.isValid()) {
159  theTDC = pTDC.product();
160  } else {
161  std::cerr << "Error! can't get the product " << tdcRecInfoCollection_.c_str() << std::endl;
162  return;
163  }
164 
165  // event header
166  const EcalTBEventHeader *evtHeader = nullptr;
167  Handle<EcalTBEventHeader> pEventHeader;
168  event.getByToken(eventHeader_Token_, pEventHeader);
169  if (pEventHeader.isValid()) {
170  evtHeader = pEventHeader.product();
171  } else {
172  std::cerr << "Error! can't get the product " << eventHeaderProducer_.c_str() << std::endl;
173  return;
174  }
175 
176  // -----------------------------------------------------------------------
177  // xtal-in-beam
178  EBDetId xtalInBeamId(1, xtalInBeam_, EBDetId::SMCRYSTALMODE);
179  if (xtalInBeamId == EBDetId(0)) {
180  return;
181  }
182  int xibEta = xtalInBeamId.ieta();
183  int xibPhi = xtalInBeamId.iphi();
184 
185  // skipping events with moving table (in data)
186  if (data_ && (evtHeader->tableIsMoving()))
187  return;
188 
189  // amplitudes
190  EBDetId Xtals5x5[25];
191  for (unsigned int icry = 0; icry < 25; icry++) {
192  unsigned int row = icry / 5;
193  unsigned int column = icry % 5;
194  int ieta = xtalInBeamId.ieta() + column - 2;
195  int iphi = xtalInBeamId.iphi() + row - 2;
196  if (EBDetId::validDetId(ieta, iphi)) {
198  if (tempId.ism() == 1)
199  Xtals5x5[icry] = tempId;
200  else
201  Xtals5x5[icry] = EBDetId(0);
202  } else {
203  Xtals5x5[icry] = EBDetId(0);
204  }
205  }
206 
207  // matrices
208  double ampl1x1 = 0.;
209  double ampl3x3 = 0.;
210  double ampl5x5 = 0.;
211  for (unsigned int icry = 0; icry < 25; icry++) {
212  if (!Xtals5x5[icry].null()) {
213  double theAmpl = (theHits->find(Xtals5x5[icry]))->amplitude();
214  ampl5x5 += theAmpl;
215  if (icry == 12) {
216  ampl1x1 = theAmpl;
217  }
218  if (icry == 6 || icry == 7 || icry == 8 || icry == 11 || icry == 12 || icry == 13 || icry == 16 || icry == 17 ||
219  icry == 18) {
220  ampl3x3 += theAmpl;
221  }
222  }
223  }
224 
225  // pulse shape
226  double sampleSave[10];
227  for (int ii = 0; ii < 10; ++ii) {
228  sampleSave[ii] = 0.0;
229  }
230  EBDigiCollection::const_iterator thisDigi = theDigis->find(xtalInBeamId);
231  // int sMax = -1; // UNUSED
232  double eMax = 0.;
233  if (thisDigi != theDigis->end()) {
234  EBDataFrame myDigi = (*thisDigi);
235  for (int sample = 0; sample < myDigi.size(); ++sample) {
236  double analogSample = myDigi.sample(sample).adc();
237  sampleSave[sample] = analogSample;
238  if (eMax < analogSample) {
239  eMax = analogSample;
240  // sMax = sample; // UNUSED
241  }
242  }
243  }
244 
245  // beam profile
246  double xBeam = theHodo->posX();
247  double yBeam = theHodo->posY();
248 
249  // filling histos
250  meETBxib_->Fill(xibEta, xibPhi);
251  meETBhodoX_->Fill(xBeam);
252  meETBhodoY_->Fill(yBeam);
253  meETBampltdc_->Fill(theTDC->offset(), ampl1x1);
254  meETBe1x1_->Fill(ampl1x1);
255  meETBe3x3_->Fill(ampl3x3);
256  meETBe5x5_->Fill(ampl5x5);
257  meETBe1e9_->Fill(ampl1x1 / ampl3x3);
258  meETBe1e25_->Fill(ampl1x1 / ampl5x5);
259  meETBe9e25_->Fill(ampl3x3 / ampl5x5);
260  meETBe1vsX_->Fill(xBeam, ampl1x1);
261  meETBe1vsY_->Fill(yBeam, ampl1x1);
262  meETBe1e9vsX_->Fill(xBeam, ampl1x1 / ampl3x3);
263  meETBe1e9vsY_->Fill(yBeam, ampl1x1 / ampl3x3);
264  meETBe1e25vsX_->Fill(xBeam, ampl1x1 / ampl5x5);
265  meETBe1e25vsY_->Fill(yBeam, ampl1x1 / ampl5x5);
266  meETBe9e25vsX_->Fill(xBeam, ampl3x3 / ampl5x5);
267  meETBe9e25vsY_->Fill(yBeam, ampl3x3 / ampl5x5);
268 
269  for (int ii = 0; ii < 10; ++ii) {
270  meETBShape_->Fill(double(ii) + theTDC->offset(), sampleSave[ii]);
271  }
272 
273  if ((fabs(xBeam) < 2.5) && (fabs(yBeam) < 2.5)) {
274  meETBe1x1_center_->Fill(ampl1x1);
275  meETBe3x3_center_->Fill(ampl3x3);
276  meETBe5x5_center_->Fill(ampl5x5);
277  }
278 }
EcalDataFrame::sample
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
EBDetId::ieta
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
CustomPhysics_cfi.amplitude
amplitude
Definition: CustomPhysics_cfi.py:12
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EcalTBValidation::hodoRecInfoProducer_
std::string hodoRecInfoProducer_
Definition: EcalTBValidation.h:39
EcalTBValidation.h
edm::DataFrameContainer::const_iterator
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: DataFrameContainer.h:61
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
EcalTBValidation::hitCollection_
std::string hitCollection_
Definition: EcalTBValidation.h:36
EcalTBValidation::eventHeaderCollection_
std::string eventHeaderCollection_
Definition: EcalTBValidation.h:42
EcalTBValidation::meETBe1vsX_
MonitorElement * meETBe1vsX_
Definition: EcalTBValidation.h:75
edm::Run
Definition: Run.h:45
EcalTBValidation::verbose_
bool verbose_
Definition: EcalTBValidation.h:29
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
EcalTBValidation::eventHeader_Token_
edm::EDGetTokenT< EcalTBEventHeader > eventHeader_Token_
Definition: EcalTBValidation.h:49
EBDataFrame
Definition: EBDataFrame.h:11
EcalTBValidation::tdcRecInfoProducer_
std::string tdcRecInfoProducer_
Definition: EcalTBValidation.h:41
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
edm::SortedCollection
Definition: SortedCollection.h:49
EcalUncalibratedRecHit.h
DQMStore.h
EcalTBValidation::meETBe3x3_center_
MonitorElement * meETBe3x3_center_
Definition: EcalTBValidation.h:73
EcalTBValidation::~EcalTBValidation
~EcalTBValidation() override
Definition: EcalTBValidation.cc:65
EcalTBValidation::xtalInBeam_
int xtalInBeam_
Definition: EcalTBValidation.h:32
edm::Handle< EBDigiCollection >
EcalTBValidation::meETBe1e9vsY_
MonitorElement * meETBe1e9vsY_
Definition: EcalTBValidation.h:78
EcalTBValidation::meETBe1vsY_
MonitorElement * meETBe1vsY_
Definition: EcalTBValidation.h:76
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
EcalRecHitCollections.h
EcalTBEventHeader
Definition: EcalTBEventHeader.h:14
EcalTBValidation::meETBe1e25vsY_
MonitorElement * meETBe1e25vsY_
Definition: EcalTBValidation.h:80
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
EcalTBValidation::meETBe1x1_center_
MonitorElement * meETBe1x1_center_
Definition: EcalTBValidation.h:72
EcalTBValidation::meETBe1x1_
MonitorElement * meETBe1x1_
Definition: EcalTBValidation.h:66
config
Definition: config.py:1
EcalMGPASample::adc
int adc() const
get the ADC sample (12 bits)
Definition: EcalMGPASample.h:31
EcalTBValidation::meETBe1e9vsX_
MonitorElement * meETBe1e9vsX_
Definition: EcalTBValidation.h:77
EcalTBTDCRecInfo::offset
float offset() const
Definition: EcalTBTDCRecInfo.h:19
EcalTBHodoscopeRecInfo
Definition: EcalTBHodoscopeRecInfo.h:12
EcalTBValidation::hodoRecInfoCollection_
std::string hodoRecInfoCollection_
Definition: EcalTBValidation.h:38
Service.h
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
EcalTBValidation::tdcRecInfoCollection_
std::string tdcRecInfoCollection_
Definition: EcalTBValidation.h:40
EcalTBValidation::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: EcalTBValidation.cc:117
EcalDigiCollections.h
EcalTBValidation::meETBhodoX_
MonitorElement * meETBhodoX_
Definition: EcalTBValidation.h:64
EcalTBValidation::meETBe1e9_
MonitorElement * meETBe1e9_
Definition: EcalTBValidation.h:69
EcalTBValidation::meETBShape_
MonitorElement * meETBShape_
Definition: EcalTBValidation.h:63
EcalTBValidation::meETBhodoY_
MonitorElement * meETBhodoY_
Definition: EcalTBValidation.h:65
EcalTBValidation::meETBampltdc_
MonitorElement * meETBampltdc_
Definition: EcalTBValidation.h:62
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EBDetId::ETAPHIMODE
static const int ETAPHIMODE
Definition: EBDetId.h:158
EcalTBValidation::digi_Token_
edm::EDGetTokenT< EBDigiCollection > digi_Token_
Definition: EcalTBValidation.h:45
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
edm::ParameterSet
Definition: ParameterSet.h:36
EcalTBHodoscopeRecInfo.h
EcalTBValidation::meETBe1e25_
MonitorElement * meETBe1e25_
Definition: EcalTBValidation.h:70
EcalTBValidation::hodoRec_Token_
edm::EDGetTokenT< EcalTBHodoscopeRecInfo > hodoRec_Token_
Definition: EcalTBValidation.h:47
EcalTBValidation::meETBe3x3_
MonitorElement * meETBe3x3_
Definition: EcalTBValidation.h:67
EcalTBValidation::digiCollection_
std::string digiCollection_
Definition: EcalTBValidation.h:34
cosmicPhotonAnalyzer_cfi.eMax
eMax
Definition: cosmicPhotonAnalyzer_cfi.py:10
EBDigiCollection
Definition: EcalDigiCollections.h:32
EcalTBValidation::bookHistograms
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
Definition: EcalTBValidation.cc:67
beam_dqm_sourceclient-live_cfg.cerr
cerr
Definition: beam_dqm_sourceclient-live_cfg.py:17
EcalTBEventHeader::tableIsMoving
bool tableIsMoving() const
Tell if the table is Moving.
Definition: EcalTBEventHeader.h:88
EcalTBValidation::meETBe5x5_
MonitorElement * meETBe5x5_
Definition: EcalTBValidation.h:68
EcalTBValidation::meETBe1e25vsX_
MonitorElement * meETBe1e25vsX_
Definition: EcalTBValidation.h:79
EcalTBHodoscopeRecInfo::posY
float posY() const
Definition: EcalTBHodoscopeRecInfo.h:26
edm::DataFrameContainer::find
const_iterator find(id_type i) const
Definition: DataFrameContainer.h:141
edm::EventSetup
Definition: EventSetup.h:57
EcalTBValidation::eventHeaderProducer_
std::string eventHeaderProducer_
Definition: EcalTBValidation.h:43
EcalTBValidation::tdcRec_Token_
edm::EDGetTokenT< EcalTBTDCRecInfo > tdcRec_Token_
Definition: EcalTBValidation.h:48
EBDetId::validDetId
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
EcalTBValidation::EcalTBValidation
EcalTBValidation(const edm::ParameterSet &)
Definition: EcalTBValidation.cc:15
EcalTBValidation::meETBe9e25vsX_
MonitorElement * meETBe9e25vsX_
Definition: EcalTBValidation.h:81
bscTrigger_cfi.theHits
theHits
Definition: bscTrigger_cfi.py:18
EcalTBValidation::meETBe9e25vsY_
MonitorElement * meETBe9e25vsY_
Definition: EcalTBValidation.h:82
EcalTBTDCRecInfo.h
EcalTBValidation::meETBe9e25_
MonitorElement * meETBe9e25_
Definition: EcalTBValidation.h:71
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
EcalTBEventHeader.h
EcalTBValidation::hit_Token_
edm::EDGetTokenT< EBUncalibratedRecHitCollection > hit_Token_
Definition: EcalTBValidation.h:46
EcalTBValidation::data_
int data_
Definition: EcalTBValidation.h:31
dqm::implementation::IBooker
Definition: DQMStore.h:43
EcalDataFrame::size
int size() const
Definition: EcalDataFrame.h:26
EBDetId::ism
int ism() const
get the ECAL/SM id
Definition: EBDetId.h:59
EcalTBTDCRecInfo
Definition: EcalTBTDCRecInfo.h:12
EBDetId::iphi
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
EcalTBValidation::digiProducer_
std::string digiProducer_
Definition: EcalTBValidation.h:35
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
EcalTBValidation::meETBe5x5_center_
MonitorElement * meETBe5x5_center_
Definition: EcalTBValidation.h:74
EBDetId::SMCRYSTALMODE
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
edm::DataFrameContainer::end
const_iterator end() const
Definition: DataFrameContainer.h:152
cuy.ii
ii
Definition: cuy.py:590
edm::InputTag
Definition: InputTag.h:15
EcalTBValidation::hitProducer_
std::string hitProducer_
Definition: EcalTBValidation.h:37
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
EcalTBValidation::meETBxib_
MonitorElement * meETBxib_
Definition: EcalTBValidation.h:61
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21
EcalTBHodoscopeRecInfo::posX
float posX() const
Definition: EcalTBHodoscopeRecInfo.h:25