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  // 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
electrons_cff.bool
bool
Definition: electrons_cff.py:366
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
HBHEPlan1Combiner::HBHEPlan1Combiner
HBHEPlan1Combiner(const edm::ParameterSet &)
Definition: HBHEPlan1Combiner.cc:68
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
HBHEPlan1Combiner::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HBHEPlan1Combiner.cc:136
parsePlan1RechitCombiner
std::unique_ptr< AbsPlan1RechitCombiner > parsePlan1RechitCombiner(const edm::ParameterSet &ps)
Definition: parsePlan1RechitCombiner.cc:7
HcalTopology
Definition: HcalTopology.h:26
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
ESGetToken.h
MakerMacros.h
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:130
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:47
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:36
CaloRecHitAuxSetter::getBit
constexpr bool getBit(const uint32_t u, const unsigned bitnum)
Definition: CaloRecHitAuxSetter.h:37
edm::EventSetup
Definition: EventSetup.h:58
HBHEPlan1Combiner::combiner_
std::unique_ptr< AbsPlan1RechitCombiner > combiner_
Definition: HBHEPlan1Combiner.cc:59
HBHEPlan1Combiner::usePlan1Mode_
bool usePlan1Mode_
Definition: HBHEPlan1Combiner.cc:56
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord >
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
HcalTopology.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
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:94
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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
HBHEPlan1Combiner::htopoToken_
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > htopoToken_
Definition: HBHEPlan1Combiner.cc:62
StreamID.h
edm::InputTag
Definition: InputTag.h:15
CaloRecHitAuxSetter.h
HBHEPlan1Combiner::~HBHEPlan1Combiner
~HBHEPlan1Combiner() override
Definition: HBHEPlan1Combiner.cc:84