CMS 3D CMS Logo

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

#include <EcalLaserDbService.h>

Public Member Functions

 EcalLaserDbService ()
 
const EcalLaserAlphasgetAlphas () const
 
const EcalLaserAPDPNRatiosgetAPDPNRatios () const
 
const EcalLaserAPDPNRatiosRefgetAPDPNRatiosRef () const
 
float getLaserCorrection (DetId const &xid, edm::Timestamp const &iTime) const
 
const EcalLinearCorrectionsgetLinearCorrections () const
 
void setAlphaData (const EcalLaserAlphas *fItem)
 
void setAPDPNData (const EcalLaserAPDPNRatios *fItem)
 
void setAPDPNRefData (const EcalLaserAPDPNRatiosRef *fItem)
 
void setLinearCorrectionsData (const EcalLinearCorrections *fItem)
 

Private Types

typedef tbb::concurrent_unordered_set< uint32_t > ErrorMapT
 

Private Attributes

ErrorMapT channelsWithInvalidCorrection_
 
const EcalLaserAlphasmAlphas_
 
const EcalLaserAPDPNRatiosmAPDPNRatios_
 
const EcalLaserAPDPNRatiosRefmAPDPNRatiosRef_
 
const EcalLinearCorrectionsmLinearCorrections_
 

Detailed Description

Definition at line 24 of file EcalLaserDbService.h.

Member Typedef Documentation

typedef tbb::concurrent_unordered_set<uint32_t> EcalLaserDbService::ErrorMapT
private

Definition at line 45 of file EcalLaserDbService.h.

Constructor & Destructor Documentation

EcalLaserDbService::EcalLaserDbService ( )

Definition at line 15 of file EcalLaserDbService.cc.

16  : mAlphas_(nullptr), mAPDPNRatiosRef_(nullptr), mAPDPNRatios_(nullptr), mLinearCorrections_(nullptr) {}
const EcalLinearCorrections * mLinearCorrections_
const EcalLaserAPDPNRatiosRef * mAPDPNRatiosRef_
const EcalLaserAPDPNRatios * mAPDPNRatios_
const EcalLaserAlphas * mAlphas_

Member Function Documentation

const EcalLaserAlphas * EcalLaserDbService::getAlphas ( ) const

Definition at line 18 of file EcalLaserDbService.cc.

References mAlphas_.

18 { return mAlphas_; }
const EcalLaserAlphas * mAlphas_
const EcalLaserAPDPNRatios * EcalLaserDbService::getAPDPNRatios ( ) const

Definition at line 22 of file EcalLaserDbService.cc.

References mAPDPNRatios_.

22 { return mAPDPNRatios_; }
const EcalLaserAPDPNRatios * mAPDPNRatios_
const EcalLaserAPDPNRatiosRef * EcalLaserDbService::getAPDPNRatiosRef ( ) const

Definition at line 20 of file EcalLaserDbService.cc.

References mAPDPNRatiosRef_.

20 { return mAPDPNRatiosRef_; }
const EcalLaserAPDPNRatiosRef * mAPDPNRatiosRef_
float EcalLaserDbService::getLaserCorrection ( DetId const &  xid,
edm::Timestamp const &  iTime 
) const

Definition at line 26 of file EcalLaserDbService.cc.

References zMuMuMuonUserData::alpha, channelsWithInvalidCorrection_, DetId::det(), DetId::Ecal, EcalBarrel, EcalEndcap, EcalCondObjectContainer< T >::end(), f, EcalCondObjectContainer< T >::find(), dqmMemoryStats::float, EcalLaserAPDPNRatios::getLaserMap(), EcalCondObjectContainer< T >::getMap(), EcalTimeDependentCorrections::getTimeMap(), EcalLaserAPDPNRatios::getTimeMap(), EcalTimeDependentCorrections::getValueMap(), EBDetId::hashedIndex(), EEDetId::hashedIndex(), PixelPluginsPhase0_cfi::isBarrel, MEEBGeom::lmr(), MEEEGeom::lmr(), mAlphas_, mAPDPNRatios_, mAPDPNRatiosRef_, mLinearCorrections_, EcalTimeDependentCorrections::Values::p1, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p1, EcalTimeDependentCorrections::Values::p2, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p2, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p3, EcalTimeDependentCorrections::Values::p3, funct::pow(), DetId::rawId(), edm::second(), DetId::subdetId(), OrderedSet::t, EcalTimeDependentCorrections::Times::t1, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t1, EcalTimeDependentCorrections::Times::t2, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t2, EcalTimeDependentCorrections::Times::t3, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t3, cond::timestamp, groupFilesInBlocks::tt, and edm::Timestamp::value().

