CMS 3D CMS Logo

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