CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
List of all members | Public Member Functions | Private Types | Private Attributes
CTPPSToFDetector Class Reference

#include <CTPPSToFDetector.h>

Public Member Functions

void AddHit (double x, double y, double tof)
 
void clear ()
 
 CTPPSToFDetector (int ncellx, int ncelly, double cellw, double cellh, double pitchx, double pitchy, double pos, int res)
 
 CTPPSToFDetector (int ncellx, int ncelly, std::vector< double > &cellw, double cellh, double pitchx, double pitchy, double pos, int res)
 
int findCellId (double x, double y)
 
bool get_CellCenter (int cell_id, double &x, double &y)
 
int get_CellId (int idx)
 
int get_CellMultiplicity ()
 
int get_nHits_ ()
 
std::vector< double > get_ToF (int cell)
 
int getADC (int cell, int hit)
 
double getHeight ()
 
int getMultiplicityByCell (int cellid)
 
double getPosition ()
 
double getWidth ()
 
virtual ~CTPPSToFDetector ()
 

Private Types

typedef std::map< int, std::vector< double > > theToFInfo_t
 

Private Attributes

std::vector< std::pair< double, double > > cellColumn_
 
double cellH_
 
std::vector< std::pair< double, double > > cellRow_
 
std::vector< double > cellW_
 
double cellWq_
 
double detH_
 
int detId_
 
double detPosition_
 
double detW_
 
int fToFResolution_
 
std::map< int, std::vector< int > > nADC_
 
int nCellX_
 
int nCellY_
 
int nHits_
 
double pitchX_
 
double pitchY_
 
std::map< int, std::vector< double > > theToFInfo
 

Detailed Description

Definition at line 8 of file CTPPSToFDetector.h.

Member Typedef Documentation

◆ theToFInfo_t

typedef std::map<int, std::vector<double> > CTPPSToFDetector::theToFInfo_t
private

Definition at line 84 of file CTPPSToFDetector.h.

Constructor & Destructor Documentation

◆ CTPPSToFDetector() [1/2]

CTPPSToFDetector::CTPPSToFDetector ( int  ncellx,
int  ncelly,
std::vector< double > &  cellw,
double  cellh,
double  pitchx,
double  pitchy,
double  pos,
int  res 
)

Definition at line 4 of file CTPPSToFDetector.cc.

6  : nCellX_(ncellx),
7  nCellY_(ncelly),
8  cellW_(cellw),
9  cellH_(cellh),
10  pitchX_(pitchx),
11  pitchY_(pitchy),
13  detPosition_(pos) {
14  // the vertical positions starts from the negative(bottom) to the positive(top) corner
15  // vector index points to the row number from below
16  cellRow_.push_back(std::pair<double, double>(-cellH_ * 0.5, cellH_ * 0.5));
17  cellColumn_.reserve(nCellX_); // vector index points to the column number
18  for (int i = 0; i < nCellX_; i++) {
19  double x1 = 0., x2 = 0.;
20  if (i == 0) {
21  detW_ = pitchX_;
22  x1 = -(detPosition_ + detW_);
23  } else
24  x1 = -detPosition_ + detW_; //detPosition_ - shift the limit of a column depending on the detector position
25  x2 = x1 - cellW_.at(i);
26  detW_ += (x2 - x1) - pitchX_;
27  cellColumn_.push_back(std::pair<double, double>(x1, x2));
28  }
29  //diamond geometry
30  detH_ = nCellY_ * cellH_;
31  detW_ = -detW_ - 2 * pitchX_;
32 };

References cellColumn_, cellH_, cellRow_, cellW_, detH_, detPosition_, detW_, mps_fire::i, nCellX_, nCellY_, pitchX_, testProducerWithPsetDescEmpty_cfi::x1, and testProducerWithPsetDescEmpty_cfi::x2.

◆ CTPPSToFDetector() [2/2]

CTPPSToFDetector::CTPPSToFDetector ( int  ncellx,
int  ncelly,
double  cellw,
double  cellh,
double  pitchx,
double  pitchy,
double  pos,
int  res 
)

Definition at line 34 of file CTPPSToFDetector.cc.

