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 Member Functions | Private Attributes
CosmicClusterProducer Class Reference

#include <CosmicClusterProducer.h>

Inheritance diagram for CosmicClusterProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 CosmicClusterProducer (const edm::ParameterSet &ps)
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
 ~CosmicClusterProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

void clusterizeECALPart (edm::Event &evt, const edm::EventSetup &es, const std::string &hitProducer, const std::string &hitCollection, const std::string &uhitProducer, const std::string &uhitCollection, const std::string &clusterCollection, const std::string &clusterShapeAssociation, const CosmicClusterAlgo::EcalPart &ecalPart)
 
bool counterExceeded () const
 
const EcalRecHitCollectiongetCollection (edm::Event &evt, const std::string &hitProducer_, const std::string &hitCollection_)
 
const
EcalUncalibratedRecHitCollection
getUCollection (edm::Event &evt, const std::string &hitProducer_, const std::string &hitCollection_)
 
void outputValidationInfo (reco::CaloClusterPtrVector &clusterPtrVector)
 

Private Attributes

std::string barrelClusterCollection_
 
std::string barrelClusterShapeAssociation_
 
std::string barrelHitCollection_
 
std::string barrelHitProducer_
 
std::string barrelUHitCollection_
 
std::string barrelUHitProducer_
 
std::string clustershapecollectionEB_
 
std::string clustershapecollectionEE_
 
std::string endcapClusterCollection_
 
std::string endcapClusterShapeAssociation_
 
std::string endcapHitCollection_
 
std::string endcapHitProducer_
 
std::string endcapUHitCollection_
 
std::string endcapUHitProducer_
 
CosmicClusterAlgoisland_p
 
int nEvt_
 
int nMaxPrintout_
 
PositionCalc posCalculator_
 
ClusterShapeAlgo shapeAlgo_
 
CosmicClusterAlgo::VerbosityLevel verbosity
 

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
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 27 of file CosmicClusterProducer.h.

Constructor & Destructor Documentation

CosmicClusterProducer::CosmicClusterProducer ( const edm::ParameterSet ps)

Definition at line 39 of file CosmicClusterProducer.cc.

References barrelClusterCollection_, barrelClusterShapeAssociation_, barrelHitCollection_, barrelHitProducer_, barrelUHitCollection_, barrelUHitProducer_, clustershapecollectionEB_, clustershapecollectionEE_, endcapClusterCollection_, endcapClusterShapeAssociation_, endcapHitCollection_, endcapHitProducer_, endcapUHitCollection_, endcapUHitProducer_, edm::ParameterSet::getParameter(), island_p, nEvt_, CosmicClusterAlgo::pDEBUG, CosmicClusterAlgo::pERROR, CosmicClusterAlgo::pINFO, posCalculator_, CosmicClusterAlgo::pWARNING, shapeAlgo_, and verbosity.

