CMS 3D CMS Logo

CosmicClusterProducer.cc
Go to the documentation of this file.
1 // C/C++ headers
2 #include <iostream>
3 #include <vector>
4 #include <memory>
5 
6 // Framework
13 
14 // Reconstruction Classes
21 
22 // Geometry
27 
28 // EgammaCoreTools
33 
34 // Class header file
36 
38  // The verbosity level
39  std::string verbosityString = ps.getParameter<std::string>("VerbosityLevel");
40  if (verbosityString == "DEBUG")
42  else if (verbosityString == "WARNING")
44  else if (verbosityString == "INFO")
46  else
48 
49  // Parameters to identify the hit collections
50  ebHitsToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("barrelHits"));
51  eeHitsToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("endcapHits"));
52 
53  ebUHitsToken_ = consumes<EcalUncalibratedRecHitCollection>(ps.getParameter<edm::InputTag>("barrelUncalibHits"));
54  eeUHitsToken_ = consumes<EcalUncalibratedRecHitCollection>(ps.getParameter<edm::InputTag>("endcapUncalibHits"));
55 
56  caloGeometryToken_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
57 
58  // The names of the produced cluster collections
59  barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
60  endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
61 
62  // Island algorithm parameters
63  double barrelSeedThreshold = ps.getParameter<double>("BarrelSeedThr");
64  double barrelSingleThreshold = ps.getParameter<double>("BarrelSingleThr");
65  double barrelSecondThreshold = ps.getParameter<double>("BarrelSecondThr");
66  double barrelSupThreshold = ps.getParameter<double>("BarrelSupThr");
67  double endcapSeedThreshold = ps.getParameter<double>("EndcapSeedThr");
68  double endcapSingleThreshold = ps.getParameter<double>("EndcapSingleThr");
69  double endcapSecondThreshold = ps.getParameter<double>("EndcapSecondThr");
70  double endcapSupThreshold = ps.getParameter<double>("EndcapSupThr");
71 
72  // Parameters for the position calculation:
74 
77 
78  clustershapecollectionEB_ = ps.getParameter<std::string>("clustershapecollectionEB");
79  clustershapecollectionEE_ = ps.getParameter<std::string>("clustershapecollectionEE");
80 
81  //AssociationMap
82  barrelClusterShapeAssociation_ = ps.getParameter<std::string>("barrelShapeAssociation");
83  endcapClusterShapeAssociation_ = ps.getParameter<std::string>("endcapShapeAssociation");
84 
85  // Produces a collection of barrel and a collection of endcap clusters
86 
87  produces<reco::ClusterShapeCollection>(clustershapecollectionEE_);
88  produces<reco::BasicClusterCollection>(endcapClusterCollection_);
89  produces<reco::ClusterShapeCollection>(clustershapecollectionEB_);
90  produces<reco::BasicClusterCollection>(barrelClusterCollection_);
91  produces<reco::BasicClusterShapeAssociationCollection>(barrelClusterShapeAssociation_);
92  produces<reco::BasicClusterShapeAssociationCollection>(endcapClusterShapeAssociation_);
93 
94  island_p = new CosmicClusterAlgo(barrelSeedThreshold,
95  barrelSingleThreshold,
96  barrelSecondThreshold,
97  barrelSupThreshold,
98  endcapSeedThreshold,
99  endcapSingleThreshold,
100  endcapSecondThreshold,
101  endcapSupThreshold,
103  verbosity);
104 
105  nEvt_ = 0;
106 }
107 
109 
111  clusterizeECALPart(evt,
112  es,
113  eeHitsToken_,
118  clusterizeECALPart(evt,
119  es,
120  eeHitsToken_,
125  nEvt_++;
126 }
127 
129  const edm::EventSetup& es,
132  const std::string& clusterCollection,
133  const std::string& clusterShapeAssociation,
134  const CosmicClusterAlgo::EcalPart& ecalPart) {
135  // get the hit collection from the event:
136 
139 
140  evt.getByToken(hitsToken, hits_h);
141  evt.getByToken(uhitsToken, uhits_h);
142 
143  const EcalRecHitCollection* hitCollection_p = hits_h.product();
144  const EcalUncalibratedRecHitCollection* uhitCollection_p = uhits_h.product();
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 
152  std::string clustershapetag;
153  if (ecalPart == CosmicClusterAlgo::barrel) {
154  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
155  topology_p = std::make_unique<EcalBarrelTopology>(*geoHandle);
156  } else {
157  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
158  topology_p = std::make_unique<EcalEndcapTopology>(*geoHandle);
159  }
160 
161  const CaloSubdetectorGeometry* geometryES_p;
162  geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
163 
164  // Run the clusterization algorithm:
166  clusters =
167  island_p->makeClusters(hitCollection_p, uhitCollection_p, geometry_p, topology_p.get(), geometryES_p, ecalPart);
168 
169  //Create associated ClusterShape objects.
170  std::vector<reco::ClusterShape> ClusVec;
171 
172  for (int erg = 0; erg < int(clusters.size()); ++erg) {
173  reco::ClusterShape TestShape = shapeAlgo_.Calculate(clusters[erg], hitCollection_p, geometry_p, topology_p.get());
174  ClusVec.push_back(TestShape);
175  }
176 
177  //Put clustershapes in event, but retain a Handle on them.
178  auto clustersshapes_p = std::make_unique<reco::ClusterShapeCollection>();
179  clustersshapes_p->assign(ClusVec.begin(), ClusVec.end());
181  if (ecalPart == CosmicClusterAlgo::barrel)
182  clusHandle = evt.put(std::move(clustersshapes_p), clustershapecollectionEB_);
183  else
184  clusHandle = evt.put(std::move(clustersshapes_p), clustershapecollectionEE_);
185 
186  // create a unique_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
187  auto clusters_p = std::make_unique<reco::BasicClusterCollection>();
188  clusters_p->assign(clusters.begin(), clusters.end());
190 
191  if (ecalPart == CosmicClusterAlgo::barrel)
192  bccHandle = evt.put(std::move(clusters_p), barrelClusterCollection_);
193  else
194  bccHandle = evt.put(std::move(clusters_p), endcapClusterCollection_);
195 
196  // BasicClusterShapeAssociationMap
197  auto shapeAssocs_p = std::make_unique<reco::BasicClusterShapeAssociationCollection>(bccHandle, clusHandle);
198 
199  for (unsigned int i = 0; i < clusHandle->size(); i++) {
200  shapeAssocs_p->insert(edm::Ref<reco::BasicClusterCollection>(bccHandle, i),
202  }
203  evt.put(std::move(shapeAssocs_p), clusterShapeAssociation);
204 }
CosmicClusterProducer::~CosmicClusterProducer
~CosmicClusterProducer() override
Definition: CosmicClusterProducer.cc:108
Handle.h
mps_fire.i
i
Definition: mps_fire.py:428
PositionCalc.h
CosmicClusterProducer::barrelClusterCollection_
std::string barrelClusterCollection_
Definition: CosmicClusterProducer.h:50
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
CosmicClusterProducer::ebUHitsToken_
edm::EDGetTokenT< EcalUncalibratedRecHitCollection > ebUHitsToken_
Definition: CosmicClusterProducer.h:46
ESHandle.h
CosmicClusterProducer.h
BasicCluster.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
CosmicClusterProducer::island_p
CosmicClusterAlgo * island_p
Definition: CosmicClusterProducer.h:62
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
CosmicClusterAlgo::endcap
Definition: CosmicClusterAlgo.h:29
edm::SortedCollection< EcalRecHit >
CosmicClusterProducer::CosmicClusterProducer
CosmicClusterProducer(const edm::ParameterSet &ps)
Definition: CosmicClusterProducer.cc:37
CosmicClusterProducer::nEvt_
int nEvt_
Definition: CosmicClusterProducer.h:39
MonitorAlCaEcalPi0_cfi.posCalcParameters
posCalcParameters
Definition: MonitorAlCaEcalPi0_cfi.py:72
ClusterShapeAlgo.h
edm::Handle
Definition: AssociativeIterator.h:50
EcalBarrel
Definition: EcalSubdetector.h:10
EcalRecHitCollections.h
BasicClusterFwd.h
edm::Ref
Definition: AssociativeIterator.h:58
CosmicClusterAlgo::EcalPart
EcalPart
Definition: CosmicClusterAlgo.h:29
CosmicClusterAlgo::makeClusters
std::vector< reco::BasicCluster > makeClusters(const EcalRecHitCollection *hits, const EcalUncalibratedRecHitCollection *uncalibhits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p, EcalPart ecalPart, bool regional=false, const std::vector< RectangularEtaPhiRegion > &regions=std::vector< RectangularEtaPhiRegion >())
Definition: CosmicClusterAlgo.cc:16
ClusterShapeFwd.h
CosmicClusterProducer::caloGeometryToken_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
Definition: CosmicClusterProducer.h:48
reco::ClusterShape
Definition: ClusterShape.h:21
edm::ESHandle< CaloGeometry >
CosmicClusterProducer::endcapClusterShapeAssociation_
std::string endcapClusterShapeAssociation_
Definition: CosmicClusterProducer.h:58
EcalRecHit.h
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:535
ClusterShapeAlgo
Definition: ClusterShapeAlgo.h:35
reco::BasicClusterCollection
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
Definition: BasicClusterFwd.h:16
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalEndcap
Definition: EcalSubdetector.h:10
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
ClusterShape.h
CosmicClusterProducer::shapeAlgo_
ClusterShapeAlgo shapeAlgo_
Definition: CosmicClusterProducer.h:61
CaloSubdetectorGeometry.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
CosmicClusterProducer::barrelClusterShapeAssociation_
std::string barrelClusterShapeAssociation_
Definition: CosmicClusterProducer.h:57
CosmicClusterProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: CosmicClusterProducer.cc:110
EcalEndcapTopology.h
CosmicClusterProducer::endcapClusterCollection_
std::string endcapClusterCollection_
Definition: CosmicClusterProducer.h:51
CosmicClusterAlgo
Definition: CosmicClusterAlgo.h:27
PositionCalc
Definition: PositionCalc.h:29
createfilelist.int
int
Definition: createfilelist.py:10
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::EventSetup
Definition: EventSetup.h:58
DetId::Ecal
Definition: DetId.h:27
CosmicClusterAlgo::pERROR
Definition: CosmicClusterAlgo.h:30
EcalPreshower
Definition: EcalSubdetector.h:10
CaloCellGeometry.h
ClusterShapeAlgo::Calculate
reco::ClusterShape Calculate(const reco::BasicCluster &passedCluster, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology)
Definition: ClusterShapeAlgo.cc:21
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::OrphanHandle
Definition: EDProductfwd.h:39
CosmicClusterAlgo::pWARNING
Definition: CosmicClusterAlgo.h:30
EventSetup.h
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
CosmicClusterProducer::ebHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > ebHitsToken_
Definition: CosmicClusterProducer.h:43
CosmicClusterProducer::verbosity
CosmicClusterAlgo::VerbosityLevel verbosity
Definition: CosmicClusterProducer.h:41
CosmicClusterProducer::clustershapecollectionEB_
std::string clustershapecollectionEB_
Definition: CosmicClusterProducer.h:53
CosmicClusterAlgo::pDEBUG
Definition: CosmicClusterAlgo.h:30
edm::Event
Definition: Event.h:73
CosmicClusterAlgo::barrel
Definition: CosmicClusterAlgo.h:29
CosmicClusterProducer::clustershapecollectionEE_
std::string clustershapecollectionEE_
Definition: CosmicClusterProducer.h:54
edm::InputTag
Definition: InputTag.h:15
BasicClusterShapeAssociation.h
CosmicClusterAlgo::pINFO
Definition: CosmicClusterAlgo.h:30
CosmicClusterProducer::eeUHitsToken_
edm::EDGetTokenT< EcalUncalibratedRecHitCollection > eeUHitsToken_
Definition: CosmicClusterProducer.h:47
CosmicClusterProducer::eeHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > eeHitsToken_
Definition: CosmicClusterProducer.h:44
CosmicClusterProducer::posCalculator_
PositionCalc posCalculator_
Definition: CosmicClusterProducer.h:60
CosmicClusterProducer::clusterizeECALPart
void clusterizeECALPart(edm::Event &evt, const edm::EventSetup &es, const edm::EDGetTokenT< EcalRecHitCollection > &hitsToken, const edm::EDGetTokenT< EcalUncalibratedRecHitCollection > &uhitsToken, const std::string &clusterCollection, const std::string &clusterShapeAssociation, const CosmicClusterAlgo::EcalPart &ecalPart)
Definition: CosmicClusterProducer.cc:128