test
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 Member Functions | Private Attributes
FastTimeDDDConstants Class Reference

#include <FastTimeDDDConstants.h>

Public Member Functions

int computeCells () const
 
 FastTimeDDDConstants (const DDCompactView &cpv)
 
int getCells () const
 
int getType () const
 
std::pair< int, int > getXY (int copy) const
 
std::pair< int, int > getXY (double x, double y) const
 
bool isValidCell (int copy) const
 
bool isValidXY (int ix, int iy) const
 
int quadrant (int ix, int iy) const
 
int quadrant (int copy) const
 
 ~FastTimeDDDConstants ()
 

Private Member Functions

std::vector< double > getDDDArray (const std::string &, const DDsvalues_type &) const
 
void initialize (const DDCompactView &cpv)
 
void loadSpecPars (const DDFilteredView &fv)
 

Private Attributes

double cellSize
 
int cellType
 
std::vector< int > firstCell
 
std::vector< int > firstY
 
std::vector< int > lastCell
 
std::vector< int > lastY
 
int nCells
 
int nCols
 
int nRows
 
double rIn
 
double rOut
 

Detailed Description

this class reads the constant section of the numbering xml-file for fast timer device

Date:
2014/03/20 00:06:50
Author
Sunanda Banerjee, SINP sunan.nosp@m.da.b.nosp@m.anerj.nosp@m.ee@c.nosp@m.ern.c.nosp@m.h

Definition at line 23 of file FastTimeDDDConstants.h.

Constructor & Destructor Documentation

FastTimeDDDConstants::FastTimeDDDConstants ( const DDCompactView cpv)

Definition at line 16 of file FastTimeDDDConstants.cc.

References initialize().

16  {
17 
18 #ifdef DebugLog
19  edm::LogInfo("HGCalGeom") << "FastTimeDDDConstants::FastTimeDDDConstants ( const DDCompactView& cpv ) constructor";
20 #endif
21  initialize(cpv);
22 
23 }
void initialize(const DDCompactView &cpv)
FastTimeDDDConstants::~FastTimeDDDConstants ( )

Definition at line 25 of file FastTimeDDDConstants.cc.

References gather_cfg::cout.

25  {
26 #ifdef DebugLog
27  std::cout << "FastTimeDDDConstants:destructed!!!" << std::endl;
28 #endif
29 }
tuple cout
Definition: gather_cfg.py:145

Member Function Documentation

int FastTimeDDDConstants::computeCells ( ) const

Definition at line 31 of file FastTimeDDDConstants.cc.

References cellSize, filterCSVwithJSON::copy, gather_cfg::cout, rIn, rOut, and mathSSE::sqrt().

31  {
32 
33  int copy(0);
34 #ifdef DebugLog
35  int column(0), rowmax(0);
36 #endif
37  double offsetX (0), offsetY(0);
38  while (offsetX < rOut) {
39 #ifdef DebugLog
40  column++;
41  int row(0);
42 #endif
43  while (offsetY <rOut) {
44 #ifdef DebugLog
45  row++;
46 #endif
47  double limit1 = sqrt((offsetX+cellSize)*(offsetX+cellSize) +
48  (offsetY+cellSize)*(offsetY+cellSize));
49  double limit2 = sqrt(offsetX*offsetX+offsetY*offsetY);
50  if (limit2 > rIn && limit1 < rOut) copy++;
51  offsetY += cellSize;
52  }
53 #ifdef DebugLog
54  if (row > rowmax) rowmax = row;
55 #endif
56  offsetY = 0;
57  offsetX += cellSize;
58  }
59 #ifdef DebugLog
60  std::cout << rowmax << " rows and " << column << " columns with total of "
61  << copy << " cells in a quadrant " << std::endl;
62 #endif
63  return 4*copy;
64 }
T sqrt(T t)
Definition: SSEVec.h:18
tuple cout
Definition: gather_cfg.py:145
int FastTimeDDDConstants::getCells ( ) const
inline

Definition at line 34 of file FastTimeDDDConstants.h.

References nCells.

Referenced by isValidCell().

