CMS 3D CMS Logo

CastorDigiProducer.cc
Go to the documentation of this file.
36 
37 #include <vector>
38 
39 namespace CLHEP {
40  class HepRandomEngine;
41 }
42 
44 public:
46  ~CastorDigiProducer() override;
47 
48  void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override;
49  void accumulate(edm::Event const &e, edm::EventSetup const &c) override;
50  void accumulate(PileUpEventPrincipal const &e, edm::EventSetup const &c, edm::StreamID const &) override;
51  void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override;
52 
53 private:
54  void accumulateCaloHits(std::vector<PCaloHit> const &, int bunchCrossing);
55 
59  void fillFakeHits();
63 
69 
72 
76 
78 
82 
84 
86 
88 
89  std::vector<PCaloHit> theCastorHits;
90 
91  CLHEP::HepRandomEngine *randomEngine_ = nullptr;
92 };
93 
95  edm::ProducesCollector producesCollector,
97  : theConditionsToken(iC.esConsumes()),
98  theGeometryToken(iC.esConsumes()),
99  theHitsProducerTag(ps.getParameter<edm::InputTag>("hitsProducer")),
100  hitToken_(iC.consumes<std::vector<PCaloHit>>(theHitsProducerTag)),
101  theParameterMap(new CastorSimParameterMap(ps)),
102  theCastorShape(new CastorShape()),
103  theCastorIntegratedShape(new CaloShapeIntegrator(theCastorShape)),
104  theCastorResponse(new CaloHitResponse(theParameterMap, theCastorIntegratedShape)),
105  theAmplifier(nullptr),
106  theCoderFactory(nullptr),
107  theElectronicsSim(nullptr),
108  theHitCorrection(nullptr),
109  theCastorDigitizer(nullptr),
110  theCastorHits() {
111  producesCollector.produces<CastorDigiCollection>();
112 
114 
115  bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
116  if (doTimeSlew) {
117  // no time slewing for HF
119  }
120 
121  bool doNoise = ps.getParameter<bool>("doNoise");
125 
127 
129  if (!rng.isAvailable()) {
130  throw cms::Exception("Configuration") << "CastorDigiProducer requires the RandomNumberGeneratorService\n"
131  "which is not present in the configuration file. You must add the "
132  "service\n"
133  "in the configuration file or remove the modules that require it.";
134  }
135 }
136 
138  delete theCastorDigitizer;
139  delete theParameterMap;
140  delete theCastorShape;
142  delete theCastorResponse;
143  delete theElectronicsSim;
144  delete theAmplifier;
145  delete theCoderFactory;
146  delete theHitCorrection;
147 }
148 
150  // get the appropriate gains, noises, & widths for this event
155 
156  // Cache random number engine
158  randomEngine_ = &rng->getEngine(event.streamID());
159 
160  edm::LogInfo("CastorDigiProducer") << "checking the geometry...";
161 
162  // get the correct geometry
164 
165  theCastorHits.clear();
166 
168 }
169 
170 void CastorDigiProducer::accumulateCaloHits(std::vector<PCaloHit> const &hcalHits, int bunchCrossing) {
171  // fillFakeHits();
172 
173  if (theHitCorrection != nullptr) {
174  theHitCorrection->fillChargeSums(hcalHits);
175  }
176  theCastorDigitizer->add(hcalHits, bunchCrossing, randomEngine_);
177 }
178 
180  // Step A: Get and accumulate digitized hits
181  const edm::Handle<std::vector<PCaloHit>> &castorHandle = e.getHandle(hitToken_);
182 
183  accumulateCaloHits(*castorHandle.product(), 0);
184 }
185 
187  edm::EventSetup const &,
188  edm::StreamID const &streamID) {
189  // Step A: Get and accumulate digitized hits
190  edm::Handle<std::vector<PCaloHit>> castorHandle;
191  e.getByLabel(theHitsProducerTag, castorHandle);
192 
193  accumulateCaloHits(*castorHandle.product(), e.bunchCrossing());
194 }
195 
197  // Step B: Create empty output
198 
199  std::unique_ptr<CastorDigiCollection> castorResult(new CastorDigiCollection());
200 
201  // Step C: Invoke the algorithm, getting back outputs.
202  theCastorDigitizer->run(*castorResult, randomEngine_);
203 
204  edm::LogInfo("CastorDigiProducer") << "HCAL/Castor digis : " << castorResult->size();
205 
206  // Step D: Put outputs into event
207  e.put(std::move(castorResult));
208 
209  randomEngine_ = nullptr; // to prevent access outside event
210 }
211 
213  for (edm::PCaloHitContainer::const_iterator hitItr = hits.begin(); hitItr != hits.end(); ++hitItr) {
214  DetId detId = hitItr->id();
215  if (detId.det() == DetId::Calo && detId.subdetId() == HcalCastorDetId::SubdetectorId) {
216  theCastorHits.push_back(*hitItr);
217  } else {
218  edm::LogError("CastorDigiProducer") << "Bad Hit subdetector " << detId.subdetId();
219  }
220  }
221 }
222 
224  HcalCastorDetId castorDetId(HcalCastorDetId::Section(2), true, 1, 1);
225 
226  theCastorHits.emplace_back(castorDetId.rawId(), 50.0, 0.);
227 }
228 
233 
234  const std::vector<DetId> &castorCells = geometry->getValidDetIds(DetId::Calo, HcalCastorDetId::SubdetectorId);
235 
236  // // edm::LogInfo("CastorDigiProducer") << "CastorDigiProducer::CheckGeometry number of cells:" << castorCells.size()
237  ;
238  theCastorDigitizer->setDetIds(castorCells);
239  }
240 }
241 
244 
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
void setGeometry(const CaloGeometry *geometry)
geometry needed for time-of-flight
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
CastorAmplifier * theAmplifier
CaloVShape * theCastorShape
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< PCaloHit > PCaloHitContainer
void add(const std::vector< PCaloHit > &hits, int bunchCrossing, CLHEP::HepRandomEngine *engine)
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
void fillChargeSums(MixCollection< PCaloHit > &hits)
CaloTDigitizer< CastorDigitizerTraits > CastorDigitizer
T const * product() const
Definition: Handle.h:70
void checkGeometry(const edm::EventSetup &eventSetup)
void setDbService(const CastorDbService *service)
CastorSimParameterMap * theParameterMap
Electronic response of the preamp.
Definition: CaloVShape.h:11
void sortHits(const edm::PCaloHitContainer &hits)
fills the vectors for each subdetector
Log< level::Error, false > LogError
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
const edm::InputTag theHitsProducerTag
CLHEP::HepRandomEngine * randomEngine_
CastorElectronicsSim * theElectronicsSim
CastorHitFilter theCastorHitFilter
void setHitFilter(const CaloVHitFilter *filter)
Creates electronics signals from hits.
void initializeHits()
CaloHitResponse * theCastorResponse
std::vector< PCaloHit > theCastorHits
void fillFakeHits()
some hits in each subdetector, just for testing purposes
static const int SubdetectorId
void accumulateCaloHits(std::vector< PCaloHit > const &, int bunchCrossing)
void accumulate(edm::Event const &e, edm::EventSetup const &c) override
const edm::EDGetTokenT< std::vector< PCaloHit > > hitToken_
Log< level::Info, false > LogInfo
CastorDigiProducer(const edm::ParameterSet &ps, edm::ProducesCollector, edm::ConsumesCollector &iC)
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
CastorHitCorrection * theHitCorrection
void run(MixCollection< PCaloHit > &, DigiCollection &)
turns hits into digis
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
const edm::ESGetToken< CastorDbService, CastorDbRecord > theConditionsToken
CastorDigitizer * theCastorDigitizer
HLT enums.
#define DEFINE_DIGI_ACCUMULATOR(type)
void setHitCorrection(const CaloVHitCorrection *hitCorrection)
If you want to correct hits, for attenuation or delay, set this.
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > theGeometryToken
CastorCoderFactory * theCoderFactory
shaper for Castor
Definition: CastorShape.h:15
edm::SortedCollection< CastorDataFrame > CastorDigiCollection
bool isAvailable() const
Definition: Service.h:40
void setDbService(const CastorDbService *service)
the Producer will probably update this every event
edm::ESWatcher< CaloGeometryRecord > theGeometryWatcher
void setDbService(const CastorDbService *service)
CaloVShape * theCastorIntegratedShape
def move(src, dest)
Definition: eostools.py:511
void setDetIds(const std::vector< DetId > &detIds)
Definition: event.py:1