CMS 3D CMS Logo

Multi5x5ClusterProducer.cc
Go to the documentation of this file.
27 
28 #include <ctime>
29 #include <iostream>
30 #include <memory>
31 #include <vector>
32 
34 public:
36 
37  ~Multi5x5ClusterProducer() override;
38 
39  void produce(edm::Event&, const edm::EventSetup&) override;
40 
41 private:
42  int nMaxPrintout_; // max # of printouts
43  int nEvt_; // internal counter of events
44 
45  // cluster which regions
46  bool doBarrel_;
47  bool doEndcap_;
48 
52 
55 
56  PositionCalc posCalculator_; // position calculation algorithm
58 
59  bool counterExceeded() const { return ((nEvt_ > nMaxPrintout_) || (nMaxPrintout_ < 0)); }
60 
62 
64  const edm::EventSetup& es,
66  const std::string& clusterCollection,
68 
69  void outputValidationInfo(reco::CaloClusterPtrVector& clusterPtrVector);
70 };
71 
74 
76  // Parameters to identify the hit collections
77  barrelHitToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("barrelHitTag"));
78 
79  endcapHitToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("endcapHitTag"));
80 
81  //EventSetup Token for CaloGeometry
82  caloGeometryToken_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
83 
84  // should cluster algo be run in barrel and endcap?
85  doEndcap_ = ps.getParameter<bool>("doEndcap");
86  doBarrel_ = ps.getParameter<bool>("doBarrel");
87 
88  // The names of the produced cluster collections
89  barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
90  endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
91 
92  // Island algorithm parameters
93  double barrelSeedThreshold = ps.getParameter<double>("IslandBarrelSeedThr");
94  double endcapSeedThreshold = ps.getParameter<double>("IslandEndcapSeedThr");
95 
96  const std::vector<std::string> flagnames = ps.getParameter<std::vector<std::string> >("RecHitFlagToBeExcluded");
97 
98  const std::vector<int> v_chstatus = StringToEnumValue<EcalRecHit::Flags>(flagnames);
99 
100  // Parameters for the position calculation:
103 
104  // Produces a collection of barrel and a collection of endcap clusters
105  produces<reco::BasicClusterCollection>(endcapClusterCollection_);
106  produces<reco::BasicClusterCollection>(barrelClusterCollection_);
107 
109  if (ps.exists("reassignSeedCrysToClusterItSeeds"))
110  reassignSeedCrysToClusterItSeeds = ps.getParameter<bool>("reassignSeedCrysToClusterItSeeds");
111 
113  barrelSeedThreshold, endcapSeedThreshold, v_chstatus, posCalculator_, reassignSeedCrysToClusterItSeeds);
114 
115  nEvt_ = 0;
116 }
117 
119 
121  if (doEndcap_) {
123  }
124  if (doBarrel_) {
126  }
127 
128  nEvt_++;
129 }
130 
134  evt.getByToken(token, rhcHandle);
135  return rhcHandle.product();
136 }
137 
139  const edm::EventSetup& es,
141  const std::string& clusterCollection,
143  // get the hit collection from the event:
144  const EcalRecHitCollection* hitCollection_p = getCollection(evt, token);
145 
146  // get the geometry and topology from the event setup:
148 
149  const CaloSubdetectorGeometry* geometry_p;
150  std::unique_ptr<CaloSubdetectorTopology> topology_p;
151 
153  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
154  topology_p = std::make_unique<EcalBarrelTopology>(*geoHandle);
155  } else {
156  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
157  topology_p = std::make_unique<EcalEndcapTopology>(*geoHandle);
158  }
159 
160  const CaloSubdetectorGeometry* geometryES_p;
161  geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
162 
163  // Run the clusterization algorithm:
165  clusters = island_p->makeClusters(hitCollection_p, geometry_p, topology_p.get(), geometryES_p, detector);
166 
167  // create a unique_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
168  auto clusters_p = std::make_unique<reco::BasicClusterCollection>();
169  clusters_p->assign(clusters.begin(), clusters.end());
172  bccHandle = evt.put(std::move(clusters_p), barrelClusterCollection_);
173  else
174  bccHandle = evt.put(std::move(clusters_p), endcapClusterCollection_);
175 }
Handle.h
PositionCalc.h
Multi5x5ClusterProducer::~Multi5x5ClusterProducer
~Multi5x5ClusterProducer() override
Definition: Multi5x5ClusterProducer.cc:118
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
Multi5x5ClusterProducer::barrelHitToken_
edm::EDGetTokenT< EcalRecHitCollection > barrelHitToken_
Definition: Multi5x5ClusterProducer.cc:49
reco::CaloID::Detectors
Detectors
Definition: CaloID.h:19
BasicCluster.h
Multi5x5ClusterProducer::barrelClusterCollection_
std::string barrelClusterCollection_
Definition: Multi5x5ClusterProducer.cc:53
edm::EDGetTokenT
Definition: EDGetToken.h:33
reco::CaloID::DET_ECAL_ENDCAP
Definition: CaloID.h:21
EBDetId.h
EcalBarrelTopology.h
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
Multi5x5ClusterAlgo.h
CaloID.h
EDProducer.h
edm::SortedCollection< EcalRecHit >
Multi5x5ClusterProducer
Definition: Multi5x5ClusterProducer.cc:33
MonitorAlCaEcalPi0_cfi.posCalcParameters
posCalcParameters
Definition: MonitorAlCaEcalPi0_cfi.py:72
edm::Handle
Definition: AssociativeIterator.h:50
ESGetToken.h
EcalBarrel
Definition: EcalSubdetector.h:10
EcalRecHitCollections.h
Multi5x5ClusterProducer::endcapHitToken_
edm::EDGetTokenT< EcalRecHitCollection > endcapHitToken_
Definition: Multi5x5ClusterProducer.cc:50
BasicClusterFwd.h
Multi5x5ClusterProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: Multi5x5ClusterProducer.cc:120
Multi5x5ClusterProducer::Multi5x5ClusterProducer
Multi5x5ClusterProducer(const edm::ParameterSet &ps)
Definition: Multi5x5ClusterProducer.cc:75
MakerMacros.h
Multi5x5ClusterProducer::nEvt_
int nEvt_
Definition: Multi5x5ClusterProducer.cc:43
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::PtrVector< CaloCluster >
edm::ESHandle< CaloGeometry >
Multi5x5ClusterProducer::island_p
Multi5x5ClusterAlgo * island_p
Definition: Multi5x5ClusterProducer.cc:57
Multi5x5ClusterAlgo::makeClusters
std::vector< reco::BasicCluster > makeClusters(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p, reco::CaloID::Detectors detector, bool regional=false, const std::vector< RectangularEtaPhiRegion > &regions=std::vector< RectangularEtaPhiRegion >())
Definition: Multi5x5ClusterAlgo.cc:54
CaloClusterFwd.h
Multi5x5ClusterAlgo
Definition: Multi5x5ClusterAlgo.h:27
EcalRecHit.h
StringToEnumValue.h
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
Multi5x5ClusterProducer::doEndcap_
bool doEndcap_
Definition: Multi5x5ClusterProducer.cc:47
reco::BasicClusterCollection
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
Definition: BasicClusterFwd.h:16
multi5x5BasicClusters_cfi.reassignSeedCrysToClusterItSeeds
reassignSeedCrysToClusterItSeeds
Definition: multi5x5BasicClusters_cfi.py:25
CaloGeometryRecord.h
EcalEndcap
Definition: EcalSubdetector.h:10
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
edm::ParameterSet::exists
bool exists(std::string const &parameterName) const
checks if a parameter exists
Definition: ParameterSet.cc:681
Multi5x5ClusterProducer::endcapClusterCollection_
std::string endcapClusterCollection_
Definition: Multi5x5ClusterProducer.cc:54
CaloSubdetectorGeometry.h
Multi5x5ClusterProducer::getCollection
const EcalRecHitCollection * getCollection(edm::Event &evt, const edm::EDGetTokenT< EcalRecHitCollection > &token)
Definition: Multi5x5ClusterProducer.cc:131
edm::ParameterSet
Definition: ParameterSet.h:47
Multi5x5ClusterProducer::caloGeometryToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
Definition: Multi5x5ClusterProducer.cc:51
Event.h
EcalEndcapTopology.h
Multi5x5ClusterProducer::doBarrel_
bool doBarrel_
Definition: Multi5x5ClusterProducer.cc:46
PositionCalc
Definition: PositionCalc.h:29
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EventSetup::getHandle
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:155
edm::stream::EDProducer
Definition: EDProducer.h:36
Multi5x5ClusterProducer::posCalculator_
PositionCalc posCalculator_
Definition: Multi5x5ClusterProducer.cc:56
edm::EventSetup
Definition: EventSetup.h:58
DetId::Ecal
Definition: DetId.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ESGetToken< CaloGeometry, CaloGeometryRecord >
Multi5x5ClusterProducer::counterExceeded
bool counterExceeded() const
Definition: Multi5x5ClusterProducer.cc:59
EcalPreshower
Definition: EcalSubdetector.h:10
CaloSubdetectorTopology.h
CaloCellGeometry.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
Multi5x5ClusterProducer::outputValidationInfo
void outputValidationInfo(reco::CaloClusterPtrVector &clusterPtrVector)
CaloGeometry.h
EventSetup.h
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
hgcalTestNeighbor_cfi.detector
detector
Definition: hgcalTestNeighbor_cfi.py:6
Multi5x5ClusterProducer::nMaxPrintout_
int nMaxPrintout_
Definition: Multi5x5ClusterProducer.cc:42
Multi5x5ClusterProducer::clusterizeECALPart
void clusterizeECALPart(edm::Event &evt, const edm::EventSetup &es, const edm::EDGetTokenT< EcalRecHitCollection > &token, const std::string &clusterCollection, const reco::CaloID::Detectors detector)
Definition: Multi5x5ClusterProducer.cc:138
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
reco::CaloID::DET_ECAL_BARREL
Definition: CaloID.h:20
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316