test
CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalUncalibRecHitProducer.cc
Go to the documentation of this file.
4 
7 
9 
12 
15 
21 
23 {
24  ebHitCollection_ = ps.getParameter<std::string>("EBhitCollection");
25  eeHitCollection_ = ps.getParameter<std::string>("EEhitCollection");
26  produces< EBUncalibratedRecHitCollection >(ebHitCollection_);
27  produces< EEUncalibratedRecHitCollection >(eeHitCollection_);
28 
29  ebDigiCollectionToken_ = consumes<EBDigiCollection>(ps.getParameter<edm::InputTag>("EBdigiCollection"));
30 
31  eeDigiCollectionToken_ = consumes<EEDigiCollection>(ps.getParameter<edm::InputTag>("EEdigiCollection"));
32 
33  std::string componentType = ps.getParameter<std::string>("algo");
34  edm::ParameterSet algoConf = ps.getParameter<edm::ParameterSet>("algoPSet");
35 
37  worker_ = EcalUncalibRecHitWorkerFactory::get()->create(componentType, algoConf, c);
38 }
39 
41 {
42  delete worker_;
43 }
44 
46 
48  std::vector<edmplugin::PluginInfo> infos = factory->available();
49 
50  {
52  desc.add<edm::InputTag>("EBdigiCollection", edm::InputTag("ecalDigis","ebDigis"));
53  desc.add<std::string>("EEhitCollection", "EcalUncalibRecHitsEE");
54  desc.add<edm::InputTag>("EEdigiCollection", edm::InputTag("ecalDigis","eeDigis"));
55  desc.add<std::string>("EBhitCollection", "EcalUncalibRecHitsEB");
56 
57  auto itInfos = infos.begin();
58  assert(itInfos != infos.end());
59 
60  std::unique_ptr<edm::ParameterDescriptionCases<std::string>> s;
61  {
62  s = (itInfos->name_ >> edm::ParameterDescription<edm::ParameterSetDescription>("algoPSet", EcalUncalibRecHitFillDescriptionWorkerFactory::get()->create(itInfos->name_)->getAlgoDescription(), true));
63  }
64  for (++itInfos; itInfos != infos.end(); ++itInfos) {
65  s = (std::move(s) or itInfos->name_ >> edm::ParameterDescription<edm::ParameterSetDescription>("algoPSet", EcalUncalibRecHitFillDescriptionWorkerFactory::get()->create(itInfos->name_)->getAlgoDescription(), true));
66  }
67  desc.ifValue(edm::ParameterDescription<std::string>("algo", "EcalUncalibRecHitWorkerMultiFit", true), std::move(s));
68 
69  descriptions.addDefault(desc);
70  }
71 
72  for (std::vector<edmplugin::PluginInfo>::const_iterator itInfos = infos.begin(); itInfos != infos.end(); itInfos++) {
73  std::unique_ptr<EcalUncalibRecHitWorkerBaseClass> fdWorker(EcalUncalibRecHitFillDescriptionWorkerFactory::get()->create(itInfos->name_));
74 
76  desc.add<edm::InputTag>("EBdigiCollection", edm::InputTag("ecalDigis","ebDigis"));
77  desc.add<std::string>("EEhitCollection", "EcalUncalibRecHitsEE");
78  desc.add<edm::InputTag>("EEdigiCollection", edm::InputTag("ecalDigis","eeDigis"));
79  desc.add<std::string>("EBhitCollection", "EcalUncalibRecHitsEB");
80  desc.add<std::string>("algo", itInfos->name_);
81  desc.add<edm::ParameterSetDescription>("algoPSet", fdWorker->getAlgoDescription());
82 
83  std::string algoName = itInfos->name_.substr(itInfos->name_.find("Worker")+6, itInfos->name_.length());
84  descriptions.add("ecal"+algoName+"UncalibRecHit", desc);
85  }
86 }
87 
88 void
90 
91  using namespace edm;
92 
95 
96  const EBDigiCollection* ebDigis =0;
97  const EEDigiCollection* eeDigis =0;
98 
99 
100  evt.getByToken( ebDigiCollectionToken_, pEBDigis);
101  ebDigis = pEBDigis.product(); // get a ptr to the produc
102  edm::LogInfo("EcalUncalibRecHitInfo") << "total # ebDigis: " << ebDigis->size() ;
103 
104  evt.getByToken( eeDigiCollectionToken_, pEEDigis);
105  eeDigis = pEEDigis.product(); // get a ptr to the product
106  edm::LogInfo("EcalUncalibRecHitInfo") << "total # eeDigis: " << eeDigis->size() ;
107 
108 
109  // tranparently get things from event setup
110  worker_->set(es);
111  worker_->set(evt);
112 
113  // prepare output
114  auto ebUncalibRechits = std::make_unique<EBUncalibratedRecHitCollection>();
115  auto eeUncalibRechits = std::make_unique<EEUncalibratedRecHitCollection>();
116 
117  // loop over EB digis
118  if (ebDigis)
119  {
120  ebUncalibRechits->reserve(ebDigis->size());
121  for(EBDigiCollection::const_iterator itdg = ebDigis->begin(); itdg != ebDigis->end(); ++itdg) {
122  worker_->run(evt, itdg, *ebUncalibRechits);
123  }
124  }
125 
126  // loop over EB digis
127  if (eeDigis)
128  {
129  eeUncalibRechits->reserve(eeDigis->size());
130  for(EEDigiCollection::const_iterator itdg = eeDigis->begin(); itdg != eeDigis->end(); ++itdg) {
131  worker_->run(evt, itdg, *eeUncalibRechits);
132  }
133  }
134 
135  // put the collection of recunstructed hits in the event
136  evt.put(std::move(ebUncalibRechits), ebHitCollection_);
137  evt.put(std::move(eeUncalibRechits), eeHitCollection_);
138 }
139 
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
virtual void set(const edm::EventSetup &es)=0
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
assert(m_qm.get())
edm::EDGetTokenT< EEDigiCollection > eeDigiCollectionToken_
void addDefault(ParameterSetDescription const &psetDescription)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T > > cases)
def move
Definition: eostools.py:510
EcalUncalibRecHitWorkerBaseClass * worker_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
virtual void produce(edm::Event &evt, const edm::EventSetup &es) override
EcalUncalibRecHitProducer(const edm::ParameterSet &ps)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual bool run(const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result)=0
edm::EDGetTokenT< EBDigiCollection > ebDigiCollectionToken_
T get(const Candidate &c)
Definition: component.h:55