CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
HybridClusterProducer Class Reference

#include <HybridClusterProducer.h>

Inheritance diagram for HybridClusterProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 HybridClusterProducer (const edm::ParameterSet &ps)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~HybridClusterProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

std::string basicclusterCollection_
 
std::string hitcollection_
 
std::string hitproducer_
 
HybridClusterAlgohybrid_p
 
int nEvt_
 
PositionCalc posCalculator_
 
std::string superclusterCollection_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 19 of file HybridClusterProducer.h.

Constructor & Destructor Documentation

HybridClusterProducer::HybridClusterProducer ( const edm::ParameterSet ps)

Definition at line 40 of file HybridClusterProducer.cc.

References basicclusterCollection_, edm::ParameterSet::getParameter(), hitcollection_, hitproducer_, hybrid_p, nEvt_, posCalculator_, AlCaHLTBitMon_QueryRunRegistry::string, and superclusterCollection_.

41 {
42 
43 
44  basicclusterCollection_ = ps.getParameter<std::string>("basicclusterCollection");
45  superclusterCollection_ = ps.getParameter<std::string>("superclusterCollection");
46  hitproducer_ = ps.getParameter<std::string>("ecalhitproducer");
47  hitcollection_ =ps.getParameter<std::string>("ecalhitcollection");
48 
49  //Setup for core tools objects.
50  edm::ParameterSet posCalcParameters =
51  ps.getParameter<edm::ParameterSet>("posCalcParameters");
52 
53  posCalculator_ = PositionCalc(posCalcParameters);
54 
55  const std::vector<std::string> flagnames =
56  ps.getParameter<std::vector<std::string> >("RecHitFlagToBeExcluded");
57 
58  const std::vector<int> flagsexcl=
59  StringToEnumValue<EcalRecHit::Flags>(flagnames);
60 
61  const std::vector<std::string> severitynames =
62  ps.getParameter<std::vector<std::string> >("RecHitSeverityToBeExcluded");
63 
64  const std::vector<int> severitiesexcl=
65  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynames);
66 
67  hybrid_p = new HybridClusterAlgo(ps.getParameter<double>("HybridBarrelSeedThr"),
68  ps.getParameter<int>("step"),
69  ps.getParameter<double>("ethresh"),
70  ps.getParameter<double>("eseed"),
71  ps.getParameter<double>("xi"),
72  ps.getParameter<bool>("useEtForXi"),
73  ps.getParameter<double>("ewing"),
74  flagsexcl,
75  posCalculator_,
76  ps.getParameter<bool>("dynamicEThresh"),
77  ps.getParameter<double>("eThreshA"),
78  ps.getParameter<double>("eThreshB"),
79  severitiesexcl,
80  ps.getParameter<bool>("excludeFlagged")
81  );
82  //bremRecoveryPset,
83 
84  // get brem recovery parameters
85  bool dynamicPhiRoad = ps.getParameter<bool>("dynamicPhiRoad");
86  if (dynamicPhiRoad) {
87  edm::ParameterSet bremRecoveryPset = ps.getParameter<edm::ParameterSet>("bremRecoveryPset");
88  hybrid_p->setDynamicPhiRoad(bremRecoveryPset);
89  }
90 
91  produces< reco::BasicClusterCollection >(basicclusterCollection_);
92  produces< reco::SuperClusterCollection >(superclusterCollection_);
93  nEvt_ = 0;
94 }
T getParameter(std::string const &) const
HybridClusterAlgo * hybrid_p
HybridClusterProducer::~HybridClusterProducer ( )

Definition at line 97 of file HybridClusterProducer.cc.

References hybrid_p.

98 {
99  delete hybrid_p;
100 }
HybridClusterAlgo * hybrid_p

Member Function Documentation

void HybridClusterProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 103 of file HybridClusterProducer.cc.

References basicclusterCollection_, DetId::Ecal, EcalBarrel, EcalEndcap, EcalPreshower, geometry, edm::EventSetup::get(), edm::Event::getByLabel(), CaloGeometry::getSubdetectorGeometry(), hitcollection_, hitproducer_, hybrid_p, i, edm::OrphanHandleBase::isValid(), edm::HandleBase::isValid(), LogTrace, HybridClusterAlgo::makeClusters(), HybridClusterAlgo::makeSuperClusters(), nEvt_, edm::Handle< T >::product(), edm::ESHandle< class >::product(), edm::PtrVector< T >::push_back(), edm::Event::put(), and superclusterCollection_.

