25 HepMCLabel(ps.getParameter<std::
string>(
"moduleLabelMC")),
26 hitsProducer_(ps.getParameter<std::
string>(
"hitsProducer")),
27 EBdigiCollection_(ps.getParameter<edm::InputTag>(
"EBdigiCollection")),
28 EEdigiCollection_(ps.getParameter<edm::InputTag>(
"EEdigiCollection")),
29 ESdigiCollection_(ps.getParameter<edm::InputTag>(
"ESdigiCollection")){
34 double simHitToPhotoelectronsBarrel = ps.
getParameter<
double>(
"simHitToPhotoelectronsBarrel");
35 double simHitToPhotoelectronsEndcap = ps.
getParameter<
double>(
"simHitToPhotoelectronsEndcap");
36 double photoelectronsToAnalogBarrel = ps.
getParameter<
double>(
"photoelectronsToAnalogBarrel");
37 double photoelectronsToAnalogEndcap = ps.
getParameter<
double>(
"photoelectronsToAnalogEndcap");
38 double samplingFactor = ps.
getParameter<
double>(
"samplingFactor");
40 int readoutFrameSize = ps.
getParameter<
int>(
"readoutFrameSize");
42 bool doPhotostatistics = ps.
getParameter<
bool>(
"doPhotostatistics");
45 doPhotostatistics =
false;
48 photoelectronsToAnalogBarrel, photoelectronsToAnalogEndcap,
49 samplingFactor, timePhase, readoutFrameSize, binOfMaximum,
50 doPhotostatistics, syncPhase);
106 if (
verbose_ ) dbe_->showDirStructure();
145 dbe_->setCurrentFolder(
"EcalDigisV/EcalDigiTask");
147 sprintf (histo,
"EcalDigiTask Barrel maximum Digi over sim signal ratio gt 100 ADC" ) ;
150 sprintf (histo,
"EcalDigiTask Endcap maximum Digi over sim signal ratio gt 100 ADC" ) ;
153 sprintf (histo,
"EcalDigiTask Barrel maximum Digi over sim signal ratio signal gt 50pc gun" ) ;
156 sprintf (histo,
"EcalDigiTask Endcap maximum Digi over sim signal ratio signal gt 40pc gun" ) ;
159 sprintf (histo,
"EcalDigiTask Barrel bunch crossing" ) ;
162 sprintf (histo,
"EcalDigiTask Endcap bunch crossing" ) ;
165 sprintf (histo,
"EcalDigiTask Preshower bunch crossing" ) ;
170 sprintf (histo,
"EcalDigiTask Barrel shape bunch crossing %02d",
i-10 );
171 meEBBunchShape_[
i] = dbe_->bookProfile(histo, histo, 10, 0, 10, 4000, 0., 400.);
173 sprintf (histo,
"EcalDigiTask Endcap shape bunch crossing %02d",
i-10 );
174 meEEBunchShape_[
i] = dbe_->bookProfile(histo, histo, 10, 0, 10, 4000, 0., 400.);
176 sprintf (histo,
"EcalDigiTask Preshower shape bunch crossing %02d",
i-10 );
177 meESBunchShape_[
i] = dbe_->bookProfile(histo, histo, 3, 0, 3, 4000, 0., 400.);
181 sprintf (histo,
"EcalDigiTask Barrel shape digi");
182 meEBShape_ = dbe_->bookProfile(histo, histo, 10, 0, 10, 4000, 0., 2000.);
184 sprintf (histo,
"EcalDigiTask Endcap shape digi");
185 meEEShape_ = dbe_->bookProfile(histo, histo, 10, 0, 10, 4000, 0., 2000.);
187 sprintf (histo,
"EcalDigiTask Preshower shape digi");
188 meESShape_ = dbe_->bookProfile(histo, histo, 3, 0, 3, 4000, 0., 2000.);
190 sprintf (histo,
"EcalDigiTask Barrel shape digi ratio");
193 sprintf (histo,
"EcalDigiTask Endcap shape digi ratio");
196 sprintf (histo,
"EcalDigiTask Preshower shape digi ratio");
218 std::vector<MonitorElement *> theBunches;
243 std::vector<double> bunchSum;
244 bunchSum.reserve(nSample);
245 std::vector<double> bunchSumErro;
246 bunchSumErro.reserve(nSample);
247 std::vector<double>
total;
248 total.reserve(nSample);
249 std::vector<double> totalErro;
250 totalErro.reserve(nSample);
251 std::vector<double> ratio;
252 ratio.reserve(nSample);
253 std::vector<double> ratioErro;
254 ratioErro.reserve(nSample);
257 for (
int iEl = 0 ; iEl < nSample ; iEl++ ) {
259 bunchSumErro[iEl] = 0.;
266 for (
int iSample = 0 ; iSample < nSample ; iSample++ ) {
269 totalErro[iSample] += theTotal->
getBinError(iSample+1);
275 bunchSum[iSample] += theBunches[iHisto]->getBinContent(iSample+1);
276 bunchSumErro[iSample] +=
pow(theBunches[iHisto]->getBinError(iSample+1),2);
279 bunchSumErro[iSample] =
sqrt(bunchSumErro[iSample]);
281 if ( bunchSum[iSample] > 0. ) {
282 ratio[iSample] = total[iSample]/bunchSum[iSample];
283 ratioErro[iSample] =
sqrt(
pow(totalErro[iSample]/bunchSum[iSample],2)+
284 pow((total[iSample]*bunchSumErro[iSample])/(bunchSum[iSample]*bunchSum[iSample]),2));
287 std::cout <<
" Sample = " << iSample <<
" Total = " << total[iSample] <<
" +- " << totalErro[iSample] <<
"\n"
288 <<
" Sum = " << bunchSum[iSample] <<
" +- " << bunchSumErro[iSample] <<
"\n"
289 <<
" Ratio = " << ratio[iSample] <<
" +- " << ratioErro[iSample] << std::endl;
292 theRatio->
setBinError(iSample+1, (
float)ratioErro[iSample]);
304 std::vector<SimTrack> theSimTracks;
305 std::vector<SimVertex> theSimVertexes;
316 if (!MCEvt.
isValid()) { skipMC =
true; }
322 bool isBarrel =
true;
325 EBdigis = EcalDigiEB.
product();
326 LogDebug(
"DigiInfo") <<
"total # EBdigis: " << EBdigis->
size() ;
327 if ( EBdigis->
size() == 0 ) isBarrel =
false;
332 bool isEndcap =
true;
335 EEdigis = EcalDigiEE.
product();
336 LogDebug(
"DigiInfo") <<
"total # EEdigis: " << EEdigis->
size() ;
337 if ( EEdigis->
size() == 0 ) isEndcap =
false;
342 bool isPreshower =
true;
345 ESdigis = EcalDigiES.
product();
346 LogDebug(
"DigiInfo") <<
"total # ESdigis: " << ESdigis->
size() ;
347 if ( ESdigis->
size() == 0 ) isPreshower =
false;
352 double theGunEnergy = 0.;
354 for ( HepMC::GenEvent::particle_const_iterator
p = MCEvt->GetEvent()->particles_begin();
355 p != MCEvt->GetEvent()->particles_end(); ++
p ) {
357 theGunEnergy = (*p)->momentum().e();
362 edm::LogWarning(
"DigiInfo") <<
"No HepMC available, using 30 GeV as giun energy";
373 e.
getByLabel(
"mix",barrelHitsName,crossingFrame);
374 std::auto_ptr<MixCollection<PCaloHit> >
379 double ebSimThreshold = 0.5*theGunEnergy;
382 hitItr != barrelHits->end () ;
388 <<
" CaloHit " << hitItr->getName() <<
"\n"
389 <<
" DetID = "<<hitItr->id()<<
" EBDetId = " << ebid.
ieta() <<
" " << ebid.
iphi() <<
"\n"
390 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
391 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
392 <<
" Energy = " << hitItr->energy();
394 uint32_t crystid = ebid.
rawId();
396 if ( hitItr->eventId().rawId() == 0 ) ebSignalSimMap[crystid] += hitItr->energy();
406 std::vector<double> ebAnalogSignal ;
407 std::vector<double> ebADCCounts ;
408 std::vector<double> ebADCGains ;
413 for (
unsigned int digis=0; digis<EcalDigiEB->size(); ++digis) {
416 int nrSamples=ebdf.
size();
424 ebAnalogSignal[
sample] = 0.;
436 if (Emax < ebAnalogSignal[
sample] ) {
437 Emax = ebAnalogSignal[
sample] ;
440 LogDebug(
"DigiInfo") <<
"EB sample " << sample <<
" ADC counts = " << ebADCCounts[
sample] <<
" Gain Id = " << ebADCGains[
sample] <<
" Analog eq = " << ebAnalogSignal[
sample];
442 double pedestalPreSampleAnalog = 0.;
443 findPedestal( ebid, (
int)ebADCGains[Pmax] , pedestalPreSampleAnalog);
445 double Erec = Emax - pedestalPreSampleAnalog;
447 if ( ebSignalSimMap[ebid.
rawId()] != 0. ) {
448 LogDebug(
"DigiInfo") <<
" Digi / Signal Hit = " << Erec <<
" / " << ebSignalSimMap[ebid.
rawId()] <<
" gainConv " <<
gainConv_[(int)ebADCGains[Pmax]];
452 for (
int i = 0;
i < 10 ;
i++ ) {
453 pedestalPreSampleAnalog = 0.;
454 findPedestal( ebid, (
int)ebADCGains[
i] , pedestalPreSampleAnalog);
475 e.
getByLabel(
"mix",endcapHitsName,crossingFrame);
476 std::auto_ptr<MixCollection<PCaloHit> >
481 double eeSimThreshold = 0.4*theGunEnergy;
484 hitItr != endcapHits->end () ;
490 <<
" CaloHit " << hitItr->getName() <<
"\n"
491 <<
" DetID = "<<hitItr->id()<<
" EEDetId side = " << eeid.
zside() <<
" = " << eeid.
ix() <<
" " << eeid.
iy() <<
"\n"
492 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
493 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
494 <<
" Energy = " << hitItr->energy();
496 uint32_t crystid = eeid.
rawId();
498 if ( hitItr->eventId().rawId() == 0 ) eeSignalSimMap[crystid] += hitItr->energy();
508 std::vector<double> eeAnalogSignal ;
509 std::vector<double> eeADCCounts ;
510 std::vector<double> eeADCGains ;
515 for (
unsigned int digis=0; digis<EcalDigiEE->size(); ++digis) {
518 int nrSamples=eedf.
size();
526 eeAnalogSignal[
sample] = 0.;
538 if (Emax < eeAnalogSignal[
sample] ) {
539 Emax = eeAnalogSignal[
sample] ;
542 LogDebug(
"DigiInfo") <<
"EE sample " << sample <<
" ADC counts = " << eeADCCounts[
sample] <<
" Gain Id = " << eeADCGains[
sample] <<
" Analog eq = " << eeAnalogSignal[
sample];
544 double pedestalPreSampleAnalog = 0.;
545 findPedestal( eeid, (
int)eeADCGains[Pmax] , pedestalPreSampleAnalog);
547 double Erec = Emax - pedestalPreSampleAnalog;
549 if ( eeSignalSimMap[eeid.
rawId()] != 0. ) {
550 LogDebug(
"DigiInfo") <<
" Digi / Signal Hit = " << Erec <<
" / " << eeSignalSimMap[eeid.
rawId()] <<
" gainConv " <<
gainConv_[(int)eeADCGains[Pmax]];
554 for (
int i = 0;
i < 10 ;
i++ ) {
555 pedestalPreSampleAnalog = 0.;
556 findPedestal( eeid, (
int)eeADCGains[
i] , pedestalPreSampleAnalog);
571 e.
getByLabel(
"mix",preshowerHitsName,crossingFrame);
572 std::auto_ptr<MixCollection<PCaloHit> >
578 hitItr != preshowerHits->end () ;
584 <<
" CaloHit " << hitItr->getName() <<
"\n"
585 <<
" DetID = "<<hitItr->id()<<
"ESDetId: z side " << esid.
zside() <<
" plane " << esid.
plane() << esid.
six() <<
',' << esid.
siy() <<
':' << esid.
strip() <<
"\n"
586 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
587 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
588 <<
" Energy = " << hitItr->energy();
590 uint32_t stripid = esid.
rawId();
592 if ( hitItr->eventId().rawId() == 0 ) esSignalSimMap[stripid] += hitItr->energy();
600 std::vector<double> esADCCounts ;
601 std::vector<double> esADCAnalogSignal ;
605 for (
unsigned int digis=0; digis<EcalDigiES->size(); ++digis) {
608 int nrSamples=esdf.
size();
614 esADCAnalogSignal[
sample] = 0.;
627 LogDebug(
"DigiInfo") <<
"Preshower Digi for ESDetId: z side " << esid.
zside() <<
" plane " << esid.
plane() << esid.
six() <<
',' << esid.
siy() <<
':' << esid.
strip();
628 for (
int i = 0;
i < 3 ;
i++ ) {
629 LogDebug(
"DigiInfo") <<
"sample " <<
i <<
" ADC = " << esADCCounts[
i] <<
" Analog eq = " << esADCAnalogSignal[
i];
633 for (
int i = 0;
i < 3 ;
i++ ) {
663 LogDebug(
"EcalDigi") <<
" Gains conversions: " <<
"\n" <<
" g1 = " << gainConv_[1] <<
"\n" <<
" g2 = " << gainConv_[2] <<
"\n" <<
" g3 = " << gainConv_[3];
665 delete defaultRatios;
697 ( 2 ==
m_ESgain ? 0.8815 : 1.0 ) ) ) ;
738 LogDebug(
"EcalMMValid") <<
"Pedestals for " << detId.
rawId() <<
" gain range " << gainId <<
" : \n" <<
"Mean = " << ped;
773 std::vector<DetId> theOverThresholdId;
774 for (
unsigned int i = 0 ;
i < theSDId.size() ;
i++ ) {
776 int sdId = theSDId[
i].rawId();
777 if ( SignalSimMap[sdId] > theSimThreshold ) theOverThresholdId.push_back( theSDId[
i] );
805 for ( std::vector<DetId>::const_iterator idItr = theOverThresholdId.begin() ; idItr != theOverThresholdId.end() ; ++idItr ) {
819 if ( analogSignal ) {
823 for (
int i = 0 ;
i <
limit ;
i++ ) {
T getParameter(std::string const &) const
void setGeometry(const CaloGeometry *geometry)
geometry needed for time-of-flight
T getUntrackedParameter(std::string const &, T const &) const
void checkPedestals(const edm::EventSetup &c)
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * meEBDigiMixRatioOriggt50pc_
MonitorElement * meESbunchCrossing_
const ESIntercalibConstants * m_ESmips
void computeSDBunchDigi(const edm::EventSetup &eventSetup, MixCollection< PCaloHit > &theHits, MapType &ebSignalSimMap, const EcalSubdetector &thisDet, const double &theSimThreshold)
void findPedestal(const DetId &detId, int gainId, double &ped) const
static const int MAXSAMPLES
virtual const CaloSimParameters & simParameters(const DetId &id) const
return the sim parameters relative to the right subdet
int gainId(sample_type sample)
get the gainId (2 bits)
void setGain(const int gain)
const self & getMap() const
const ESDetId & id() const
MonitorElement * meEEShapeRatio_
const self & getMap() const
float getESValueLow() const
edm::InputTag EEdigiCollection_
void checkCalibrations(edm::EventSetup const &c)
MonitorElement * meEEBunchShape_[nBunch]
MonitorElement * meEBBunchShape_[nBunch]
const EBShape * theEBShape
edm::InputTag ESdigiCollection_
int gainId() const
get the gainId (2 bits)
MonitorElement * meESShape_
CaloHitResponse * theESResponse
MonitorElement * meESShapeRatio_
int iphi() const
get the crystal iphi
uint32_t rawId() const
get the raw id
MonitorElement * meEBbunchCrossing_
CaloHitResponse * theEBResponse
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
void bunchSumTest(std::vector< MonitorElement * > &theBunches, MonitorElement *&theTotal, MonitorElement *&theRatio, int nSample)
MonitorElement * meESBunchShape_[nBunch]
Creates electronics signals from hits.
static const int MAXSAMPLES
MonitorElement * meEBShape_
const_iterator find(uint32_t rawId) const
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
int ieta() const
get the crystal ieta
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
std::map< int, double, std::less< int > > gainConv_
void analyze(edm::Event const &e, edm::EventSetup const &c)
Analyze.
virtual void run(MixCollection< PCaloHit > &hits)
Complete cell digitization.
const EcalSimParameterMap * theParameterMap
const EcalPedestals * thePedestals
std::map< uint32_t, float, std::less< uint32_t > > MapType
MonitorElement * meEBShapeRatio_
const CaloGeometry * theGeometry
MonitorElement * meEEbunchCrossing_
edm::InputTag EBdigiCollection_
double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
T const * product() const
float gain12Over6() const
std::string hitsProducer_
T const * product() const
CaloHitResponse * theEEResponse
void setBunchRange(int minBunch, int maxBunch)
tells it which pileup bunches to do
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
CaloSamples * findSignal(const DetId &detId)
users can look for the signal for a given cell
const EEShape * theEEShape
double getBinContent(int binx) const
get content of bin (1-D)
void clear()
frees up memory
const ESPedestals * m_ESpeds
MonitorElement * meEEShape_
void endRun(const edm::Run &r, const edm::EventSetup &c)
const_iterator find(uint32_t rawId) const
void beginRun(edm::Run const &, edm::EventSetup const &c)
~EcalMixingModuleValidation()
Destructor.
const_iterator end() const
int adc() const
get the ADC sample (singed 16 bits)
DetId id() const
get the (generic) id
EcalMixingModuleValidation(const edm::ParameterSet &ps)
Constructor.
float getESValueHigh() const
static const int MAXSAMPLES
Power< A, B >::type pow(const A &a, const B &b)
int adc() const
get the ADC sample (12 bits)
MonitorElement * meEBDigiMixRatiogt100ADC_
MonitorElement * meEEDigiMixRatiogt100ADC_
MonitorElement * meEEDigiMixRatioOriggt40pc_