CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloRecHitsProducer.cc
Go to the documentation of this file.
19 
20 // Random engine
22 
23 //#include <iostream>
24 
26  : EcalPreshowerRecHitsMaker_(NULL),EcalBarrelRecHitsMaker_(NULL), EcalEndcapRecHitsMaker_(NULL), HcalRecHitsMaker_(NULL)
27 {
28 
29  // Initialize the random number generator service
31  if ( ! rng.isAvailable() ) {
32  throw cms::Exception("Configuration")
33  << "CaloRecHitsProducer requires the RandomGeneratorService\n"
34  "which is not present in the configuration file.\n"
35  "You must add the service in the configuration file\n"
36  "or remove the module that requires it";
37  }
38  random = new RandomEngine(&(*rng));
39  theInputRecHitCollectionTypes = p.getParameter<std::vector<unsigned> >("InputRecHitCollectionTypes");
40  theOutputRecHitCollections = p.getParameter<std::vector<std::string> >("OutputRecHitCollections");
41  doDigis_ = p.getParameter<bool>("doDigis");
42  doMiscalib_ = p.getParameter<bool>("doMiscalib");
43  edm::ParameterSet RecHitsParameters = p.getParameter<edm::ParameterSet>("RecHitsFactory");
44 
45  for ( unsigned input=0; input<theInputRecHitCollectionTypes.size(); ++input ) {
46 
48 
49  case 1:
50  {
51  //Preshower
52  if (theOutputRecHitCollections.size()&&theOutputRecHitCollections[input].size())
53  produces<ESRecHitCollection>(theOutputRecHitCollections[input]);
54  else
55  produces<ESRecHitCollection>();
56 
57  if (doDigis_)
58  std::cout << " The digitization of the preshower is not implemented " << std::endl;
59 
61  }
62  break;
63 
64  case 2:
65  {
66  //Ecal Barrel
67  if (theOutputRecHitCollections.size()&&theOutputRecHitCollections[input].size())
68  produces<EBRecHitCollection>(theOutputRecHitCollections[input]);
69  else
70  produces<EBRecHitCollection>();
71 
72  if (doDigis_) produces<EBDigiCollection>();
73  EcalBarrelRecHitsMaker_ = new EcalBarrelRecHitsMaker(RecHitsParameters,random);
74  }
75  break;
76 
77  case 3:
78  {
79  //EcalEndcap
80  if (theOutputRecHitCollections.size()&&theOutputRecHitCollections[input].size())
81  produces<EERecHitCollection>(theOutputRecHitCollections[input]);
82  else
83  produces<EERecHitCollection>();
84  if (doDigis_) produces<EEDigiCollection>();
85  EcalEndcapRecHitsMaker_ = new EcalEndcapRecHitsMaker(RecHitsParameters,random);
86  }
87  break;
88 
89  case 4:
90  {
91  //HBHE
92  if (theOutputRecHitCollections.size()&&theOutputRecHitCollections[input].size())
93  produces<HBHERecHitCollection>(theOutputRecHitCollections[input]);
94  else
95  produces<HBHERecHitCollection>();
96 
97  if (doDigis_) produces<HBHEDigiCollection>();
98  HcalRecHitsMaker_ = new HcalRecHitsMaker(RecHitsParameters,4,random);
99  }
100  break;
101 
102  case 5:
103  {
104  //HO
105  if (theOutputRecHitCollections.size()&&theOutputRecHitCollections[input].size())
106  produces<HORecHitCollection>(theOutputRecHitCollections[input]);
107  else
108  produces<HORecHitCollection>();
109 
110  if (doDigis_) produces<HODigiCollection>();
111 
112  HcalRecHitsMaker_ = new HcalRecHitsMaker(RecHitsParameters,5,random);
113  }
114  break;
115 
116  case 6:
117  {
118  //HF
119  if (theOutputRecHitCollections.size()&&theOutputRecHitCollections[input].size())
120  produces<HFRecHitCollection>(theOutputRecHitCollections[input]);
121  else
122  produces<HFRecHitCollection>();
123  if(doDigis_) produces<HFDigiCollection>();
124 
125  HcalRecHitsMaker_ = new HcalRecHitsMaker(RecHitsParameters,6,random);
126  }
127  break;
128 
129  default:
130  // Should not happen
131  break;
132 
133  }
134 
135  }
136 
137 }
138 
140 {
141  if ( random ) {
142  delete random;
143  }
144 }
145 
146 void
148 
149  for ( unsigned input=0; input<theInputRecHitCollectionTypes.size(); ++input ) {
150  switch ( theInputRecHitCollectionTypes[input] ) {
151  case 1:
152  {
153  // preshower
155  }
156  break;
157  case 2:
158  {
159  // ecal barrel
161  }
162  break;
163  case 3:
164  {
165  // ecal endcap
167  }
168  break;
169  case 4:
170  case 5:
171  case 6:
172  {
174  }
175  break;
176  default:
177  break;
178  }
179  }
180 }
181 
183 {
184  //std::cout << " (Fast)RecHitsProducer terminating " << std::endl;
189 }
190 
192 {
194  es.get<IdealGeometryRecord>().get( topo );
195 
196 
197  // create empty outputs for HCAL
198  // see RecoLocalCalo/HcalRecProducers/src/HcalSimpleReconstructor.cc
199  for ( unsigned input=0; input<theInputRecHitCollectionTypes.size(); ++input ) {
200  switch ( theInputRecHitCollectionTypes[input] ) {
201  case 1:
202  {
203  // preshower
204  std::auto_ptr<ESRecHitCollection> reces(new ESRecHitCollection); // ECAL pre-shower
207  iEvent.put(reces,theOutputRecHitCollections[input]);
208  else
209  iEvent.put(reces);
210  break;
211  }
212 
213  case 2:
214  {
215  // ecal barrel
216  std::auto_ptr<EBRecHitCollection> receb(new EBRecHitCollection); // ECAL Barrel
217  std::auto_ptr<EBDigiCollection> digieb(new EBDigiCollection(1));
218  EcalBarrelRecHitsMaker_->loadEcalBarrelRecHits(iEvent,*receb,*digieb);
219  // std::cout << " ECALBarrel " << receb->size() << std::endl;
221  iEvent.put(receb,theOutputRecHitCollections[input]);
222  else
223  iEvent.put(receb);
224 
225  if(doDigis_)
226  iEvent.put(digieb);
227  }
228  break;
229  case 3:
230  {
231  // ecal endcap
232  std::auto_ptr<EERecHitCollection> recee(new EERecHitCollection); // ECAL Endcap
233  std::auto_ptr<EEDigiCollection> digiee(new EEDigiCollection(1));
234  EcalEndcapRecHitsMaker_->loadEcalEndcapRecHits(iEvent,*recee,*digiee);
235  // std::cout << " ECALEndcap " << recee->size() << std::endl;
237  iEvent.put(recee,theOutputRecHitCollections[input]);
238  else
239  iEvent.put(recee);
240 
241  if(doDigis_)
242  iEvent.put(digiee);
243  }
244  break;
245  case 4:
246  {
247  // hbhe
248  std::auto_ptr<HBHERecHitCollection> rec1(new HBHERecHitCollection); // Barrel+Endcap
249  std::auto_ptr<HBHEDigiCollection> digihbhe(new HBHEDigiCollection);
250  HcalRecHitsMaker_->loadHcalRecHits(iEvent,(*topo),*rec1,*digihbhe);
252  iEvent.put(rec1,theOutputRecHitCollections[input]);
253  else
254  iEvent.put(rec1);
255 
256  if(doDigis_)
257  iEvent.put(digihbhe);
258  }
259  break;
260  case 5:
261  {
262  //ho
263  std::auto_ptr<HORecHitCollection> rec2(new HORecHitCollection); // Outer
264  std::auto_ptr<HODigiCollection> digiho(new HODigiCollection);
265 
266  HcalRecHitsMaker_->loadHcalRecHits(iEvent,(*topo),*rec2,*digiho);
268  iEvent.put(rec2,theOutputRecHitCollections[input]);
269  else
270  iEvent.put(rec2);
271  if(doDigis_)
272  iEvent.put(digiho);
273  }
274  break;
275  case 6:
276  {
277  //hf
278  std::auto_ptr<HFRecHitCollection> rec3(new HFRecHitCollection); // Forward
279  std::auto_ptr<HFDigiCollection> digihf(new HFDigiCollection);
280  HcalRecHitsMaker_->loadHcalRecHits(iEvent,(*topo),*rec3,*digihf);
282  iEvent.put(rec3,theOutputRecHitCollections[input]);
283  else
284  iEvent.put(rec3);
285  if(doDigis_)
286  iEvent.put(digihf);
287  }
288  break;
289  default:
290  break;
291  }
292  }
293 }
294 
T getParameter(std::string const &) const
EcalEndcapRecHitsMaker * EcalEndcapRecHitsMaker_
void loadEcalEndcapRecHits(edm::Event &iEvent, EERecHitCollection &ecalHits, EEDigiCollection &ecalDigis)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void beginRun(const edm::Run &run, const edm::EventSetup &es) override
#define NULL
Definition: scimark2.h:8
void loadEcalBarrelRecHits(edm::Event &iEvent, EBRecHitCollection &ecalHits, EBDigiCollection &ecaldigis)
EcalPreshowerRecHitsMaker * EcalPreshowerRecHitsMaker_
HcalRecHitsMaker * HcalRecHitsMaker_
void loadHcalRecHits(edm::Event &iEvent, const HcalTopology &, HBHERecHitCollection &hbheHits, HBHEDigiCollection &hbheDigis)
int iEvent
Definition: GenABIO.cc:243
std::vector< std::string > theOutputRecHitCollections
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
bool isAvailable() const
Definition: Service.h:47
std::vector< unsigned int > theInputRecHitCollectionTypes
const T & get() const
Definition: EventSetup.h:55
void init(const edm::EventSetup &es, bool dodigis, bool domiscalib)
void loadEcalPreshowerRecHits(edm::Event &iEvent, ESRecHitCollection &esRecHits)
EcalBarrelRecHitsMaker * EcalBarrelRecHitsMaker_
virtual void endJob() override
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
void init(const edm::EventSetup &es)
const RandomEngine * random
tuple cout
Definition: gather_cfg.py:121
CaloRecHitsProducer(edm::ParameterSet const &p)
void init(const edm::EventSetup &es, bool dodigis, bool domiscalib)
void init(const edm::EventSetup &es, bool dodigis, bool doMiscalib)
Definition: Run.h:36