CMS 3D CMS Logo

EcalTBDigiProducer.cc
Go to the documentation of this file.
1 
13 
15  edm::ProducesCollector producesCollector,
17  : EcalDigiProducer(params, producesCollector, iC) {
18  std::string const instance("simEcalUnsuppressedDigis");
19  m_EBdigiFinalTag = params.getParameter<std::string>("EBdigiFinalCollection");
20  m_EBdigiTempTag = params.getParameter<std::string>("EBdigiCollection");
21 
22  producesCollector.produces<EBDigiCollection>(instance + m_EBdigiFinalTag); // after selective readout
23  producesCollector.produces<EcalTBTDCRawInfo>(instance);
24 
25  const bool syncPhase(params.getParameter<bool>("syncPhase"));
26 
27  // possible phase shift for asynchronous trigger (e.g. test-beam)
28 
30  m_thisPhaseShift = 1.;
31 
32  typedef std::vector<edm::ParameterSet> Parameters;
33  Parameters ranges = params.getParameter<Parameters>("tdcRanges");
34  for (Parameters::iterator itRanges = ranges.begin(); itRanges != ranges.end(); ++itRanges) {
36  aRange.runRanges.first = itRanges->getParameter<int>("startRun");
37  aRange.runRanges.second = itRanges->getParameter<int>("endRun");
38  aRange.tdcMin = itRanges->getParameter<std::vector<double>>("tdcMin");
39  aRange.tdcMax = itRanges->getParameter<std::vector<double>>("tdcMax");
40  m_tdcRanges.push_back(std::move(aRange));
41  }
42 
43  m_use2004OffsetConvention = params.getUntrackedParameter<bool>("use2004OffsetConvention", false);
44 
45  m_ecalTBInfoLabel = params.getUntrackedParameter<std::string>("EcalTBInfoLabel", "SimEcalTBG4Object");
46 
47  m_doReadout = params.getParameter<bool>("doReadout");
48 
49  m_theTBReadout = new EcalTBReadout(m_ecalTBInfoLabel);
50 
51  m_tunePhaseShift = params.getParameter<double>("tunePhaseShift");
52 
53  if (m_doPhaseShift) {
55  edm::InputTag(params.getUntrackedParameter<std::string>("EcalTBInfoLabel", "SimEcalTBG4Object")));
56  }
57 }
58 
60 
62  std::cout << "====****Entering EcalTBDigiProducer produce()" << std::endl;
64  eventSetup.get<CaloGeometryRecord>().get(hGeometry);
65  const std::vector<DetId> &theBarrelDets(hGeometry->getValidDetIds(DetId::Ecal, EcalBarrel));
66 
67  m_theTBReadout->setDetIds(theBarrelDets);
68 
69  m_TDCproduct.reset(new EcalTBTDCRawInfo(1));
70  if (m_doPhaseShift) {
71  edm::Handle<PEcalTBInfo> theEcalTBInfo;
72  event.getByLabel(m_ecalTBInfoLabel, theEcalTBInfo);
73  m_thisPhaseShift = theEcalTBInfo->phaseShift();
74 
75  DetId detId(DetId::Ecal, 1);
76  setPhaseShift(detId);
77 
78  fillTBTDCRawInfo(*m_TDCproduct); // fill the TDC info in the event
79  }
80  EcalDigiProducer::initializeEvent(event, eventSetup);
81 }
82 
84  m_ebDigis.reset(new EBDigiCollection);
85 
86  EcalDigiProducer::finalizeEvent(event, eventSetup);
87 
88  const EBDigiCollection *barrelResult(&*m_ebDigis);
89 
90  std::unique_ptr<EBDigiCollection> barrelReadout(new EBDigiCollection());
91  if (m_doReadout) {
92  m_theTBReadout->performReadout(event, m_theTTmap, *barrelResult, *barrelReadout);
93  } else {
94  *barrelReadout = *barrelResult;
95  }
96 
97  std::cout << "===**** EcalTBDigiProducer: number of barrel digis = " << barrelReadout->size() << std::endl;
98 
99  std::string const instance("simEcalUnsuppressedDigis");
100  event.put(std::move(barrelReadout), instance + m_EBdigiFinalTag);
101  event.put(std::move(m_TDCproduct), instance);
102 
103  m_ebDigis.reset(); // release memory
104  m_eeDigis.reset(); // release memory
105 }
106 
108  const CaloSimParameters &parameters(EcalDigiProducer::m_ParameterMap->simParameters(detId));
109 
110  if (!parameters.syncPhase()) {
111  const int myDet(detId.subdetId());
112 
113  LogDebug("EcalDigi") << "Setting the phase shift " << m_thisPhaseShift << " and the offset " << m_tunePhaseShift
114  << " for the subdetector " << myDet;
115 
116  if (myDet == 1) {
117  double passPhaseShift(m_thisPhaseShift + m_tunePhaseShift);
119  passPhaseShift = 1. - passPhaseShift;
120  EcalDigiProducer::m_EBResponse->setPhaseShift(passPhaseShift);
121  EcalDigiProducer::m_EEResponse->setPhaseShift(passPhaseShift);
122  }
123  }
124 }
125 
127  const unsigned int thisChannel(1);
128 
129  const unsigned int thisCount((unsigned int)(m_thisPhaseShift * (m_tdcRanges[0].tdcMax[0] - m_tdcRanges[0].tdcMin[0]) +
130  m_tdcRanges[0].tdcMin[0]));
131 
132  EcalTBTDCSample theTBTDCSample(thisChannel, thisCount);
133 
134  const unsigned int sampleIndex(0);
135  theTBTDCRawInfo.setSample(sampleIndex, theTBTDCSample);
136 
137  LogDebug("EcalDigi") << theTBTDCSample << "\n" << theTBTDCRawInfo;
138 }
139 
141  m_ebDigis.reset(new EBDigiCollection);
142  *m_ebDigis = *ebDigiPtr;
143 }
144 
146  std::cout << "===**** EcalTBDigiProducer: number of endcap digis = " << eeDigiPtr->size() << std::endl;
147 }
#define LogDebug(id)
const EcalTrigTowerConstituentsMap m_theTTmap
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
std::unique_ptr< EEDigiCollection > m_eeDigis
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
static PFTauRenderPlugin instance
void cacheEEDigis(const EEDigiCollection *eeDigiPtr) const override
std::vector< EcalTBTDCRecInfoAlgo::EcalTBTDCRanges > m_tdcRanges
Main class for Parameters in different subdetectors.
void fillTBTDCRawInfo(EcalTBTDCRawInfo &theTBTDCRawInfo)
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
std::unique_ptr< EBDigiCollection > m_ebDigis
vector< ParameterSet > Parameters
void setPhaseShift(const DetId &detId)
void cacheEBDigis(const EBDigiCollection *ebDigiPtr) const override
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
std::string m_EBdigiFinalTag
void performReadout(edm::Event &event, const EcalTrigTowerConstituentsMap &theTTmap, const EBDigiCollection &input, EBDigiCollection &output)
master function to be called once per event
void finalizeEvent(edm::Event &, edm::EventSetup const &) override
string ranges
Definition: diffTwoXMLs.py:79
void setDetIds(const std::vector< DetId > &detIds)
tell the readout which cells exist
Definition: EcalTBReadout.h:25
void initializeEvent(edm::Event const &, edm::EventSetup const &) override
Definition: DetId.h:17
std::unique_ptr< EEHitResponse > m_EEResponse
EcalTBDigiProducer(const edm::ParameterSet &params, edm::ProducesCollector, edm::ConsumesCollector &iC)
EcalTBReadout * m_theTBReadout
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:75
~EcalTBDigiProducer() override
double phaseShift() const
Definition: PEcalTBInfo.h:37
void setSample(unsigned int i, const EcalTBTDCSample &sam)
T get() const
Definition: EventSetup.h:73
std::string m_EBdigiTempTag
std::unique_ptr< EBHitResponse > m_EBResponse
std::unique_ptr< EcalTBTDCRawInfo > m_TDCproduct
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
std::string m_ecalTBInfoLabel
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
std::unique_ptr< const EcalSimParameterMap > m_ParameterMap
bool syncPhase() const