34 {return 4*nCells;}
std::vector< double > FastTimeDDDConstants::getDDDArray ( const std::string &  str,
const DDsvalues_type sv 
) const
private

Definition at line 228 of file FastTimeDDDConstants.cc.

References gather_cfg::cout, DDfetch(), DDValue::doubles(), Exception, and relativeConstraints::value.

Referenced by loadSpecPars().

229  {
230 
231 #ifdef DebugLog
232  std::cout << "FastTimeDDDConstants:getDDDArray called for " << str << std::endl;
233 #endif
234  DDValue value(str);
235  if (DDfetch(&sv,value)) {
236 #ifdef DebugLog
237  std::cout << "FastTimeDDDConstants: " << value << std::endl;
238 #endif
239  const std::vector<double> & fvec = value.doubles();
240  int nval = fvec.size();
241  if (nval > 0) return fvec;
242  }
243  edm::LogError("HGCalGeom") << "FastTimeDDDConstants: cannot get array "
244  << str;
245  throw cms::Exception("DDException") << "FastTimeDDDConstants: cannot get array " << str;
246 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:80
tuple cout
Definition: gather_cfg.py:145
int FastTimeDDDConstants::getType ( void  ) const
inline

Definition at line 31 of file FastTimeDDDConstants.h.

References cellType.

Referenced by FastTimerSD::FastTimerSD().

std::pair< int, int > FastTimeDDDConstants::getXY ( int  copy) const

Definition at line 66 of file FastTimeDDDConstants.cc.

References firstCell, firstY, ecalpyutils::ism(), relval_2017::k, lastCell, nCells, nCols, nRows, and quadrant().

Referenced by FastTimerSD::setDetUnitId().

66  {
67 
68  int iq = quadrant(copy);
69  if (iq != 0) {
70  int ism = copy - (iq-1)*nCells;
71  int jx(0), jy(0);
72  for (unsigned int k=0; k<firstY.size(); ++k) {
73  if (ism >= firstCell[k] && ism <= lastCell[k]) {
74  jx = k + 1;
75  jy = ism - firstCell[k] + firstY[k];
76  break;
77  }
78  }
79  int ix = (iq == 1 || iq == 4) ? (jx + nCols) : (nCols+1-jx);
80  int iy = (iq == 1 || iq == 2) ? (jy + nRows) : (nRows+1-jy);
81  return std::pair<int,int>(ix,iy);
82  } else {
83  return std::pair<int,int>(0,0);
84  }
85 }
int quadrant(int ix, int iy) const
std::vector< int > firstCell
std::vector< int > firstY
std::vector< int > lastCell
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
std::pair< int, int > FastTimeDDDConstants::getXY ( double  x,
double  y 
) const

Definition at line 87 of file FastTimeDDDConstants.cc.

References cellSize, isValidXY(), nCols, and nRows.

87  {
88 
89  int jx = floor(fabs(x)/cellSize);
90  int jy = floor(fabs(y)/cellSize);
91  int iq(0);
92  if (x < 0) {
93  if (y < 0) iq = 3;
94  else iq = 2;
95  } else {
96  if (y < 0) iq = 4;
97  else iq = 1;
98  }
99  int ix = (iq == 1 || iq == 4) ? (jx + nCols) : (nCols+1-jx);
100  int iy = (iq == 1 || iq == 2) ? (jy + nRows) : (nRows+1-jy);
101  if (isValidXY(ix,iy)) {
102  return std::pair<int,int>(ix,iy);
103  } else {
104  return std::pair<int,int>(0,0);
105  }
106 }
bool isValidXY(int ix, int iy) const
void FastTimeDDDConstants::initialize ( const DDCompactView cpv)
private

Definition at line 152 of file FastTimeDDDConstants.cc.

References DDFilteredView::addFilter(), equals, Exception, alcazmumu_cfi::filter, DDFilteredView::firstChild(), loadSpecPars(), convertSQLiteXML::ok, DDSpecificsFilter::setCriteria(), AlCaHLTBitMon_QueryRunRegistry::string, and relativeConstraints::value.

Referenced by FastTimeDDDConstants().

152  {
153 
154  std::string attribute = "Volume";
155  std::string value = "SFBX";
156  DDValue val(attribute, value, 0.0);
157 
159  filter.setCriteria(val, DDCompOp::equals);
160  DDFilteredView fv(cpv);
161  fv.addFilter(filter);
162  bool ok = fv.firstChild();
163 
164  if (ok) {
165  loadSpecPars(fv);
166  } else {
167  edm::LogError("HGCalGeom") << "FastTimeDDDConstants: cannot get filtered"
168  << " view for " << attribute
169  << " not matching " << value;
170  throw cms::Exception("DDException") << "FastTimeDDDConstants: cannot match " << attribute << " to " << value;
171  }
172 }
void loadSpecPars(const DDFilteredView &fv)
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:245
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:32
bool FastTimeDDDConstants::isValidCell ( int  copy) const

Definition at line 120 of file FastTimeDDDConstants.cc.

References getCells(), and convertSQLiteXML::ok.

120  {
121  bool ok = (copy > 0 && copy <= getCells());
122  return ok;
123 }
bool FastTimeDDDConstants::isValidXY ( int  ix,
int  iy 
) const

Definition at line 108 of file FastTimeDDDConstants.cc.

References firstY, lastY, nCols, nRows, convertSQLiteXML::ok, and quadrant().

Referenced by getXY().

108  {
109  int iq = quadrant(ix,iy);
110  if (iq != 0) {
111  int kx = (iq == 1 || iq == 4) ? (ix-nCols) : (nCols-1-ix);
112  int ky = (iq == 1 || iq == 2) ? (iy-nRows) : (nRows-1-iy);
113  bool ok = (ky+1 >= firstY[kx] && ky+1 <= lastY[kx]);
114  return ok;
115  } else {
116  return false;
117  }
118 }
int quadrant(int ix, int iy) const
std::vector< int > firstY
std::vector< int > lastY
void FastTimeDDDConstants::loadSpecPars ( const DDFilteredView fv)
private

Definition at line 174 of file FastTimeDDDConstants.cc.

References cellSize, cellType, gather_cfg::cout, dbl_to_int(), Exception, firstCell, firstY, getDDDArray(), relval_2017::k, lastCell, lastY, DDFilteredView::mergedSpecifics(), nCells, nCols, nRows, rIn, and rOut.

Referenced by initialize().

174  {
175 
177 
178  // First and Last Row number in each column
179  firstY = dbl_to_int(getDDDArray("firstRow",sv));
180  lastY = dbl_to_int(getDDDArray("lastRow", sv));
181  if (firstY.size() != lastY.size()) {
182  edm::LogError("HGCalGeom") << "FastTimeDDDConstants: unequal numbers "
183  << firstY.size() << ":" << lastY.size()
184  << " elements for first and last rows";
185  throw cms::Exception("DDException") << "FastTimeDDDConstants: wrong array sizes for first/last Row";
186  }
187 
188  nCells = 0;
189  nCols = (int)(firstY.size());
190  nRows = 0;
191  for (int k=0; k<nCols; ++k) {
192  firstCell.push_back(nCells+1);
193  nCells += (lastY[k]-firstY[k]+1);
194  lastCell.push_back(nCells);
195  if (lastY[k] > nRows) nRows = lastY[k];
196  }
197 
198 #ifdef DebugLog
199  std::cout << "FastTimeDDDConstants: nCells = " << nCells << ", nRow = "
200  << 2*nRows << ", nColumns = " << 2*nCols << std::endl;
201  for (int k=0; k<nCols; ++k)
202  std::cout << "Column[" << k << "] Cells = " << firstCell[k] << ":"
203  << lastCell[k] << ", Rows = " << firstY[k] << ":" << lastY[k]
204  << std::endl;
205 #endif
206 
207  std::vector<double> gpar = getDDDArray("geomPars",sv);
208  if (gpar.size() < 3) {
209  edm::LogError("HGCalGeom") << "FastTimeDDDConstants: too few "
210  << gpar.size() << " elements for gpar";
211  throw cms::Exception("DDException") << "FastTimeDDDConstants: wrong array sizes for gpar";
212  }
213  rIn = gpar[0];
214  rOut = gpar[1];
215  cellSize = gpar[2];
216 #ifdef DebugLog
217  std::cout << "FastTimeDDDConstants: cellsize " << cellSize << " in region "
218  << rIn << ":" << rOut << std::endl;
219 #endif
220 
221  gpar = getDDDArray("geomType",sv);
222  cellType = int(gpar[0]);
223 #ifdef DebugLog
224  std::cout << "FastTimeDDDConstants: cell type " << cellType << std::endl;
225 #endif
226 }
std::vector< int > dbl_to_int(const std::vector< double > &vecdbl)
Converts a std::vector of doubles to a std::vector of int.
Definition: DDutils.cc:4
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
Definition: DDsvalues.h:19
std::vector< int > firstCell
std::vector< int > firstY
std::vector< int > lastCell
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &) const
DDsvalues_type mergedSpecifics() const
std::vector< int > lastY
tuple cout
Definition: gather_cfg.py:145
int FastTimeDDDConstants::quadrant ( int  ix,
int  iy 
) const

