CMS 3D CMS Logo

HBHEPlan1Combiner.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RecoLocalCalo/HcalRecProducers
4 // Class: HBHEPlan1Combiner
5 //
13 //
14 // Original Author: Igor Volobouev
15 // Created: Sun, 29 Jan 2017 16:05:31 GMT
16 //
17 //
18 
25 
29 
32 
34 
37 
38 //
39 // class declaration
40 //
42 {
43 public:
44  explicit HBHEPlan1Combiner(const edm::ParameterSet&);
46 
47  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
48 
49 private:
50  virtual void produce(edm::Event&, const edm::EventSetup&) override;
51 
52  // ----------member data ---------------------------
53 
54  // Configuration parameters
58 
59  // Other members
60  std::unique_ptr<AbsPlan1RechitCombiner> combiner_;
61 };
62 
63 //
64 // constructors and destructor
65 //
67  : ignorePlan1Topology_(conf.getParameter<bool>("ignorePlan1Topology")),
68  usePlan1Mode_(conf.getParameter<bool>("usePlan1Mode")),
69  combiner_(parsePlan1RechitCombiner(conf.getParameter<edm::ParameterSet>("algorithm")))
70 {
71  // Check that the rechit recombination algorithm has been successfully configured
72  if (!combiner_.get())
73  throw cms::Exception("HBHEPlan1BadConfig")
74  << "Invalid Plan1RechitCombiner algorithm configuration"
75  << std::endl;
76 
77  // Consumes and produces statements
78  tok_rechits_ = consumes<HBHERecHitCollection>(conf.getParameter<edm::InputTag>("hbheInput"));
79  produces<HBHERecHitCollection>();
80 }
81 
82 
84 {
85  // do anything here that needs to be done at destruction time
86  // (e.g. close files, deallocate resources etc.)
87 }
88 
89 
90 //
91 // member functions
92 //
93 
94 // ------------ method called to produce the data ------------
95 void
97 {
98  using namespace edm;
99 
100  // Get the Hcal topology
102  eventSetup.get<HcalRecNumberingRecord>().get(htopo);
103  combiner_->setTopo(htopo.product());
104 
105  // Are we using "Plan 1" geometry?
106  const bool plan1Mode = ignorePlan1Topology_ ? usePlan1Mode_
107  : htopo->withSpecialRBXHBHE();
108 
109  // Find the input rechit collection
110  Handle<HBHERecHitCollection> inputRechits;
111  iEvent.getByToken(tok_rechits_, inputRechits);
112 
113  // Create a new output collections
114  std::unique_ptr<HBHERecHitCollection> outputRechits = std::make_unique<HBHERecHitCollection>();
115  outputRechits->reserve(inputRechits->size());
116 
117  // Iterate over the input collection. Copy QIE8 rechits directly into
118  // the output collection and prepare to combine QIE11 rechits.
119  combiner_->clear();
120  for (typename HBHERecHitCollection::const_iterator it = inputRechits->begin();
121  it != inputRechits->end(); ++it)
122  {
123  // If the rechit has TDC time info, it corresponds to QIE11
124  if (plan1Mode && CaloRecHitAuxSetter::getBit(
125  it->auxPhase1(), HBHERecHitAuxSetter::OFF_TDC_TIME))
126  combiner_->add(*it);
127  else
128  outputRechits->push_back(*it);
129  }
130 
131  // Combine QIE11 rechits and fill the output collection
132  combiner_->combine(&*outputRechits);
133 
134  // Put the output collection into the Event
135  iEvent.put(std::move(outputRechits));
136 }
137 
138 #define add_param_set(name) \
139  edm::ParameterSetDescription name; \
140  name.setAllowAnything(); \
141  desc.add<edm::ParameterSetDescription>(#name, name)
142 
143 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
144 void
146 {
148 
149  desc.add<edm::InputTag>("hbheInput");
150  desc.add<bool>("ignorePlan1Topology");
151  desc.add<bool>("usePlan1Mode");
152 
154 
155  descriptions.addDefault(desc);
156 }
157 
158 //define this as a plug-in
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
HBHEPlan1Combiner(const edm::ParameterSet &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< HBHERecHit >::const_iterator const_iterator
edm::EDGetTokenT< HBHERecHitCollection > tok_rechits_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::unique_ptr< AbsPlan1RechitCombiner > parsePlan1RechitCombiner(const edm::ParameterSet &ps)
static const unsigned OFF_TDC_TIME
int iEvent
Definition: GenABIO.cc:230
void addDefault(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::unique_ptr< AbsPlan1RechitCombiner > combiner_
const_iterator end() const
const T & get() const
Definition: EventSetup.h:56
#define add_param_set(name)
HLT enums.
size_type size() const
virtual void produce(edm::Event &, const edm::EventSetup &) override
bool getBit(const uint32_t u, const unsigned bitnum)
bool withSpecialRBXHBHE() const
Definition: HcalTopology.h:162
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510
const_iterator begin() const