CMS 3D CMS Logo

HybridClusterProducer Class Reference

#include <RecoEcal/EgammaClusterProducers/interface/HybridClusterProducer.h>

Inheritance diagram for HybridClusterProducer:

edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 HybridClusterProducer (const edm::ParameterSet &ps)
virtual void produce (edm::Event &, const edm::EventSetup &)
 ~HybridClusterProducer ()

Private Member Functions

bool counterExceeded () const

Private Attributes

std::string basicclusterCollection_
std::string clusterShapeAssociation_
std::string clustershapecollection_
HybridClusterAlgo::DebugLevel debugL
std::string hitcollection_
std::string hitproducer_
HybridClusterAlgohybrid_p
int nEvt_
int nMaxPrintout_
PositionCalc posCalculator_
ClusterShapeAlgo shapeAlgo_
std::string superclusterCollection_


Detailed Description

Definition at line 20 of file HybridClusterProducer.h.


Constructor & Destructor Documentation

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

Definition at line 40 of file HybridClusterProducer.cc.

References basicclusterCollection_, clusterShapeAssociation_, clustershapecollection_, debugL, edm::ParameterSet::getParameter(), hitcollection_, hitproducer_, hybrid_p, nEvt_, HybridClusterAlgo::pDEBUG, HybridClusterAlgo::pERROR, HybridClusterAlgo::pINFO, posCalculator_, HybridClusterAlgo::setDynamicPhiRoad(), shapeAlgo_, and superclusterCollection_.

00041 {
00042 
00043     // The debug level
00044   std::string debugString = ps.getParameter<std::string>("debugLevel");
00045   if      (debugString == "DEBUG")   debugL = HybridClusterAlgo::pDEBUG;
00046   else if (debugString == "INFO")    debugL = HybridClusterAlgo::pINFO;
00047   else                               debugL = HybridClusterAlgo::pERROR;
00048 
00049   basicclusterCollection_ = ps.getParameter<std::string>("basicclusterCollection");
00050   superclusterCollection_ = ps.getParameter<std::string>("superclusterCollection");
00051   hitproducer_ = ps.getParameter<std::string>("ecalhitproducer");
00052   hitcollection_ =ps.getParameter<std::string>("ecalhitcollection");
00053 
00054   //Setup for core tools objects.
00055   std::map<std::string,double> providedParameters;  
00056   providedParameters.insert(std::make_pair("LogWeighted",ps.getParameter<bool>("posCalc_logweight")));
00057   providedParameters.insert(std::make_pair("T0_barl",ps.getParameter<double>("posCalc_t0")));
00058   providedParameters.insert(std::make_pair("W0",ps.getParameter<double>("posCalc_w0")));
00059   providedParameters.insert(std::make_pair("X0",ps.getParameter<double>("posCalc_x0")));
00060 
00061   posCalculator_ = PositionCalc(providedParameters);
00062   shapeAlgo_ = ClusterShapeAlgo(providedParameters);
00063 
00064   hybrid_p = new HybridClusterAlgo(ps.getParameter<double>("HybridBarrelSeedThr"), 
00065                                    ps.getParameter<int>("step"),
00066                                    ps.getParameter<double>("eseed"),
00067                                    ps.getParameter<double>("ewing"),
00068                                    ps.getParameter<double>("ethresh"),
00069                                    posCalculator_,
00070                                    //dynamicPhiRoad,
00071                                    ps.getParameter<bool>("dynamicEThresh"),
00072                                    ps.getParameter<double>("eThreshA"),
00073                                    ps.getParameter<double>("eThreshB"),
00074                                    //bremRecoveryPset,
00075                                    debugL);
00076 
00077 
00078   // get brem recovery parameters
00079   bool dynamicPhiRoad = ps.getParameter<bool>("dynamicPhiRoad");
00080   if (dynamicPhiRoad) {
00081      edm::ParameterSet bremRecoveryPset = ps.getParameter<edm::ParameterSet>("bremRecoveryPset");
00082      hybrid_p->setDynamicPhiRoad(bremRecoveryPset);
00083   }
00084 
00085 
00086   clustershapecollection_ = ps.getParameter<std::string>("clustershapecollection");
00087   clusterShapeAssociation_ = ps.getParameter<std::string>("shapeAssociation");
00088 
00089   produces< reco::ClusterShapeCollection>(clustershapecollection_);
00090   produces< reco::BasicClusterCollection >(basicclusterCollection_);
00091   produces< reco::SuperClusterCollection >(superclusterCollection_);
00092   produces< reco::BasicClusterShapeAssociationCollection >(clusterShapeAssociation_);
00093   nEvt_ = 0;
00094 }