Definition at line 125 of file FastTimeDDDConstants.cc.

References nCols, and nRows.

Referenced by getXY(), and isValidXY().

125  {
126  int iq(0);
127  if (ix>nCols && ix<=2*nCols) {
128  if (iy>nRows && iy<=2*nRows) iq = 1;
129  else if (iy>0 && iy<=nRows) iq = 4;
130  } else if (ix>0 && ix<=nCols) {
131  if (iy>nRows && iy<=2*nRows) iq = 2;
132  else if (iy>0 && iy<=nRows) iq = 3;
133  }
134  return iq;
135 }
int FastTimeDDDConstants::quadrant ( int  copy) const

Definition at line 137 of file FastTimeDDDConstants.cc.

References nCells.

137  {
138  int iq(0);
139  if (copy > 4*nCells) {
140  } else if (copy > 3*nCells) {
141  iq = 4;
142  } else if (copy > 2*nCells) {
143  iq = 3;
144  } else if (copy > nCells) {
145  iq = 2;
146  } else if (copy > 0) {
147  iq = 1;
148  }
149  return iq;
150 }

Member Data Documentation

double FastTimeDDDConstants::cellSize
private

Definition at line 47 of file FastTimeDDDConstants.h.

Referenced by computeCells(), getXY(), and loadSpecPars().