104 {
105  // get the hit collection from the event:
107  // evt.getByType(rhcHandle);
108  evt.getByLabel(hitproducer_, hitcollection_, rhcHandle);
109  if (!(rhcHandle.isValid())){
110  edm::LogError("MissingProduct") << "could not get a handle on the EcalRecHitCollection!";
111  return;
112 
113  }
114  const EcalRecHitCollection *hit_collection = rhcHandle.product();
115 
116  // get the collection geometry:
117  edm::ESHandle<CaloGeometry> geoHandle;
118  es.get<CaloGeometryRecord>().get(geoHandle);
119  const CaloGeometry& geometry = *geoHandle;
120  const CaloSubdetectorGeometry *geometry_p;
121  std::auto_ptr<const CaloSubdetectorTopology> topology;
122 
124  es.get<EcalSeverityLevelAlgoRcd>().get(sevLv);
125 
126  LogTrace("EcalClusters") << "\n\n\n" << hitcollection_ << "\n\n";
127 
128  if(hitcollection_ == "EcalRecHitsEB") {
129  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
130  topology.reset(new EcalBarrelTopology(geoHandle));
131  } else if(hitcollection_ == "EcalRecHitsEE") {
132  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
133  topology.reset(new EcalEndcapTopology(geoHandle));
134  } else if(hitcollection_ == "EcalRecHitsPS") {
135  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
136  topology.reset(new EcalPreshowerTopology (geoHandle));
137  } else throw(std::runtime_error("\n\nHybrid Cluster Producer encountered invalied ecalhitcollection type.\n\n"));
138 
139  // make the Basic clusters!
140  reco::BasicClusterCollection basicClusters;
141  hybrid_p->makeClusters(hit_collection, geometry_p, basicClusters, sevLv.product(),false,
142  std::vector<EcalEtaPhiRegion>());
143 
144  LogTrace("EcalClusters") << "Finished clustering - BasicClusterCollection returned to producer..." ;
145 
146  // create an auto_ptr to a BasicClusterCollection, copy the clusters into it and put in the Event:
147  std::auto_ptr< reco::BasicClusterCollection > basicclusters_p(new reco::BasicClusterCollection);
148  basicclusters_p->assign(basicClusters.begin(), basicClusters.end());
150 
151  //Basic clusters now in the event.
152  LogTrace("EcalClusters") << "Basic Clusters now put into event." ;
153 
154 
155  //Weird though it is, get the BasicClusters back out of the event. We need the
156  //edm::Ref to these guys to make our superclusters for Hybrid.
157  //edm::Handle<reco::BasicClusterCollection> bccHandle;
158  // evt.getByLabel("clusterproducer",basicclusterCollection_, bccHandle);
159  if (!(bccHandle.isValid())) {
160  edm::LogError("Missing Product") << "could not get a handle on the BasicClusterCollection!" ;
161  return;
162  }
163 
164  reco::BasicClusterCollection clusterCollection = *bccHandle;
165 
166  LogTrace("EcalClusters")<< "Got the BasicClusterCollection" << std::endl;
167 
168  reco::CaloClusterPtrVector clusterPtrVector;
169  for (unsigned int i = 0; i < clusterCollection.size(); i++){
170  clusterPtrVector.push_back(reco::CaloClusterPtr(bccHandle, i));
171  }
172 
173  reco::SuperClusterCollection superClusters = hybrid_p->makeSuperClusters(clusterPtrVector);
174  LogTrace("EcalClusters") << "Found: " << superClusters.size() << " superclusters." ;
175 
176  std::auto_ptr< reco::SuperClusterCollection > superclusters_p(new reco::SuperClusterCollection);
177  superclusters_p->assign(superClusters.begin(), superClusters.end());
178 
179  evt.put(superclusters_p, superclusterCollection_);
180  LogTrace("EcalClusters") << "Hybrid Clusters (Basic/Super) added to the Event! :-)" ;
181 
182 
183  nEvt_++;
184 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
int i
Definition: DBlmapReader.cc:9
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:137
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
reco::SuperClusterCollection makeSuperClusters(const reco::CaloClusterPtrVector &)
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
#define LogTrace(id)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
T const * product() const
Definition: Handle.h:74
ESHandle< TrackerGeometry > geometry
HybridClusterAlgo * hybrid_p
void makeClusters(const EcalRecHitCollection *, const CaloSubdetectorGeometry *geometry, reco::BasicClusterCollection &basicClusters, const EcalSeverityLevelAlgo *sevLv, bool regional=false, const std::vector< EcalEtaPhiRegion > &regions=std::vector< EcalEtaPhiRegion >())

Member Data Documentation

std::string HybridClusterProducer::basicclusterCollection_
private

Definition at line 33 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer(), and produce().

std::string HybridClusterProducer::hitcollection_
private

Definition at line 36 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer(), and produce().

std::string HybridClusterProducer::hitproducer_
private

Definition at line 35 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer(), and produce().

HybridClusterAlgo* HybridClusterProducer::hybrid_p
private

Definition at line 39 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer(), produce(), and ~HybridClusterProducer().

int HybridClusterProducer::nEvt_
private

Definition at line 31 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer(), and produce().

PositionCalc HybridClusterProducer::posCalculator_
private

Definition at line 40 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer().

std::string HybridClusterProducer::superclusterCollection_
private

Definition at line 34 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer(), and produce().