CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
EcalLaserDbService Class Reference

#include <EcalLaserDbService.h>

Public Member Functions

 EcalLaserDbService ()
 
 EcalLaserDbService (const edm::ParameterSet &)
 
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 Attributes

const EcalLaserAlphasmAlphas_
 
const EcalLaserAPDPNRatiosmAPDPNRatios_
 
const EcalLaserAPDPNRatiosRefmAPDPNRatiosRef_
 
const EcalLinearCorrectionsmLinearCorrections_
 

Detailed Description

Definition at line 25 of file EcalLaserDbService.h.

Constructor & Destructor Documentation

EcalLaserDbService::EcalLaserDbService ( )

Definition at line 16 of file EcalLaserDbService.cc.

17  :
18  mAlphas_ (0),
19  mAPDPNRatiosRef_ (0),
20  mAPDPNRatios_ (0),
22  {}
const EcalLinearCorrections * mLinearCorrections_
const EcalLaserAPDPNRatiosRef * mAPDPNRatiosRef_
const EcalLaserAPDPNRatios * mAPDPNRatios_
const EcalLaserAlphas * mAlphas_
EcalLaserDbService::EcalLaserDbService ( const edm::ParameterSet )

Member Function Documentation

const EcalLaserAlphas * EcalLaserDbService::getAlphas ( ) const

Definition at line 26 of file EcalLaserDbService.cc.

References mAlphas_.

26  {
27  return mAlphas_;
28 }
const EcalLaserAlphas * mAlphas_
const EcalLaserAPDPNRatios * EcalLaserDbService::getAPDPNRatios ( ) const

Definition at line 34 of file EcalLaserDbService.cc.

References mAPDPNRatios_.

34  {
35  return mAPDPNRatios_;
36 }
const EcalLaserAPDPNRatios * mAPDPNRatios_
const EcalLaserAPDPNRatiosRef * EcalLaserDbService::getAPDPNRatiosRef ( ) const

Definition at line 30 of file EcalLaserDbService.cc.

References mAPDPNRatiosRef_.

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

Definition at line 43 of file EcalLaserDbService.cc.

References alpha, DetId::det(), DetId::Ecal, EcalBarrel, EcalEndcap, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), EcalLaserAPDPNRatios::getLaserMap(), EcalCondObjectContainer< T >::getMap(), EcalTimeDependentCorrections::getTimeMap(), EcalLaserAPDPNRatios::getTimeMap(), EcalTimeDependentCorrections::getValueMap(), 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(), DetId::subdetId(), lumiQTWidget::t, EcalTimeDependentCorrections::Times::t1, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t1, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t2, EcalTimeDependentCorrections::Times::t2, EcalTimeDependentCorrections::Times::t3, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t3, cond::timestamp, and edm::Timestamp::value().

Referenced by EcalHitResponse::findLaserConstant().

