CMS 3D CMS Logo

EcalTimeDigiProducer.cc
Go to the documentation of this file.
4 
6 
11 
14 
20 
21 //#define ecal_time_debug 1
22 
24  edm::ProducerBase &mixMod,
27  m_EBdigiCollection(params.getParameter<std::string>("EBtimeDigiCollection")),
28  m_EEdigiCollection(params.getParameter<std::string>("EEtimeDigiCollection")),
29  m_hitsProducerTagEB(params.getParameter<edm::InputTag>("hitsProducerEB")),
30  m_hitsProducerTagEE(params.getParameter<edm::InputTag>("hitsProducerEE")),
31  m_hitsProducerTokenEB(sumes.consumes<std::vector<PCaloHit>>(m_hitsProducerTagEB)),
32  m_hitsProducerTokenEE(sumes.consumes<std::vector<PCaloHit>>(m_hitsProducerTagEE)),
33  m_timeLayerEB(params.getParameter<int>("timeLayerBarrel")),
34  m_timeLayerEE(params.getParameter<int>("timeLayerEndcap")),
35  m_Geometry(nullptr) {
38 
41 
42 #ifdef ecal_time_debug
43  std::cout << "[EcalTimeDigiProducer]::Create EB " << m_EBdigiCollection << " and EE " << m_EEdigiCollection
44  << " collections and digitizers" << std::endl;
45 #endif
46 
47  m_BarrelDigitizer->setTimeLayerId(m_timeLayerEB);
49 }
50 
52 
54  checkGeometry(eventSetup);
55  // checkCalibrations( event, eventSetup );
56  // here the methods to clean the maps
59 }
60 
62  HitsHandle const &eeHandle,
63  int bunchCrossing) {
64  // accumulate the simHits and do the averages in a given layer per bunch
65  // crossing
66  if (ebHandle.isValid()) {
67  m_BarrelDigitizer->add(*ebHandle.product(), bunchCrossing);
68  }
69 
70  if (eeHandle.isValid()) {
71  m_EndcapDigitizer->add(*eeHandle.product(), bunchCrossing);
72  }
73 }
74 
76  // Step A: Get Inputs
78  e.getByToken(m_hitsProducerTokenEB, ebHandle);
79 
81  e.getByToken(m_hitsProducerTokenEE, eeHandle);
82 
83 #ifdef ecal_time_debug
84  std::cout << "[EcalTimeDigiProducer]::Accumulate Hits HS event" << std::endl;
85 #endif
86 
87  accumulateCaloHits(ebHandle, eeHandle, 0);
88 }
89 
91  edm::EventSetup const &eventSetup,
92  edm::StreamID const &) {
94  e.getByLabel(m_hitsProducerTagEB, ebHandle);
95 
97  e.getByLabel(m_hitsProducerTagEE, eeHandle);
98 
99 #ifdef ecal_time_debug
100  std::cout << "[EcalTimeDigiProducer]::Accumulate Hits for BC " << e.bunchCrossing() << std::endl;
101 #endif
102  accumulateCaloHits(ebHandle, eeHandle, e.bunchCrossing());
103 }
104 
106  std::unique_ptr<EcalTimeDigiCollection> barrelResult(new EcalTimeDigiCollection());
107  std::unique_ptr<EcalTimeDigiCollection> endcapResult(new EcalTimeDigiCollection());
108 
109 #ifdef ecal_time_debug
110  std::cout << "[EcalTimeDigiProducer]::finalizeEvent" << std::endl;
111 #endif
112 
113  // here basically just put everything in the final collections
114  m_BarrelDigitizer->run(*barrelResult);
115 
116 #ifdef ecal_time_debug
117  std::cout << "[EcalTimeDigiProducer]::EB Digi size " << barrelResult->size() << std::endl;
118 #endif
119 
120  edm::LogInfo("TimeDigiInfo") << "EB time Digis: " << barrelResult->size();
121 
122  m_EndcapDigitizer->run(*endcapResult);
123 
124 #ifdef ecal_time_debug
125  std::cout << "[EcalTimeDigiProducer]::EE Digi size " << endcapResult->size() << std::endl;
126 #endif
127 
128  edm::LogInfo("TimeDigiInfo") << "EE Digis: " << endcapResult->size();
129 
130 #ifdef ecal_time_debug
131  std::cout << "[EcalTimeDigiProducer]::putting collections into the event " << std::endl;
132 #endif
133 
134  event.put(std::move(barrelResult), m_EBdigiCollection);
135  event.put(std::move(endcapResult), m_EEdigiCollection);
136 }
137 
139  // TODO find a way to avoid doing this every event
140  edm::ESHandle<CaloGeometry> hGeometry;
141  eventSetup.get<CaloGeometryRecord>().get(hGeometry);
142 
143  const CaloGeometry *pGeometry = &*hGeometry;
144 
145  if (pGeometry != m_Geometry) {
146  m_Geometry = pGeometry;
147  updateGeometry();
148  }
149 }
150 
154 }
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
EcalTimeMapDigitizer * m_EndcapDigitizer
const edm::EDGetTokenT< std::vector< PCaloHit > > m_hitsProducerTokenEE
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
EcalTimeDigiProducer(const edm::ParameterSet &params, edm::ProducerBase &mixMod, edm::ConsumesCollector &)
void run(EcalTimeDigiCollection &output)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
#define nullptr
void setGeometry(const CaloSubdetectorGeometry *geometry)
void accumulateCaloHits(HitsHandle const &ebHandle, HitsHandle const &eeHandle, int bunchCrossing)
void setTimeLayerId(const int &layerId)
const edm::EDGetTokenT< std::vector< PCaloHit > > m_hitsProducerTokenEB
const edm::InputTag m_hitsProducerTagEB
const std::string m_EEdigiCollection
bool isValid() const
Definition: HandleBase.h:74
edm::SortedCollection< EcalTimeDigi > EcalTimeDigiCollection
void accumulate(edm::Event const &e, edm::EventSetup const &c) override
T const * product() const
Definition: Handle.h:74
EcalTimeMapDigitizer * m_BarrelDigitizer
void add(const std::vector< PCaloHit > &hits, int bunchCrossing)
HLT enums.
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
T get() const
Definition: EventSetup.h:71
const CaloGeometry * m_Geometry
const edm::InputTag m_hitsProducerTagEE
def move(src, dest)
Definition: eostools.py:511
void checkGeometry(const edm::EventSetup &eventSetup)
Definition: event.py:1
const std::string m_EBdigiCollection