diff --git a/CalibFormats/CaloObjects/src/CaloTSamples_Ph2.cc b/CalibFormats/CaloObjects/src/CaloTSamples_Ph2.cc new file mode 100644 index 0000000000000..0479197cc8de5 --- /dev/null +++ b/CalibFormats/CaloObjects/src/CaloTSamples_Ph2.cc @@ -0,0 +1,8 @@ +#include "CalibFormats/CaloObjects/interface/CaloTSamplesBase.icc" +#include "CalibFormats/CaloObjects/interface/CaloTSamples.icc" +#include "CondFormats/EcalObjects/interface/EcalConstants.h" + +template class CaloTSamplesBase; + +template class CaloTSamples; +template class CaloTSamples; diff --git a/CondFormats/DataRecord/interface/EcalCATIAGainRatiosRcd.h b/CondFormats/DataRecord/interface/EcalCATIAGainRatiosRcd.h new file mode 100644 index 0000000000000..a05b14aa67d07 --- /dev/null +++ b/CondFormats/DataRecord/interface/EcalCATIAGainRatiosRcd.h @@ -0,0 +1,6 @@ +#ifndef CondFormats_DataRecord_EcalCATIAGainRatiosRcd_H +#define CondFormats_DataRecord_EcalCATIAGainRatiosRcd_H + +#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" +class EcalCATIAGainRatiosRcd : public edm::eventsetup::EventSetupRecordImplementation {}; +#endif diff --git a/CondFormats/DataRecord/interface/EcalLiteDTUPedestalsRcd.h b/CondFormats/DataRecord/interface/EcalLiteDTUPedestalsRcd.h new file mode 100644 index 0000000000000..44cd477b836ef --- /dev/null +++ b/CondFormats/DataRecord/interface/EcalLiteDTUPedestalsRcd.h @@ -0,0 +1,6 @@ +#ifndef CondFormats_DataRecord_EcalLiteDTUPedestalsRcd_h +#define CondFormats_DataRecord_EcalLiteDTUPedestalsRcd_h + +#include "FWCore/Framework/interface/EventSetupRecordImplementation.h" +class EcalLiteDTUPedestalsRcd : public edm::eventsetup::EventSetupRecordImplementation {}; +#endif diff --git a/CondFormats/DataRecord/src/EcalCATIAGainRatiosRcd.cc b/CondFormats/DataRecord/src/EcalCATIAGainRatiosRcd.cc new file mode 100644 index 0000000000000..d59977b155288 --- /dev/null +++ b/CondFormats/DataRecord/src/EcalCATIAGainRatiosRcd.cc @@ -0,0 +1,4 @@ +#include "CondFormats/DataRecord/interface/EcalCATIAGainRatiosRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(EcalCATIAGainRatiosRcd); diff --git a/CondFormats/DataRecord/src/EcalLiteDTUPedestalsRcd.cc b/CondFormats/DataRecord/src/EcalLiteDTUPedestalsRcd.cc new file mode 100644 index 0000000000000..ca644efc17fa3 --- /dev/null +++ b/CondFormats/DataRecord/src/EcalLiteDTUPedestalsRcd.cc @@ -0,0 +1,4 @@ +#include "CondFormats/DataRecord/interface/EcalLiteDTUPedestalsRcd.h" +#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h" + +EVENTSETUP_RECORD_REG(EcalLiteDTUPedestalsRcd); diff --git a/CondFormats/EcalObjects/interface/EcalCATIAGainRatios.h b/CondFormats/EcalObjects/interface/EcalCATIAGainRatios.h new file mode 100644 index 0000000000000..56ba116355817 --- /dev/null +++ b/CondFormats/EcalObjects/interface/EcalCATIAGainRatios.h @@ -0,0 +1,10 @@ +#ifndef CondFormats_EcalObjects_EcalCATIAGainRatios_h +#define CondFormats_EcalObjects_EcalCATIAGainRatios_h + +#include "CondFormats/EcalObjects/interface/EcalCondObjectContainer.h" + +typedef float EcalCATIAGainRatio; +typedef EcalFloatCondObjectContainer EcalCATIAGainRatioMap; +typedef EcalCATIAGainRatioMap EcalCATIAGainRatios; + +#endif diff --git a/CondFormats/EcalObjects/interface/EcalConstants.h b/CondFormats/EcalObjects/interface/EcalConstants.h new file mode 100644 index 0000000000000..b5bc70d985e25 --- /dev/null +++ b/CondFormats/EcalObjects/interface/EcalConstants.h @@ -0,0 +1,31 @@ +//Namespaces for Phase1 and Phase2 +#ifndef CondFormats_EcalObject_EcalConstants_h +#define CondFormats_EcalObject_EcalConstants_h + +class ecalPh2 { +public: + static constexpr double Samp_Period = 6.25; + static constexpr unsigned int NGAINS = 2; + static constexpr float gains[2] = {10., 1.}; + static constexpr unsigned int gainId1 = 1; + static constexpr unsigned int gainId10 = 0; + static constexpr unsigned int sampleSize = 16; + static constexpr unsigned int NBITS = 12; // number of available bits + static constexpr unsigned int MAXADC = (1 << NBITS) - 1; // 2^12 -1, adc max range + static constexpr unsigned int kEBChannels = 61200; + static constexpr double maxEneEB = 2000.; + static constexpr unsigned int kNOffsets = 2000; + static constexpr unsigned int kAdcMask = 0xFFF; + static constexpr unsigned int kGainIdMask = 0x3; + +}; // namespace ecalPh2 + +class ecalPh1 { +public: + static constexpr double Samp_Period = 25.; + static constexpr unsigned int NGAINS = 4; + static constexpr float gains[4] = {0., 12., 6., 1.}; + static constexpr unsigned int sampleSize = 10; + static constexpr unsigned int kNOffsets = 2000; +}; // namespace ecalPh1 +#endif diff --git a/CondFormats/EcalObjects/interface/EcalLiteDTUPedestals.h b/CondFormats/EcalObjects/interface/EcalLiteDTUPedestals.h new file mode 100644 index 0000000000000..599ce3eaa29c8 --- /dev/null +++ b/CondFormats/EcalObjects/interface/EcalLiteDTUPedestals.h @@ -0,0 +1,39 @@ +#ifndef CondFormats_EcalObject_EcalLiteDTUPedestals_h +#define CondFormats_EcalObject_EcalLiteDTUPedestals_h + +#include "CondFormats/Serialization/interface/Serializable.h" +#include "CondFormats/EcalObjects/interface/EcalCondObjectContainer.h" +#include "CondFormats/EcalObjects/interface/EcalConstants.h" + +class EcalLiteDTUPedestals { +public: + float meanarray[2] = {13., 8.}; + float rmsarray[2] = {2.8, 1.2}; + + int setMean(unsigned int i, float value) { + if (i >= ecalPh2::NGAINS) + return -1; + else + meanarray[i] = value; + return 1; + } + + int setRMS(unsigned int i, float value) { + if (i >= ecalPh2::NGAINS) + return -1; + else + rmsarray[i] = value; + return 1; + } + + float mean(unsigned int i) const { return meanarray[i]; } + + float rms(unsigned int i) const { return rmsarray[i]; } + + COND_SERIALIZABLE; +}; + +typedef EcalCondObjectContainer EcalLiteDTUPedestalsMap; +typedef EcalLiteDTUPedestalsMap::const_iterator EcalLiteDTUPedestalsMapIterator; + +#endif diff --git a/CondFormats/EcalObjects/src/SerializationManual.h b/CondFormats/EcalObjects/src/SerializationManual.h index 5efd2ebcc7440..2f6158477b05d 100644 --- a/CondFormats/EcalObjects/src/SerializationManual.h +++ b/CondFormats/EcalObjects/src/SerializationManual.h @@ -4,6 +4,7 @@ COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer); COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer); COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer); +COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer); COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer); COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer); COND_SERIALIZATION_INSTANTIATE(EcalCondObjectContainer); diff --git a/CondFormats/EcalObjects/src/T_EventSetup_EcalLiteDTUPedestals.cc b/CondFormats/EcalObjects/src/T_EventSetup_EcalLiteDTUPedestals.cc new file mode 100644 index 0000000000000..75bcfb76d8b96 --- /dev/null +++ b/CondFormats/EcalObjects/src/T_EventSetup_EcalLiteDTUPedestals.cc @@ -0,0 +1,4 @@ +#include "CondFormats/EcalObjects/interface/EcalLiteDTUPedestals.h" +#include "FWCore/Utilities/interface/typelookup.h" + +TYPELOOKUP_DATA_REG(EcalLiteDTUPedestalsMap); diff --git a/CondFormats/EcalObjects/src/classes.h b/CondFormats/EcalObjects/src/classes.h index 265320eb1ddea..2c40d0319ff6b 100644 --- a/CondFormats/EcalObjects/src/classes.h +++ b/CondFormats/EcalObjects/src/classes.h @@ -1,4 +1,4 @@ - +#include #include "CondFormats/EcalObjects/interface/EcalCondObjectContainer.h" #include "CondFormats/EcalObjects/interface/EcalCondTowerObjectContainer.h" #include "CondFormats/EcalObjects/interface/EcalPedestals.h" @@ -64,7 +64,9 @@ #include "CondFormats/EcalObjects/interface/EcalTPGSpike.h" #include "CondFormats/EcalObjects/interface/EcalSRSettings.h" #include "CondFormats/EcalObjects/interface/EcalSimPulseShape.h" -#include +//ECAL PH2: +#include "CondFormats/EcalObjects/interface/EcalLiteDTUPedestals.h" +#include "CondFormats/EcalObjects/interface/EcalCATIAGainRatios.h" namespace CondFormats_EcalObjects { struct dictionary { @@ -93,6 +95,11 @@ namespace CondFormats_EcalObjects { EcalContainer ec_ebDetId_ecalPedestal; EcalCondObjectContainer pedmap; //typedef EcalPedestals + //ECAL PH2: + std::vector v_ecalDTUPedestals; + EcalContainer ec_ebDetId_ecalLiteDTUPedestals; + EcalCondObjectContainer pedmapDTU; //typedef EcalPedestals + std::vector v_ecalTPGCrystalStatusCode; EcalContainer ec_eeDetId_ecalTPGCrystalStatusCode; EcalContainer ec_ebDetId_ecalTPGCrystalStatusCode; diff --git a/CondFormats/EcalObjects/src/classes_def.xml b/CondFormats/EcalObjects/src/classes_def.xml index 67d8101caa54e..c5cc8af4e828b 100644 --- a/CondFormats/EcalObjects/src/classes_def.xml +++ b/CondFormats/EcalObjects/src/classes_def.xml @@ -82,6 +82,14 @@ + + + + + + + + diff --git a/CondFormats/EcalObjects/xml/EcalLiteDTUPedestals_default.xml b/CondFormats/EcalObjects/xml/EcalLiteDTUPedestals_default.xml new file mode 100644 index 0000000000000..89bdb3db85e34 --- /dev/null +++ b/CondFormats/EcalObjects/xml/EcalLiteDTUPedestals_default.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/Configuration/StandardSequences/python/Digi_Ph2_cff.py b/Configuration/StandardSequences/python/Digi_Ph2_cff.py new file mode 100644 index 0000000000000..eb29b87bdb441 --- /dev/null +++ b/Configuration/StandardSequences/python/Digi_Ph2_cff.py @@ -0,0 +1,71 @@ +import FWCore.ParameterSet.Config as cms + +# +# Full-scale Digitization of the simulated hits +# in all CMS subdets : Tracker, ECAL, HCAl, Muon's; +# MixingModule (at least in zero-pileup mode) needs +# to be included to make Digi's operational, since +# it's required for ECAL/HCAL & Muon's +# Defined in a separate fragment +# +# Tracker Digis (Pixel + SiStrips) are now made in the mixing +# module, so the old "trDigi" sequence has been taken out. +# + +# Calorimetry Digis (Ecal + Hcal) - * unsuppressed * +# returns sequence "calDigi" + +from SimCalorimetry.Configuration.SimCalorimetry_Ph2_cff import * +# Muon Digis (CSC + DT + RPC) +# returns sequence "muonDigi" +# +from SimMuon.Configuration.SimMuon_cff import * +# +# TrackingParticle Producer is now part of the mixing module, so +# it is no longer run here. +# +from SimGeneral.Configuration.SimGeneral_cff import * + +# add updating the GEN information by default +from Configuration.StandardSequences.Generator_cff import * +from GeneratorInterface.Core.generatorSmeared_cfi import * +from SimGeneral.PileupInformation.genPUProtons_cfi import * + +doAllDigiTask = cms.Task(generatorSmeared, calDigiTask, muonDigiTask) +pdigiTask_nogen = cms.Task(generatorSmeared, cms.TaskPlaceholder("randomEngineStateProducer"), cms.TaskPlaceholder("mix"), doAllDigiTask, addPileupInfo, genPUProtons) +pdigiTask = cms.Task(pdigiTask_nogen, fixGenInfoTask) + +doAllDigi = cms.Sequence(doAllDigiTask) +pdigi = cms.Sequence(pdigiTask) +pdigi_valid = cms.Sequence(pdigiTask) +pdigi_nogen=cms.Sequence(pdigiTask_nogen) +pdigi_valid_nogen=cms.Sequence(pdigiTask_nogen) + +from GeneratorInterface.HiGenCommon.HeavyIon_cff import * +pdigiTask_hi = cms.Task(pdigiTask, heavyIon) +pdigiTask_hi_nogen = cms.Task(pdigiTask_nogen, genJetMETTask, heavyIon) +pdigi_hi=cms.Sequence(pdigiTask_hi) +pdigi_hi_nogen=cms.Sequence(pdigiTask_hi_nogen) + +from Configuration.Eras.Modifier_fastSim_cff import fastSim +def _fastSimDigis(process): + import FastSimulation.Configuration.DigiAliases_cff as DigiAliases + + # pretend these digis have been through digi2raw and raw2digi, by using the approprate aliases + # use an alias to make the mixed track collection available under the usual label + from FastSimulation.Configuration.DigiAliases_cff import loadDigiAliases + loadDigiAliases(process) +# no need for the aliases for premixing stage1 +modifyDigi_fastSimDigis = (fastSim & ~premix_stage1).makeProcessModifier(_fastSimDigis) + +#phase 2 common mods +def _modifyEnableHcalHardcode( theProcess ): + from CalibCalorimetry.HcalPlugins.Hcal_Conditions_forGlobalTag_cff import hcal_db_producer as _hcal_db_producer, es_hardcode as _es_hardcode, es_prefer_hcalHardcode as _es_prefer_hcalHardcode + theProcess.hcal_db_producer = _hcal_db_producer + theProcess.es_hardcode = _es_hardcode + theProcess.es_prefer_hcalHardcode = _es_prefer_hcalHardcode + +from Configuration.Eras.Modifier_hcalHardcodeConditions_cff import hcalHardcodeConditions +modifyEnableHcalHardcode_ = hcalHardcodeConditions.makeProcessModifier( _modifyEnableHcalHardcode ) + + diff --git a/DataFormats/EcalDigi/interface/EBDataFrame.h b/DataFormats/EcalDigi/interface/EBDataFrame.h index cb6ded7d25a82..89c6e97da5419 100644 --- a/DataFormats/EcalDigi/interface/EBDataFrame.h +++ b/DataFormats/EcalDigi/interface/EBDataFrame.h @@ -3,6 +3,7 @@ #include "DataFormats/EcalDetId/interface/EBDetId.h" #include "DataFormats/EcalDigi/interface/EcalDataFrame.h" +#include "DataFormats/EcalDigi/interface/EcalDataFrame_Ph2.h" #include /** \class EBDataFrame diff --git a/DataFormats/EcalDigi/interface/EcalDataFrame_Ph2.h b/DataFormats/EcalDigi/interface/EcalDataFrame_Ph2.h new file mode 100644 index 0000000000000..0420f97c28a1e --- /dev/null +++ b/DataFormats/EcalDigi/interface/EcalDataFrame_Ph2.h @@ -0,0 +1,38 @@ +#ifndef DataFormats_EcalDigi_EcalDataFrame_Ph2_h +#define DataFormats_EcalDigi_EcalDataFrame_Ph2_h +#include "DataFormats/EcalDigi/interface/EcalLiteDTUSample.h" +#include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/Common/interface/DataFrame.h" +#include "CondFormats/EcalObjects/interface/EcalConstants.h" + +/** \class EcalDataFrame_Ph2 + +*/ +class EcalDataFrame_Ph2 { +public: + EcalDataFrame_Ph2() {} + EcalDataFrame_Ph2(edm::DataFrame const& iframe) : m_data(iframe) {} + + virtual ~EcalDataFrame_Ph2() {} + + DetId id() const { return m_data.id(); } + + int size() const { return m_data.size(); } + + EcalLiteDTUSample operator[](int i) const { return m_data[i]; } + EcalLiteDTUSample sample(int i) const { return m_data[i]; } + + // FIXME (shall we throw??) + void setSize(int) {} + void setSample(int i, EcalLiteDTUSample sam) { m_data[i] = sam; } + + int MAXSAMPLES = ecalPh2::sampleSize; + + edm::DataFrame const& frame() const { return m_data; } + edm::DataFrame& frame() { return m_data; } + +private: + edm::DataFrame m_data; +}; + +#endif diff --git a/DataFormats/EcalDigi/interface/EcalDigiCollections.h b/DataFormats/EcalDigi/interface/EcalDigiCollections.h index 3a117d2cc908a..49b7042bde065 100644 --- a/DataFormats/EcalDigi/interface/EcalDigiCollections.h +++ b/DataFormats/EcalDigi/interface/EcalDigiCollections.h @@ -18,6 +18,29 @@ #include "DataFormats/DetId/interface/DetId.h" #include "DataFormats/EcalDetId/interface/EcalSubdetector.h" #include "DataFormats/Common/interface/DataFrameContainer.h" +#include "CondFormats/EcalObjects/interface/EcalConstants.h" + +class EcalDigiCollectionPh2 : public edm::DataFrameContainer { +public: + typedef edm::DataFrameContainer::size_type size_type; + static const size_type MAXSAMPLES = ecalPh2::sampleSize; + explicit EcalDigiCollectionPh2(size_type istride = MAXSAMPLES, int isubdet = 0) + : edm::DataFrameContainer(istride, isubdet) {} + void swap(DataFrameContainer& other) { this->DataFrameContainer::swap(other); } +}; + +class EBDigiCollectionPh2 : public EcalDigiCollectionPh2 { +public: + typedef edm::DataFrameContainer::size_type size_type; + typedef EBDataFrame Digi; + typedef Digi::key_type DetId; + + EBDigiCollectionPh2(size_type istride = MAXSAMPLES) : EcalDigiCollectionPh2(istride, EcalBarrel) {} + void swap(EBDigiCollectionPh2& other) { this->EcalDigiCollectionPh2::swap(other); } + void push_back(const Digi& digi) { DataFrameContainer::push_back(digi.id(), digi.frame().begin()); } + void push_back(id_type iid) { DataFrameContainer::push_back(iid); } + void push_back(id_type iid, data_type const* idata) { DataFrameContainer::push_back(iid, idata); } +}; class EcalDigiCollection : public edm::DataFrameContainer { public: @@ -89,6 +112,10 @@ inline void swap(EEDigiCollection& lhs, EEDigiCollection& rhs) { lhs.swap(rhs); inline void swap(ESDigiCollection& lhs, ESDigiCollection& rhs) { lhs.swap(rhs); } +inline void swap(EcalDigiCollectionPh2& lhs, EcalDigiCollectionPh2& rhs) { lhs.swap(rhs); } + +inline void swap(EBDigiCollectionPh2& lhs, EBDigiCollectionPh2& rhs) { lhs.swap(rhs); } + typedef edm::SortedCollection EcalTimeDigiCollection; typedef edm::SortedCollection EcalTrigPrimDigiCollection; typedef edm::SortedCollection EcalEBTrigPrimDigiCollection; diff --git a/DataFormats/EcalDigi/interface/EcalLiteDTUSample.h b/DataFormats/EcalDigi/interface/EcalLiteDTUSample.h new file mode 100644 index 0000000000000..e359e3438d963 --- /dev/null +++ b/DataFormats/EcalDigi/interface/EcalLiteDTUSample.h @@ -0,0 +1,47 @@ +#ifndef DataFormats_EcalDigi_EcalLiteDTUSample_h +#define DataFormats_EcalDigi_EcalLiteDTUSample_h + +#include +#include +#include "CondFormats/EcalObjects/interface/EcalConstants.h" + +namespace ecalLiteDTU { + typedef uint16_t sample_type; + + /// get the ADC sample (12 bits) + constexpr int adc(sample_type sample) { return sample & ecalPh2::kAdcMask; } + /// get the gainId (2 bits) + constexpr int gainId(sample_type sample) { return (sample >> ecalPh2::NBITS) & ecalPh2::kGainIdMask; } + constexpr sample_type pack(int adc, int gainId) { + return (adc & ecalPh2::kAdcMask) | ((gainId & ecalPh2::kGainIdMask) << ecalPh2::NBITS); + } +} // namespace ecalLiteDTU + +/** \class EcalLiteDTUSample + * Simple container packer/unpacker for a single sample from the Lite_CATIA electronics + * + * + */ +class EcalLiteDTUSample { +public: + EcalLiteDTUSample() { theSample = 0; } + EcalLiteDTUSample(uint16_t data) { theSample = data; } + EcalLiteDTUSample(int adc, int gainId); + + /// get the raw word + uint16_t raw() const { return theSample; } + /// get the ADC sample (12 bits) + int adc() const { return theSample & ecalPh2::kAdcMask; } + /// get the gainId (2 bits) + int gainId() const { return (theSample >> ecalPh2::NBITS) & ecalPh2::kGainIdMask; } + /// for streaming + uint16_t operator()() const { return theSample; } + operator uint16_t() const { return theSample; } + +private: + uint16_t theSample; +}; + +std::ostream& operator<<(std::ostream&, const EcalLiteDTUSample&); + +#endif diff --git a/DataFormats/EcalDigi/src/EBDataFrame.cc b/DataFormats/EcalDigi/src/EBDataFrame.cc index c31e9f251a4d6..bee47b39472f2 100644 --- a/DataFormats/EcalDigi/src/EBDataFrame.cc +++ b/DataFormats/EcalDigi/src/EBDataFrame.cc @@ -1,7 +1,7 @@ #include "DataFormats/EcalDigi/interface/EBDataFrame.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include - +//#warning[DataFormats/EcalDigi/src/EBDataFrame.cc] spike estimator contains a suspicious 10 float EBDataFrame::spikeEstimator() const { if (size() != 10) { edm::LogError("InvalidNumberOfSamples") diff --git a/DataFormats/EcalDigi/src/EcalLiteDTUSample.cc b/DataFormats/EcalDigi/src/EcalLiteDTUSample.cc new file mode 100644 index 0000000000000..bb036f3472054 --- /dev/null +++ b/DataFormats/EcalDigi/src/EcalLiteDTUSample.cc @@ -0,0 +1,11 @@ +#include "DataFormats/EcalDigi/interface/EcalLiteDTUSample.h" +#include + +EcalLiteDTUSample::EcalLiteDTUSample(int adc, int gainId) { + theSample = (adc & ecalPh2::kAdcMask) | ((gainId & ecalPh2::kGainIdMask) << ecalPh2::NBITS); +} + +std::ostream& operator<<(std::ostream& s, const EcalLiteDTUSample& samp) { + s << "ADC=" << samp.adc() << ", gainId=" << samp.gainId(); + return s; +} diff --git a/DataFormats/EcalDigi/src/classes_def.xml b/DataFormats/EcalDigi/src/classes_def.xml index cd9b32c91ae11..9c40edacab4db 100644 --- a/DataFormats/EcalDigi/src/classes_def.xml +++ b/DataFormats/EcalDigi/src/classes_def.xml @@ -72,6 +72,13 @@ + + + + + + + @@ -91,6 +98,8 @@ + + diff --git a/SimCalorimetry/Configuration/python/SimCalorimetry_EventContent_cff.py b/SimCalorimetry/Configuration/python/SimCalorimetry_EventContent_cff.py index d159b7eee48a5..94d8df9329b03 100644 --- a/SimCalorimetry/Configuration/python/SimCalorimetry_EventContent_cff.py +++ b/SimCalorimetry/Configuration/python/SimCalorimetry_EventContent_cff.py @@ -1,5 +1,4 @@ import FWCore.ParameterSet.Config as cms - # This object modifies the event content for different scenarios SimCalorimetryFEVTDEBUG = cms.PSet( diff --git a/SimCalorimetry/Configuration/python/ecalDigiSequence_cff.py b/SimCalorimetry/Configuration/python/ecalDigiSequence_cff.py index c8250bc348ae8..c6d368f3569b2 100644 --- a/SimCalorimetry/Configuration/python/ecalDigiSequence_cff.py +++ b/SimCalorimetry/Configuration/python/ecalDigiSequence_cff.py @@ -18,8 +18,14 @@ premix_stage1.toReplaceWith(ecalDigiTask, ecalDigiTask.copyAndExclude([simEcalPreshowerDigis])) from SimCalorimetry.EcalEBTrigPrimProducers.ecalEBTriggerPrimitiveDigis_cff import * -_phase2_ecalDigiTask = ecalDigiTask.copy() -_phase2_ecalDigiTask.add(simEcalEBTriggerPrimitiveDigis) + +#DARIO COMMENTED: +#_phase2_ecalDigiTask = ecalDigiTask.copy() +#_phase2_ecalDigiTask.add(simEcalEBTriggerPrimitiveDigis) + +#DARIO ADDED: +#_phase2_ecalDigiTask = cms.Task(simEcalDigis) +_phase2_ecalDigiTask = cms.Task() from Configuration.Eras.Modifier_phase2_common_cff import phase2_common phase2_common.toReplaceWith(ecalDigiTask,_phase2_ecalDigiTask) diff --git a/SimCalorimetry/EcalSelectiveReadoutProducers/python/ecalDigis_cfi.py b/SimCalorimetry/EcalSelectiveReadoutProducers/python/ecalDigis_cfi.py index 094977444b01f..170a1381b8f9a 100644 --- a/SimCalorimetry/EcalSelectiveReadoutProducers/python/ecalDigis_cfi.py +++ b/SimCalorimetry/EcalSelectiveReadoutProducers/python/ecalDigis_cfi.py @@ -38,6 +38,7 @@ trigPrimCollection = cms.string(''), #switch to run w/o trigger primitive. For debug use only + trigPrimBypass = cms.bool(False), # Mode selection for "Trig bypass" mode @@ -72,6 +73,82 @@ defaultTtf = cms.int32(4) ) + +simEcalDigisPh2 = cms.EDProducer("EcalSelectiveReadoutProducer", + # Label of input EB and EE digi collections + digiProducer = cms.string('simEcalUnsuppressedDigis'), + + # Instance name of input EB digi collections + EBdigiCollection = cms.string(''), + + # Instance name of input EB digi collections + EEdigiCollection = cms.string(''), + + # Instance name of output EB SR flags collection + EBSrFlagCollection = cms.string('ebSrFlags'), + + # Instance name of output EE SR flags collection + EESrFlagCollection = cms.string('eeSrFlags'), + + # Instance name of output EB digis collection + EBSRPdigiCollection = cms.string('ebDigis'), + + # Instance name of output EE digis collection + EESRPdigiCollection = cms.string('eeDigis'), + + # Switch for reading SRP settings from condition database + configFromCondDB = cms.bool(True), + + # Switch to turn off SRP altogether using special DB payload + UseFullReadout = cms.bool(False), + + # ES label? + # NZSLabel = cms.ESInputTag(' '), + + # Label name of input ECAL trigger primitive collection + trigPrimProducer = cms.string('simEcalTriggerPrimitiveDigis'), + + # Instance name of ECAL trigger primitive collection + trigPrimCollection = cms.string(''), + + #switch to run w/o trigger primitive. For debug use only + trigPrimBypass = cms.bool(True), + + # Mode selection for "Trig bypass" mode + # 0: TT thresholds applied on sum of crystal Et's + # 1: TT thresholds applies on compressed Et from Trigger primitive + # @ee trigPrimByPass_ switch + trigPrimBypassMode = cms.int32(0), + + #for debug mode only: + trigPrimBypassLTH = cms.double(1.0), + + #for debug mode only: + trigPrimBypassHTH = cms.double(1.0), + + #for debug mode only + trigPrimBypassWithPeakFinder = cms.bool(True), + + #number of events whose TT and SR flags must be dumped (for debug purpose): + dumpFlags = cms.untracked.int32(0), + + #logical flag to write out SrFlags + writeSrFlags = cms.untracked.bool(True), + + #switch to apply selective readout decision on the digis and produce + #the "suppressed" digis + produceDigis = cms.untracked.bool(True), + + #Trigger Tower Flag to use when a flag is not found from the input + #Trigger Primitive collection. Must be one of the following values: + # 0: low interest, 1: mid interest, 3: high interest + # 4: forced low interest, 5: forced mid interest, 7: forced high interest + defaultTtf = cms.int32(4) +) + + + + # Turn off SR in Ecal for premixing stage1 from Configuration.ProcessModifiers.premix_stage1_cff import premix_stage1 premix_stage1.toModify(simEcalDigis, UseFullReadout = True) diff --git a/SimCalorimetry/EcalSimAlgos/interface/EBHitResponse.h b/SimCalorimetry/EcalSimAlgos/interface/EBHitResponse.h index 80699d98f24a7..b5e74ded8b14e 100644 --- a/SimCalorimetry/EcalSimAlgos/interface/EBHitResponse.h +++ b/SimCalorimetry/EcalSimAlgos/interface/EBHitResponse.h @@ -4,6 +4,7 @@ #include "CalibFormats/CaloObjects/interface/CaloTSamples.h" #include "SimCalorimetry/EcalSimAlgos/interface/EcalHitResponse.h" #include "CondFormats/EcalObjects/interface/EcalIntercalibConstantsMC.h" +#include "CondFormats/EcalObjects/interface/EcalConstants.h" class APDSimParameters; @@ -11,21 +12,24 @@ namespace CLHEP { class HepRandomEngine; } -class EBHitResponse : public EcalHitResponse { +template +class EBHitResponseImpl : public EcalHitResponse { public: - typedef CaloTSamples EBSamples; + typedef CaloTSamples EBSamples; typedef std::vector VecD; - enum { kNOffsets = 2000 }; + static constexpr size_t kNOffsets = constset::kNOffsets; - EBHitResponse(const CaloVSimParameterMap* parameterMap, - const CaloVShape* shape, - bool apdOnly, - const APDSimParameters* apdPars, - const CaloVShape* apdShape); + static constexpr double kSamplePeriod = constset::Samp_Period; - ~EBHitResponse() override; + EBHitResponseImpl(const CaloVSimParameterMap* parameterMap, + const CaloVShape* shape, + bool apdOnly, + const APDSimParameters* apdPars = nullptr, + const CaloVShape* apdShape = nullptr); + + ~EBHitResponseImpl() override; void initialize(CLHEP::HepRandomEngine*); @@ -95,4 +99,8 @@ class EBHitResponse : public EcalHitResponse { bool m_isInitialized; }; + +typedef EBHitResponseImpl EBHitResponse; +typedef EBHitResponseImpl EBHitResponse_Ph2; +#include "EBHitResponse.icc" #endif diff --git a/SimCalorimetry/EcalSimAlgos/src/EBHitResponse.cc b/SimCalorimetry/EcalSimAlgos/interface/EBHitResponse.icc similarity index 74% rename from SimCalorimetry/EcalSimAlgos/src/EBHitResponse.cc rename to SimCalorimetry/EcalSimAlgos/interface/EBHitResponse.icc index c500007a729eb..25e7286f81e81 100644 --- a/SimCalorimetry/EcalSimAlgos/src/EBHitResponse.cc +++ b/SimCalorimetry/EcalSimAlgos/interface/EBHitResponse.icc @@ -12,11 +12,11 @@ #include "FWCore/Utilities/interface/isFinite.h" #include "FWCore/Utilities/interface/Exception.h" -EBHitResponse::EBHitResponse(const CaloVSimParameterMap* parameterMap, +template EBHitResponseImpl::EBHitResponseImpl(const CaloVSimParameterMap* parameterMap, const CaloVShape* shape, bool apdOnly, - const APDSimParameters* apdPars = nullptr, - const CaloVShape* apdShape = nullptr) + const APDSimParameters* apdPars, + const CaloVShape* apdShape) : EcalHitResponse(parameterMap, shape), @@ -51,26 +51,29 @@ EBHitResponse::EBHitResponse(const CaloVSimParameterMap* parameterMap, } } -EBHitResponse::~EBHitResponse() {} +template EBHitResponseImpl::~EBHitResponseImpl() {} -void EBHitResponse::initialize(CLHEP::HepRandomEngine* engine) { +template void EBHitResponseImpl::initialize(CLHEP::HepRandomEngine* engine) { m_isInitialized = true; for (unsigned int i(0); i != kNOffsets; ++i) { m_timeOffVec[i] += CLHEP::RandGaussQ::shoot(engine, 0, apdParameters()->timeOffWidth()); } } -const APDSimParameters* EBHitResponse::apdParameters() const { +template +const APDSimParameters* EBHitResponseImpl::apdParameters() const { assert(nullptr != m_apdPars); return m_apdPars; } -const CaloVShape* EBHitResponse::apdShape() const { +template +const CaloVShape* EBHitResponseImpl::apdShape() const { assert(nullptr != m_apdShape); return m_apdShape; } -void EBHitResponse::putAPDSignal(const DetId& detId, double npe, double time) { +template +void EBHitResponseImpl::putAPDSignal(const DetId& detId, double npe, double time) { const CaloSimParameters& parameters(*params(detId)); const double energyFac(1. / parameters.simHitToPhotoelectrons(detId)); @@ -88,7 +91,7 @@ void EBHitResponse::putAPDSignal(const DetId& detId, double npe, double time) { } const double tzero(apdShape()->timeToRise() - jitter - offsets()[EBDetId(detId).denseIndex() % kNOffsets] - - BUNCHSPACE * (parameters.binOfMaximum() - phaseShift())); + kSamplePeriod * (parameters.binOfMaximum() - phaseShift())); double binTime(tzero); @@ -96,11 +99,12 @@ void EBHitResponse::putAPDSignal(const DetId& detId, double npe, double time) { for (unsigned int bin(0); bin != result.size(); ++bin) { result[bin] += (*apdShape())(binTime)*signal; - binTime += BUNCHSPACE; + binTime += kSamplePeriod; } } -double EBHitResponse::apdSignalAmplitude(const PCaloHit& hit, CLHEP::HepRandomEngine* engine) const { +template +double EBHitResponseImpl::apdSignalAmplitude(const PCaloHit& hit, CLHEP::HepRandomEngine* engine) const { int iddepth = (hit.depth() & PCaloHit::kEcalDepthIdMask); assert(1 == iddepth || 2 == iddepth); @@ -126,9 +130,11 @@ double EBHitResponse::apdSignalAmplitude(const PCaloHit& hit, CLHEP::HepRandomEn return npe; } -void EBHitResponse::setIntercal(const EcalIntercalibConstantsMC* ical) { m_intercal = ical; } +template +void EBHitResponseImpl::setIntercal(const EcalIntercalibConstantsMC* ical) { m_intercal = ical; } -void EBHitResponse::findIntercalibConstant(const DetId& detId, double& icalconst) const { +template +void EBHitResponseImpl::findIntercalibConstant(const DetId& detId, double& icalconst) const { EcalIntercalibConstantMC thisconst(1.); if (nullptr == m_intercal) { @@ -148,7 +154,8 @@ void EBHitResponse::findIntercalibConstant(const DetId& detId, double& icalconst icalconst = thisconst; } -void EBHitResponse::initializeHits() { +template +void EBHitResponseImpl::initializeHits() { if (!index().empty()) blankOutUsedSamples(); @@ -160,7 +167,8 @@ void EBHitResponse::initializeHits() { } } -void EBHitResponse::finalizeHits() { +template +void EBHitResponseImpl::finalizeHits() { const unsigned int bSize(EBDetId::kSizeForDenseIndexing); if (apdParameters()->addToBarrel() || m_apdOnly) { for (unsigned int i(0); i != bSize; ++i) { @@ -175,7 +183,8 @@ void EBHitResponse::finalizeHits() { } } -void EBHitResponse::add(const PCaloHit& hit, CLHEP::HepRandomEngine* engine) { +template +void EBHitResponseImpl::add(const PCaloHit& hit, CLHEP::HepRandomEngine* engine) { if (!edm::isNotFinite(hit.time()) && (nullptr == hitFilter() || hitFilter()->accepts(hit))) { int iddepth = (hit.depth() & PCaloHit::kEcalDepthIdMask); if (0 == iddepth) // for now take only nonAPD hits @@ -194,7 +203,8 @@ void EBHitResponse::add(const PCaloHit& hit, CLHEP::HepRandomEngine* engine) { } } -void EBHitResponse::run(MixCollection& hits, CLHEP::HepRandomEngine* engine) { +template +void EBHitResponseImpl::run(MixCollection& hits, CLHEP::HepRandomEngine* engine) { if (!index().empty()) blankOutUsedSamples(); @@ -240,16 +250,23 @@ void EBHitResponse::run(MixCollection& hits, CLHEP::HepRandomEngine* e } } -unsigned int EBHitResponse::samplesSize() const { return m_vSam.size(); } +template +unsigned int EBHitResponseImpl::samplesSize() const { return m_vSam.size(); } -unsigned int EBHitResponse::samplesSizeAll() const { return m_vSam.size(); } +template +unsigned int EBHitResponseImpl::samplesSizeAll() const { return m_vSam.size(); } -const EcalHitResponse::EcalSamples* EBHitResponse::operator[](unsigned int i) const { return &m_vSam[i]; } +template +const EcalHitResponse::EcalSamples* EBHitResponseImpl::operator[](unsigned int i) const { return &m_vSam[i]; } -EcalHitResponse::EcalSamples* EBHitResponse::operator[](unsigned int i) { return &m_vSam[i]; } +template +EcalHitResponse::EcalSamples* EBHitResponseImpl::operator[](unsigned int i) { return &m_vSam[i]; } -EcalHitResponse::EcalSamples* EBHitResponse::vSam(unsigned int i) { return &m_vSam[i]; } +template +EcalHitResponse::EcalSamples* EBHitResponseImpl::vSam(unsigned int i) { return &m_vSam[i]; } -EcalHitResponse::EcalSamples* EBHitResponse::vSamAll(unsigned int i) { return &m_vSam[i]; } +template +EcalHitResponse::EcalSamples* EBHitResponseImpl::vSamAll(unsigned int i) { return &m_vSam[i]; } -const EcalHitResponse::EcalSamples* EBHitResponse::vSamAll(unsigned int i) const { return &m_vSam[i]; } +template +const EcalHitResponse::EcalSamples* EBHitResponseImpl::vSamAll(unsigned int i) const { return &m_vSam[i]; } diff --git a/SimCalorimetry/EcalSimAlgos/interface/EcalCoder.h b/SimCalorimetry/EcalSimAlgos/interface/EcalCoder.h index ec60ac2f2af2a..6232f4a3fff43 100644 --- a/SimCalorimetry/EcalSimAlgos/interface/EcalCoder.h +++ b/SimCalorimetry/EcalSimAlgos/interface/EcalCoder.h @@ -1,6 +1,5 @@ - -#ifndef EcalSimAlgos_EcalCoder_h -#define EcalSimAlgos_EcalCoder_h 1 +#ifndef SimCalorimetry_EcalSimAlgos_EcalCoder_h +#define SimCalorimetry_EcalSimAlgos_EcalCoder_h #include "CalibFormats/CaloObjects/interface/CaloTSamples.h" #include "CondFormats/EcalObjects/interface/EcalPedestals.h" diff --git a/SimCalorimetry/EcalSimAlgos/interface/EcalCorrelatedNoiseMatrix_Ph2.h b/SimCalorimetry/EcalSimAlgos/interface/EcalCorrelatedNoiseMatrix_Ph2.h new file mode 100644 index 0000000000000..40ec734fb6c3f --- /dev/null +++ b/SimCalorimetry/EcalSimAlgos/interface/EcalCorrelatedNoiseMatrix_Ph2.h @@ -0,0 +1,10 @@ +#ifndef SimCalorimetry_EcalSimAlgos_EcalCorrelatedNoiseMatrix_Ph2_h +#define SimCalorimetry_EcalSimAlgos_EcalCorrelatedNoiseMatrix_Ph2_h + +#include "DataFormats/Math/interface/Error.h" +#include "CalibFormats/CaloObjects/interface/CaloSamples.h" +#include "CondFormats/EcalObjects/interface/EcalConstants.h" + +typedef math::ErrorD::type EcalCorrMatrix_Ph2; + +#endif diff --git a/SimCalorimetry/EcalSimAlgos/interface/EcalDigitizerTraits_Ph2.h b/SimCalorimetry/EcalSimAlgos/interface/EcalDigitizerTraits_Ph2.h new file mode 100644 index 0000000000000..c143672cfc2d7 --- /dev/null +++ b/SimCalorimetry/EcalSimAlgos/interface/EcalDigitizerTraits_Ph2.h @@ -0,0 +1,25 @@ +#ifndef SimCalorimetry_EcalSimAlgos_EcalDigitizerTraits_Ph2_h +#define SimCalorimetry_EcalSimAlgos_EcalDigitizerTraits_Ph2_h + +#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" +#include "SimCalorimetry/EcalSimAlgos/interface/EcalElectronicsSim_Ph2.h" +#include "CalibFormats/CaloObjects/interface/CaloTSamples.h" +#include "DataFormats/EcalDigi/interface/EcalDataFrame_Ph2.h" +#include "CondFormats/EcalObjects/interface/EcalConstants.h" +class EcalHitResponse; + +class EBDigitizerTraits_Ph2 { +public: + /// the digis collection + typedef EBDigiCollectionPh2 DigiCollection; + /// the dataframes + typedef EcalDataFrame_Ph2 Digi; + /// the electronics simulation + typedef EcalElectronicsSim_Ph2 ElectronicsSim_Ph2; + + typedef CaloTSamples EcalSamples; + + static void fix(Digi& digi, edm::DataFrame df){}; +}; + +#endif diff --git a/SimCalorimetry/EcalSimAlgos/interface/EcalElectronicsSim_Ph2.h b/SimCalorimetry/EcalSimAlgos/interface/EcalElectronicsSim_Ph2.h new file mode 100644 index 0000000000000..1f81c0908b17e --- /dev/null +++ b/SimCalorimetry/EcalSimAlgos/interface/EcalElectronicsSim_Ph2.h @@ -0,0 +1,57 @@ +#ifndef SimCalorimetry_EcalSimAlgos_EcalElectronicsSim_Ph2_h +#define SimCalorimetry_EcalSimAlgos_EcalElectronicsSim_Ph2_h + +#include "CalibFormats/CaloObjects/interface/CaloTSamples.h" +#include "SimCalorimetry/CaloSimAlgos/interface/CaloVNoiseSignalGenerator.h" +#include "CondFormats/EcalObjects/interface/EcalConstants.h" +#include "DataFormats/EcalDigi/interface/EcalDataFrame_Ph2.h" + +class EcalLiteDTUCoder; +//class EcalDataFrame_Ph2; +class EcalSimParameterMap_Ph2; + +namespace CLHEP { + class HepRandomEngine; +} + +/* \class EcalElectronicsSim_Ph2 + * \brief Converts CaloDataFrame in CaloTimeSample and vice versa. + * + */ + +class EcalElectronicsSim_Ph2 { +public: + typedef CaloTSamples EcalSamples; + EcalElectronicsSim_Ph2(const EcalSimParameterMap_Ph2* parameterMap, + EcalLiteDTUCoder* coder, + bool applyConstantTerm, + double rmsConstantTerm); + + ~EcalElectronicsSim_Ph2(); + + /// from EcalSamples to EcalDataFrame_Ph2 + void analogToDigital(CLHEP::HepRandomEngine*, EcalSamples& clf, EcalDataFrame_Ph2& df) const; + + void newEvent() {} + + void setNoiseSignalGenerator(const CaloVNoiseSignalGenerator* noiseSignalGenerator) { + theNoiseSignalGenerator = noiseSignalGenerator; + } + +private: + /// input signal is in pe. Converted in GeV + void amplify(EcalSamples& clf, CLHEP::HepRandomEngine*) const; + + /// map of parameters + + const EcalSimParameterMap_Ph2* m_simMap; + + const CaloVNoiseSignalGenerator* theNoiseSignalGenerator; + + EcalLiteDTUCoder* m_theCoder; + + const double m_thisCT; + const bool m_applyConstantTerm; +}; + +#endif diff --git a/SimCalorimetry/EcalSimAlgos/interface/EcalLiteDTUCoder.h b/SimCalorimetry/EcalSimAlgos/interface/EcalLiteDTUCoder.h new file mode 100644 index 0000000000000..b520d4ecd2d97 --- /dev/null +++ b/SimCalorimetry/EcalSimAlgos/interface/EcalLiteDTUCoder.h @@ -0,0 +1,82 @@ +#ifndef SimCalorimetry_EcalSimAlgos_EcalLiteDTUCoder_h +#define SimCalorimetry_EcalSimAlgos_EcalLiteDTUCoder_h + +#include "CalibFormats/CaloObjects/interface/CaloTSamples.h" +#include "CondFormats/EcalObjects/interface/EcalLiteDTUPedestals.h" +#include "CondFormats/EcalObjects/interface/EcalIntercalibConstantsMC.h" +#include "CondFormats/EcalObjects/interface/EcalCATIAGainRatios.h" +#include "SimCalorimetry/EcalSimAlgos/interface/EcalCorrelatedNoiseMatrix_Ph2.h" +#include "CondFormats/EcalObjects/interface/EcalConstants.h" + +template +class CorrelatedNoisifier; +class EcalLiteDTUSample; +class EcalDataFrame_Ph2; +class DetId; +class EcalLiteDTUPed; + +#include + +namespace CLHEP { + class HepRandomEngine; +} + +class EcalLiteDTUCoder { +public: + typedef CaloTSamples EcalSamples; + + + typedef CorrelatedNoisifier Noisifier; + + enum { + NBITS = ecalPh2::NBITS, // number of available bits + MAXADC = ecalPh2::MAXADC, // 2^12 -1, adc max range + NGAINS = ecalPh2::NGAINS // number of electronic gains + }; + + /// ctor + EcalLiteDTUCoder(bool addNoise, bool PreMix1, Noisifier* ebCorrNoise0, Noisifier* ebCorrNoise1 = nullptr); + + /// dtor + virtual ~EcalLiteDTUCoder(); + + /// can be fetched every event from the EventSetup + void setPedestals(const EcalLiteDTUPedestalsMap* pedestals); + + void setGainRatios(const EcalCATIAGainRatios* gainRatios); + + void setFullScaleEnergy(double EBscale); + + void setIntercalibConstants(const EcalIntercalibConstantsMC* ical); + + /// from EcalSamples to EcalDataFrame_Ph2 + virtual void analogToDigital(CLHEP::HepRandomEngine*, const EcalSamples& clf, EcalDataFrame_Ph2& df) const; + +private: + /// limit on the energy scale due to the electronics range + double fullScaleEnergy(const DetId& did) const; + + /// produce the pulse-shape + void encode(const EcalSamples& ecalSamples, EcalDataFrame_Ph2& df, CLHEP::HepRandomEngine*) const; + + void findPedestal(const DetId& detId, int gainId, double& pedestal, double& width) const; + + void findGains(const DetId& detId, float theGains[]) const; + + void findIntercalibConstant(const DetId& detId, double& icalconst) const; + + const EcalLiteDTUPedestalsMap* m_peds; + + const EcalCATIAGainRatios* m_gainRatios; // the electronics gains + + const EcalIntercalibConstantsMC* m_intercals; //record specific for simulation of gain variation in MC + + double m_maxEneEB; // max attainable energy in the ecal barrel + + bool m_addNoise; // whether add noise to the pedestals and the gains + bool m_PreMix1; // Follow necessary steps for PreMixing input + + const Noisifier* m_ebCorrNoise[NGAINS]; +}; + +#endif diff --git a/SimCalorimetry/EcalSimAlgos/interface/EcalSimParameterMap_Ph2.h b/SimCalorimetry/EcalSimAlgos/interface/EcalSimParameterMap_Ph2.h new file mode 100644 index 0000000000000..47a4facf36d4c --- /dev/null +++ b/SimCalorimetry/EcalSimAlgos/interface/EcalSimParameterMap_Ph2.h @@ -0,0 +1,40 @@ +#ifndef SimCalorimetry_EcalSimAlgos_EcalSimParameterMap_Ph2_h +#define SimCalorimetry_EcalSimAlgos_EcalSimParameterMap_Ph2_h + +#include "SimCalorimetry/CaloSimAlgos/interface/CaloVSimParameterMap.h" +#include "SimCalorimetry/CaloSimAlgos/interface/CaloSimParameters.h" + +/* \class EcalSimParametersMap + * \brief map of parameters for the ECAL (EE, EB, preshower) simulation + * + */ +class EcalSimParameterMap_Ph2 : public CaloVSimParameterMap { +public: + /// ctor + EcalSimParameterMap_Ph2(); + EcalSimParameterMap_Ph2(double simHitToPhotoelectronsBarrel, + //double simHitToPhotoelectronsEndcap, + double photoelectronsToAnalogBarrel, + //double photoelectronsToAnalogEndcap, + double samplingFactor, + double timePhase, + int readoutFrameSize, + int binOfMaximum, + bool doPhotostatistics, + bool syncPhase); + /// dtor + ~EcalSimParameterMap_Ph2() override {} + + /// return the sim parameters relative to the right subdet + const CaloSimParameters& simParameters(const DetId& id) const override; + +private: + /// EB + CaloSimParameters theBarrelParameters; + /// EE + //CaloSimParameters theEndcapParameters; + /// ES + //CaloSimParameters theESParameters; +}; + +#endif diff --git a/SimCalorimetry/EcalSimAlgos/interface/EcalTDigitizer_Ph2.h b/SimCalorimetry/EcalSimAlgos/interface/EcalTDigitizer_Ph2.h new file mode 100644 index 0000000000000..7ea5197293179 --- /dev/null +++ b/SimCalorimetry/EcalSimAlgos/interface/EcalTDigitizer_Ph2.h @@ -0,0 +1,61 @@ +#ifndef SimCalorimetry_EcalSimAlgos_EcalTDigitizer_Ph2_h +#define SimCalorimetry_EcalSimAlgos_EcalTDigitizer_Ph2_h + +/** Turns hits into digis. Assumes that + there's an ElectroncsSim class with the + interface analogToDigital(CLHEP::HepRandomEngine*, const CaloSamples &, Digi &); +*/ + +#include "SimDataFormats/CrossingFrame/interface/MixCollection.h" +#include "SimDataFormats/CaloHit/interface/PCaloHit.h" +#include "DataFormats/DetId/interface/DetId.h" +#include "CalibFormats/CaloObjects/interface/CaloTSamplesBase.h" +#include "SimCalorimetry/EcalSimAlgos/interface/EcalBaseSignalGenerator.h" + +class EcalHitResponse; +class EcalBaseSignalGenerator; + +namespace CLHEP { + class HepRandomEngine; +} + +template +class EcalTDigitizer_Ph2 { +public: + typedef typename Traits::ElectronicsSim_Ph2 ElectronicsSim_Ph2; + typedef typename Traits::Digi Digi; + typedef typename Traits::DigiCollection DigiCollection; + typedef typename Traits::EcalSamples EcalSamples; + + EcalTDigitizer_Ph2(EcalHitResponse* hitResponse, ElectronicsSim_Ph2* electronicsSim, bool addNoise); + + virtual ~EcalTDigitizer_Ph2(); + + void add(const std::vector& hits, int bunchCrossing, CLHEP::HepRandomEngine*); + + virtual void initializeHits(); + + virtual void run(DigiCollection& output, CLHEP::HepRandomEngine*); + + virtual void run(MixCollection& input, DigiCollection& output) { assert(0); } + + void setNoiseSignalGenerator(EcalBaseSignalGenerator* noiseSignalGenerator); + + void addNoiseSignals(); + +protected: + bool addNoise() const; + + const EcalHitResponse* hitResponse() const; + + const ElectronicsSim_Ph2* elecSim() const; + +private: + EcalHitResponse* m_hitResponse; + ElectronicsSim_Ph2* m_electronicsSim; + bool m_addNoise; + + EcalBaseSignalGenerator* theNoiseSignalGenerator; +}; + +#endif diff --git a/SimCalorimetry/EcalSimAlgos/interface/EcalTDigitizer_Ph2.icc b/SimCalorimetry/EcalSimAlgos/interface/EcalTDigitizer_Ph2.icc new file mode 100644 index 0000000000000..ba871b0d59393 --- /dev/null +++ b/SimCalorimetry/EcalSimAlgos/interface/EcalTDigitizer_Ph2.icc @@ -0,0 +1,96 @@ +#ifndef EcalSimAlgos_EcalTDigitizer_Ph2_icc +#define EcalSimAlgos_EcalTDigitizer_Ph2_icc + +#include "SimCalorimetry/EcalSimAlgos/interface/EcalTDigitizer_Ph2.h" +#include "SimCalorimetry/EcalSimAlgos/interface/EcalHitResponse.h" +#include "SimCalorimetry/EcalSimAlgos/interface/EcalBaseSignalGenerator.h" +#include "CalibFormats/CaloObjects/interface/CaloSamples.h" + +template +EcalTDigitizer_Ph2::EcalTDigitizer_Ph2(EcalHitResponse* hitResponse, + ElectronicsSim_Ph2* electronicsSim, + bool addNoise) + : m_hitResponse(hitResponse), + m_electronicsSim(electronicsSim), + m_addNoise(addNoise), + theNoiseSignalGenerator(nullptr) {} + +template +EcalTDigitizer_Ph2::~EcalTDigitizer_Ph2() {} + +template +void EcalTDigitizer_Ph2::add(const std::vector& hits, + int bunchCrossing, + CLHEP::HepRandomEngine* engine) { + if (m_hitResponse->withinBunchRange(bunchCrossing)) { + for (std::vector::const_iterator it = hits.begin(), itEnd = hits.end(); it != itEnd; ++it) { + m_hitResponse->add(*it, engine); + } + } +} + +template +void EcalTDigitizer_Ph2::initializeHits() { + m_hitResponse->initializeHits(); +} + +template +void EcalTDigitizer_Ph2::setNoiseSignalGenerator(EcalBaseSignalGenerator* noiseSignalGenerator) { + theNoiseSignalGenerator = noiseSignalGenerator; +} + +template +void EcalTDigitizer_Ph2::run(DigiCollection& output, CLHEP::HepRandomEngine* engine) { + m_hitResponse->finalizeHits(); + + if (theNoiseSignalGenerator != nullptr) { + addNoiseSignals(); + } + + m_electronicsSim->newEvent(); + + const unsigned int ssize(m_hitResponse->samplesSize()); + output.reserve(ssize); + + for (unsigned int i(0); i != ssize; ++i) { + EcalSamples& analogSignal(*static_cast((*m_hitResponse)[i])); + if (m_addNoise || // digitize if real or adding noise + !analogSignal.zero()) { + output.push_back(analogSignal.id().rawId()); + Digi digi(output.back()); // why does this work without & + m_electronicsSim->analogToDigital(engine, analogSignal, digi); + Traits::fix(digi, output.back()); + } + } +} + +template +void EcalTDigitizer_Ph2::addNoiseSignals() { + std::vector noiseSignals; + // noise signals need to be in units of photoelectrons. Fractional is OK + theNoiseSignalGenerator->fillEvent(); + theNoiseSignalGenerator->getNoiseSignals(noiseSignals); + for (typename std::vector::const_iterator signalItr = noiseSignals.begin(), + signalEnd = noiseSignals.end(); + signalItr != signalEnd; + ++signalItr) { + m_hitResponse->add(*signalItr); + } +} + +template +bool EcalTDigitizer_Ph2::addNoise() const { + return m_addNoise; +} + +template +const EcalHitResponse* EcalTDigitizer_Ph2::hitResponse() const { + return m_hitResponse; +} + +template +const typename Traits::ElectronicsSim_Ph2* EcalTDigitizer_Ph2::elecSim() const { + return m_electronicsSim; +} + +#endif diff --git a/SimCalorimetry/EcalSimAlgos/src/EcalCorrelatedNoiseMatrix_Ph2.cc b/SimCalorimetry/EcalSimAlgos/src/EcalCorrelatedNoiseMatrix_Ph2.cc new file mode 100644 index 0000000000000..c99fa779c36b8 --- /dev/null +++ b/SimCalorimetry/EcalSimAlgos/src/EcalCorrelatedNoiseMatrix_Ph2.cc @@ -0,0 +1,8 @@ +#include "SimCalorimetry/EcalSimAlgos/interface/EcalCorrelatedNoiseMatrix_Ph2.h" +#include "SimGeneral/NoiseGenerators/interface/CorrelatedNoisifier.icc" + +template class CorrelatedNoisifier; + +template void CorrelatedNoisifier::noisify(CaloSamples&, + CLHEP::HepRandomEngine*, + const std::vector* rangau) const; diff --git a/SimCalorimetry/EcalSimAlgos/src/EcalDigitizers_Ph2.cc b/SimCalorimetry/EcalSimAlgos/src/EcalDigitizers_Ph2.cc new file mode 100644 index 0000000000000..4f11f9315fd47 --- /dev/null +++ b/SimCalorimetry/EcalSimAlgos/src/EcalDigitizers_Ph2.cc @@ -0,0 +1,4 @@ +#include "SimCalorimetry/EcalSimAlgos/interface/EcalDigitizerTraits_Ph2.h" +#include "SimCalorimetry/EcalSimAlgos/interface/EcalTDigitizer_Ph2.icc" + +template class EcalTDigitizer_Ph2; diff --git a/SimCalorimetry/EcalSimAlgos/src/EcalElectronicsSim_Ph2.cc b/SimCalorimetry/EcalSimAlgos/src/EcalElectronicsSim_Ph2.cc new file mode 100644 index 0000000000000..b875b76473f64 --- /dev/null +++ b/SimCalorimetry/EcalSimAlgos/src/EcalElectronicsSim_Ph2.cc @@ -0,0 +1,38 @@ +#include "SimCalorimetry/EcalSimAlgos/interface/EcalElectronicsSim_Ph2.h" +#include "SimCalorimetry/EcalSimAlgos/interface/EcalLiteDTUCoder.h" +#include "SimCalorimetry/EcalSimAlgos/interface/EcalSimParameterMap_Ph2.h" +#include "DataFormats/EcalDigi/interface/EcalDataFrame_Ph2.h" + +#include "CLHEP/Random/RandGaussQ.h" + +#include +#include +#include +#include +#include + +EcalElectronicsSim_Ph2::EcalElectronicsSim_Ph2(const EcalSimParameterMap_Ph2* parameterMap, + EcalLiteDTUCoder* coder, + bool applyConstantTerm, + double rmsConstantTerm) + : m_simMap(parameterMap), m_theCoder(coder), m_thisCT(rmsConstantTerm), m_applyConstantTerm(applyConstantTerm) {} + +EcalElectronicsSim_Ph2::~EcalElectronicsSim_Ph2() {} + +void EcalElectronicsSim_Ph2::analogToDigital(CLHEP::HepRandomEngine* engine, + EcalElectronicsSim_Ph2::EcalSamples& clf, + EcalDataFrame_Ph2& df) const { + //PG input signal is in pe. Converted in GeV + amplify(clf, engine); + + m_theCoder->analogToDigital(engine, clf, df); +} + +void EcalElectronicsSim_Ph2::amplify(EcalElectronicsSim_Ph2::EcalSamples& clf, CLHEP::HepRandomEngine* engine) const { + const double fac(m_simMap->simParameters(clf.id()).photoelectronsToAnalog()); + if (m_applyConstantTerm) { + clf *= fac * CLHEP::RandGaussQ::shoot(engine, 1.0, m_thisCT); + } else { + clf *= fac; + } +} diff --git a/SimCalorimetry/EcalSimAlgos/src/EcalLiteDTUCoder.cc b/SimCalorimetry/EcalSimAlgos/src/EcalLiteDTUCoder.cc new file mode 100644 index 0000000000000..3b954c4392280 --- /dev/null +++ b/SimCalorimetry/EcalSimAlgos/src/EcalLiteDTUCoder.cc @@ -0,0 +1,241 @@ +#include "SimCalorimetry/EcalSimAlgos/interface/EcalLiteDTUCoder.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "SimGeneral/NoiseGenerators/interface/CorrelatedNoisifier.h" +#include "DataFormats/EcalDigi/interface/EcalLiteDTUSample.h" +#include "DataFormats/EcalDigi/interface/EcalDataFrame_Ph2.h" + +#include "CondFormats/EcalObjects/interface/EcalConstants.h" + +#include + +//#include "Geometry/CaloGeometry/interface/CaloGenericDetId.h" + +///////////////////// +//NOTE: +//TO BE CORRECTLY IMPLEMENTED! +//Simona Cometti, [20.03.20 12:05] +//[In reply to Dario Soldi] +//Allora nella versione 1 i samples a gain 1 erano solo 8 +//Centrati così: +//Quindi 2 samples prima e 5 dopo a quello saturato +//Nella versione 1.2 c'è la possibilità di avere 8 samples o 16 samples dal gain 1 +//Quando è selezionata l'opzione dei 16 samples: +//5 samples prima, il sample saturo e poi 10 samples dopo +const float DTUVersion = 1.0; + +EcalLiteDTUCoder::EcalLiteDTUCoder(bool addNoise, + bool PreMix1, + EcalLiteDTUCoder::Noisifier* ebCorrNoise0, + EcalLiteDTUCoder::Noisifier* ebCorrNoise1) + : m_peds(nullptr), + m_gainRatios(nullptr), + m_intercals(nullptr), + // m_maxEneEB ( 1668.3 ) , // 4095(MAXADC)*12(gain 2)*0.035(GeVtoADC)*0.97 + m_maxEneEB(ecalPh2::maxEneEB), // Maximum for CATIA: LSB gain 10: 0.048 MeV + m_addNoise(addNoise), + m_PreMix1(PreMix1) + +{ + m_ebCorrNoise[0] = ebCorrNoise0; + assert(nullptr != m_ebCorrNoise[0]); + m_ebCorrNoise[1] = ebCorrNoise1; +} + +EcalLiteDTUCoder::~EcalLiteDTUCoder() {} + +void EcalLiteDTUCoder::setFullScaleEnergy(double EBscale) { + // m_maxEneEB = EBscale ; + m_maxEneEB = ecalPh2::maxEneEB; //I don 't know where is setFullScaleEnergy first call +} + +void EcalLiteDTUCoder::setPedestals(const EcalLiteDTUPedestalsMap* pedestals) { m_peds = pedestals; } + +void EcalLiteDTUCoder::setGainRatios(const EcalCATIAGainRatios* gainRatios) { m_gainRatios = gainRatios; } + +void EcalLiteDTUCoder::setIntercalibConstants(const EcalIntercalibConstantsMC* ical) { m_intercals = ical; } + +double EcalLiteDTUCoder::fullScaleEnergy(const DetId& detId) const { + //return detId.subdetId() == EcalBarrel ? m_maxEneEB : m_maxEneEE ; + return m_maxEneEB; +} + +void EcalLiteDTUCoder::analogToDigital(CLHEP::HepRandomEngine* engine, + const EcalSamples& clf, + EcalDataFrame_Ph2& df) const { + df.setSize(clf.size()); + encode(clf, df, engine); +} + +void EcalLiteDTUCoder::encode(const EcalSamples& ecalSamples, + EcalDataFrame_Ph2& df, + CLHEP::HepRandomEngine* engine) const { + assert(nullptr != m_peds); + + const unsigned int csize(ecalSamples.size()); + + DetId detId = ecalSamples.id(); + double Emax = fullScaleEnergy(detId); + + //....initialisation + if (ecalSamples[5] > 0.) + LogDebug("EcalLiteDTUCoder") << "Input caloSample" + << "\n" + << ecalSamples; + + //N Gains set to 2 in the .h + double pedestals[ecalPh2::NGAINS]; + double widths[ecalPh2::NGAINS]; + //float gains[ecalPh2::NGAINS]; + double LSB[ecalPh2::NGAINS]; + double trueRMS[ecalPh2::NGAINS]; + + double icalconst = 1.; + findIntercalibConstant(detId, icalconst); + + for (unsigned int igain(0); igain < NGAINS; ++igain) { + // fill in the pedestal and width + + findPedestal(detId, igain, pedestals[igain], widths[igain]); + //I insert an absolute value in the trueRMS + trueRMS[igain] = std::sqrt(std::fabs(widths[igain] * widths[igain] - 1. / 12.)); + + // set nominal value first + //findGains( detId , gains ); + + LSB[igain] = Emax / (MAXADC * ecalPh2::gains[igain]); + } + + CaloSamples noiseframe[] = { + CaloSamples(detId, csize), + CaloSamples(detId, csize), + }; + + const Noisifier* noisy[NGAINS] = {m_ebCorrNoise[0], m_ebCorrNoise[1]}; + + if (m_addNoise) { + //#warning noise generation to be checked + noisy[0]->noisify(noiseframe[0], engine); // high gain + //if( nullptr == noisy[1] ) noisy[0]->noisify( noiseframe[1] , + // engine, + // &noisy[0]->vecgau() ) ; // lwo gain + noisy[1]->noisify(noiseframe[1], engine); // low gain + } + + bool isSaturated[] = {false, false}; + std::vector> adctrace(csize); + unsigned int saturatedSample[] = {0, 0}; + + for (unsigned int i(0); i != csize; ++i) + adctrace[i].resize(NGAINS); + + for (unsigned int igain = 0; igain < NGAINS; ++igain) { + for (unsigned int i(0); i != csize; ++i) { + adctrace[i][igain] = -1; + } + } + + // fill ADC trace in gain 0 (x10) and gain 1 (x1) + //NOTE: Before was pedestals[igain], widths[igain] + + for (unsigned int igain = 0; igain < NGAINS; ++igain) { + for (unsigned int i(0); i != csize; ++i) { + double asignal = 0; + + if (!m_PreMix1) { + asignal = + pedestals[igain] + ecalSamples[i] / (LSB[igain] * icalconst) + + trueRMS[igain] * + noiseframe + [igain] + [i]; //Analog signal value for each sample in ADC. It is corrected by the intercalibration constants + + } else { + // no noise nor pedestal when premixing + asignal = ecalSamples[i] / (LSB[igain] * icalconst); + } + int isignal = asignal; + + int adc = asignal - (double)isignal < 0.5 ? isignal : isignal + 1; + if (adc > MAXADC) { + adc = MAXADC; + isSaturated[igain] = true; + saturatedSample[igain] = i; + } + + if (isSaturated[0] && igain == 0) { + break; // gain 0 (x10) channel is saturated, readout will use gain 1 (x10) + } else + adctrace[i][igain] = adc; + + //if (ecalSamples[i] > 0.) { + // std::cout<<" igain = "<getMap().size(); + } + + LogDebug("EcalLiteDTUCoder") << "Pedestals for " << detId.rawId() << " gain range " << gainId << " : \n" + << "Mean = " << ped << " rms = " << width; +} + +// void +// EcalCoder::findGains( const DetId & detId , float Gains[] ) const +// { + +// EcalCATIAGainRatioMap::const_iterator grit = m_gainRatios->getMap().find( detId ); +// Gains[1] = 1.; +// Gains[0] = Gains[1]*(*grit); + +// if ( (detId.subdetId() != EcalBarrel) && (detId.subdetId() != EcalEndcap) ) +// { +// edm::LogError("EcalCoder") << "Could not find gain ratios for " << detId.rawId() << " among the " << m_gainRatios->getMap().size(); +// } + +// } + +void EcalLiteDTUCoder::findIntercalibConstant(const DetId& detId, double& icalconst) const { + EcalIntercalibConstantMC thisconst = 1.; + // find intercalib constant for this xtal + const EcalIntercalibConstantMCMap& icalMap = m_intercals->getMap(); + EcalIntercalibConstantMCMap::const_iterator icalit = icalMap.find(detId); + if (icalit != icalMap.end()) { + thisconst = (*icalit); + if (icalconst == 0.) { + thisconst = 1.; + } + } else { + edm::LogError("EcalLiteDTUCoder") << "No intercalib const found for xtal " << detId.rawId() + << "! something wrong with EcalIntercalibConstants in your DB? "; + } + icalconst = thisconst; +} diff --git a/SimCalorimetry/EcalSimAlgos/src/EcalSimParameterMap_Ph2.cc b/SimCalorimetry/EcalSimAlgos/src/EcalSimParameterMap_Ph2.cc new file mode 100644 index 0000000000000..5307bfaadb378 --- /dev/null +++ b/SimCalorimetry/EcalSimAlgos/src/EcalSimParameterMap_Ph2.cc @@ -0,0 +1,54 @@ +#include "SimCalorimetry/EcalSimAlgos/interface/EcalSimParameterMap_Ph2.h" +#include "DataFormats/DetId/interface/DetId.h" +#include "DataFormats/EcalDetId/interface/EcalSubdetector.h" +#include + +/** Relevant constants are: + 4.5 photoelectrons per MeV (J. Nash's slides) + APD gain 50, but analog signal stays in GeV + Account for excess noise factor + */ + +EcalSimParameterMap_Ph2::EcalSimParameterMap_Ph2() + : theBarrelParameters(2250., 1. / 2250., 1., 0, 16, 6, true, true) {} //, +//theEndcapParameters(1800., 1./1800., 1., 0, 16, 6, true, true), +//theESParameters(1., 1., 1., 20., 3, 2, false, true) {} + +EcalSimParameterMap_Ph2::EcalSimParameterMap_Ph2(double simHitToPhotoelectronsBarrel, + //double simHitToPhotoelectronsEndcap, + double photoelectronsToAnalogBarrel, + //double photoelectronsToAnalogEndcap, + double samplingFactor, + double timePhase, + int readoutFrameSize, + int binOfMaximum, + bool doPhotostatistics, + bool syncPhase) + : theBarrelParameters(simHitToPhotoelectronsBarrel, + photoelectronsToAnalogBarrel, + samplingFactor, + timePhase, + readoutFrameSize, + binOfMaximum, + doPhotostatistics, + syncPhase) {} //, +//theEndcapParameters(simHitToPhotoelectronsEndcap, photoelectronsToAnalogEndcap, +//samplingFactor, timePhase, +//readoutFrameSize, binOfMaximum, doPhotostatistics, syncPhase), +//theESParameters(1., 1., 1., 20., 3, 2, false, syncPhase) {} + +/* + CaloSimParameters(double simHitToPhotoelectrons, double photoelectronsToAnalog, + double samplingFactor, double timePhase, + int readoutFrameSize, int binOfMaximum, + bool doPhotostatistics, bool syncPhase) + */ + +const CaloSimParameters& EcalSimParameterMap_Ph2::simParameters(const DetId& detId) const { + //if (EcalSubdetector(detId.subdetId()) == EcalBarrel) + return theBarrelParameters; + //else if (EcalSubdetector(detId.subdetId()) == EcalEndcap) + //return theEndcapParameters; + //else + //return theESParameters; +} diff --git a/SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer.h b/SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer.h index 133852c53dfa4..91625338c772a 100644 --- a/SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer.h +++ b/SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer.h @@ -15,7 +15,7 @@ #include "SimCalorimetry/EcalSimAlgos/interface/EcalDigitizerTraits.h" #include "SimCalorimetry/EcalSimAlgos/interface/EcalTDigitizer.h" #include "SimGeneral/MixingModule/interface/DigiAccumulatorMixMod.h" - +#include "SimCalorimetry/EcalSimAlgos/interface/EBHitResponse.h" #include typedef EcalTDigitizer EBDigitizer; @@ -25,7 +25,6 @@ typedef CaloTDigitizer ESOldDigitizer; class ESDigitizer; class APDSimParameters; -class EBHitResponse; class EEHitResponse; class ESHitResponse; class CaloHitResponse; diff --git a/SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer_Ph2.h b/SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer_Ph2.h new file mode 100644 index 0000000000000..6c483e90b4818 --- /dev/null +++ b/SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer_Ph2.h @@ -0,0 +1,122 @@ +#ifndef SimCalorimetry_EcalSimProducers_EcalDigiProducer_Ph2_h +#define SimCalorimetry_EcalSimProducers_EcalDigiProducer_Ph2_h + +#include "SimCalorimetry/EcalSimAlgos/interface/APDShape.h" +#include "SimCalorimetry/EcalSimAlgos/interface/EBShape.h" +#include "DataFormats/Math/interface/Error.h" +#include "FWCore/Framework/interface/ProducesCollector.h" +#include "SimGeneral/NoiseGenerators/interface/CorrelatedNoisifier.h" +#include "SimCalorimetry/EcalSimAlgos/interface/EcalCorrelatedNoiseMatrix_Ph2.h" + +#include "SimCalorimetry/CaloSimAlgos/interface/CaloTDigitizer.h" +#include "SimCalorimetry/EcalSimAlgos/interface/EcalTDigitizer_Ph2.h" +#include "SimCalorimetry/EcalSimAlgos/interface/EcalDigitizerTraits_Ph2.h" +#include "SimGeneral/MixingModule/interface/DigiAccumulatorMixMod.h" +#include "SimCalorimetry/EcalSimAlgos/interface/EBHitResponse.h" +#include + +typedef EcalTDigitizer_Ph2 EBDigitizer_Ph2; + +class APDSimParameters; +class CaloHitResponse; +class EcalSimParameterMap_Ph2; +class EcalLiteDTUCoder; +class EcalElectronicsSim_Ph2; +class EcalBaseSignalGenerator; +class CaloGeometry; +class EBDigiCollectionPh2; +class PileUpEventPrincipal; + +namespace edm { + class ConsumesCollector; + class ProducerBase; + class Event; + class EventSetup; + template + class Handle; + class ParameterSet; + class StreamID; +} // namespace edm + +namespace CLHEP { + class HepRandomEngine; +} + +class EcalDigiProducer_Ph2 : public DigiAccumulatorMixMod { +public: + EcalDigiProducer_Ph2(const edm::ParameterSet& params, + edm::ProducesCollector producesCollector, + edm::ConsumesCollector& iC); + EcalDigiProducer_Ph2(const edm::ParameterSet& params, edm::ConsumesCollector& iC); + ~EcalDigiProducer_Ph2() override; + + void initializeEvent(edm::Event const& e, edm::EventSetup const& c) override; + void accumulate(edm::Event const& e, edm::EventSetup const& c) override; + void accumulate(PileUpEventPrincipal const& e, edm::EventSetup const& c, edm::StreamID const&) override; + void finalizeEvent(edm::Event& e, edm::EventSetup const& c) override; + void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& setup) override; + void beginRun(edm::Run const& run, edm::EventSetup const& setup) override; + + void setEBNoiseSignalGenerator(EcalBaseSignalGenerator* noiseGenerator); + +private: + virtual void cacheEBDigis(const EBDigiCollectionPh2* ebDigiPtr) const {} + + typedef edm::Handle > HitsHandle; + void accumulateCaloHits(HitsHandle const& ebHandle, int bunchCrossing); + + void checkGeometry(const edm::EventSetup& eventSetup); + + void updateGeometry(); + + void checkCalibrations(const edm::Event& event, const edm::EventSetup& eventSetup); + + APDShape m_APDShape; + EBShape m_EBShape; + + const std::string m_EBdigiCollection; + const std::string m_hitsProducerTag; + + bool m_useLCcorrection; + + const bool m_apdSeparateDigi; + + const double m_EBs25notCont; + + const unsigned int m_readoutFrameSize; + +protected: + std::unique_ptr m_ParameterMap; + +private: + const std::string m_apdDigiTag; + std::unique_ptr m_apdParameters; + + std::unique_ptr m_APDResponse; + +protected: + std::unique_ptr m_EBResponse; + +private: + const bool m_PreMix1; + const bool m_PreMix2; + + const bool m_doEB; + + std::unique_ptr m_APDDigitizer; + std::unique_ptr m_BarrelDigitizer; + + std::unique_ptr m_ElectronicsSim; + std::unique_ptr m_Coder; + + std::unique_ptr m_APDElectronicsSim; + std::unique_ptr m_APDCoder; + + const CaloGeometry* m_Geometry; + + std::array >, 2> m_EBCorrNoise; + + CLHEP::HepRandomEngine* randomEngine_ = nullptr; +}; + +#endif diff --git a/SimCalorimetry/EcalSimProducers/interface/EcalTimeDigiProducer_Ph2.h b/SimCalorimetry/EcalSimProducers/interface/EcalTimeDigiProducer_Ph2.h new file mode 100644 index 0000000000000..5fadb5f7fca57 --- /dev/null +++ b/SimCalorimetry/EcalSimProducers/interface/EcalTimeDigiProducer_Ph2.h @@ -0,0 +1,60 @@ +#ifndef SimCalorimetry_EcalSimProducers_EcalTimeDigiProducer_Ph2_h +#define SimCalorimetry_EcalSimProducers_EcalTimeDigiProducer_Ph2_h + +#include "DataFormats/Math/interface/Error.h" + +#include "SimCalorimetry/EcalSimAlgos/interface/EcalDigitizerTraits_Ph2.h" +#include "SimGeneral/MixingModule/interface/DigiAccumulatorMixMod.h" +#include "SimDataFormats/CaloHit/interface/PCaloHit.h" +#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" +#include "FWCore/Utilities/interface/EDGetToken.h" +#include "FWCore/Framework/interface/ProducesCollector.h" +#include "FWCore/Framework/interface/ConsumesCollector.h" + +#include + +class ESDigitizer; + +class CaloGeometry; +class EcalSimParameterMap_Ph2; +class PileUpEventPrincipal; +class EcalTimeMapDigitizer; + +namespace edm { + class Event; + class EventSetup; + template + class Handle; + class ParameterSet; +} // namespace edm + +class EcalTimeDigiProducer_Ph2 : public DigiAccumulatorMixMod { +public: + EcalTimeDigiProducer_Ph2(const edm::ParameterSet& params, edm::ProducesCollector, edm::ConsumesCollector&); + ~EcalTimeDigiProducer_Ph2() override; + + void initializeEvent(edm::Event const& e, edm::EventSetup const& c) override; + void accumulate(edm::Event const& e, edm::EventSetup const& c) override; + void accumulate(PileUpEventPrincipal const& e, edm::EventSetup const& c, edm::StreamID const&) override; + void finalizeEvent(edm::Event& e, edm::EventSetup const& c) override; + +private: + typedef edm::Handle > HitsHandle; + void accumulateCaloHits(HitsHandle const& ebHandle, int bunchCrossing); + + void checkGeometry(const edm::EventSetup& eventSetup); + + void updateGeometry(); + + const std::string m_EBdigiCollection; + const edm::InputTag m_hitsProducerTagEB; + const edm::EDGetTokenT > m_hitsProducerTokenEB; + +private: + int m_timeLayerEB; + const CaloGeometry* m_Geometry; + + EcalTimeMapDigitizer* m_BarrelDigitizer; +}; + +#endif diff --git a/SimCalorimetry/EcalSimProducers/plugins/EcalCATIAGainRatiosESProducer.cc b/SimCalorimetry/EcalSimProducers/plugins/EcalCATIAGainRatiosESProducer.cc new file mode 100644 index 0000000000000..f3c3f914cc3ea --- /dev/null +++ b/SimCalorimetry/EcalSimProducers/plugins/EcalCATIAGainRatiosESProducer.cc @@ -0,0 +1,54 @@ +#include +#include "FWCore/Framework/interface/ModuleFactory.h" +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Framework/interface/ESProductHost.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "CondFormats/DataRecord/interface/EcalCATIAGainRatiosRcd.h" +#include "CondFormats/EcalObjects/interface/EcalCATIAGainRatios.h" +#include "CondFormats/EcalObjects/src/classes.h" +// +// class declaration +// +const int kEBChannels = ecalPh2::kEBChannels; + +class EcalCATIAGainRatiosESProducer : public edm::ESProducer { +public: + EcalCATIAGainRatiosESProducer(const edm::ParameterSet& iConfig); + + //typedef std::shared_ptr ReturnType; + typedef std::unique_ptr ReturnType; + + ReturnType produce(const EcalCATIAGainRatiosRcd& iRecord); + +private: + edm::ParameterSet pset_; +}; + +EcalCATIAGainRatiosESProducer::EcalCATIAGainRatiosESProducer(const edm::ParameterSet& iConfig) : pset_(iConfig) { + //the following line is needed to tell the framework what + // data is being produced + //std::cout<<"*********Creating EcalCATIAGainRatiosESProducer"<(); + + //std::cout<<"**********Set EB Values "<setValue(myEBDetId.rawId(), val); + } + + //std::cout<size()< +#include "FWCore/Framework/interface/ModuleFactory.h" +#include "FWCore/Framework/interface/ESProducer.h" +#include "FWCore/Framework/interface/ESProductHost.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "CondFormats/DataRecord/interface/EcalLiteDTUPedestalsRcd.h" +#include "CondFormats/EcalObjects/interface/EcalLiteDTUPedestals.h" +#include "CondFormats/EcalObjects/src/classes.h" +#include "CondFormats/EcalObjects/interface/EcalConstants.h" + +// +// class declaration +// +//const int kEBChannels = 61200; + +class EcalLiteDTUPedestalsESProducer : public edm::ESProducer { +public: + EcalLiteDTUPedestalsESProducer(const edm::ParameterSet& iConfig); + + typedef std::unique_ptr ReturnType; + + ReturnType produce(const EcalLiteDTUPedestalsRcd& iRecord); + +private: + edm::ParameterSet pset_; +}; + +EcalLiteDTUPedestalsESProducer::EcalLiteDTUPedestalsESProducer(const edm::ParameterSet& iConfig) : pset_(iConfig) { + //the following line is needed to tell the framework what + // data is being produced + //std::cout<<"*********Creating EcalLiteDTUPedestalsESProducer"<(); + + //std::cout<<"**********Set EB Values "<insert(std::make_pair(myEBDetId, ped)); + } + + //std::cout<size()<(m_apdDigiTag); + + producesCollector.produces(m_EBdigiCollection); +} + +// version for Pre-Mixing, for use outside of MixingModule +EcalDigiProducer_Ph2::EcalDigiProducer_Ph2(const edm::ParameterSet& params, edm::ConsumesCollector& iC) + : DigiAccumulatorMixMod(), + m_APDShape(true), + m_EBShape(true), + + m_EBdigiCollection(params.getParameter("EBdigiCollectionPh2")), + + m_hitsProducerTag(params.getParameter("hitsProducer")), + m_useLCcorrection(params.getUntrackedParameter("UseLCcorrection")), + m_apdSeparateDigi(params.getParameter("apdSeparateDigi")), + + m_EBs25notCont(params.getParameter("EBs25notContainment")), + + m_readoutFrameSize(params.getParameter("readoutFrameSize")), + m_ParameterMap(new EcalSimParameterMap_Ph2(params.getParameter("simHitToPhotoelectronsBarrel"), + params.getParameter("photoelectronsToAnalogBarrel"), + params.getParameter("samplingFactor"), + params.getParameter("timePhase"), + m_readoutFrameSize, + params.getParameter("binOfMaximum"), + params.getParameter("doPhotostatistics"), + params.getParameter("syncPhase"))), + + m_apdDigiTag(params.getParameter("apdDigiTag")), + m_apdParameters(new APDSimParameters(params.getParameter("apdAddToBarrel"), + m_apdSeparateDigi, + params.getParameter("apdSimToPELow"), + params.getParameter("apdSimToPEHigh"), + params.getParameter("apdTimeOffset"), + params.getParameter("apdTimeOffWidth"), + params.getParameter("apdDoPEStats"), + m_apdDigiTag, + params.getParameter >("apdNonlParms"))), + + m_APDResponse( + !m_apdSeparateDigi + ? nullptr + : new EBHitResponse_Ph2(m_ParameterMap.get(), &m_EBShape, true, m_apdParameters.get(), &m_APDShape)), + + m_EBResponse(new EBHitResponse_Ph2(m_ParameterMap.get(), + &m_EBShape, + false, // barrel + m_apdParameters.get(), + &m_APDShape)), + + m_PreMix1(params.getParameter("EcalPreMixStage1")), + m_PreMix2(params.getParameter("EcalPreMixStage2")), + + m_doEB(params.getParameter("doEB")), + + m_APDDigitizer(nullptr), + m_BarrelDigitizer(nullptr), + m_ElectronicsSim(nullptr), + m_Coder(nullptr), + m_APDElectronicsSim(nullptr), + m_APDCoder(nullptr), + m_Geometry(nullptr), + m_EBCorrNoise({{nullptr, nullptr}}) + +{ + //std::cout<<"[EcalDigiProducer_Ph2] Constructing producer"<< "frameSize: " << m_readoutFrameSize<< std::endl; + if (m_doEB) + iC.consumes >(edm::InputTag(m_hitsProducerTag, "EcalHitsEB")); + + const std::vector ebCorMatG10Ph2 = params.getParameter >("EBCorrNoiseMatrixG10Ph2"); + const std::vector ebCorMatG01Ph2 = params.getParameter >("EBCorrNoiseMatrixG01Ph2"); + + const bool applyConstantTerm = params.getParameter("applyConstantTerm"); + const double rmsConstantTerm = params.getParameter("ConstantTerm"); + + const bool addNoise = params.getParameter("doENoise"); + const bool cosmicsPhase = params.getParameter("cosmicsPhase"); + const double cosmicsShift = params.getParameter("cosmicsShift"); + + //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + // further phase for cosmics studies + if (cosmicsPhase) { + if (m_doEB) + m_EBResponse->setPhaseShift(1. + cosmicsShift); + } + + EcalCorrMatrix_Ph2 ebMatrix[2]; + + //std::cout<<"[EcalDigiProducer_Ph2] Check size10: "< fabs(ebCorMatG10Ph2[0] - 1.0)); + assert(1.e-7 > fabs(ebCorMatG01Ph2[0] - 1.0)); + + //std::cout<<"[EcalDigiProducer_Ph2] Check row of cor and col mat"<= ebCorMatG10Ph2[row]); + assert(0 == row || 1. >= ebCorMatG01Ph2[row]); + + // std::cout<<"row "<(ebMatrix[0])); + m_EBCorrNoise[1].reset(new CorrelatedNoisifier(ebMatrix[1])); + + //std::cout<<"[EcalDigiProducer_Ph2] More reset"< rng; + randomEngine_ = &rng->getEngine(event.streamID()); + + checkGeometry(eventSetup); + checkCalibrations(event, eventSetup); + if (m_doEB) { + m_BarrelDigitizer->initializeHits(); + if (m_apdSeparateDigi) { + m_APDDigitizer->initializeHits(); + } + } +} + +void EcalDigiProducer_Ph2::accumulateCaloHits(HitsHandle const& ebHandle, int bunchCrossing) { + if (m_doEB && ebHandle.isValid()) { + m_BarrelDigitizer->add(*ebHandle.product(), bunchCrossing, randomEngine_); + + if (m_apdSeparateDigi) { + m_APDDigitizer->add(*ebHandle.product(), bunchCrossing, randomEngine_); + } + } +} + +void EcalDigiProducer_Ph2::accumulate(edm::Event const& e, edm::EventSetup const& eventSetup) { + // Step A: Get Inputs + edm::Handle > ebHandle; + if (m_doEB) { + m_EBShape.setEventSetup(eventSetup); // need to set the eventSetup here, otherwise pre-mixing module will not wrk + m_APDShape.setEventSetup(eventSetup); // + edm::InputTag ebTag(m_hitsProducerTag, "EcalHitsEB"); + e.getByLabel(ebTag, ebHandle); + } + + accumulateCaloHits(ebHandle, 0); +} + +void EcalDigiProducer_Ph2::accumulate(PileUpEventPrincipal const& e, + edm::EventSetup const& eventSetup, + edm::StreamID const& streamID) { + // Step A: Get Inputs + edm::Handle > ebHandle; + if (m_doEB) { + edm::InputTag ebTag(m_hitsProducerTag, "EcalHitsEB"); + e.getByLabel(ebTag, ebHandle); + } + accumulateCaloHits(ebHandle, e.bunchCrossing()); +} + +void EcalDigiProducer_Ph2::finalizeEvent(edm::Event& event, edm::EventSetup const& eventSetup) { + // Step B: Create empty output + std::unique_ptr apdResult(!m_apdSeparateDigi || !m_doEB ? nullptr : new EBDigiCollectionPh2()); + std::unique_ptr barrelResult(new EBDigiCollectionPh2()); + + // run the algorithm + + if (m_doEB) { + //std::cout << " EcalDigiProducer_Ph2 ::finalize, running digitizer " + //<< event.run() << " " << event.id() << std::endl; + + m_BarrelDigitizer->run(*barrelResult, randomEngine_); + cacheEBDigis(&*barrelResult); + + edm::LogInfo("DigiInfo") << "EB Digis: " << barrelResult->size(); + + if (m_apdSeparateDigi) { + m_APDDigitizer->run(*apdResult, randomEngine_); + edm::LogInfo("DigiInfo") << "APD Digis: " << apdResult->size(); + } + } + + // Step D: Put outputs into event + if (m_apdSeparateDigi) { + //event.put(std::move(apdResult), m_apdDigiTag ) ; + } + + event.put(std::move(barrelResult), m_EBdigiCollection); + + randomEngine_ = nullptr; // to prevent access outside event +} + +void EcalDigiProducer_Ph2::beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& setup) { + edm::Service rng; + if (!rng.isAvailable()) { + throw cms::Exception("Configuration") << "RandomNumberGenerator service is not available.\n" + "You must add the service in the configuration file\n" + "or remove the module that requires it."; + } + CLHEP::HepRandomEngine* engine = &rng->getEngine(lumi.index()); + + if (m_doEB) { + if (nullptr != m_APDResponse) + m_APDResponse->initialize(engine); + m_EBResponse->initialize(engine); + } +} + +void EcalDigiProducer_Ph2::checkCalibrations(const edm::Event& event, const edm::EventSetup& eventSetup) { + // Pedestals from event setup + + edm::ESHandle dbPed; + eventSetup.get().get(dbPed); + const EcalLiteDTUPedestalsMap* pedestals(dbPed.product()); + + m_Coder->setPedestals(pedestals); + if (nullptr != m_APDCoder) + m_APDCoder->setPedestals(pedestals); + + // Ecal Intercalibration Constants + edm::ESHandle pIcal; + eventSetup.get().get(pIcal); + const EcalIntercalibConstantsMC* ical(pIcal.product()); + + m_Coder->setIntercalibConstants(ical); + if (nullptr != m_APDCoder) + m_APDCoder->setIntercalibConstants(ical); + + m_EBResponse->setIntercal(ical); + if (nullptr != m_APDResponse) + m_APDResponse->setIntercal(ical); + + // Ecal LaserCorrection Constants + edm::ESHandle laser; + eventSetup.get().get(laser); + const edm::TimeValue_t eventTimeValue = event.time().value(); + + m_EBResponse->setEventTime(eventTimeValue); + m_EBResponse->setLaserConstants(laser.product(), m_useLCcorrection); + + // ADC -> GeV Scale + edm::ESHandle pAgc; + eventSetup.get().get(pAgc); + const EcalADCToGeVConstant* agc = pAgc.product(); + + // Gain Ratios + edm::ESHandle pRatio; + eventSetup.get().get(pRatio); + const EcalCATIAGainRatios* gr = pRatio.product(); + m_Coder->setGainRatios(gr); + if (nullptr != m_APDCoder) + m_APDCoder->setGainRatios(gr); + + const double EBscale((agc->getEBValue()) * ecalPh2::gains[1] * (m_Coder->MAXADC) * m_EBs25notCont); + + LogDebug("EcalDigi") << " GeV/ADC = " << agc->getEBValue() << "\n" + << " notCont = " << m_EBs25notCont << "\n" + << " saturation for EB = " << EBscale << ", " << m_EBs25notCont; + + m_Coder->setFullScaleEnergy(EBscale); + if (nullptr != m_APDCoder) + m_APDCoder->setFullScaleEnergy(EBscale); +} + +void EcalDigiProducer_Ph2::checkGeometry(const edm::EventSetup& eventSetup) { + // TODO find a way to avoid doing this every event + edm::ESHandle hGeometry; + eventSetup.get().get(hGeometry); + + const CaloGeometry* pGeometry = &*hGeometry; + + if (pGeometry != m_Geometry) { + m_Geometry = pGeometry; + updateGeometry(); + } +} + +void EcalDigiProducer_Ph2::updateGeometry() { + if (m_doEB) { + if (nullptr != m_APDResponse) + m_APDResponse->setGeometry(m_Geometry->getSubdetectorGeometry(DetId::Ecal, EcalBarrel)); + m_EBResponse->setGeometry(m_Geometry->getSubdetectorGeometry(DetId::Ecal, EcalBarrel)); + } +} + +void EcalDigiProducer_Ph2::setEBNoiseSignalGenerator(EcalBaseSignalGenerator* noiseGenerator) { + //noiseGenerator->setParameterMap(theParameterMap); + if (nullptr != m_BarrelDigitizer) + m_BarrelDigitizer->setNoiseSignalGenerator(noiseGenerator); +} + +void EcalDigiProducer_Ph2::beginRun(edm::Run const& run, edm::EventSetup const& setup) { + m_EBShape.setEventSetup(setup); + m_APDShape.setEventSetup(setup); +} diff --git a/SimCalorimetry/EcalSimProducers/src/EcalTimeDigiProducer_Ph2.cc b/SimCalorimetry/EcalSimProducers/src/EcalTimeDigiProducer_Ph2.cc new file mode 100644 index 0000000000000..6c140c9e697b7 --- /dev/null +++ b/SimCalorimetry/EcalSimProducers/src/EcalTimeDigiProducer_Ph2.cc @@ -0,0 +1,122 @@ +#include "FWCore/Framework/interface/Event.h" +#include "SimCalorimetry/EcalSimProducers/interface/EcalTimeDigiProducer_Ph2.h" +#include "SimCalorimetry/EcalSimAlgos/interface/EcalTimeMapDigitizer.h" + +#include "CalibFormats/CaloObjects/interface/CaloSamples.h" + +#include "Geometry/CaloGeometry/interface/CaloGeometry.h" +#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" +#include "Geometry/Records/interface/CaloGeometryRecord.h" +#include "Geometry/EcalAlgo/interface/EcalEndcapGeometry.h" + +#include "FWCore/Framework/interface/ESHandle.h" +#include "DataFormats/Common/interface/Handle.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "SimGeneral/MixingModule/interface/PileUpEventPrincipal.h" + +//#define ecal_time_debug 1 + +EcalTimeDigiProducer_Ph2::EcalTimeDigiProducer_Ph2(const edm::ParameterSet& params, + edm::ProducesCollector producesCollector, + edm::ConsumesCollector& sumes) + : DigiAccumulatorMixMod(), + m_EBdigiCollection(params.getParameter("EBtimeDigiCollection")), + m_hitsProducerTagEB(params.getParameter("hitsProducerEB")), + m_hitsProducerTokenEB(sumes.consumes >(m_hitsProducerTagEB)), + m_timeLayerEB(params.getParameter("timeLayerBarrel")), + m_Geometry(nullptr) { + producesCollector.produces(m_EBdigiCollection); + + m_BarrelDigitizer = new EcalTimeMapDigitizer(EcalBarrel); + +#ifdef ECAL_TIME_DEBUG + std::cout << "[EcalTimeDigiProducer_Ph2]::Create EB " << m_EBdigiCollection << " collection and digitizer" + << std::endl; +#endif + + m_BarrelDigitizer->setTimeLayerId(m_timeLayerEB); +} + +EcalTimeDigiProducer_Ph2::~EcalTimeDigiProducer_Ph2() {} + +void EcalTimeDigiProducer_Ph2::initializeEvent(edm::Event const& event, edm::EventSetup const& eventSetup) { + checkGeometry(eventSetup); + // checkCalibrations( event, eventSetup ); + // here the methods to clean the maps + m_BarrelDigitizer->initializeMap(); +} + +void EcalTimeDigiProducer_Ph2::accumulateCaloHits(HitsHandle const& ebHandle, int bunchCrossing) { + // accumulate the simHits and do the averages in a given layer per bunch crossing + if (ebHandle.isValid()) { + m_BarrelDigitizer->add(*ebHandle.product(), bunchCrossing); + } +} + +void EcalTimeDigiProducer_Ph2::accumulate(edm::Event const& e, edm::EventSetup const& eventSetup) { + // Step A: Get Inputs + edm::Handle > ebHandle; + e.getByToken(m_hitsProducerTokenEB, ebHandle); + +#ifdef ecal_time_debug + std::cout << "[EcalTimeDigiProducer_Ph2]::Accumulate Hits HS event" << std::endl; +#endif + + accumulateCaloHits(ebHandle, 0); +} + +void EcalTimeDigiProducer_Ph2::accumulate(PileUpEventPrincipal const& e, + edm::EventSetup const& eventSetup, + edm::StreamID const&) { + edm::Handle > ebHandle; + e.getByLabel(m_hitsProducerTagEB, ebHandle); + +#ifdef ecal_time_debug + std::cout << "[EcalTimeDigiProducer_Ph2]::Accumulate Hits for BC " << e.bunchCrossing() << std::endl; +#endif + accumulateCaloHits(ebHandle, e.bunchCrossing()); +} + +void EcalTimeDigiProducer_Ph2::finalizeEvent(edm::Event& event, edm::EventSetup const& eventSetup) { + std::unique_ptr barrelResult(new EcalTimeDigiCollection()); + +#ifdef ecal_time_debug + std::cout << "[EcalTimeDigiProducer_Ph2]::finalizeEvent" << std::endl; +#endif + + // here basically just put everything in the final collections + m_BarrelDigitizer->run(*barrelResult); + +#ifdef ecal_time_debug + std::cout << "[EcalTimeDigiProducer_Ph2]::EB Digi size " << barrelResult->size() << std::endl; +#endif + + edm::LogInfo("TimeDigiInfo") << "EB time Digis: " << barrelResult->size(); + +#ifdef ecal_time_debug + std::cout << "[EcalTimeDigiProducer_Ph2]::putting collections into the event " << std::endl; +#endif + + event.put(std::move(barrelResult), m_EBdigiCollection); +} + +void EcalTimeDigiProducer_Ph2::checkGeometry(const edm::EventSetup& eventSetup) { + // TODO find a way to avoid doing this every event + edm::ESHandle hGeometry; + eventSetup.get().get(hGeometry); + + const CaloGeometry* pGeometry = &*hGeometry; + + if (pGeometry != m_Geometry) { + m_Geometry = pGeometry; + updateGeometry(); + } +} + +void EcalTimeDigiProducer_Ph2::updateGeometry() { + m_BarrelDigitizer->setGeometry(m_Geometry->getSubdetectorGeometry(DetId::Ecal, EcalBarrel)); +} diff --git a/SimCalorimetry/EcalSimProducers/test/SingleElectron_cfi_py_GEN_IDEAL_withECALDigi_Ph1.py b/SimCalorimetry/EcalSimProducers/test/SingleElectron_cfi_py_GEN_IDEAL_withECALDigi_Ph1.py new file mode 100644 index 0000000000000..3328646be4c20 --- /dev/null +++ b/SimCalorimetry/EcalSimProducers/test/SingleElectron_cfi_py_GEN_IDEAL_withECALDigi_Ph1.py @@ -0,0 +1,168 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: SingleElectronPt10_pythia8_cfi.py -s GEN,SIM,DIGI --conditions auto:mc --datatier GEN-SIM-RAW --eventcontent RECOSIM -n 10 --no_exec --python_filename SingleElectronPt10_cfi_py_GEN_IDEAL.py +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('DIGI')#,eras.phase2_common) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_cfi') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.Geometry.GeometrySimDB_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedRealistic50ns13TeVCollision_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.Digi_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(1) +) + +# Input source +process.source = cms.Source("EmptySource") + +process.options = cms.untracked.PSet( + SkipEvent = cms.untracked.vstring('ProductNotFound') +) + + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('SingleElectronPt10_pythia8_cfi.py nevts:10'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.RECOSIMoutput = cms.OutputModule("PoolOutputModule", + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-RAW'), + filterName = cms.untracked.string('') + ), + fileName = cms.untracked.string('SingleElectronPt10_pythia8_cfi_py_GEN_SIM_DIGI_Pt10_Ph1.root'), +# outputCommands = process.RECOSIMEventContent.outputCommands, + outputCommands = cms.untracked.vstring('keep *', + 'drop *_mix_*_*'), + splitLevel = cms.untracked.int32(1) +) + +#process.RECOSIMoutput.outputCommands.append('keep EBDigiCollection_ecalDigis_*_*') + + + +# Additional output definition + + +# Other statements +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:mc', '') + +process.generator = cms.EDFilter("Pythia8PtGun", + PGunParameters = cms.PSet( + AddAntiParticle = cms.bool(True), + MaxEta = cms.double(1.43), + MaxPhi = cms.double(3.14159265359), + #MaxPt = cms.double(300.01), + MaxPt = cms.double(1110.01), + MinEta = cms.double(1.42), + MinPhi = cms.double(-3.14159265359), + #MinPt = cms.double(299.99), + MinPt = cms.double(1109.99), + ParticleID = cms.vint32(11) + ), + PythiaParameters = cms.PSet( + parameterSets = cms.vstring() + ), + Verbosity = cms.untracked.int32(0), + firstRun = cms.untracked.uint32(1), + psethack = cms.string('single electron pt 10') +) + + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.digitisation_step = cms.Path(process.pdigi) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.RECOSIMoutput_step = cms.EndPath(process.RECOSIMoutput) + + + +##CondCore.CondDB.CondDB_cfi +#from CondCore.DBCommon.CondDBSetup_cfi import * +##from CondCore.CondDB.CondDB_cfi import * +#process.ecalConditions = cms.ESSource("PoolDBESSource", CondDBSetup, +# connect = cms.string('frontier://FrontierProd/CMS_COND_31X_ECAL'), +# #connect = cms.string('oracle://cms_orcoff_prep/CMS_COND_ECAL'), +# #authpath = cms.string('/afs/cern.ch/cms/DB/conddb'), +# connect = cms.string('sqlite_file:/afs/cern.ch/user/d/dsoldi/work/CMS/CMSEcal_Phase2_Ultimate/CMSSW_10_6_1/src/SimCalorimetry/EcalSimProducers/test/simPulseShapePhaseII.db'), +# +# toGet = cms.VPSet( # overide Global Tag use EcalTBWeights_EBEE_offline +# cms.PSet( +# record = cms.string('EcalSimPulseShapeRcd') , +# tag = cms.string('EcalSimPulseShape_default_mc') +# ) +# ) +#) +#process.es_prefer_ecalPulseShape = cms.ESPrefer("PoolDBESSource","ecalConditions") +# +#process.EcalCATIAGainRatiosESProducer = cms.ESProducer( +# "EcalCATIAGainRatiosESProducer", +# ComponentName = cms.string('testGainProducer') +#) +# +#process.EcalLiteDTUPedestalsESProducer = cms.ESProducer( +# "EcalLiteDTUPedestalsESProducer", +# ComponentName = cms.string('testPedestalProducer') +#) + +#LOGGER: +process.MessageLogger.cout = cms.untracked.PSet( + threshold = cms.untracked.string("DEBUG"), + default = cms.untracked.PSet( limit = cms.untracked.int32(0) ), + FwkReport = cms.untracked.PSet( limit = cms.untracked.int32(-1) ), +) + + +#process.es_prefer_EcalCATIAGainRatioESProducer = cms.ESPrefer("EcalCATIAGainRatioESProducer","EcalCATIAGainRatioESProducer") + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.digitisation_step,process.endjob_step,process.RECOSIMoutput_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path)._seq = process.generator * getattr(process,path)._seq + + +# Customisation from command line + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion + + + + + + + diff --git a/SimCalorimetry/EcalSimProducers/test/SingleElectron_cfi_py_GEN_IDEAL_withECALDigi_newshape.py b/SimCalorimetry/EcalSimProducers/test/SingleElectron_cfi_py_GEN_IDEAL_withECALDigi_newshape.py new file mode 100644 index 0000000000000..a5a87a3898a60 --- /dev/null +++ b/SimCalorimetry/EcalSimProducers/test/SingleElectron_cfi_py_GEN_IDEAL_withECALDigi_newshape.py @@ -0,0 +1,171 @@ +# Auto generated configuration file +# using: +# Revision: 1.19 +# Source: /local/reps/CMSSW/CMSSW/Configuration/Applications/python/ConfigBuilder.py,v +# with command line options: SingleElectronPt10_pythia8_cfi.py -s GEN,SIM,DIGI --conditions auto:mc --datatier GEN-SIM-RAW --eventcontent RECOSIM -n 10 --no_exec --python_filename SingleElectronPt10_cfi_py_GEN_IDEAL.py +import FWCore.ParameterSet.Config as cms + +from Configuration.StandardSequences.Eras import eras + +process = cms.Process('DIGI',eras.phase2_common) + +# import of standard configurations +process.load('Configuration.StandardSequences.Services_cff') +process.load('SimGeneral.HepPDTESSource.pythiapdt_cfi') +process.load('FWCore.MessageService.MessageLogger_cfi') +process.load('SimCalorimetry.EcalSimProducers.esCATIAGainProducer_cfi') +process.load('SimCalorimetry.EcalSimProducers.esEcalLiteDTUPedestalsProducer_cfi') +process.load('Configuration.EventContent.EventContent_cff') +process.load('SimGeneral.MixingModule.mixNoPU_Ph2_cfi') +process.load('Configuration.StandardSequences.GeometryRecoDB_cff') +process.load('Configuration.Geometry.GeometrySimDB_cff') +process.load('Configuration.StandardSequences.MagneticField_cff') +process.load('Configuration.StandardSequences.Generator_cff') +process.load('IOMC.EventVertexGenerators.VtxSmearedRealistic50ns13TeVCollision_cfi') +process.load('Calibration.EcalCalibAlgos.ecalPedestalPCLHarvester_cfi') +process.load('GeneratorInterface.Core.genFilterSummary_cff') +process.load('Configuration.StandardSequences.SimIdeal_cff') +process.load('Configuration.StandardSequences.Digi_Ph2_cff') +process.load('Configuration.StandardSequences.EndOfProcess_cff') +process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff') + +process.maxEvents = cms.untracked.PSet( + input = cms.untracked.int32(3) +) + +# Input source +process.source = cms.Source("EmptySource") + +process.options = cms.untracked.PSet( + SkipEvent = cms.untracked.vstring('ProductNotFound') +) + + +# Production Info +process.configurationMetadata = cms.untracked.PSet( + annotation = cms.untracked.string('SingleElectronPt10_pythia8_cfi.py nevts:10'), + name = cms.untracked.string('Applications'), + version = cms.untracked.string('$Revision: 1.19 $') +) + +# Output definition + +process.RECOSIMoutput = cms.OutputModule("PoolOutputModule", + SelectEvents = cms.untracked.PSet( + SelectEvents = cms.vstring('generation_step') + ), + dataset = cms.untracked.PSet( + dataTier = cms.untracked.string('GEN-SIM-RAW'), + filterName = cms.untracked.string('') + ), + fileName = cms.untracked.string('SingleElectronPt10_pythia8_cfi_py_GEN_SIM_DIGI_Pt10.root'), +# outputCommands = process.RECOSIMEventContent.outputCommands, + outputCommands = cms.untracked.vstring('keep *', + 'drop *_mix_*_*'), + splitLevel = cms.untracked.int32(1) +) + +#process.RECOSIMoutput.outputCommands.append('keep EBDigiCollection_ecalDigis_*_*') + + + +# Additional output definition + + +# Other statements +process.genstepfilter.triggerConditions=cms.vstring("generation_step") +from Configuration.AlCa.GlobalTag import GlobalTag +process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:mc', '') + +process.generator = cms.EDFilter("Pythia8PtGun", + PGunParameters = cms.PSet( + AddAntiParticle = cms.bool(True), + MaxEta = cms.double(1.43), + MaxPhi = cms.double(3.14159265359), + #MaxPt = cms.double(300.01), + MaxPt = cms.double(10.01), + MinEta = cms.double(1.42), + MinPhi = cms.double(-3.14159265359), + #MinPt = cms.double(299.99), + MinPt = cms.double(9.99), + ParticleID = cms.vint32(11) + ), + PythiaParameters = cms.PSet( + parameterSets = cms.vstring() + ), + Verbosity = cms.untracked.int32(0), + firstRun = cms.untracked.uint32(1), + psethack = cms.string('single electron pt 10') +) + + +# Path and EndPath definitions +process.generation_step = cms.Path(process.pgen) +process.simulation_step = cms.Path(process.psim) +process.digitisation_step = cms.Path(process.pdigi) +process.genfiltersummary_step = cms.EndPath(process.genFilterSummary) +process.endjob_step = cms.EndPath(process.endOfProcess) +process.RECOSIMoutput_step = cms.EndPath(process.RECOSIMoutput) + + + +#CondCore.CondDB.CondDB_cfi +from CondCore.DBCommon.CondDBSetup_cfi import * +#from CondCore.CondDB.CondDB_cfi import * +process.ecalConditions = cms.ESSource("PoolDBESSource", CondDBSetup, + #connect = cms.string('frontier://FrontierProd/CMS_COND_31X_ECAL'), + #connect = cms.string('oracle://cms_orcoff_prep/CMS_COND_ECAL'), + #authpath = cms.string('/afs/cern.ch/cms/DB/conddb'), + connect = cms.string('sqlite_file:SimCalorimetry/EcalSimProducers/test/simPulseShapePhaseII.db'), + + toGet = cms.VPSet( # overide Global Tag use EcalTBWeights_EBEE_offline + cms.PSet( + record = cms.string('EcalSimPulseShapeRcd') , + tag = cms.string('EcalSimPulseShape_default_mc') + ) + ) +) +process.es_prefer_ecalPulseShape = cms.ESPrefer("PoolDBESSource","ecalConditions") + +process.EcalCATIAGainRatiosESProducer = cms.ESProducer( + "EcalCATIAGainRatiosESProducer", + ComponentName = cms.string('testGainProducer') +) + +process.EcalLiteDTUPedestalsESProducer = cms.ESProducer( + "EcalLiteDTUPedestalsESProducer", + ComponentName = cms.string('testPedestalProducer') +) + +#LOGGER: +process.MessageLogger.cout = cms.untracked.PSet( + threshold = cms.untracked.string("DEBUG"), + default = cms.untracked.PSet( limit = cms.untracked.int32(0) ), + FwkReport = cms.untracked.PSet( limit = cms.untracked.int32(-1) ), +) + + +#process.es_prefer_EcalCATIAGainRatioESProducer = cms.ESPrefer("EcalCATIAGainRatioESProducer","EcalCATIAGainRatioESProducer") + +# Schedule definition +process.schedule = cms.Schedule(process.generation_step,process.genfiltersummary_step,process.simulation_step,process.digitisation_step,process.endjob_step,process.RECOSIMoutput_step) +from PhysicsTools.PatAlgos.tools.helpers import associatePatAlgosToolsTask +associatePatAlgosToolsTask(process) +# filter all path with the production filter sequence +for path in process.paths: + getattr(process,path)._seq = process.generator * getattr(process,path)._seq + + +# Customisation from command line + +# Add early deletion of temporary data products to reduce peak memory need +from Configuration.StandardSequences.earlyDeleteSettings_cff import customiseEarlyDelete +process = customiseEarlyDelete(process) +# End adding early deletion + + + + + + + diff --git a/SimCalorimetry/EcalSimProducers/test/simPulseShapePhaseII.db b/SimCalorimetry/EcalSimProducers/test/simPulseShapePhaseII.db new file mode 100644 index 0000000000000..cb5f462c0aa47 Binary files /dev/null and b/SimCalorimetry/EcalSimProducers/test/simPulseShapePhaseII.db differ diff --git a/SimCalorimetry/PhaseIAnalyzer/plugins/BuildFile.xml b/SimCalorimetry/PhaseIAnalyzer/plugins/BuildFile.xml new file mode 100644 index 0000000000000..07215bd4b10a5 --- /dev/null +++ b/SimCalorimetry/PhaseIAnalyzer/plugins/BuildFile.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/SimCalorimetry/PhaseIAnalyzer/plugins/PhaseIAnalyzer.cc b/SimCalorimetry/PhaseIAnalyzer/plugins/PhaseIAnalyzer.cc new file mode 100644 index 0000000000000..e2dd31decad96 --- /dev/null +++ b/SimCalorimetry/PhaseIAnalyzer/plugins/PhaseIAnalyzer.cc @@ -0,0 +1,254 @@ +// -*- C++ -*- +// +// Package: PhaseI/PhaseIAnalyzer +// Class: PhaseIAnalyzer +// +/**\class PhaseIAnalyzer PhaseIAnalyzer.cc PhaseI/PhaseIAnalyzer/plugins/PhaseIAnalyzer.cc + + Description: [one line class summary] + + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Dario Soldi +// Created: Tue, 16 Jan 2018 11:56:05 GMT +// +// + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +//My includes +#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" +#include "CondFormats/EcalObjects/interface/EcalPedestals.h" +#include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h" +#include "CondFormats/DataRecord/interface/EcalIntercalibConstantsMCRcd.h" +#include "CondFormats/EcalObjects/interface/EcalIntercalibConstantsMC.h" + +#include "PhaseIAnalyzer.h" + +#include "DataFormats/EcalDetId/interface/EBDetId.h" +#include "DataFormats/EcalDetId/interface/EEDetId.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "SimDataFormats/CaloHit/interface/PCaloHit.h" + +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" +#include "SimDataFormats/Track/interface/SimTrack.h" +#include "CondFormats/EcalObjects/interface/EcalConstants.h" + +using namespace std; +using namespace edm; + +// +// constants, enums and typedefs +// + +// +// static data member definitions +// + +// +// constructors and destructor +// + +PhaseIAnalyzer::PhaseIAnalyzer(const edm::ParameterSet& iConfig) { + //now do what ever initialization is needed + usesResource("TFileService"); + + digiTagEB_ = iConfig.getParameter("BarrelDigis"); + + digiTokenEB_ = consumes(digiTagEB_); + + //Files: + edm::Service fs; + //Histograms + + for (unsigned int isample = 0; isample < ecalPh1::sampleSize; isample++) { + EBEnergyHisto[isample] = + fs->make(Form("EnergyEB_%d", isample), Form("Energy sample %d Barrel;ADC", isample), 950, 100, 2000); + EBGainHisto[isample] = + fs->make(Form("GainEB_%d", isample), Form("Gain Barrel sample %d;Gain", isample), 5, 0, 4); + } + SingleChannelE = fs->make("SingleChannelE", "Energy single channel Barrel;ADC", 17, -0.5, 16.5); + SingleChannelELow = fs->make("SingleChannelELow", "Energy single channel Barrel;ADC", 17, -0.5, 16.5); + + Char_t histo[200]; + + sprintf(histo, "EcalDigiTaskBarrelOccupancy"); + meEBDigiOccupancy_ = fs->make(histo, histo, 360, 0., 360., 170, -85., 85.); + + sprintf(histo, "EcalDigiTaskBarrelOccupancyHigh"); + meEBDigiOccupancyHigh_ = fs->make(histo, histo, 360, 0., 360., 170, -85., 85.); + + sprintf(histo, "EcalDigiTaskBarrelOccupancyLow"); + meEBDigiOccupancyLow_ = fs->make(histo, histo, 360, 0., 360., 170, -85., 85.); + + sprintf(histo, "EcalDigiTaskBarrelOccupancyMid"); + meEBDigiOccupancyMid_ = fs->make(histo, histo, 360, 0., 360., 170, -85., 85.); + + sprintf(histo, "EcalDigiTaskBarrelDigisMultiplicity"); + meEBDigiMultiplicity_ = fs->make(histo, histo, 612, 0., 61200); + + for (unsigned int i = 0; i < ecalPh1::sampleSize; i++) { + sprintf(histo, "EcalDigiTaskBarrelAnalogPulse%02d", i + 1); + meEBDigiADCAnalog_[i] = fs->make(histo, histo, 4000, 0., 400.); + + sprintf(histo, "EcalDigiTaskBarrelADCPulse%02dGain0_Saturated", i + 1); + meEBDigiADCgS_[i] = fs->make(histo, histo, 4096, -0.5, 4095.5); + sprintf(histo, "EcalDigiTaskBarrelGainPulse%02d", i + 1); + meEBDigiGain_[i] = fs->make(histo, histo, 4, 0, 4); + } + + sprintf(histo, "EcalDigiTaskBarrelPedestalForPreSample"); + meEBPedestal_ = fs->make(histo, histo, 4096, -0.5, 4095.5); + + sprintf(histo, "EcalDigiTaskBarrelMaximumPositionGt100ADC"); + meEBMaximumgt100ADC_ = fs->make(histo, histo, 10, 0., 10.); + + sprintf(histo, "EcalDigiTaskBarrelMaximumPositionGt10ADC"); + meEBMaximumgt10ADC_ = fs->make(histo, histo, 10, 0., 10.); + + // sprintf (histo, "EcalDigiTask Barrel ADC counts after gain switch" ) ; + //meEBnADCafterSwitch_ = fs->makehisto, histo, 10, 0., 10.) ; +} + +PhaseIAnalyzer::~PhaseIAnalyzer() { + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) +} + +// +// member functions +// + +// ------------ method called for each event ------------ +void PhaseIAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + Handle pDigiEB; + iEvent.getByToken(digiTokenEB_, pDigiEB); + + std::vector ebAnalogSignal; + std::vector ebADCCounts; + std::vector ebADCGains_temp; + std::vector ebADCGains; + + ebAnalogSignal.reserve(EBDataFrame::MAXSAMPLES); + ebADCCounts.reserve(EBDataFrame::MAXSAMPLES); + ebADCGains_temp.reserve(EBDataFrame::MAXSAMPLES); + ebADCGains.reserve(EBDataFrame::MAXSAMPLES); + + int nDigis = 0; + int LowGain(0), MidGain(0), HighGain(0); + int maxADCValue = 0; + + for (EBDigiCollection::const_iterator pDigi = pDigiEB->begin(); pDigi != pDigiEB->end(); ++pDigi) { + LowGain = 0; + MidGain = 0; + HighGain = 0; + maxADCValue = 0; + + EBDataFrame digi(*pDigi); + int nrSamples = digi.size(); + std::cout << "NSamples found: " << nrSamples << std::endl; + EBDetId ebid = digi.id(); + std::cout << " Crystall ID " << ebid << std::endl; + nDigis++; + std::cout << " nDigis aaaaaaa " << nDigis << std::endl; + double Emax = 0.; + int Pmax = 0; + //double pedestalPreSample = 0.; + //double pedestalPreSampleAnalog = 0.; + //int countsAfterGainSwitch = -1; + + for (int sample = 0; sample < nrSamples; ++sample) { + ebAnalogSignal[sample] = 0.; + ebADCCounts[sample] = 0.; + ebADCGains_temp[sample] = 0.; + ebADCGains[sample] = 0.; + } + + double gainConv_[4] = {0, 12, 6, 1}; + // saturated channels + double barrelADCtoGeV_ = 0.048; //GeV + + // EcalIntercalibConstantsMC* ical = + + // EcalIntercalibConstantMCMap &icalMap = + + for (int sample = 0; sample < nrSamples; ++sample) { + int thisSample = digi[sample]; + + ebADCCounts[sample] = (thisSample & 0xFFF); + ebADCGains[sample] = (thisSample & (0x3 << 12)) >> 12; + ebAnalogSignal[sample] = (ebADCCounts[sample] * gainConv_[(int)ebADCGains[sample]] * barrelADCtoGeV_); + + if (ebADCCounts[sample] > maxADCValue) + maxADCValue = ebADCCounts[sample]; + + if (ebid.iphi() == 333 and ebid.ieta() == 83) + SingleChannelE->SetBinContent(sample, ebADCCounts[sample]); + + if (ebid.iphi() == 334 and ebid.ieta() == 83) { + SingleChannelELow->SetBinContent(sample, ebADCCounts[sample]); + } + + if (ebADCGains[sample] == 3) + LowGain = 1; + if (ebADCGains[sample] == 2) + MidGain = 1; + if (ebADCGains[sample] == 1) + HighGain = 1; + + if (ebADCCounts[sample] > 250) { + std::cout << "Channel: " << ebid << std::endl; + std::cout << "Sample " << sample << std::endl; + std::cout << " Full data " << thisSample << std::endl; + std::cout << " ebADCCounts " << ebADCCounts[sample] << std::endl; + std::cout << " ebADCGains " << ebADCGains[sample] << std::endl; + std::cout << " gainConv_ " << gainConv_[(int)ebADCGains[sample]] << std::endl; + std::cout << " barrelADCtoGeV_ " << barrelADCtoGeV_ << std::endl; + std::cout << " ebAnalogSignal " << ebAnalogSignal[sample] << std::endl; + } + + if (Emax < ebAnalogSignal[sample]) { + Emax = ebAnalogSignal[sample]; + Pmax = sample; + } + } + + if (1 == 1) + std::cout << "P max " << Pmax << std::endl; + std::cout << "High Gain: " << HighGain << " MidGain " << MidGain << " LowGain " << LowGain << std::endl; + std::cout << "maxADCValue " << maxADCValue << std::endl; + if (maxADCValue > 250) { + meEBDigiOccupancy_->SetBinContent(ebid.iphi(), ebid.ieta(), maxADCValue); + if (HighGain == 1) + meEBDigiOccupancyHigh_->SetBinContent(ebid.iphi(), ebid.ieta(), maxADCValue); + if (MidGain == 1) + meEBDigiOccupancyMid_->SetBinContent(ebid.iphi(), ebid.ieta(), maxADCValue); + if (LowGain == 1) + meEBDigiOccupancyLow_->SetBinContent(ebid.iphi(), ebid.ieta(), maxADCValue); + } + + } //end digi +} + +// ------------ method called once each job just before starting event loop ------------ +void PhaseIAnalyzer::beginJob() {} + +// ------------ method called once each job just after ending the event loop ------------ +void PhaseIAnalyzer::endJob() {} + +//define this as a plug-in +DEFINE_FWK_MODULE(PhaseIAnalyzer); diff --git a/SimCalorimetry/PhaseIAnalyzer/plugins/PhaseIAnalyzer.h b/SimCalorimetry/PhaseIAnalyzer/plugins/PhaseIAnalyzer.h new file mode 100644 index 0000000000000..d4800aed12fac --- /dev/null +++ b/SimCalorimetry/PhaseIAnalyzer/plugins/PhaseIAnalyzer.h @@ -0,0 +1,71 @@ +#ifndef SimCalorimetry_PhaseIAnalyzer_PhaseIAnalyzer_h +#define SimCalorimetry_PhaseIAnalyzer_PhaseIAnalyzer_h + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" +#include "SimDataFormats/CaloHit/interface/PCaloHit.h" +#include "TH1.h" +#include "TH2.h" +#include "SimDataFormats/Track/interface/SimTrack.h" +#include +#include "CondFormats/EcalObjects/interface/EcalConstants.h" + +// +// class declaration +// + +class PhaseIAnalyzer : public edm::one::EDAnalyzer { +public: + explicit PhaseIAnalyzer(const edm::ParameterSet&); + ~PhaseIAnalyzer(); + +private: + virtual void beginJob(); + void analyze(const edm::Event&, const edm::EventSetup&) override; + virtual void endJob(); + + edm::InputTag digiTagEB_; + + edm::EDGetTokenT digiTokenEB_; + + edm::InputTag hitTagEB_; + + edm::EDGetTokenT> hitTokenEB_; + + edm::InputTag trackTag_; + edm::EDGetTokenT> trackToken_; + + //Histograms + TH1I* EBEnergyHisto[ecalPh2::sampleSize]; + TH1I* EBGainHisto[ecalPh2::sampleSize]; + + TH2D* meEBDigiOccupancy_; + TH2D* meEBDigiOccupancyHigh_; + TH2D* meEBDigiOccupancyMid_; + TH2D* meEBDigiOccupancyLow_; + + TH1D* meEBDigiMultiplicity_; + + TH1D* meEBDigiADCGlobal_; + + TH1I* SingleChannelE; + TH1I* SingleChannelELow; + + TH1D* meEBDigiADCAnalog_[ecalPh2::sampleSize]; + TH1D* meEBDigiADCgS_[ecalPh2::sampleSize]; + TH1D* meEBDigiGain_[ecalPh2::sampleSize]; + + TH1D* meEBPedestal_; + + TH1D* meEBMaximumgt100ADC_; + + TH1D* meEBMaximumgt10ADC_; + + TH1D* meEBnADCafterSwitch_; +}; + +#endif diff --git a/SimCalorimetry/PhaseIAnalyzer/python/CfiFile_cfi.py b/SimCalorimetry/PhaseIAnalyzer/python/CfiFile_cfi.py new file mode 100644 index 0000000000000..be67c535ef270 --- /dev/null +++ b/SimCalorimetry/PhaseIAnalyzer/python/CfiFile_cfi.py @@ -0,0 +1,5 @@ +import FWCore.ParameterSet.Config as cms + +phaseI = cms.EDAnalyzer('PhaseIAnalyzer', + BarrelDigis=cms.InputTag('simEcalUnsuppressedDigis','','DIGI') +) diff --git a/SimCalorimetry/PhaseIAnalyzer/test/run_PhaseIAnalyzer.py b/SimCalorimetry/PhaseIAnalyzer/test/run_PhaseIAnalyzer.py new file mode 100644 index 0000000000000..bc2cfc24e21f7 --- /dev/null +++ b/SimCalorimetry/PhaseIAnalyzer/test/run_PhaseIAnalyzer.py @@ -0,0 +1,33 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("PhaseI") + +#Print out: +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.MessageLogger.cerr.threshold = 'INFO' +process.MessageLogger.categories.append('PhaseIAnalyzer') +process.MessageLogger.cerr.INFO = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) ) + + + +#Max event +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) + +#input: +process.source = cms.Source("PoolSource", + + fileNames = cms.untracked.vstring('file:../../../SimCalorimetry/EcalSimProducers/test/SingleElectronPt10_pythia8_cfi_py_GEN_SIM_DIGI_Pt10_Ph1.root'), + + ) + +process.phaseI = cms.EDAnalyzer('PhaseIAnalyzer') +process.TFileService = cms.Service("TFileService", + fileName = cms.string('Digitizer1.root') + ) +process.load("SimCalorimetry.PhaseIAnalyzer.CfiFile_cfi") + +#Running process: +process.p = cms.Path(process.phaseI) diff --git a/SimCalorimetry/PhaseIIAnalyzer/plugins/BuildFile.xml b/SimCalorimetry/PhaseIIAnalyzer/plugins/BuildFile.xml new file mode 100644 index 0000000000000..07215bd4b10a5 --- /dev/null +++ b/SimCalorimetry/PhaseIIAnalyzer/plugins/BuildFile.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/SimCalorimetry/PhaseIIAnalyzer/plugins/PhaseIIAnalyzer.cc b/SimCalorimetry/PhaseIIAnalyzer/plugins/PhaseIIAnalyzer.cc new file mode 100644 index 0000000000000..f657f154962d9 --- /dev/null +++ b/SimCalorimetry/PhaseIIAnalyzer/plugins/PhaseIIAnalyzer.cc @@ -0,0 +1,243 @@ +// -*- C++ -*- +// +// Package: PhaseII/PhaseIIAnalyzer +// Class: PhaseIIAnalyzer +// +/**\class PhaseIIAnalyzer PhaseIIAnalyzer.cc PhaseII/PhaseIIAnalyzer/plugins/PhaseIIAnalyzer.cc + Description: [one line class summary] + Implementation: + [Notes on implementation] +*/ +// +// Original Author: Dario Soldi +// Created: Tue, 16 Jan 2018 11:56:05 GMT +// +// + +// system include files +#include + +// user include files +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" + +//My includes +#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" +#include "CondFormats/EcalObjects/interface/EcalPedestals.h" +#include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h" +#include "CondFormats/EcalObjects/interface/EcalLiteDTUPedestals.h" +#include "CondFormats/DataRecord/interface/EcalLiteDTUPedestalsRcd.h" +#include "CondFormats/DataRecord/interface/EcalIntercalibConstantsMCRcd.h" +#include "CondFormats/EcalObjects/interface/EcalIntercalibConstantsMC.h" + +#include "PhaseIIAnalyzer.h" + +#include "DataFormats/EcalDetId/interface/EBDetId.h" +#include "DataFormats/EcalDetId/interface/EEDetId.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "SimDataFormats/CaloHit/interface/PCaloHit.h" + +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "CommonTools/UtilAlgos/interface/TFileService.h" +#include "SimDataFormats/Track/interface/SimTrack.h" +#include "CondFormats/EcalObjects/interface/EcalConstants.h" + +using namespace std; +using namespace edm; + +// +// constants, enums and typedefs +// + +// +// static data member definitions +// + +// +// constructors and destructor +// + +PhaseIIAnalyzer::PhaseIIAnalyzer(const edm::ParameterSet& iConfig) { + //now do what ever initialization is needed + usesResource("TFileService"); + + digiTagEB_ = iConfig.getParameter("BarrelDigis"); + + digiTokenEB_ = consumes(digiTagEB_); + + //Files: + edm::Service fs; + //Histograms + + for (unsigned int isample = 0; isample < ecalPh2::sampleSize; isample++) { + EBEnergyHisto[isample] = + fs->make(Form("EnergyEB_%d", isample), Form("Energy sample %d Barrel;ADC", isample), 950, 100, 2000); + EBGainHisto[isample] = + fs->make(Form("GainEB_%d", isample), Form("Gain Barrel sample %d;Gain", isample), 5, 0, 4); + } + + SingleChannelE = fs->make("SingleChannelE", "Energy single channel Barrel;ADC", 17, -0.5, 16.5); + SingleChannelELow = fs->make("SingleChannelELow", "Energy single channel Barrel;ADC", 17, -0.5, 16.5); + + Char_t histo[200]; + + sprintf(histo, "EcalDigiTaskBarrelOccupancy"); + meEBDigiOccupancy_ = fs->make(histo, histo, 360, 0., 360., 170, -85., 85.); + + sprintf(histo, "EcalDigiTaskBarrelOccupancyHigh"); + meEBDigiOccupancyHigh_ = fs->make(histo, histo, 360, 0., 360., 170, -85., 85.); + + sprintf(histo, "EcalDigiTaskBarrelOccupancyLow"); + meEBDigiOccupancyLow_ = fs->make(histo, histo, 360, 0., 360., 170, -85., 85.); + + sprintf(histo, "EcalDigiTaskBarrelDigisMultiplicity"); + meEBDigiMultiplicity_ = fs->make(histo, histo, 612, 0., 61200); + + for (unsigned int i = 0; i < ecalPh2::sampleSize; i++) { + sprintf(histo, "EcalDigiTaskBarrelAnalogPulse%02d", i + 1); + meEBDigiADCAnalog_[i] = fs->make(histo, histo, 4000, 0., 400.); + + sprintf(histo, "EcalDigiTaskBarrelADCPulse%02dGain0_Saturated", i + 1); + meEBDigiADCgS_[i] = fs->make(histo, histo, 4096, -0.5, 4095.5); + sprintf(histo, "EcalDigiTaskBarrelGainPulse%02d", i + 1); + meEBDigiGain_[i] = fs->make(histo, histo, 4, 0, 4); + } + + sprintf(histo, "EcalDigiTaskBarrelPedestalForPreSample"); + meEBPedestal_ = fs->make(histo, histo, 4096, -0.5, 4095.5); + + sprintf(histo, "EcalDigiTaskBarrelMaximumPositionGt100ADC"); + meEBMaximumgt100ADC_ = fs->make(histo, histo, 10, 0., 10.); + + sprintf(histo, "EcalDigiTaskBarrelMaximumPositionGt10ADC"); + meEBMaximumgt10ADC_ = fs->make(histo, histo, 10, 0., 10.); + + // sprintf (histo, "EcalDigiTask Barrel ADC counts after gain switch" ) ; + //meEBnADCafterSwitch_ = fs->makehisto, histo, 10, 0., 10.) ; +} + +PhaseIIAnalyzer::~PhaseIIAnalyzer() { + // do anything here that needs to be done at desctruction time + // (e.g. close files, deallocate resources etc.) +} + +// +// member functions +// + +// ------------ method called for each event ------------ +void PhaseIIAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + Handle pDigiEB; + iEvent.getByToken(digiTokenEB_, pDigiEB); + + std::vector ebAnalogSignal; + std::vector ebADCCounts; + std::vector ebADCGains_temp; + std::vector ebADCGains; + + ebAnalogSignal.reserve(EBDataFrame::MAXSAMPLES); + ebADCCounts.reserve(EBDataFrame::MAXSAMPLES); + ebADCGains_temp.reserve(EBDataFrame::MAXSAMPLES); + ebADCGains.reserve(EBDataFrame::MAXSAMPLES); + + int nDigis = 0; + int maxADCValue = 0; + int LowGain = 0; + double gainConv_[2] = {10, 1}; + double barrelADCtoGeV_ = 0.048; //GeV + + for (EBDigiCollectionPh2::const_iterator pDigi = pDigiEB->begin(); pDigi != pDigiEB->end(); ++pDigi) { + maxADCValue = 0; + LowGain = 0; + + EBDataFrame digi(*pDigi); + int nrSamples = digi.size(); + EBDetId ebid = digi.id(); + nDigis++; + + edm::ESHandle peds; + iSetup.get().get(peds); + + double Emax = 0.; + int Pmax = 0; + //double pedestalPreSample = 0.; + //double pedestalPreSampleAnalog = 0.; + //int countsAfterGainSwitch = -1; + //double higherGain = 1.; + + for (int sample = 0; sample < nrSamples; ++sample) { + ebAnalogSignal[sample] = 0.; + ebADCCounts[sample] = 0.; + ebADCGains_temp[sample] = 0.; + ebADCGains[sample] = 0.; + } + + // EcalIntercalibConstantsMC* ical = + + // EcalIntercalibConstantMCMap &icalMap = + + for (int sample = 0; sample < nrSamples; ++sample) { + int thisSample = digi[sample]; + + ebADCCounts[sample] = (thisSample & 0xFFF); + ebADCGains[sample] = (thisSample & (0x3 << 12)) >> 12; + ebAnalogSignal[sample] = (ebADCCounts[sample] * gainConv_[(int)ebADCGains[sample]] * barrelADCtoGeV_); + + if (ebADCCounts[sample] > maxADCValue) + maxADCValue = ebADCCounts[sample]; + + if (ebADCGains[sample] == 1) + LowGain = 1; + + if (ebid.iphi() == 333 and ebid.ieta() == 83) { + SingleChannelE->SetBinContent(sample, ebADCCounts[sample]); + } + if (ebid.iphi() == 333 and ebid.ieta() == 83) { + SingleChannelELow->SetBinContent(sample, ebADCCounts[sample]); + } + if (ebADCCounts[sample] > 27) { + std::cout << "Channel: " << ebid << std::endl; + std::cout << "Sample " << sample << std::endl; + std::cout << "Full data " << thisSample << std::endl; + std::cout << "ebADCCounts " << ebADCCounts[sample] << std::endl; + std::cout << "ebADCGains " << ebADCGains[sample] << std::endl; + std::cout << "gainConv_ " << gainConv_[(int)ebADCGains[sample]] << std::endl; + std::cout << "barrelADCtoGeV_ " << barrelADCtoGeV_ << std::endl; + std::cout << "ebAnalogSignal " << ebAnalogSignal[sample] << std::endl; + std::cout << "LowGain " << LowGain << std::endl; + } + + if (Emax < ebAnalogSignal[sample]) { + Emax = ebAnalogSignal[sample]; + Pmax = sample; + } + + } // end samples + if (maxADCValue > 27.5) { + std::cout << "Filling Histo: " << LowGain << std::endl; + meEBDigiOccupancy_->SetBinContent(ebid.iphi(), ebid.ieta(), maxADCValue); + if (LowGain == 0) + meEBDigiOccupancyHigh_->SetBinContent(ebid.iphi(), ebid.ieta(), maxADCValue); + else + meEBDigiOccupancyLow_->SetBinContent(ebid.iphi(), ebid.ieta(), maxADCValue); + } + + if (0 == 1) + std::cout << "P max " << Pmax << std::endl; + } //end digi +} + +// ------------ method called once each job just before starting event loop ------------ +void PhaseIIAnalyzer::beginJob() {} + +// ------------ method called once each job just after ending the event loop ------------ +void PhaseIIAnalyzer::endJob() {} + +//define this as a plug-in +DEFINE_FWK_MODULE(PhaseIIAnalyzer); diff --git a/SimCalorimetry/PhaseIIAnalyzer/plugins/PhaseIIAnalyzer.h b/SimCalorimetry/PhaseIIAnalyzer/plugins/PhaseIIAnalyzer.h new file mode 100644 index 0000000000000..7513b462c5c19 --- /dev/null +++ b/SimCalorimetry/PhaseIIAnalyzer/plugins/PhaseIIAnalyzer.h @@ -0,0 +1,72 @@ +#ifndef SimCalorimetry_PhaseIIAnalyzer_PhaseIIAnalyzer_h +#define SimCalorimetry_PhaseIIAnalyzer_PhaseIIAnalyzer_h + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/MakerMacros.h" + +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "DataFormats/EcalDigi/interface/EcalDigiCollections.h" +#include "SimDataFormats/CaloHit/interface/PCaloHit.h" +#include "TH1.h" +#include "TH2.h" +#include "SimDataFormats/Track/interface/SimTrack.h" +#include +#include "CondFormats/EcalObjects/interface/EcalConstants.h" + +// +// class declaration +// + +class PhaseIIAnalyzer : public edm::one::EDAnalyzer { +public: + explicit PhaseIIAnalyzer(const edm::ParameterSet&); + ~PhaseIIAnalyzer(); + +private: + virtual void beginJob(); + void analyze(const edm::Event&, const edm::EventSetup&) override; + virtual void endJob(); + + edm::InputTag digiTagEB_; + + edm::EDGetTokenT digiTokenEB_; + + edm::InputTag hitTagEB_; + + edm::EDGetTokenT> hitTokenEB_; + + edm::InputTag trackTag_; + edm::EDGetTokenT> trackToken_; + + //Histograms + TH1I* EBEnergyHisto[ecalPh2::sampleSize]; + TH1I* EBGainHisto[ecalPh2::sampleSize]; + + TH2D* meEBDigiOccupancy_; + TH2D* meEBDigiOccupancyHigh_; + TH2D* meEBDigiOccupancyLow_; + + TH1D* meEBDigiMultiplicity_; + + TH1D* meEBDigiADCGlobal_; + + TH1I* SingleChannelE; + TH1I* SingleChannelELow; + + TH1D* meEBDigiADCAnalog_[ecalPh2::sampleSize]; + TH1D* meEBDigiADCgS_[ecalPh2::sampleSize]; + TH1D* meEBDigiGain_[ecalPh2::sampleSize]; + + TH1D* meEBPedestal_; + + TH1D* meEBMaximumgt100ADC_; + + TH1D* meEBMaximumgt10ADC_; + + TH1D* meEBnADCafterSwitch_; + + TF1* f; +}; + +#endif diff --git a/SimCalorimetry/PhaseIIAnalyzer/python/CfiFile_cfi.py b/SimCalorimetry/PhaseIIAnalyzer/python/CfiFile_cfi.py new file mode 100644 index 0000000000000..241782d96afd4 --- /dev/null +++ b/SimCalorimetry/PhaseIIAnalyzer/python/CfiFile_cfi.py @@ -0,0 +1,6 @@ +import FWCore.ParameterSet.Config as cms + +phaseII = cms.EDAnalyzer('PhaseIIAnalyzer', + BarrelDigis=cms.InputTag('simEcalUnsuppressedDigis','','DIGI'), + record = cms.string('EcalLiteDTUPedestalsRcd') +) diff --git a/SimCalorimetry/PhaseIIAnalyzer/test/run_PhaseIIAnalyzer.py b/SimCalorimetry/PhaseIIAnalyzer/test/run_PhaseIIAnalyzer.py new file mode 100644 index 0000000000000..7c2362a4ddd48 --- /dev/null +++ b/SimCalorimetry/PhaseIIAnalyzer/test/run_PhaseIIAnalyzer.py @@ -0,0 +1,39 @@ +import FWCore.ParameterSet.Config as cms + +process = cms.Process("PhaseII") + +#Print out: +process.load("FWCore.MessageLogger.MessageLogger_cfi") +process.MessageLogger.cerr.threshold = 'INFO' +process.MessageLogger.categories.append('PhaseIIAnalyzer') +process.MessageLogger.cerr.INFO = cms.untracked.PSet( + limit = cms.untracked.int32(-1) +) +process.options = cms.untracked.PSet( wantSummary = cms.untracked.bool(True) ) + + + +#Max event +process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) + +#input: +process.source = cms.Source("PoolSource", + + fileNames = cms.untracked.vstring('file:../../../SimCalorimetry/EcalSimProducers/test/SingleElectronPt10_pythia8_cfi_py_GEN_SIM_DIGI_Pt10.root'), + + ) + +process.load('SimCalorimetry.EcalSimProducers.esEcalLiteDTUPedestalsProducer_cfi') +process.EcalLiteDTUPedestalsESProducer = cms.ESProducer( + "EcalLiteDTUPedestalsESProducer", + ComponentName = cms.string('testPedestalProducer') +) + +process.phaseII = cms.EDAnalyzer('PhaseIIAnalyzer') +process.TFileService = cms.Service("TFileService", + fileName = cms.string('Digitizer2.root') + ) +process.load("SimCalorimetry.PhaseIIAnalyzer.CfiFile_cfi") + +#Running process: +process.p = cms.Path(process.phaseII) diff --git a/SimGeneral/MixingModule/python/aliases_cfi.py b/SimGeneral/MixingModule/python/aliases_cfi.py index ab7507921b55c..511af5789932b 100644 --- a/SimGeneral/MixingModule/python/aliases_cfi.py +++ b/SimGeneral/MixingModule/python/aliases_cfi.py @@ -1,5 +1,4 @@ import FWCore.ParameterSet.Config as cms - simCastorDigis = cms.EDAlias( mix = cms.VPSet( cms.PSet(type = cms.string('CastorDataFramesSorted')) @@ -7,11 +6,20 @@ ) simEcalUnsuppressedDigis = cms.EDAlias( mix = cms.VPSet( - cms.PSet(type = cms.string('EBDigiCollection')), - cms.PSet(type = cms.string('EEDigiCollection')), - cms.PSet(type = cms.string('ESDigiCollection')) + cms.PSet(type = cms.string('EBDigiCollection')), + cms.PSet(type = cms.string('EEDigiCollection')), + cms.PSet(type = cms.string('ESDigiCollection')) ) ) + +from Configuration.Eras.Modifier_phase2_ecal_cff import phase2_ecal + +phase2_ecal.toModify(simEcalUnsuppressedDigis, + mix = cms.VPSet( + cms.PSet(type = cms.string('EBDigiCollectionPh2')) + ) +) + simHcalUnsuppressedDigis = cms.EDAlias( mix = cms.VPSet( cms.PSet(type = cms.string('HBHEDataFramesSorted')), @@ -22,13 +30,16 @@ cms.PSet(type = cms.string('QIE11DataFrameHcalDataFrameContainer')) ) ) + _pixelCommon = cms.VPSet( cms.PSet(type = cms.string('PixelDigiedmDetSetVector')), cms.PSet(type = cms.string('PixelDigiSimLinkedmDetSetVector')) ) + simSiPixelDigis = cms.EDAlias( mix = _pixelCommon ) + simSiStripDigis = cms.EDAlias( mix = cms.VPSet( cms.PSet(type = cms.string('SiStripDigiedmDetSetVector')), @@ -36,6 +47,7 @@ cms.PSet(type = cms.string('StripDigiSimLinkedmDetSetVector')) ) ) + simHGCalUnsuppressedDigis = cms.EDAlias( mix = cms.VPSet( cms.PSet( @@ -55,6 +67,7 @@ ), ) ) + simHFNoseUnsuppressedDigis = cms.EDAlias( mix = cms.VPSet( cms.PSet( @@ -66,9 +79,9 @@ ) simAPVsaturation = cms.EDAlias( - mix = cms.VPSet( - cms.PSet(type = cms.string('bool')) - ) + mix = cms.VPSet( + cms.PSet(type = cms.string('bool')) + ) ) from Configuration.Eras.Modifier_run3_common_cff import run3_common diff --git a/SimGeneral/MixingModule/python/digitizers_Ph2_cfi.py b/SimGeneral/MixingModule/python/digitizers_Ph2_cfi.py new file mode 100644 index 0000000000000..396c2c6121fe2 --- /dev/null +++ b/SimGeneral/MixingModule/python/digitizers_Ph2_cfi.py @@ -0,0 +1,127 @@ +import FWCore.ParameterSet.Config as cms + +# configuration to model pileup for initial physics phase +from SimGeneral.MixingModule.aliases_Ph2_cfi import * +from SimGeneral.MixingModule.pixelDigitizer_cfi import * +from SimGeneral.MixingModule.stripDigitizer_cfi import * +from SimGeneral.MixingModule.ecalDigitizer_Ph2_cfi import * +from SimGeneral.MixingModule.hcalDigitizer_cfi import * +from SimGeneral.MixingModule.castorDigitizer_cfi import * +from SimGeneral.MixingModule.pileupVtxDigitizer_cfi import * +from SimGeneral.MixingModule.trackingTruthProducerSelection_cfi import * +from SimGeneral.MixingModule.caloTruthProducer_cfi import * +from FastSimulation.Tracking.recoTrackAccumulator_cfi import * + +theDigitizers = cms.PSet( + pixel = cms.PSet( + pixelDigitizer + ), + strip = cms.PSet( + stripDigitizer + ), + ecal = cms.PSet( + ecalDigitizer_Ph2 + ), + hcal = cms.PSet( + hcalDigitizer + ), + castor = cms.PSet( + castorDigitizer + ), + puVtx = cms.PSet( + pileupVtxDigitizer + ), + mergedtruth = cms.PSet( + trackingParticles + ) +) + +from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toModify(theDigitizers, + # fastsim does not model castor + castor = None, + # fastsim does not digitize pixel and strip hits + pixel = None, + strip = None, + tracks = recoTrackAccumulator +) +from Configuration.ProcessModifiers.premix_stage2_cff import premix_stage2 +(fastSim & premix_stage2).toModify(theDigitizers, + tracks = None +) + +from SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi import hgceeDigitizer, hgchebackDigitizer, hgchefrontDigitizer, HGCAL_noise_fC, HGCAL_noise_heback, HGCAL_chargeCollectionEfficiencies, HGCAL_ileakParam_toUse, HGCAL_cceParams_toUse, HGCAL_noises + +from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal +phase2_hgcal.toModify( theDigitizers, + hgceeDigitizer = cms.PSet(hgceeDigitizer), + hgchebackDigitizer = cms.PSet(hgchebackDigitizer), + hgchefrontDigitizer = cms.PSet(hgchefrontDigitizer), +) + +from SimCalorimetry.HGCalSimProducers.hgcalDigitizer_cfi import hfnoseDigitizer + +from Configuration.Eras.Modifier_phase2_hfnose_cff import phase2_hfnose +phase2_hfnose.toModify( theDigitizers, + hfnoseDigitizer = cms.PSet(hfnoseDigitizer), +) + +from Configuration.Eras.Modifier_run3_common_cff import run3_common +run3_common.toModify( theDigitizers, castor = None ) + +from SimGeneral.MixingModule.ecalTimeDigitizer_cfi import ecalTimeDigitizer +from Configuration.Eras.Modifier_phase2_timing_cff import phase2_timing +from Configuration.Eras.Modifier_phase2_timing_layer_cff import phase2_timing_layer +phase2_timing.toModify( theDigitizers, + ecalTime = ecalTimeDigitizer.clone() ) + +from SimFastTiming.Configuration.SimFastTiming_cff import mtdDigitizer + +premix_stage2.toModify(theDigitizers, + ecal = None, + hcal = None, +) +(premix_stage2 & phase2_hgcal).toModify(theDigitizers, + hgceeDigitizer = dict(premixStage1 = True), + hgchebackDigitizer = dict(premixStage1 = True), + hgchefrontDigitizer = dict(premixStage1 = True), +) +(premix_stage2 & phase2_hfnose).toModify(theDigitizers, + hfnoseDigitizer = dict(premixStage1 = True), +) +(premix_stage2 & phase2_timing_layer).toModify(theDigitizers, + fastTimingLayer = dict( + barrelDigitizer = dict(premixStage1 = True), + endcapDigitizer = dict(premixStage1 = True) + ) +) + +theDigitizersValid = cms.PSet(theDigitizers) +theDigitizers.mergedtruth.select.signalOnlyTP = True + +phase2_hgcal.toModify( theDigitizersValid, + calotruth = cms.PSet( caloParticles ) ) # Doesn't HGCal need these also without validation? +(premix_stage2 & phase2_hgcal).toModify(theDigitizersValid, calotruth = dict(premixStage1 = True)) + + +phase2_timing.toModify( theDigitizersValid.mergedtruth, + createInitialVertexCollection = cms.bool(True) ) + + +from Configuration.ProcessModifiers.premix_stage1_cff import premix_stage1 +def _customizePremixStage1(mod): + # To avoid this if-else structure we'd need an "_InverseModifier" + # to customize pixel/strip for everything else than fastSim. + if hasattr(mod, "pixel"): + if hasattr(mod.pixel, "AlgorithmCommon"): + mod.pixel.AlgorithmCommon.makeDigiSimLinks = True + else: + mod.pixel.makeDigiSimLinks = True + if hasattr(mod, "strip"): + mod.strip.makeDigiSimLinks = True + mod.mergedtruth.select.signalOnlyTP = False +premix_stage1.toModify(theDigitizersValid, _customizePremixStage1) + +def _loadPremixStage2Aliases(process): + process.load("SimGeneral.MixingModule.aliases_PreMix_cfi") +modifyDigitizers_loadPremixStage2Aliases = premix_stage2.makeProcessModifier(_loadPremixStage2Aliases) diff --git a/SimGeneral/MixingModule/python/ecalDigitizer_Ph2_cfi.py b/SimGeneral/MixingModule/python/ecalDigitizer_Ph2_cfi.py new file mode 100644 index 0000000000000..72bf5b4f60785 --- /dev/null +++ b/SimGeneral/MixingModule/python/ecalDigitizer_Ph2_cfi.py @@ -0,0 +1,28 @@ +import FWCore.ParameterSet.Config as cms + +from SimCalorimetry.EcalSimProducers.ecalDigiParameters_Ph2_cff import * +from SimCalorimetry.EcalSimProducers.apdSimParameters_cff import * +from SimCalorimetry.EcalSimProducers.ecalSimParameterMap_cff import * +from SimCalorimetry.EcalSimProducers.ecalElectronicsSim_Ph2_cff import * +from SimCalorimetry.EcalSimProducers.ecalNotContainmentSim_cff import * +from SimCalorimetry.EcalSimProducers.ecalCosmicsSim_cff import * + + +ecalDigitizer_Ph2 = cms.PSet( + ecal_digi_parameters, + apd_sim_parameters, + ecal_electronics_sim, + ecal_cosmics_sim, + ecal_sim_parameter_map_ph2, + ecal_notCont_sim, + hitsProducer = cms.string('g4SimHits'), + accumulatorType = cms.string("EcalDigiProducer_Ph2"), + makeDigiSimLinks = cms.untracked.bool(False) +) + +from Configuration.Eras.Modifier_fastSim_cff import fastSim +fastSim.toModify(ecalDigitizer_Ph2, hitsProducer = "fastSimProducer") + + +ecalDigitizer_Ph2.doEB = cms.bool(True) + diff --git a/SimGeneral/MixingModule/python/ecalDigitizer_cfi.py b/SimGeneral/MixingModule/python/ecalDigitizer_cfi.py index d52c937f94c10..78e47e26a5aea 100644 --- a/SimGeneral/MixingModule/python/ecalDigitizer_cfi.py +++ b/SimGeneral/MixingModule/python/ecalDigitizer_cfi.py @@ -8,6 +8,7 @@ from SimCalorimetry.EcalSimProducers.ecalNotContainmentSim_cff import * from SimCalorimetry.EcalSimProducers.ecalCosmicsSim_cff import * + ecalDigitizer = cms.PSet( ecal_digi_parameters, apd_sim_parameters, @@ -32,3 +33,9 @@ phase2_common.toModify( ecalDigitizer, doES = cms.bool(False) ) from Configuration.Eras.Modifier_phase2_hgcal_cff import phase2_hgcal phase2_hgcal.toModify( ecalDigitizer, doEE = cms.bool(False) ) + + +#phase 2 digitization +from Configuration.Eras.Modifier_phase2_ecal_cff import phase2_ecal +from SimGeneral.MixingModule.ecalDigitizer_Ph2_cfi import * +phase2_ecal.toReplaceWith(ecalDigitizer,ecalDigitizer_Ph2) diff --git a/SimGeneral/MixingModule/python/mixNoPU_Ph2_cfi.py b/SimGeneral/MixingModule/python/mixNoPU_Ph2_cfi.py new file mode 100644 index 0000000000000..3a9a71c055a35 --- /dev/null +++ b/SimGeneral/MixingModule/python/mixNoPU_Ph2_cfi.py @@ -0,0 +1,25 @@ +import FWCore.ParameterSet.Config as cms + +# this is a minimum configuration of the Mixing module, +# to run it in the zero-pileup mode +# +from SimGeneral.MixingModule.mixObjects_cfi import theMixObjects +from SimGeneral.MixingModule.mixPoolSource_cfi import * +from SimGeneral.MixingModule.digitizers_Ph2_cfi import * + +mix = cms.EDProducer("MixingModule", + digitizers = cms.PSet(theDigitizers), + LabelPlayback = cms.string(''), + maxBunch = cms.int32(3), + minBunch = cms.int32(-5), ## in terms of 25 ns + + bunchspace = cms.int32(450), + mixProdStep1 = cms.bool(False), + mixProdStep2 = cms.bool(False), + + playback = cms.untracked.bool(False), + useCurrentProcessOnly = cms.bool(False), + mixObjects = cms.PSet(theMixObjects) +) + +