CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Static Private Attributes
EcalRingCalibrationTools Class Reference

#include <EcalRingCalibrationTools.h>

Public Member Functions

 EcalRingCalibrationTools ()
 
 ~EcalRingCalibrationTools ()
 

Static Public Member Functions

static std::vector< DetIdgetDetIdsInECAL ()
 
static std::vector< DetIdgetDetIdsInModule (short int)
 
static std::vector< DetIdgetDetIdsInRing (short aRingIndex)
 Retrieve the DetIds in a phi-ring. More...
 
static short getModuleIndex (DetId aDetId)
 
static short getRingIndex (DetId aDetId)
 Retrieve the phi-ring index corresponding to a DetId. More...
 
static void setCaloGeometry (const CaloGeometry *geometry)
 

Static Public Attributes

static const short N_MODULES_BARREL = 144
 
static const short N_RING_BARREL = 170
 
static const short N_RING_ENDCAP = 78
 
static const short N_RING_TOTAL = 248
 

Static Private Member Functions

static void initializeFromGeometry (CaloGeometry const *geometry)
 

Static Private Attributes

static short endcapRingIndex_ [EEDetId::IX_MAX][EEDetId::IY_MAX]
 
static std::atomic< bool > isInitializedFromGeometry_
 
static std::once_flag once_
 

Detailed Description

Definition at line 22 of file EcalRingCalibrationTools.h.

Constructor & Destructor Documentation

EcalRingCalibrationTools::EcalRingCalibrationTools ( )
inline

Definition at line 25 of file EcalRingCalibrationTools.h.

25 {};
EcalRingCalibrationTools::~EcalRingCalibrationTools ( )
inline

Member Function Documentation

std::vector< DetId > EcalRingCalibrationTools::getDetIdsInECAL ( )
static

Definition at line 112 of file EcalRingCalibrationTools.cc.

References isInitializedFromGeometry_, EEDetId::IX_MAX, EEDetId::IY_MAX, EBDetId::MAX_IETA, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, EBDetId::validDetId(), EEDetId::validDetId(), and HcalDigiParam_cfi::zside.

Referenced by ZeeCalibration::duringLoop(), ZeeCalibration::endOfLoop(), and ~EcalRingCalibrationTools().

113 {
114  std::vector<DetId> ringIds;
115 
116  for(int ieta= - EBDetId::MAX_IETA; ieta<=EBDetId::MAX_IETA; ++ieta)
117  for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi)
118  if (EBDetId::validDetId(ieta,iphi))
119  ringIds.push_back(EBDetId(ieta,iphi));
120 
121  //needed only for the EE, it can be replaced at some point maybe with something smarter
123  throw std::logic_error("EcalRingCalibrationTools::initializeFromGeometry Ecal Endcap geometry is not initialized");
124 
125  for (int ix=0;ix<EEDetId::IX_MAX;++ix)
126  for (int iy=0;iy<EEDetId::IY_MAX;++iy)
127  for(int zside = -1; zside<2; zside += 2)
128  if ( EEDetId::validDetId(ix+1,iy+1,zside) )
129  ringIds.push_back( EEDetId(ix+1,iy+1,zside) );
130 
131 
132  // std::cout<<" [EcalRingCalibrationTools::getDetIdsInECAL()] DetId.size() is "<<ringIds.size()<<std::endl;
133 
134  return ringIds;
135 }
static const int MIN_IPHI
Definition: EBDetId.h:142
static std::atomic< bool > isInitializedFromGeometry_
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:124
static const int IX_MAX
Definition: EEDetId.h:302
static const int MAX_IPHI
Definition: EBDetId.h:144
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int MAX_IETA
Definition: EBDetId.h:143
static const int IY_MAX
Definition: EEDetId.h:306
std::vector< DetId > EcalRingCalibrationTools::getDetIdsInModule ( short  int)
static

Definition at line 137 of file EcalRingCalibrationTools.cc.

References gather_cfg::cout, and N_MODULES_BARREL.

Referenced by ZeeCalibration::duringLoop(), ZeeCalibration::endOfLoop(), and ~EcalRingCalibrationTools().