int FastTimeDDDConstants::cellType
private

Definition at line 46 of file FastTimeDDDConstants.h.

Referenced by getType(), and loadSpecPars().

std::vector<int> FastTimeDDDConstants::firstCell
private

Definition at line 48 of file FastTimeDDDConstants.h.

Referenced by getXY(), and loadSpecPars().

std::vector<int> FastTimeDDDConstants::firstY
private

Definition at line 48 of file FastTimeDDDConstants.h.

Referenced by getXY(), isValidXY(), and loadSpecPars().

std::vector<int> FastTimeDDDConstants::lastCell
private

Definition at line 48 of file FastTimeDDDConstants.h.

Referenced by getXY(), and loadSpecPars().

std::vector<int> FastTimeDDDConstants::lastY
private

Definition at line 48 of file FastTimeDDDConstants.h.

Referenced by isValidXY(), and loadSpecPars().

int FastTimeDDDConstants::nCells
private

Definition at line 46 of file FastTimeDDDConstants.h.

Referenced by getCells(), getXY(), loadSpecPars(), and quadrant().

int FastTimeDDDConstants::nCols
private

Definition at line 46 of file FastTimeDDDConstants.h.

Referenced by getXY(), isValidXY(), loadSpecPars(), and quadrant().

int FastTimeDDDConstants::nRows
private

Definition at line 46 of file FastTimeDDDConstants.h.

Referenced by getXY(), isValidXY(), loadSpecPars(), and quadrant().

double FastTimeDDDConstants::rIn
private

Definition at line 47 of file FastTimeDDDConstants.h.

Referenced by computeCells(), and loadSpecPars().

double FastTimeDDDConstants::rOut
private

Definition at line 47 of file FastTimeDDDConstants.h.

Referenced by computeCells(), and loadSpecPars().