CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes | Static Private Attributes
CrystalPad Class Reference

#include <CrystalPad.h>

Classes

class  padEqual
 equality operator More...
 

Public Types

typedef ROOT::Math::Transform3DPJ::Point Point
 
typedef ROOT::Math::Transform3DPJ Transform3D
 
typedef math::XYZVector XYZPoint
 
typedef math::XYZVector XYZVector
 

Public Member Functions

const CLHEP::Hep2Vector & center () const
 get the center More...
 
 CrystalPad ()
 
 CrystalPad (const CrystalPad &right)
 
 CrystalPad (unsigned number, const std::vector< CLHEP::Hep2Vector > &corners)
 Order matters. 1234 2341 3412 4123 are ok but not 1324 .... More...
 
 CrystalPad (unsigned number, const std::vector< XYZPoint > &corners, const Transform3D &, double scaf=1., bool bothdirections=false)
 
 CrystalPad (unsigned number, int onEcal, const std::vector< XYZPoint > &corners, const XYZPoint &origin, const XYZVector &vec1, const XYZVector &vec2)
 
CLHEP::Hep2Vector & edge (CaloDirection)
 access to one corner (NE,NW,SE,SW) More...
 
CLHEP::Hep2Vector & edge (unsigned iside, int n)
 access to the corners in direction iside; n=0,1 More...
 
void extrems (double &xmin, double &xmax, double &ymin, double &ymax) const
 xmin xmax, ymin ymax of the quad More...
 
const std::vector< CLHEP::Hep2Vector > & getCorners () const
 Check that the point (in the global frame) is inside the crystal. More...
 
void getDrawingCoordinates (std::vector< float > &x, std::vector< float > &y) const
 for graphic debugging More...
 
unsigned getNumber () const
 access to the number More...
 
bool inside (const CLHEP::Hep2Vector &point, bool debug=false) const
 Check that the point (in the local frame) is inside the crystal. More...
 
bool operator< (const CrystalPad &quad) const
 
CrystalPadoperator= (const CrystalPad &rhs)
 
bool operator== (const CrystalPad &quad) const
 get the coordinates in the original frame More...
 
void print () const
 print More...
 
void resetCorners ()
 Rescale the Quad to allow for some inaccuracy ... More...
 
void setSurvivalProbability (double val)
 
double survivalProbability () const
 access methods to the survivalProbability More...
 
 ~CrystalPad ()
 

Private Attributes

CLHEP::Hep2Vector center_
 
std::vector< CLHEP::Hep2Vector > corners_
 
std::vector< CLHEP::Hep2Vector > dir_
 
bool dummy_
 
double epsilon_
 
unsigned number_
 
ROOT::Math::Rotation3D rotation_
 
double survivalProbability_
 
Transform3D trans_
 
XYZVector translation_
 
double yscalefactor_
 

Static Private Attributes

static std::vector< CLHEP::Hep2Vector > aVector
 

Detailed Description

Definition at line 13 of file CrystalPad.h.

Member Typedef Documentation

◆ Point

Definition at line 18 of file CrystalPad.h.

◆ Transform3D

Definition at line 17 of file CrystalPad.h.

◆ XYZPoint

Definition at line 16 of file CrystalPad.h.

◆ XYZVector

Definition at line 15 of file CrystalPad.h.

Constructor & Destructor Documentation

◆ CrystalPad() [1/5]

CrystalPad::CrystalPad ( )
inline

Definition at line 20 of file CrystalPad.h.

20 { dummy_ = true; };

References dummy_.

◆ CrystalPad() [2/5]

CrystalPad::CrystalPad ( unsigned  number,
const std::vector< CLHEP::Hep2Vector > &  corners 
)

Order matters. 1234 2341 3412 4123 are ok but not 1324 ....

Definition at line 30 of file CrystalPad.cc.

