35 #include <boost/foreach.hpp>
42 namespace HcalDigitizerImpl {
44 template<
typename SIPMDIGITIZER>
45 void fillSiPMCells(std::vector<int> & siPMCells, SIPMDIGITIZER * siPMDigitizer)
47 std::vector<DetId> siPMDetIds;
48 siPMDetIds.reserve(siPMCells.size());
49 for(std::vector<int>::const_iterator idItr = siPMCells.begin();
50 idItr != siPMCells.end(); ++idItr)
52 siPMDetIds.emplace_back(*idItr);
54 siPMDigitizer->setDetIds(siPMDetIds);
59 template<
typename HPDDIGITIZER,
typename SIPMDIGITIZER>
61 HPDDIGITIZER * hpdDigitizer,
62 SIPMDIGITIZER * siPMDigitizer)
65 if(siPMDigitizer && hpdDigitizer)
67 std::vector<DetId> siPMDetIds = siPMDigitizer->detIds();
68 std::sort(siPMDetIds.begin(), siPMDetIds.end());
69 std::vector<DetId> sortedCells = allCells;
70 std::sort(sortedCells.begin(), sortedCells.end());
71 std::vector<DetId> hpdCells;
72 std::set_difference(sortedCells.begin(), sortedCells.end(),
73 siPMDetIds.begin(), siPMDetIds.end(),
74 std::back_inserter(hpdCells) );
75 hpdDigitizer->setDetIds(hpdCells);
79 if(siPMDigitizer) siPMDigitizer->setDetIds(allCells);
80 if(hpdDigitizer) hpdDigitizer->setDetIds(allCells);
92 theHBHESiPMResponse(0),
103 theUpgradeCoderFactory(0),
104 theHBHEElectronicsSim(0),
105 theHFElectronicsSim(0),
106 theHOElectronicsSim(0),
107 theZDCElectronicsSim(0),
108 theUpgradeHBHEElectronicsSim(0),
109 theUpgradeHFElectronicsSim(0),
111 theHFHitFilter(ps.getParameter<bool>(
"doHFWindow")),
116 theNoiseGenerator(0),
117 theNoiseHitGenerator(0),
119 theHBHESiPMDigitizer(0),
121 theHOSiPMDigitizer(0),
124 theHBHEUpgradeDigitizer(0),
125 theHFUpgradeDigitizer(0),
133 hitsProducer_(ps.getParameter<std::
string>(
"hitsProducer")),
134 theHOSiPMCode(ps.getParameter<edm::
ParameterSet>(
"ho").getParameter<int>(
"siPMCode")),
143 bool PreMix1 = ps.
getParameter<
bool>(
"HcalPreMixStage1");
144 bool PreMix2 = ps.
getParameter<
bool>(
"HcalPreMixStage2");
150 double HBtp = ps.
getParameter<
double>(
"HBTuningParameter");
151 double HEtp = ps.
getParameter<
double>(
"HETuningParameter");
152 double HFtp = ps.
getParameter<
double>(
"HFTuningParameter");
153 double HOtp = ps.
getParameter<
double>(
"HOTuningParameter");
154 bool doHBHEUpgrade = ps.
getParameter<
bool>(
"HBHEUpgradeQIE");
155 bool doHFUpgrade = ps.
getParameter<
bool>(
"HFUpgradeQIE");
157 bool agingFlagHE = ps.
getParameter<
bool>(
"HEDarkening");
158 bool agingFlagHF = ps.
getParameter<
bool>(
"HFDarkening");
159 double minFCToDelay= ps.
getParameter<
double>(
"minFCToDelay");
161 if(PreMix1 && PreMix2) {
163 <<
"HcalDigitizer cannot operate in PreMixing digitization and PreMixing\n"
164 "digi combination modes at the same time. Please set one mode to False\n"
165 "in the configuration file.";
203 bool doHBHEHPD = hbSiPMCells.empty() || (hbSiPMCells[0] != 1);
205 bool doHBHESiPM = !hbSiPMCells.empty();
209 edm::LogInfo(
"HcalDigitizer") <<
"Set scale for HB towers";
214 bool changeResponse = ps.
getParameter<
bool>(
"ChangeResponse");
216 if (changeResponse) {
218 edm::LogInfo(
"HcalDigitizer") <<
"Set scale for HB towers from " << corrFileName;
247 if(doHBHEHPD && doHBHESiPM) {
406 if (eventSetup.
find(edm::eventsetup::EventSetupRecordKey::makeKey<HcalCholeskyMatricesRcd>())) {
441 std::vector<PCaloHit> hcalHitsOrig = *hcalHandle.product();
442 std::vector<PCaloHit> hcalHits;
443 hcalHits.reserve(hcalHitsOrig.size());
456 for (
unsigned int i=0;
i< hcalHitsOrig.size();
i++) {
457 DetId id(hcalHitsOrig[
i].
id());
460 edm::LogError(
"HcalDigitizer") <<
"bad hcal id found in digitizer. Skipping " <<
id.rawId() << std::endl;
463 std::cout <<
"HcalDigitizer format " << hid.
oldFormat() <<
" for " << hid << std::endl;
469 hcalHitsOrig[
i].setID(newid.
rawId());
470 hcalHits.push_back(hcalHitsOrig[
i]);
495 edm::LogInfo(
"HcalDigitizer") <<
"We don't have HCAL hit collection available ";
503 edm::LogInfo(
"HcalDigitizer") <<
"We don't have ZDC hit collection available ";
562 std::cout <<
"HcalDigitizer::finalizeEvent theHBHEUpgradeDigitizer->run" << std::endl;
578 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HBHE digis : " << hbheResult->size();
579 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HO digis : " << hoResult->size();
580 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HF digis : " << hfResult->size();
581 edm::LogInfo(
"HcalDigitizer") <<
"HCAL ZDC digis : " << zdcResult->size();
582 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HBHE upgrade digis : " << hbheupgradeResult->size();
583 edm::LogInfo(
"HcalDigitizer") <<
"HCAL HF upgrade digis : " << hfupgradeResult->size();
587 std::cout <<
"HCAL HBHE digis : " << hbheResult->size() << std::endl;
588 std::cout <<
"HCAL HO digis : " << hoResult->size() << std::endl;
589 std::cout <<
"HCAL HF digis : " << hfResult->size() << std::endl;
591 std::cout <<
"HCAL HBHE upgrade digis : " << hbheupgradeResult->size()
593 std::cout <<
"HCAL HF upgrade digis : " << hfupgradeResult->size()
602 e.
put(hbheupgradeResult,
"HBHEUpgradeDigiCollection");
603 e.
put(hfupgradeResult,
"HFUpgradeDigiCollection");
605 std::cout << std::endl <<
"========> HcalDigitizer e.put " << std::endl << std::endl;
657 if(zdcCells.empty())
zdcgeo =
false;
658 if(hbCells.empty() && heCells.empty())
hbhegeo =
false;
659 if(hoCells.empty())
hogeo =
false;
660 if(hfCells.empty())
hfgeo =
false;
675 std::cout <<
" HcalDigitizer::updateGeometry theHBHEUpgradeDigitizer->setDetIds(theHBHEDetIds)"<< std::endl;
691 std::vector<HcalDetId> zecotekDetIds, hamamatsuDetIds;
698 if (mcParams.topo()==0) {
702 for(std::vector<DetId>::const_iterator detItr = allCells.begin();
703 detItr != allCells.end(); ++detItr) {
704 int shapeType = mcParams.getValues(*detItr)->signalShape();
706 zecotekDetIds.emplace_back(*detItr);
709 hamamatsuDetIds.emplace_back(*detItr);
732 for (
unsigned int ii=0;
ii<hcalHits.size(); ++
ii) {
733 uint32_t tmpId = hcalHits[
ii].id();
737 bool darkened =
false;
754 if(darkened) hcalHits[
ii].setEnergy(hcalHits[
ii].
energy()*dweight);
void setUseOldHB(bool useOld)
void setNoiseHitGenerator(CaloVNoiseHitGenerator *generator)
int bunchCrossing() const
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
void setHOtuningParameter(double tp)
T getParameter(std::string const &) const
void setGeometry(const CaloGeometry *geometry)
geometry needed for time-of-flight
void setDbService(const HcalDbService *service)
the Producer will probably update this every event
T getUntrackedParameter(std::string const &, T const &) const
HBHEHitFilter theHBHEHitFilter
void setGeometry(const CaloGeometry *&, const HcalDDDRecConstants *&)
const HcalDDDRecConstants * theRecNumber
void setParameterMap(HcalSimParameterMap *map)
void setDetIds(const std::vector< DetId > &detIds)
HcalElectronicsSim * theHFElectronicsSim
HBHEDigitizer * theHBHEDigitizer
HOHitFilter theHOHitFilter
CaloTDigitizer< HcalUpgradeDigitizerTraits > UpgradeDigitizer
void setUseOldHF(bool useOld)
void darkening(std::vector< PCaloHit > &hcalHits)
void add(const std::vector< PCaloHit > &hits, int bunchCrossing, CLHEP::HepRandomEngine *engine)
HFDigitizer * theHFDigitizer
HFHitFilter theHFHitFilter
void checkGeometry(const edm::EventSetup &eventSetup)
HcalSimParameterMap * theParameterMap
void setHFtuningParameter(double tp)
bool validHcal(const HcalDetId &id) const
void setPECorrection(const CaloVPECorrection *peCorrection)
if you want to correct the photoelectrons
HcalTimeSlewSim * theTimeSlewSim
void setADCPeds(const HcalPedestals *ADCPeds)
HcalAmplifier * theHFAmplifier
HcalElectronicsSim * theUpgradeHFElectronicsSim
void fillSiPMCells(std::vector< int > &siPMCells, SIPMDIGITIZER *siPMDigitizer)
HcalCoderFactory * theCoderFactory
HcalHitRelabeller * theRelabeller
edm::SortedCollection< ZDCDataFrame > ZDCDigiCollection
HcalCoderFactory * theUpgradeCoderFactory
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
void initializeEvent(edm::Event const &e, edm::EventSetup const &c)
void setDbService(const HcalDbService *service)
void setIonFeedbackSim(HPDIonFeedbackSim *feedbackSim)
uint32_t rawId() const
get the raw id
UpgradeDigitizer * theHFUpgradeDigitizer
void accumulate(edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *)
CaloTDigitizer< HFDigitizerTraits > HFDigitizer
void setHOZecotekDetIds(const std::vector< HcalDetId > &ids)
HcalAmplifier * theHBHEAmplifier
void setUseOldHO(bool useOld)
edm::SortedCollection< HODataFrame > HODigiCollection
CaloTDigitizer< ZDCDigitizerTraits > ZDCDigitizer
std::string hitsProducer_
HcalElectronicsSim * theHOElectronicsSim
void setHEtuningParameter(double tp)
void setUseOldHE(bool useOld)
void setElectronicsSim(HcalElectronicsSim *electronicsSim)
void setHitFilter(const CaloVHitFilter *filter)
if you want to reject hits, for example, from a certain subdetector, set this
double getCorr(int ieta, int idepth, double lumi)
Creates electronics signals from hits.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void setHFNoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
std::vector< DetId > theHBHEDetIds
void buildHOSiPMCells(const std::vector< DetId > &allCells, const edm::EventSetup &eventSetup)
ZDCHitFilter theZDCHitFilter
HPDIonFeedbackSim * theIonFeedback
void fillChargeSums(MixCollection< PCaloHit > &hits)
CaloHitResponse * theHOResponse
HcalHitFilter theHOSiPMHitFilter
CaloHitResponse * theHOSiPMResponse
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
void setHBHEScale(std::string &)
void setNoiseSignalGenerator(CaloVNoiseSignalGenerator *generator)
ZDCDigitizer * theZDCDigitizer
edm::SortedCollection< HcalUpgradeDataFrame > HFUpgradeDigiCollection
std::vector< DetId > theHOHPDDetIds
edm::SortedCollection< HcalUpgradeDataFrame > HBHEUpgradeDigiCollection
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
HcalHitCorrection * theHitCorrection
CaloHitResponse * theZDCResponse
void setNoiseSignalGenerator(const CaloVNoiseSignalGenerator *noiseSignalGenerator)
HcalElectronicsSim * theZDCElectronicsSim
HcalElectronicsSim * theUpgradeHBHEElectronicsSim
void run(MixCollection< PCaloHit > &, DigiCollection &)
turns hits into digis
static const int SubdetectorId
void beginRun(const edm::EventSetup &es)
void process(std::vector< PCaloHit > &hcalHits)
CaloTDigitizer< HODigitizerTraits > HODigitizer
void setTimeSlewSim(HcalTimeSlewSim *timeSlewSim)
void setHOHamamatsuDetIds(const std::vector< HcalDetId > &ids)
void accumulateCaloHits(edm::Handle< std::vector< PCaloHit > > const &hcalHits, edm::Handle< std::vector< PCaloHit > > const &zdcHits, int bunchCrossing, CLHEP::HepRandomEngine *, const HcalTopology *h)
HcalAmplifier * theHOAmplifier
void setDbService(const HcalDbService *service)
HFRecalibration * m_HFRecalibration
HcalElectronicsSim * theHBHEElectronicsSim
T const * product() const
void fillCells(std::vector< DetId > &allCells, HPDDIGITIZER *hpdDigitizer, SIPMDIGITIZER *siPMDigitizer)
CaloHitResponse * theHBHEResponse
HODigitizer * theHODigitizer
std::vector< DetId > theHOSiPMDetIds
const CaloGeometry * theGeometry
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
void setCholesky(const HcalCholeskyMatrices *Cholesky)
ESHandle< TrackerGeometry > geometry
CaloHitResponse * theHFResponse
HODigitizer * theHOSiPMDigitizer
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
void setZDCNoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
HBHEDigitizer * theHBHESiPMDigitizer
HEDarkening * m_HEDarkening
edm::SortedCollection< HFDataFrame > HFDigiCollection
void setDetIds(const std::vector< DetId > &detIds)
void beginRun(edm::EventSetup const &es)
CaloHitResponse * theHBHESiPMResponse
void setHBtuningParameter(double tp)
void updateGeometry(const edm::EventSetup &eventSetup)
float degradation(float intlumi, int ieta, int lay)
void setHBHENoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
CaloVNoiseHitGenerator * theNoiseHitGenerator
HcalAmplifier * theZDCAmplifier
void setTopo(const HcalTopology *topo)
void setDbService(const HcalDbService *service)
edm::SortedCollection< HBHEDataFrame > HBHEDigiCollection
void finalizeEvent(edm::Event &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *)
UpgradeDigitizer * theHBHEUpgradeDigitizer
void setHONoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator)
CaloTDigitizer< HBHEDigitizerTraits > HBHEDigitizer
HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector &iC)
CaloVNoiseSignalGenerator * theNoiseGenerator