138 {
139 
140  std::vector<DetId> ringIds;
141  if (moduleIndex < 0)
142  return ringIds;
143 
144  short moduleBound[5] = {1, 26, 46, 66, 86};
146  {
148  short sm, moduleInSm, zsm;
149 
150  short minModuleiphi, maxModuleiphi, minModuleieta=360,maxModuleieta=0;
151 
152  // if(moduleIndex%4 != 0 )
153  sm = moduleIndex / 4 + 1;
154  // else
155  //sm = moduleIndex/4;//i.e. module 8 belongs to sm=3, not sm=3
156 
157  //if(moduleIndex%4 != 0 )
158  moduleInSm = moduleIndex%4;
159  //else
160  //moduleInSm = 4;//moduleInSm is [1,2,3,4]
161 
162  if(moduleIndex > 71)
163  zsm = -1;
164  else
165  zsm = 1;
166 
167  minModuleiphi = ( (sm - 1) %18 + 1 ) *20 - 19;
168  maxModuleiphi = ( (sm - 1) %18 + 1 ) * 20;
169 
170  if(zsm == 1)
171  {
172  minModuleieta = moduleBound[ moduleInSm ];
173  maxModuleieta = moduleBound[ moduleInSm + 1 ] - 1;
174  }
175  else if(zsm == -1){
176  minModuleieta = - moduleBound[ moduleInSm + 1 ] + 1;
177  maxModuleieta = - moduleBound[ moduleInSm ];
178  }
180 
181 
182  std::cout<<"Called moduleIndex "<<moduleIndex<<std::endl;
183  std::cout<<"minModuleieta "<<minModuleieta<<" maxModuleieta "<<maxModuleieta<<" minModuleiphi "<<minModuleiphi<<" maxModuleiphi "<<maxModuleiphi<<std::endl;
184 
185  for(int ieta = minModuleieta; ieta <= maxModuleieta; ++ieta){
186  for(int iphi = minModuleiphi; iphi<= maxModuleiphi; ++iphi){
187 
188 
189  ringIds.push_back(EBDetId(ieta,iphi));
190 
191  // std::cout<<"Putting Xtal with ieta: "<<ieta<<" iphi "<<iphi<<" of SM "<<sm<<" into Module "<<moduleIndex<<std::endl;
192 
193 
194  }//close loop on phi
195  }//close loop on eta
196  }//close if ( moduleInstallationNumber < 144)
197 
198  return ringIds;
199 }
std::vector< DetId > EcalRingCalibrationTools::getDetIdsInRing ( short  aRingIndex)
static

Retrieve the DetIds in a phi-ring.

Definition at line 71 of file EcalRingCalibrationTools.cc.

References endcapRingIndex_, isInitializedFromGeometry_, EEDetId::IX_MAX, EEDetId::IY_MAX, gen::k, EBDetId::MAX_IPHI, EBDetId::MIN_IPHI, N_RING_BARREL, N_RING_ENDCAP, N_RING_TOTAL, EBDetId::validDetId(), and HcalDigiParam_cfi::zside.

Referenced by ZeeCalibration::duringLoop(), ZeeCalibration::endOfLoop(), and ~EcalRingCalibrationTools().

72 {
73 
74  std::vector<DetId> ringIds;
75  if (etaIndex < 0)
76  return ringIds;
77 
78  if (etaIndex < N_RING_BARREL)
79  {
80 
81  int k =0;
82  if (etaIndex<85)
83  k=-85 + etaIndex;
84  else
85  k= etaIndex - 84;
86 
87  for(int iphi=EBDetId::MIN_IPHI; iphi<=EBDetId::MAX_IPHI; ++iphi)
88 
89  if (EBDetId::validDetId(k,iphi))
90  ringIds.push_back(EBDetId(k,iphi));
91  }
92 
93  else if (etaIndex < N_RING_TOTAL)
94  {
95  //needed only for the EE, it can be replaced at some point maybe with something smarter
97  throw std::logic_error("EcalRingCalibrationTools::initializeFromGeometry Ecal Endcap geometry is not initialized");
98 
99  int zside= (etaIndex < N_RING_BARREL + (N_RING_ENDCAP/2) ) ? -1 : 1;
100  short eeEtaIndex = (etaIndex - N_RING_BARREL)%(N_RING_ENDCAP/2);
101 
102  for (int ix=0;ix<EEDetId::IX_MAX;++ix)
103  for (int iy=0;iy<EEDetId::IY_MAX;++iy)
104  if (endcapRingIndex_[ix][iy] == eeEtaIndex)
105  ringIds.push_back(EEDetId(ix+1,iy+1,zside));
106 
107  }
108 
109  return ringIds;
110 }
static short endcapRingIndex_[EEDetId::IX_MAX][EEDetId::IY_MAX]
static const int MIN_IPHI
Definition: EBDetId.h:142
static std::atomic< bool > isInitializedFromGeometry_
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.h:124
int k[5][pyjets_maxn]
static const int IX_MAX
Definition: EEDetId.h:302
static const int MAX_IPHI
Definition: EBDetId.h:144
static const int IY_MAX
Definition: EEDetId.h:306
short EcalRingCalibrationTools::getModuleIndex ( DetId  aDetId)
static