31  : corners_(corners), dir_(aVector), number_(number), survivalProbability_(1.), center_(0., 0.), epsilon_(0.001) {
32  // std::cout << " Hello " << std::endl;
33  if (corners.size() != 4) {
34  std::cout << " Try to construct a quadrilateral with " << corners.size() << " points ! " << std::endl;
35  dummy_ = true;
36  } else {
37  dummy_ = false;
38  // Set explicity the z to 0 !
39  for (unsigned ic = 0; ic < 4; ++ic) {
40  dir_[ic] = (corners[(ic + 1) % 4] - corners[ic]).unit();
41  center_ += corners_[ic];
42  }
43  center_ *= 0.25;
44  }
45  // std::cout << " End of 1 constructor " << std::endl;
46  // std::cout << " Ncorners " << corners_.size() << std::endl;
47  // std::cout << " Ndirs " << dir_.size() << std::endl;
48 }

References center_, corners_, gather_cfg::cout, dir_, and dummy_.

◆ CrystalPad() [3/5]

CrystalPad::CrystalPad ( unsigned  number,
int  onEcal,
const std::vector< XYZPoint > &  corners,
const XYZPoint origin,
const XYZVector vec1,
const XYZVector vec2 
)

Constructor from space points, with the description of the local frame (origin,vec1,vec2) where vec1 is normal to the plane and vec2 in the plane

Definition at line 50 of file CrystalPad.cc.

57  // std::cout << " We are in the 2nd constructor " << std::endl;
58  if (corners.size() != 4) {
59  std::cout << " Try to construct a quadrilateral with " << corners.size() << " points ! " << std::endl;
60  dummy_ = true;
61  } else {
62  dummy_ = false;
63  double sign = (onEcal == 1) ? -1. : 1.;
64 
65  // the good one in the central
66  trans_ = Transform3D((Point)origin,
67  (Point)(origin + vec1),
68  (Point)(origin + vec2),
69  Point(0., 0., 0.),
70  Point(0., 0., sign),
71  Point(0., 1., 0.));
73  // std::cout << " Constructor 2; input corners " << std::endl;
74  for (unsigned ic = 0; ic < 4; ++ic) {
75  // std::cout << corners[ic]<< " " ;
76  XYZPoint corner = rotation_(corners[ic]) + translation_;
77  // std::cout << corner << std::endl ;
78  corners_[ic] = CLHEP::Hep2Vector(corner.X(), corner.Y());
79  center_ += corners_[ic];
80  }
81  for (unsigned ic = 0; ic < 4; ++ic) {
82  dir_[ic] = (corners_[(ic + 1) % 4] - corners_[ic]).unit();
83  }
84  center_ *= 0.25;
85  }
86  // std::cout << " End of 2 constructor " << std::endl;
87  // std::cout << " Corners(constructor) " ;
88  // std::cout << corners_[0] << std::endl;
89  // std::cout << corners_[1] << std::endl;
90  // std::cout << corners_[2] << std::endl;
91  // std::cout << corners_[3] << std::endl;
92 }

References center_, distTCMET_cfi::corner, corners_, gather_cfg::cout, dir_, dummy_, ROOT::Math::Transform3DPJ::GetDecomposition(), rotation_, Validation_hcalonly_cfi::sign, trans_, and translation_.

◆ CrystalPad() [4/5]

CrystalPad::CrystalPad ( unsigned  number,
const std::vector< XYZPoint > &  corners,
const Transform3D trans,
double  scaf = 1.,
bool  bothdirections = false 
)

Definition at line 93 of file CrystalPad.cc.

95  : corners_(aVector),
96  dir_(aVector),
97  number_(number),
99  center_(0., 0.),
100  epsilon_(0.001),
101  yscalefactor_(scaf) {
102  // std::cout << " We are in the 2nd constructor " << std::endl;
103  if (corners.size() != 4) {
104  std::cout << " Try to construct a quadrilateral with " << corners.size() << " points ! " << std::endl;
105  dummy_ = true;
106  } else {
107  dummy_ = false;
108 
109  // the good one in the central
110  trans_ = trans;
111  // std::cout << " Constructor 2; input corners " << std::endl;
113  for (unsigned ic = 0; ic < 4; ++ic) {
114  XYZPoint corner = rotation_(corners[ic]) + translation_;
115  // std::cout << corner << std::endl ;
116  double xscalefactor = (bothdirections) ? yscalefactor_ : 1.;
117  corners_[ic] = CLHEP::Hep2Vector(corner.X() * xscalefactor, corner.Y() * yscalefactor_);
118  center_ += corners_[ic];
119  }
120  for (unsigned ic = 0; ic < 4; ++ic) {
121  dir_[ic] = (corners_[(ic + 1) % 4] - corners_[ic]).unit();
122  }
123  center_ *= 0.25;
124  }
125 }

