CMS 3D CMS Logo

CastorDigiProducer.cc
Go to the documentation of this file.
19 
21  edm::ProducesCollector producesCollector,
23  : theConditionsToken(iC.esConsumes()),
24  theGeometryToken(iC.esConsumes()),
25  theParameterMap(new CastorSimParameterMap(ps)),
26  theCastorShape(new CastorShape()),
27  theCastorIntegratedShape(new CaloShapeIntegrator(theCastorShape)),
28  theCastorResponse(new CaloHitResponse(theParameterMap, theCastorIntegratedShape)),
29  theAmplifier(nullptr),
30  theCoderFactory(nullptr),
31  theElectronicsSim(nullptr),
32  theHitCorrection(nullptr),
33  theCastorDigitizer(nullptr),
34  theCastorHits() {
35  theHitsProducerTag = ps.getParameter<edm::InputTag>("hitsProducer");
36  iC.consumes<std::vector<PCaloHit>>(theHitsProducerTag);
37 
38  producesCollector.produces<CastorDigiCollection>();
39 
41 
42  bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
43  if (doTimeSlew) {
44  // no time slewing for HF
46  }
47 
48  bool doNoise = ps.getParameter<bool>("doNoise");
52 
54 
56  if (!rng.isAvailable()) {
57  throw cms::Exception("Configuration") << "CastorDigiProducer requires the RandomNumberGeneratorService\n"
58  "which is not present in the configuration file. You must add the "
59  "service\n"
60  "in the configuration file or remove the modules that require it.";
61  }
62 }
63 
65  delete theCastorDigitizer;
66  delete theParameterMap;
67  delete theCastorShape;
69  delete theCastorResponse;
70  delete theElectronicsSim;
71  delete theAmplifier;
72  delete theCoderFactory;
73  delete theHitCorrection;
74 }
75 
77  // get the appropriate gains, noises, & widths for this event
82 
83  // Cache random number engine
85  randomEngine_ = &rng->getEngine(event.streamID());
86 
87  edm::LogInfo("CastorDigiProducer") << "checking the geometry...";
88 
89  // get the correct geometry
90  checkGeometry(eventSetup);
91 
92  theCastorHits.clear();
93 
95 }
96 
97 void CastorDigiProducer::accumulateCaloHits(std::vector<PCaloHit> const &hcalHits, int bunchCrossing) {
98  // fillFakeHits();
99 
100  if (theHitCorrection != nullptr) {
101  theHitCorrection->fillChargeSums(hcalHits);
102  }
103  theCastorDigitizer->add(hcalHits, bunchCrossing, randomEngine_);
104 }
105 
107  // Step A: Get and accumulate digitized hits
108  edm::Handle<std::vector<PCaloHit>> castorHandle;
109  e.getByLabel(theHitsProducerTag, castorHandle);
110 
111  accumulateCaloHits(*castorHandle.product(), 0);
112 }
113 
115  edm::EventSetup const &,
116  edm::StreamID const &streamID) {
117  // Step A: Get and accumulate digitized hits
118  edm::Handle<std::vector<PCaloHit>> castorHandle;
119  e.getByLabel(theHitsProducerTag, castorHandle);
120 
121  accumulateCaloHits(*castorHandle.product(), e.bunchCrossing());
122 }
123 
125  // Step B: Create empty output
126 
127  std::unique_ptr<CastorDigiCollection> castorResult(new CastorDigiCollection());
128 
129  // Step C: Invoke the algorithm, getting back outputs.
130  theCastorDigitizer->run(*castorResult, randomEngine_);
131 
132  edm::LogInfo("CastorDigiProducer") << "HCAL/Castor digis : " << castorResult->size();
133 
134  // Step D: Put outputs into event
135  e.put(std::move(castorResult));
136 
137  randomEngine_ = nullptr; // to prevent access outside event
138 }
139 
141  for (edm::PCaloHitContainer::const_iterator hitItr = hits.begin(); hitItr != hits.end(); ++hitItr) {
142  DetId detId = hitItr->id();
143  if (detId.det() == DetId::Calo && detId.subdetId() == HcalCastorDetId::SubdetectorId) {
144  theCastorHits.push_back(*hitItr);
145  } else {
146  edm::LogError("CastorDigiProducer") << "Bad Hit subdetector " << detId.subdetId();
147  }
148  }
149 }
150 
152  HcalCastorDetId castorDetId(HcalCastorDetId::Section(2), true, 1, 1);
153 
154  theCastorHits.emplace_back(castorDetId.rawId(), 50.0, 0.);
155 }
156 
158  if (theGeometryWatcher.check(eventSetup)) {
159  const CaloGeometry *geometry = &eventSetup.getData(theGeometryToken);
161 
162  const std::vector<DetId> &castorCells = geometry->getValidDetIds(DetId::Calo, HcalCastorDetId::SubdetectorId);
163 
164  // std::cout<<"CastorDigiProducer::CheckGeometry number of cells:
165  // "<<castorCells.size()<<std::endl;
166  theCastorDigitizer->setDetIds(castorCells);
167  }
168 }
CaloTDigitizer::add
void add(const std::vector< PCaloHit > &hits, int bunchCrossing, CLHEP::HepRandomEngine *engine)
Definition: CaloTDigitizer.h:75
edm::ESWatcher::check
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
CastorDigiProducer::theCastorResponse
CaloHitResponse * theCastorResponse
Definition: CastorDigiProducer.h:67
edm::StreamID
Definition: StreamID.h:30
CaloShapeIntegrator.h
CastorDigiProducer::theCastorDigitizer
CastorDigitizer * theCastorDigitizer
Definition: CastorDigiProducer.h:77
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
Handle.h
CastorHitCorrection::fillChargeSums
void fillChargeSums(MixCollection< PCaloHit > &hits)
Definition: CastorHitCorrection.cc:12
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EDProducer.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
CastorDigiProducer::CastorDigitizer
CaloTDigitizer< CastorDigitizerTraits > CastorDigitizer
Definition: CastorDigiProducer.h:61
RandomNumberGenerator.h
DetId::det
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
CrossingFrame.h
geometry
Definition: geometry.py:1
CastorDigiProducer::theElectronicsSim
CastorElectronicsSim * theElectronicsSim
Definition: CastorDigiProducer.h:71
CaloTDigitizer::initializeHits
void initializeHits()
Definition: CaloTDigitizer.h:83
edm::SortedCollection
Definition: SortedCollection.h:49
CaloTDigitizer::setDetIds
void setDetIds(const std::vector< DetId > &detIds)
Definition: CaloTDigitizer.h:67
CastorElectronicsSim
Definition: CastorElectronicsSim.h:19
HcalCastorDetId::SubdetectorId
static const int SubdetectorId
Definition: HcalCastorDetId.h:28
PileUpEventPrincipal
Definition: PileUpEventPrincipal.h:19
CastorDigiProducer::~CastorDigiProducer
~CastorDigiProducer() override
Definition: CastorDigiProducer.cc:64
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
CastorDigiProducer::theCastorHits
std::vector< PCaloHit > theCastorHits
Definition: CastorDigiProducer.h:79
HcalCastorDetId::Section
Section
Definition: HcalCastorDetId.h:25
CaloShapeIntegrator
Definition: CaloShapeIntegrator.h:11
edm::Handle
Definition: AssociativeIterator.h:50
DetId::Calo
Definition: DetId.h:29
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
CastorDigiProducer::initializeEvent
void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override
Definition: CastorDigiProducer.cc:76
DigiDM_cff.doNoise
doNoise
Definition: DigiDM_cff.py:32
DetId
Definition: DetId.h:17
CastorShape
shaper for Castor
Definition: CastorShape.h:15
CastorSimParameterMap
Definition: CastorSimParameterMap.h:9
CaloGeometry
Definition: CaloGeometry.h:21
CastorDigiProducer::theConditionsToken
const edm::ESGetToken< CastorDbService, CastorDbRecord > theConditionsToken
Definition: CastorDigiProducer.h:56
MixCollection.h
Service.h
HcalDigiCollections.h
CastorDigiProducer::checkGeometry
void checkGeometry(const edm::EventSetup &eventSetup)
Definition: CastorDigiProducer.cc:157
CastorDigiProducer.h
PileUpEventPrincipal.h
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
hcalUnsuppressedDigis_cfi.doTimeSlew
doTimeSlew
Definition: hcalUnsuppressedDigis_cfi.py:20
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
HcalCastorDetId
Definition: HcalCastorDetId.h:23
CastorDigiProducer::finalizeEvent
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
Definition: CastorDigiProducer.cc:124
CastorSimParameterMap::setDbService
void setDbService(const CastorDbService *service)
Definition: CastorSimParameterMap.cc:33
edm::ParameterSet
Definition: ParameterSet.h:47
CastorCoderFactory::setDbService
void setDbService(const CastorDbService *service)
Definition: CastorCoderFactory.h:14
CaloHitResponse::setHitFilter
void setHitFilter(const CaloVHitFilter *filter)
Definition: CaloHitResponse.h:70
CaloHitResponse
Creates electronics signals from hits.
Definition: CaloHitResponse.h:33
edm::Service< edm::RandomNumberGenerator >
CastorDbService
Definition: CastorDbService.h:25
CastorDigiProducer::theGeometryToken
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > theGeometryToken
Definition: CastorDigiProducer.h:57
CastorDigiProducer::accumulateCaloHits
void accumulateCaloHits(std::vector< PCaloHit > const &, int bunchCrossing)
Definition: CastorDigiProducer.cc:97
edm::ProducesCollector::produces
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
Definition: ProducesCollector.h:52
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
CaloTDigitizer.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
CastorAmplifier
Definition: CastorAmplifier.h:13
CastorDigiProducer::fillFakeHits
void fillFakeHits()
some hits in each subdetector, just for testing purposes
Definition: CastorDigiProducer.cc:151
CastorDigiProducer::accumulate
void accumulate(edm::Event const &e, edm::EventSetup const &c) override
Definition: CastorDigiProducer.cc:106
submitPVValidationJobs.conditions
list conditions
Definition: submitPVValidationJobs.py:674
eostools.move
def move(src, dest)
Definition: eostools.py:511
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
edm::ProducesCollector
Definition: ProducesCollector.h:43
CastorDigiProducer::theGeometryWatcher
edm::ESWatcher< CaloGeometryRecord > theGeometryWatcher
Definition: CastorDigiProducer.h:58
CastorDigiProducer::CastorDigiProducer
CastorDigiProducer(const edm::ParameterSet &ps, edm::ProducesCollector, edm::ConsumesCollector &iC)
Definition: CastorDigiProducer.cc:20
CastorDigiProducer::sortHits
void sortHits(const edm::PCaloHitContainer &hits)
fills the vectors for each subdetector
Definition: CastorDigiProducer.cc:140
CastorCoderFactory
Definition: CastorCoderFactory.h:8
CastorAmplifier::setDbService
void setDbService(const CastorDbService *service)
the Producer will probably update this every event
Definition: CastorAmplifier.h:19
Exception
Definition: hltDiff.cc:245
CaloGeometry.h
edm::PCaloHitContainer
std::vector< PCaloHit > PCaloHitContainer
Definition: PCaloHitContainer.h:8
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
CaloTDigitizer::run
void run(MixCollection< PCaloHit > &, DigiCollection &)
turns hits into digis
Definition: CaloTDigitizer.h:86
CastorDbService.h
CastorDigiProducer::theCastorShape
CaloVShape * theCastorShape
Definition: CastorDigiProducer.h:64
ConsumesCollector.h
CaloHitResponse::setHitCorrection
void setHitCorrection(const CaloVHitCorrection *hitCorrection)
If you want to correct hits, for attenuation or delay, set this.
Definition: CaloHitResponse.h:73
HcalCastorDetId.h
CastorDigiCollection
edm::SortedCollection< CastorDataFrame > CastorDigiCollection
Definition: HcalDigiCollections.h:27
CastorDigiProducer::theHitCorrection
CastorHitCorrection * theHitCorrection
Definition: CastorDigiProducer.h:75
event
Definition: event.py:1
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
CastorDigiProducer::randomEngine_
CLHEP::HepRandomEngine * randomEngine_
Definition: CastorDigiProducer.h:81
edm::Event
Definition: Event.h:73
CastorDigiProducer::theCoderFactory
CastorCoderFactory * theCoderFactory
Definition: CastorDigiProducer.h:70
StreamID.h
CastorCoderFactory::DB
Definition: CastorCoderFactory.h:10
CastorDigiProducer::theCastorHitFilter
CastorHitFilter theCastorHitFilter
Definition: CastorDigiProducer.h:73
CastorDigiProducer::theHitsProducerTag
edm::InputTag theHitsProducerTag
Definition: CastorDigiProducer.h:55
CastorDbRecord.h
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
CaloHitResponse::setGeometry
void setGeometry(const CaloGeometry *geometry)
geometry needed for time-of-flight
Definition: CaloHitResponse.h:49
CastorDigiProducer::theCastorIntegratedShape
CaloVShape * theCastorIntegratedShape
Definition: CastorDigiProducer.h:65
CastorDigiProducer::theParameterMap
CastorSimParameterMap * theParameterMap
Definition: CastorDigiProducer.h:63
CastorDigiProducer::theAmplifier
CastorAmplifier * theAmplifier
Definition: CastorDigiProducer.h:69
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37