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 
107 
108  for ( unsigned input=0; input<theInputRecHitCollectionTypes.size(); ++input ) {
109 
110  switch ( theInputRecHitCollectionTypes[input] ) {
111 
112  case 1:
113  {
114  //Preshower
115  std::auto_ptr< ESRecHitCollection > copiedESRecHitCollection( new ESRecHitCollection );
117  iEvent.getByLabel(theInputRecHitCollections[input],ESRecHits);
118  ESRecHitCollection::const_iterator itES = ESRecHits->begin();
119  ESRecHitCollection::const_iterator lastES = ESRecHits->end();
120  // saves a bit of CPU
121  copiedESRecHitCollection->reserve(ESRecHits->size());
122  for ( ; itES!=lastES; ++itES++ ) {
123  EcalRecHit aHit(*itES);
124  copiedESRecHitCollection->push_back(aHit);
125  }
126  if ( !theOutputRecHitInstances[input] )
127  iEvent.put(copiedESRecHitCollection);
128  else
129  iEvent.put(copiedESRecHitCollection,theOutputRecHitCollections[input]);
130  }
131  break;
132 
133  case 2:
134  {
135  //Ecal Barrel
136  std::auto_ptr< EBRecHitCollection > copiedEBRecHitCollection( new EBRecHitCollection );
138  iEvent.getByLabel(theInputRecHitCollections[input],EBRecHits);
139  EBRecHitCollection::const_iterator itEB = EBRecHits->begin();
140  EBRecHitCollection::const_iterator lastEB = EBRecHits->end();
141  //saves a bit of CPU
142  copiedEBRecHitCollection->reserve(EBRecHits->size());
143 
144  for ( ; itEB!=lastEB; ++itEB++ ) {
145  EcalRecHit aHit(*itEB);
146  copiedEBRecHitCollection->push_back(aHit);
147  }
148  if ( !theOutputRecHitInstances[input] )
149  iEvent.put(copiedEBRecHitCollection);
150  else
151  iEvent.put(copiedEBRecHitCollection,theOutputRecHitCollections[input]);
152  }
153  break;
154 
155  case 3:
156  {
157  //EcalEndcap
158  std::auto_ptr< EERecHitCollection > copiedEERecHitCollection( new EERecHitCollection );
160  iEvent.getByLabel(theInputRecHitCollections[input],EERecHits);
161  EERecHitCollection::const_iterator itEE = EERecHits->begin();
162  EERecHitCollection::const_iterator lastEE = EERecHits->end();
163  //saves a bit of CPU
164  copiedEERecHitCollection->reserve(EERecHits->size());
165 
166  for ( ; itEE!=lastEE; ++itEE++ ) {
167  EcalRecHit aHit(*itEE);
168  copiedEERecHitCollection->push_back(aHit);
169  }
170  if ( !theOutputRecHitInstances[input] )
171  iEvent.put(copiedEERecHitCollection);
172  else
173  iEvent.put(copiedEERecHitCollection,theOutputRecHitCollections[input]);
174  }
175  break;
176 
177  case 4:
178  {
179  //HCAL
180  std::auto_ptr< HBHERecHitCollection > copiedHBHERecHitCollection( new HBHERecHitCollection );
182  iEvent.getByLabel(theInputRecHitCollections[input],HBHERecHits);
183  HBHERecHitCollection::const_iterator itHBHE = HBHERecHits->begin();
184  HBHERecHitCollection::const_iterator lastHBHE = HBHERecHits->end();
185  //saves a bit of CPU
186  copiedHBHERecHitCollection->reserve(HBHERecHits->size());
187 
188  for ( ; itHBHE!=lastHBHE; ++itHBHE++ ) {
189  HBHERecHit aHit(*itHBHE);
190  copiedHBHERecHitCollection->push_back(aHit);
191  }
192  if ( !theOutputRecHitInstances[input] )
193  iEvent.put(copiedHBHERecHitCollection);
194  else
195  iEvent.put(copiedHBHERecHitCollection,theOutputRecHitCollections[input]);
196  }
197  break;
198 
199  case 5:
200  {
201  //HO
202  std::auto_ptr< HORecHitCollection > copiedHORecHitCollection( new HORecHitCollection );
204  iEvent.getByLabel(theInputRecHitCollections[input],HORecHits);
205  HORecHitCollection::const_iterator itHO = HORecHits->begin();
206  HORecHitCollection::const_iterator lastHO = HORecHits->end();
207  //saves a bit of CPU
208  copiedHORecHitCollection->reserve(HORecHits->size());
209 
210  for ( ; itHO!=lastHO; ++itHO++ ) {
211  HORecHit aHit(*itHO);
212  copiedHORecHitCollection->push_back(aHit);
213  }
214  if ( !theOutputRecHitInstances[input] )
215  iEvent.put(copiedHORecHitCollection);
216  else
217  iEvent.put(copiedHORecHitCollection,theOutputRecHitCollections[input]);
218  }
219  break;
220 
221  case 6:
222  {
223  //HF
224  std::auto_ptr< HFRecHitCollection > copiedHFRecHitCollection( new HFRecHitCollection );
226  iEvent.getByLabel(theInputRecHitCollections[input],HFRecHits);
227  HFRecHitCollection::const_iterator itHF = HFRecHits->begin();
228  HFRecHitCollection::const_iterator lastHF = HFRecHits->end();
229  //saves a bit of CPU
230  copiedHFRecHitCollection->reserve(HFRecHits->size());
231 
232  for ( ; itHF!=lastHF; ++itHF++ ) {
233  HFRecHit aHit(*itHF);
234  copiedHFRecHitCollection->push_back(aHit);
235  }
236  if ( !theOutputRecHitInstances[input] )
237  iEvent.put(copiedHFRecHitCollection);
238  else
239  iEvent.put(copiedHFRecHitCollection,theOutputRecHitCollections[input]);
240  }
241  break;
242 
243  default:
244  // Should not happen
245  break;
246 
247  }
248 
249  }
250 
251 }
252 
T getParameter(std::string const &) const
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< bool > theOutputRecHitInstances
std::vector< EcalRecHit >::const_iterator const_iterator
static std::string const input
Definition: EdmProvDump.cc:44
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
std::vector< unsigned int > theInputRecHitCollectionTypes
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
std::vector< std::string > theOutputRecHitCollections
std::vector< edm::InputTag > theInputRecHitCollections
virtual ~CaloRecHitCopy()
CaloRecHitCopy(edm::ParameterSet const &p)