36  : nCellX_(ncellx),
37  nCellY_(ncelly),
38  cellWq_(cellwq),
39  cellH_(cellh),
40  pitchX_(pitchx),
41  pitchY_(pitchy),
43  detPosition_(pos) {
44  //
45  detW_ = nCellX_ * cellWq_ + (nCellX_ - 1) * pitchX_;
46  detH_ = nCellY_ * cellH_ + (nCellY_ - 1) * pitchY_;
47  // the vertical positions starts from the negative(bottom) to the positive(top) corner
48  cellRow_.reserve(nCellY_); // vector index points to the row number from below
49  for (int i = 0; i < nCellY_; i++) {
50  double y1 = cellH_ * (i - nCellY_ * 0.5) + pitchY_ * (i - (nCellY_ - 1) * 0.5);
51  double y2 = y1 + cellH_;
52  cellRow_.push_back(std::pair<double, double>(y1, y2));
53  }
54  cellColumn_.reserve(nCellX_); // vector index points to the column number
55  for (int i = 0; i < nCellX_; i++) {
56  double x1 = -(cellWq_ * i + pitchX_ * i);
57  x1 -= detPosition_; // shift the limit of a column depending on the detector position
58  double x2 = x1 - cellWq_;
59  cellColumn_.push_back(std::pair<double, double>(x1, x2));
60  }
61 };

References cellColumn_, cellH_, cellRow_, cellWq_, detH_, detPosition_, detW_, mps_fire::i, nCellX_, nCellY_, pitchX_, pitchY_, testProducerWithPsetDescEmpty_cfi::x1, testProducerWithPsetDescEmpty_cfi::x2, testProducerWithPsetDescEmpty_cfi::y1, and testProducerWithPsetDescEmpty_cfi::y2.

◆ ~CTPPSToFDetector()

virtual CTPPSToFDetector::~CTPPSToFDetector ( )
inlinevirtual

Definition at line 20 of file CTPPSToFDetector.h.

20 {};

Member Function Documentation

◆ AddHit()

void CTPPSToFDetector::AddHit ( double  x,
double  y,
double  tof 
)

Definition at line 62 of file CTPPSToFDetector.cc.

62  {
63  int cellid = findCellId(x, y);
64  if (cellid == 0)
65  return;
66  if (theToFInfo.find(cellid) == theToFInfo.end())
67  theToFInfo[cellid]; // add empty cell
68  std::vector<double>* tofs = &(theToFInfo.find(cellid)->second);
69  int ntof = tofs->size();
70  int i = 0;
71  double oneOverRes = 1.0 / fToFResolution_;
72  for (; i < ntof; i++) {
73  if (fabs(tofs->at(i) - tof) * oneOverRes < 3) {
74  tofs->at(i) = (tofs->at(i) + tof) / 2.;
75  nADC_.at(cellid).at(i)++;
76  return;
77  }
78  }
79  tofs->push_back(tof); // no other ToF inside resolution found
80  nHits_++;
81  nADC_[cellid].push_back(1);
82 }

References findCellId(), fToFResolution_, mps_fire::i, nADC_, nHits_, theToFInfo, x, and y.

◆ clear()

void CTPPSToFDetector::clear ( void  )
inline

Definition at line 56 of file CTPPSToFDetector.h.

56  {
57  detId_ = 0;
58  nHits_ = 0;
59  theToFInfo.clear();
60  };

References detId_, nHits_, and theToFInfo.

◆ findCellId()

int CTPPSToFDetector::findCellId ( double  x,
double  y 
)

Definition at line 83 of file CTPPSToFDetector.cc.

83  {
84  int y_idx, x_idx;
85  // first, get the row number
86  unsigned int i;
87  unsigned int start_idx = 0;
88  unsigned int end_idx = cellRow_.size();
89  for (i = 0; i < cellRow_.size(); i++) {
90  if (y >= cellRow_.at(i).first && y <= cellRow_.at(i).second)
91  break;
92  }
93  if (i >= cellRow_.size())
94  return 0;
95  y_idx = i + 1;
96  start_idx = 0;
97  end_idx = cellColumn_.size();
98  for (i = start_idx; i < end_idx; i++) {
99  if (x <= cellColumn_.at(i).first && x > cellColumn_.at(i).second)
100  break;
101  }
102  if (i >= end_idx)
103  return 0;
104  x_idx = i + 1 - start_idx;
105  return 100 * y_idx + x_idx;
106 }

References cellColumn_, cellRow_, mps_fire::i, x, and y.

Referenced by AddHit(), CTPPSFastTrackingProducer::FastReco(), and CTPPSRecHitProducer::produce().

