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
 
void setAlphaData (const EcalLaserAlphas *fItem)
 
void setAPDPNData (const EcalLaserAPDPNRatios *fItem)
 
void setAPDPNRefData (const EcalLaserAPDPNRatiosRef *fItem)
 

Private Attributes

const EcalLaserAlphasmAlphas_
 
const EcalLaserAPDPNRatiosmAPDPNRatios_
 
const EcalLaserAPDPNRatiosRefmAPDPNRatiosRef_
 

Detailed Description

Definition at line 24 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)
21  {}
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 25 of file EcalLaserDbService.cc.

References mAlphas_.

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

Definition at line 33 of file EcalLaserDbService.cc.

References mAPDPNRatios_.

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

Definition at line 29 of file EcalLaserDbService.cc.

References mAPDPNRatiosRef_.

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

Definition at line 38 of file EcalLaserDbService.cc.

References alpha, DetId::det(), DetId::Ecal, EcalBarrel, EcalEndcap, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), EcalLaserAPDPNRatios::getLaserMap(), EcalCondObjectContainer< T >::getMap(), EcalLaserAPDPNRatios::getTimeMap(), MEEBGeom::lmr(), MEEEGeom::lmr(), mAlphas_, mAPDPNRatios_, mAPDPNRatiosRef_, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p1, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p2, EcalLaserAPDPNRatios::EcalLaserAPDPNpair::p3, funct::pow(), DetId::rawId(), DetId::subdetId(), lumiQTWidget::t, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t1, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t2, EcalLaserAPDPNRatios::EcalLaserTimeStamp::t3, cond::timestamp, and edm::Timestamp::value().

Referenced by EcalHitResponse::findLaserConstant().

