CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
PreshowerClusterShapeProducer Class Reference
Inheritance diagram for PreshowerClusterShapeProducer:
edm::stream::EDProducer<>

Public Types

typedef math::XYZPoint Point
 
- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Public Member Functions

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

Private Attributes

edm::ESGetToken< CaloGeometry, CaloGeometryRecordcaloGeometryToken_
 
edm::EDGetTokenT< reco::SuperClusterCollectionendcapSClusterToken_
 
int nEvt_
 
EndcapPiZeroDiscriminatorAlgopresh_pi0_algo
 
edm::EDGetTokenT< EcalRecHitCollectionpreshHitToken_
 
std::string PreshowerClusterShapeCollectionX_
 
std::string PreshowerClusterShapeCollectionY_
 

Detailed Description

Definition at line 32 of file PreshowerClusterShapeProducer.cc.

Member Typedef Documentation

◆ Point

Definition at line 34 of file PreshowerClusterShapeProducer.cc.

Constructor & Destructor Documentation

◆ PreshowerClusterShapeProducer()

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


Definition at line 67 of file PreshowerClusterShapeProducer.cc.

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

67  {
68  // use configuration file to setup input/output collection names
69  // Parameters to identify the hit collections
70  preshHitToken_ = consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("preshRecHitProducer"));
72  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("endcapSClusterProducer"));
73  caloGeometryToken_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
74 
75  PreshowerClusterShapeCollectionX_ = ps.getParameter<string>("PreshowerClusterShapeCollectionX");
76  PreshowerClusterShapeCollectionY_ = ps.getParameter<string>("PreshowerClusterShapeCollectionY");
77 
78  produces<reco::PreshowerClusterShapeCollection>(PreshowerClusterShapeCollectionX_);
79  produces<reco::PreshowerClusterShapeCollection>(PreshowerClusterShapeCollectionY_);
80 
81  float preshStripECut = ps.getParameter<double>("preshStripEnergyCut");
82  int preshNst = ps.getParameter<int>("preshPi0Nstrip");
83 
84  string debugString = ps.getParameter<string>("debugLevel");
85 
86  string tmpPath = ps.getUntrackedParameter<string>("pathToWeightFiles", "RecoEcal/EgammaClusterProducers/data/");
87 
88  presh_pi0_algo = new EndcapPiZeroDiscriminatorAlgo(preshStripECut, preshNst, tmpPath);
89 
90  LogTrace("EcalClusters") << "PreshowerClusterShapeProducer:presh_pi0_algo class instantiated ";
91 
92  nEvt_ = 0;
93 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
#define LogTrace(id)
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::SuperClusterCollection > endcapSClusterToken_
EndcapPiZeroDiscriminatorAlgo * presh_pi0_algo
edm::EDGetTokenT< EcalRecHitCollection > preshHitToken_

◆ ~PreshowerClusterShapeProducer()

PreshowerClusterShapeProducer::~PreshowerClusterShapeProducer ( )
override

Definition at line 95 of file PreshowerClusterShapeProducer.cc.

95 { delete presh_pi0_algo; }
EndcapPiZeroDiscriminatorAlgo * presh_pi0_algo

Member Function Documentation

◆ produce()

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

Definition at line 97 of file PreshowerClusterShapeProducer.cc.

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

