CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTRechitsToDigis.cc
Go to the documentation of this file.
1 //
2 // Package: HLTrigger/special
3 // Class: HLTRechitsToDigis
4 //
12 //
13 // Original Author: Joshua Robert Hardenbrook
14 // Created: Fri, 20 Feb 2015 15:51:36 GMT
15 //
16 //
17 
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
27 
29 
34 
37 
38 //
39 // class declaration
40 //
41 
43 public:
44  explicit HLTRechitsToDigis(const edm::ParameterSet&);
46  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
48  static const HLTRechitsToDigis::ecalRegion stringToRegion(const std::string& region);
49 
50 private:
51  virtual void produce( edm::Event&, edm::EventSetup const&) override;
52 
53  // ----------member data ---------------------------
54  // tokens for the digi and rechits for matching
58 
59  // input tags
62 
63  // string for the produced digi collection
66 };
67 //
68 
69 //
70 // constructors and destructor
71 //
73 {
74  //region to do rechit digi matching
75  region_ = stringToRegion(iConfig.getParameter<std::string> ("region"));
76 
77  // digis to match to hit collections
78  digisIn_ = iConfig.getParameter<edm::InputTag> ("digisIn");
79  digisOut_ = iConfig.getParameter<std::string> ("digisOut");
80 
81  // hit collections to save digis for
82  recHits_ = iConfig.getParameter<edm::InputTag> ("recHits");
83 
84  // region specific tokens
85  switch(region_) {
86  case barrel:
87  digisEBInToken_ = consumes<EBDigiCollection>(digisIn_);
88  produces<EBDigiCollection>(digisOut_);
89  break;
90  case endcap:
91  digisEEInToken_ = consumes<EEDigiCollection>(digisIn_);
92  produces<EEDigiCollection>(digisOut_);
93  break;
94  case invalidRegion:
95  break;
96  }
97 
98  recHitsToken_ = consumes<EcalRecHitCollection>(recHits_);
99 }
100 
102 {
103  // do anything here that needs to be done at desctruction time
104  // (e.g. close files, deallocate resources etc.)
105 }
106 
107 //
108 // member functions
109 //
112  if (region == "barrel") return barrel;
113  else if (region == "endcap") return endcap;
114  else return invalidRegion;
115 }
116 
117 
118 // ------------ method called to produce the data ------------
119 void
121  using namespace edm;
122  // handles for digis
123  Handle<EBDigiCollection> digisEBHandle;
124  Handle<EEDigiCollection> digisEEHandle;
125 
126  // output collections
127  std::auto_ptr<EBDigiCollection> outputEBDigiCollection( new EBDigiCollection );
128  std::auto_ptr<EEDigiCollection> outputEEDigiCollection( new EEDigiCollection );
129 
130  // calibrated rechits
131  Handle<EcalRecHitCollection> recHitsHandle;
132  iEvent.getByToken(recHitsToken_, recHitsHandle);
133 
134  // match the digis based on the region
135  switch(region_) {
136  case barrel: {
137  iEvent.getByToken(digisEBInToken_, digisEBHandle);
138  const EBDigiCollection* digisEB = digisEBHandle.product();
139 
140  // loop over the collection of rechits and match to digis
142  for (ituneEB = recHitsHandle->begin(); ituneEB != recHitsHandle->end(); ituneEB++) {
143  EcalRecHit hit = (*ituneEB);
144  outputEBDigiCollection->push_back( (*digisEB->find(hit.id())).id(), (*digisEB->find(hit.id())).begin() );
145  }
146 
147  iEvent.put( outputEBDigiCollection, digisOut_);
148  break;
149  }
150 
151  case endcap: {
152  iEvent.getByToken(digisEEInToken_, digisEEHandle);
153  const EEDigiCollection* digisEE = digisEEHandle.product();
154 
155  // loop over the collection of rechits and match to digis
157  for (ituneEE = recHitsHandle->begin(); ituneEE != recHitsHandle->end(); ituneEE++) {
158  EcalRecHit hit = (*ituneEE);
159  outputEEDigiCollection->push_back( (*digisEE->find(hit.id())).id(), (*digisEE->find(hit.id())).begin() );
160  }
161 
162  iEvent.put(outputEEDigiCollection, digisOut_);
163  break;
164  }
165  case invalidRegion: {
166  break;
167  }
168  }
169 }
170 
171 // ------------ method called when starting to processes a run ------------
172 /*
173 void
174 HLTRechitsToDigis::beginRun(edm::Run const&, edm::EventSetup const&)
175 {
176 }
177 */
178 
179 // ------------ method called when ending the processing of a run ------------
180 /*
181 void
182 HLTRechitsToDigis::endRun(edm::Run const&, edm::EventSetup const&)
183 {
184 }
185 */
186 
187 // ------------ method called when starting to processes a luminosity block ------------
188 /*
189 void
190 HLTRechitsToDigis::beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
191 {
192 }
193 */
194 
195 // ------------ method called when ending the processing of a luminosity block ------------
196 /*
197 void
198 HLTRechitsToDigis::endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&)
199 {
200 }
201 */
202 
203 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
204 void
206  //The following says we do not know what parameters are allowed so do no validation
207  // Please change this to state exactly what you do use, even if it is no parameters
209 
210  desc.add<std::string>("region", "barrel")
211  ->setComment("Region of rechits to save Digis for. Allowed values: barrel or endcap.");
212  desc.add<edm::InputTag>("digisIn",edm::InputTag("ecalDigis","ebDigis"))
213  ->setComment("The collection of either barrel or endcap digis which correspond to the rechit collection");
214  desc.add<std::string>("digisOut","pi0EBDigis")
215  ->setComment("Name for the collection of Digis saved by the module");
216  desc.add<edm::InputTag>("recHits",edm::InputTag("hltAlCaPi0EBUncalibrator","pi0EcalRecHitsEB"))
217  ->setComment("Collection of rechits to match Digis to");
218  descriptions.add("hltFindMatchingECALDigisToRechits", desc);
219 }
220 
221 //define this as a plug-in
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< EcalRecHit >::const_iterator const_iterator
edm::EDGetTokenT< EEDigiCollection > digisEEInToken_
virtual void produce(edm::Event &, edm::EventSetup const &) override
const_iterator find(id_type i) const
HLTRechitsToDigis(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:230
static const HLTRechitsToDigis::ecalRegion stringToRegion(const std::string &region)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
edm::EDGetTokenT< EcalRecHitCollection > recHitsToken_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::InputTag digisIn_
DetId id() const
get the id
Definition: EcalRecHit.h:76
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::InputTag recHits_
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
edm::EDGetTokenT< EBDigiCollection > digisEBInToken_