40 {
41  // The verbosity level
42  std::string verbosityString = ps.getParameter<std::string>("VerbosityLevel");
43  if (verbosityString == "DEBUG") verbosity = CosmicClusterAlgo::pDEBUG;
44  else if (verbosityString == "WARNING") verbosity = CosmicClusterAlgo::pWARNING;
45  else if (verbosityString == "INFO") verbosity = CosmicClusterAlgo::pINFO;
47 
48 
49  // Parameters to identify the hit collections
50  barrelHitProducer_ = ps.getParameter<std::string>("barrelHitProducer");
51  endcapHitProducer_ = ps.getParameter<std::string>("endcapHitProducer");
52  barrelHitCollection_ = ps.getParameter<std::string>("barrelHitCollection");
53  endcapHitCollection_ = ps.getParameter<std::string>("endcapHitCollection");
54  barrelUHitProducer_ = ps.getParameter<std::string>("barrelUnHitProducer");
55  endcapUHitProducer_ = ps.getParameter<std::string>("endcapUnHitProducer");
56  barrelUHitCollection_ = ps.getParameter<std::string>("barrelUnHitCollection");
57  endcapUHitCollection_ = ps.getParameter<std::string>("endcapUnHitCollection");
58 
59  // The names of the produced cluster collections
60  barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
61  endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
62 
63  // Island algorithm parameters
64  double barrelSeedThreshold = ps.getParameter<double>("BarrelSeedThr");
65  double barrelSingleThreshold = ps.getParameter<double>("BarrelSingleThr");
66  double barrelSecondThreshold = ps.getParameter<double>("BarrelSecondThr");
67  double barrelSupThreshold = ps.getParameter<double>("BarrelSupThr");
68  double endcapSeedThreshold = ps.getParameter<double>("EndcapSeedThr");
69  double endcapSingleThreshold = ps.getParameter<double>("EndcapSingleThr");
70  double endcapSecondThreshold = ps.getParameter<double>("EndcapSecondThr");
71  double endcapSupThreshold = ps.getParameter<double>("EndcapSupThr");
72 
73  // Parameters for the position calculation:
74  edm::ParameterSet posCalcParameters =
75  ps.getParameter<edm::ParameterSet>("posCalcParameters");
76 
77  posCalculator_ = PositionCalc(posCalcParameters);
78  shapeAlgo_ = ClusterShapeAlgo(posCalcParameters);
79 
80  clustershapecollectionEB_ = ps.getParameter<std::string>("clustershapecollectionEB");
81  clustershapecollectionEE_ = ps.getParameter<std::string>("clustershapecollectionEE");
82 
83  //AssociationMap
84  barrelClusterShapeAssociation_ = ps.getParameter<std::string>("barrelShapeAssociation");
85  endcapClusterShapeAssociation_ = ps.getParameter<std::string>("endcapShapeAssociation");
86 
87  // Produces a collection of barrel and a collection of endcap clusters
88 
89  produces< reco::ClusterShapeCollection>(clustershapecollectionEE_);
90  produces< reco::BasicClusterCollection >(endcapClusterCollection_);
91  produces< reco::ClusterShapeCollection>(clustershapecollectionEB_);
92  produces< reco::BasicClusterCollection >(barrelClusterCollection_);
93  produces< reco::BasicClusterShapeAssociationCollection >(barrelClusterShapeAssociation_);
94  produces< reco::BasicClusterShapeAssociationCollection >(endcapClusterShapeAssociation_);
95 
96  island_p = new CosmicClusterAlgo(barrelSeedThreshold, barrelSingleThreshold, barrelSecondThreshold, barrelSupThreshold, endcapSeedThreshold, endcapSingleThreshold, endcapSecondThreshold, endcapSupThreshold, posCalculator_,verbosity);
97 
98  nEvt_ = 0;
99 }
T getParameter(std::string const &) const
CosmicClusterAlgo * island_p
CosmicClusterAlgo::VerbosityLevel verbosity
std::string endcapClusterShapeAssociation_
std::string barrelClusterShapeAssociation_
CosmicClusterProducer::~CosmicClusterProducer ( )

Definition at line 102 of file CosmicClusterProducer.cc.

References island_p.

103 {
104  delete island_p;
105 }
CosmicClusterAlgo * island_p

Member Function Documentation

void CosmicClusterProducer::clusterizeECALPart ( edm::Event evt,
const edm::EventSetup es,
const std::string &  hitProducer,
const std::string &  hitCollection,
const std::string &  uhitProducer,
const std::string &  uhitCollection,
const std::string &  clusterCollection,
const std::string &  clusterShapeAssociation,
const CosmicClusterAlgo::EcalPart ecalPart 
)
private

Definition at line 161 of file CosmicClusterProducer.cc.

References CosmicClusterAlgo::barrel, barrelClusterCollection_, ClusterShapeAlgo::Calculate(), clustershapecollectionEB_, clustershapecollectionEE_, DetId::Ecal, EcalBarrel, EcalEndcap, EcalPreshower, endcapClusterCollection_, edm::EventSetup::get(), getCollection(), getUCollection(), i, island_p, CosmicClusterAlgo::makeClusters(), edm::Event::put(), and shapeAlgo_.

Referenced by produce().