References center_, distTCMET_cfi::corner, corners_, gather_cfg::cout, dir_, dummy_, ROOT::Math::Transform3DPJ::GetDecomposition(), rotation_, trans_, translation_, and yscalefactor_.

◆ CrystalPad() [5/5]

CrystalPad::CrystalPad ( const CrystalPad right)

Definition at line 7 of file CrystalPad.cc.

7  {
8  corners_ = right.corners_;
9  dir_ = right.dir_;
10  number_ = right.number_;
12  center_ = right.center_;
13  epsilon_ = right.epsilon_;
14  dummy_ = right.dummy_;
15 }

References center_, corners_, dir_, dummy_, epsilon_, number_, and survivalProbability_.

◆ ~CrystalPad()

CrystalPad::~CrystalPad ( )
inline

Definition at line 43 of file CrystalPad.h.

43 { ; };

Member Function Documentation

◆ center()

const CLHEP::Hep2Vector& CrystalPad::center ( ) const
inline

get the center

Definition at line 95 of file CrystalPad.h.

95 { return center_; }

References center_.

Referenced by operator<().

◆ edge() [1/2]

CLHEP::Hep2Vector & CrystalPad::edge ( CaloDirection  dir)

access to one corner (NE,NW,SE,SW)

Definition at line 224 of file CrystalPad.cc.

224  {
225  switch (dir) {
226  case NORTHWEST:
227  return corners_[0];
228  break;
229  case NORTHEAST:
230  return corners_[1];
231  break;
232  case SOUTHEAST:
233  return corners_[2];
234  break;
235  case SOUTHWEST:
236  return corners_[3];
237  break;
238  default: {
239  std::cout << " Serious problem in CrystalPad ! " << dir << std::endl;
240  return corners_[0];
241  }
242  }
243  return corners_[0];
244 }

References corners_, gather_cfg::cout, DeadROC_duringRun::dir, NORTHEAST, NORTHWEST, SOUTHEAST, and SOUTHWEST.

◆ edge() [2/2]

CLHEP::Hep2Vector & CrystalPad::edge ( unsigned  iside,
int  n 
)

access to the corners in direction iside; n=0,1

Definition at line 222 of file CrystalPad.cc.

222 { return corners_[(iside + n) % 4]; }

References corners_, and dqmiodumpmetadata::n.

Referenced by EcalHitMaker::cracksPads(), EcalHitMaker::gapsLifting(), and operator<<().

◆ extrems()

void CrystalPad::extrems ( double &  xmin,
double &  xmax,
double &  ymin,
double &  ymax 
) const

xmin xmax, ymin ymax of the quad

Definition at line 246 of file CrystalPad.cc.

246  {
247  xmin = ymin = 999;
248  xmax = ymax = -999;
249  for (unsigned ic = 0; ic < 4; ++ic) {
250  if (corners_[ic].x() < xmin)
251  xmin = corners_[ic].x();
252  if (corners_[ic].x() > xmax)
253  xmax = corners_[ic].x();
254  if (corners_[ic].y() < ymin)
255  ymin = corners_[ic].y();
256  if (corners_[ic].y() > ymax)
257  ymax = corners_[ic].y();
258  }
259 }

References corners_, x, TrackerOfflineValidation_Dqm_cff::xmax, TrackerOfflineValidation_Dqm_cff::xmin, y, L1TOccupancyClient_cfi::ymax, and L1TOccupancyClient_cfi::ymin.

◆ getCorners()

const std::vector<CLHEP::Hep2Vector>& CrystalPad::getCorners ( ) const
inline

Check that the point (in the global frame) is inside the crystal.

coordinates of the point in the local frame get the corners

Definition at line 54 of file CrystalPad.h.

