CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalTBValidation.cc
Go to the documentation of this file.
1 // Ecal H4 tesbeam analysis
11 
12 
13 #include <iostream>
14 #include <string>
15 
16 
18 
19  data_ = config.getUntrackedParameter<int>("data",-1000);
20  xtalInBeam_ = config.getUntrackedParameter<int>("xtalInBeam",-1000);
21 
22  digiCollection_ = config.getParameter<std::string>("digiCollection");
23  digiProducer_ = config.getParameter<std::string>("digiProducer");
24  hitCollection_ = config.getParameter<std::string>("hitCollection");
25  hitProducer_ = config.getParameter<std::string>("hitProducer");
26  hodoRecInfoCollection_ = config.getParameter<std::string>("hodoRecInfoCollection");
27  hodoRecInfoProducer_ = config.getParameter<std::string>("hodoRecInfoProducer");
28  tdcRecInfoCollection_ = config.getParameter<std::string>("tdcRecInfoCollection");
29  tdcRecInfoProducer_ = config.getParameter<std::string>("tdcRecInfoProducer");
30  eventHeaderCollection_ = config.getParameter<std::string>("eventHeaderCollection");
31  eventHeaderProducer_ = config.getParameter<std::string>("eventHeaderProducer");
32 
33  digi_Token_ = consumes<EBDigiCollection>(edm::InputTag(digiProducer_, digiCollection_));
34  hit_Token_ = consumes<EBUncalibratedRecHitCollection>(edm::InputTag(hitProducer_, hitCollection_));
35  hodoRec_Token_ = consumes<EcalTBHodoscopeRecInfo>(edm::InputTag(hodoRecInfoProducer_, hodoRecInfoCollection_));
36  tdcRec_Token_ = consumes<EcalTBTDCRecInfo>(edm::InputTag(tdcRecInfoProducer_, tdcRecInfoCollection_));
37  eventHeader_Token_ = consumes<EcalTBEventHeader>(edm::InputTag(eventHeaderProducer_));
38  //rootfile_ = config.getUntrackedParameter<std::string>("rootfile","EcalTBValidation.root");
39 
40  // verbosity...
41  verbose_ = config.getUntrackedParameter<bool>("verbose", false);
42 
44  if( dbe_ ) {
45  if( verbose_ ) {
46  dbe_->setVerbose(1);
47  dbe_->showDirStructure();
48  }
49  else {
50  dbe_->setVerbose(0);
51  }
52  }
53 
54  meETBxib_ = 0;
55  meETBampltdc_ = 0;
56  meETBShape_ = 0;
57  meETBhodoX_ = 0;
58  meETBhodoY_ = 0;
59  meETBe1x1_ = 0;
60  meETBe3x3_ = 0;
61  meETBe5x5_ = 0;
62  meETBe1e9_ = 0;
63  meETBe1e25_ = 0;
64  meETBe9e25_ = 0;
68  meETBe1vsX_ = 0;
69  meETBe1vsY_ = 0;
70  meETBe1e9vsX_ = 0;
71  meETBe1e9vsY_ = 0;
72  meETBe1e25vsX_ = 0;
73  meETBe1e25vsY_ = 0;
74  meETBe9e25vsX_ = 0;
75  meETBe9e25vsY_ = 0;
76 
77  if( dbe_ ) {
78 
79  std::string hname;
80  dbe_->setCurrentFolder( "EcalRecHitsV/EcalTBValidationTask" );
81 
82  hname = "xtal in beam position";
83  meETBxib_ = dbe_->book2D( hname, hname, 85, 0., 85., 20,0., 20. );
84  hname = "Max Amplitude vs TDC offset";
85  meETBampltdc_ = dbe_->book2D( hname, hname, 100, 0., 1., 1000, 0., 4000. );
86  hname = "Beam Profile X";
87  meETBhodoX_ = dbe_->book1D( hname, hname, 100, -20., 20. );
88  hname = "Beam Profile Y";
89  meETBhodoY_ = dbe_->book1D( hname, hname, 100, -20., 20. );
90  hname = "E1x1 energy";
91  meETBe1x1_ = dbe_->book1D( hname, hname, 1000, 0., 4000. );
92  hname = "E3x3 energy";
93  meETBe3x3_ = dbe_->book1D( hname, hname, 1000, 0., 4000. );
94  hname = "E5x5 energy";
95  meETBe5x5_ = dbe_->book1D( hname, hname, 1000, 0., 4000. );
96  hname = "E1x1 energy center";
97  meETBe1x1_center_ = dbe_->book1D( hname, hname, 1000, 0., 4000. );
98  hname = "E3x3 energy center";
99  meETBe3x3_center_ = dbe_->book1D( hname, hname, 1000, 0., 4000. );
100  hname = "E5x5 energy center";
101  meETBe5x5_center_ = dbe_->book1D( hname, hname, 1000, 0., 4000. );
102  hname = "E1 over E9 ratio";
103  meETBe1e9_ = dbe_->book1D( hname, hname, 600, 0., 1.2 );
104  hname = "E1 over E25 ratio";
105  meETBe1e25_ = dbe_->book1D( hname, hname, 600, 0., 1.2 );
106  hname = "E9 over E25 ratio";
107  meETBe9e25_ = dbe_->book1D( hname, hname, 600, 0., 1.2 );
108  hname = "E1 vs X";
109  meETBe1vsX_ = dbe_->book2D( hname, hname, 80, -20, 20, 1000, 0., 4000. );
110  hname = "E1 vs Y";
111  meETBe1vsY_ = dbe_->book2D( hname, hname, 80, -20, 20, 1000, 0., 4000. );
112  hname = "E1 over E9 vs X";
113  meETBe1e9vsX_ = dbe_->book2D( hname, hname, 80, -20, 20, 600, 0., 1.2 );
114  hname = "E1 over E9 vs Y";
115  meETBe1e9vsY_ = dbe_->book2D( hname, hname, 80, -20, 20, 600, 0., 1.2 );
116  hname = "E1 over E25 vs X";
117  meETBe1e25vsX_ = dbe_->book2D( hname, hname, 80, -20, 20, 600, 0., 1.2 );
118  hname = "E1 over E25 vs Y";
119  meETBe1e25vsY_ = dbe_->book2D( hname, hname, 80, -20, 20, 600, 0., 1.2 );
120  hname = "E9 over E25 vs X";
121  meETBe9e25vsX_ = dbe_->book2D( hname, hname, 80, -20, 20, 600, 0., 1.2 );
122  hname = "E9 over E25 vs Y";
123  meETBe9e25vsY_ = dbe_->book2D( hname, hname, 80, -20, 20, 600, 0., 1.2 );
124  hname = "Xtal in Beam Shape";
125  meETBShape_ = dbe_->book2D( hname, hname, 250, 0, 10, 350, 0, 3500 );
126  }
127 
128 }
129 
130 
132 
134 
136 
138 
139  using namespace edm;
140  using namespace cms;
141 
142  // digis
143  const EBDigiCollection* theDigis=0;
145  event.getByToken(digi_Token_, pdigis);
146  if(pdigis.isValid()){
147  theDigis = pdigis.product();
148  }
149  else {
150  std::cerr << "Error! can't get the product " << digiCollection_.c_str() << std::endl;
151  return;
152  }
153 
154  // rechits
155  const EBUncalibratedRecHitCollection* theHits=0;
157  event.getByToken(hit_Token_, phits);
158  if(phits.isValid()){
159  theHits = phits.product();
160  }
161  else {
162  std::cerr << "Error! can't get the product " << hitCollection_.c_str() << std::endl;
163  return;
164  }
165 
166  // hodoscopes
167  const EcalTBHodoscopeRecInfo* theHodo=0;
169  event.getByToken(hodoRec_Token_, pHodo);
170  if(pHodo.isValid()){
171  theHodo = pHodo.product();
172  }
173  else{
174  std::cerr << "Error! can't get the product " << hodoRecInfoCollection_.c_str() << std::endl;
175  return;
176  }
177 
178  // tdc
179  const EcalTBTDCRecInfo* theTDC=0;
181  event.getByToken(tdcRec_Token_, pTDC);
182  if(pTDC.isValid()){
183  theTDC = pTDC.product();
184  }
185  else{
186  std::cerr << "Error! can't get the product " << tdcRecInfoCollection_.c_str() << std::endl;
187  return;
188  }
189 
190  // event header
191  const EcalTBEventHeader* evtHeader=0;
192  Handle<EcalTBEventHeader> pEventHeader;
193  event.getByToken(eventHeader_Token_ , pEventHeader);
194  if(pEventHeader.isValid()){
195  evtHeader = pEventHeader.product();
196  }
197  else{
198  std::cerr << "Error! can't get the product " << eventHeaderProducer_.c_str() << std::endl;
199  return;
200  }
201 
202 
203  // -----------------------------------------------------------------------
204  // xtal-in-beam
205  EBDetId xtalInBeamId(1,xtalInBeam_, EBDetId::SMCRYSTALMODE);
206  if (xtalInBeamId==EBDetId(0)){ return; }
207  int xibEta = xtalInBeamId.ieta();
208  int xibPhi = xtalInBeamId.iphi();
209 
210  // skipping events with moving table (in data)
211  if (data_ && (evtHeader->tableIsMoving())) return;
212 
213  // amplitudes
214  EBDetId Xtals5x5[25];
215  for (unsigned int icry=0;icry<25;icry++){
216  unsigned int row = icry/5;
217  unsigned int column = icry%5;
218  int ieta = xtalInBeamId.ieta()+column-2;
219  int iphi = xtalInBeamId.iphi()+row-2;
220  if(EBDetId::validDetId(ieta, iphi)){
221  EBDetId tempId(ieta, iphi,EBDetId::ETAPHIMODE);
222  if (tempId.ism()==1)
223  Xtals5x5[icry] = tempId;
224  else
225  Xtals5x5[icry] = EBDetId(0);
226  } else {
227  Xtals5x5[icry] = EBDetId(0);
228  }
229  }
230 
231  // matrices
232  double ampl1x1 = 0.;
233  double ampl3x3 = 0.;
234  double ampl5x5 = 0.;
235  for (unsigned int icry=0;icry<25;icry++) {
236  if (!Xtals5x5[icry].null()){
237  double theAmpl = (theHits->find(Xtals5x5[icry]))->amplitude();
238  ampl5x5 += theAmpl;
239  if (icry==12){ampl1x1 = theAmpl;}
240  if (icry==6 || icry==7 || icry==8 || icry==11 || icry==12 || icry==13 || icry==16 || icry==17 || icry==18){ampl3x3 += theAmpl;}
241  }}
242 
243 
244  // pulse shape
245  double sampleSave[10];
246  for(int ii=0; ii < 10; ++ii){ sampleSave[ii] = 0.0; }
247  EBDigiCollection::const_iterator thisDigi = theDigis->find(xtalInBeamId);
248  // int sMax = -1; // UNUSED
249  double eMax = 0.;
250  if (thisDigi != theDigis->end()){
251  EBDataFrame myDigi = (*thisDigi);
252  for (int sample=0; sample < myDigi.size(); ++sample){
253  double analogSample = myDigi.sample(sample).adc();
254  sampleSave[sample] = analogSample;
255  if ( eMax < analogSample ) {
256  eMax = analogSample;
257  // sMax = sample; // UNUSED
258  }
259  }
260  }
261 
262  // beam profile
263  double xBeam = theHodo->posX();
264  double yBeam = theHodo->posY();
265 
266  // filling histos
267  meETBxib_ -> Fill(xibEta, xibPhi);
268  meETBhodoX_ -> Fill(xBeam);
269  meETBhodoY_ -> Fill(yBeam);
270  meETBampltdc_ -> Fill(theTDC->offset(),ampl1x1);
271  meETBe1x1_ -> Fill(ampl1x1);
272  meETBe3x3_ -> Fill(ampl3x3);
273  meETBe5x5_ -> Fill(ampl5x5);
274  meETBe1e9_ -> Fill(ampl1x1/ampl3x3);
275  meETBe1e25_ -> Fill(ampl1x1/ampl5x5);
276  meETBe9e25_ -> Fill(ampl3x3/ampl5x5);
277  meETBe1vsX_ -> Fill(xBeam,ampl1x1);
278  meETBe1vsY_ -> Fill(yBeam,ampl1x1);
279  meETBe1e9vsX_ -> Fill(xBeam,ampl1x1/ampl3x3);
280  meETBe1e9vsY_ -> Fill(yBeam,ampl1x1/ampl3x3);
281  meETBe1e25vsX_ -> Fill(xBeam,ampl1x1/ampl5x5);
282  meETBe1e25vsY_ -> Fill(yBeam,ampl1x1/ampl5x5);
283  meETBe9e25vsX_ -> Fill(xBeam,ampl3x3/ampl5x5);
284  meETBe9e25vsY_ -> Fill(yBeam,ampl3x3/ampl5x5);
285 
286  for(int ii=0; ii < 10; ++ii){ meETBShape_->Fill(double(ii)+theTDC->offset(),sampleSave[ii]); }
287 
288  if ( (fabs(xBeam)<2.5) && (fabs(yBeam)<2.5) ){
289  meETBe1x1_center_ -> Fill(ampl1x1);
290  meETBe3x3_center_ -> Fill(ampl3x3);
291  meETBe5x5_center_ -> Fill(ampl5x5);
292  }
293 }
294 
295 
MonitorElement * meETBShape_
T getParameter(std::string const &) const
MonitorElement * meETBampltdc_
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * meETBe5x5_
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
MonitorElement * meETBe1e25_
MonitorElement * meETBe3x3_
edm::EDGetTokenT< EcalTBTDCRecInfo > tdcRec_Token_
edm::EDGetTokenT< EBDigiCollection > digi_Token_
MonitorElement * meETBe9e25vsX_
edm::EDGetTokenT< EcalTBHodoscopeRecInfo > hodoRec_Token_
EcalMGPASample sample(int i) const
Definition: EcalDataFrame.h:29
MonitorElement * meETBe1e25vsX_
int ii
Definition: cuy.py:588
std::string eventHeaderProducer_
int ism() const
get the ECAL/SM id
Definition: EBDetId.h:61
int size() const
Definition: EcalDataFrame.h:26
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:124
MonitorElement * meETBxib_
void Fill(long long x)
int iphi() const
get the crystal iphi
Definition: EBDetId.h:53
EcalTBValidation(const edm::ParameterSet &)
edm::EDGetTokenT< EBUncalibratedRecHitCollection > hit_Token_
MonitorElement * meETBe9e25_
MonitorElement * meETBe9e25vsY_
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
std::string eventHeaderCollection_
MonitorElement * meETBe1vsX_
std::string hitProducer_
std::string hodoRecInfoProducer_
std::string digiProducer_
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
MonitorElement * meETBe5x5_center_
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
static const int ETAPHIMODE
Definition: EBDetId.h:166
std::string hitCollection_
T const * product() const
Definition: Handle.h:81
#define column(...)
Definition: DbCore.h:74
MonitorElement * meETBe1e9vsX_
MonitorElement * meETBe1e25vsY_
MonitorElement * meETBe1x1_
std::string tdcRecInfoCollection_
std::string tdcRecInfoProducer_
edm::EDGetTokenT< EcalTBEventHeader > eventHeader_Token_
MonitorElement * meETBe1e9_
virtual void beginJob()
virtual void analyze(const edm::Event &, const edm::EventSetup &)
MonitorElement * meETBe3x3_center_
static const int SMCRYSTALMODE
Definition: EBDetId.h:167
MonitorElement * meETBe1e9vsY_
std::string digiCollection_
MonitorElement * meETBhodoY_
MonitorElement * meETBe1vsY_
std::string hodoRecInfoCollection_
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
MonitorElement * meETBe1x1_center_
MonitorElement * meETBhodoX_
int adc() const
get the ADC sample (12 bits)
virtual void endJob()