CMS 3D CMS Logo

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 
26  // The verbosity level
27  std::string verbosityString = ps.getParameter<std::string>("VerbosityLevel");
28  if (verbosityString == "DEBUG")
30  else if (verbosityString == "WARNING")
32  else if (verbosityString == "INFO")
34  else
36 
37  endcapSuperclusterCollection_ = ps.getParameter<std::string>("endcapSuperclusterCollection");
38  barrelSuperclusterCollection_ = ps.getParameter<std::string>("barrelSuperclusterCollection");
39 
40  doBarrel_ = ps.getParameter<bool>("doBarrel");
41  doEndcaps_ = ps.getParameter<bool>("doEndcaps");
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 
63  verbosity);
64 
65  produces<reco::SuperClusterCollection>(endcapSuperclusterCollection_);
66  produces<reco::SuperClusterCollection>(barrelSuperclusterCollection_);
67 
68  eeClustersToken_ = consumes<reco::BasicClusterCollection>(edm::InputTag(
69  ps.getParameter<std::string>("endcapClusterProducer"), ps.getParameter<std::string>("endcapClusterCollection")));
70  ebClustersToken_ = consumes<reco::BasicClusterCollection>(edm::InputTag(
71  ps.getParameter<std::string>("barrelClusterProducer"), ps.getParameter<std::string>("barrelClusterCollection")));
72 
73  totalE = 0;
74  noSuperClusters = 0;
75  nEvt_ = 0;
76 }
77 
79 
81  double averEnergy = 0.;
82  std::ostringstream str;
83  str << "HiSuperClusterProducer::endJob()\n"
84  << " total # reconstructed super clusters: " << noSuperClusters << "\n"
85  << " total energy of all clusters: " << totalE << "\n";
86  if (noSuperClusters > 0) {
87  averEnergy = totalE / noSuperClusters;
88  str << " average SuperCluster energy = " << averEnergy << "\n";
89  }
90  edm::LogInfo("HiSuperClusterProducerInfo") << str.str() << "\n";
91 }
92 
94  if (doEndcaps_)
96 
97  if (doBarrel_)
99 
100  nEvt_++;
101 }
102 
104  edm::Event& evt,
107  // get the cluster collection out and turn it to a BasicClusterRefVector:
108  reco::CaloClusterPtrVector* clusterPtrVector_p = new reco::CaloClusterPtrVector;
109  getClusterPtrVector(evt, clustersToken, clusterPtrVector_p);
110 
111  // run the brem recovery and get the SC collection
112  auto superclusters_ap =
113  std::make_unique<reco::SuperClusterCollection>(bremAlgo_p->makeSuperClusters(*clusterPtrVector_p));
114 
115  // count the total energy and the number of superclusters
116  reco::SuperClusterCollection::iterator it;
117  for (it = superclusters_ap->begin(); it != superclusters_ap->end(); it++) {
118  totalE += it->energy();
119  noSuperClusters++;
120  }
121 
122  // put the SC collection in the event
123  evt.put(std::move(superclusters_ap), superclusterCollection);
124 
125  delete clusterPtrVector_p;
126 }
127 
130  reco::CaloClusterPtrVector* clusterPtrVector_p) {
132 
133  evt.getByToken(clustersToken, bccHandle);
134 
135  if (!(bccHandle.isValid())) {
136  edm::LogError("HiSuperClusterProducerError") << "could not get a handle on the BasicCluster Collection!";
137  clusterPtrVector_p = nullptr;
138  }
139 
140  const reco::BasicClusterCollection* clusterCollection_p = bccHandle.product();
141  for (unsigned int i = 0; i < clusterCollection_p->size(); i++) {
142  clusterPtrVector_p->push_back(reco::CaloClusterPtr(bccHandle, i));
143  }
144 }
145 
146 //define this as a plug-in
Handle.h
mps_fire.i
i
Definition: mps_fire.py:428
HiSuperClusterProducer::endJob
virtual void endJob()
Definition: HiSuperClusterProducer.cc:80
MessageLogger.h
HiSuperClusterProducer::endcapBCEnergyThreshold_
float endcapBCEnergyThreshold_
Definition: HiSuperClusterProducer.h:46
HiSuperClusterProducer::eeClustersToken_
edm::EDGetTokenT< reco::BasicClusterCollection > eeClustersToken_
Definition: HiSuperClusterProducer.h:37
edm::Handle::product
T const * product() const
Definition: Handle.h:70
HiSuperClusterProducer
Definition: HiSuperClusterProducer.h:19
BasicCluster.h
edm::EDGetTokenT< reco::BasicClusterCollection >
HiBremRecoveryClusterAlgo::pDEBUG
Definition: HiBremRecoveryClusterAlgo.h:23
gather_cfg.cout
cout
Definition: gather_cfg.py:144
HiSuperClusterProducer::HiSuperClusterProducer
HiSuperClusterProducer(const edm::ParameterSet &ps)
Definition: HiSuperClusterProducer.cc:25
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
HiSuperClusterProducer::barrelEtaSearchRoad_
float barrelEtaSearchRoad_
Definition: HiSuperClusterProducer.h:40
HiSuperClusterProducer::bremAlgo_p
HiBremRecoveryClusterAlgo * bremAlgo_p
Definition: HiSuperClusterProducer.h:51
HiSuperClusterProducer::verbosity
HiBremRecoveryClusterAlgo::VerbosityLevel verbosity
Definition: HiSuperClusterProducer.h:32
MakerMacros.h
HiSuperClusterProducer::endcapSuperclusterCollection_
std::string endcapSuperclusterCollection_
Definition: HiSuperClusterProducer.h:34
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::PtrVector< CaloCluster >
HiSuperClusterProducer::endcapEtaSearchRoad_
float endcapEtaSearchRoad_
Definition: HiSuperClusterProducer.h:42
str
#define str(s)
Definition: TestProcessor.cc:51
HiSuperClusterProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: HiSuperClusterProducer.cc:93
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:531
reco::BasicClusterCollection
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
Definition: BasicClusterFwd.h:16
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::PtrVector::push_back
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:149
HiSuperClusterProducer::doBarrel_
bool doBarrel_
Definition: HiSuperClusterProducer.h:48
HiSuperClusterProducer::seedTransverseEnergyThreshold_
float seedTransverseEnergyThreshold_
Definition: HiSuperClusterProducer.h:44
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
HiSuperClusterProducer::barrelPhiSearchRoad_
float barrelPhiSearchRoad_
Definition: HiSuperClusterProducer.h:41
reco::CaloClusterPtrVector
edm::PtrVector< CaloCluster > CaloClusterPtrVector
Definition: CaloClusterFwd.h:22
ModuleDef.h
HiSuperClusterProducer::totalE
double totalE
Definition: HiSuperClusterProducer.h:53
HiSuperClusterProducer::nEvt_
int nEvt_
Definition: HiSuperClusterProducer.h:30
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
HiSuperClusterProducer::doEndcaps_
bool doEndcaps_
Definition: HiSuperClusterProducer.h:49
edm::EventSetup
Definition: EventSetup.h:57
HiSuperClusterProducer::barrelSuperclusterCollection_
std::string barrelSuperclusterCollection_
Definition: HiSuperClusterProducer.h:35
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
HiSuperClusterProducer::noSuperClusters
int noSuperClusters
Definition: HiSuperClusterProducer.h:54
HiSuperClusterProducer::getClusterPtrVector
void getClusterPtrVector(edm::Event &evt, const edm::EDGetTokenT< reco::BasicClusterCollection > &clustersToken, reco::CaloClusterPtrVector *)
Definition: HiSuperClusterProducer.cc:128
edm::Ptr< CaloCluster >
HiSuperClusterProducer::~HiSuperClusterProducer
~HiSuperClusterProducer() override
Definition: HiSuperClusterProducer.cc:78
eostools.move
def move(src, dest)
Definition: eostools.py:511
SuperClusterFwd.h
Frameworkfwd.h
HiSuperClusterProducer.h
SuperCluster.h
hybridSuperClusters_cfi.superclusterCollection
superclusterCollection
Definition: hybridSuperClusters_cfi.py:31
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HiSuperClusterProducer::endcapPhiSearchRoad_
float endcapPhiSearchRoad_
Definition: HiSuperClusterProducer.h:43
Exception.h
HiBremRecoveryClusterAlgo::pERROR
Definition: HiBremRecoveryClusterAlgo.h:23
HiSuperClusterProducer::ebClustersToken_
edm::EDGetTokenT< reco::BasicClusterCollection > ebClustersToken_
Definition: HiSuperClusterProducer.h:38
HiBremRecoveryClusterAlgo
Definition: HiBremRecoveryClusterAlgo.h:21
HiSuperClusterProducer::produceSuperclustersForECALPart
void produceSuperclustersForECALPart(edm::Event &evt, const edm::EDGetTokenT< reco::BasicClusterCollection > &clustersToken, std::string superclusterColection)
Definition: HiSuperClusterProducer.cc:103
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
edm::Event
Definition: Event.h:73
HiSuperClusterProducer::barrelBCEnergyThreshold_
float barrelBCEnergyThreshold_
Definition: HiSuperClusterProducer.h:45
edm::InputTag
Definition: InputTag.h:15
HiBremRecoveryClusterAlgo::pINFO
Definition: HiBremRecoveryClusterAlgo.h:23
HiBremRecoveryClusterAlgo::makeSuperClusters
reco::SuperClusterCollection makeSuperClusters(reco::CaloClusterPtrVector &clusters)
Definition: HiBremRecoveryClusterAlgo.cc:5
HiBremRecoveryClusterAlgo::pWARNING
Definition: HiBremRecoveryClusterAlgo.h:23