22 HepMCLabel(ps.getParameter<std::string>(
"moduleLabelMC")),
23 g4InfoLabel(ps.getParameter<std::string>(
"moduleLabelG4")),
24 EBdigiCollection_(ps.getParameter<edm::
InputTag>(
"EBdigiCollection")),
25 EEdigiCollection_(ps.getParameter<edm::
InputTag>(
"EEdigiCollection")),
26 ESdigiCollection_(ps.getParameter<edm::
InputTag>(
"ESdigiCollection")){
33 LogInfo(
"OutputInfo") <<
" Ecal Digi Task histograms will be saved to '" <<
outputFile_.c_str() <<
"'";
35 LogInfo(
"OutputInfo") <<
" Ecal Digi Task histograms will NOT be saved";
55 if (
verbose_ ) dbe_->showDirStructure();
82 dbe_->setCurrentFolder(
"EcalDigisV/EcalDigiTask");
84 sprintf (histo,
"EcalDigiTask Gun Momentum" ) ;
85 meGunEnergy_ = dbe_->book1D(histo, histo, 100, 0., 1000.);
87 sprintf (histo,
"EcalDigiTask Gun Eta" ) ;
88 meGunEta_ = dbe_->book1D(histo, histo, 700, -3.5, 3.5);
90 sprintf (histo,
"EcalDigiTask Gun Phi" ) ;
91 meGunPhi_ = dbe_->book1D(histo, histo, 360, 0., 360.);
93 sprintf (histo,
"EcalDigiTask Barrel maximum Digi over Sim ratio" ) ;
96 sprintf (histo,
"EcalDigiTask Endcap maximum Digi over Sim ratio" ) ;
99 sprintf (histo,
"EcalDigiTask Barrel maximum Digi over Sim ratio gt 10 ADC" ) ;
102 sprintf (histo,
"EcalDigiTask Endcap maximum Digi over Sim ratio gt 20 ADC" ) ;
105 sprintf (histo,
"EcalDigiTask Barrel maximum Digi over Sim ratio gt 100 ADC" ) ;
108 sprintf (histo,
"EcalDigiTask Endcap maximum Digi over Sim ratio gt 100 ADC" ) ;
135 vector<SimTrack> theSimTracks;
136 vector<SimVertex> theSimVertexes;
148 if (!MCEvt.
isValid()) { skipMC =
true; }
156 bool isBarrel =
true;
159 EBdigis = EcalDigiEB.
product();
160 LogDebug(
"DigiInfo") <<
"total # EBdigis: " << EBdigis->
size() ;
161 if ( EBdigis->
size() == 0 ) isBarrel =
false;
166 bool isEndcap =
true;
169 EEdigis = EcalDigiEE.
product();
170 LogDebug(
"DigiInfo") <<
"total # EEdigis: " << EEdigis->
size() ;
171 if ( EEdigis->
size() == 0 ) isEndcap =
false;
176 bool isPreshower =
true;
179 ESdigis = EcalDigiES.
product();
180 LogDebug(
"DigiInfo") <<
"total # ESdigis: " << ESdigis->
size() ;
181 if ( ESdigis->
size() == 0 ) isPreshower =
false;
186 theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
187 theSimVertexes.insert(theSimVertexes.end(),SimVtx->begin(),SimVtx->end());
190 double theGunEnergy = 0.;
191 for ( HepMC::GenEvent::particle_const_iterator
p = MCEvt->GetEvent()->particles_begin();
192 p != MCEvt->GetEvent()->particles_end(); ++
p ) {
194 theGunEnergy = (*p)->momentum().e();
195 double htheta = (*p)->momentum().theta();
196 double heta = -
log(
tan(htheta * 0.5));
197 double hphi = (*p)->momentum().phi();
198 hphi = (hphi>=0) ? hphi : hphi+2*
M_PI;
199 hphi = hphi /
M_PI * 180.;
200 LogDebug(
"EventInfo") <<
"Particle gun type form MC = " <<
abs((*p)->pdg_id()) <<
"\n" <<
"Energy = "<< (*p)->momentum().e() <<
" Eta = " << heta <<
" Phi = " << hphi;
210 for (vector<SimVertex>::iterator isimvtx = theSimVertexes.begin();
211 isimvtx != theSimVertexes.end(); ++isimvtx){
212 LogDebug(
"EventInfo") <<
" Vertex index = " << nvtx <<
" event Id = " << isimvtx->eventId().rawId() <<
"\n" <<
" vertex dump: " << *isimvtx ;
217 for (vector<SimTrack>::iterator isimtrk = theSimTracks.begin();
218 isimtrk != theSimTracks.end(); ++isimtrk){
219 LogDebug(
"EventInfo") <<
" Track index = " << ntrk <<
" track Id = " << isimtrk->trackId() <<
" event Id = " << isimtrk->eventId().rawId() <<
"\n" <<
" track dump: " << *isimtrk ;
229 const std::string barrelHitsName(
g4InfoLabel+
"EcalHitsEB");
230 e.
getByLabel(
"mix",barrelHitsName,crossingFrame);
231 std::auto_ptr<MixCollection<PCaloHit> >
237 hitItr != barrelHits->end () ;
243 <<
" CaloHit " << hitItr->getName() <<
"\n"
244 <<
" DetID = " << hitItr->id()<<
" EBDetId = " << ebid.
ieta() <<
" " << ebid.
iphi() <<
"\n"
245 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
246 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
247 <<
" Energy = " << hitItr->energy();
249 uint32_t crystid = ebid.
rawId();
250 ebSimMap[crystid] += hitItr->energy();
258 std::vector<double> ebAnalogSignal ;
259 std::vector<double> ebADCCounts ;
260 std::vector<double> ebADCGains ;
265 for (
unsigned int digis=0; digis<EcalDigiEB->size(); ++digis) {
268 int nrSamples=ebdf.
size();
274 double pedestalPreSample = 0.;
275 double pedestalPreSampleAnalog = 0.;
278 ebAnalogSignal[
sample] = 0.;
290 if (Emax < ebAnalogSignal[
sample] ) {
291 Emax = ebAnalogSignal[
sample] ;
295 pedestalPreSample += ebADCCounts[
sample] ;
296 pedestalPreSampleAnalog += ebADCCounts[
sample]*
gainConv_[(int)ebADCGains[sample]]*barrelADCtoGeV_ ;
298 LogDebug(
"DigiInfo") <<
"EB sample " << sample <<
" ADC counts = " << ebADCCounts[
sample] <<
" Gain Id = " << ebADCGains[
sample] <<
" Analog eq = " << ebAnalogSignal[
sample];
301 pedestalPreSample /= 3. ;
302 pedestalPreSampleAnalog /= 3. ;
303 double Erec = Emax - pedestalPreSampleAnalog*
gainConv_[(int)ebADCGains[Pmax]];
305 if ( ebSimMap[ebid.
rawId()] != 0. ) {
306 LogDebug(
"DigiInfo") <<
" Digi / Hit = " << Erec <<
" / " << ebSimMap[ebid.
rawId()] <<
" gainConv " <<
gainConv_[(int)ebADCGains[Pmax]];
323 const std::string endcapHitsName(
g4InfoLabel+
"EcalHitsEE");
324 e.
getByLabel(
"mix",endcapHitsName,crossingFrame);
325 std::auto_ptr<MixCollection<PCaloHit> >
331 hitItr != endcapHits->end () ;
337 <<
" CaloHit " << hitItr->getName() <<
"\n"
338 <<
" DetID = "<<hitItr->id()<<
" EEDetId side = " << eeid.
zside() <<
" = " << eeid.
ix() <<
" " << eeid.
iy() <<
"\n"
339 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
340 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
341 <<
" Energy = " << hitItr->energy();
343 uint32_t crystid = eeid.
rawId();
344 eeSimMap[crystid] += hitItr->energy();
352 std::vector<double> eeAnalogSignal ;
353 std::vector<double> eeADCCounts ;
354 std::vector<double> eeADCGains ;
359 for (
unsigned int digis=0; digis<EcalDigiEE->size(); ++digis) {
362 int nrSamples=eedf.
size();
368 double pedestalPreSample = 0.;
369 double pedestalPreSampleAnalog = 0.;
372 eeAnalogSignal[
sample] = 0.;
384 if (Emax < eeAnalogSignal[
sample] ) {
385 Emax = eeAnalogSignal[
sample] ;
389 pedestalPreSample += eeADCCounts[
sample] ;
390 pedestalPreSampleAnalog += eeADCCounts[
sample]*
gainConv_[(int)eeADCGains[sample]]*endcapADCtoGeV_ ;
392 LogDebug(
"DigiInfo") <<
"EE sample " << sample <<
" ADC counts = " << eeADCCounts[
sample] <<
" Gain Id = " << eeADCGains[
sample] <<
" Analog eq = " << eeAnalogSignal[
sample];
394 pedestalPreSample /= 3. ;
395 pedestalPreSampleAnalog /= 3. ;
396 double Erec = Emax - pedestalPreSampleAnalog*
gainConv_[(int)eeADCGains[Pmax]];
398 if (eeSimMap[eeid.
rawId()] != 0. ) {
399 LogDebug(
"DigiInfo") <<
" Digi / Hit = " << Erec <<
" / " << eeSimMap[eeid.
rawId()] <<
" gainConv " <<
gainConv_[(int)eeADCGains[Pmax]];
411 const std::string preshowerHitsName(
g4InfoLabel+
"EcalHitsES");
412 e.
getByLabel(
"mix",preshowerHitsName,crossingFrame);
413 std::auto_ptr<MixCollection<PCaloHit> >
417 hitItr != preshowerHits->end () ;
423 <<
" CaloHit " << hitItr->getName() <<
"\n"
424 <<
" DetID = " << hitItr->id()<<
"ESDetId: z side " << esid.
zside() <<
" plane " << esid.
plane() << esid.
six() <<
',' << esid.
siy() <<
':' << esid.
strip() <<
"\n"
425 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
426 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
427 <<
" Energy = " << hitItr->energy();
450 LogDebug(
"EcalDigi") <<
" Gains conversions: " <<
"\n" <<
" g1 = " << gainConv_[1] <<
"\n" <<
" g2 = " << gainConv_[2] <<
"\n" <<
" g3 = " << gainConv_[3];
451 LogDebug(
"EcalDigi") <<
" Gains conversions: " <<
"\n" <<
" saturation = " << gainConv_[0];
453 delete defaultRatios;
edm::InputTag EEdigiCollection_
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
std::map< uint32_t, float, std::less< uint32_t > > MapType
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
~EcalDigisValidation()
Destructor.
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
void beginRun(edm::Run const &, edm::EventSetup const &c)
MonitorElement * meEBDigiSimRatiogt10ADC_
MonitorElement * meEBDigiSimRatio_
void analyze(edm::Event const &e, edm::EventSetup const &c)
Analyze.
Tan< T >::type tan(const T &t)
int ieta() const
get the crystal ieta
MonitorElement * meGunEta_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
T const * product() const
float gain12Over6() const
EcalDigisValidation(const edm::ParameterSet &ps)
Constructor.
T const * product() const
MonitorElement * meEEDigiSimRatio_
edm::InputTag EBdigiCollection_
edm::InputTag ESdigiCollection_
MonitorElement * meGunPhi_
MonitorElement * meEEDigiSimRatiogt20ADC_
void checkCalibrations(edm::EventSetup const &c)
MonitorElement * meEBDigiSimRatiogt100ADC_
static const int MAXSAMPLES
int adc() const
get the ADC sample (12 bits)