CMS 3D CMS Logo

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, std::vector< double > &cellw, double cellh, double pitchx, double pitchy, double pos, int res)
 
 CTPPSToFDetector (int ncellx, int ncelly, 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

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

Definition at line 84 of file CTPPSToFDetector.h.

Constructor & Destructor Documentation

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.

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

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 };
std::vector< std::pair< double, double > > cellRow_
Definition: Electron.h:6
std::vector< std::pair< double, double > > cellColumn_
std::vector< double > cellW_
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.

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.

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 };
std::vector< std::pair< double, double > > cellRow_
Definition: Electron.h:6
std::vector< std::pair< double, double > > cellColumn_
virtual CTPPSToFDetector::~CTPPSToFDetector ( )
inlinevirtual

Definition at line 20 of file CTPPSToFDetector.h.

20 {};

Member Function Documentation

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

Definition at line 62 of file CTPPSToFDetector.cc.

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

Referenced by getADC().

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 }
int findCellId(double x, double y)
std::map< int, std::vector< int > > nADC_
std::map< int, std::vector< double > > theToFInfo
void CTPPSToFDetector::clear ( void  )
inline
int CTPPSToFDetector::findCellId ( double  x,
double  y 
)

Definition at line 83 of file CTPPSToFDetector.cc.

References cellColumn_, cellRow_, and mps_fire::i.

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

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 }
std::vector< std::pair< double, double > > cellRow_
std::vector< std::pair< double, double > > cellColumn_
bool CTPPSToFDetector::get_CellCenter ( int  cell_id,
double &  x,
double &  y 
)

Definition at line 107 of file CTPPSToFDetector.cc.

References cellColumn_, cellRow_, and createfilelist::int.

Referenced by getPosition(), and CTPPSRecHitProducer::produce().

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 }
std::vector< std::pair< double, double > > cellRow_
std::vector< std::pair< double, double > > cellColumn_
int CTPPSToFDetector::get_CellId ( int  idx)
inline

Definition at line 27 of file CTPPSToFDetector.h.

References theToFInfo.

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  }
std::map< int, std::vector< double > > theToFInfo
int CTPPSToFDetector::get_CellMultiplicity ( )
inline

Definition at line 34 of file CTPPSToFDetector.h.

References theToFInfo.

34 { return (int)theToFInfo.size(); }; // return the number of cells with hit
std::map< int, std::vector< double > > theToFInfo
int CTPPSToFDetector::get_nHits_ ( )
inline

Definition at line 41 of file CTPPSToFDetector.h.

References nHits_.

41 { return nHits_; }; // return the total hit multiplicity (full det)
std::vector<double> CTPPSToFDetector::get_ToF ( int  cell)
inline

Definition at line 42 of file CTPPSToFDetector.h.

References theToFInfo.

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

Definition at line 47 of file CTPPSToFDetector.h.

References AddHit(), and nADC_.

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  }
std::map< int, std::vector< int > > nADC_
double CTPPSToFDetector::getHeight ( )
inline

Definition at line 22 of file CTPPSToFDetector.h.

References detH_.

22 { return detH_; };
int CTPPSToFDetector::getMultiplicityByCell ( int  cellid)
inline

Definition at line 35 of file CTPPSToFDetector.h.

References theToFInfo.

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
std::map< int, std::vector< double > > theToFInfo
double CTPPSToFDetector::getPosition ( )
inline

Definition at line 24 of file CTPPSToFDetector.h.

References detPosition_, findCellId(), get_CellCenter(), x, and y.

24 { return detPosition_; };
double CTPPSToFDetector::getWidth ( )
inline

Definition at line 23 of file CTPPSToFDetector.h.

References detW_.

23 { return detW_; };

Member Data Documentation

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

Definition at line 71 of file CTPPSToFDetector.h.

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

double CTPPSToFDetector::cellH_
private

Definition at line 67 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

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

Definition at line 72 of file CTPPSToFDetector.h.

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

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

Definition at line 66 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

double CTPPSToFDetector::cellWq_
private

Definition at line 65 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

double CTPPSToFDetector::detH_
private

Definition at line 75 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector(), and getHeight().

int CTPPSToFDetector::detId_
private

Definition at line 78 of file CTPPSToFDetector.h.

Referenced by clear().

double CTPPSToFDetector::detPosition_
private

Definition at line 76 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector(), and getPosition().

double CTPPSToFDetector::detW_
private

Definition at line 74 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector(), and getWidth().

int CTPPSToFDetector::fToFResolution_
private

Definition at line 70 of file CTPPSToFDetector.h.

Referenced by AddHit().

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

Definition at line 80 of file CTPPSToFDetector.h.

Referenced by AddHit(), and getADC().

int CTPPSToFDetector::nCellX_
private

Definition at line 60 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

int CTPPSToFDetector::nCellY_
private

Definition at line 64 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

int CTPPSToFDetector::nHits_
private

Definition at line 79 of file CTPPSToFDetector.h.

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

double CTPPSToFDetector::pitchX_
private

Definition at line 68 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

double CTPPSToFDetector::pitchY_
private

Definition at line 69 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

std::map<int, std::vector<double> > CTPPSToFDetector::theToFInfo
private