43 doPhotostatistics =
false;
46 simHitToPhotoelectronsEndcap,
47 photoelectronsToAnalogBarrel,
48 photoelectronsToAnalogEndcap,
140 sprintf(histo,
"EcalDigiTask Barrel maximum Digi over sim signal ratio gt 100 ADC");
143 sprintf(histo,
"EcalDigiTask Endcap maximum Digi over sim signal ratio gt 100 ADC");
146 sprintf(histo,
"EcalDigiTask Barrel maximum Digi over sim signal ratio signal gt 50pc gun");
149 sprintf(histo,
"EcalDigiTask Endcap maximum Digi over sim signal ratio signal gt 40pc gun");
152 sprintf(histo,
"EcalDigiTask Barrel bunch crossing");
155 sprintf(histo,
"EcalDigiTask Endcap bunch crossing");
158 sprintf(histo,
"EcalDigiTask Preshower bunch crossing");
162 sprintf(histo,
"EcalDigiTask Barrel shape bunch crossing %02d",
i - 10);
165 sprintf(histo,
"EcalDigiTask Endcap shape bunch crossing %02d",
i - 10);
168 sprintf(histo,
"EcalDigiTask Preshower shape bunch crossing %02d",
i - 10);
172 sprintf(histo,
"EcalDigiTask Barrel shape digi");
175 sprintf(histo,
"EcalDigiTask Endcap shape digi");
178 sprintf(histo,
"EcalDigiTask Preshower shape digi");
181 sprintf(histo,
"EcalDigiTask Barrel shape digi ratio");
184 sprintf(histo,
"EcalDigiTask Endcap shape digi ratio");
187 sprintf(histo,
"EcalDigiTask Preshower shape digi ratio");
194 std::vector<MonitorElement*> theBunches;
219 std::vector<double> bunchSum;
220 bunchSum.reserve(nSample);
221 std::vector<double> bunchSumErro;
222 bunchSumErro.reserve(nSample);
223 std::vector<double>
total;
224 total.reserve(nSample);
225 std::vector<double> totalErro;
226 totalErro.reserve(nSample);
227 std::vector<double>
ratio;
228 ratio.reserve(nSample);
229 std::vector<double> ratioErro;
230 ratioErro.reserve(nSample);
232 for (
int iEl = 0; iEl < nSample; iEl++) {
234 bunchSumErro[iEl] = 0.;
241 for (
int iSample = 0; iSample < nSample; iSample++) {
243 totalErro[iSample] += theTotal->
getBinError(iSample + 1);
248 bunchSum[iSample] += theBunches[iHisto]->getBinContent(iSample + 1);
249 bunchSumErro[iSample] +=
pow(theBunches[iHisto]->getBinError(iSample + 1), 2);
251 bunchSumErro[iSample] =
sqrt(bunchSumErro[iSample]);
253 if (bunchSum[iSample] > 0.) {
254 ratio[iSample] = total[iSample] / bunchSum[iSample];
256 sqrt(
pow(totalErro[iSample] / bunchSum[iSample], 2) +
257 pow((total[iSample] * bunchSumErro[iSample]) / (bunchSum[iSample] * bunchSum[iSample]), 2));
260 std::cout <<
" Sample = " << iSample <<
" Total = " << total[iSample] <<
" +- " << totalErro[iSample] <<
"\n" 261 <<
" Sum = " << bunchSum[iSample] <<
" +- " << bunchSumErro[iSample] <<
"\n" 262 <<
" Ratio = " << ratio[iSample] <<
" +- " << ratioErro[iSample] << std::endl;
265 theRatio->
setBinError(iSample + 1, (
float)ratioErro[iSample]);
274 std::vector<SimTrack> theSimTracks;
275 std::vector<SimVertex> theSimVertexes;
296 EBdigis = EcalDigiEB.
product();
297 LogDebug(
"DigiInfo") <<
"total # EBdigis: " << EBdigis->
size();
298 if (EBdigis->
empty())
307 EEdigis = EcalDigiEE.
product();
308 LogDebug(
"DigiInfo") <<
"total # EEdigis: " << EEdigis->
size();
309 if (EEdigis->
empty())
315 bool isPreshower =
true;
318 ESdigis = EcalDigiES.
product();
319 LogDebug(
"DigiInfo") <<
"total # ESdigis: " << ESdigis->
size();
320 if (ESdigis->
empty())
326 double theGunEnergy = 0.;
328 for (HepMC::GenEvent::particle_const_iterator
p = MCEvt->
GetEvent()->particles_begin();
331 theGunEnergy = (*p)->momentum().e();
336 edm::LogWarning(
"DigiInfo") <<
"No HepMC available, using 30 GeV as giun energy";
350 double ebSimThreshold = 0.5 * theGunEnergy;
355 LogDebug(
"HitInfo") <<
" CaloHit " << iHit.getName() <<
"\n" 356 <<
" DetID = " << iHit.id() <<
" EBDetId = " << ebid.
ieta() <<
" " << ebid.
iphi() <<
"\n" 357 <<
" Time = " << iHit.time() <<
" Event id. = " << iHit.eventId().rawId() <<
"\n" 358 <<
" Track Id = " << iHit.geantTrackId() <<
"\n" 359 <<
" Energy = " << iHit.energy();
361 uint32_t crystid = ebid.
rawId();
363 if (iHit.eventId().rawId() == 0)
364 ebSignalSimMap[crystid] += iHit.energy();
374 std::vector<double> ebAnalogSignal;
375 std::vector<double> ebADCCounts;
376 std::vector<double> ebADCGains;
381 for (
unsigned int digis = 0; digis < EcalDigiEB->
size(); ++digis) {
383 int nrSamples = ebdf.
size();
391 ebAnalogSignal[
sample] = 0.;
402 if (Emax < ebAnalogSignal[
sample]) {
403 Emax = ebAnalogSignal[
sample];
406 LogDebug(
"DigiInfo") <<
"EB sample " << sample <<
" ADC counts = " << ebADCCounts[
sample]
407 <<
" Gain Id = " << ebADCGains[
sample] <<
" Analog eq = " << ebAnalogSignal[
sample];
409 double pedestalPreSampleAnalog = 0.;
410 findPedestal(ebid, (
int)ebADCGains[Pmax], pedestalPreSampleAnalog);
412 double Erec = Emax - pedestalPreSampleAnalog;
414 if (ebSignalSimMap[ebid.
rawId()] != 0.) {
415 LogDebug(
"DigiInfo") <<
" Digi / Signal Hit = " << Erec <<
" / " << ebSignalSimMap[ebid.
rawId()] <<
" gainConv " 422 for (
int i = 0;
i < 10;
i++) {
423 pedestalPreSampleAnalog = 0.;
424 findPedestal(ebid, (
int)ebADCGains[
i], pedestalPreSampleAnalog);
445 double eeSimThreshold = 0.4 * theGunEnergy;
450 LogDebug(
"HitInfo") <<
" CaloHit " << iHit.getName() <<
"\n" 451 <<
" DetID = " << iHit.id() <<
" EEDetId side = " << eeid.
zside() <<
" = " << eeid.
ix() <<
" " 453 <<
" Time = " << iHit.time() <<
" Event id. = " << iHit.eventId().rawId() <<
"\n" 454 <<
" Track Id = " << iHit.geantTrackId() <<
"\n" 455 <<
" Energy = " << iHit.energy();
457 uint32_t crystid = eeid.
rawId();
459 if (iHit.eventId().rawId() == 0)
460 eeSignalSimMap[crystid] += iHit.energy();
470 std::vector<double> eeAnalogSignal;
471 std::vector<double> eeADCCounts;
472 std::vector<double> eeADCGains;
477 for (
unsigned int digis = 0; digis < EcalDigiEE->
size(); ++digis) {
479 int nrSamples = eedf.
size();
487 eeAnalogSignal[
sample] = 0.;
498 if (Emax < eeAnalogSignal[
sample]) {
499 Emax = eeAnalogSignal[
sample];
502 LogDebug(
"DigiInfo") <<
"EE sample " << sample <<
" ADC counts = " << eeADCCounts[
sample]
503 <<
" Gain Id = " << eeADCGains[
sample] <<
" Analog eq = " << eeAnalogSignal[
sample];
505 double pedestalPreSampleAnalog = 0.;
506 findPedestal(eeid, (
int)eeADCGains[Pmax], pedestalPreSampleAnalog);
508 double Erec = Emax - pedestalPreSampleAnalog;
510 if (eeSignalSimMap[eeid.
rawId()] != 0.) {
511 LogDebug(
"DigiInfo") <<
" Digi / Signal Hit = " << Erec <<
" / " << eeSignalSimMap[eeid.
rawId()] <<
" gainConv " 518 for (
int i = 0;
i < 10;
i++) {
519 pedestalPreSampleAnalog = 0.;
520 findPedestal(eeid, (
int)eeADCGains[
i], pedestalPreSampleAnalog);
541 LogDebug(
"HitInfo") <<
" CaloHit " << iHit.getName() <<
"\n" 542 <<
" DetID = " << iHit.id() <<
"ESDetId: z side " << esid.
zside() <<
" plane " 543 << esid.
plane() << esid.
six() <<
',' << esid.
siy() <<
':' << esid.
strip() <<
"\n" 544 <<
" Time = " << iHit.time() <<
" Event id. = " << iHit.eventId().rawId() <<
"\n" 545 <<
" Track Id = " << iHit.geantTrackId() <<
"\n" 546 <<
" Energy = " << iHit.energy();
548 uint32_t stripid = esid.
rawId();
550 if (iHit.eventId().rawId() == 0)
551 esSignalSimMap[stripid] += iHit.energy();
560 std::vector<double> esADCCounts;
561 std::vector<double> esADCAnalogSignal;
565 for (
unsigned int digis = 0; digis < EcalDigiES->
size(); ++digis) {
567 int nrSamples = esdf.
size();
573 esADCAnalogSignal[
sample] = 0.;
585 LogDebug(
"DigiInfo") <<
"Preshower Digi for ESDetId: z side " << esid.
zside() <<
" plane " << esid.
plane()
586 << esid.
six() <<
',' << esid.
siy() <<
':' << esid.
strip();
587 for (
int i = 0;
i < 3;
i++) {
588 LogDebug(
"DigiInfo") <<
"sample " <<
i <<
" ADC = " << esADCCounts[
i]
589 <<
" Analog eq = " << esADCAnalogSignal[
i];
593 for (
int i = 0;
i < 3;
i++) {
618 LogDebug(
"EcalDigi") <<
" Gains conversions: " 620 <<
" g1 = " << gainConv_[1] <<
"\n" 621 <<
" g2 = " << gainConv_[2] <<
"\n" 622 <<
" g3 = " << gainConv_[3];
624 delete defaultRatios;
668 edm::LogError(
"EcalMMValid") <<
"Could not find pedestal for " << detId.
rawId() <<
" among the " 690 LogDebug(
"EcalMMValid") <<
"Pedestals for " << detId.
rawId() <<
" gain range " << gainId <<
" : \n" 699 const double& theSimThreshold,
700 CLHEP::HepRandomEngine* engine) {
728 std::vector<DetId> theOverThresholdId;
729 for (
unsigned int i = 0;
i < theSDId.size();
i++) {
730 int sdId = theSDId[
i].rawId();
731 if (SignalSimMap[sdId] > theSimThreshold)
732 theOverThresholdId.push_back(theSDId[
i]);
757 for (std::vector<DetId>::const_iterator idItr = theOverThresholdId.begin(); idItr != theOverThresholdId.end();
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
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)
MonitorElement * meEBDigiMixRatioOriggt50pc_
MonitorElement * meESbunchCrossing_
const ESIntercalibConstants * m_ESmips
void findPedestal(const DetId &detId, int gainId, double &ped) const
static const int MAXSAMPLES
std::map< uint32_t, float, std::less< uint32_t > > MapType
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_
void setCurrentFolder(std::string const &fullpath)
const self & getMap() const
float getESValueLow() const
simHitToPhotoelectronsEndcap
constexpr uint32_t rawId() const
get the raw id
virtual double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
void checkCalibrations(edm::EventSetup const &c)
MonitorElement * meEEBunchShape_[nBunch]
edm::EDGetTokenT< EBDigiCollection > EBdigiCollectionToken_
std::vector< CLHEP::HepRandomEngine * > randomEngines_
MonitorElement * meEBBunchShape_[nBunch]
simHitToPhotoelectronsBarrel
edm::EDGetTokenT< CrossingFrame< PCaloHit > > crossingFramePCaloHitEEToken_
int gainId() const
get the gainId (2 bits)
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
MonitorElement * meESShape_
virtual void run(const MixCollection< PCaloHit > &hits, CLHEP::HepRandomEngine *)
Complete cell digitization.
CaloHitResponse * theESResponse
MonitorElement * meESShapeRatio_
int iphi() const
get the crystal iphi
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.
~EcalMixingModuleValidation() override
Destructor.
static const int MAXSAMPLES
CLHEP::HepRandomEngine * randomEngine(edm::StreamID const &streamID)
MonitorElement * meEBShape_
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, char const *option="s")
const_iterator find(uint32_t rawId) const
const CaloSimParameters & simParameters(const DetId &id) const override
return the sim parameters relative to the right subdet
int ieta() const
get the crystal ieta
virtual double getBinContent(int binx) const
get content of bin (1-D)
bool isEndcap(GeomDetEnumerators::SubDetector m)
void computeSDBunchDigi(const edm::EventSetup &eventSetup, const MixCollection< PCaloHit > &theHits, MapType &ebSignalSimMap, const EcalSubdetector &thisDet, const double &theSimThreshold, CLHEP::HepRandomEngine *)
edm::EDGetTokenT< CrossingFrame< PCaloHit > > crossingFramePCaloHitEBToken_
std::map< int, double, std::less< int > > gainConv_
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
void reserve(size_t isize)
const EcalSimParameterMap * theParameterMap
const EcalPedestals * thePedestals
edm::EDGetTokenT< ESDigiCollection > ESdigiCollectionToken_
MonitorElement * meEBShapeRatio_
unsigned int value() const
const CaloGeometry * theGeometry
MonitorElement * meEEbunchCrossing_
const HepMC::GenEvent * GetEvent() const
T const * product() const
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
void dqmEndRun(const edm::Run &r, const edm::EventSetup &c) override
void analyze(edm::Event const &e, edm::EventSetup const &c) override
Analyze.
float gain12Over6() const
edm::EDGetTokenT< CrossingFrame< PCaloHit > > crossingFramePCaloHitESToken_
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
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
void clear()
frees up memory
photoelectronsToAnalogBarrel
const ESPedestals * m_ESpeds
StreamID streamID() const
MonitorElement * meEEShape_
void setEventSetup(const edm::EventSetup &evtSetup)
const_iterator find(uint32_t rawId) const
const_iterator end() const
int adc() const
get the ADC sample (singed 16 bits)
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
static constexpr int MAXSAMPLES
DetId id() const
get the (generic) id
EcalMixingModuleValidation(const edm::ParameterSet &ps)
Constructor.
float getESValueHigh() const
T const * product() const
photoelectronsToAnalogEndcap
Power< A, B >::type pow(const A &a, const B &b)
edm::EDGetTokenT< EEDigiCollection > EEdigiCollectionToken_
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
int adc() const
get the ADC sample (12 bits)
MonitorElement * meEBDigiMixRatiogt100ADC_
MonitorElement * meEEDigiMixRatiogt100ADC_
MonitorElement * meEEDigiMixRatioOriggt40pc_