CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Multi5x5SuperClusterProducer.cc
Go to the documentation of this file.
1 // C/C++ headers
2 #include <iostream>
3 #include <vector>
4 #include <memory>
5 #include <sstream>
6 
7 // Framework
13 
14 // Reconstruction Classes
19 
20 // Class header file
22 
23 
25 {
26  // The verbosity level
27  std::string verbosityString = ps.getParameter<std::string>("VerbosityLevel");
28  if (verbosityString == "DEBUG") verbosity = Multi5x5BremRecoveryClusterAlgo::pDEBUG;
29  else if (verbosityString == "WARNING") verbosity = Multi5x5BremRecoveryClusterAlgo::pWARNING;
30  else if (verbosityString == "INFO") verbosity = Multi5x5BremRecoveryClusterAlgo::pINFO;
32 
33  endcapClusterProducer_ = ps.getParameter<std::string>("endcapClusterProducer");
34  barrelClusterProducer_ = ps.getParameter<std::string>("barrelClusterProducer");
35 
36  endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
37  barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
38 
39  endcapSuperclusterCollection_ = ps.getParameter<std::string>("endcapSuperclusterCollection");
40  barrelSuperclusterCollection_ = ps.getParameter<std::string>("barrelSuperclusterCollection");
41 
42  doBarrel_ = ps.getParameter<bool>("doBarrel");
43  doEndcaps_ = ps.getParameter<bool>("doEndcaps");
44 
45  barrelEtaSearchRoad_ = ps.getParameter<double>("barrelEtaSearchRoad");
46  barrelPhiSearchRoad_ = ps.getParameter<double>("barrelPhiSearchRoad");
47  endcapEtaSearchRoad_ = ps.getParameter<double>("endcapEtaSearchRoad");
48  endcapPhiSearchRoad_ = ps.getParameter<double>("endcapPhiSearchRoad");
49  seedTransverseEnergyThreshold_ = ps.getParameter<double>("seedTransverseEnergyThreshold");
50 
51  const edm::ParameterSet bremRecoveryPset = ps.getParameter<edm::ParameterSet>("bremRecoveryPset");
52  bool dynamicPhiRoad = ps.getParameter<bool>("dynamicPhiRoad");
53 
54  bremAlgo_p = new Multi5x5BremRecoveryClusterAlgo(bremRecoveryPset, barrelEtaSearchRoad_, barrelPhiSearchRoad_,
55  endcapEtaSearchRoad_, endcapPhiSearchRoad_,
56  dynamicPhiRoad, seedTransverseEnergyThreshold_, verbosity);
57 
58  produces< reco::SuperClusterCollection >(endcapSuperclusterCollection_);
59  produces< reco::SuperClusterCollection >(barrelSuperclusterCollection_);
60 
61  totalE = 0;
62  noSuperClusters = 0;
63  nEvt_ = 0;
64 }
65 
66 
68 {
69  delete bremAlgo_p;
70 }
71 
72 void
74  double averEnergy = 0.;
75  std::ostringstream str;
76  str << "Multi5x5SuperClusterProducer::endJob()\n"
77  << " total # reconstructed super clusters: " << noSuperClusters << "\n"
78  << " total energy of all clusters: " << totalE << "\n";
79  if(noSuperClusters>0) {
80  averEnergy = totalE / noSuperClusters;
81  str << " average SuperCluster energy = " << averEnergy << "\n";
82  }
83  edm::LogInfo("Multi5x5SuperClusterProducerInfo") << str.str() << "\n";
84 
85 }
86 
87 
89 {
90  if(doEndcaps_)
92 
93  if(doBarrel_)
95 
96  nEvt_++;
97 }
98 
99 
101  std::string clusterProducer,
102  std::string clusterCollection,
103  std::string superclusterCollection)
104 {
105  // get the cluster collection out and turn it to a BasicClusterRefVector:
106  reco::CaloClusterPtrVector *clusterPtrVector_p = new reco::CaloClusterPtrVector;
107  getClusterPtrVector(evt, clusterProducer, clusterCollection, clusterPtrVector_p);
108 
109  // run the brem recovery and get the SC collection
110  std::auto_ptr<reco::SuperClusterCollection>
111  superclusters_ap(new reco::SuperClusterCollection(bremAlgo_p->makeSuperClusters(*clusterPtrVector_p)));
112 
113  // count the total energy and the number of superclusters
114  reco::SuperClusterCollection::iterator it;
115  for (it = superclusters_ap->begin(); it != superclusters_ap->end(); it++)
116  {
117  totalE += it->energy();
118  noSuperClusters++;
119  }
120 
121  // put the SC collection in the event
122  evt.put(superclusters_ap, superclusterCollection);
123 
124  delete clusterPtrVector_p;
125 }
126 
127 
128 void Multi5x5SuperClusterProducer::getClusterPtrVector(edm::Event& evt, std::string clusterProducer_, std::string clusterCollection_, reco::CaloClusterPtrVector *clusterPtrVector_p)
129 {
131  try
132  {
133  evt.getByLabel(clusterProducer_, clusterCollection_, bccHandle);
134  if (!(bccHandle.isValid()))
135  {
136  edm::LogError("Multi5x5SuperClusterProducerError") << "could not get a handle on the BasicCluster Collection!";
137  clusterPtrVector_p = 0;
138  }
139  }
140  catch ( cms::Exception& ex )
141  {
142  edm::LogError("Multi5x5SuperClusterProducerError") << "Error! can't get the product " << clusterCollection_.c_str();
143  clusterPtrVector_p = 0;
144  }
145 
146  const reco::BasicClusterCollection *clusterCollection_p = bccHandle.product();
147  for (unsigned int i = 0; i < clusterCollection_p->size(); i++)
148  {
149  clusterPtrVector_p->push_back(reco::CaloClusterPtr(bccHandle, i));
150  }
151 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
void produceSuperclustersForECALPart(edm::Event &evt, std::string clusterProducer, std::string clusterCollection, std::string superclusterColection)
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:135
reco::SuperClusterCollection makeSuperClusters(reco::CaloClusterPtrVector &clusters)
virtual void produce(edm::Event &, const edm::EventSetup &)
Multi5x5BremRecoveryClusterAlgo * bremAlgo_p
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
Multi5x5SuperClusterProducer(const edm::ParameterSet &ps)
Multi5x5BremRecoveryClusterAlgo::VerbosityLevel verbosity
edm::PtrVector< CaloCluster > CaloClusterPtrVector
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
T const * product() const
Definition: Handle.h:74
void getClusterPtrVector(edm::Event &evt, std::string clusterProducer_, std::string clusterCollection_, reco::CaloClusterPtrVector *)