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 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
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
electrons_cff.bool
bool
Definition: electrons_cff.py:372
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
ESHandle.h
HBHEPlan1Combiner::HBHEPlan1Combiner
HBHEPlan1Combiner(const edm::ParameterSet &)
Definition: HBHEPlan1Combiner.cc:65
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
HBHEPlan1Combiner::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HBHEPlan1Combiner.cc:131
parsePlan1RechitCombiner
std::unique_ptr< AbsPlan1RechitCombiner > parsePlan1RechitCombiner(const edm::ParameterSet &ps)
Definition: parsePlan1RechitCombiner.cc:7
HBHERecHitAuxSetter.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HBHEPlan1Combiner::ignorePlan1Topology_
bool ignorePlan1Topology_
Definition: HBHEPlan1Combiner.cc:55
EDProducer.h
HBHERecHitAuxSetter::OFF_TDC_TIME
static const unsigned OFF_TDC_TIME
Definition: HBHERecHitAuxSetter.h:35
edm::SortedCollection::size
size_type size() const
Definition: SortedCollection.h:215
HcalRecNumberingRecord.h
HBHEPlan1Combiner::tok_rechits_
edm::EDGetTokenT< HBHERecHitCollection > tok_rechits_
Definition: HBHEPlan1Combiner.cc:54
HcalTopology::getMergePositionFlag
bool getMergePositionFlag() const
Definition: HcalTopology.h:167
edm::Handle
Definition: AssociativeIterator.h:50
MakerMacros.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
add_param_set
#define add_param_set(name)
Definition: HBHEPlan1Combiner.cc:125
edm::ESHandle< HcalTopology >
HcalRecNumberingRecord
Definition: HcalRecNumberingRecord.h:23
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
ParameterSet
Definition: Functions.h:16
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
qcdUeDQM_cfi.algorithm
algorithm
Definition: qcdUeDQM_cfi.py:32
parsePlan1RechitCombiner.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
CaloRecHitAuxSetter::getBit
constexpr bool getBit(const uint32_t u, const unsigned bitnum)
Definition: CaloRecHitAuxSetter.h:37
edm::EventSetup
Definition: EventSetup.h:57
HBHEPlan1Combiner::combiner_
std::unique_ptr< AbsPlan1RechitCombiner > combiner_
Definition: HBHEPlan1Combiner.cc:59
HBHEPlan1Combiner::usePlan1Mode_
bool usePlan1Mode_
Definition: HBHEPlan1Combiner.cc:56
get
#define get
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
HcalTopology.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
Frameworkfwd.h
HBHEPlan1Combiner::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HBHEPlan1Combiner.cc:88
EventSetup.h
Exception.h
HBHEPlan1Combiner
Definition: HBHEPlan1Combiner.cc:41
cms::Exception
Definition: Exception.h:70
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::ConfigurationDescriptions::addDefault
void addDefault(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:99
StreamID.h
edm::InputTag
Definition: InputTag.h:15
CaloRecHitAuxSetter.h
HBHEPlan1Combiner::~HBHEPlan1Combiner
~HBHEPlan1Combiner() override
Definition: HBHEPlan1Combiner.cc:78