Skip to content

Commit

Permalink
just some cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
amassiro committed Sep 17, 2019
1 parent c05e827 commit 12b3237
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 32 deletions.
33 changes: 11 additions & 22 deletions SimCalorimetry/EcalSimAlgos/interface/EcalSignalGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,12 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator {
m_peToABarrel = peToABarrel;
m_peToAEndcap = peToAEndcap;


// std::cout << " ---> EcalSignalGenerator() : EcalBaseSignalGenerator() " << std::endl;

}

~EcalSignalGenerator() override {}

void initializeEvent(const edm::Event* event, const edm::EventSetup* eventSetup) {

// std::cout << " ---> EcalSignalGenerator() : initializeEvent() " << std::endl;

theEvent = event;
eventSetup->get<EcalGainRatiosRcd>().get(grHandle); // find the gains
// Ecal Intercalibration Constants
Expand All @@ -109,6 +104,10 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator {
eventSetup->get<EcalLaserDbRecord>().get(laser);

// const edm::TimeValue_t eventTimeValue = theEvent->time().value();
//
// FIXME: is this workaround of using "run" really needed or "time" can be used in MC generation as well?
// check with generation experts
//
const edm::TimeValue_t eventTimeValue = theEvent->run();
//---- NB: this is a trick. Since the time dependent MC
// will be based on "run" (and lumisection)
Expand All @@ -122,7 +121,6 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator {


m_lasercals = laser.product();
// std::cout << " ---> EcalSignalGenerator() : initializeEvent() :: eventTimeValue = " << eventTimeValue << std::endl;

//
// the "prime" is exactly the same as the usual laser service, BUT
Expand All @@ -136,9 +134,9 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator {
m_lasercals_prime = laser_prime.product();

//clear the laser cache for each event time
// CalibCache().swap(m_valueLCCache_LC); -> strange way to clear a collection ... why was it like this?
// http://www.cplusplus.com/reference/unordered_map/unordered_map/clear/
// http://www.cplusplus.com/reference/unordered_map/unordered_map/swap/
// CalibCache().swap(m_valueLCCache_LC); -> strange way to clear a collection ... why was it like this?
// http://www.cplusplus.com/reference/unordered_map/unordered_map/clear/
// http://www.cplusplus.com/reference/unordered_map/unordered_map/swap/
m_valueLCCache_LC.clear();
m_valueLCCache_LC_prime.clear(); //--- also the "prime" ... yes
//----
Expand All @@ -164,15 +162,11 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator {
else
ESMIPToGeV = esMipToGeV->getESValueHigh();

// std::cout << " ---> EcalSignalGenerator() : initializeEvent() [end] " << std::endl;

}

/// some users use EventPrincipals, not Events. We support both
void initializeEvent(const edm::EventPrincipal* eventPrincipal, const edm::EventSetup* eventSetup) {

// std::cout << " ---> EcalSignalGenerator() : initializeEvent() [second version]" << std::endl;

theEventPrincipal = eventPrincipal;
eventSetup->get<EcalGainRatiosRcd>().get(grHandle); // find the gains
// Ecal Intercalibration Constants
Expand All @@ -191,6 +185,10 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator {
edm::TimeValue_t eventTimeValue;
if (theEventPrincipal) {
// eventTimeValue = theEventPrincipal->time().value();
//
// FIXME: is this workaround of using "run" really needed or "time" can be used in MC generation as well?
// check with generation experts
//
eventTimeValue = theEventPrincipal->run();
//---- NB: this is a trick. Since the time dependent MC
// will be based on "run" (and lumisection)
Expand Down Expand Up @@ -238,8 +236,6 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator {
else
ESMIPToGeV = esMipToGeV->getESValueHigh();

// std::cout << " ---> EcalSignalGenerator() : initializeEvent() [end] " << std::endl;

}

virtual void fill(edm::ModuleCallingContext const* mcc) {
Expand Down Expand Up @@ -305,13 +301,8 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator {
//---- LC that depends with time
double findLaserConstant_LC(const DetId& detId) const {

// return 1.0;

// const edm::TimeValue_t m_iTime = event.time().value();
const edm::Timestamp& evtTimeStamp = edm::Timestamp(m_iTime);

// std::cout << " findLaserConstant_LC::evtTimeStamp = " << evtTimeStamp << std::endl;

return (m_lasercals->getLaserCorrection(detId, evtTimeStamp));

}
Expand All @@ -321,8 +312,6 @@ class EcalSignalGenerator : public EcalBaseSignalGenerator {
//---- Using the different "tag", the one with "MC": exactly the same function as findLaserConstant_LC but with a different object
double findLaserConstant_LC_prime(const DetId& detId) const {

// return 1.0;

const edm::Timestamp& evtTimeStamp = edm::Timestamp(m_iTime);
return (m_lasercals_prime->getLaserCorrection(detId, evtTimeStamp));

Expand Down
10 changes: 0 additions & 10 deletions SimCalorimetry/EcalSimAlgos/src/EcalSignalGenerator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,17 @@ CaloSamples EcalSignalGenerator<EBDigitizerTraits>::samplesInPE(const DIGI &digi
LSB[igain] = Emax / (MAXADC * gainRatios[igain]);
}

// std::cout << " intercal, LSBs, egains " << icalconst << " " << LSB[0] << " " << LSB[1] << " " << gainRatios[0] << " " << gainRatios[1] << " " << Emax << std::endl;

CaloSamples result(detId, digi.size());

// correction facotr for premixed sample: ratio of laser corrections
float correction_factor_for_premixed_sample_transparency = 1.0;
// correction_factor_for_premixed_sample_transparency
double value_LC = 1.;
if (detId.subdetId() != 3) {
// std::cout << " detId.subdetId() = " << detId.subdetId() << std::endl;
auto cache = m_valueLCCache_LC.find(detId);
if (cache != m_valueLCCache_LC.end()) {
value_LC = cache->second;
} else {
value_LC = findLaserConstant_LC(detId);
// value_LC = 1.0;
m_valueLCCache_LC.emplace(detId, value_LC);
}
}
Expand All @@ -73,7 +68,6 @@ CaloSamples EcalSignalGenerator<EBDigitizerTraits>::samplesInPE(const DIGI &digi
}

correction_factor_for_premixed_sample_transparency = value_LC_prime / value_LC;
// std::cout << " EB correction_factor_for_premixed_sample_transparency[" << detId() << "] = " << correction_factor_for_premixed_sample_transparency << " = " << value_LC_prime << " / " << value_LC << std::endl;
//
// LC' / LC (see formula)
//
Expand Down Expand Up @@ -142,13 +136,10 @@ CaloSamples EcalSignalGenerator<EEDigitizerTraits>::samplesInPE(const DIGI &digi
LSB[igain] = Emax / (MAXADC * gainRatios[igain]);
}

// std::cout << " intercal, LSBs, egains " << icalconst << " " << LSB[0] << " " << LSB[1] << " " << gainRatios[0] << " " << gainRatios[1] << " " << Emax << std::endl;

CaloSamples result(detId, digi.size());

// correction facotr for premixed sample: ratio of laser corrections
float correction_factor_for_premixed_sample_transparency = 1.0;
// correction_factor_for_premixed_sample_transparency
double value_LC = 1.;
if (detId.subdetId() != 3) {
auto cache = m_valueLCCache_LC.find(detId);
Expand All @@ -172,7 +163,6 @@ CaloSamples EcalSignalGenerator<EEDigitizerTraits>::samplesInPE(const DIGI &digi
}

correction_factor_for_premixed_sample_transparency = value_LC_prime / value_LC;
// std::cout << " EE correction_factor_for_premixed_sample_transparency[" << detId() << "] = " << correction_factor_for_premixed_sample_transparency << " = " << value_LC_prime << " / " << value_LC << std::endl;
//
// LC' / LC (see formula)
//
Expand Down

0 comments on commit 12b3237

Please sign in to comment.