CMS 3D CMS Logo

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

#include <PreshowerClusterProducer.h>

Inheritance diagram for PreshowerClusterProducer:
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

 PreshowerClusterProducer (const edm::ParameterSet &ps)
 
void produce (edm::Event &evt, const edm::EventSetup &es) override
 
void set (const edm::EventSetup &es)
 
 ~PreshowerClusterProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Private Attributes

double aEta_ [4]
 
double alpha0_
 
double alpha1_
 
double alpha2_
 
double alpha3_
 
std::string assocSClusterCollection_
 
double bEta_ [4]
 
edm::EDGetTokenT< reco::SuperClusterCollectionendcapSClusterToken_
 
edm::ESHandle< ESChannelStatusesChannelStatus_
 
edm::ESHandle< ESEEIntercalibConstantsesEEInterCalib_
 
edm::ESHandle< ESGainesgain_
 
edm::ESHandle< ESMIPToGeVConstantesMIPToGeV_
 
edm::ESHandle< ESMissingEnergyCalibrationesMissingECalib_
 
double etThresh_
 
double gamma0_
 
double gamma1_
 
double gamma2_
 
double gamma3_
 
double mip_
 
int nEvt_
 
PreshowerClusterAlgopresh_algo
 
float preshClustECut
 
std::string preshClusterCollectionX_
 
std::string preshClusterCollectionY_
 
edm::EDGetTokenT< EcalRecHitCollectionpreshHitsToken_
 
int preshNclust_
 

Detailed Description

Definition at line 24 of file PreshowerClusterProducer.h.

Member Typedef Documentation

Definition at line 28 of file PreshowerClusterProducer.h.

Constructor & Destructor Documentation

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

Definition at line 48 of file PreshowerClusterProducer.cc.

References edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

48  {
49 
50  // use configuration file to setup input/output collection names
52  consumes<EcalRecHitCollection>(ps.getParameter<edm::InputTag>("preshRecHitProducer"));
53 
54  // Name of a SuperClusterCollection to make associations:
56  consumes<reco::SuperClusterCollection>(ps.getParameter<edm::InputTag>("endcapSClusterProducer"));
57 
58  // Output collections:
59  preshClusterCollectionX_ = ps.getParameter<std::string>("preshClusterCollectionX");
60  preshClusterCollectionY_ = ps.getParameter<std::string>("preshClusterCollectionY");
61  preshNclust_ = ps.getParameter<int>("preshNclust");
62 
63  etThresh_ = ps.getParameter<double>("etThresh");
64 
65  assocSClusterCollection_ = ps.getParameter<std::string>("assocSClusterCollection");
66 
67  produces< reco::PreshowerClusterCollection >(preshClusterCollectionX_);
68  produces< reco::PreshowerClusterCollection >(preshClusterCollectionY_);
69  produces< reco::SuperClusterCollection >(assocSClusterCollection_);
70 
71  float preshStripECut = ps.getParameter<double>("preshStripEnergyCut");
72  int preshSeededNst = ps.getParameter<int>("preshSeededNstrip");
73  preshClustECut = ps.getParameter<double>("preshClusterEnergyCut");
74 
75  presh_algo = new PreshowerClusterAlgo(preshStripECut,preshClustECut,preshSeededNst);
76 
77  nEvt_ = 0;
78 }
T getParameter(std::string const &) const
PreshowerClusterAlgo * presh_algo
edm::EDGetTokenT< EcalRecHitCollection > preshHitsToken_
edm::EDGetTokenT< reco::SuperClusterCollection > endcapSClusterToken_
PreshowerClusterProducer::~PreshowerClusterProducer ( )
override

Definition at line 81 of file PreshowerClusterProducer.cc.

81  {
82  delete presh_algo;
83 }
PreshowerClusterAlgo * presh_algo

Member Function Documentation

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

Definition at line 85 of file PreshowerClusterProducer.cc.