38  {
39 
40  float correctionFactor = 1.0;
41 
44  const EcalLaserAPDPNRatiosRefMap& laserRefMap = mAPDPNRatiosRef_->getMap();
45  const EcalLaserAlphaMap& laserAlphaMap = mAlphas_->getMap();
46 
49  EcalLaserAPDPNref apdpnref;
51 
52  if (xid.det()==DetId::Ecal) {
53  // std::cout << " XID is in Ecal : ";
54  } else {
55  // std::cout << " XID is NOT in Ecal : ";
56  edm::LogError("EcalLaserDbService") << " DetId is NOT in ECAL" << endl;
57  return correctionFactor;
58  }
59 
60 // int hi = -1;
61 // if (xid.subdetId()==EcalBarrel) {
62 // // std::cout << "EcalBarrel" << std::endl;
63 // // std::cout << "--> rawId() = " << xid.rawId() << " id() = " << EBDetId( xid ).hashedIndex() << std::endl;
64 // hi = EBDetId( xid ).hashedIndex();
65 // } else if (xid.subdetId()==EcalEndcap) {
66 // // std::cout << "EcalEndcap" << std::endl;
67 // hi = EEDetId( xid ).hashedIndex() + EBDetId::MAX_HASH + 1;
68 //
69 // } else {
70 // // std::cout << "NOT EcalBarrel or EcalEndCap" << std::endl;
71 // edm::LogError("EcalLaserDbService") << " DetId is NOT in ECAL Barrel or Endcap" << endl;
72 // return correctionFactor;
73 // }
74 
75  int iLM;
76  if (xid.subdetId()==EcalBarrel) {
77  EBDetId ebid( xid.rawId() );
78  iLM = MEEBGeom::lmr(ebid.ieta(), ebid.iphi());
79  } else if (xid.subdetId()==EcalEndcap) {
80  EEDetId eeid( xid.rawId() );
81  // SuperCrystal coordinates
82  MEEEGeom::SuperCrysCoord iX = (eeid.ix()-1)/5 + 1;
83  MEEEGeom::SuperCrysCoord iY = (eeid.iy()-1)/5 + 1;
84  iLM = MEEEGeom::lmr(iX, iY, eeid.zside());
85  } else {
86  edm::LogError("EcalLaserDbService") << " DetId is NOT in ECAL Barrel or Endcap" << endl;
87  return correctionFactor;
88  }
89  // std::cout << " LM num ====> " << iLM << endl;
90 
91  // get alpha, apd/pn ref, apd/pn pairs and timestamps for interpolation
92 
94  if (itratio != laserRatiosMap.end()) {
95  apdpnpair = (*itratio);
96  } else {
97  edm::LogError("EcalLaserDbService") << "error with laserRatiosMap!" << endl;
98  return correctionFactor;
99  }
100 
101  if (iLM-1< (int)laserTimeMap.size()) {
102  timestamp = laserTimeMap[iLM-1];
103  } else {
104  edm::LogError("EcalLaserDbService") << "error with laserTimeMap!" << endl;
105  return correctionFactor;
106  }
107 
108  EcalLaserAPDPNRatiosRefMap::const_iterator itref = laserRefMap.find(xid);
109  if ( itref != laserRefMap.end() ) {
110  apdpnref = (*itref);
111  } else {
112  edm::LogError("EcalLaserDbService") << "error with laserRefMap!" << endl;
113  return correctionFactor;
114  }
115 
116  EcalLaserAlphaMap::const_iterator italpha = laserAlphaMap.find(xid);
117  if ( italpha != laserAlphaMap.end() ) {
118  alpha = (*italpha);
119  } else {
120  edm::LogError("EcalLaserDbService") << "error with laserAlphaMap!" << endl;
121  return correctionFactor;
122  }
123 
124  // std::cout << " APDPN pair " << apdpnpair.p1 << " , " << apdpnpair.p2 << std::endl;
125  // std::cout << " TIME pair " << timestamp.t1.value() << " , " << timestamp.t2.value() << " iLM " << iLM << std::endl;
126  // std::cout << " LM module " << iLM << std::endl;
127  // std::cout << " APDPN ref " << apdpnref << std::endl;
128  // std::cout << " ALPHA " << alpha << std::endl;
129 
130  // should implement some default in case of error...
131 
132  // should do some quality checks first
133  // ...
134 
135  // we will need to treat time differently...
136  // is time in DB same format as in MC? probably not...
137 
138  // interpolation
139 
140  edm::TimeValue_t t = iTime.value();
141  edm::TimeValue_t t_i = 0, t_f = 0;
142  float p_i = 0, p_f = 0;
143 
144  if ( t >= timestamp.t1.value() && t < timestamp.t2.value() ) {
145  t_i = timestamp.t1.value();
146  t_f = timestamp.t2.value();
147  p_i = apdpnpair.p1;
148  p_f = apdpnpair.p2;
149  } else if ( t >= timestamp.t2.value() && t <= timestamp.t3.value() ) {
150  t_i = timestamp.t2.value();
151  t_f = timestamp.t3.value();
152  p_i = apdpnpair.p2;
153  p_f = apdpnpair.p3;
154  } else if ( t < timestamp.t1.value() ) {
155  t_i = timestamp.t1.value();
156  t_f = timestamp.t2.value();
157  p_i = apdpnpair.p1;
158  p_f = apdpnpair.p2;
159  //edm::LogWarning("EcalLaserDbService") << "The event timestamp t=" << t
160  // << " is lower than t1=" << t_i << ". Extrapolating...";
161  } else if ( t > timestamp.t3.value() ) {
162  t_i = timestamp.t2.value();
163  t_f = timestamp.t3.value();
164  p_i = apdpnpair.p2;
165  p_f = apdpnpair.p3;
166  //edm::LogWarning("EcalLaserDbService") << "The event timestamp t=" << t
167  // << " is greater than t3=" << t_f << ". Extrapolating...";
168  }
169 
170  if ( apdpnref != 0 && (t_i - t_f) != 0) {
171  float interpolatedLaserResponse = p_i/apdpnref + (t-t_i)*(p_f-p_i)/apdpnref/(t_f-t_i);
172  if ( interpolatedLaserResponse <= 0 ) {
173  edm::LogError("EcalLaserDbService") << "The interpolated laser correction is <= zero! ("
174  << interpolatedLaserResponse << "). Using 1. as correction factor.";
175  return correctionFactor;
176  } else {
177  correctionFactor = 1/pow(interpolatedLaserResponse,alpha);
178  }
179 
180  } else {
181  edm::LogError("EcalLaserDbService")
182  << "apdpnref (" << apdpnref << ") "
183  << "or t_i-t_f (" << (t_i - t_f) << " is zero!";
184  return correctionFactor;
185  }
186 
187  return correctionFactor;
188 }
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 EcalLaserAPDPNRatiosMap & getLaserMap() const
const EcalLaserAPDPNRatiosRef * mAPDPNRatiosRef_
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:251
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
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_

Member Data Documentation

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().