◆ get_CellCenter()

bool CTPPSToFDetector::get_CellCenter ( int  cell_id,
double &  x,
double &  y 
)

Definition at line 107 of file CTPPSToFDetector.cc.

107  {
108  if (cell_id == 0)
109  return false;
110  //if(!isValidCellId(cell_id)) return 0;
111  unsigned int y_idx = int(cell_id * 0.01);
112  unsigned int x_idx = cell_id - y_idx * 100;
113  x = (cellColumn_.at(x_idx - 1).first + cellColumn_.at(x_idx - 1).second) / 2.0;
114  y = (cellRow_.at(y_idx - 1).first + cellRow_.at(y_idx - 1).second) / 2.0;
115  return true;
116 }

References cellColumn_, cellRow_, createfilelist::int, x, and y.

Referenced by CTPPSRecHitProducer::produce().

◆ get_CellId()

int CTPPSToFDetector::get_CellId ( int  idx)
inline

Definition at line 27 of file CTPPSToFDetector.h.

27  {
28  if (idx >= (int)theToFInfo.size())
29  return 0;
30  std::map<int, std::vector<double> >::const_iterator it = theToFInfo.begin();
31  std::advance(it, idx);
32  return it->first;
33  }

References heavyIonCSV_trainingSettings::idx, and theToFInfo.

◆ get_CellMultiplicity()

int CTPPSToFDetector::get_CellMultiplicity ( )
inline

Definition at line 34 of file CTPPSToFDetector.h.

34 { return (int)theToFInfo.size(); }; // return the number of cells with hit

References theToFInfo.

◆ get_nHits_()

int CTPPSToFDetector::get_nHits_ ( )
inline

Definition at line 41 of file CTPPSToFDetector.h.

41 { return nHits_; }; // return the total hit multiplicity (full det)

References nHits_.

◆ get_ToF()

std::vector<double> CTPPSToFDetector::get_ToF ( int  cell)
inline

Definition at line 42 of file CTPPSToFDetector.h.

42  {
43  if (!theToFInfo.count(cell))
44  return std::vector<double>();
45  return theToFInfo.at(cell);
46  }; // return the tof of the given cell

References theToFInfo.

◆ getADC()

int CTPPSToFDetector::getADC ( int  cell,
int  hit 
)
inline

Definition at line 47 of file CTPPSToFDetector.h.

47  {
48  if (!nADC_.count(cell))
49  return 0;
50  if ((int)nADC_.at(cell).size() < hit)
51  return 0;
52  return nADC_.at(cell).at(hit);
53  }

References nADC_.

◆ getHeight()

double CTPPSToFDetector::getHeight ( )
inline

Definition at line 22 of file CTPPSToFDetector.h.

22 { return detH_; };

References detH_.

◆ getMultiplicityByCell()

int CTPPSToFDetector::getMultiplicityByCell ( int  cellid)
inline

Definition at line 35 of file CTPPSToFDetector.h.

35  {
36  if (!theToFInfo.count(cellid))
37  return 0;
38  return (int)theToFInfo.at(cellid).size();
39  }; // return the hit multiplicity of the given cell

References theToFInfo.

◆ getPosition()

double CTPPSToFDetector::getPosition ( )
inline

Definition at line 24 of file CTPPSToFDetector.h.

24 { return detPosition_; };

References detPosition_.

◆ getWidth()

double CTPPSToFDetector::getWidth ( )
inline

Definition at line 23 of file CTPPSToFDetector.h.

23 { return detW_; };

References detW_.

Member Data Documentation

◆ cellColumn_

std::vector<std::pair<double, double> > CTPPSToFDetector::cellColumn_
private

Definition at line 71 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector(), findCellId(), and get_CellCenter().

◆ cellH_

double CTPPSToFDetector::cellH_
private

Definition at line 67 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

◆ cellRow_

std::vector<std::pair<double, double> > CTPPSToFDetector::cellRow_
private

Definition at line 72 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector(), findCellId(), and get_CellCenter().

◆ cellW_

std::vector<double> CTPPSToFDetector::cellW_
private

Definition at line 66 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

◆ cellWq_

double CTPPSToFDetector::cellWq_
private

Definition at line 65 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

◆ detH_

double CTPPSToFDetector::detH_
private

Definition at line 75 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector(), and getHeight().

◆ detId_

