CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 public:
43  explicit HBHEPlan1Combiner(const edm::ParameterSet&);
44  ~HBHEPlan1Combiner() override;
45 
46  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
47 
48 private:
49  void produce(edm::Event&, const edm::EventSetup&) override;
50 
51  // ----------member data ---------------------------
52 
53  // Configuration parameters
57 
58  // Other members
59  std::unique_ptr<AbsPlan1RechitCombiner> combiner_;
60 };
61 
62 //
63 // constructors and destructor
64 //
66  : ignorePlan1Topology_(conf.getParameter<bool>("ignorePlan1Topology")),
67  usePlan1Mode_(conf.getParameter<bool>("usePlan1Mode")),
68  combiner_(parsePlan1RechitCombiner(conf.getParameter<edm::ParameterSet>("algorithm"))) {
69  // Check that the rechit recombination algorithm has been successfully configured
70  if (!combiner_.get())
71  throw cms::Exception("HBHEPlan1BadConfig") << "Invalid Plan1RechitCombiner algorithm configuration" << std::endl;
72 
73  // Consumes and produces statements
74  tok_rechits_ = consumes<HBHERecHitCollection>(conf.getParameter<edm::InputTag>("hbheInput"));
75  produces<HBHERecHitCollection>();
76 }
77 
79  // do anything here that needs to be done at destruction time
80  // (e.g. close files, deallocate resources etc.)
81 }
82 
83 //
84 // member functions
85 //
86 
87 // ------------ method called to produce the data ------------
89  using namespace edm;
90 
91  // Get the Hcal topology
93  eventSetup.get<HcalRecNumberingRecord>().get(htopo);
94  combiner_->setTopo(htopo.product());
95 
96  // Are we using "Plan 1" geometry?
97  const bool plan1Mode = ignorePlan1Topology_ ? usePlan1Mode_ : htopo->getMergePositionFlag();
98 
99  // Find the input rechit collection
100  Handle<HBHERecHitCollection> inputRechits;
101  iEvent.getByToken(tok_rechits_, inputRechits);
102 
103  // Create a new output collections
104  std::unique_ptr<HBHERecHitCollection> outputRechits = std::make_unique<HBHERecHitCollection>();
105  outputRechits->reserve(inputRechits->size());
106 
107  // Iterate over the input collection. Copy QIE8 rechits directly into
108  // the output collection and prepare to combine QIE11 rechits.
109  combiner_->clear();
110  for (typename HBHERecHitCollection::const_iterator it = inputRechits->begin(); it != inputRechits->end(); ++it) {
111  // If the rechit has TDC time info, it corresponds to QIE11
112  if (plan1Mode && CaloRecHitAuxSetter::getBit(it->auxPhase1(), HBHERecHitAuxSetter::OFF_TDC_TIME))
113  combiner_->add(*it);
114  else
115  outputRechits->push_back(*it);
116  }
117 
118  // Combine QIE11 rechits and fill the output collection
119  combiner_->combine(&*outputRechits);
120 
121  // Put the output collection into the Event
122  iEvent.put(std::move(outputRechits));
123 }
124 
125 #define add_param_set(name) \
126  edm::ParameterSetDescription name; \
127  name.setAllowAnything(); \
128  desc.add<edm::ParameterSetDescription>(#name, name)
129 
130 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
133 
134  desc.add<edm::InputTag>("hbheInput");
135  desc.add<bool>("ignorePlan1Topology");
136  desc.add<bool>("usePlan1Mode");
137 
139 
140  descriptions.addDefault(desc);
141 }
142 
143 //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:131
HBHEPlan1Combiner(const edm::ParameterSet &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
std::vector< T >::const_iterator const_iterator
edm::EDGetTokenT< HBHERecHitCollection > tok_rechits_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool getMergePositionFlag() const
Definition: HcalTopology.h:167
std::unique_ptr< AbsPlan1RechitCombiner > parsePlan1RechitCombiner(const edm::ParameterSet &ps)
static const unsigned OFF_TDC_TIME
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void addDefault(ParameterSetDescription const &psetDescription)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
constexpr bool getBit(const uint32_t u, const unsigned bitnum)
std::unique_ptr< AbsPlan1RechitCombiner > combiner_
const_iterator end() const
#define add_param_set(name)
HLT enums.
size_type size() const
~HBHEPlan1Combiner() override
T get() const
Definition: EventSetup.h:73
void produce(edm::Event &, const edm::EventSetup &) override
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
const_iterator begin() const