References edm::SortedCollection< T, SORT >::begin(), GetRecoTauVFromDQM_MC_cff::cl2, MillePedeFileConverter_cfg::e, DetId::Ecal, EcalPreshower, edm::SortedCollection< T, SORT >::end(), SimCluster::energy(), reco::CaloCluster::energy(), ESCondObjectContainer< T >::find(), edm::EventSetup::get(), edm::Event::getByToken(), ESCondObjectContainer< T >::getMap(), CaloGeometry::getSubdetectorGeometry(), mps_fire::i, LogTrace, eostools::move(), point, edm::Handle< T >::product(), edm::PtrVector< T >::push_back(), edm::Event::put(), TrackInfoProducer_cfi::rechits, SimDataFormats::CaloAnalysis::sc, reco::PreshowerCluster::setBCRef(), funct::sin(), edm::SortedCollection< T, SORT >::size(), SimCluster::theta(), X, DOFs::Y, and DOFs::Z.

85  {
86 
89 
90  // get the ECAL geometry:
92  es.get<CaloGeometryRecord>().get(geoHandle);
93 
94  // retrieve ES-EE intercalibration constants and channel status
95  set(es);
96  const ESChannelStatus *channelStatus = esChannelStatus_.product();
97 
99 
100  // create unique_ptr to a PreshowerClusterCollection
101  auto clusters_p1 = std::make_unique<reco::PreshowerClusterCollection>();
102  auto clusters_p2 = std::make_unique<reco::PreshowerClusterCollection>();
103  // create new collection of corrected super clusters
104  auto superclusters_p = std::make_unique<reco::SuperClusterCollection>();
105 
106  std::unique_ptr<CaloSubdetectorTopology> topology_p;
107  if (geometry_p)
108  topology_p = std::make_unique<EcalPreshowerTopology>();
109 
110  // fetch the product (pSuperClusters)
111  evt.getByToken(endcapSClusterToken_, pSuperClusters);
112  const reco::SuperClusterCollection* SClusts = pSuperClusters.product();
113 
114  // fetch the product (RecHits)
115  evt.getByToken( preshHitsToken_, pRecHits);
116  // pointer to the object in the product
117  const EcalRecHitCollection* rechits = pRecHits.product(); // EcalRecHitCollection hit_collection = *rhcHandle;
118 
119  LogTrace("EcalClusters") << "PreshowerClusterProducerInfo: ### Total # of preshower RecHits: "<< rechits->size();
120 
121  // make the map of rechits:
122  std::map<DetId, EcalRecHit> rechits_map;
124  for (it = rechits->begin(); it != rechits->end(); it++) {
125  // remove bad ES rechits
126  if (it->recoFlag()==1 || it->recoFlag()==14 || (it->recoFlag()<=10 && it->recoFlag()>=5)) continue;
127  //Make the map of DetID, EcalRecHit pairs
128  rechits_map.insert(std::make_pair(it->id(), *it));
129  }
130  // The set of used DetID's for a given event:
131  std::set<DetId> used_strips;
132  used_strips.clear();
133  LogTrace("EcalClusters") << "PreshowerClusterProducerInfo: ### rechits_map of size " << rechits_map.size() <<" was created!";
134 
135 
136  reco::PreshowerClusterCollection clusters1, clusters2; // output collection of corrected PCs
137  reco::SuperClusterCollection new_SC; // output collection of corrected SCs
138 
139  //make cycle over super clusters
140  reco::SuperClusterCollection::const_iterator it_super;
141  int isc = 0;
142  for (it_super=SClusts->begin(); it_super!=SClusts->end(); ++it_super) {
143 
144  float e1 = 0;
145  float e2 = 0;
146  float deltaE = 0;
147 
149  ++isc;
150  LogTrace("EcalClusters")<< " superE = " << it_super->energy() << " superETA = " << it_super->eta() << " superPHI = " << it_super->phi() ;
151 
152  int nBC = 0;
153  int condP1 = 1; // 0: dead channel; 1: active channel
154  int condP2 = 1;
155  reco::CaloCluster_iterator bc_iter = it_super->clustersBegin();
156  for ( ; bc_iter !=it_super->clustersEnd(); ++bc_iter ) {
157  if (geometry_p) {
158 
159  // Get strip position at intersection point of the line EE - Vertex:
160  double X = (*bc_iter)->x();
161  double Y = (*bc_iter)->y();
162  double Z = (*bc_iter)->z();
163  const GlobalPoint point(X,Y,Z);
164 
165  DetId tmp1 = (dynamic_cast<const EcalPreshowerGeometry*>(geometry_p))->getClosestCellInPlane(point, 1);
166  DetId tmp2 = (dynamic_cast<const EcalPreshowerGeometry*>(geometry_p))->getClosestCellInPlane(point, 2);
167  ESDetId strip1 = (tmp1 == DetId(0)) ? ESDetId(0) : ESDetId(tmp1);
168  ESDetId strip2 = (tmp2 == DetId(0)) ? ESDetId(0) : ESDetId(tmp2);
169 
170  if (nBC == 0) {
171  if (strip1 != ESDetId(0) && strip2 != ESDetId(0)) {
172  ESChannelStatusMap::const_iterator status_p1 = channelStatus->getMap().find(strip1);
173  ESChannelStatusMap::const_iterator status_p2 = channelStatus->getMap().find(strip2);
174  if (status_p1->getStatusCode() == 1) condP1 = 0;
175  if (status_p2->getStatusCode() == 1) condP2 = 0;
176  } else if (strip1 == ESDetId(0))
177  condP1 = 0;
178  else if (strip2 == ESDetId(0))
179  condP2 = 0;
180  }
181 
182  // Get a vector of ES clusters (found by the PreshSeeded algorithm) associated with a given EE basic cluster.
183  for (int i=0; i<preshNclust_; i++) {
184  reco::PreshowerCluster cl1 = presh_algo->makeOneCluster(strip1,&used_strips,&rechits_map,geometry_p,topology_p.get());
185  cl1.setBCRef(*bc_iter);
186  if (cl1.energy() > preshClustECut) {
187  clusters1.push_back(cl1);
188  e1 += cl1.energy();
189  }
190  reco::PreshowerCluster cl2 = presh_algo->makeOneCluster(strip2,&used_strips,&rechits_map,geometry_p,topology_p.get());
191  cl2.setBCRef(*bc_iter);
192 
193  if ( cl2.energy() > preshClustECut) {
194  clusters2.push_back(cl2);
195  e2 += cl2.energy();
196  }
197  } // end of cycle over ES clusters
198  }
199 
200  new_BC.push_back(*bc_iter);
201  nBC++;
202  } // end of cycle over BCs
203 
204  LogTrace("EcalClusters") << " For SC #" << isc-1 << ", containing "
205  << it_super->clustersSize()
206  << " basic clusters, PreshowerClusterAlgo made "
207  << clusters1.size() << " in X plane and "
208  << clusters2.size()
209  << " in Y plane " << " preshower clusters " ;
210 
211  // update energy of the SuperCluster
212  if(e1+e2 > 1.0e-10) {
213 
214  e1 = e1 / mip_; // GeV to #MIPs
215  e2 = e2 / mip_;
216 
217  if (condP1 == 1 && condP2 == 1) {
218  deltaE = gamma0_*(e1 + alpha0_*e2);
219  } else if (condP1 == 1 && condP2 == 0) {
220  deltaE = gamma1_*(e1 + alpha1_*e2);
221  } else if (condP1 == 0 && condP2 == 1) {
222  deltaE = gamma2_*(e1 + alpha2_*e2);
223  } else if (condP1 == 0 && condP2 == 0) {
224  deltaE = gamma3_*(e1 + alpha3_*e2);
225  }
226  }
227 
228  //corrected Energy
229  float E = it_super->energy() + deltaE;
230 
231  LogTrace("EcalClusters") << " Creating corrected SC ";
232 
233  reco::SuperCluster sc(E, it_super->position(), it_super->seed(), new_BC, deltaE);
234  if (condP1 == 1 && condP2 == 1) sc.setPreshowerPlanesStatus(0);
235  else if (condP1 == 1 && condP2 == 0) sc.setPreshowerPlanesStatus(1);
236  else if (condP1 == 0 && condP2 == 1) sc.setPreshowerPlanesStatus(2);
237  else if (condP1 == 0 && condP2 == 0) sc.setPreshowerPlanesStatus(3);
238 
239  if (sc.energy()*sin(sc.position().theta())>etThresh_)
240  new_SC.push_back(sc);
241  LogTrace("EcalClusters") << " SuperClusters energies: new E = " << sc.energy() << " vs. old E =" << it_super->energy();
242 
243  } // end of cycle over SCs
244 
245  // copy the preshower clusters into collections and put in the Event:
246  clusters_p1->assign(clusters1.begin(), clusters1.end());
247  clusters_p2->assign(clusters2.begin(), clusters2.end());
248  // put collection of preshower clusters to the event
249  evt.put(std::move(clusters_p1), preshClusterCollectionX_);
250  evt.put(std::move(clusters_p2), preshClusterCollectionY_);
251  LogTrace("EcalClusters") << "Preshower clusters added to the event" ;
252 
253  // put collection of corrected super clusters to the event
254  superclusters_p->assign(new_SC.begin(), new_SC.end());
255  evt.put(std::move(superclusters_p), assocSClusterCollection_);
256  LogTrace("EcalClusters") << "Corrected SClusters added to the event" ;
257 
258  nEvt_++;
259 
260 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:140
const self & getMap() const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< EcalRecHit >::const_iterator const_iterator
#define X(str)
Definition: MuonsGrabber.cc:48
PreshowerClusterAlgo * presh_algo
reco::PreshowerCluster makeOneCluster(ESDetId strip, HitsID *used_strips, RecHitsMap *rechits_map, const CaloSubdetectorGeometry *geometry_p, const CaloSubdetectorTopology *topology_p)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
edm::ESHandle< ESChannelStatus > esChannelStatus_
void setBCRef(const CaloClusterPtr &r)
DetIds of component RecHits – now inherited from CaloCluster.
const_iterator find(uint32_t rawId) const
float energy() const
Energy. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:104
std::vector< PreshowerCluster > PreshowerClusterCollection
collection of PreshowerCluster objects
double energy() const
cluster energy
Definition: CaloCluster.h:126
#define LogTrace(id)
float theta() const
Momentum polar angle. Note this is taken from the first SimTrack only.
Definition: SimCluster.h:144
const_iterator end() const
Definition: DetId.h:18
edm::EDGetTokenT< EcalRecHitCollection > preshHitsToken_
T const * product() const
Definition: Handle.h:74
std::vector< Item >::const_iterator const_iterator
size_type size() const
T get() const
Definition: EventSetup.h:71
edm::EDGetTokenT< reco::SuperClusterCollection > endcapSClusterToken_
def move(src, dest)
Definition: eostools.py:511
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
const_iterator begin() const
void PreshowerClusterProducer::set ( const edm::EventSetup es)

Definition at line 262 of file PreshowerClusterProducer.cc.

References muonCSCDigis_cfi::gain, edm::EventSetup::get(), ESEEIntercalibConstants::getAlphaHigh0(), ESEEIntercalibConstants::getAlphaHigh1(), ESEEIntercalibConstants::getAlphaHigh2(), ESEEIntercalibConstants::getAlphaHigh3(), ESEEIntercalibConstants::getAlphaLow0(), ESEEIntercalibConstants::getAlphaLow1(), ESEEIntercalibConstants::getAlphaLow2(), ESEEIntercalibConstants::getAlphaLow3(), ESMissingEnergyCalibration::getConstAEta0(), ESMissingEnergyCalibration::getConstAEta1(), ESMissingEnergyCalibration::getConstAEta2(), ESMissingEnergyCalibration::getConstAEta3(), ESMissingEnergyCalibration::getConstBEta0(), ESMissingEnergyCalibration::getConstBEta1(), ESMissingEnergyCalibration::getConstBEta2(), ESMissingEnergyCalibration::getConstBEta3(), ESGain::getESGain(), ESMIPToGeVConstant::getESValueHigh(), ESMIPToGeVConstant::getESValueLow(), ESEEIntercalibConstants::getGammaHigh0(), ESEEIntercalibConstants::getGammaHigh1(), ESEEIntercalibConstants::getGammaHigh2(), ESEEIntercalibConstants::getGammaHigh3(), ESEEIntercalibConstants::getGammaLow1(), and ESEEIntercalibConstants::getGammaLow2().

262  {
263 
264  es.get<ESGainRcd>().get(esgain_);
265  const ESGain *gain = esgain_.product();
266 
267  double ESGain = gain->getESGain();
268 
270  const ESMIPToGeVConstant *mipToGeV = esMIPToGeV_.product();
271 
272  mip_ = (ESGain == 1) ? mipToGeV->getESValueLow() : mipToGeV->getESValueHigh();
273 
275 
277  const ESEEIntercalibConstants *esEEInterCalib = esEEInterCalib_.product();
278 
279  // both planes work
280  gamma0_ = (ESGain == 1) ? 0.02 : esEEInterCalib->getGammaHigh0();
281  alpha0_ = (ESGain == 1) ? esEEInterCalib->getAlphaLow0() : esEEInterCalib->getAlphaHigh0();
282 
283  // only first plane works
284  gamma1_ = (ESGain == 1) ? (0.02 * esEEInterCalib->getGammaLow1()) : esEEInterCalib->getGammaHigh1();
285  alpha1_ = (ESGain == 1) ? esEEInterCalib->getAlphaLow1() : esEEInterCalib->getAlphaHigh1();
286 
287  // only second plane works
288  gamma2_ = (ESGain == 1) ? (0.02 * esEEInterCalib->getGammaLow2()) : esEEInterCalib->getGammaHigh2();
289  alpha2_ = (ESGain == 1) ? esEEInterCalib->getAlphaLow2() : esEEInterCalib->getAlphaHigh2();
290 
291  // both planes do not work
292  gamma3_ = (ESGain == 1) ? 0.02 : esEEInterCalib->getGammaHigh3();
293  alpha3_ = (ESGain == 1) ? esEEInterCalib->getAlphaLow3() : esEEInterCalib->getAlphaHigh3();
294 
296  const ESMissingEnergyCalibration * esMissingECalib = esMissingECalib_.product();
297 
298  // |eta| < 1.9
299  aEta_[0] = esMissingECalib->getConstAEta0();
300  bEta_[0] = esMissingECalib->getConstBEta0();
301 
302  // 1.9 < |eta| < 2.1
303  aEta_[1] = esMissingECalib->getConstAEta1();
304  bEta_[1] = esMissingECalib->getConstBEta1();
305 
306  // 2.1 < |eta| < 2.3
307  aEta_[2] = esMissingECalib->getConstAEta2();
308  bEta_[2] = esMissingECalib->getConstBEta2();
309 
310  // 2.3 < |eta| < 2.5
311  aEta_[3] = esMissingECalib->getConstAEta3();
312  bEta_[3] = esMissingECalib->getConstBEta3();
313 
314 }
edm::ESHandle< ESMissingEnergyCalibration > esMissingECalib_
Definition: ESGain.h:7
edm::ESHandle< ESGain > esgain_
float getESValueLow() const
edm::ESHandle< ESChannelStatus > esChannelStatus_
edm::ESHandle< ESMIPToGeVConstant > esMIPToGeV_
edm::ESHandle< ESEEIntercalibConstants > esEEInterCalib_
float getESGain() const
Definition: ESGain.h:13
T get() const
Definition: EventSetup.h:71
float getESValueHigh() const
T const * product() const
Definition: ESHandle.h:86

Member Data Documentation

double PreshowerClusterProducer::aEta_[4]
private

Definition at line 70 of file PreshowerClusterProducer.h.

double PreshowerClusterProducer::alpha0_
private

Definition at line 66 of file PreshowerClusterProducer.h.

double PreshowerClusterProducer::alpha1_
private

Definition at line 67 of file PreshowerClusterProducer.h.

double PreshowerClusterProducer::alpha2_
private

Definition at line 68 of file PreshowerClusterProducer.h.

double PreshowerClusterProducer::alpha3_
private

Definition at line 69 of file PreshowerClusterProducer.h.

std::string PreshowerClusterProducer::assocSClusterCollection_
private

Definition at line 54 of file PreshowerClusterProducer.h.

double PreshowerClusterProducer::bEta_[4]
private

Definition at line 71 of file PreshowerClusterProducer.h.

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

Definition at line 43 of file PreshowerClusterProducer.h.

edm::ESHandle<ESChannelStatus> PreshowerClusterProducer::esChannelStatus_
private

Definition at line 60 of file PreshowerClusterProducer.h.

edm::ESHandle<ESEEIntercalibConstants> PreshowerClusterProducer::esEEInterCalib_
private

Definition at line 58 of file PreshowerClusterProducer.h.

edm::ESHandle<ESGain> PreshowerClusterProducer::esgain_
private

Definition at line 56 of file PreshowerClusterProducer.h.

edm::ESHandle<ESMIPToGeVConstant> PreshowerClusterProducer::esMIPToGeV_
private

Definition at line 57 of file PreshowerClusterProducer.h.

edm::ESHandle<ESMissingEnergyCalibration> PreshowerClusterProducer::esMissingECalib_
private

Definition at line 59 of file PreshowerClusterProducer.h.

double PreshowerClusterProducer::etThresh_
private

Definition at line 51 of file PreshowerClusterProducer.h.

double PreshowerClusterProducer::gamma0_
private

Definition at line 62 of file PreshowerClusterProducer.h.

double PreshowerClusterProducer::gamma1_
private

Definition at line 63 of file PreshowerClusterProducer.h.

double PreshowerClusterProducer::gamma2_
private

Definition at line 64 of file PreshowerClusterProducer.h.

double PreshowerClusterProducer::gamma3_
private

Definition at line 65 of file PreshowerClusterProducer.h.

double PreshowerClusterProducer::mip_
private

Definition at line 61 of file PreshowerClusterProducer.h.

int PreshowerClusterProducer::nEvt_
private

Definition at line 39 of file PreshowerClusterProducer.h.

PreshowerClusterAlgo* PreshowerClusterProducer::presh_algo
private

Definition at line 73 of file PreshowerClusterProducer.h.

float PreshowerClusterProducer::preshClustECut
private

Definition at line 50 of file PreshowerClusterProducer.h.

std::string PreshowerClusterProducer::preshClusterCollectionX_
private

Definition at line 46 of file PreshowerClusterProducer.h.

std::string PreshowerClusterProducer::preshClusterCollectionY_
private

Definition at line 47 of file PreshowerClusterProducer.h.

edm::EDGetTokenT<EcalRecHitCollection> PreshowerClusterProducer::preshHitsToken_
private

Definition at line 42 of file PreshowerClusterProducer.h.

int PreshowerClusterProducer::preshNclust_
private

Definition at line 49 of file PreshowerClusterProducer.h.