Definition at line 46 of file EcalRingCalibrationTools.cc.

References DetId::Ecal, EcalBarrel, EcalEndcap, EBDetId::im(), EBDetId::ism(), and python.rootplot.argparse::module.

Referenced by calib::CalibElectron::getCalibModulesWeights(), and ~EcalRingCalibrationTools().

47 {
48 
49  if (id.det() != DetId::Ecal)
50  return -1;
51 
52  if (id.subdetId() == EcalBarrel)
53  {
54 
55 
56  short module = 4*( EBDetId(id).ism() -1 ) + EBDetId(id).im() -1;
57 
58  // std::cout<<"SM construction # : "<<EBDetId(id).ism() <<" SM installation # : "<< installationSMNumber[ EBDetId(id).ism() -1 ]<< "Xtal is Module :"<<module<< std::endl;
59  return module;
60 
61  }
62  if (id.subdetId() == EcalEndcap)
63  {
64 
65  return -1;
66  }
67 
68  return -1;
69 }
int ism() const
get the ECAL/SM id
Definition: EBDetId.h:61
int im() const
get the number of module inside the SM (1-4)
Definition: EBDetId.h:66
Definition: vlib.h:208
short EcalRingCalibrationTools::getRingIndex ( DetId  aDetId)
static

Retrieve the phi-ring index corresponding to a DetId.

Definition at line 19 of file EcalRingCalibrationTools.cc.

References DetId::Ecal, EcalBarrel, EcalEndcap, runTauDisplay::eid, endcapRingIndex_, EBDetId::ieta(), isInitializedFromGeometry_, EEDetId::ix(), EEDetId::iy(), N_RING_BARREL, N_RING_ENDCAP, and EEDetId::zside().

Referenced by calib::CalibElectron::getCalibModulesWeights(), PFRecHitQTestECALMultiThreshold::pass(), and ~EcalRingCalibrationTools().

20 {
21  if (id.det() != DetId::Ecal)
22  return -1;
23 
24  if (id.subdetId() == EcalBarrel)
25  {
26  if(EBDetId(id).ieta()<0)
27  return EBDetId(id).ieta() + 85;
28  else
29  return EBDetId(id).ieta() + 84;
30 
31  }
32  if (id.subdetId() == EcalEndcap)
33  {
34  //needed only for the EE, it can be replaced at some point with something smarter
36  throw std::logic_error("EcalRingCalibrationTools::initializeFromGeometry Ecal Endcap geometry is not initialized");
37 
38  EEDetId eid(id);
39  short endcapRingIndex = endcapRingIndex_[eid.ix()-1][eid.iy()-1] + N_RING_BARREL;
40  if (eid.zside() == 1) endcapRingIndex += N_RING_ENDCAP/2;
41  return endcapRingIndex;
42  }
43  return -1;
44 }
static short endcapRingIndex_[EEDetId::IX_MAX][EEDetId::IY_MAX]
static std::atomic< bool > isInitializedFromGeometry_
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
void EcalRingCalibrationTools::initializeFromGeometry ( CaloGeometry const *  geometry)
staticprivate

Definition at line 206 of file EcalRingCalibrationTools.cc.

References DetId::Ecal, EcalBarrel, EcalEndcap, endcapRingIndex_, PV3DBase< T, PVType, FrameType >::eta(), CaloCellGeometry::getPosition(), isInitializedFromGeometry_, EEDetId::ix(), EEDetId::IX_MAX, EEDetId::iy(), EEDetId::IY_MAX, N_RING_ENDCAP, relativeConstraints::ring, and EEDetId::zside().

Referenced by setCaloGeometry().

