CMS 3D CMS Logo

EcalBarrelRecHitsValidation.cc
Go to the documentation of this file.
1 /*
2  * \file EcalBarrelRecHitsValidation.cc
3  *
4  * \author C. Rovelli
5  *
6  */
7 
11 
12 using namespace cms;
13 using namespace edm;
14 using namespace std;
15 
17 
18  // ----------------------
19  EBdigiCollection_token_ = consumes< EBDigiCollection > (ps.getParameter<edm::InputTag>("EBdigiCollection") );
20  EBuncalibrechitCollection_token_ = consumes< EBUncalibratedRecHitCollection > (ps.getParameter<edm::InputTag>("EBuncalibrechitCollection") );
21 
22  // ----------------------
23  // verbosity switch
24  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
25 
26  // ----------------------
27  meEBUncalibRecHitsOccupancy_ = 0;
28  meEBUncalibRecHitsAmplitude_ = 0;
29  meEBUncalibRecHitsPedestal_ = 0;
30  meEBUncalibRecHitsJitter_ = 0;
31  meEBUncalibRecHitsChi2_ = 0;
32  meEBUncalibRecHitMaxSampleRatio_ = 0;
33  meEBUncalibRecHitsOccupancyGt100adc_ = 0;
34  meEBUncalibRecHitsAmplitudeGt100adc_ = 0;
35  meEBUncalibRecHitsPedestalGt100adc_ = 0;
36  meEBUncalibRecHitsJitterGt100adc_ = 0;
37  meEBUncalibRecHitsChi2Gt100adc_ = 0;
38  meEBUncalibRecHitMaxSampleRatioGt100adc_ = 0;
39  meEBUncalibRecHitsAmpFullMap_ = 0;
40  meEBUncalibRecHitsPedFullMap_ = 0;
41  for (int i=0; i<36 ; i++)
42  {
43  meEBUncalibRecHitAmplMap_[i] = 0;
44  meEBUncalibRecHitPedMap_[i] = 0;
45  }
46 }
47 
49 
50 }
51 
53  Char_t histo[200];
54 
55  ibooker.setCurrentFolder("EcalRecHitsV/EcalBarrelRecHitsTask");
56 
57  sprintf (histo, "EB Occupancy" );
58  meEBUncalibRecHitsOccupancy_ = ibooker.book2D(histo, histo, 170, -85., 85., 360, 0., 360.);
59 
60  sprintf (histo, "EB Amplitude" );
61  meEBUncalibRecHitsAmplitude_ = ibooker.book1D(histo, histo, 201, -20., 4000.);
62 
63  sprintf (histo, "EB Pedestal" );
64  meEBUncalibRecHitsPedestal_ = ibooker.book1D(histo, histo, 50, 190., 210.);
65 
66  sprintf (histo, "EB Jitter" );
67  meEBUncalibRecHitsJitter_ = ibooker.book1D(histo, histo, 100, 0., 100.);
68 
69  sprintf (histo, "EB Chi2" );
70  meEBUncalibRecHitsChi2_ = ibooker.book1D(histo, histo, 100, 18000., 22000.);
71 
72  sprintf (histo, "EB RecHit Max Sample Ratio");
73  meEBUncalibRecHitMaxSampleRatio_ = ibooker.book1D(histo, histo, 120, 0.90, 1.05);
74 
75  sprintf (histo, "EB Occupancy gt 100 adc counts" );
76  meEBUncalibRecHitsOccupancyGt100adc_ = ibooker.book2D(histo, histo, 170, -85., 85., 360, 0., 360.);
77 
78  sprintf (histo, "EB Amplitude gt 100 adc counts" );
79  meEBUncalibRecHitsAmplitudeGt100adc_ = ibooker.book1D(histo, histo, 200, 0., 4000.);
80 
81  sprintf (histo, "EB Pedestal gt 100 adc counts" );
82  meEBUncalibRecHitsPedestalGt100adc_ = ibooker.book1D(histo, histo, 50, 190., 210.);
83 
84  sprintf (histo, "EB Jitter gt 100 adc counts" );
85  meEBUncalibRecHitsJitterGt100adc_ = ibooker.book1D(histo, histo, 100, 0., 100.);
86 
87  sprintf (histo, "EB Chi2 gt 100 adc counts" );
88  meEBUncalibRecHitsChi2Gt100adc_ = ibooker.book1D(histo, histo, 100, 18000., 22000.);
89 
90  sprintf (histo, "EB RecHit Max Sample Ratio gt 100 adc counts");
91  meEBUncalibRecHitMaxSampleRatioGt100adc_ = ibooker.book1D(histo, histo, 120, 0.90, 1.05);
92 
93  sprintf (histo, "EB Amplitude Full Map");
94  meEBUncalibRecHitsAmpFullMap_ = ibooker.bookProfile2D(histo, histo, 170, -85., 85., 360, 0., 360., 200, 0., 4000.);
95 
96  sprintf (histo, "EB Pedestal Full Map");
97  meEBUncalibRecHitsPedFullMap_ = ibooker.bookProfile2D(histo, histo, 170, -85., 85., 360, 0., 360., 50, 194., 201.);
98 
99  for (int i=0; i<36 ; i++)
100  {
101  sprintf(histo, "EB Amp SM%02d", i+1);
102  meEBUncalibRecHitAmplMap_[i] = ibooker.bookProfile2D(histo, histo, 85, 0., 85., 20, 0., 20., 200, 0., 4000.);
103 
104  sprintf(histo, "EB Ped SM%02d", i+1);
105  meEBUncalibRecHitPedMap_[i] = ibooker.bookProfile2D(histo, histo, 85, 0., 85., 20, 0., 20., 50, 194., 201.);
106  }
107 }
108 
110 
111 
112  const EBUncalibratedRecHitCollection *EBUncalibRecHit = 0;
113  Handle< EBUncalibratedRecHitCollection > EcalUncalibRecHitEB;
114  e.getByToken( EBuncalibrechitCollection_token_, EcalUncalibRecHitEB);
115  if (EcalUncalibRecHitEB.isValid()) {
116  EBUncalibRecHit = EcalUncalibRecHitEB.product();
117  } else {
118  return;
119  }
120 
121  bool skipDigis = false;
122  const EBDigiCollection *EBDigi = 0;
123  Handle< EBDigiCollection > EcalDigiEB;
124  e.getByToken( EBdigiCollection_token_, EcalDigiEB);
125  if (EcalDigiEB.isValid()) {
126  EBDigi = EcalDigiEB.product();
127  } else {
128  skipDigis = true;
129  }
130 
132  c.get<EcalPedestalsRcd>().get(ecalPeds);
133 
134  // ----------------------
135  // loop over UncalibRecHits
136  for (EcalUncalibratedRecHitCollection::const_iterator uncalibRecHit = EBUncalibRecHit->begin(); uncalibRecHit != EBUncalibRecHit->end() ; ++uncalibRecHit)
137  {
138  EBDetId EBid = EBDetId(uncalibRecHit->id());
139 
140  // general checks
141  if (meEBUncalibRecHitsOccupancy_) meEBUncalibRecHitsOccupancy_ -> Fill(EBid.ieta(), EBid.iphi());
142  if (meEBUncalibRecHitsAmplitude_) meEBUncalibRecHitsAmplitude_ -> Fill(uncalibRecHit->amplitude());
143  if (meEBUncalibRecHitsPedestal_) meEBUncalibRecHitsPedestal_ -> Fill(uncalibRecHit->pedestal());
144  if (meEBUncalibRecHitsJitter_) meEBUncalibRecHitsJitter_ -> Fill(uncalibRecHit->jitter());
145  if (meEBUncalibRecHitsChi2_) meEBUncalibRecHitsChi2_ -> Fill(uncalibRecHit->chi2());
146  if (meEBUncalibRecHitsAmpFullMap_) meEBUncalibRecHitsAmpFullMap_ -> Fill(EBid.ieta(), EBid.iphi(), uncalibRecHit->amplitude());
147  if (meEBUncalibRecHitsPedFullMap_) meEBUncalibRecHitsPedFullMap_ -> Fill(EBid.ieta(), EBid.iphi(), uncalibRecHit->pedestal());
148 
149  // general checks, with threshold at 3.5 GeV = 100 ADC counts
150  if ( uncalibRecHit->amplitude() > 100 )
151  {
152  if (meEBUncalibRecHitsOccupancyGt100adc_) meEBUncalibRecHitsOccupancyGt100adc_ -> Fill(EBid.ieta(), EBid.iphi());
153  if (meEBUncalibRecHitsAmplitudeGt100adc_) meEBUncalibRecHitsAmplitudeGt100adc_ -> Fill(uncalibRecHit->amplitude());
154  if (meEBUncalibRecHitsPedestalGt100adc_) meEBUncalibRecHitsPedestalGt100adc_ -> Fill(uncalibRecHit->pedestal());
155  if (meEBUncalibRecHitsJitterGt100adc_) meEBUncalibRecHitsJitterGt100adc_ -> Fill(uncalibRecHit->jitter());
156  if (meEBUncalibRecHitsChi2Gt100adc_) meEBUncalibRecHitsChi2Gt100adc_ -> Fill(uncalibRecHit->chi2());
157  }
158 
159  // supermodule maps
160  int ic = EBid.ic();
161  int ie = (ic-1)/20 + 1;
162  int ip = (ic-1)%20 + 1;
163  int ism = EBid.ism();
164  float xie = ie - 0.5;
165  float xip = ip - 0.5;
166  if( meEBUncalibRecHitPedMap_[ism-1] ) meEBUncalibRecHitPedMap_[ism-1]->Fill(xie, xip, uncalibRecHit->pedestal());
167  if( meEBUncalibRecHitAmplMap_[ism-1] ) meEBUncalibRecHitAmplMap_[ism-1]->Fill(xie, xip, uncalibRecHit->amplitude());
168 
169  if ( ! skipDigis ) {
170  // find the rechit corresponding digi and the max sample
171  EBDigiCollection::const_iterator myDigi = EBDigi->find(EBid);
172  // int sMax = -1; // UNUSED
173  double eMax = 0.;
174  if (myDigi != EBDigi->end()){
175  for (unsigned int sample = 0 ; sample < myDigi->size(); ++sample){
176  EcalMGPASample thisSample = (*myDigi)[sample];
177  double analogSample = thisSample.adc();
178  if ( eMax < analogSample ){
179  eMax = analogSample;
180  // sMax = sample; // UNUSED
181  }
182  }
183  }
184  else
185  continue;
186 
187  // ratio uncalibratedRecHit amplitude + ped / max energy digi
188  const EcalPedestals* myped = ecalPeds.product();
189  EcalPedestalsMap::const_iterator it=myped->getMap().find( EBid );
190  if( it != myped->getMap().end() ){
191 
192  if (eMax > (*it).mean_x1 + 5 * (*it).rms_x1 && eMax != 0 ) {//only real signal RecHit
193 
194  if ( meEBUncalibRecHitMaxSampleRatio_ ) meEBUncalibRecHitMaxSampleRatio_->Fill( (uncalibRecHit->amplitude()+uncalibRecHit->pedestal())/eMax);
195  if ( meEBUncalibRecHitMaxSampleRatioGt100adc_ && (uncalibRecHit->amplitude()>100) ) meEBUncalibRecHitMaxSampleRatioGt100adc_->Fill( (uncalibRecHit->amplitude()+uncalibRecHit->pedestal())/eMax);
196  LogDebug("EcalRecHitsTaskInfo") << "barrel, eMax = " << eMax << " Amplitude = " << uncalibRecHit->amplitude()+uncalibRecHit->pedestal();
197  }
198  else
199  continue;
200  }
201  else
202  continue;
203  }
204 
205  } // loop over the UncalibratedRecHitCollection
206 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
EcalBarrelRecHitsValidation(const edm::ParameterSet &ps)
Constructor.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
const self & getMap() const
std::vector< EcalUncalibratedRecHit >::const_iterator const_iterator
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
Analyze.
int ism() const
get the ECAL/SM id
Definition: EBDetId.h:61
int iphi() const
get the crystal iphi
Definition: EBDetId.h:53
const_iterator find(id_type i) const
MonitorElement * bookProfile2D(Args &&...args)
Definition: DQMStore.h:163
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
bool isValid() const
Definition: HandleBase.h:74
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:46
void analyze(const edm::Event &e, const edm::EventSetup &c) override
const_iterator end() const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
T const * product() const
Definition: Handle.h:81
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
const T & get() const
Definition: EventSetup.h:55
std::vector< Item >::const_iterator const_iterator
const_iterator end() const
HLT enums.
const_iterator find(uint32_t rawId) const
const_iterator end() const
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
T const * product() const
Definition: ESHandle.h:86
const_iterator begin() const
Definition: Run.h:43
int adc() const
get the ADC sample (12 bits)