Referenced by EcalPFRecHitThresholdsMaker::analyze(), EcalClusterLazyToolsBase::BasicClusterTime(), EcalLaserCorrFilter::filter(), EcalMIPRecHitFilter::filter(), EcalHitResponse::findLaserConstant(), EcalRecalibRecHitProducer::produce(), and EcalRecHitWorkerSimple::run().

26  {
27  float correctionFactor = 1.0;
28 
31  const EcalLaserAPDPNRatiosRefMap& laserRefMap = mAPDPNRatiosRef_->getMap();
32  const EcalLaserAlphaMap& laserAlphaMap = mAlphas_->getMap();
35 
38  EcalLaserAPDPNref apdpnref;
42 
43  if (xid.det() == DetId::Ecal) {
44  } else {
45  edm::LogError("EcalLaserDbService") << " DetId is NOT in ECAL" << endl;
46  return correctionFactor;
47  }
48 
49  int iLM;
50  int xind;
51  bool isBarrel = true;
52  if (xid.subdetId() == EcalBarrel) {
53  EBDetId ebid(xid.rawId());
54  xind = ebid.hashedIndex();
55  iLM = MEEBGeom::lmr(ebid.ieta(), ebid.iphi());
56  } else if (xid.subdetId() == EcalEndcap) {
57  isBarrel = false;
58  EEDetId eeid(xid.rawId());
59  xind = eeid.hashedIndex();
60  // SuperCrystal coordinates
61  MEEEGeom::SuperCrysCoord iX = (eeid.ix() - 1) / 5 + 1;
62  MEEEGeom::SuperCrysCoord iY = (eeid.iy() - 1) / 5 + 1;
63  iLM = MEEEGeom::lmr(iX, iY, eeid.zside());
64  } else {
65  edm::LogError("EcalLaserDbService") << " DetId is NOT in ECAL Barrel or Endcap" << endl;
66  return correctionFactor;
67  }
68  // std::cout << " LM num ====> " << iLM << endl;
69 
70  // get alpha, apd/pn ref, apd/pn pairs and timestamps for interpolation
71 
72 #ifdef VERIFY_LASER
74  if (itratio != laserRatiosMap.end()) {
75  apdpnpair = (*itratio);
76  } else {
77  edm::LogError("EcalLaserDbService") << "error with laserRatiosMap!" << endl;
78  return correctionFactor;
79  }
80 
81  if (iLM - 1 < (int)laserTimeMap.size()) {
82  timestamp = laserTimeMap[iLM - 1];
83  } else {
84  edm::LogError("EcalLaserDbService") << "error with laserTimeMap!" << endl;
85  return correctionFactor;
86  }
87 
89  if (itlin != linearValueMap.end()) {
90  linValues = (*itlin);
91  } else {
92  edm::LogError("EcalLaserDbService") << "error with linearValueMap!" << endl;
93  return correctionFactor;
94  }
95 
96  if (iLM - 1 < (int)linearTimeMap.size()) {
97  linTimes = linearTimeMap[iLM - 1];
98  } else {
99  edm::LogError("EcalLaserDbService") << "error with laserTimeMap!" << endl;
100  return correctionFactor;
101  }
102 
103  EcalLaserAPDPNRatiosRefMap::const_iterator itref = laserRefMap.find(xid);
104  if (itref != laserRefMap.end()) {
105  apdpnref = (*itref);
106  } else {
107  edm::LogError("EcalLaserDbService") << "error with laserRefMap!" << endl;
108  return correctionFactor;
109  }
110 
111  EcalLaserAlphaMap::const_iterator italpha = laserAlphaMap.find(xid);
112  if (italpha != laserAlphaMap.end()) {
113  alpha = (*italpha);
114  } else {
115  edm::LogError("EcalLaserDbService") << "error with laserAlphaMap!" << endl;
116  return correctionFactor;
117  }
118 
119 #else
120 
121  // waiting for templated lambdas
122  auto getCond = [=](EcalFloatCondObjectContainer const& cond) -> float {
123  return isBarrel ? cond.barrel(xind) : cond.endcap(xind);
124  };
125 
126  auto getPair =
128  return isBarrel ? cond.barrel(xind) : cond.endcap(xind);
129  };
130 
132  return isBarrel ? cond.barrel(xind) : cond.endcap(xind);
133  };
134 
135  apdpnpair = getPair(laserRatiosMap);
136  linValues = getLinear(linearValueMap);
137  apdpnref = getCond(laserRefMap);
138  alpha = getCond(laserAlphaMap);
139 
140  if (iLM - 1 < (int)laserTimeMap.size()) {
141  timestamp = laserTimeMap[iLM - 1];
142  } else {
143  edm::LogError("EcalLaserDbService") << "error with laserTimeMap!" << endl;
144  return correctionFactor;
145  }
146 
147  if (iLM - 1 < (int)linearTimeMap.size()) {
148  linTimes = linearTimeMap[iLM - 1];
149  } else {
150  edm::LogError("EcalLaserDbService") << "error with laserTimeMap!" << endl;
151  return correctionFactor;
152  }
153 
154 #endif
155 
156  // should implement some default in case of error...
157 
158  // should do some quality checks first
159  // ...
160 
161  // we will need to treat time differently...
162  // is time in DB same format as in MC? probably not...
163 
164  // interpolation
165 
166  edm::TimeValue_t t = iTime.value();
167  long long t_i = 0, t_f = 0;
168  float p_i = 0, p_f = 0;
169  long long lt_i = 0, lt_f = 0;
170  float lp_i = 0, lp_f = 0;
171 
172  if (t >= timestamp.t1.value() && t < timestamp.t2.value()) {
173  t_i = timestamp.t1.value();
174  t_f = timestamp.t2.value();
175  p_i = apdpnpair.p1;
176  p_f = apdpnpair.p2;
177  } else if (t >= timestamp.t2.value() && t <= timestamp.t3.value()) {
178  t_i = timestamp.t2.value();
179  t_f = timestamp.t3.value();
180  p_i = apdpnpair.p2;
181  p_f = apdpnpair.p3;
182  } else if (t < timestamp.t1.value()) {
183  t_i = timestamp.t1.value();
184  t_f = timestamp.t2.value();
185  p_i = apdpnpair.p1;
186  p_f = apdpnpair.p2;
187 
188  } else if (t > timestamp.t3.value()) {
189  t_i = timestamp.t2.value();
190  t_f = timestamp.t3.value();
191  p_i = apdpnpair.p2;
192  p_f = apdpnpair.p3;
193  }
194 
195  if (t >= linTimes.t1.value() && t < linTimes.t2.value()) {
196  lt_i = linTimes.t1.value();
197  lt_f = linTimes.t2.value();
198  lp_i = linValues.p1;
199  lp_f = linValues.p2;
200  } else if (t >= linTimes.t2.value() && t <= linTimes.t3.value()) {
201  lt_i = linTimes.t2.value();
202  lt_f = linTimes.t3.value();
203  lp_i = linValues.p2;
204  lp_f = linValues.p3;
205  } else if (t < linTimes.t1.value()) {
206  lt_i = linTimes.t1.value();
207  lt_f = linTimes.t2.value();
208  lp_i = linValues.p1;
209  lp_f = linValues.p2;
210 
211  } else if (t > linTimes.t3.value()) {
212  lt_i = linTimes.t2.value();
213  lt_f = linTimes.t3.value();
214  lp_i = linValues.p2;
215  lp_f = linValues.p3;
216  }
217 
218  if (apdpnref != 0 && (t_i - t_f) != 0 && (lt_i - lt_f) != 0) {
219  long long tt = t; // never subtract two unsigned!
220  float interpolatedLaserResponse = p_i / apdpnref + float(tt - t_i) * (p_f - p_i) / (apdpnref * float(t_f - t_i));
221  float interpolatedLinearResponse =
222  lp_i / apdpnref + float(tt - lt_i) * (lp_f - lp_i) / (apdpnref * float(lt_f - lt_i)); // FIXED BY FC
223 
224  if (interpolatedLinearResponse > 2.f || interpolatedLinearResponse < 0.1f)
225  interpolatedLinearResponse = 1.f;
226  if (interpolatedLaserResponse <= 0.) {
227  // print message only if it is the first time we see < 0
228  // on this detid
229  if (channelsWithInvalidCorrection_.insert(xid.rawId()).second) {
230  edm::LogError("EcalLaserDbService") << "Interpolated Laser correction <0 for detid " << xid.rawId();
231  }
232 
233  return correctionFactor;
234 
235  } else {
236  float interpolatedTransparencyResponse = interpolatedLaserResponse / interpolatedLinearResponse;
237 
238  correctionFactor = 1.f / (std::pow(interpolatedTransparencyResponse, alpha) * interpolatedLinearResponse);
239  }
240 
241  } else {
242  edm::LogError("EcalLaserDbService") << "apdpnref (" << apdpnref << ") "
243  << "or t_i-t_f (" << (t_i - t_f) << " is zero!";
244  return correctionFactor;
245  }
246 
247  return correctionFactor;
248 }
const EcalTimeMap & getTimeMap() const
float EcalLaserAlpha
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:82
const self & getMap() const
ErrorMapT channelsWithInvalidCorrection_
static int lmr(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:110
float EcalLaserAPDPNref
U second(std::pair< T, U > const &p)
const EcalLinearCorrections * mLinearCorrections_
const EcalLaserAPDPNRatiosMap & getLaserMap() const
const EcalLaserAPDPNRatiosRef * mAPDPNRatiosRef_
const EcalValueMap & getValueMap() const
double f[11][100]
unsigned long long TimeValue_t
Definition: Timestamp.h:28
int SuperCrysCoord
Definition: MEEEGeom.h:20
int hashedIndex() const
Definition: EEDetId.h:183
const EcalLaserTimeStampMap & getTimeMap() const
std::vector< EcalLaserTimeStamp > EcalLaserTimeStampMap
const EcalLaserAPDPNRatios * mAPDPNRatios_
std::vector< Item >::const_iterator const_iterator
const EcalLaserAlphas * mAlphas_
Definition: plugin.cc:23
const_iterator find(uint32_t rawId) const
const_iterator end() const
alpha
zGenParticlesMatch = cms.InputTag(""),
TimeValue_t value() const
Definition: Timestamp.h:45
static int lmr(SuperCrysCoord iX, SuperCrysCoord iY, int iz)
Definition: MEEEGeom.cc:254
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
const EcalLinearCorrections * EcalLaserDbService::getLinearCorrections ( ) const

Definition at line 24 of file EcalLaserDbService.cc.

References mLinearCorrections_.

24 { return mLinearCorrections_; }
const EcalLinearCorrections * mLinearCorrections_
void EcalLaserDbService::setAlphaData ( const EcalLaserAlphas fItem)
inline

Definition at line 34 of file EcalLaserDbService.h.

References mAlphas_.

34 { mAlphas_ = fItem; }
const EcalLaserAlphas * mAlphas_
void EcalLaserDbService::setAPDPNData ( const EcalLaserAPDPNRatios fItem)
inline

Definition at line 36 of file EcalLaserDbService.h.

References mAPDPNRatios_.

36 { mAPDPNRatios_ = fItem; }
const EcalLaserAPDPNRatios * mAPDPNRatios_
void EcalLaserDbService::setAPDPNRefData ( const EcalLaserAPDPNRatiosRef fItem)
inline

Definition at line 35 of file EcalLaserDbService.h.

References mAPDPNRatiosRef_.

35 { mAPDPNRatiosRef_ = fItem; }
const EcalLaserAPDPNRatiosRef * mAPDPNRatiosRef_
void EcalLaserDbService::setLinearCorrectionsData ( const EcalLinearCorrections fItem)
inline

Definition at line 37 of file EcalLaserDbService.h.

References mLinearCorrections_.

37 { mLinearCorrections_ = fItem; }
const EcalLinearCorrections * mLinearCorrections_

Member Data Documentation

ErrorMapT EcalLaserDbService::channelsWithInvalidCorrection_
mutableprivate

Definition at line 46 of file EcalLaserDbService.h.

Referenced by getLaserCorrection().

const EcalLaserAlphas* EcalLaserDbService::mAlphas_
private

Definition at line 40 of file EcalLaserDbService.h.

Referenced by getAlphas(), getLaserCorrection(), and setAlphaData().

const EcalLaserAPDPNRatios* EcalLaserDbService::mAPDPNRatios_
private

Definition at line 42 of file EcalLaserDbService.h.

Referenced by getAPDPNRatios(), getLaserCorrection(), and setAPDPNData().

const EcalLaserAPDPNRatiosRef* EcalLaserDbService::mAPDPNRatiosRef_
private

Definition at line 41 of file EcalLaserDbService.h.

Referenced by getAPDPNRatiosRef(), getLaserCorrection(), and setAPDPNRefData().

const EcalLinearCorrections* EcalLaserDbService::mLinearCorrections_
private