CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorDigiProducer.cc
Go to the documentation of this file.
18 
19 using namespace std;
20 
21 
23 : theParameterMap(new CastorSimParameterMap(ps)),
24  theCastorShape(new CastorShape()),
25  theCastorIntegratedShape(new CaloShapeIntegrator(theCastorShape)),
26  theCastorResponse(new CaloHitResponse(theParameterMap, theCastorIntegratedShape)),
27  theAmplifier(0),
28  theCoderFactory(0),
29  theElectronicsSim(0),
30  theHitCorrection(0),
31  theCastorDigitizer(0),
32  theCastorHits()
33 {
34 
35 produces<CastorDigiCollection>();
36 
38 
39 bool doTimeSlew = ps.getParameter<bool>("doTimeSlew");
40  if(doTimeSlew) {
41  // no time slewing for HF
43  }
44 
45  bool doNoise = ps.getParameter<bool>("doNoise");
49 
51 
53  if ( ! rng.isAvailable()) {
54  throw cms::Exception("Configuration")
55  << "CastorDigiProducer requires the RandomNumberGeneratorService\n"
56  "which is not present in the configuration file. You must add the service\n"
57  "in the configuration file or remove the modules that require it.";
58  }
59 
60  CLHEP::HepRandomEngine& engine = rng->getEngine();
61  theAmplifier->setRandomEngine(engine);
63 }
64 
65 
67  delete theCastorDigitizer;
68  delete theParameterMap;
69  delete theCastorShape;
71  delete theCastorResponse;
72  delete theElectronicsSim;
73  delete theAmplifier;
74  delete theCoderFactory;
75  delete theHitCorrection;
76 }
77 
78 
80  // get the appropriate gains, noises, & widths for this event
82  eventSetup.get<CastorDbRecord>().get(conditions);
83  theAmplifier->setDbService(conditions.product());
84  theCoderFactory->setDbService(conditions.product());
85  theParameterMap->setDbService(conditions.product());
86 
87 edm::LogInfo("CastorDigiProducer") << "checking the geometry...";
88 
89  // get the correct geometry
90 checkGeometry(eventSetup);
91 
92 theCastorHits.clear();
93 
94  // Step A: Get Inputs
95 //edm::Handle<edm::PCaloHitContainer> castorcf;
97 e.getByLabel("mix", "g4SimHitsCastorFI", castorcf);
98 
99  // test access to SimHits for HcalHits and ZDC hits
100 std::auto_ptr<MixCollection<PCaloHit> > colcastor(new MixCollection<PCaloHit>(castorcf.product()));
101 
102  //fillFakeHits();
103 
104 if(theHitCorrection != 0)
105  {
106 theHitCorrection->fillChargeSums(*colcastor);
107  }
108  // Step B: Create empty output
109 
110 std::auto_ptr<CastorDigiCollection> castorResult(new CastorDigiCollection());
111 
112  // Step C: Invoke the algorithm, passing in inputs and getting back outputs.
113 theCastorDigitizer->run(*colcastor, *castorResult);
114 
115 edm::LogInfo("CastorDigiProducer") << "HCAL/Castor digis : " << castorResult->size();
116 
117  // Step D: Put outputs into event
118 e.put(castorResult);
119 }
120 
121 
123  for(edm::PCaloHitContainer::const_iterator hitItr = hits.begin();
124  hitItr != hits.end(); ++hitItr){
125  DetId detId = hitItr->id();
126  if (detId.det()==DetId::Calo && detId.subdetId()==HcalCastorDetId::SubdetectorId){
127  theCastorHits.push_back(*hitItr);
128  }
129  else {
130  edm::LogError("CastorDigiProducer") << "Bad Hit subdetector " << detId.subdetId();
131  }
132  }
133 }
134 
136 HcalCastorDetId castorDetId(HcalCastorDetId::Section(2),true,1,1);
137 PCaloHit castorHit(castorDetId.rawId(), 50.0, 0.);
138 
139 theCastorHits.push_back(castorHit);
140 }
141 
142 
144  // TODO find a way to avoid doing this every event
146 eventSetup.get<CaloGeometryRecord>().get(geometry);
147 theCastorResponse->setGeometry(&*geometry);
148 
149 const vector<DetId>& castorCells = geometry->getValidDetIds(DetId::Calo, HcalCastorDetId::SubdetectorId);
150 
151 //std::cout<<"CastorDigiProducer::CheckGeometry number of cells: "<<castorCells.size()<<std::endl;
152 theCastorDigitizer->setDetIds(castorCells);
153 }
154 
155 
T getParameter(std::string const &) const
void setGeometry(const CaloGeometry *geometry)
geometry needed for time-of-flight
CastorAmplifier * theAmplifier
CaloVShape * theCastorShape
std::vector< PCaloHit > PCaloHitContainer
void fillChargeSums(MixCollection< PCaloHit > &hits)
CaloTDigitizer< CastorDigitizerTraits > CastorDigitizer
void checkGeometry(const edm::EventSetup &eventSetup)
void setDbService(const CastorDbService *service)
CastorSimParameterMap * theParameterMap
void sortHits(const edm::PCaloHitContainer &hits)
fills the vectors for each subdetector
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
CastorElectronicsSim * theElectronicsSim
CastorHitFilter theCastorHitFilter
void setHitFilter(const CaloVHitFilter *filter)
if you want to reject hits, for example, from a certain subdetector, set this
Creates electronics signals from hits.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
void run(MixCollection< PCaloHit > &input, DigiCollection &output)
turns hits into digis
virtual void produce(edm::Event &e, const edm::EventSetup &c)
CaloHitResponse * theCastorResponse
bool isAvailable() const
Definition: Service.h:47
std::vector< PCaloHit > theCastorHits
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
void fillFakeHits()
some hits in each subdetector, just for testing purposes
void setRandomEngine(CLHEP::HepRandomEngine &engine)
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
static const int SubdetectorId
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
Definition: DetId.h:20
CastorDigiProducer(const edm::ParameterSet &ps)
const T & get() const
Definition: EventSetup.h:55
CastorHitCorrection * theHitCorrection
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
ESHandle< TrackerGeometry > geometry
CastorDigitizer * theCastorDigitizer
void setHitCorrection(const CaloVHitCorrection *hitCorrection)
If you want to correct hits, for attenuation or delay, set this.
CastorCoderFactory * theCoderFactory
void setDetIds(const std::vector< DetId > &detIds)
shaper for Castor
Definition: CastorShape.h:16
edm::SortedCollection< CastorDataFrame > CastorDigiCollection
void setDbService(const CastorDbService *service)
the Producer will probably update this every event
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
void setDbService(const CastorDbService *service)
CaloVShape * theCastorIntegratedShape