97  {
98  ostringstream ostr; // use this stream for all messages in produce
99 
100  LogTrace("EcalClusters") << "\n ....... Event " << evt.id() << " with Number = " << nEvt_ + 1
101  << " is analyzing ....... ";
102 
104  Handle<SuperClusterCollection> pSuperClusters;
105 
106  // get the ECAL -> Preshower geometry and topology:
109  const CaloSubdetectorGeometry*& geometry_p = geometry;
110 
111  // create a unique_ptr to a PreshowerClusterShapeCollection
112  auto ps_cl_for_pi0_disc_x = std::make_unique<reco::PreshowerClusterShapeCollection>();
113  auto ps_cl_for_pi0_disc_y = std::make_unique<reco::PreshowerClusterShapeCollection>();
114 
115  std::unique_ptr<CaloSubdetectorTopology> topology_p;
116  if (geometry)
117  topology_p = std::make_unique<EcalPreshowerTopology>();
118 
119  // fetch the Preshower product (RecHits)
120  evt.getByToken(preshHitToken_, pRecHits);
121  // pointer to the object in the product
122  const EcalRecHitCollection* rechits = pRecHits.product();
123 
124  LogTrace("EcalClusters") << "PreshowerClusterShapeProducer: ### Total # of preshower RecHits: " << rechits->size();
125 
126  // if ( rechits->size() <= 0 ) return;
127 
128  // make the map of Preshower rechits:
129  map<DetId, EcalRecHit> rechits_map;
131  for (it = rechits->begin(); it != rechits->end(); it++) {
132  rechits_map.insert(make_pair(it->id(), *it));
133  }
134 
135  LogTrace("EcalClusters") << "PreshowerClusterShapeProducer: ### Preshower RecHits_map of size " << rechits_map.size()
136  << " was created!";
137 
138  reco::PreshowerClusterShapeCollection ps_cl_x, ps_cl_y;
139 
140  //make cycle over Photon Collection
141  int SC_index = 0;
142  // Handle<PhotonCollection> correctedPhotonHandle;
143  // evt.getByLabel(photonCorrCollectionProducer_, correctedPhotonCollection_ , correctedPhotonHandle);
144  // const PhotonCollection corrPhoCollection = *(correctedPhotonHandle.product());
145  // cout << " Photon Collection size : " << corrPhoCollection.size() << endl;
146 
147  evt.getByToken(endcapSClusterToken_, pSuperClusters);
148  const reco::SuperClusterCollection* SClusts = pSuperClusters.product();
149  LogTrace("EcalClusters") << "### Total # Endcap Superclusters: " << SClusts->size();
150 
151  SuperClusterCollection::const_iterator it_s;
152  for (it_s = SClusts->begin(); it_s != SClusts->end(); it_s++) {
153  SuperClusterRef it_super(reco::SuperClusterRef(pSuperClusters, SC_index));
154 
155  float SC_eta = it_super->eta();
156 
157  LogTrace("EcalClusters") << "PreshowerClusterShapeProducer: superCl_E = " << it_super->energy()
158  << " superCl_Et = " << it_super->energy() * sin(2 * atan(exp(-it_super->eta())))
159  << " superCl_Eta = " << SC_eta << " superCl_Phi = " << it_super->phi();
160 
161  if (fabs(SC_eta) >= 1.65 && fabs(SC_eta) <= 2.5) { // Use Preshower region only
162  if (geometry) {
163  const GlobalPoint pointSC(it_super->x(), it_super->y(), it_super->z()); // get the centroid of the SC
164  LogTrace("EcalClusters") << "SC centroind = " << pointSC;
165 
166  // Get the Preshower 2-planes RecHit vectors associated with the given SC
167 
168  DetId tmp_stripX = (dynamic_cast<const EcalPreshowerGeometry*>(geometry_p))->getClosestCellInPlane(pointSC, 1);
169  DetId tmp_stripY = (dynamic_cast<const EcalPreshowerGeometry*>(geometry_p))->getClosestCellInPlane(pointSC, 2);
170  ESDetId stripX = (tmp_stripX == DetId(0)) ? ESDetId(0) : ESDetId(tmp_stripX);
171  ESDetId stripY = (tmp_stripY == DetId(0)) ? ESDetId(0) : ESDetId(tmp_stripY);
172 
173  vector<float> vout_stripE1 = presh_pi0_algo->findPreshVector(stripX, &rechits_map, topology_p.get());
174  vector<float> vout_stripE2 = presh_pi0_algo->findPreshVector(stripY, &rechits_map, topology_p.get());
175 
176  LogTrace("EcalClusters") << "PreshowerClusterShapeProducer : ES Energy vector associated to the given SC = ";
177  for (int k1 = 0; k1 < 11; k1++) {
178  LogTrace("EcalClusters") << vout_stripE1[k1] << " ";
179  }
180 
181  for (int k1 = 0; k1 < 11; k1++) {
182  LogTrace("EcalClusters") << vout_stripE2[k1] << " ";
183  }
184 
186  ps1.setSCRef(it_super);
187  ps_cl_x.push_back(ps1);
188 
190  ps2.setSCRef(it_super);
191  ps_cl_y.push_back(ps2);
192  }
193  SC_index++;
194  } // end of cycle over Endcap SC
195  }
196  // put collection of PreshowerClusterShape in the Event:
197  ps_cl_for_pi0_disc_x->assign(ps_cl_x.begin(), ps_cl_x.end());
198  ps_cl_for_pi0_disc_y->assign(ps_cl_y.begin(), ps_cl_y.end());
199 
200  evt.put(std::move(ps_cl_for_pi0_disc_x), PreshowerClusterShapeCollectionX_);
201  evt.put(std::move(ps_cl_for_pi0_disc_y), PreshowerClusterShapeCollectionY_);
202  LogTrace("EcalClusters") << "PreshowerClusterShapeCollection added to the event";
203 
204  nEvt_++;
205 
206  LogDebug("PiZeroDiscriminatorDebug") << ostr.str();
207 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
void setSCRef(const SuperClusterRef &r)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T const * product() const
Definition: Handle.h:70
std::vector< EcalRecHit >::const_iterator const_iterator
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
#define LogTrace(id)
std::vector< float > findPreshVector(ESDetId strip, RecHitsMap *rechits_map, CaloSubdetectorTopology *topology_p)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
std::vector< PreshowerClusterShape > PreshowerClusterShapeCollection
collection of PreshowerClusterShape objects
edm::EventID id() const
Definition: EventBase.h:63
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
Definition: DetId.h:17
edm::EDGetTokenT< reco::SuperClusterCollection > endcapSClusterToken_
EndcapPiZeroDiscriminatorAlgo * presh_pi0_algo
edm::EDGetTokenT< EcalRecHitCollection > preshHitToken_
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
def move(src, dest)
Definition: eostools.py:511
#define LogDebug(id)

Member Data Documentation

◆ caloGeometryToken_

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> PreshowerClusterShapeProducer::caloGeometryToken_
private

Definition at line 51 of file PreshowerClusterShapeProducer.cc.

◆ endcapSClusterToken_

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

Definition at line 49 of file PreshowerClusterShapeProducer.cc.

◆ nEvt_

int PreshowerClusterShapeProducer::nEvt_
private

Definition at line 43 of file PreshowerClusterShapeProducer.cc.

◆ presh_pi0_algo

EndcapPiZeroDiscriminatorAlgo* PreshowerClusterShapeProducer::presh_pi0_algo
private

Definition at line 56 of file PreshowerClusterShapeProducer.cc.

◆ preshHitToken_

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

Definition at line 47 of file PreshowerClusterShapeProducer.cc.

◆ PreshowerClusterShapeCollectionX_

std::string PreshowerClusterShapeProducer::PreshowerClusterShapeCollectionX_
private

Definition at line 53 of file PreshowerClusterShapeProducer.cc.

◆ PreshowerClusterShapeCollectionY_

std::string PreshowerClusterShapeProducer::PreshowerClusterShapeCollectionY_
private

Definition at line 54 of file PreshowerClusterShapeProducer.cc.