54 { return corners_; }

References corners_.

◆ getDrawingCoordinates()

void CrystalPad::getDrawingCoordinates ( std::vector< float > &  x,
std::vector< float > &  y 
) const

for graphic debugging

Definition at line 284 of file CrystalPad.cc.

284  {
285  x.clear();
286  y.clear();
287  x.push_back(corners_[0].x());
288  x.push_back(corners_[1].x());
289  x.push_back(corners_[2].x());
290  x.push_back(corners_[3].x());
291  x.push_back(corners_[0].x());
292  y.push_back(corners_[0].y());
293  y.push_back(corners_[1].y());
294  y.push_back(corners_[2].y());
295  y.push_back(corners_[3].y());
296  y.push_back(corners_[0].y());
297 }

References corners_, x, and y.

◆ getNumber()

unsigned CrystalPad::getNumber ( ) const
inline

access to the number

Definition at line 73 of file CrystalPad.h.

73 { return number_; };

References number_.

Referenced by CrystalPad::padEqual::operator()(), operator<<(), and operator==().

◆ inside()

bool CrystalPad::inside ( const CLHEP::Hep2Vector &  point,
bool  debug = false 
) const

Check that the point (in the local frame) is inside the crystal.

Definition at line 127 of file CrystalPad.cc.

127  {
128  // std::cout << "Inside " << ppoint <<std::endl;
129  // std::cout << "Corners " << corners_.size() << std::endl;
130  // std::cout << corners_[0] << std::endl;
131  // std::cout << corners_[1] << std::endl;
132  // std::cout << corners_[2] << std::endl;
133  // std::cout << corners_[3] << std::endl;
134  // std::cout << " Got the 2D point " << std::endl;
135  CLHEP::Hep2Vector pv0(ppoint - corners_[0]);
136  CLHEP::Hep2Vector pv2(ppoint - corners_[2]);
137  CLHEP::Hep2Vector n1(pv0 - (pv0 * dir_[0]) * dir_[0]);
138  CLHEP::Hep2Vector n2(pv2 - (pv2 * dir_[2]) * dir_[2]);
139 
140  // double N1(n1.mag());
141  // double N2(n2.mag());
142  double r1(n1 * n2);
143  bool inside1(r1 <= 0.);
144 
145  if (!inside1)
146  return false;
147 
148  // if(debug)
149  // {
150  // std::cout << n1 << std::endl;
151  // std::cout << n2 << std::endl;
152  // std::cout << r1 << std::endl;
153  // std::cout << inside1 << std::endl;
154  // }
155 
156  // bool close1=(N1<epsilon_||N2<epsilon_);
157  //
158  // if(!close1&&!inside1) return false;
159  // std::cout << " First calculation " << std::endl;
160  CLHEP::Hep2Vector pv1(ppoint - corners_[1]);
161  CLHEP::Hep2Vector pv3(ppoint - corners_[3]);
162  CLHEP::Hep2Vector n3(pv1 - (pv1 * dir_[1]) * dir_[1]);
163  CLHEP::Hep2Vector n4(pv3 - (pv3 * dir_[3]) * dir_[3]);
164  // double N3(n3.mag());
165  // double N4(n4.mag());
166  // bool close2=(N3<epsilon_||N4<epsilon_);
167  double r2(n3 * n4);
168  bool inside2(r2 <= 0.);
169  // // std::cout << " pv1 & pv3 " << pv1.mag() << " " << pv3.mag() << std::endl;
170  // // double tmp=(pv1-(pv1*dir_[1])*dir_[1])*(pv3-(pv3*dir_[3])*dir_[3]);
171  // // std::cout << " Computed tmp " << tmp << std::endl;
172  // if(debug)
173  // {
174  // std::cout << n3 << std::endl;
175  // std::cout << n4 << std::endl;
176  // std::cout << r2 << std::endl;
177  // std::cout << inside2 << std::endl;
178  // }
179  // if(!close2&&!inside2) return false;
180  // std::cout << " Second calculation " << std::endl;
181  // std::cout << " True " << std::endl;
182  // return (!close1&&!close2||(close2&&inside1||close1&&inside2));
183 
184  return inside2;
185 }

