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<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

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 Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

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
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

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

Additional Inherited Members

- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 22 of file PreshowerClusterShapeProducer.h.

Member Typedef Documentation

Definition at line 26 of file PreshowerClusterShapeProducer.h.

Constructor & Destructor Documentation

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


Definition at line 40 of file PreshowerClusterShapeProducer.cc.

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

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

Definition at line 72 of file PreshowerClusterShapeProducer.cc.

72  {
73  delete presh_pi0_algo;
74 }
EndcapPiZeroDiscriminatorAlgo * presh_pi0_algo

Member Function Documentation

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

Definition at line 77 of file PreshowerClusterShapeProducer.cc.

References edm::SortedCollection< T, SORT >::begin(), DetId::Ecal, EcalPreshower, edm::SortedCollection< T, SORT >::end(), JetChargeProducer_cfi::exp, geometry, edm::EventSetup::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(), funct::sin(), and edm::SortedCollection< T, SORT >::size().

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

Member Data Documentation

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

Definition at line 42 of file PreshowerClusterShapeProducer.h.

int PreshowerClusterShapeProducer::nEvt_
private

Definition at line 36 of file PreshowerClusterShapeProducer.h.

EndcapPiZeroDiscriminatorAlgo* PreshowerClusterShapeProducer::presh_pi0_algo
private

Definition at line 48 of file PreshowerClusterShapeProducer.h.

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

Definition at line 40 of file PreshowerClusterShapeProducer.h.

std::string PreshowerClusterShapeProducer::PreshowerClusterShapeCollectionX_
private

Definition at line 45 of file PreshowerClusterShapeProducer.h.

std::string PreshowerClusterShapeProducer::PreshowerClusterShapeCollectionY_
private

Definition at line 46 of file PreshowerClusterShapeProducer.h.