22 , ps.getParameter<std::
string>(
"moduleLabelG4" ) + std::
string(
"EcalHitsEB" )
27 , ps.getParameter<std::
string>(
"moduleLabelG4" ) + std::
string(
"EcalHitsEE" )
32 , ps.getParameter<std::
string>(
"moduleLabelG4" ) + std::
string(
"EcalHitsES" )
44 edm::LogInfo(
"OutputInfo") <<
" Ecal Digi Task histograms will NOT be saved";
88 sprintf (histo,
"EcalDigiTask Gun Momentum" ) ;
91 sprintf (histo,
"EcalDigiTask Gun Eta" ) ;
94 sprintf (histo,
"EcalDigiTask Gun Phi" ) ;
97 sprintf (histo,
"EcalDigiTask Barrel maximum Digi over Sim ratio" ) ;
100 sprintf (histo,
"EcalDigiTask Endcap maximum Digi over Sim ratio" ) ;
103 sprintf (histo,
"EcalDigiTask Barrel maximum Digi over Sim ratio gt 10 ADC" ) ;
106 sprintf (histo,
"EcalDigiTask Endcap maximum Digi over Sim ratio gt 20 ADC" ) ;
109 sprintf (histo,
"EcalDigiTask Barrel maximum Digi over Sim ratio gt 100 ADC" ) ;
112 sprintf (histo,
"EcalDigiTask Endcap maximum Digi over Sim ratio gt 100 ADC" ) ;
121 std::vector<SimTrack> theSimTracks;
122 std::vector<SimVertex> theSimVertexes;
134 if (!MCEvt.
isValid()) { skipMC =
true; }
145 EBdigis = EcalDigiEB.
product();
146 LogDebug(
"DigiInfo") <<
"total # EBdigis: " << EBdigis->
size() ;
147 if ( EBdigis->
size() == 0 ) isBarrel =
false;
155 EEdigis = EcalDigiEE.
product();
156 LogDebug(
"DigiInfo") <<
"total # EEdigis: " << EEdigis->
size() ;
157 if ( EEdigis->
size() == 0 ) isEndcap =
false;
162 bool isPreshower =
true;
165 ESdigis = EcalDigiES.
product();
166 LogDebug(
"DigiInfo") <<
"total # ESdigis: " << ESdigis->
size() ;
167 if ( ESdigis->
size() == 0 ) isPreshower =
false;
172 theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
173 theSimVertexes.insert(theSimVertexes.end(),SimVtx->begin(),SimVtx->end());
176 double theGunEnergy = 0.;
177 for ( HepMC::GenEvent::particle_const_iterator
p = MCEvt->GetEvent()->particles_begin();
178 p != MCEvt->GetEvent()->particles_end(); ++
p ) {
180 theGunEnergy = (*p)->momentum().e();
181 double htheta = (*p)->momentum().theta();
182 double heta = -
log(
tan(htheta * 0.5));
183 double hphi = (*p)->momentum().phi();
184 hphi = (hphi>=0) ? hphi : hphi+2*
M_PI;
185 hphi = hphi /
M_PI * 180.;
186 LogDebug(
"EventInfo") <<
"Particle gun type form MC = " <<
abs((*p)->pdg_id()) <<
"\n" <<
"Energy = "<< (*p)->momentum().e() <<
" Eta = " << heta <<
" Phi = " << hphi;
196 for (std::vector<SimVertex>::iterator isimvtx = theSimVertexes.begin();
197 isimvtx != theSimVertexes.end(); ++isimvtx){
198 LogDebug(
"EventInfo") <<
" Vertex index = " << nvtx <<
" event Id = " << isimvtx->eventId().rawId() <<
"\n" <<
" vertex dump: " << *isimvtx ;
203 for (std::vector<SimTrack>::iterator isimtrk = theSimTracks.begin();
204 isimtrk != theSimTracks.end(); ++isimtrk){
205 LogDebug(
"EventInfo") <<
" Track index = " << ntrk <<
" track Id = " << isimtrk->trackId() <<
" event Id = " << isimtrk->eventId().rawId() <<
"\n" <<
" track dump: " << *isimtrk ;
216 std::auto_ptr<MixCollection<PCaloHit> >
222 hitItr != barrelHits->end () ;
228 <<
" CaloHit " << hitItr->getName() <<
"\n"
229 <<
" DetID = " << hitItr->id()<<
" EBDetId = " << ebid.
ieta() <<
" " << ebid.
iphi() <<
"\n"
230 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
231 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
232 <<
" Energy = " << hitItr->energy();
234 uint32_t crystid = ebid.
rawId();
235 ebSimMap[crystid] += hitItr->energy();
243 std::vector<double> ebAnalogSignal ;
244 std::vector<double> ebADCCounts ;
245 std::vector<double> ebADCGains ;
250 for (
unsigned int digis=0; digis<EcalDigiEB->size(); ++digis) {
253 int nrSamples=ebdf.
size();
259 double pedestalPreSample = 0.;
260 double pedestalPreSampleAnalog = 0.;
263 ebAnalogSignal[
sample] = 0.;
275 if (Emax < ebAnalogSignal[
sample] ) {
276 Emax = ebAnalogSignal[
sample] ;
280 pedestalPreSample += ebADCCounts[
sample] ;
281 pedestalPreSampleAnalog += ebADCCounts[
sample]*
gainConv_[(int)ebADCGains[sample]]*barrelADCtoGeV_ ;
283 LogDebug(
"DigiInfo") <<
"EB sample " << sample <<
" ADC counts = " << ebADCCounts[
sample] <<
" Gain Id = " << ebADCGains[
sample] <<
" Analog eq = " << ebAnalogSignal[
sample];
286 pedestalPreSample /= 3. ;
287 pedestalPreSampleAnalog /= 3. ;
288 double Erec = Emax - pedestalPreSampleAnalog*
gainConv_[(int)ebADCGains[Pmax]];
290 if ( ebSimMap[ebid.
rawId()] != 0. ) {
291 LogDebug(
"DigiInfo") <<
" Digi / Hit = " << Erec <<
" / " << ebSimMap[ebid.
rawId()] <<
" gainConv " <<
gainConv_[(int)ebADCGains[Pmax]];
309 std::auto_ptr<MixCollection<PCaloHit> >
315 hitItr != endcapHits->end () ;
321 <<
" CaloHit " << hitItr->getName() <<
"\n"
322 <<
" DetID = "<<hitItr->id()<<
" EEDetId side = " << eeid.
zside() <<
" = " << eeid.
ix() <<
" " << eeid.
iy() <<
"\n"
323 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
324 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
325 <<
" Energy = " << hitItr->energy();
327 uint32_t crystid = eeid.
rawId();
328 eeSimMap[crystid] += hitItr->energy();
336 std::vector<double> eeAnalogSignal ;
337 std::vector<double> eeADCCounts ;
338 std::vector<double> eeADCGains ;
343 for (
unsigned int digis=0; digis<EcalDigiEE->size(); ++digis) {
346 int nrSamples=eedf.
size();
352 double pedestalPreSample = 0.;
353 double pedestalPreSampleAnalog = 0.;
356 eeAnalogSignal[
sample] = 0.;
368 if (Emax < eeAnalogSignal[
sample] ) {
369 Emax = eeAnalogSignal[
sample] ;
373 pedestalPreSample += eeADCCounts[
sample] ;
374 pedestalPreSampleAnalog += eeADCCounts[
sample]*
gainConv_[(int)eeADCGains[sample]]*endcapADCtoGeV_ ;
376 LogDebug(
"DigiInfo") <<
"EE sample " << sample <<
" ADC counts = " << eeADCCounts[
sample] <<
" Gain Id = " << eeADCGains[
sample] <<
" Analog eq = " << eeAnalogSignal[
sample];
378 pedestalPreSample /= 3. ;
379 pedestalPreSampleAnalog /= 3. ;
380 double Erec = Emax - pedestalPreSampleAnalog*
gainConv_[(int)eeADCGains[Pmax]];
382 if (eeSimMap[eeid.
rawId()] != 0. ) {
383 LogDebug(
"DigiInfo") <<
" Digi / Hit = " << Erec <<
" / " << eeSimMap[eeid.
rawId()] <<
" gainConv " <<
gainConv_[(int)eeADCGains[Pmax]];
396 std::auto_ptr<MixCollection<PCaloHit> >
400 hitItr != preshowerHits->end () ;
406 <<
" CaloHit " << hitItr->getName() <<
"\n"
407 <<
" DetID = " << hitItr->id()<<
"ESDetId: z side " << esid.
zside() <<
" plane " << esid.
plane() << esid.
six() <<
',' << esid.
siy() <<
':' << esid.
strip() <<
"\n"
408 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
409 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
410 <<
" Energy = " << hitItr->energy();
433 LogDebug(
"EcalDigi") <<
" Gains conversions: " <<
"\n" <<
" g1 = " << gainConv_[1] <<
"\n" <<
" g2 = " << gainConv_[2] <<
"\n" <<
" g3 = " << gainConv_[3];
434 LogDebug(
"EcalDigi") <<
" Gains conversions: " <<
"\n" <<
" saturation = " << gainConv_[0];
436 delete defaultRatios;
edm::EDGetTokenT< EEDigiCollection > EEdigiCollectionToken_
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< EBDigiCollection > EBdigiCollectionToken_
std::map< uint32_t, float, std::less< uint32_t > > MapType
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool isBarrel(GeomDetEnumerators::SubDetector m)
~EcalDigisValidation()
Destructor.
edm::EDGetTokenT< edm::SimVertexContainer > g4VtxInfoToken_
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
MonitorElement * meEEDigiSimRatiogt100ADC_
std::map< int, double, std::less< int > > gainConv_
int gainId() const
get the gainId (2 bits)
MonitorElement * meGunEnergy_
int iphi() const
get the crystal iphi
uint32_t rawId() const
get the raw id
MonitorElement * meEBDigiSimRatiogt10ADC_
MonitorElement * meEBDigiSimRatio_
void analyze(edm::Event const &e, edm::EventSetup const &c)
Analyze.
MonitorElement * book1D(Args &&...args)
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< CrossingFrame< PCaloHit > > crossingFramePCaloHitESToken_
int ieta() const
get the crystal ieta
MonitorElement * meGunEta_
bool isEndcap(GeomDetEnumerators::SubDetector m)
edm::EDGetTokenT< CrossingFrame< PCaloHit > > crossingFramePCaloHitEBToken_
void setCurrentFolder(const std::string &fullpath)
T const * product() const
std::vector< SimVertex > SimVertexContainer
T const * product() const
float gain12Over6() const
EcalDigisValidation(const edm::ParameterSet &ps)
Constructor.
MonitorElement * meEEDigiSimRatio_
MonitorElement * meGunPhi_
edm::EDGetTokenT< ESDigiCollection > ESdigiCollectionToken_
MonitorElement * meEEDigiSimRatiogt20ADC_
edm::EDGetTokenT< edm::HepMCProduct > HepMCToken_
void checkCalibrations(edm::EventSetup const &c)
edm::EDGetTokenT< CrossingFrame< PCaloHit > > crossingFramePCaloHitEEToken_
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
std::vector< SimTrack > SimTrackContainer
MonitorElement * meEBDigiSimRatiogt100ADC_
static const int MAXSAMPLES
edm::EDGetTokenT< edm::SimTrackContainer > g4TkInfoToken_
int adc() const
get the ADC sample (12 bits)