169 {
170  // get the hit collection from the event:
171 
172  const EcalRecHitCollection *hitCollection_p = getCollection(evt, hitProducer, hitCollection);
173  const EcalUncalibratedRecHitCollection *uhitCollection_p = getUCollection(evt, uhitProducer, uhitCollection);
174 
175  // get the geometry and topology from the event setup:
176  edm::ESHandle<CaloGeometry> geoHandle;
177  es.get<CaloGeometryRecord>().get(geoHandle);
178 
179  const CaloSubdetectorGeometry *geometry_p;
180  CaloSubdetectorTopology *topology_p;
181 
182  std::string clustershapetag;
183  if (ecalPart == CosmicClusterAlgo::barrel)
184  {
185  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
186  topology_p = new EcalBarrelTopology(geoHandle);
187  }
188  else
189  {
190  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
191  topology_p = new EcalEndcapTopology(geoHandle);
192  }
193 
194  const CaloSubdetectorGeometry *geometryES_p;
195  geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
196 
197  // Run the clusterization algorithm:
199  clusters = island_p->makeClusters(hitCollection_p, uhitCollection_p, geometry_p, topology_p, geometryES_p, ecalPart);
200 
201  //Create associated ClusterShape objects.
202  std::vector <reco::ClusterShape> ClusVec;
203 
204  for (int erg=0;erg<int(clusters.size());++erg){
205  reco::ClusterShape TestShape = shapeAlgo_.Calculate(clusters[erg],hitCollection_p,geometry_p,topology_p);
206  ClusVec.push_back(TestShape);
207  }
208 
209  //Put clustershapes in event, but retain a Handle on them.
210  std::auto_ptr< reco::ClusterShapeCollection> clustersshapes_p(new reco::ClusterShapeCollection);
211  clustersshapes_p->assign(ClusVec.begin(), ClusVec.end());
213  if (ecalPart == CosmicClusterAlgo::barrel)
214  clusHandle= evt.put(clustersshapes_p, clustershapecollectionEB_);
215  else
216  clusHandle= evt.put(clustersshapes_p, clustershapecollectionEE_);
217 
218  // create an auto_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
219  std::auto_ptr< reco::BasicClusterCollection > clusters_p(new reco::BasicClusterCollection);
220  clusters_p->assign(clusters.begin(), clusters.end());
222 
223  if (ecalPart == CosmicClusterAlgo::barrel)
224  bccHandle = evt.put(clusters_p, barrelClusterCollection_);
225  else
226  bccHandle = evt.put(clusters_p, endcapClusterCollection_);
227 
228 
229  // BasicClusterShapeAssociationMap
230  std::auto_ptr<reco::BasicClusterShapeAssociationCollection> shapeAssocs_p(new reco::BasicClusterShapeAssociationCollection);
231  for (unsigned int i = 0; i < clusHandle->size(); i++){
232  shapeAssocs_p->insert(edm::Ref<reco::BasicClusterCollection>(bccHandle,i),edm::Ref<reco::ClusterShapeCollection>(clusHandle,i));
233  }
234  evt.put(shapeAssocs_p,clusterShapeAssociation);
235 
236  delete topology_p;
237 }
int i
Definition: DBlmapReader.cc:9
const EcalRecHitCollection * getCollection(edm::Event &evt, const std::string &hitProducer_, const std::string &hitCollection_)
std::vector< ClusterShape > ClusterShapeCollection
collection of ClusterShape objects
CosmicClusterAlgo * island_p
reco::ClusterShape Calculate(const reco::BasicCluster &passedCluster, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology)
std::vector< reco::BasicCluster > makeClusters(const EcalRecHitCollection *hits, const EcalUncalibratedRecHitCollection *uncalibhits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p, EcalPart ecalPart, bool regional=false, const std::vector< EcalEtaPhiRegion > &regions=std::vector< EcalEtaPhiRegion >())
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
const EcalUncalibratedRecHitCollection * getUCollection(edm::Event &evt, const std::string &hitProducer_, const std::string &hitCollection_)
const T & get() const
Definition: EventSetup.h:55
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
bool CosmicClusterProducer::counterExceeded ( ) const
inlineprivate

Definition at line 68 of file CosmicClusterProducer.h.

References nEvt_, and nMaxPrintout_.

const EcalRecHitCollection * CosmicClusterProducer::getCollection ( edm::Event evt,
const std::string &  hitProducer_,
const std::string &  hitCollection_ 
)
private

Definition at line 116 of file CosmicClusterProducer.cc.

References gather_cfg::cout, edm::Event::getByLabel(), edm::HandleBase::isValid(), and edm::Handle< T >::product().

Referenced by clusterizeECALPart().

119 {
121  try
122  {
123  evt.getByLabel(hitProducer_, hitCollection_, rhcHandle);
124  if (!(rhcHandle.isValid()))
125  {
126  std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl;
127  return 0;
128  }
129  }
130  catch ( cms::Exception& ex )
131  {
132  edm::LogError("CosmicClusterProducerError") << "Error! can't get the product " << hitCollection_.c_str() ;
133  return 0;
134  }
135  return rhcHandle.product();
136 }
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
T const * product() const
Definition: Handle.h:74
tuple cout
Definition: gather_cfg.py:121
const EcalUncalibratedRecHitCollection * CosmicClusterProducer::getUCollection ( edm::Event evt,
const std::string &  hitProducer_,
const std::string &  hitCollection_ 
)
private

Definition at line 138 of file CosmicClusterProducer.cc.

References gather_cfg::cout, edm::Event::getByLabel(), edm::HandleBase::isValid(), and edm::Handle< T >::product().

Referenced by clusterizeECALPart().

141 {
143  try
144  {
145  evt.getByLabel(hitProducer_, hitCollection_, rhcHandle);
146  if (!(rhcHandle.isValid()))
147  {
148  std::cout << "could not get a handle on the EcalUncalibratedRecHitCollection!" << std::endl;
149  return 0;
150  }
151  }
152  catch ( cms::Exception& ex )
153  {
154  edm::LogError("CosmicClusterProducerError") << "Error! can't get the product " << hitCollection_.c_str() ;
155  return 0;
156  }
157  return rhcHandle.product();
158 }
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
T const * product() const
Definition: Handle.h:74
tuple cout
Definition: gather_cfg.py:121
void CosmicClusterProducer::outputValidationInfo ( reco::CaloClusterPtrVector clusterPtrVector)
private
void CosmicClusterProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 108 of file CosmicClusterProducer.cc.

