CMS 3D CMS Logo

EcalPreshowerGeometry.cc
Go to the documentation of this file.
7 #include <iostream>
8 
12 typedef HepGeom::Plane3D<CCGFloat> Pl3D;
13 
14 //#define EDM_ML_DEBUG
15 
17  : m_xWidWaf(6.3),
18  m_xInterLadGap(0.05), // additional gap between wafers in adj ladders
19  m_xIntraLadGap(0.04), // gap between wafers in same ladder
20  m_yWidAct(6.1),
21  m_yCtrOff(0.05), // gap at center
22  m_cellVec(k_NumberOfCellsForCorners) {
23  m_zplane[0] = 0.;
24  m_zplane[1] = 0.;
25  m_zplane[2] = 0.;
26  m_zplane[3] = 0.;
27 #ifdef EDM_ML_DEBUG
28  edm::LogVerbatim("EcalGeom") << "EcalPreshowerGeometry::Creating an instance";
29 #endif
30 }
31 
33 
35  const CaloGenericDetId gid(id);
36 
37  assert(gid.isES());
38 
39  // plane 2 is split into 2 dees along x=0 for both signs of z
40 
41  // plane 1 at zsign=-1 is split into 2 dees between six=19 and six=20 for siy<=20,
42  // and six=21 and 22 for siy>=21
43 
44  // plane 1 at zsign=+1 is split into 2 dees between six=20 and six=21 for siy<=20,
45  // and six=19 and 20 for siy>=21
46 
47  // Desired numbering
48  // LEFT RIGHT (as one faces the Dee from the IP)
49  // ES- pl=2 0 1
50  // pl=1 2 3 the reversal of pl=2 and pl=1 is intentional here (CM Kuo)
51  // ES+ pl=1 4 5
52  // pl=2 6 7
53 
54  const ESDetId esid(id);
55  const int jx(esid.six() - 1);
56  const int jy(esid.siy() - 1);
57  const int jz(esid.zside() + 1);
58  const int pl(esid.plane() - 1);
59  const bool second(1 == pl);
60  const bool top(19 < jy);
61  const bool negz(0 == jz);
62  const int lrl(19 > jx ? 0 : 1);
63  const int lrr(21 > jx ? 0 : 1);
64 
65  return (second ? jx / 20 + 3 * jz : // 2nd plane split along middle
66  (negz && !top ? lrl + 2 : // 1st plane at neg z and bottom half split at six=19&20
67  (negz && top ? lrr + 2 : // 1st plane at neg z and top half split at six=21&22
68  (!negz && !top ? lrr + 4 : lrl + 4)))); // opposite at positive z
69 }
70 
72  return ESDetId(1, 10 + 20 * (iLoc % 2), 10, 2 > iLoc || 5 < iLoc ? 2 : 1, 2 * (iLoc / 4) - 1);
73 }
74 
76  return (unsigned int)DetId::Ecal - 1;
77 }
78 
80  unsigned int n1minus(0);
81  unsigned int n2minus(0);
82  unsigned int n1plus(0);
83  unsigned int n2plus(0);
84  CCGFloat z1minus(0);
85  CCGFloat z2minus(0);
86  CCGFloat z1plus(0);
87  CCGFloat z2plus(0);
88  const std::vector<DetId>& esDetIds(getValidDetIds());
89 #ifdef EDM_ML_DEBUG
90  edm::LogVerbatim("EcalGeom") << "EcalPreshowerGeometry:: Get " << esDetIds.size() << " valid DetIds";
91 #endif
92 
93  for (unsigned int i(0); i != esDetIds.size(); ++i) {
94  const ESDetId esid(esDetIds[i]);
95  auto cell = getGeometry(esid);
96  if (nullptr != cell) {
97  const CCGFloat zz(cell->getPosition().z());
98  if (1 == esid.plane()) {
99  if (0 > esid.zside()) {
100  z1minus += zz;
101  ++n1minus;
102  } else {
103  z1plus += zz;
104  ++n1plus;
105  }
106  }
107  if (2 == esid.plane()) {
108  if (0 > esid.zside()) {
109  z2minus += zz;
110  ++n2minus;
111  } else {
112  z2plus += zz;
113  ++n2plus;
114  }
115  }
116  }
117  }
118  assert(0 != n1minus && 0 != n2minus && 0 != n1plus && 0 != n2plus);
119  z1minus /= (1. * n1minus);
120  z2minus /= (1. * n2minus);
121  z1plus /= (1. * n1plus);
122  z2plus /= (1. * n2plus);
123  assert(0 != z1minus && 0 != z2minus && 0 != z1plus && 0 != z2plus);
124  setzPlanes(z1minus, z2minus, z1plus, z2plus);
125 }
126 
127 void EcalPreshowerGeometry::setzPlanes(CCGFloat z1minus, CCGFloat z2minus, CCGFloat z1plus, CCGFloat z2plus) {
128  assert(0 > z1minus && 0 > z2minus && 0 < z1plus && 0 < z2plus);
129 
130  m_zplane[0] = z1minus;
131  m_zplane[1] = z2minus;
132  m_zplane[2] = z1plus;
133  m_zplane[3] = z2plus;
134 }
135 
136 // Get closest cell, etc...
138 
140  const CCGFloat x(point.x());
141  const CCGFloat y(point.y());
142  const CCGFloat z(point.z());
143 
144  if (0 == z || 1 > plane || 2 < plane)
145  return DetId(0);
146 
147  const unsigned int iz((0 > z ? 0 : 2) + plane - 1);
148 
149  const CCGFloat ze(m_zplane[iz]);
150  const CCGFloat xe(x * ze / z);
151  const CCGFloat ye(y * ze / z);
152 
153  const CCGFloat x0(1 == plane ? xe : ye);
154  const CCGFloat y0(1 == plane ? ye : xe);
155 
156  static const CCGFloat xWid(m_xWidWaf + m_xIntraLadGap + m_xInterLadGap);
157 
158  const int row(1 + int(y0 + 20. * m_yWidAct - m_yCtrOff) / m_yWidAct);
159  const int col(1 + int((x0 + 20. * xWid) / xWid));
160 
161  CCGFloat closest(1e9);
162 
163  DetId detId(0);
164 
165  const int jz(0 > ze ? -1 : 1);
166 
167  // std::cout<<"** p="<<point<<", ("<<xe<<", "<<ye<<", "<<ze<<"), row="<<row<<", col="<<col<<std::endl;
168 
169  for (int ix(-1); ix != 2; ++ix) // search within +-1 in row and col
170  {
171  for (int iy(-1); iy != 2; ++iy) {
172  for (int jstrip(ESDetId::ISTRIP_MIN); jstrip <= ESDetId::ISTRIP_MAX; ++jstrip) {
173  const int jx(1 == plane ? col + ix : row + iy);
174  const int jy(1 == plane ? row + iy : col + ix);
175  if (ESDetId::validDetId(jstrip, jx, jy, plane, jz)) {
176  const ESDetId esId(jstrip, jx, jy, plane, jz);
177  auto cell = getGeometry(esId);
178  if (nullptr != cell) {
179  const GlobalPoint& p(cell->getPosition());
180  const CCGFloat dist2((p.x() - xe) * (p.x() - xe) + (p.y() - ye) * (p.y() - ye));
181  if (dist2 < closest && present(esId)) {
182  closest = dist2;
183  detId = esId;
184  }
185  }
186  }
187  }
188  }
189  }
190  return detId;
191 }
192 
193 void EcalPreshowerGeometry::localCorners(Pt3DVec& lc, const CCGFloat* pv, unsigned int /*i*/, Pt3D& ref) {
195 }
196 
198  const GlobalPoint& /*f2*/,
199  const GlobalPoint& /*f3*/,
200  const CCGFloat* parm,
201  const DetId& detId) {
202  const unsigned int cellIndex(ESDetId(detId).denseIndex());
203  m_cellVec[cellIndex] = PreshowerStrip(f1, cornersMgr(), parm);
204  addValidID(detId);
205 #ifdef EDM_ML_DEBUG
206  edm::LogVerbatim("EcalGeom") << "EcalPreshowerGeometry::Add a new DetId " << ESDetId(detId);
207 #endif
208 }
209 
211  // Modify the RawPtr class
212  const CaloCellGeometry* cell(&m_cellVec[index]);
213  return (m_cellVec.size() < index || nullptr == cell->param() ? nullptr : cell);
214 }
CaloCellGeometry::Pt3DVec
std::vector< Pt3D > Pt3DVec
Definition: CaloCellGeometry.h:55
CaloGenericDetId.h
EcalPreshowerGeometry::getGeometryRawPtr
const CaloCellGeometry * getGeometryRawPtr(uint32_t index) const override
Definition: EcalPreshowerGeometry.cc:210
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
EcalPreshowerGeometry::m_xWidWaf
const CCGFloat m_xWidWaf
Definition: EcalPreshowerGeometry.h:94
geometryCSVtoXML.zz
zz
Definition: geometryCSVtoXML.py:19
CaloCellGeometry::CCGFloat
float CCGFloat
Definition: CaloCellGeometry.h:52
MessageLogger.h
ESDetId::ISTRIP_MIN
static const int ISTRIP_MIN
Definition: ESDetId.h:68
CaloGenericDetId
Definition: CaloGenericDetId.h:12
EcalPreshowerGeometry::~EcalPreshowerGeometry
~EcalPreshowerGeometry() override
The EcalPreshowerGeometry will delete all its cell geometries at destruction time.
Definition: EcalPreshowerGeometry.cc:32
EcalPreshowerGeometry::getClosestCell
DetId getClosestCell(const GlobalPoint &r) const override
Definition: EcalPreshowerGeometry.cc:137
EcalPreshowerGeometry::setzPlanes
void setzPlanes(CCGFloat z1minus, CCGFloat z2minus, CCGFloat z1plus, CCGFloat z2plus)
Definition: EcalPreshowerGeometry.cc:127
CaloGenericDetId::isES
bool isES() const
Definition: CaloGenericDetId.h:31
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
EcalPreshowerGeometry::Pt3DVec
CaloCellGeometry::Pt3DVec Pt3DVec
Definition: EcalPreshowerGeometry.h:21
EcalPreshowerGeometry::detIdFromLocalAlignmentIndex
static DetId detIdFromLocalAlignmentIndex(unsigned int iLoc)
Definition: EcalPreshowerGeometry.cc:71
cuy.col
col
Definition: cuy.py:1010
cms::cuda::assert
assert(be >=bs)
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
EcalPreshowerGeometry::m_xIntraLadGap
const CCGFloat m_xIntraLadGap
Definition: EcalPreshowerGeometry.h:96
ESDetId
Definition: ESDetId.h:15
DDAxes::x
ESDetId.h
CCGFloat
CaloCellGeometry::CCGFloat CCGFloat
Definition: EcalPreshowerGeometry.cc:9
Pt3D
CaloCellGeometry::Pt3D Pt3D
Definition: EcalPreshowerGeometry.cc:10
EcalPreshowerGeometry::m_xInterLadGap
const CCGFloat m_xInterLadGap
Definition: EcalPreshowerGeometry.h:95
DetId
Definition: DetId.h:17
CaloSubdetectorGeometry::CCGFloat
CaloCellGeometry::CCGFloat CCGFloat
Definition: CaloSubdetectorGeometry.h:25
EcalPreshowerGeometry::Pt3D
CaloCellGeometry::Pt3D Pt3D
Definition: EcalPreshowerGeometry.h:20
DDAxes::z
EcalPreshowerGeometry.h
EcalPreshowerGeometry::newCell
void newCell(const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId) override
Definition: EcalPreshowerGeometry.cc:197
EcalPreshowerGeometry::localCorners
static void localCorners(Pt3DVec &lc, const CCGFloat *pv, unsigned int i, Pt3D &ref)
Definition: EcalPreshowerGeometry.cc:193
Point3DBase< float, GlobalTag >
EcalPreshowerGeometry::m_yWidAct
const CCGFloat m_yWidAct
Definition: EcalPreshowerGeometry.h:98
EcalPreshowerGeometry::m_cellVec
CellVec m_cellVec
Definition: EcalPreshowerGeometry.h:103
CaloCellGeometry::Pt3D
HepGeom::Point3D< CCGFloat > Pt3D
Definition: CaloCellGeometry.h:54
CaloSubdetectorGeometry::getValidDetIds
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
Definition: CaloSubdetectorGeometry.cc:32
Pt3DVec
CaloCellGeometry::Pt3DVec Pt3DVec
Definition: EcalPreshowerGeometry.cc:11
Pl3D
HepGeom::Plane3D< CCGFloat > Pl3D
Definition: EcalPreshowerGeometry.cc:12
EcalPreshowerGeometry::getClosestCellInPlane
virtual DetId getClosestCellInPlane(const GlobalPoint &r, int plane) const
Definition: EcalPreshowerGeometry.cc:139
PreshowerStrip.h
ESDetId::ISTRIP_MAX
static const int ISTRIP_MAX
Definition: ESDetId.h:69
CaloCellGeometry
Definition: CaloCellGeometry.h:50
CaloCellGeometry::param
const CCGFloat * param() const
Definition: CaloCellGeometry.h:99
EcalPreshowerGeometry::m_zplane
CCGFloat m_zplane[4]
Definition: EcalPreshowerGeometry.h:101
EcalPreshowerGeometry::alignmentTransformIndexGlobal
static unsigned int alignmentTransformIndexGlobal(const DetId &id)
Definition: EcalPreshowerGeometry.cc:75
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
CaloSubdetectorGeometry::addValidID
void addValidID(const DetId &id)
Definition: CaloSubdetectorGeometry.cc:27
CaloSubdetectorGeometry::getGeometry
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Definition: CaloSubdetectorGeometry.cc:36
DetId::Ecal
Definition: DetId.h:27
ESDetId::plane
int plane() const
Definition: ESDetId.h:41
CaloSubdetectorGeometry::cornersMgr
CaloCellGeometry::CornersMgr * cornersMgr()
Definition: CaloSubdetectorGeometry.h:82
EcalPreshowerGeometry::EcalPreshowerGeometry
EcalPreshowerGeometry()
Definition: EcalPreshowerGeometry.cc:16
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
ESDetId::validDetId
static bool validDetId(int istrip, int ixs, int iys, int iplane, int iz)
check if a valid index combination
Definition: ESDetId.cc:15
EcalPreshowerGeometry::initializeParms
void initializeParms() override
Definition: EcalPreshowerGeometry.cc:79
Exception.h
EcalPreshowerGeometry::present
bool present(const DetId &id) const override
is this detid present in the geometry?
Definition: EcalPreshowerGeometry.h:81
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
EcalPreshowerGeometry::alignmentTransformIndexLocal
static unsigned int alignmentTransformIndexLocal(const DetId &id)
Definition: EcalPreshowerGeometry.cc:34
PreshowerStrip
A base class to handle the shape of preshower strips.
Definition: PreshowerStrip.h:21
EcalPreshowerGeometry::m_yCtrOff
const CCGFloat m_yCtrOff
Definition: EcalPreshowerGeometry.h:99
point
*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
DeadROC_duringRun.f1
f1
Definition: DeadROC_duringRun.py:219
PreshowerStrip::localCorners
static void localCorners(Pt3DVec &vec, const CCGFloat *pv, Pt3D &ref)
Definition: PreshowerStrip.cc:66
ESDetId::zside
int zside() const
Definition: ESDetId.h:39