CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HiSuperClusterProducer.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
16 
17 // Reconstruction Classes
21 
22 // Class header file
24 
25 
27 {
28  // The verbosity level
29  std::string verbosityString = ps.getParameter<std::string>("VerbosityLevel");
30  if (verbosityString == "DEBUG") verbosity = HiBremRecoveryClusterAlgo::pDEBUG;
31  else if (verbosityString == "WARNING") verbosity = HiBremRecoveryClusterAlgo::pWARNING;
32  else if (verbosityString == "INFO") verbosity = HiBremRecoveryClusterAlgo::pINFO;
34 
35 
36  endcapSuperclusterCollection_ = ps.getParameter<std::string>("endcapSuperclusterCollection");
37  barrelSuperclusterCollection_ = ps.getParameter<std::string>("barrelSuperclusterCollection");
38 
39  doBarrel_ = ps.getParameter<bool>("doBarrel");
40  doEndcaps_ = ps.getParameter<bool>("doEndcaps");
41 
42 
43  barrelEtaSearchRoad_ = ps.getParameter<double>("barrelEtaSearchRoad");
44  barrelPhiSearchRoad_ = ps.getParameter<double>("barrelPhiSearchRoad");
45  endcapEtaSearchRoad_ = ps.getParameter<double>("endcapEtaSearchRoad");
46  endcapPhiSearchRoad_ = ps.getParameter<double>("endcapPhiSearchRoad");
47  seedTransverseEnergyThreshold_ = ps.getParameter<double>("seedTransverseEnergyThreshold");
48  barrelBCEnergyThreshold_ = ps.getParameter<double>("barrelBCEnergyThreshold");
49  endcapBCEnergyThreshold_ = ps.getParameter<double>("endcapBCEnergyThreshold");
50 
51  if (verbosityString == "INFO") {
52  std::cout <<"Barrel BC Energy threshold = "<<barrelBCEnergyThreshold_<<std::endl;
53  std::cout <<"Endcap BC Energy threshold = "<<endcapBCEnergyThreshold_<<std::endl;
54  }
55 
56  bremAlgo_p = new HiBremRecoveryClusterAlgo(barrelEtaSearchRoad_, barrelPhiSearchRoad_,
57  endcapEtaSearchRoad_, endcapPhiSearchRoad_,
58  seedTransverseEnergyThreshold_,
59  barrelBCEnergyThreshold_,
60  endcapBCEnergyThreshold_,
61  verbosity);
62 
63  produces< reco::SuperClusterCollection >(endcapSuperclusterCollection_);
64  produces< reco::SuperClusterCollection >(barrelSuperclusterCollection_);
65 
66  eeClustersToken_ = consumes<reco::BasicClusterCollection>(edm::InputTag(ps.getParameter<std::string>("endcapClusterProducer"),
67  ps.getParameter<std::string>("endcapClusterCollection")));
68  ebClustersToken_ = consumes<reco::BasicClusterCollection>(edm::InputTag(ps.getParameter<std::string>("barrelClusterProducer"),
69  ps.getParameter<std::string>("barrelClusterCollection")));
70 
71  totalE = 0;
72  noSuperClusters = 0;
73  nEvt_ = 0;
74 }
75 
76 
78 {
79  delete bremAlgo_p;
80 }
81 
83  double averEnergy = 0.;
84  std::ostringstream str;
85  str << "HiSuperClusterProducer::endJob()\n"
86  << " total # reconstructed super clusters: " << noSuperClusters << "\n"
87  << " total energy of all clusters: " << totalE << "\n";
88  if(noSuperClusters>0) {
89  averEnergy = totalE / noSuperClusters;
90  str << " average SuperCluster energy = " << averEnergy << "\n";
91  }
92  edm::LogInfo("HiSuperClusterProducerInfo") << str.str() << "\n";
93 
94 }
95 
96 
98 {
99  if(doEndcaps_)
101 
102  if(doBarrel_)
104 
105  nEvt_++;
106 }
107 
108 
111  std::string superclusterCollection)
112 {
113  // get the cluster collection out and turn it to a BasicClusterRefVector:
114  reco::CaloClusterPtrVector *clusterPtrVector_p = new reco::CaloClusterPtrVector;
115  getClusterPtrVector(evt, clustersToken, clusterPtrVector_p);
116 
117  // run the brem recovery and get the SC collection
118  std::auto_ptr<reco::SuperClusterCollection>
119  superclusters_ap(new reco::SuperClusterCollection(bremAlgo_p->makeSuperClusters(*clusterPtrVector_p)));
120 
121  // count the total energy and the number of superclusters
122  reco::SuperClusterCollection::iterator it;
123  for (it = superclusters_ap->begin(); it != superclusters_ap->end(); it++)
124  {
125  totalE += it->energy();
126  noSuperClusters++;
127  }
128 
129  // put the SC collection in the event
130  evt.put(superclusters_ap, superclusterCollection);
131 
132  delete clusterPtrVector_p;
133 }
134 
135 
137 {
139 
140  evt.getByToken(clustersToken, bccHandle);
141 
142  if (!(bccHandle.isValid()))
143  {
144  edm::LogError("HiSuperClusterProducerError") << "could not get a handle on the BasicCluster Collection!";
145  clusterPtrVector_p = 0;
146  }
147 
148  const reco::BasicClusterCollection *clusterCollection_p = bccHandle.product();
149  for (unsigned int i = 0; i < clusterCollection_p->size(); i++)
150  {
151  clusterPtrVector_p->push_back(reco::CaloClusterPtr(bccHandle, i));
152  }
153 }
154 
155 
156 
157 //define this as a plug-in
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< reco::BasicClusterCollection > ebClustersToken_
virtual void produce(edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:141
edm::EDGetTokenT< reco::BasicClusterCollection > eeClustersToken_
reco::SuperClusterCollection makeSuperClusters(reco::CaloClusterPtrVector &clusters)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
void produceSuperclustersForECALPart(edm::Event &evt, const edm::EDGetTokenT< reco::BasicClusterCollection > &clustersToken, std::string superclusterColection)
void getClusterPtrVector(edm::Event &evt, const edm::EDGetTokenT< reco::BasicClusterCollection > &clustersToken, reco::CaloClusterPtrVector *)
edm::PtrVector< CaloCluster > CaloClusterPtrVector
HiSuperClusterProducer(const edm::ParameterSet &ps)
bool isValid() const
Definition: HandleBase.h:75
HiBremRecoveryClusterAlgo::VerbosityLevel verbosity
T const * product() const
Definition: Handle.h:81
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
HiBremRecoveryClusterAlgo * bremAlgo_p
tuple cout
Definition: gather_cfg.py:121