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
20 
21 // Geometry
29 
32 
33 // Class header file
36 
37 
38 
40 {
41 
42  // The debug level
43  std::string debugString = ps.getParameter<std::string>("debugLevel");
44  if (debugString == "DEBUG") debugL = HybridClusterAlgo::pDEBUG;
45  else if (debugString == "INFO") debugL = HybridClusterAlgo::pINFO;
47 
48  basicclusterCollection_ = ps.getParameter<std::string>("basicclusterCollection");
49  superclusterCollection_ = ps.getParameter<std::string>("superclusterCollection");
50  hitproducer_ = ps.getParameter<std::string>("ecalhitproducer");
51  hitcollection_ =ps.getParameter<std::string>("ecalhitcollection");
52 
53  //Setup for core tools objects.
54  edm::ParameterSet posCalcParameters =
55  ps.getParameter<edm::ParameterSet>("posCalcParameters");
56 
57  posCalculator_ = PositionCalc(posCalcParameters);
58 
59  hybrid_p = new HybridClusterAlgo(ps.getParameter<double>("HybridBarrelSeedThr"),
60  ps.getParameter<int>("step"),
61  ps.getParameter<double>("ethresh"),
62  ps.getParameter<double>("eseed"),
63  ps.getParameter<double>("ewing"),
64  ps.getParameter<std::vector<int> >("RecHitFlagToBeExcluded"),
65  posCalculator_,
66  debugL,
67  ps.getParameter<bool>("dynamicEThresh"),
68  ps.getParameter<double>("eThreshA"),
69  ps.getParameter<double>("eThreshB"),
70  ps.getParameter<std::vector<int> >("RecHitSeverityToBeExcluded"),
71  //ps.getParameter<double>("severityRecHitThreshold"),
72  //ps.getParameter<int>("severitySpikeId"),
73  //ps.getParameter<double>("severitySpikeThreshold"),
74  ps.getParameter<bool>("excludeFlagged")
75  );
76  //bremRecoveryPset,
77 
78  // get brem recovery parameters
79  bool dynamicPhiRoad = ps.getParameter<bool>("dynamicPhiRoad");
80  if (dynamicPhiRoad) {
81  edm::ParameterSet bremRecoveryPset = ps.getParameter<edm::ParameterSet>("bremRecoveryPset");
82  hybrid_p->setDynamicPhiRoad(bremRecoveryPset);
83  }
84 
85  produces< reco::BasicClusterCollection >(basicclusterCollection_);
86  produces< reco::SuperClusterCollection >(superclusterCollection_);
87  nEvt_ = 0;
88 }
89 
90 
92 {
93  delete hybrid_p;
94 }
95 
96 
98 {
99  // get the hit collection from the event:
101  // evt.getByType(rhcHandle);
102  evt.getByLabel(hitproducer_, hitcollection_, rhcHandle);
103  if (!(rhcHandle.isValid()))
104  {
106  std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl;
107  return;
108  }
109  const EcalRecHitCollection *hit_collection = rhcHandle.product();
110 
111  // get the collection geometry:
112  edm::ESHandle<CaloGeometry> geoHandle;
113  es.get<CaloGeometryRecord>().get(geoHandle);
114  const CaloGeometry& geometry = *geoHandle;
115  const CaloSubdetectorGeometry *geometry_p;
116  std::auto_ptr<const CaloSubdetectorTopology> topology;
117 
119  es.get<EcalSeverityLevelAlgoRcd>().get(sevLv);
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, sevLv.product(),false,
138  std::vector<EcalEtaPhiRegion>());
139 
141  std::cout << "Finished clustering - BasicClusterCollection returned to producer..." << std::endl;
142 
143  // create an auto_ptr to a BasicClusterCollection, copy the clusters into it and put in the Event:
144  std::auto_ptr< reco::BasicClusterCollection > basicclusters_p(new reco::BasicClusterCollection);
145  basicclusters_p->assign(basicClusters.begin(), basicClusters.end());
146  edm::OrphanHandle<reco::BasicClusterCollection> bccHandle = evt.put(basicclusters_p,
148  //Basic clusters now in the event.
150  std::cout << "Basic Clusters now put into event." << std::endl;
151 
152  //Weird though it is, get the BasicClusters back out of the event. We need the
153  //edm::Ref to these guys to make our superclusters for Hybrid.
154  //edm::Handle<reco::BasicClusterCollection> bccHandle;
155  // evt.getByLabel("clusterproducer",basicclusterCollection_, bccHandle);
156  if (!(bccHandle.isValid())) {
158  std::cout << "could not get a handle on the BasicClusterCollection!" << std::endl;
159  return;
160  }
161  reco::BasicClusterCollection clusterCollection = *bccHandle;
163  std::cout << "Got the BasicClusterCollection" << std::endl;
164 
165  reco::CaloClusterPtrVector clusterPtrVector;
166  for (unsigned int i = 0; i < clusterCollection.size(); i++){
167  clusterPtrVector.push_back(reco::CaloClusterPtr(bccHandle, i));
168  }
169 
170  reco::SuperClusterCollection superClusters = hybrid_p->makeSuperClusters(clusterPtrVector);
171 
173  std::cout << "Found: " << superClusters.size() << " superclusters." << std::endl;
174 
175  std::auto_ptr< reco::SuperClusterCollection > superclusters_p(new reco::SuperClusterCollection);
176  superclusters_p->assign(superClusters.begin(), superClusters.end());
177 
178  evt.put(superclusters_p, superclusterCollection_);
179 
181  std::cout << "Hybrid Clusters (Basic/Super) added to the Event! :-)" << std::endl;
182 
183  nEvt_++;
184 }
185 
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:137
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:355
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
void makeClusters(const EcalRecHitCollection *, const CaloSubdetectorGeometry *geometry, reco::BasicClusterCollection &basicClusters, const EcalSeverityLevelAlgo *sevLv, bool regional=false, const std::vector< EcalEtaPhiRegion > &regions=std::vector< EcalEtaPhiRegion >())