CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
PreshowerClusterShapeProducer Class Reference

#include <PreshowerClusterShapeProducer.h>

Inheritance diagram for PreshowerClusterShapeProducer:
edm::stream::EDProducer<>

Public Types

typedef math::XYZPoint Point
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Public Member Functions

 PreshowerClusterShapeProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &evt, const edm::EventSetup &es) override
 
 ~PreshowerClusterShapeProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Private Attributes

edm::EDGetTokenT< reco::SuperClusterCollectionendcapSClusterToken_
 
int nEvt_
 
EndcapPiZeroDiscriminatorAlgopresh_pi0_algo
 
edm::EDGetTokenT< EcalRecHitCollectionpreshHitToken_
 
std::string PreshowerClusterShapeCollectionX_
 
std::string PreshowerClusterShapeCollectionY_
 

Detailed Description

Definition at line 21 of file PreshowerClusterShapeProducer.h.

Member Typedef Documentation

◆ Point

Definition at line 23 of file PreshowerClusterShapeProducer.h.

Constructor & Destructor Documentation

◆ PreshowerClusterShapeProducer()

PreshowerClusterShapeProducer::PreshowerClusterShapeProducer ( const edm::ParameterSet ps)
explicit

Definition at line 40 of file PreshowerClusterShapeProducer.cc.

40  {
41  // use configuration file to setup input/output collection names
42  // Parameters to identify the hit collections
43  preshHitToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("preshRecHitProducer"));
45  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("endcapSClusterProducer"));
46 
47  PreshowerClusterShapeCollectionX_ = ps.getParameter<string>("PreshowerClusterShapeCollectionX");
48  PreshowerClusterShapeCollectionY_ = ps.getParameter<string>("PreshowerClusterShapeCollectionY");
49 
50  produces<reco::PreshowerClusterShapeCollection>(PreshowerClusterShapeCollectionX_);
51  produces<reco::PreshowerClusterShapeCollection>(PreshowerClusterShapeCollectionY_);
52 
53  float preshStripECut = ps.getParameter<double>("preshStripEnergyCut");
54  int preshNst = ps.getParameter<int>("preshPi0Nstrip");
55 
56  string debugString = ps.getParameter<string>("debugLevel");
57 
58  string tmpPath = ps.getUntrackedParameter<string>("pathToWeightFiles", "RecoEcal/EgammaClusterProducers/data/");
59 
60  presh_pi0_algo = new EndcapPiZeroDiscriminatorAlgo(preshStripECut, preshNst, tmpPath);
61 
62  LogTrace("EcalClusters") << "PreshowerClusterShapeProducer:presh_pi0_algo class instantiated ";
63 
64  nEvt_ = 0;
65 }

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and LogTrace.

◆ ~PreshowerClusterShapeProducer()

PreshowerClusterShapeProducer::~PreshowerClusterShapeProducer ( )
override

Definition at line 67 of file PreshowerClusterShapeProducer.cc.

67 { delete presh_pi0_algo; }

Member Function Documentation

◆ produce()

