CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloRecHitCopy.cc
Go to the documentation of this file.
1 
7 
9 
10 #include <iostream>
11 
13 
14 {
15 
16  theInputRecHitCollectionTypes = p.getParameter<std::vector<unsigned> >("InputRecHitCollectionTypes");
17  theInputRecHitCollections = p.getParameter<std::vector<edm::InputTag> >("InputRecHitCollections");
18  theOutputRecHitCollections = p.getParameter<std::vector<std::string> >("OutputRecHitCollections");
19 
21 
22  for ( unsigned input=0; input<theInputRecHitCollectionTypes.size(); ++input ) {
23 
25  theOutputRecHitCollections[input] == "none" ?
26  false : true;
27 
29 
30  case 1:
31  {
32  //Preshower
33  if ( !theOutputRecHitInstances[input] )
34  produces<ESRecHitCollection>();
35  else
36  produces<ESRecHitCollection>(theOutputRecHitCollections[input]);
37  }
38  break;
39 
40  case 2:
41  {
42  //Ecal Barrel
43  if ( !theOutputRecHitInstances[input] )
44  produces<EBRecHitCollection>();
45  else
46  produces<EBRecHitCollection>(theOutputRecHitCollections[input]);
47  }
48  break;
49 
50  case 3:
51  {
52  //EcalEndcap
53  if ( !theOutputRecHitInstances[input] )
54  produces<EERecHitCollection>();
55  else
56  produces<EERecHitCollection>(theOutputRecHitCollections[input]);
57  }
58  break;
59 
60  case 4:
61  {
62  //HCAL
63  if ( !theOutputRecHitInstances[input] )
64  produces<HBHERecHitCollection>();
65  else
66  produces<HBHERecHitCollection>(theOutputRecHitCollections[input]);
67  }
68  break;
69 
70  case 5:
71  {
72  //HO
73  if ( !theOutputRecHitInstances[input] )
74  produces<HORecHitCollection>();
75  else
76  produces<HORecHitCollection>(theOutputRecHitCollections[input]);
77  }
78  break;
79 
80  case 6:
81  {
82  //HF
83  if ( !theOutputRecHitInstances[input] )
84  produces<HFRecHitCollection>();
85  else
86  produces<HFRecHitCollection>(theOutputRecHitCollections[input]);
87  }
88  break;
89 
90  default:
91  // Should not happen
92  break;
93 
94  }
95 
96  }
97 
98 
99 }
100 
102 
103 void
105 
106 void
108 {
109 
110 
111  for ( unsigned input=0; input<theInputRecHitCollectionTypes.size(); ++input ) {
112 
113  switch ( theInputRecHitCollectionTypes[input] ) {
114 
115  case 1:
116  {
117  //Preshower
118  std::auto_ptr< ESRecHitCollection > copiedESRecHitCollection( new ESRecHitCollection );
120  iEvent.getByLabel(theInputRecHitCollections[input],ESRecHits);
121  ESRecHitCollection::const_iterator itES = ESRecHits->begin();
122  ESRecHitCollection::const_iterator lastES = ESRecHits->end();
123  // saves a bit of CPU
124  copiedESRecHitCollection->reserve(ESRecHits->size());
125  for ( ; itES!=lastES; ++itES++ ) {
126  EcalRecHit aHit(*itES);
127  copiedESRecHitCollection->push_back(aHit);
128  }
129  if ( !theOutputRecHitInstances[input] )
130  iEvent.put(copiedESRecHitCollection);
131  else
132  iEvent.put(copiedESRecHitCollection,theOutputRecHitCollections[input]);
133  }
134  break;
135 
136  case 2:
137  {
138  //Ecal Barrel
139  std::auto_ptr< EBRecHitCollection > copiedEBRecHitCollection( new EBRecHitCollection );
141  iEvent.getByLabel(theInputRecHitCollections[input],EBRecHits);
142  EBRecHitCollection::const_iterator itEB = EBRecHits->begin();
143  EBRecHitCollection::const_iterator lastEB = EBRecHits->end();
144  //saves a bit of CPU
145  copiedEBRecHitCollection->reserve(EBRecHits->size());
146 
147  for ( ; itEB!=lastEB; ++itEB++ ) {
148  EcalRecHit aHit(*itEB);
149  copiedEBRecHitCollection->push_back(aHit);
150  }
151  if ( !theOutputRecHitInstances[input] )
152  iEvent.put(copiedEBRecHitCollection);
153  else
154  iEvent.put(copiedEBRecHitCollection,theOutputRecHitCollections[input]);
155  }
156  break;
157 
158  case 3:
159  {
160  //EcalEndcap
161  std::auto_ptr< EERecHitCollection > copiedEERecHitCollection( new EERecHitCollection );
163  iEvent.getByLabel(theInputRecHitCollections[input],EERecHits);
164  EERecHitCollection::const_iterator itEE = EERecHits->begin();
165  EERecHitCollection::const_iterator lastEE = EERecHits->end();
166  //saves a bit of CPU
167  copiedEERecHitCollection->reserve(EERecHits->size());
168 
169  for ( ; itEE!=lastEE; ++itEE++ ) {
170  EcalRecHit aHit(*itEE);
171  copiedEERecHitCollection->push_back(aHit);
172  }
173  if ( !theOutputRecHitInstances[input] )
174  iEvent.put(copiedEERecHitCollection);
175  else
176  iEvent.put(copiedEERecHitCollection,theOutputRecHitCollections[input]);
177  }
178  break;
179 
180  case 4:
181  {
182  //HCAL
183  std::auto_ptr< HBHERecHitCollection > copiedHBHERecHitCollection( new HBHERecHitCollection );
185  iEvent.getByLabel(theInputRecHitCollections[input],HBHERecHits);
186  HBHERecHitCollection::const_iterator itHBHE = HBHERecHits->begin();
187  HBHERecHitCollection::const_iterator lastHBHE = HBHERecHits->end();
188  //saves a bit of CPU
189  copiedHBHERecHitCollection->reserve(HBHERecHits->size());
190 
191  for ( ; itHBHE!=lastHBHE; ++itHBHE++ ) {
192  HBHERecHit aHit(*itHBHE);
193  copiedHBHERecHitCollection->push_back(aHit);
194  }
195  if ( !theOutputRecHitInstances[input] )
196  iEvent.put(copiedHBHERecHitCollection);
197  else
198  iEvent.put(copiedHBHERecHitCollection,theOutputRecHitCollections[input]);
199  }
200  break;
201 
202  case 5:
203  {
204  //HO
205  std::auto_ptr< HORecHitCollection > copiedHORecHitCollection( new HORecHitCollection );
207  iEvent.getByLabel(theInputRecHitCollections[input],HORecHits);
208  HORecHitCollection::const_iterator itHO = HORecHits->begin();
209  HORecHitCollection::const_iterator lastHO = HORecHits->end();
210  //saves a bit of CPU
211  copiedHORecHitCollection->reserve(HORecHits->size());
212 
213  for ( ; itHO!=lastHO; ++itHO++ ) {
214  HORecHit aHit(*itHO);
215  copiedHORecHitCollection->push_back(aHit);
216  }
217  if ( !theOutputRecHitInstances[input] )
218  iEvent.put(copiedHORecHitCollection);
219  else
220  iEvent.put(copiedHORecHitCollection,theOutputRecHitCollections[input]);
221  }
222  break;
223 
224  case 6:
225  {
226  //HF
227  std::auto_ptr< HFRecHitCollection > copiedHFRecHitCollection( new HFRecHitCollection );
229  iEvent.getByLabel(theInputRecHitCollections[input],HFRecHits);
230  HFRecHitCollection::const_iterator itHF = HFRecHits->begin();
231  HFRecHitCollection::const_iterator lastHF = HFRecHits->end();
232  //saves a bit of CPU
233  copiedHFRecHitCollection->reserve(HFRecHits->size());
234 
235  for ( ; itHF!=lastHF; ++itHF++ ) {
236  HFRecHit aHit(*itHF);
237  copiedHFRecHitCollection->push_back(aHit);
238  }
239  if ( !theOutputRecHitInstances[input] )
240  iEvent.put(copiedHFRecHitCollection);
241  else
242  iEvent.put(copiedHFRecHitCollection,theOutputRecHitCollections[input]);
243  }
244  break;
245 
246  default:
247  // Should not happen
248  break;
249 
250  }
251 
252  }
253 
254 }
255 
T getParameter(std::string const &) const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void produce(edm::Event &e, const edm::EventSetup &c)
std::vector< bool > theOutputRecHitInstances
std::vector< EcalRecHit >::const_iterator const_iterator
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
std::vector< unsigned int > theInputRecHitCollectionTypes
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::vector< std::string > theOutputRecHitCollections
std::vector< edm::InputTag > theInputRecHitCollections
virtual ~CaloRecHitCopy()
CaloRecHitCopy(edm::ParameterSet const &p)
virtual void endRun()