int CTPPSToFDetector::detId_
private

Definition at line 78 of file CTPPSToFDetector.h.

Referenced by clear().

◆ detPosition_

double CTPPSToFDetector::detPosition_
private

Definition at line 76 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector(), and getPosition().

◆ detW_

double CTPPSToFDetector::detW_
private

Definition at line 74 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector(), and getWidth().

◆ fToFResolution_

int CTPPSToFDetector::fToFResolution_
private

Definition at line 70 of file CTPPSToFDetector.h.

Referenced by AddHit().

◆ nADC_

std::map<int, std::vector<int> > CTPPSToFDetector::nADC_
private

Definition at line 80 of file CTPPSToFDetector.h.

Referenced by AddHit(), and getADC().

◆ nCellX_

int CTPPSToFDetector::nCellX_
private

Definition at line 60 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

◆ nCellY_

int CTPPSToFDetector::nCellY_
private

Definition at line 64 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

◆ nHits_

int CTPPSToFDetector::nHits_
private

Definition at line 79 of file CTPPSToFDetector.h.

Referenced by AddHit(), clear(), and get_nHits_().

◆ pitchX_

double CTPPSToFDetector::pitchX_
private

Definition at line 68 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

◆ pitchY_

double CTPPSToFDetector::pitchY_
private

Definition at line 69 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

◆ theToFInfo

std::map<int, std::vector<double> > CTPPSToFDetector::theToFInfo
private
DDAxes::y
mps_fire.i
i
Definition: mps_fire.py:428
CTPPSToFDetector::nHits_
int nHits_
Definition: CTPPSToFDetector.h:79
testProducerWithPsetDescEmpty_cfi.x2
x2
Definition: testProducerWithPsetDescEmpty_cfi.py:28
CTPPSToFDetector::pitchX_
double pitchX_
Definition: CTPPSToFDetector.h:68
pos
Definition: PixelAliasList.h:18
CTPPSToFDetector::cellH_
double cellH_
Definition: CTPPSToFDetector.h:67
CTPPSToFDetector::cellWq_
double cellWq_
Definition: CTPPSToFDetector.h:65
CTPPSToFDetector::pitchY_
double pitchY_
Definition: CTPPSToFDetector.h:69
DDAxes::x
CTPPSToFDetector::detW_
double detW_
Definition: CTPPSToFDetector.h:74
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
testProducerWithPsetDescEmpty_cfi.x1
x1
Definition: testProducerWithPsetDescEmpty_cfi.py:33
testProducerWithPsetDescEmpty_cfi.y1
y1
Definition: testProducerWithPsetDescEmpty_cfi.py:29
CTPPSToFDetector::cellRow_
std::vector< std::pair< double, double > > cellRow_
Definition: CTPPSToFDetector.h:72
CTPPSToFDetector::fToFResolution_
int fToFResolution_
Definition: CTPPSToFDetector.h:70
testProducerWithPsetDescEmpty_cfi.y2
y2
Definition: testProducerWithPsetDescEmpty_cfi.py:30
createfilelist.int
int
Definition: createfilelist.py:10
CTPPSToFDetector::nADC_
std::map< int, std::vector< int > > nADC_
Definition: CTPPSToFDetector.h:80
CTPPSToFDetector::findCellId
int findCellId(double x, double y)
Definition: CTPPSToFDetector.cc:83
res
Definition: Electron.h:6
CTPPSToFDetector::detPosition_
double detPosition_
Definition: CTPPSToFDetector.h:76
CTPPSToFDetector::cellColumn_
std::vector< std::pair< double, double > > cellColumn_
Definition: CTPPSToFDetector.h:71
CTPPSToFDetector::nCellX_
int nCellX_
Definition: CTPPSToFDetector.h:60
CTPPSToFDetector::nCellY_
int nCellY_
Definition: CTPPSToFDetector.h:64
CTPPSToFDetector::detId_
int detId_
Definition: CTPPSToFDetector.h:78
hit
Definition: SiStripHitEffFromCalibTree.cc:88
CTPPSToFDetector::theToFInfo
std::map< int, std::vector< double > > theToFInfo
Definition: CTPPSToFDetector.h:82
CTPPSToFDetector::detH_
double detH_
Definition: CTPPSToFDetector.h:75
CTPPSToFDetector::cellW_
std::vector< double > cellW_
Definition: CTPPSToFDetector.h:66