void PreshowerClusterShapeProducer::produce ( edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 69 of file PreshowerClusterShapeProducer.cc.

69  {
70  ostringstream ostr; // use this stream for all messages in produce
71 
72  LogTrace("EcalClusters") << "\n ....... Event " << evt.id() << " with Number = " << nEvt_ + 1
73  << " is analyzing ....... ";
74 
76  Handle<SuperClusterCollection> pSuperClusters;
77 
78  // get the ECAL -> Preshower geometry and topology:
79  ESHandle<CaloGeometry> geoHandle;
80  es.get<CaloGeometryRecord>().get(geoHandle);
82  const CaloSubdetectorGeometry*& geometry_p = geometry;
83 
84  // create a unique_ptr to a PreshowerClusterShapeCollection
85  auto ps_cl_for_pi0_disc_x = std::make_unique<reco::PreshowerClusterShapeCollection>();
86  auto ps_cl_for_pi0_disc_y = std::make_unique<reco::PreshowerClusterShapeCollection>();
87 
88  std::unique_ptr<CaloSubdetectorTopology> topology_p;
89  if (geometry)
90  topology_p = std::make_unique<EcalPreshowerTopology>();
91 
92  // fetch the Preshower product (RecHits)
93  evt.getByToken(preshHitToken_, pRecHits);
94  // pointer to the object in the product
95  const EcalRecHitCollection* rechits = pRecHits.product();
96 
97  LogTrace("EcalClusters") << "PreshowerClusterShapeProducer: ### Total # of preshower RecHits: " << rechits->size();
98 
99  // if ( rechits->size() <= 0 ) return;
100 
101  // make the map of Preshower rechits:
102  map<DetId, EcalRecHit> rechits_map;
104  for (it = rechits->begin(); it != rechits->end(); it++) {
105  rechits_map.insert(make_pair(it->id(), *it));
106  }
107 
108  LogTrace("EcalClusters") << "PreshowerClusterShapeProducer: ### Preshower RecHits_map of size " << rechits_map.size()
109  << " was created!";
110 
111  reco::PreshowerClusterShapeCollection ps_cl_x, ps_cl_y;
112 
113  //make cycle over Photon Collection
114  int SC_index = 0;
115  // Handle<PhotonCollection> correctedPhotonHandle;
116  // evt.getByLabel(photonCorrCollectionProducer_, correctedPhotonCollection_ , correctedPhotonHandle);
117  // const PhotonCollection corrPhoCollection = *(correctedPhotonHandle.product());
118  // cout << " Photon Collection size : " << corrPhoCollection.size() << endl;
119 
120  evt.getByToken(endcapSClusterToken_, pSuperClusters);
121  const reco::SuperClusterCollection* SClusts = pSuperClusters.product();
122  LogTrace("EcalClusters") << "### Total # Endcap Superclusters: " << SClusts->size();
123 
124  SuperClusterCollection::const_iterator it_s;
125  for (it_s = SClusts->begin(); it_s != SClusts->end(); it_s++) {
126  SuperClusterRef it_super(reco::SuperClusterRef(pSuperClusters, SC_index));
127 
128  float SC_eta = it_super->eta();
129 
130  LogTrace("EcalClusters") << "PreshowerClusterShapeProducer: superCl_E = " << it_super->energy()
131  << " superCl_Et = " << it_super->energy() * sin(2 * atan(exp(-it_super->eta())))
132  << " superCl_Eta = " << SC_eta << " superCl_Phi = " << it_super->phi();
133 
134  if (fabs(SC_eta) >= 1.65 && fabs(SC_eta) <= 2.5) { // Use Preshower region only
135  if (geometry) {
136  const GlobalPoint pointSC(it_super->x(), it_super->y(), it_super->z()); // get the centroid of the SC
137  LogTrace("EcalClusters") << "SC centroind = " << pointSC;
138 
139  // Get the Preshower 2-planes RecHit vectors associated with the given SC
140 
141  DetId tmp_stripX = (dynamic_cast<const EcalPreshowerGeometry*>(geometry_p))->getClosestCellInPlane(pointSC, 1);
142  DetId tmp_stripY = (dynamic_cast<const EcalPreshowerGeometry*>(geometry_p))->getClosestCellInPlane(pointSC, 2);
143  ESDetId stripX = (tmp_stripX == DetId(0)) ? ESDetId(0) : ESDetId(tmp_stripX);
144  ESDetId stripY = (tmp_stripY == DetId(0)) ? ESDetId(0) : ESDetId(tmp_stripY);
145 
146  vector<float> vout_stripE1 = presh_pi0_algo->findPreshVector(stripX, &rechits_map, topology_p.get());
147  vector<float> vout_stripE2 = presh_pi0_algo->findPreshVector(stripY, &rechits_map, topology_p.get());
148 
149  LogTrace("EcalClusters") << "PreshowerClusterShapeProducer : ES Energy vector associated to the given SC = ";
150  for (int k1 = 0; k1 < 11; k1++) {
151  LogTrace("EcalClusters") << vout_stripE1[k1] << " ";
152  }
153 
154  for (int k1 = 0; k1 < 11; k1++) {
155  LogTrace("EcalClusters") << vout_stripE2[k1] << " ";
156  }
157 
159  ps1.setSCRef(it_super);
160  ps_cl_x.push_back(ps1);
161 
163  ps2.setSCRef(it_super);
164  ps_cl_y.push_back(ps2);
165  }
166  SC_index++;
167  } // end of cycle over Endcap SC
168  }
169  // put collection of PreshowerClusterShape in the Event:
170  ps_cl_for_pi0_disc_x->assign(ps_cl_x.begin(), ps_cl_x.end());
171  ps_cl_for_pi0_disc_y->assign(ps_cl_y.begin(), ps_cl_y.end());
172 
173  evt.put(std::move(ps_cl_for_pi0_disc_x), PreshowerClusterShapeCollectionX_);
174  evt.put(std::move(ps_cl_for_pi0_disc_y), PreshowerClusterShapeCollectionY_);
175  LogTrace("EcalClusters") << "PreshowerClusterShapeCollection added to the event";
176 
177  nEvt_++;
178 
179  LogDebug("PiZeroDiscriminatorDebug") << ostr.str();
180 }

References DetId::Ecal, EcalPreshower, JetChargeProducer_cfi::exp, geometry, edm::EventSetup::get(), get, edm::Event::getByToken(), CaloGeometry::getSubdetectorGeometry(), edm::EventBase::id(), LogDebug, LogTrace, eostools::move(), edm::Handle< T >::product(), edm::Event::put(), TrackInfoProducer_cfi::rechits, reco::PreshowerClusterShape::setSCRef(), and funct::sin().

Member Data Documentation

◆ endcapSClusterToken_

edm::EDGetTokenT<reco::SuperClusterCollection> PreshowerClusterShapeProducer::endcapSClusterToken_
private

Definition at line 38 of file PreshowerClusterShapeProducer.h.

◆ nEvt_

int PreshowerClusterShapeProducer::nEvt_
private

Definition at line 32 of file PreshowerClusterShapeProducer.h.

◆ presh_pi0_algo

EndcapPiZeroDiscriminatorAlgo* PreshowerClusterShapeProducer::presh_pi0_algo
private

Definition at line 44 of file PreshowerClusterShapeProducer.h.

◆ preshHitToken_

edm::EDGetTokenT<EcalRecHitCollection> PreshowerClusterShapeProducer::preshHitToken_
private

Definition at line 36 of file PreshowerClusterShapeProducer.h.

◆ PreshowerClusterShapeCollectionX_

std::string PreshowerClusterShapeProducer::PreshowerClusterShapeCollectionX_
private

Definition at line 41 of file PreshowerClusterShapeProducer.h.

◆ PreshowerClusterShapeCollectionY_

std::string PreshowerClusterShapeProducer::PreshowerClusterShapeCollectionY_
private

Definition at line 42 of file PreshowerClusterShapeProducer.h.

reco::PreshowerClusterShape
Definition: PreshowerClusterShape.h:14
geometry
ESHandle< TrackerGeometry > geometry
Definition: TkLasBeamFitter.cc:200
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
edm::Handle::product
T const * product() const
Definition: Handle.h:70
reco::PreshowerClusterShape::setSCRef
void setSCRef(const SuperClusterRef &r)
Definition: PreshowerClusterShape.h:36
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
geometry
Definition: geometry.py:1
CaloGeometry::getSubdetectorGeometry
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
edm::SortedCollection< EcalRecHit >
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
ESDetId
Definition: ESDetId.h:15
edm::Handle
Definition: AssociativeIterator.h:50
EndcapPiZeroDiscriminatorAlgo
Definition: EndcapPiZeroDiscriminatorAlgo.h:15
EndcapPiZeroDiscriminatorAlgo::findPreshVector
std::vector< float > findPreshVector(ESDetId strip, RecHitsMap *rechits_map, CaloSubdetectorTopology *topology_p)
Definition: EndcapPiZeroDiscriminatorAlgo.cc:40
edm::Ref< SuperClusterCollection >
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
reco::SuperClusterCollection
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Definition: SuperClusterFwd.h:9
DetId
Definition: DetId.h:17
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
edm::ESHandle< CaloGeometry >
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
Point3DBase< float, GlobalTag >
reco::PreshowerClusterShapeCollection
std::vector< PreshowerClusterShape > PreshowerClusterShapeCollection
collection of PreshowerClusterShape objects
Definition: PreshowerClusterShapeFwd.h:13
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
PreshowerClusterShapeProducer::PreshowerClusterShapeCollectionY_
std::string PreshowerClusterShapeCollectionY_
Definition: PreshowerClusterShapeProducer.h:42
TrackInfoProducer_cfi.rechits
rechits
Definition: TrackInfoProducer_cfi.py:9
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
PreshowerClusterShapeProducer::PreshowerClusterShapeCollectionX_
std::string PreshowerClusterShapeCollectionX_
Definition: PreshowerClusterShapeProducer.h:41
DetId::Ecal
Definition: DetId.h:27
get
#define get
PreshowerClusterShapeProducer::endcapSClusterToken_
edm::EDGetTokenT< reco::SuperClusterCollection > endcapSClusterToken_
Definition: PreshowerClusterShapeProducer.h:38
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
EcalPreshower
Definition: EcalSubdetector.h:10
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::EventBase::id
edm::EventID id() const
Definition: EventBase.h:59
CaloSubdetectorGeometry
Definition: CaloSubdetectorGeometry.h:22
PreshowerClusterShapeProducer::preshHitToken_
edm::EDGetTokenT< EcalRecHitCollection > preshHitToken_
Definition: PreshowerClusterShapeProducer.h:36
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:671
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
PreshowerClusterShapeProducer::presh_pi0_algo
EndcapPiZeroDiscriminatorAlgo * presh_pi0_algo
Definition: PreshowerClusterShapeProducer.h:44
edm::InputTag
Definition: InputTag.h:15
PreshowerClusterShapeProducer::nEvt_
int nEvt_
Definition: PreshowerClusterShapeProducer.h:32