HybridClusterProducer::~HybridClusterProducer (  ) 

Definition at line 97 of file HybridClusterProducer.cc.

References hybrid_p.

00098 {
00099   delete hybrid_p;
00100 }


Member Function Documentation

bool HybridClusterProducer::counterExceeded (  )  const [inline, private]

Definition at line 48 of file HybridClusterProducer.h.

References nEvt_, and nMaxPrintout_.

00048 { return ((nEvt_ > nMaxPrintout_) || (nMaxPrintout_ < 0));}

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

Implements edm::EDProducer.

Definition at line 103 of file HybridClusterProducer.cc.

References basicclusterCollection_, ClusterShapeAlgo::Calculate(), clusterShapeAssociation_, clustershapecollection_, GenMuonPlsPt100GeV_cfg::cout, debugL, DetId::Ecal, EcalBarrel, EcalEndcap, EcalPreshower, lat::endl(), edm::EventSetup::get(), edm::Event::getByLabel(), CaloGeometry::getSubdetectorGeometry(), hitcollection_, hitproducer_, hybrid_p, i, int, edm::Handle< T >::isValid(), edm::OrphanHandle< T >::isValid(), HybridClusterAlgo::makeClusters(), HybridClusterAlgo::makeSuperClusters(), nEvt_, HybridClusterAlgo::pDEBUG, HybridClusterAlgo::pINFO, edm::Handle< T >::product(), edm::RefVector< C, T, F >::push_back(), edm::Event::put(), shapeAlgo_, and superclusterCollection_.

