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 }
MonitorElement * meETBShape_
MonitorElement * meETBampltdc_
MonitorElement * meETBe5x5_
MonitorElement * meETBe1e25_
MonitorElement * meETBe3x3_
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
edm::EDGetTokenT< EcalTBTDCRecInfo > tdcRec_Token_
edm::EDGetTokenT< EBDigiCollection > digi_Token_
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
T const * product() const
Definition: Handle.h:70
MonitorElement * meETBe9e25vsX_
edm::EDGetTokenT< EcalTBHodoscopeRecInfo > hodoRec_Token_
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
Definition: config.py:1
MonitorElement * meETBe1e25vsX_
std::string eventHeaderProducer_
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:118
int size() const
Definition: EcalDataFrame.h:26
MonitorElement * meETBxib_
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
EcalTBValidation(const edm::ParameterSet &)
void Fill(long long x)
edm::EDGetTokenT< EBUncalibratedRecHitCollection > hit_Token_
MonitorElement * meETBe9e25_
MonitorElement * meETBe9e25vsY_
std::string eventHeaderCollection_
MonitorElement * meETBe1vsX_
std::string hitProducer_
int ism() const
get the ECAL/SM id
Definition: EBDetId.h:59
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
std::string hodoRecInfoProducer_
std::string digiProducer_
MonitorElement * meETBe5x5_center_
bool tableIsMoving() const
Tell if the table is Moving.
static const int ETAPHIMODE
Definition: EBDetId.h:158
ii
Definition: cuy.py:589
const_iterator end() const
Namespace of DDCMS conversion namespace.
std::string hitCollection_
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:212
MonitorElement * meETBe1e9vsX_
float offset() const
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
bool isValid() const
Definition: HandleBase.h:70
MonitorElement * meETBe1e25vsY_
MonitorElement * meETBe1x1_
std::string tdcRecInfoCollection_
~EcalTBValidation() override
HLT enums.
std::string tdcRecInfoProducer_
edm::EDGetTokenT< EcalTBEventHeader > eventHeader_Token_
MonitorElement * meETBe1e9_
int adc() const
get the ADC sample (12 bits)
MonitorElement * meETBe3x3_center_
const_iterator find(id_type i) const
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
MonitorElement * meETBe1e9vsY_
std::string digiCollection_
MonitorElement * meETBhodoY_
MonitorElement * meETBe1vsY_
std::string hodoRecInfoCollection_
MonitorElement * meETBe1x1_center_
Definition: event.py:1
Definition: Run.h:45
MonitorElement * meETBhodoX_
void analyze(const edm::Event &, const edm::EventSetup &) override
caConstants::TupleMultiplicity const *__restrict__ HitsOnGPU const *__restrict__ tindex_type *__restrict__ double *__restrict__ phits