References corners_, dir_, diffTwoXMLs::r1, and diffTwoXMLs::r2.

◆ operator<()

bool CrystalPad::operator< ( const CrystalPad quad) const
inline

Definition at line 89 of file CrystalPad.h.

89 { return (center_.mag() < quad.center().mag()); }

References center(), and center_.

◆ operator=()

CrystalPad & CrystalPad::operator= ( const CrystalPad rhs)

Definition at line 17 of file CrystalPad.cc.

17  {
18  if (this != &right) { // don't copy into yourself
19  corners_ = right.corners_;
20  dir_ = right.dir_;
21  number_ = right.number_;
22  survivalProbability_ = right.survivalProbability_;
23  center_ = right.center_;
24  epsilon_ = right.epsilon_;
25  dummy_ = right.dummy_;
26  }
27  return *this;
28 }

References center_, corners_, dir_, dummy_, epsilon_, number_, and survivalProbability_.

◆ operator==()

bool CrystalPad::operator== ( const CrystalPad quad) const
inline

get the coordinates in the original frame

Definition at line 84 of file CrystalPad.h.

84  {
85  // std::cout << " First " << quad.getCellID() << " Second " << this->getCellID() << std::endl;
86  return quad.getNumber() == this->getNumber();
87  }

References getNumber().

◆ print()

void CrystalPad::print ( void  ) const

print

Definition at line 205 of file CrystalPad.cc.

205  {
206  std::cout << " Corners " << std::endl;
207  std::cout << corners_[0] << std::endl;
208  std::cout << corners_[1] << std::endl;
209  std::cout << corners_[2] << std::endl;
210  std::cout << corners_[3] << std::endl;
211 }

References corners_, and gather_cfg::cout.

◆ resetCorners()

void CrystalPad::resetCorners ( )

Rescale the Quad to allow for some inaccuracy ...

Definition at line 261 of file CrystalPad.cc.

261  {
262  // Find the centre-of-gravity of the Quad (after re-organization)
263  center_ = CLHEP::Hep2Vector(0., 0.);
264  for (unsigned ic = 0; ic < 4; ++ic)
265  center_ += corners_[ic];
266  center_ *= 0.25;
267 
268  // Rescale the corners to allow for some inaccuracies in
269  // in the inside test
270  for (unsigned ic = 0; ic < 4; ++ic)
271  corners_[ic] += 0.001 * (corners_[ic] - center_);
272 }

References center_, and corners_.

◆ setSurvivalProbability()

void CrystalPad::setSurvivalProbability ( double  val)
inline

Definition at line 64 of file CrystalPad.h.

References survivalProbability_, and heppy_batch::val.

Referenced by EcalHitMaker::cracksPads().

◆ survivalProbability()

double CrystalPad::survivalProbability ( ) const
inline

access methods to the survivalProbability

Definition at line 63 of file CrystalPad.h.

63 { return survivalProbability_; };

References survivalProbability_.

Member Data Documentation

◆ aVector

std::vector< CLHEP::Hep2Vector > CrystalPad::aVector
staticprivate

Definition at line 101 of file CrystalPad.h.

◆ center_

CLHEP::Hep2Vector CrystalPad::center_
private

Definition at line 110 of file CrystalPad.h.

Referenced by center(), CrystalPad(), operator<(), operator=(), and resetCorners().

◆ corners_

std::vector<CLHEP::Hep2Vector> CrystalPad::corners_
private

◆ dir_

std::vector<CLHEP::Hep2Vector> CrystalPad::dir_
private

Definition at line 104 of file CrystalPad.h.

Referenced by CrystalPad(), inside(), and operator=().

◆ dummy_

bool CrystalPad::dummy_
private

Definition at line 112 of file CrystalPad.h.

Referenced by CrystalPad(), and operator=().

◆ epsilon_

double CrystalPad::epsilon_
private

Definition at line 111 of file CrystalPad.h.

Referenced by CrystalPad(), and operator=().

◆ number_

unsigned CrystalPad::number_
private

Definition at line 105 of file CrystalPad.h.