207 {
208  if (not geometry)
209  throw std::invalid_argument("EcalRingCalibrationTools::initializeFromGeometry called with a nullptr argument");
210 
211  float cellPosEta[EEDetId::IX_MAX][EEDetId::IY_MAX];
212  for (int ix=0; ix<EEDetId::IX_MAX; ++ix)
213  for (int iy=0; iy<EEDetId::IY_MAX; ++iy)
214  {
215  cellPosEta[ix][iy] = -1.;
216  endcapRingIndex_[ix][iy]=-9;
217  }
218 
219  CaloSubdetectorGeometry const* endcapGeometry = geometry->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
220  if (not endcapGeometry)
221  throw std::logic_error("EcalRingCalibrationTools::initializeFromGeometry Ecal Endcap geometry not found");
222 
223  std::vector<DetId> const& endcapCells = geometry->getValidDetIds(DetId::Ecal, EcalEndcap);
224 
225  for (std::vector<DetId>::const_iterator endcapIt = endcapCells.begin();
226  endcapIt!=endcapCells.end();
227  ++endcapIt)
228  {
229  EEDetId ee(*endcapIt);
230  if (ee.zside() == -1) continue; //Just using +side to fill absEta x,y map
231  const CaloCellGeometry *cellGeometry = endcapGeometry->getGeometry(*endcapIt) ;
232  int ics=ee.ix() - 1 ;
233  int ips=ee.iy() - 1 ;
234  cellPosEta[ics][ips] = fabs(cellGeometry->getPosition().eta());
235  //std::cout<<"EE Xtal, |eta| is "<<fabs(cellGeometry->getPosition().eta())<<std::endl;
236  }
237 
238  float eta_ring[N_RING_ENDCAP/2];
239  for (int ring=0; ring<N_RING_ENDCAP/2; ++ring)
240  eta_ring[ring]=cellPosEta[ring][50];
241 
242  double etaBoundary[N_RING_ENDCAP/2 + 1];
243  etaBoundary[0]=1.47;
244  etaBoundary[N_RING_ENDCAP/2]=4.0;
245 
246  for (int ring=1; ring<N_RING_ENDCAP/2; ++ring)
247  etaBoundary[ring]=(eta_ring[ring]+eta_ring[ring-1])/2.;
248 
249  for (int ring=0; ring<N_RING_ENDCAP/2; ++ring){
250  // std::cout<<"***********************EE ring: "<<ring<<" eta "<<(etaBoundary[ring] + etaBoundary[ring+1])/2.<<std::endl;
251  for (int ix=0; ix<EEDetId::IX_MAX; ix++)
252  for (int iy=0; iy<EEDetId::IY_MAX; iy++)
253  if (cellPosEta[ix][iy]>etaBoundary[ring] && cellPosEta[ix][iy]<etaBoundary[ring+1])
254  {
255  endcapRingIndex_[ix][iy]=ring;
256  //std::cout<<"endcapRing_["<<ix+1<<"]["<<iy+1<<"] = "<<ring<<";"<<std::endl;
257  }
258  }
259 
260  std::vector<DetId> const& barrelCells = geometry->getValidDetIds(DetId::Ecal, EcalBarrel);
261 
262  for (std::vector<DetId>::const_iterator barrelIt = barrelCells.begin();
263  barrelIt!=barrelCells.end();
264  ++barrelIt)
265  {
266  EBDetId eb(*barrelIt);
267  }
268 
269  //EB
270 
272 
273 }
static short endcapRingIndex_[EEDetId::IX_MAX][EEDetId::IY_MAX]
static std::atomic< bool > isInitializedFromGeometry_
static const int IX_MAX
Definition: EEDetId.h:302
T eta() const
Definition: PV3DBase.h:76
static const int IY_MAX
Definition: EEDetId.h:306
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
void EcalRingCalibrationTools::setCaloGeometry ( const CaloGeometry geometry)
static

Definition at line 201 of file EcalRingCalibrationTools.cc.

References initializeFromGeometry(), and once_.

Referenced by PFRecHitQTestECALMultiThreshold::beginEvent(), ZeeCalibration::duringLoop(), and HLTEcalPhiSymFilter::filter().

202 {
203  std::call_once(once_, EcalRingCalibrationTools::initializeFromGeometry, geometry);
204 }
static void initializeFromGeometry(CaloGeometry const *geometry)

Member Data Documentation

short EcalRingCalibrationTools::endcapRingIndex_
staticprivate
std::atomic< bool > EcalRingCalibrationTools::isInitializedFromGeometry_
staticprivate
const short EcalRingCalibrationTools::N_MODULES_BARREL = 144
static
const short EcalRingCalibrationTools::N_RING_BARREL = 170
static
const short EcalRingCalibrationTools::N_RING_ENDCAP = 78
static
const short EcalRingCalibrationTools::N_RING_TOTAL = 248
static
std::once_flag EcalRingCalibrationTools::once_
staticprivate

Definition at line 54 of file EcalRingCalibrationTools.h.

Referenced by setCaloGeometry().