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 
27  endcapClusterProducer_ = ps.getParameter<std::string>("endcapClusterProducer");
28  barrelClusterProducer_ = ps.getParameter<std::string>("barrelClusterProducer");
29 
30  endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
31  barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
32 
33  endcapSuperclusterCollection_ = ps.getParameter<std::string>("endcapSuperclusterCollection");
34  barrelSuperclusterCollection_ = ps.getParameter<std::string>("barrelSuperclusterCollection");
35 
36  doBarrel_ = ps.getParameter<bool>("doBarrel");
37  doEndcaps_ = ps.getParameter<bool>("doEndcaps");
38 
39  barrelEtaSearchRoad_ = ps.getParameter<double>("barrelEtaSearchRoad");
40  barrelPhiSearchRoad_ = ps.getParameter<double>("barrelPhiSearchRoad");
41  endcapEtaSearchRoad_ = ps.getParameter<double>("endcapEtaSearchRoad");
42  endcapPhiSearchRoad_ = ps.getParameter<double>("endcapPhiSearchRoad");
43  seedTransverseEnergyThreshold_ = ps.getParameter<double>("seedTransverseEnergyThreshold");
44 
45  const edm::ParameterSet bremRecoveryPset = ps.getParameter<edm::ParameterSet>("bremRecoveryPset");
46  bool dynamicPhiRoad = ps.getParameter<bool>("dynamicPhiRoad");
47 
48  bremAlgo_p = new Multi5x5BremRecoveryClusterAlgo(bremRecoveryPset, barrelEtaSearchRoad_, barrelPhiSearchRoad_,
49  endcapEtaSearchRoad_, endcapPhiSearchRoad_,
50  dynamicPhiRoad, seedTransverseEnergyThreshold_);
51 
52  produces< reco::SuperClusterCollection >(endcapSuperclusterCollection_);
53  produces< reco::SuperClusterCollection >(barrelSuperclusterCollection_);
54 
55  totalE = 0;
56  noSuperClusters = 0;
57  nEvt_ = 0;
58 }
59 
60 
62 {
63  delete bremAlgo_p;
64 }
65 
66 void
68  double averEnergy = 0.;
69  std::ostringstream str;
70  str << "Multi5x5SuperClusterProducer::endJob()\n"
71  << " total # reconstructed super clusters: " << noSuperClusters << "\n"
72  << " total energy of all clusters: " << totalE << "\n";
73  if(noSuperClusters>0) {
74  averEnergy = totalE / noSuperClusters;
75  str << " average SuperCluster energy = " << averEnergy << "\n";
76  }
77  edm::LogInfo("Multi5x5SuperClusterProducerInfo") << str.str() << "\n";
78 
79 }
80 
81 
83 {
84  if(doEndcaps_)
86 
87  if(doBarrel_)
89 
90  nEvt_++;
91 }
92 
93 
95  std::string clusterProducer,
96  std::string clusterCollection,
97  std::string superclusterCollection)
98 {
99  // get the cluster collection out and turn it to a BasicClusterRefVector:
100  reco::CaloClusterPtrVector *clusterPtrVector_p = new reco::CaloClusterPtrVector;
101  getClusterPtrVector(evt, clusterProducer, clusterCollection, clusterPtrVector_p);
102 
103  // run the brem recovery and get the SC collection
104  std::auto_ptr<reco::SuperClusterCollection>
105  superclusters_ap(new reco::SuperClusterCollection(bremAlgo_p->makeSuperClusters(*clusterPtrVector_p)));
106 
107  // count the total energy and the number of superclusters
108  reco::SuperClusterCollection::iterator it;
109  for (it = superclusters_ap->begin(); it != superclusters_ap->end(); it++)
110  {
111  totalE += it->energy();
112  noSuperClusters++;
113  }
114 
115  // put the SC collection in the event
116  evt.put(superclusters_ap, superclusterCollection);
117 
118  delete clusterPtrVector_p;
119 }
120 
121 
122 void Multi5x5SuperClusterProducer::getClusterPtrVector(edm::Event& evt, std::string clusterProducer_, std::string clusterCollection_, reco::CaloClusterPtrVector *clusterPtrVector_p)
123 {
125  try
126  {
127  evt.getByLabel(clusterProducer_, clusterCollection_, bccHandle);
128  if (!(bccHandle.isValid()))
129  {
130  edm::LogError("Multi5x5SuperClusterProducerError") << "could not get a handle on the BasicCluster Collection!";
131  clusterPtrVector_p = 0;
132  }
133  }
134  catch ( cms::Exception& ex )
135  {
136  edm::LogError("Multi5x5SuperClusterProducerError") << "Error! can't get the product " << clusterCollection_.c_str();
137  clusterPtrVector_p = 0;
138  }
139 
140  const reco::BasicClusterCollection *clusterCollection_p = bccHandle.product();
141  for (unsigned int i = 0; i < clusterCollection_p->size(); i++)
142  {
143  clusterPtrVector_p->push_back(reco::CaloClusterPtr(bccHandle, i));
144  }
145 }
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:137
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:94
Multi5x5SuperClusterProducer(const edm::ParameterSet &ps)
edm::PtrVector< CaloCluster > CaloClusterPtrVector
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
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 *)