Referenced by CrystalPad(), getNumber(), and operator=().

◆ rotation_

ROOT::Math::Rotation3D CrystalPad::rotation_
private

Definition at line 107 of file CrystalPad.h.

Referenced by CrystalPad().

◆ survivalProbability_

double CrystalPad::survivalProbability_
private

Definition at line 109 of file CrystalPad.h.

Referenced by CrystalPad(), operator=(), setSurvivalProbability(), and survivalProbability().

◆ trans_

Transform3D CrystalPad::trans_
private

Definition at line 106 of file CrystalPad.h.

Referenced by CrystalPad().

◆ translation_

XYZVector CrystalPad::translation_
private

Definition at line 108 of file CrystalPad.h.

Referenced by CrystalPad().

◆ yscalefactor_

double CrystalPad::yscalefactor_
private

Definition at line 113 of file CrystalPad.h.

Referenced by CrystalPad().

DDAxes::y
CrystalPad::yscalefactor_
double yscalefactor_
Definition: CrystalPad.h:113
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
CrystalPad::dir_
std::vector< CLHEP::Hep2Vector > dir_
Definition: CrystalPad.h:104
vec1
std::vector< double > vec1
Definition: HCALResponse.h:15
gather_cfg.cout
cout
Definition: gather_cfg.py:144
distTCMET_cfi.corner
corner
Definition: distTCMET_cfi.py:38
CrystalPad::Transform3D
ROOT::Math::Transform3DPJ Transform3D
Definition: CrystalPad.h:17
CrystalPad::Point
ROOT::Math::Transform3DPJ::Point Point
Definition: CrystalPad.h:18
CrystalPad::dummy_
bool dummy_
Definition: CrystalPad.h:112
ROOT::Math::Transform3DPJ::GetDecomposition
void GetDecomposition(Rotation3D &r, Vector &v) const
Definition: Transform3DPJ.cc:164
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
DDAxes::x
CrystalPad::survivalProbability_
double survivalProbability_
Definition: CrystalPad.h:109
vec2
std::vector< vec1 > vec2
Definition: HCALResponse.h:16
CrystalPad::center
const CLHEP::Hep2Vector & center() const
get the center
Definition: CrystalPad.h:95
L1TOccupancyClient_cfi.ymax
ymax
Definition: L1TOccupancyClient_cfi.py:43
contentValuesFiles.number
number
Definition: contentValuesFiles.py:53
CrystalPad::trans_
Transform3D trans_
Definition: CrystalPad.h:106
SOUTHEAST
Definition: CaloDirection.h:12
CrystalPad::rotation_
ROOT::Math::Rotation3D rotation_
Definition: CrystalPad.h:107
CrystalPad::aVector
static std::vector< CLHEP::Hep2Vector > aVector
Definition: CrystalPad.h:101
Point
Structure Point Contains parameters of Gaussian fits to DMRs.
Definition: DMRtrends.cc:57
CrystalPad::number_
unsigned number_
Definition: CrystalPad.h:105
diffTwoXMLs.r2
r2
Definition: diffTwoXMLs.py:73
SOUTHWEST
Definition: CaloDirection.h:13
CrystalPad::corners_
std::vector< CLHEP::Hep2Vector > corners_
Definition: CrystalPad.h:103
CrystalPad::getNumber
unsigned getNumber() const
access to the number
Definition: CrystalPad.h:73
XYZPoint
math::XYZVector XYZPoint
Definition: CalorimetryManager.cc:69
CrystalPad::epsilon_
double epsilon_
Definition: CrystalPad.h:111
heppy_batch.val
val
Definition: heppy_batch.py:351
CrystalPad::center_
CLHEP::Hep2Vector center_
Definition: CrystalPad.h:110
L1TOccupancyClient_cfi.ymin
ymin
Definition: L1TOccupancyClient_cfi.py:43
diffTwoXMLs.r1
r1
Definition: diffTwoXMLs.py:53
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
NORTHWEST
Definition: CaloDirection.h:17
NORTHEAST
Definition: CaloDirection.h:16
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
CrystalPad::translation_
XYZVector translation_
Definition: CrystalPad.h:108
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23