CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HybridClusterProducer.cc
Go to the documentation of this file.
1 // C/C++ headers
2 #include <iostream>
3 #include <vector>
4 #include <memory>
5 
6 // Framework
12 
13 // Reconstruction Classes
22 
23 // Geometry
31 
32 // Class header file
35 
36 
37 
39 {
40 
41  // The debug level
42  std::string debugString = ps.getParameter<std::string>("debugLevel");
43  if (debugString == "DEBUG") debugL = HybridClusterAlgo::pDEBUG;
44  else if (debugString == "INFO") debugL = HybridClusterAlgo::pINFO;
46 
47  basicclusterCollection_ = ps.getParameter<std::string>("basicclusterCollection");
48  superclusterCollection_ = ps.getParameter<std::string>("superclusterCollection");
49  hitproducer_ = ps.getParameter<std::string>("ecalhitproducer");
50  hitcollection_ =ps.getParameter<std::string>("ecalhitcollection");
51 
52  //Setup for core tools objects.
53  edm::ParameterSet posCalcParameters =
54  ps.getParameter<edm::ParameterSet>("posCalcParameters");
55 
56  posCalculator_ = PositionCalc(posCalcParameters);
57 
58  hybrid_p = new HybridClusterAlgo(ps.getParameter<double>("HybridBarrelSeedThr"),
59  ps.getParameter<int>("step"),
60  ps.getParameter<double>("ethresh"),
61  ps.getParameter<double>("eseed"),
62  ps.getParameter<double>("ewing"),
63  ps.getParameter<std::vector<int> >("RecHitFlagToBeExcluded"),
64  posCalculator_,
65  debugL,
66  ps.getParameter<bool>("dynamicEThresh"),
67  ps.getParameter<double>("eThreshA"),
68  ps.getParameter<double>("eThreshB"),
69  ps.getParameter<std::vector<int> >("RecHitSeverityToBeExcluded"),
70  ps.getParameter<double>("severityRecHitThreshold"),
71  ps.getParameter<int>("severitySpikeId"),
72  ps.getParameter<double>("severitySpikeThreshold"),
73  ps.getParameter<bool>("excludeFlagged")
74  );
75  //bremRecoveryPset,
76 
77  // get brem recovery parameters
78  bool dynamicPhiRoad = ps.getParameter<bool>("dynamicPhiRoad");
79  if (dynamicPhiRoad) {
81  hybrid_p->setDynamicPhiRoad(bremRecoveryPset);
82  }
83 
84  produces< reco::BasicClusterCollection >(basicclusterCollection_);
85  produces< reco::SuperClusterCollection >(superclusterCollection_);
86  nEvt_ = 0;
87 }
88 
89 
91 {
92  delete hybrid_p;
93 }
94 
95 
97 {
98  // get the hit collection from the event:
100  // evt.getByType(rhcHandle);
101  evt.getByLabel(hitproducer_, hitcollection_, rhcHandle);
102  if (!(rhcHandle.isValid()))
103  {
105  std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl;
106  return;
107  }
108  const EcalRecHitCollection *hit_collection = rhcHandle.product();
109 
110  // get the collection geometry:
111  edm::ESHandle<CaloGeometry> geoHandle;
112  es.get<CaloGeometryRecord>().get(geoHandle);
113  const CaloGeometry& geometry = *geoHandle;
114  const CaloSubdetectorGeometry *geometry_p;
115  std::auto_ptr<const CaloSubdetectorTopology> topology;
116 
118  es.get<EcalChannelStatusRcd>().get(chStatus);
119  const EcalChannelStatus* theEcalChStatus = chStatus.product();
120 
122  std::cout << "\n\n\n" << hitcollection_ << "\n\n" << std::endl;
123 
124  if(hitcollection_ == "EcalRecHitsEB") {
125  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
126  topology.reset(new EcalBarrelTopology(geoHandle));
127  } else if(hitcollection_ == "EcalRecHitsEE") {
128  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
129  topology.reset(new EcalEndcapTopology(geoHandle));
130  } else if(hitcollection_ == "EcalRecHitsPS") {
131  geometry_p = geometry.getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
132  topology.reset(new EcalPreshowerTopology (geoHandle));
133  } else throw(std::runtime_error("\n\nHybrid Cluster Producer encountered invalied ecalhitcollection type.\n\n"));
134 
135  // make the Basic clusters!
136  reco::BasicClusterCollection basicClusters;
137  hybrid_p->makeClusters(hit_collection, geometry_p, basicClusters, false, std::vector<EcalEtaPhiRegion>(),theEcalChStatus);
139  std::cout << "Finished clustering - BasicClusterCollection returned to producer..." << std::endl;
140 
141  // create an auto_ptr to a BasicClusterCollection, copy the clusters into it and put in the Event:
142  std::auto_ptr< reco::BasicClusterCollection > basicclusters_p(new reco::BasicClusterCollection);
143  basicclusters_p->assign(basicClusters.begin(), basicClusters.end());
144  edm::OrphanHandle<reco::BasicClusterCollection> bccHandle = evt.put(basicclusters_p,
146  //Basic clusters now in the event.
148  std::cout << "Basic Clusters now put into event." << std::endl;
149 
150  //Weird though it is, get the BasicClusters back out of the event. We need the
151  //edm::Ref to these guys to make our superclusters for Hybrid.
152  //edm::Handle<reco::BasicClusterCollection> bccHandle;
153  // evt.getByLabel("clusterproducer",basicclusterCollection_, bccHandle);
154  if (!(bccHandle.isValid())) {
156  std::cout << "could not get a handle on the BasicClusterCollection!" << std::endl;
157  return;
158  }
159  reco::BasicClusterCollection clusterCollection = *bccHandle;
161  std::cout << "Got the BasicClusterCollection" << std::endl;
162 
163  reco::CaloClusterPtrVector clusterPtrVector;
164  for (unsigned int i = 0; i < clusterCollection.size(); i++){
165  clusterPtrVector.push_back(reco::CaloClusterPtr(bccHandle, i));
166  }
167 
168  reco::SuperClusterCollection superClusters = hybrid_p->makeSuperClusters(clusterPtrVector);
169 
171  std::cout << "Found: " << superClusters.size() << " superclusters." << std::endl;
172 
173  std::auto_ptr< reco::SuperClusterCollection > superclusters_p(new reco::SuperClusterCollection);
174  superclusters_p->assign(superClusters.begin(), superClusters.end());
175 
176  evt.put(superclusters_p, superclusterCollection_);
177 
179  std::cout << "Hybrid Clusters (Basic/Super) added to the Event! :-)" << std::endl;
180 
181  nEvt_++;
182 }
183 
T getParameter(std::string const &) const
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
HybridClusterProducer(const edm::ParameterSet &ps)
virtual void produce(edm::Event &, const edm::EventSetup &)
HybridClusterAlgo::DebugLevel debugL
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:135
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
reco::SuperClusterCollection makeSuperClusters(const reco::CaloClusterPtrVector &)
bool isValid() const
Definition: HandleBase.h:76
void setDynamicPhiRoad(const edm::ParameterSet &bremRecoveryPset)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
void makeClusters(const EcalRecHitCollection *, const CaloSubdetectorGeometry *geometry, reco::BasicClusterCollection &basicClusters, bool regional=false, const std::vector< EcalEtaPhiRegion > &regions=std::vector< EcalEtaPhiRegion >(), const EcalChannelStatus *chStatus=new EcalChannelStatus())
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
tuple cout
Definition: gather_cfg.py:41
HybridClusterAlgo * hybrid_p