References CosmicClusterAlgo::barrel, barrelClusterCollection_, barrelClusterShapeAssociation_, barrelHitCollection_, barrelHitProducer_, barrelUHitCollection_, barrelUHitProducer_, clusterizeECALPart(), CosmicClusterAlgo::endcap, endcapClusterCollection_, endcapClusterShapeAssociation_, endcapHitCollection_, endcapHitProducer_, endcapUHitCollection_, endcapUHitProducer_, and nEvt_.

109 {
112  nEvt_++;
113 }
void clusterizeECALPart(edm::Event &evt, const edm::EventSetup &es, const std::string &hitProducer, const std::string &hitCollection, const std::string &uhitProducer, const std::string &uhitCollection, const std::string &clusterCollection, const std::string &clusterShapeAssociation, const CosmicClusterAlgo::EcalPart &ecalPart)
std::string endcapClusterShapeAssociation_
std::string barrelClusterShapeAssociation_

Member Data Documentation

std::string CosmicClusterProducer::barrelClusterCollection_
private

Definition at line 54 of file CosmicClusterProducer.h.

Referenced by clusterizeECALPart(), CosmicClusterProducer(), and produce().

std::string CosmicClusterProducer::barrelClusterShapeAssociation_
private

Definition at line 61 of file CosmicClusterProducer.h.

Referenced by CosmicClusterProducer(), and produce().

std::string CosmicClusterProducer::barrelHitCollection_
private

Definition at line 46 of file CosmicClusterProducer.h.

Referenced by CosmicClusterProducer(), and produce().

std::string CosmicClusterProducer::barrelHitProducer_
private

Definition at line 44 of file CosmicClusterProducer.h.

Referenced by CosmicClusterProducer(), and produce().

std::string CosmicClusterProducer::barrelUHitCollection_
private

Definition at line 51 of file CosmicClusterProducer.h.

Referenced by CosmicClusterProducer(), and produce().

std::string CosmicClusterProducer::barrelUHitProducer_
private

Definition at line 49 of file CosmicClusterProducer.h.

Referenced by CosmicClusterProducer(), and produce().

std::string CosmicClusterProducer::clustershapecollectionEB_
private

Definition at line 57 of file CosmicClusterProducer.h.

Referenced by clusterizeECALPart(), and CosmicClusterProducer().

std::string CosmicClusterProducer::clustershapecollectionEE_
private

Definition at line 58 of file CosmicClusterProducer.h.

Referenced by clusterizeECALPart(), and CosmicClusterProducer().

std::string CosmicClusterProducer::endcapClusterCollection_
private

Definition at line 55 of file CosmicClusterProducer.h.

Referenced by clusterizeECALPart(), CosmicClusterProducer(), and produce().

std::string CosmicClusterProducer::endcapClusterShapeAssociation_
private

Definition at line 62 of file CosmicClusterProducer.h.

Referenced by CosmicClusterProducer(), and produce().

std::string CosmicClusterProducer::endcapHitCollection_
private

Definition at line 47 of file CosmicClusterProducer.h.

Referenced by CosmicClusterProducer(), and produce().

std::string CosmicClusterProducer::endcapHitProducer_
private

Definition at line 45 of file CosmicClusterProducer.h.

Referenced by CosmicClusterProducer(), and produce().

std::string CosmicClusterProducer::endcapUHitCollection_
private

Definition at line 52 of file CosmicClusterProducer.h.

Referenced by CosmicClusterProducer(), and produce().

std::string CosmicClusterProducer::endcapUHitProducer_
private

Definition at line 50 of file CosmicClusterProducer.h.

Referenced by CosmicClusterProducer(), and produce().

CosmicClusterAlgo* CosmicClusterProducer::island_p
private
int CosmicClusterProducer::nEvt_
private

Definition at line 40 of file CosmicClusterProducer.h.

Referenced by CosmicClusterProducer(), counterExceeded(), and produce().

int CosmicClusterProducer::nMaxPrintout_
private

Definition at line 39 of file CosmicClusterProducer.h.

Referenced by counterExceeded().

PositionCalc CosmicClusterProducer::posCalculator_
private

Definition at line 64 of file CosmicClusterProducer.h.

Referenced by CosmicClusterProducer().

ClusterShapeAlgo CosmicClusterProducer::shapeAlgo_
private

Definition at line 65 of file CosmicClusterProducer.h.

Referenced by clusterizeECALPart(), and CosmicClusterProducer().

CosmicClusterAlgo::VerbosityLevel CosmicClusterProducer::verbosity
private

Definition at line 42 of file CosmicClusterProducer.h.

Referenced by CosmicClusterProducer().