20 HepMCToken_( consumes<edm::
HepMCProduct>( edm::InputTag( ps.getParameter<std::
string>(
"moduleLabelMC" ) ) ) ),
21 EBdigiCollectionToken_( consumes<
EBDigiCollection>( ps.getParameter<edm::InputTag>(
"EBdigiCollection" ) ) ),
22 EEdigiCollectionToken_( consumes<
EEDigiCollection>( ps.getParameter<edm::InputTag>(
"EEdigiCollection" ) ) ),
23 ESdigiCollectionToken_( consumes<
ESDigiCollection>( ps.getParameter<edm::InputTag>(
"ESdigiCollection" ) ) ),
25 , ps.getParameter<std::
string>(
"hitsProducer" ) + std::
string(
"EcalHitsEB" )
30 , ps.getParameter<std::
string>(
"hitsProducer" ) + std::
string(
"EcalHitsEE" )
35 , ps.getParameter<std::
string>(
"hitsProducer" ) + std::
string(
"EcalHitsES" )
43 double simHitToPhotoelectronsBarrel = ps.
getParameter<
double>(
"simHitToPhotoelectronsBarrel");
44 double simHitToPhotoelectronsEndcap = ps.
getParameter<
double>(
"simHitToPhotoelectronsEndcap");
45 double photoelectronsToAnalogBarrel = ps.
getParameter<
double>(
"photoelectronsToAnalogBarrel");
46 double photoelectronsToAnalogEndcap = ps.
getParameter<
double>(
"photoelectronsToAnalogEndcap");
47 double samplingFactor = ps.
getParameter<
double>(
"samplingFactor");
49 int readoutFrameSize = ps.
getParameter<
int>(
"readoutFrameSize");
51 bool doPhotostatistics = ps.
getParameter<
bool>(
"doPhotostatistics");
54 doPhotostatistics =
false;
57 photoelectronsToAnalogBarrel, photoelectronsToAnalogEndcap,
58 samplingFactor, timePhase, readoutFrameSize, binOfMaximum,
59 doPhotostatistics, syncPhase);
115 if (
verbose_ ) dbe_->showDirStructure();
154 dbe_->setCurrentFolder(
"EcalDigisV/EcalDigiTask");
156 sprintf (histo,
"EcalDigiTask Barrel maximum Digi over sim signal ratio gt 100 ADC" ) ;
159 sprintf (histo,
"EcalDigiTask Endcap maximum Digi over sim signal ratio gt 100 ADC" ) ;
162 sprintf (histo,
"EcalDigiTask Barrel maximum Digi over sim signal ratio signal gt 50pc gun" ) ;
165 sprintf (histo,
"EcalDigiTask Endcap maximum Digi over sim signal ratio signal gt 40pc gun" ) ;
168 sprintf (histo,
"EcalDigiTask Barrel bunch crossing" ) ;
171 sprintf (histo,
"EcalDigiTask Endcap bunch crossing" ) ;
174 sprintf (histo,
"EcalDigiTask Preshower bunch crossing" ) ;
179 sprintf (histo,
"EcalDigiTask Barrel shape bunch crossing %02d",
i-10 );
180 meEBBunchShape_[
i] = dbe_->bookProfile(histo, histo, 10, 0, 10, 4000, 0., 400.);
182 sprintf (histo,
"EcalDigiTask Endcap shape bunch crossing %02d",
i-10 );
183 meEEBunchShape_[
i] = dbe_->bookProfile(histo, histo, 10, 0, 10, 4000, 0., 400.);
185 sprintf (histo,
"EcalDigiTask Preshower shape bunch crossing %02d",
i-10 );
186 meESBunchShape_[
i] = dbe_->bookProfile(histo, histo, 3, 0, 3, 4000, 0., 400.);
190 sprintf (histo,
"EcalDigiTask Barrel shape digi");
191 meEBShape_ = dbe_->bookProfile(histo, histo, 10, 0, 10, 4000, 0., 2000.);
193 sprintf (histo,
"EcalDigiTask Endcap shape digi");
194 meEEShape_ = dbe_->bookProfile(histo, histo, 10, 0, 10, 4000, 0., 2000.);
196 sprintf (histo,
"EcalDigiTask Preshower shape digi");
197 meESShape_ = dbe_->bookProfile(histo, histo, 3, 0, 3, 4000, 0., 2000.);
199 sprintf (histo,
"EcalDigiTask Barrel shape digi ratio");
202 sprintf (histo,
"EcalDigiTask Endcap shape digi ratio");
205 sprintf (histo,
"EcalDigiTask Preshower shape digi ratio");
227 std::vector<MonitorElement *> theBunches;
252 std::vector<double> bunchSum;
253 bunchSum.reserve(nSample);
254 std::vector<double> bunchSumErro;
255 bunchSumErro.reserve(nSample);
256 std::vector<double>
total;
257 total.reserve(nSample);
258 std::vector<double> totalErro;
259 totalErro.reserve(nSample);
260 std::vector<double> ratio;
261 ratio.reserve(nSample);
262 std::vector<double> ratioErro;
263 ratioErro.reserve(nSample);
266 for (
int iEl = 0 ; iEl < nSample ; iEl++ ) {
268 bunchSumErro[iEl] = 0.;
275 for (
int iSample = 0 ; iSample < nSample ; iSample++ ) {
278 totalErro[iSample] += theTotal->
getBinError(iSample+1);
284 bunchSum[iSample] += theBunches[iHisto]->getBinContent(iSample+1);
285 bunchSumErro[iSample] +=
pow(theBunches[iHisto]->getBinError(iSample+1),2);
288 bunchSumErro[iSample] =
sqrt(bunchSumErro[iSample]);
290 if ( bunchSum[iSample] > 0. ) {
291 ratio[iSample] = total[iSample]/bunchSum[iSample];
292 ratioErro[iSample] =
sqrt(
pow(totalErro[iSample]/bunchSum[iSample],2)+
293 pow((total[iSample]*bunchSumErro[iSample])/(bunchSum[iSample]*bunchSum[iSample]),2));
296 std::cout <<
" Sample = " << iSample <<
" Total = " << total[iSample] <<
" +- " << totalErro[iSample] <<
"\n"
297 <<
" Sum = " << bunchSum[iSample] <<
" +- " << bunchSumErro[iSample] <<
"\n"
298 <<
" Ratio = " << ratio[iSample] <<
" +- " << ratioErro[iSample] << std::endl;
301 theRatio->
setBinError(iSample+1, (
float)ratioErro[iSample]);
313 std::vector<SimTrack> theSimTracks;
314 std::vector<SimVertex> theSimVertexes;
325 if (!MCEvt.
isValid()) { skipMC =
true; }
331 bool isBarrel =
true;
334 EBdigis = EcalDigiEB.
product();
335 LogDebug(
"DigiInfo") <<
"total # EBdigis: " << EBdigis->
size() ;
336 if ( EBdigis->
size() == 0 ) isBarrel =
false;
341 bool isEndcap =
true;
344 EEdigis = EcalDigiEE.
product();
345 LogDebug(
"DigiInfo") <<
"total # EEdigis: " << EEdigis->
size() ;
346 if ( EEdigis->
size() == 0 ) isEndcap =
false;
351 bool isPreshower =
true;
354 ESdigis = EcalDigiES.
product();
355 LogDebug(
"DigiInfo") <<
"total # ESdigis: " << ESdigis->
size() ;
356 if ( ESdigis->
size() == 0 ) isPreshower =
false;
361 double theGunEnergy = 0.;
363 for ( HepMC::GenEvent::particle_const_iterator
p = MCEvt->GetEvent()->particles_begin();
364 p != MCEvt->GetEvent()->particles_end(); ++
p ) {
366 theGunEnergy = (*p)->momentum().e();
371 edm::LogWarning(
"DigiInfo") <<
"No HepMC available, using 30 GeV as giun energy";
382 std::auto_ptr<MixCollection<PCaloHit> >
387 double ebSimThreshold = 0.5*theGunEnergy;
390 hitItr != barrelHits->end () ;
396 <<
" CaloHit " << hitItr->getName() <<
"\n"
397 <<
" DetID = "<<hitItr->id()<<
" EBDetId = " << ebid.
ieta() <<
" " << ebid.
iphi() <<
"\n"
398 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
399 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
400 <<
" Energy = " << hitItr->energy();
402 uint32_t crystid = ebid.
rawId();
404 if ( hitItr->eventId().rawId() == 0 ) ebSignalSimMap[crystid] += hitItr->energy();
414 std::vector<double> ebAnalogSignal ;
415 std::vector<double> ebADCCounts ;
416 std::vector<double> ebADCGains ;
421 for (
unsigned int digis=0; digis<EcalDigiEB->size(); ++digis) {
424 int nrSamples=ebdf.
size();
432 ebAnalogSignal[
sample] = 0.;
444 if (Emax < ebAnalogSignal[
sample] ) {
445 Emax = ebAnalogSignal[
sample] ;
448 LogDebug(
"DigiInfo") <<
"EB sample " << sample <<
" ADC counts = " << ebADCCounts[
sample] <<
" Gain Id = " << ebADCGains[
sample] <<
" Analog eq = " << ebAnalogSignal[
sample];
450 double pedestalPreSampleAnalog = 0.;
451 findPedestal( ebid, (
int)ebADCGains[Pmax] , pedestalPreSampleAnalog);
453 double Erec = Emax - pedestalPreSampleAnalog;
455 if ( ebSignalSimMap[ebid.
rawId()] != 0. ) {
456 LogDebug(
"DigiInfo") <<
" Digi / Signal Hit = " << Erec <<
" / " << ebSignalSimMap[ebid.
rawId()] <<
" gainConv " <<
gainConv_[(int)ebADCGains[Pmax]];
460 for (
int i = 0;
i < 10 ;
i++ ) {
461 pedestalPreSampleAnalog = 0.;
462 findPedestal( ebid, (
int)ebADCGains[
i] , pedestalPreSampleAnalog);
483 std::auto_ptr<MixCollection<PCaloHit> >
488 double eeSimThreshold = 0.4*theGunEnergy;
491 hitItr != endcapHits->end () ;
497 <<
" CaloHit " << hitItr->getName() <<
"\n"
498 <<
" DetID = "<<hitItr->id()<<
" EEDetId side = " << eeid.
zside() <<
" = " << eeid.
ix() <<
" " << eeid.
iy() <<
"\n"
499 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
500 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
501 <<
" Energy = " << hitItr->energy();
503 uint32_t crystid = eeid.
rawId();
505 if ( hitItr->eventId().rawId() == 0 ) eeSignalSimMap[crystid] += hitItr->energy();
515 std::vector<double> eeAnalogSignal ;
516 std::vector<double> eeADCCounts ;
517 std::vector<double> eeADCGains ;
522 for (
unsigned int digis=0; digis<EcalDigiEE->size(); ++digis) {
525 int nrSamples=eedf.
size();
533 eeAnalogSignal[
sample] = 0.;
545 if (Emax < eeAnalogSignal[
sample] ) {
546 Emax = eeAnalogSignal[
sample] ;
549 LogDebug(
"DigiInfo") <<
"EE sample " << sample <<
" ADC counts = " << eeADCCounts[
sample] <<
" Gain Id = " << eeADCGains[
sample] <<
" Analog eq = " << eeAnalogSignal[
sample];
551 double pedestalPreSampleAnalog = 0.;
552 findPedestal( eeid, (
int)eeADCGains[Pmax] , pedestalPreSampleAnalog);
554 double Erec = Emax - pedestalPreSampleAnalog;
556 if ( eeSignalSimMap[eeid.
rawId()] != 0. ) {
557 LogDebug(
"DigiInfo") <<
" Digi / Signal Hit = " << Erec <<
" / " << eeSignalSimMap[eeid.
rawId()] <<
" gainConv " <<
gainConv_[(int)eeADCGains[Pmax]];
561 for (
int i = 0;
i < 10 ;
i++ ) {
562 pedestalPreSampleAnalog = 0.;
563 findPedestal( eeid, (
int)eeADCGains[
i] , pedestalPreSampleAnalog);
578 std::auto_ptr<MixCollection<PCaloHit> >
584 hitItr != preshowerHits->end () ;
590 <<
" CaloHit " << hitItr->getName() <<
"\n"
591 <<
" DetID = "<<hitItr->id()<<
"ESDetId: z side " << esid.
zside() <<
" plane " << esid.
plane() << esid.
six() <<
',' << esid.
siy() <<
':' << esid.
strip() <<
"\n"
592 <<
" Time = " << hitItr->time() <<
" Event id. = " << hitItr->eventId().rawId() <<
"\n"
593 <<
" Track Id = " << hitItr->geantTrackId() <<
"\n"
594 <<
" Energy = " << hitItr->energy();
596 uint32_t stripid = esid.
rawId();
598 if ( hitItr->eventId().rawId() == 0 ) esSignalSimMap[stripid] += hitItr->energy();
606 std::vector<double> esADCCounts ;
607 std::vector<double> esADCAnalogSignal ;
611 for (
unsigned int digis=0; digis<EcalDigiES->size(); ++digis) {
614 int nrSamples=esdf.
size();
620 esADCAnalogSignal[
sample] = 0.;
633 LogDebug(
"DigiInfo") <<
"Preshower Digi for ESDetId: z side " << esid.
zside() <<
" plane " << esid.
plane() << esid.
six() <<
',' << esid.
siy() <<
':' << esid.
strip();
634 for (
int i = 0;
i < 3 ;
i++ ) {
635 LogDebug(
"DigiInfo") <<
"sample " <<
i <<
" ADC = " << esADCCounts[
i] <<
" Analog eq = " << esADCAnalogSignal[
i];
639 for (
int i = 0;
i < 3 ;
i++ ) {
669 LogDebug(
"EcalDigi") <<
" Gains conversions: " <<
"\n" <<
" g1 = " << gainConv_[1] <<
"\n" <<
" g2 = " << gainConv_[2] <<
"\n" <<
" g3 = " << gainConv_[3];
671 delete defaultRatios;
703 ( 2 ==
m_ESgain ? 0.8815 : 1.0 ) ) ) ;
744 LogDebug(
"EcalMMValid") <<
"Pedestals for " << detId.
rawId() <<
" gain range " << gainId <<
" : \n" <<
"Mean = " << ped;
779 std::vector<DetId> theOverThresholdId;
780 for (
unsigned int i = 0 ;
i < theSDId.size() ;
i++ ) {
782 int sdId = theSDId[
i].rawId();
783 if ( SignalSimMap[sdId] > theSimThreshold ) theOverThresholdId.push_back( theSDId[
i] );
811 for ( std::vector<DetId>::const_iterator idItr = theOverThresholdId.begin() ; idItr != theOverThresholdId.end() ; ++idItr ) {
825 if ( analogSignal ) {
829 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_
void computeSDBunchDigi(const edm::EventSetup &eventSetup, MixCollection< PCaloHit > &theHits, MapType &ebSignalSimMap, const EcalSubdetector &thisDet, const double &theSimThreshold, CLHEP::HepRandomEngine *)
MonitorElement * meESbunchCrossing_
const ESIntercalibConstants * m_ESmips
edm::EDGetTokenT< CrossingFrame< PCaloHit > > crossingFramePCaloHitESToken_
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)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void setGain(const int gain)
const self & getMap() const
edm::EDGetTokenT< edm::HepMCProduct > HepMCToken_
const ESDetId & id() const
MonitorElement * meEEShapeRatio_
const self & getMap() const
float getESValueLow() const
virtual void run(MixCollection< PCaloHit > &hits, CLHEP::HepRandomEngine *)
Complete cell digitization.
void checkCalibrations(edm::EventSetup const &c)
MonitorElement * meEEBunchShape_[nBunch]
edm::EDGetTokenT< EBDigiCollection > EBdigiCollectionToken_
std::vector< CLHEP::HepRandomEngine * > randomEngines_
MonitorElement * meEBBunchShape_[nBunch]
const EBShape * theEBShape
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
edm::EDGetTokenT< CrossingFrame< PCaloHit > > crossingFramePCaloHitEEToken_
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
CLHEP::HepRandomEngine * randomEngine(edm::StreamID const &streamID)
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
edm::EDGetTokenT< CrossingFrame< PCaloHit > > crossingFramePCaloHitEBToken_
std::map< int, double, std::less< int > > gainConv_
void analyze(edm::Event const &e, edm::EventSetup const &c)
Analyze.
const EcalSimParameterMap * theParameterMap
const EcalPedestals * thePedestals
std::map< uint32_t, float, std::less< uint32_t > > MapType
edm::EDGetTokenT< ESDigiCollection > ESdigiCollectionToken_
MonitorElement * meEBShapeRatio_
unsigned int value() const
const CaloGeometry * theGeometry
MonitorElement * meEEbunchCrossing_
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
T const * product() const
CaloHitResponse * theEEResponse
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &) const =0
Use this engine in event methods.
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
StreamID streamID() const
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)
edm::EDGetTokenT< EEDigiCollection > EEdigiCollectionToken_
int adc() const
get the ADC sample (12 bits)
MonitorElement * meEBDigiMixRatiogt100ADC_
MonitorElement * meEEDigiMixRatiogt100ADC_
MonitorElement * meEEDigiMixRatioOriggt40pc_