00104 {
00105   // get the hit collection from the event:
00106   edm::Handle<EcalRecHitCollection> rhcHandle;
00107   //  evt.getByType(rhcHandle);
00108   evt.getByLabel(hitproducer_, hitcollection_, rhcHandle);
00109   if (!(rhcHandle.isValid())) 
00110     {
00111       if (debugL <= HybridClusterAlgo::pINFO)
00112         std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl;
00113       return;
00114     }
00115   const EcalRecHitCollection *hit_collection = rhcHandle.product();
00116 
00117   // get the collection geometry:
00118   edm::ESHandle<CaloGeometry> geoHandle;
00119   es.get<CaloGeometryRecord>().get(geoHandle);
00120   const CaloGeometry& geometry = *geoHandle;
00121   const CaloSubdetectorGeometry *geometry_p;
00122   std::auto_ptr<const CaloSubdetectorTopology> topology;
00123 
00124   if (debugL == HybridClusterAlgo::pDEBUG)
00125     std::cout << "\n\n\n" << hitcollection_ << "\n\n" << std::endl;
00126 
00127   if(hitcollection_ == "EcalRecHitsEB") {
00128     geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
00129     topology.reset(new EcalBarrelTopology(geoHandle));
00130   } else if(hitcollection_ == "EcalRecHitsEE") {
00131     geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
00132     topology.reset(new EcalEndcapTopology(geoHandle));
00133   } else if(hitcollection_ == "EcalRecHitsPS") {
00134     geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
00135     topology.reset(new EcalPreshowerTopology (geoHandle));
00136   } else throw(std::runtime_error("\n\nHybrid Cluster Producer encountered invalied ecalhitcollection type.\n\n"));
00137     
00138   // make the Basic clusters!
00139   reco::BasicClusterCollection basicClusters;
00140   hybrid_p->makeClusters(hit_collection, geometry_p, basicClusters);
00141   if (debugL == HybridClusterAlgo::pDEBUG)
00142     std::cout << "Finished clustering - BasicClusterCollection returned to producer..." << std::endl;
00143 
00144   std::vector <reco::ClusterShape> ClusVec;
00145   for (int erg=0;erg<int(basicClusters.size());++erg){
00146     reco::ClusterShape TestShape = shapeAlgo_.Calculate(basicClusters[erg],hit_collection,geometry_p,topology.get());
00147     ClusVec.push_back(TestShape);
00148   }
00149   std::auto_ptr< reco::ClusterShapeCollection> clustersshapes_p(new reco::ClusterShapeCollection);
00150   clustersshapes_p->assign(ClusVec.begin(), ClusVec.end());
00151   edm::OrphanHandle<reco::ClusterShapeCollection> clusHandle = evt.put(clustersshapes_p, 
00152                                                                        clustershapecollection_);
00153 
00154   // create an auto_ptr to a BasicClusterCollection, copy the clusters into it and put in the Event:
00155   std::auto_ptr< reco::BasicClusterCollection > basicclusters_p(new reco::BasicClusterCollection);
00156   basicclusters_p->assign(basicClusters.begin(), basicClusters.end());
00157   edm::OrphanHandle<reco::BasicClusterCollection> bccHandle =  evt.put(basicclusters_p, 
00158                                                                        basicclusterCollection_);
00159   //Basic clusters now in the event.
00160   if (debugL == HybridClusterAlgo::pDEBUG)
00161     std::cout << "Basic Clusters now put into event." << std::endl;
00162   
00163   //Weird though it is, get the BasicClusters back out of the event.  We need the
00164   //edm::Ref to these guys to make our superclusters for Hybrid.
00165   //edm::Handle<reco::BasicClusterCollection> bccHandle;
00166   // evt.getByLabel("clusterproducer",basicclusterCollection_, bccHandle);
00167   if (!(bccHandle.isValid())) {
00168     if (debugL <= HybridClusterAlgo::pINFO)
00169       std::cout << "could not get a handle on the BasicClusterCollection!" << std::endl;
00170     return;
00171   }
00172   reco::BasicClusterCollection clusterCollection = *bccHandle;
00173   if (debugL == HybridClusterAlgo::pDEBUG)
00174     std::cout << "Got the BasicClusterCollection" << std::endl;
00175 
00176   reco::BasicClusterRefVector clusterRefVector;
00177   for (unsigned int i = 0; i < clusterCollection.size(); i++){
00178     clusterRefVector.push_back(reco::BasicClusterRef(bccHandle, i));
00179   }
00180 
00181   reco::SuperClusterCollection superClusters = hybrid_p->makeSuperClusters(clusterRefVector);
00182 
00183   if (debugL == HybridClusterAlgo::pDEBUG)
00184     std::cout << "Found: " << superClusters.size() << " superclusters." << std::endl;  
00185 
00186   std::auto_ptr< reco::SuperClusterCollection > superclusters_p(new reco::SuperClusterCollection);
00187   superclusters_p->assign(superClusters.begin(), superClusters.end());
00188   
00189   evt.put(superclusters_p, superclusterCollection_);
00190 
00191   // BasicClusterShapeAssociationMap
00192   std::auto_ptr<reco::BasicClusterShapeAssociationCollection> shapeAssocs_p(new reco::BasicClusterShapeAssociationCollection);
00193   for (unsigned int i = 0; i < clusterCollection.size(); i++){
00194     shapeAssocs_p->insert(edm::Ref<reco::BasicClusterCollection>(bccHandle,i),edm::Ref<reco::ClusterShapeCollection>(clusHandle,i));
00195   }  
00196   
00197   evt.put(shapeAssocs_p,clusterShapeAssociation_);
00198 
00199   if (debugL == HybridClusterAlgo::pDEBUG)
00200     std::cout << "Hybrid Clusters (Basic/Super) added to the Event! :-)" << std::endl;
00201 
00202   nEvt_++;
00203 }


Member Data Documentation

std::string HybridClusterProducer::basicclusterCollection_ [private]

Definition at line 35 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer(), and produce().

std::string HybridClusterProducer::clusterShapeAssociation_ [private]

Definition at line 40 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer(), and produce().

std::string HybridClusterProducer::clustershapecollection_ [private]

Definition at line 39 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer(), and produce().

HybridClusterAlgo::DebugLevel HybridClusterProducer::debugL [private]

Definition at line 42 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer(), and produce().

std::string HybridClusterProducer::hitcollection_ [private]

Definition at line 38 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer(), and produce().

std::string HybridClusterProducer::hitproducer_ [private]

Definition at line 37 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer(), and produce().

HybridClusterAlgo* HybridClusterProducer::hybrid_p [private]

Definition at line 44 of file HybridClusterProducer.h.

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

int HybridClusterProducer::nEvt_ [private]

Definition at line 33 of file HybridClusterProducer.h.

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

int HybridClusterProducer::nMaxPrintout_ [private]

Definition at line 32 of file HybridClusterProducer.h.

Referenced by counterExceeded().

PositionCalc HybridClusterProducer::posCalculator_ [private]

Definition at line 45 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer().

ClusterShapeAlgo HybridClusterProducer::shapeAlgo_ [private]

Definition at line 46 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer(), and produce().

std::string HybridClusterProducer::superclusterCollection_ [private]

Definition at line 36 of file HybridClusterProducer.h.

Referenced by HybridClusterProducer(), and produce().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:24:49 2009 for CMSSW by  doxygen 1.5.4