CMS 3D CMS Logo

CastorDigiProducer.cc
Go to the documentation of this file.
21 
23  edm::ProducesCollector producesCollector,
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
79  eventSetup.get<CastorDbRecord>().get(conditions);
83 
84  // Cache random number engine
86  randomEngine_ = &rng->getEngine(event.streamID());
87 
88  edm::LogInfo("CastorDigiProducer") << "checking the geometry...";
89 
90  // get the correct geometry
91  checkGeometry(eventSetup);
92 
93  theCastorHits.clear();
94 
96 }
97 
98 void CastorDigiProducer::accumulateCaloHits(std::vector<PCaloHit> const &hcalHits, int bunchCrossing) {
99  // fillFakeHits();
100 
101  if (theHitCorrection != nullptr) {
102  theHitCorrection->fillChargeSums(hcalHits);
103  }
104  theCastorDigitizer->add(hcalHits, bunchCrossing, randomEngine_);
105 }
106 
108  // Step A: Get and accumulate digitized hits
109  edm::Handle<std::vector<PCaloHit>> castorHandle;
110  e.getByLabel(theHitsProducerTag, castorHandle);
111 
112  accumulateCaloHits(*castorHandle.product(), 0);
113 }
114 
116  edm::EventSetup const &,
117  edm::StreamID const &streamID) {
118  // Step A: Get and accumulate digitized hits
119  edm::Handle<std::vector<PCaloHit>> castorHandle;
120  e.getByLabel(theHitsProducerTag, castorHandle);
121 
122  accumulateCaloHits(*castorHandle.product(), e.bunchCrossing());
123 }
124 
126  // Step B: Create empty output
127 
128  std::unique_ptr<CastorDigiCollection> castorResult(new CastorDigiCollection());
129 
130  // Step C: Invoke the algorithm, getting back outputs.
131  theCastorDigitizer->run(*castorResult, randomEngine_);
132 
133  edm::LogInfo("CastorDigiProducer") << "HCAL/Castor digis : " << castorResult->size();
134 
135  // Step D: Put outputs into event
136  e.put(std::move(castorResult));
137 
138  randomEngine_ = nullptr; // to prevent access outside event
139 }
140 
142  for (edm::PCaloHitContainer::const_iterator hitItr = hits.begin(); hitItr != hits.end(); ++hitItr) {
143  DetId detId = hitItr->id();
144  if (detId.det() == DetId::Calo && detId.subdetId() == HcalCastorDetId::SubdetectorId) {
145  theCastorHits.push_back(*hitItr);
146  } else {
147  edm::LogError("CastorDigiProducer") << "Bad Hit subdetector " << detId.subdetId();
148  }
149  }
150 }
151 
153  HcalCastorDetId castorDetId(HcalCastorDetId::Section(2), true, 1, 1);
154 
155  theCastorHits.emplace_back(castorDetId.rawId(), 50.0, 0.);
156 }
157 
159  // TODO find a way to avoid doing this every event
161  eventSetup.get<CaloGeometryRecord>().get(geometry);
163 
164  const std::vector<DetId> &castorCells = geometry->getValidDetIds(DetId::Calo, HcalCastorDetId::SubdetectorId);
165 
166  // std::cout<<"CastorDigiProducer::CheckGeometry number of cells:
167  // "<<castorCells.size()<<std::endl;
168  theCastorDigitizer->setDetIds(castorCells);
169 }
CaloTDigitizer::add
void add(const std::vector< PCaloHit > &hits, int bunchCrossing, CLHEP::HepRandomEngine *engine)
Definition: CaloTDigitizer.h:75
CastorDigiProducer::theCastorResponse
CaloHitResponse * theCastorResponse
Definition: CastorDigiProducer.h:65
edm::StreamID
Definition: StreamID.h:30
CaloShapeIntegrator.h
CastorDigiProducer::theCastorDigitizer
CastorDigitizer * theCastorDigitizer
Definition: CastorDigiProducer.h:75
edm::RandomNumberGenerator::getEngine
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
geometry
ESHandle< TrackerGeometry > geometry
Definition: TkLasBeamFitter.cc:200
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
ESHandle.h
CastorDigiProducer::CastorDigitizer
CaloTDigitizer< CastorDigitizerTraits > CastorDigitizer
Definition: CastorDigiProducer.h:59
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
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:69
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:77
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
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
MixCollection.h
Service.h
HcalDigiCollections.h
CastorDigiProducer::checkGeometry
void checkGeometry(const edm::EventSetup &eventSetup)
Definition: CastorDigiProducer.cc:158
edm::ESHandle
Definition: DTSurvey.h:22
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
CaloGeometryRecord.h
HcalCastorDetId
Definition: HcalCastorDetId.h:23
CastorDigiProducer::finalizeEvent
void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override
Definition: CastorDigiProducer.cc:125
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 >
CastorDigiProducer::accumulateCaloHits
void accumulateCaloHits(std::vector< PCaloHit > const &, int bunchCrossing)
Definition: CastorDigiProducer.cc:98
edm::ProducesCollector::produces
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
Definition: ProducesCollector.h:52
edm::EventSetup
Definition: EventSetup.h:57
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
CaloTDigitizer.h
get
#define get
CastorAmplifier
Definition: CastorAmplifier.h:13
CastorDbRecord
Definition: CastorDbRecord.h:29
CastorDigiProducer::fillFakeHits
void fillFakeHits()
some hits in each subdetector, just for testing purposes
Definition: CastorDigiProducer.cc:152
CastorDigiProducer::accumulate
void accumulate(edm::Event const &e, edm::EventSetup const &c) override
Definition: CastorDigiProducer.cc:107
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::CastorDigiProducer
CastorDigiProducer(const edm::ParameterSet &ps, edm::ProducesCollector, edm::ConsumesCollector &iC)
Definition: CastorDigiProducer.cc:22
CastorDigiProducer::sortHits
void sortHits(const edm::PCaloHitContainer &hits)
fills the vectors for each subdetector
Definition: CastorDigiProducer.cc:141
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:246
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:62
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:73
event
Definition: event.py:1
CastorDigiProducer::randomEngine_
CLHEP::HepRandomEngine * randomEngine_
Definition: CastorDigiProducer.h:79
edm::Event
Definition: Event.h:73
CastorDigiProducer::theCoderFactory
CastorCoderFactory * theCoderFactory
Definition: CastorDigiProducer.h:68
StreamID.h
CastorCoderFactory::DB
Definition: CastorCoderFactory.h:10
CastorDigiProducer::theCastorHitFilter
CastorHitFilter theCastorHitFilter
Definition: CastorDigiProducer.h:71
CastorDigiProducer::theHitsProducerTag
edm::InputTag theHitsProducerTag
Definition: CastorDigiProducer.h:56
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:63
CastorDigiProducer::theParameterMap
CastorSimParameterMap * theParameterMap
Definition: CastorDigiProducer.h:61
CastorDigiProducer::theAmplifier
CastorAmplifier * theAmplifier
Definition: CastorDigiProducer.h:67
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37