43  {
44 
45  float correctionFactor = 1.0;
46 
49  const EcalLaserAPDPNRatiosRefMap& laserRefMap = mAPDPNRatiosRef_->getMap();
50  const EcalLaserAlphaMap& laserAlphaMap = mAlphas_->getMap();
53 
56  EcalLaserAPDPNref apdpnref;
60 
61  if (xid.det()==DetId::Ecal) {
62  // std::cout << " XID is in Ecal : ";
63  } else {
64  // std::cout << " XID is NOT in Ecal : ";
65  edm::LogError("EcalLaserDbService") << " DetId is NOT in ECAL" << endl;
66  return correctionFactor;
67  }
68 
69 // int hi = -1;
70 // if (xid.subdetId()==EcalBarrel) {
71 // // std::cout << "EcalBarrel" << std::endl;
72 // // std::cout << "--> rawId() = " << xid.rawId() << " id() = " << EBDetId( xid ).hashedIndex() << std::endl;
73 // hi = EBDetId( xid ).hashedIndex();
74 // } else if (xid.subdetId()==EcalEndcap) {
75 // // std::cout << "EcalEndcap" << std::endl;
76 // hi = EEDetId( xid ).hashedIndex() + EBDetId::MAX_HASH + 1;
77 //
78 // } else {
79 // // std::cout << "NOT EcalBarrel or EcalEndCap" << std::endl;
80 // edm::LogError("EcalLaserDbService") << " DetId is NOT in ECAL Barrel or Endcap" << endl;
81 // return correctionFactor;
82 // }
83 
84  int iLM;
85  if (xid.subdetId()==EcalBarrel) {
86  EBDetId ebid( xid.rawId() );
87  iLM = MEEBGeom::lmr(ebid.ieta(), ebid.iphi());
88  } else if (xid.subdetId()==EcalEndcap) {
89  EEDetId eeid( xid.rawId() );
90  // SuperCrystal coordinates
91  MEEEGeom::SuperCrysCoord iX = (eeid.ix()-1)/5 + 1;
92  MEEEGeom::SuperCrysCoord iY = (eeid.iy()-1)/5 + 1;
93  iLM = MEEEGeom::lmr(iX, iY, eeid.zside());
94  } else {
95  edm::LogError("EcalLaserDbService") << " DetId is NOT in ECAL Barrel or Endcap" << endl;
96  return correctionFactor;
97  }
98  // std::cout << " LM num ====> " << iLM << endl;
99 
100  // get alpha, apd/pn ref, apd/pn pairs and timestamps for interpolation
101 
103  if (itratio != laserRatiosMap.end()) {
104  apdpnpair = (*itratio);
105  } else {
106  edm::LogError("EcalLaserDbService") << "error with laserRatiosMap!" << endl;
107  return correctionFactor;
108  }
109 
110  if (iLM-1< (int)laserTimeMap.size()) {
111  timestamp = laserTimeMap[iLM-1];
112  } else {
113  edm::LogError("EcalLaserDbService") << "error with laserTimeMap!" << endl;
114  return correctionFactor;
115  }
116 
117  EcalLinearCorrections::EcalValueMap::const_iterator itlin = linearValueMap.find(xid);
118  if (itlin != linearValueMap.end()) {
119  linValues = (*itlin);
120  } else {
121  edm::LogError("EcalLaserDbService") << "error with linearValueMap!" << endl;
122  return correctionFactor;
123  }
124 
125  if (iLM-1< (int)linearTimeMap.size()) {
126  linTimes = linearTimeMap[iLM-1];
127  } else {
128  edm::LogError("EcalLaserDbService") << "error with laserTimeMap!" << endl;
129  return correctionFactor;
130  }
131 
132  EcalLaserAPDPNRatiosRefMap::const_iterator itref = laserRefMap.find(xid);
133  if ( itref != laserRefMap.end() ) {
134  apdpnref = (*itref);
135  } else {
136  edm::LogError("EcalLaserDbService") << "error with laserRefMap!" << endl;
137  return correctionFactor;
138  }
139 
140  EcalLaserAlphaMap::const_iterator italpha = laserAlphaMap.find(xid);
141  if ( italpha != laserAlphaMap.end() ) {
142  alpha = (*italpha);
143  } else {
144  edm::LogError("EcalLaserDbService") << "error with laserAlphaMap!" << endl;
145  return correctionFactor;
146  }
147 
148  // std::cout << " APDPN pair " << apdpnpair.p1 << " , " << apdpnpair.p2 << std::endl;
149  // std::cout << " TIME pair " << timestamp.t1.value() << " , " << timestamp.t2.value() << " iLM " << iLM << std::endl;
150  // std::cout << " LM module " << iLM << std::endl;
151  // std::cout << " APDPN ref " << apdpnref << std::endl;
152  // std::cout << " ALPHA " << alpha << std::endl;
153 
154  // should implement some default in case of error...
155 
156  // should do some quality checks first
157  // ...
158 
159  // we will need to treat time differently...
160  // is time in DB same format as in MC? probably not...
161 
162  // interpolation
163 
164  edm::TimeValue_t t = iTime.value();
165  edm::TimeValue_t t_i = 0, t_f = 0;
166  float p_i = 0, p_f = 0;
167  edm::TimeValue_t lt_i = 0, lt_f = 0;
168  float lp_i = 0, lp_f = 0;
169 
170  if ( t >= timestamp.t1.value() && t < timestamp.t2.value() ) {
171  t_i = timestamp.t1.value();
172  t_f = timestamp.t2.value();
173  p_i = apdpnpair.p1;
174  p_f = apdpnpair.p2;
175  } else if ( t >= timestamp.t2.value() && t <= timestamp.t3.value() ) {
176  t_i = timestamp.t2.value();
177  t_f = timestamp.t3.value();
178  p_i = apdpnpair.p2;
179  p_f = apdpnpair.p3;
180  } else if ( t < timestamp.t1.value() ) {
181  t_i = timestamp.t1.value();
182  t_f = timestamp.t2.value();
183  p_i = apdpnpair.p1;
184  p_f = apdpnpair.p2;
185  //edm::LogWarning("EcalLaserDbService") << "The event timestamp t=" << t
186  // << " is lower than t1=" << t_i << ". Extrapolating...";
187  } else if ( t > timestamp.t3.value() ) {
188  t_i = timestamp.t2.value();
189  t_f = timestamp.t3.value();
190  p_i = apdpnpair.p2;
191  p_f = apdpnpair.p3;
192  //edm::LogWarning("EcalLaserDbService") << "The event timestamp t=" << t
193  // << " is greater than t3=" << t_f << ". Extrapolating...";
194  }
195 
196  if ( t >= linTimes.t1.value() && t < linTimes.t2.value() ) {
197  lt_i = linTimes.t1.value();
198  lt_f = linTimes.t2.value();
199  lp_i = linValues.p1;
200  lp_f = linValues.p2;
201  } else if ( t >= linTimes.t2.value() && t <= linTimes.t3.value() ) {
202  lt_i = linTimes.t2.value();
203  lt_f = linTimes.t3.value();
204  lp_i = linValues.p2;
205  lp_f = linValues.p3;
206  } else if ( t < linTimes.t1.value() ) {
207  lt_i = linTimes.t1.value();
208  lt_f = linTimes.t2.value();
209  lp_i = linValues.p1;
210  lp_f = linValues.p2;
211  //edm::LogWarning("EcalLaserDbService") << "The event timestamp t=" << t
212  // << " is lower than t1=" << t_i << ". Extrapolating...";
213  } else if ( t > linTimes.t3.value() ) {
214  lt_i = linTimes.t2.value();
215  lt_f = linTimes.t3.value();
216  lp_i = linValues.p2;
217  lp_f = linValues.p3;
218  //edm::LogWarning("EcalLaserDbService") << "The event timestamp t=" << t
219  // << " is greater than t3=" << t_f << ". Extrapolating...";
220  }
221 
222  if ( apdpnref != 0 && (t_i - t_f) != 0 && (lt_i - lt_f) != 0) {
223  float interpolatedLaserResponse = p_i/apdpnref + (t-t_i)*(p_f-p_i)/apdpnref/(t_f-t_i);
224  float interpolatedLinearResponse = lp_i/apdpnref + (t-lt_i)*(lp_f-lp_i)/apdpnref/(lt_f-lt_i); // FIXED BY FC
225 
226  if(interpolatedLinearResponse >2 || interpolatedLinearResponse <0.1) interpolatedLinearResponse=1;
227  if ( interpolatedLaserResponse <= 0 ) {
228  edm::LogWarning("EcalLaserDbService") << "The interpolated laser correction is <= zero! ("
229  << interpolatedLaserResponse << "). Using 1. as correction factor.";
230  return correctionFactor;
231  } else {
232 
233  float interpolatedTransparencyResponse = interpolatedLaserResponse / interpolatedLinearResponse;
234 
235  correctionFactor = 1/( pow(interpolatedTransparencyResponse,alpha) *interpolatedLinearResponse );
236 
237  }
238 
239  } else {
240  edm::LogError("EcalLaserDbService")
241  << "apdpnref (" << apdpnref << ") "
242  << "or t_i-t_f (" << (t_i - t_f) << " is zero!";
243  return correctionFactor;
244  }
245 
246  return correctionFactor;
247 }
const EcalTimeMap & getTimeMap() const
float EcalLaserAlpha
float alpha
Definition: AMPTWrapper.h:95
const self & getMap() const
static int lmr(EBGlobalCoord ieta, EBGlobalCoord iphi)
Definition: MEEBGeom.cc:121
float EcalLaserAPDPNref
const EcalLinearCorrections * mLinearCorrections_
const EcalLaserAPDPNRatiosMap & getLaserMap() const
const EcalLaserAPDPNRatiosRef * mAPDPNRatiosRef_
const EcalValueMap & getValueMap() const
unsigned long long TimeValue_t
Definition: Timestamp.h:27
int SuperCrysCoord
Definition: MEEEGeom.h:22
TimeValue_t value() const
Definition: Timestamp.cc:72
const EcalLaserTimeStampMap & getTimeMap() const
std::vector< EcalLaserTimeStamp > EcalLaserTimeStampMap
const EcalLaserAPDPNRatios * mAPDPNRatios_
std::vector< Item >::const_iterator const_iterator
const EcalLaserAlphas * mAlphas_
const_iterator find(uint32_t rawId) const
const_iterator end() const
static int lmr(SuperCrysCoord iX, SuperCrysCoord iY, int iz)
Definition: MEEEGeom.cc:250
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
const EcalLinearCorrections * EcalLaserDbService::getLinearCorrections ( ) const

Definition at line 38 of file EcalLaserDbService.cc.

References mLinearCorrections_.

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

Definition at line 36 of file EcalLaserDbService.h.

References mAlphas_.

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

Definition at line 38 of file EcalLaserDbService.h.

References mAPDPNRatios_.

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

Definition at line 37 of file EcalLaserDbService.h.

References mAPDPNRatiosRef_.

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

Definition at line 39 of file EcalLaserDbService.h.

References mLinearCorrections_.

39 {mLinearCorrections_ = fItem;}
const EcalLinearCorrections * mLinearCorrections_

Member Data Documentation

const EcalLaserAlphas* EcalLaserDbService::mAlphas_
private

Definition at line 43 of file EcalLaserDbService.h.

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

const EcalLaserAPDPNRatios* EcalLaserDbService::mAPDPNRatios_
private

Definition at line 45 of file EcalLaserDbService.h.

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

const EcalLaserAPDPNRatiosRef* EcalLaserDbService::mAPDPNRatiosRef_
private

Definition at line 44 of file EcalLaserDbService.h.

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

const EcalLinearCorrections* EcalLaserDbService::mLinearCorrections_
private