CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PFClusterShapeProducer.cc
Go to the documentation of this file.
2 
5 
7 
8 #include <sstream>
9 
10 using namespace edm;
11 using namespace std;
12 
14 {
15  shapesLabel_ = ps.getParameter<std::string>("PFClusterShapesLabel");
16 
17  inputTagPFClustersECAL_
18  = ps.getParameter<InputTag>("PFClustersECAL");
19  inputTagPFRecHitsECAL_
20  = ps.getParameter<InputTag>("PFRecHitsECAL");
21 
22  csAlgo_p = new PFClusterShapeAlgo(ps.getParameter<bool>("useFractions"),
23  ps.getParameter<double>("W0"));
24 
25  produces<reco::ClusterShapeCollection>(shapesLabel_);
26  produces<reco::PFClusterShapeAssociationCollection>(shapesLabel_);
27 }
28 
29 
31 {
32  delete csAlgo_p;
33 }
34 
35 
37 {
38 
40  clusterHandle = getClusterCollection(evt);
42  rechitHandle = getRecHitCollection(evt);
43 
45  es.get<CaloGeometryRecord>().get(geoHandle);
46 
47  const CaloSubdetectorGeometry * barrelGeo_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
48  const CaloSubdetectorTopology * barrelTop_p = new EcalBarrelTopology(geoHandle);
49  const CaloSubdetectorGeometry * endcapGeo_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
50  const CaloSubdetectorTopology * endcapTop_p = new EcalEndcapTopology(geoHandle);
51 
52  std::auto_ptr<reco::ClusterShapeCollection>
53  csCollection_ap(csAlgo_p->makeClusterShapes(clusterHandle, rechitHandle,
54  barrelGeo_p, barrelTop_p,
55  endcapGeo_p, endcapTop_p));
56 
57  edm::OrphanHandle<reco::ClusterShapeCollection> shape_h = evt.put(csCollection_ap, shapesLabel_);
58 
59  std::auto_ptr<reco::PFClusterShapeAssociationCollection> association_ap(new reco::PFClusterShapeAssociationCollection);
60 
61  for (unsigned int i = 0; i < clusterHandle->size(); i++){
62  association_ap->insert(edm::Ref<reco::PFClusterCollection>(clusterHandle, i),
64  }
65 
66  evt.put(association_ap, shapesLabel_);
67 
68  delete barrelTop_p;
69  delete endcapTop_p;
70 }
71 
72 
75 {
77 
78  bool found = evt.getByLabel(inputTagPFClustersECAL_, handle);
79  if (!found) {
80  ostringstream err;
81  err<<"cannot find clusters: "<<inputTagPFClustersECAL_;
82  LogError("PFSimParticleProducer")<<err.str()<<endl;
83 
84  throw cms::Exception( "MissingProduct", err.str());
85  }
86 
87  return handle;
88 }
89 
90 
91 
94 {
96 
97  bool found = evt.getByLabel(inputTagPFRecHitsECAL_, handle);
98  if (!found) {
99  ostringstream err;
100  err<<"cannot find rechits: "<<inputTagPFRecHitsECAL_;
101  LogError("PFSimParticleProducer")<<err.str()<<endl;
102 
103  throw cms::Exception( "MissingProduct", err.str());
104  }
105 
106  return handle;
107 }
108 
edm::Handle< reco::PFRecHitCollection > getRecHitCollection(edm::Event &evt)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
edm::Handle< reco::PFClusterCollection > getClusterCollection(edm::Event &evt)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
tuple handle
Definition: patZpeak.py:22
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
const T & get() const
Definition: EventSetup.h:55
virtual void produce(edm::Event &ev, const edm::EventSetup &es)
PFClusterShapeProducer(const edm::ParameterSet &)