15 HepMCToken_( consumes<edm::
HepMCProduct>( edm::InputTag( ps.getParameter<std::
string>(
"moduleLabelMC" ) ) ) ),
16 g4TkInfoToken_( consumes<edm::
SimTrackContainer>( edm::InputTag( ps.getParameter<std::
string>(
"moduleLabelG4" ) ) ) ),
17 g4VtxInfoToken_( consumes<edm::
SimVertexContainer>( edm::InputTag( ps.getParameter<std::
string>(
"moduleLabelG4" ) ) ) ),
18 EBdigiCollectionToken_( consumes<
EBDigiCollection>( ps.getParameter<edm::InputTag>(
"EBdigiCollection" ) ) ),
19 EEdigiCollectionToken_( consumes<
EEDigiCollection>( ps.getParameter<edm::InputTag>(
"EEdigiCollection" ) ) ),
20 ESdigiCollectionToken_( consumes<
ESDigiCollection>( ps.getParameter<edm::InputTag>(
"ESdigiCollection" ) ) ),
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";
64 if (
verbose_ ) dbe_->showDirStructure();
91 dbe_->setCurrentFolder(
"EcalDigisV/EcalDigiTask");
93 sprintf (histo,
"EcalDigiTask Gun Momentum" ) ;
94 meGunEnergy_ = dbe_->book1D(histo, histo, 100, 0., 1000.);
96 sprintf (histo,
"EcalDigiTask Gun Eta" ) ;
97 meGunEta_ = dbe_->book1D(histo, histo, 700, -3.5, 3.5);
99 sprintf (histo,
"EcalDigiTask Gun Phi" ) ;
100 meGunPhi_ = dbe_->book1D(histo, histo, 360, 0., 360.);
102 sprintf (histo,
"EcalDigiTask Barrel maximum Digi over Sim ratio" ) ;
105 sprintf (histo,
"EcalDigiTask Endcap maximum Digi over Sim ratio" ) ;
108 sprintf (histo,
"EcalDigiTask Barrel maximum Digi over Sim ratio gt 10 ADC" ) ;
111 sprintf (histo,
"EcalDigiTask Endcap maximum Digi over Sim ratio gt 20 ADC" ) ;
114 sprintf (histo,
"EcalDigiTask Barrel maximum Digi over Sim ratio gt 100 ADC" ) ;
117 sprintf (histo,
"EcalDigiTask Endcap maximum Digi over Sim ratio gt 100 ADC" ) ;
144 std::vector<SimTrack> theSimTracks;
145 std::vector<SimVertex> theSimVertexes;
157 if (!MCEvt.
isValid()) { skipMC =
true; }
165 bool isBarrel =
true;
168 EBdigis = EcalDigiEB.
product();
169 LogDebug(
"DigiInfo") <<
"total # EBdigis: " << EBdigis->
size() ;
170 if ( EBdigis->
size() == 0 ) isBarrel =
false;
175 bool isEndcap =
true;
178 EEdigis = EcalDigiEE.
product();
179 LogDebug(
"DigiInfo") <<
"total # EEdigis: " << EEdigis->
size() ;
180 if ( EEdigis->
size() == 0 ) isEndcap =
false;
185 bool isPreshower =
true;
188 ESdigis = EcalDigiES.
product();
189 LogDebug(
"DigiInfo") <<
"total # ESdigis: " << ESdigis->
size() ;
190 if ( ESdigis->
size() == 0 ) isPreshower =
false;
195 theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
196 theSimVertexes.insert(theSimVertexes.end(),SimVtx->begin(),SimVtx->end());
199 double theGunEnergy = 0.;
200 for ( HepMC::GenEvent::particle_const_iterator
p = MCEvt->GetEvent()->particles_begin();
201 p != MCEvt->GetEvent()->particles_end(); ++
p ) {
203 theGunEnergy = (*p)->momentum().e();
204 double htheta = (*p)->momentum().theta();
205 double heta = -
log(
tan(htheta * 0.5));
206 double hphi = (*p)->momentum().phi();
207 hphi = (hphi>=0) ? hphi : hphi+2*
M_PI;
208 hphi = hphi /
M_PI * 180.;
209 LogDebug(
"EventInfo") <<
"Particle gun type form MC = " <<
abs((*p)->pdg_id()) <<
"\n" <<
"Energy = "<< (*p)->momentum().e() <<
" Eta = " << heta <<
" Phi = " << hphi;
219 for (std::vector<SimVertex>::iterator isimvtx = theSimVertexes.begin();
220 isimvtx != theSimVertexes.end(); ++isimvtx){
221 LogDebug(
"EventInfo") <<
" Vertex index = " << nvtx <<
" event Id = " << isimvtx->eventId().rawId() <<
"\n" <<
" vertex dump: " << *isimvtx ;
226 for (std::vector<SimTrack>::iterator isimtrk = theSimTracks.begin();
227 isimtrk != theSimTracks.end(); ++isimtrk){
228 LogDebug(
"EventInfo") <<
" Track index = " << ntrk <<
" track Id = " << isimtrk->trackId() <<
" event Id = " << isimtrk->eventId().rawId() <<
"\n" <<
" track dump: " << *isimtrk ;
239 std::auto_ptr<MixCollection<PCaloHit> >
245 hitItr != barrelHits->end () ;
251 <<
" CaloHit " << hitItr->getName() <<
"\n"
252 <<
" DetID = " << hitItr->id()<<
" EBDetId = " << ebid.
ieta() <<
" " << ebid.
iphi() <<
"\n"
253 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
254 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
255 <<
" Energy = " << hitItr->energy();
257 uint32_t crystid = ebid.
rawId();
258 ebSimMap[crystid] += hitItr->energy();
266 std::vector<double> ebAnalogSignal ;
267 std::vector<double> ebADCCounts ;
268 std::vector<double> ebADCGains ;
273 for (
unsigned int digis=0; digis<EcalDigiEB->size(); ++digis) {
276 int nrSamples=ebdf.
size();
282 double pedestalPreSample = 0.;
283 double pedestalPreSampleAnalog = 0.;
286 ebAnalogSignal[
sample] = 0.;
298 if (Emax < ebAnalogSignal[
sample] ) {
299 Emax = ebAnalogSignal[
sample] ;
303 pedestalPreSample += ebADCCounts[
sample] ;
304 pedestalPreSampleAnalog += ebADCCounts[
sample]*
gainConv_[(int)ebADCGains[sample]]*barrelADCtoGeV_ ;
306 LogDebug(
"DigiInfo") <<
"EB sample " << sample <<
" ADC counts = " << ebADCCounts[
sample] <<
" Gain Id = " << ebADCGains[
sample] <<
" Analog eq = " << ebAnalogSignal[
sample];
309 pedestalPreSample /= 3. ;
310 pedestalPreSampleAnalog /= 3. ;
311 double Erec = Emax - pedestalPreSampleAnalog*
gainConv_[(int)ebADCGains[Pmax]];
313 if ( ebSimMap[ebid.
rawId()] != 0. ) {
314 LogDebug(
"DigiInfo") <<
" Digi / Hit = " << Erec <<
" / " << ebSimMap[ebid.
rawId()] <<
" gainConv " <<
gainConv_[(int)ebADCGains[Pmax]];
332 std::auto_ptr<MixCollection<PCaloHit> >
338 hitItr != endcapHits->end () ;
344 <<
" CaloHit " << hitItr->getName() <<
"\n"
345 <<
" DetID = "<<hitItr->id()<<
" EEDetId side = " << eeid.
zside() <<
" = " << eeid.
ix() <<
" " << eeid.
iy() <<
"\n"
346 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
347 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
348 <<
" Energy = " << hitItr->energy();
350 uint32_t crystid = eeid.
rawId();
351 eeSimMap[crystid] += hitItr->energy();
359 std::vector<double> eeAnalogSignal ;
360 std::vector<double> eeADCCounts ;
361 std::vector<double> eeADCGains ;
366 for (
unsigned int digis=0; digis<EcalDigiEE->size(); ++digis) {
369 int nrSamples=eedf.
size();
375 double pedestalPreSample = 0.;
376 double pedestalPreSampleAnalog = 0.;
379 eeAnalogSignal[
sample] = 0.;
391 if (Emax < eeAnalogSignal[
sample] ) {
392 Emax = eeAnalogSignal[
sample] ;
396 pedestalPreSample += eeADCCounts[
sample] ;
397 pedestalPreSampleAnalog += eeADCCounts[
sample]*
gainConv_[(int)eeADCGains[sample]]*endcapADCtoGeV_ ;
399 LogDebug(
"DigiInfo") <<
"EE sample " << sample <<
" ADC counts = " << eeADCCounts[
sample] <<
" Gain Id = " << eeADCGains[
sample] <<
" Analog eq = " << eeAnalogSignal[
sample];
401 pedestalPreSample /= 3. ;
402 pedestalPreSampleAnalog /= 3. ;
403 double Erec = Emax - pedestalPreSampleAnalog*
gainConv_[(int)eeADCGains[Pmax]];
405 if (eeSimMap[eeid.
rawId()] != 0. ) {
406 LogDebug(
"DigiInfo") <<
" Digi / Hit = " << Erec <<
" / " << eeSimMap[eeid.
rawId()] <<
" gainConv " <<
gainConv_[(int)eeADCGains[Pmax]];
419 std::auto_ptr<MixCollection<PCaloHit> >
423 hitItr != preshowerHits->end () ;
429 <<
" CaloHit " << hitItr->getName() <<
"\n"
430 <<
" DetID = " << hitItr->id()<<
"ESDetId: z side " << esid.
zside() <<
" plane " << esid.
plane() << esid.
six() <<
',' << esid.
siy() <<
':' << esid.
strip() <<
"\n"
431 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
432 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
433 <<
" Energy = " << hitItr->energy();
456 LogDebug(
"EcalDigi") <<
" Gains conversions: " <<
"\n" <<
" g1 = " << gainConv_[1] <<
"\n" <<
" g2 = " << gainConv_[2] <<
"\n" <<
" g3 = " << gainConv_[3];
457 LogDebug(
"EcalDigi") <<
" Gains conversions: " <<
"\n" <<
" saturation = " << gainConv_[0];
459 delete defaultRatios;
edm::EDGetTokenT< EEDigiCollection > EEdigiCollectionToken_
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
static std::vector< std::string > checklist log
edm::EDGetTokenT< EBDigiCollection > EBdigiCollectionToken_
std::map< uint32_t, float, std::less< uint32_t > > MapType
bool getByToken(EDGetToken token, Handle< PROD > &result) const
~EcalDigisValidation()
Destructor.
edm::EDGetTokenT< edm::SimVertexContainer > g4VtxInfoToken_
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)
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< CrossingFrame< PCaloHit > > crossingFramePCaloHitESToken_
int ieta() const
get the crystal ieta
MonitorElement * meGunEta_
edm::EDGetTokenT< CrossingFrame< PCaloHit > > crossingFramePCaloHitEBToken_
std::vector< SimVertex > SimVertexContainer
T const * product() const
float gain12Over6() const
EcalDigisValidation(const edm::ParameterSet &ps)
Constructor.
T const * product() const
MonitorElement * meEEDigiSimRatio_
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
MonitorElement * meGunPhi_
edm::EDGetTokenT< ESDigiCollection > ESdigiCollectionToken_
MonitorElement * meEEDigiSimRatiogt20ADC_
edm::EDGetTokenT< edm::HepMCProduct > HepMCToken_
void checkCalibrations(edm::EventSetup const &c)
edm::EDGetTokenT< CrossingFrame< PCaloHit > > crossingFramePCaloHitEEToken_
std::vector< SimTrack > SimTrackContainer
MonitorElement * meEBDigiSimRatiogt100ADC_
static const int MAXSAMPLES
edm::EDGetTokenT< edm::SimTrackContainer > g4TkInfoToken_
int adc() const
get the ADC sample (12 bits)