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 63 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 5 of file CTPPSToFDetector.cc.

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

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

Definition at line 24 of file CTPPSToFDetector.cc.

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

24  :
25  nCellX_(ncellx),nCellY_(ncelly),cellWq_(cellwq),cellH_(cellh),pitchX_(pitchx),pitchY_(pitchy),fToFResolution_(res),detPosition_(pos) {
26  //
29  // the vertical positions starts from the negative(bottom) to the positive(top) corner
30  cellRow_.reserve(nCellY_); // vector index points to the row number from below
31  for(int i=0;i<nCellY_;i++) {
32  double y1=cellH_*(i-nCellY_*0.5)+pitchY_*(i-(nCellY_-1)*0.5);
33  double y2=y1+cellH_;
34  cellRow_.push_back(std::pair<double,double>(y1,y2));
35  }
36  cellColumn_.reserve(nCellX_);// vector index points to the column number
37  for(int i=0;i<nCellX_;i++) {
38  double x1 = -(cellWq_*i+pitchX_*i);
39  x1-=detPosition_; // shift the limit of a column depending on the detector position
40  double x2 = x1-cellWq_;
41  cellColumn_.push_back(std::pair<double,double>(x1,x2));
42  }
43  };
Definition: Electron.h:4
std::vector< std::pair< double, double > > cellRow_
std::vector< std::pair< double, double > > cellColumn_
virtual CTPPSToFDetector::~CTPPSToFDetector ( )
inlinevirtual

Definition at line 12 of file CTPPSToFDetector.h.

12 {};

Member Function Documentation

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

Definition at line 44 of file CTPPSToFDetector.cc.

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

Referenced by getADC().

44  {
45  int cellid = findCellId(x,y);
46  if (cellid==0) return;
47  if (theToFInfo.find(cellid)==theToFInfo.end()) theToFInfo[cellid]; // add empty cell
48  std::vector<double>* tofs = &(theToFInfo.find(cellid)->second);
49  int ntof = tofs->size();
50  int i=0; double oneOverRes=1.0/fToFResolution_;
51  for(;i<ntof;i++) {
52  if (fabs(tofs->at(i)-tof)*oneOverRes<3) {
53  tofs->at(i)=(tofs->at(i)+tof)/2.;
54  nADC_.at(cellid).at(i)++;
55  return;
56  }
57  }
58  tofs->push_back(tof); // no other ToF inside resolution found
59  nHits_++;
60  nADC_[cellid].push_back(1);
61 }
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 62 of file CTPPSToFDetector.cc.

References cellColumn_, cellRow_, and mps_fire::i.

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

63 {
64  int y_idx,x_idx;
65  // first, get the row number
66  unsigned int i;
67  unsigned int start_idx=0;
68  unsigned int end_idx=cellRow_.size();
69  for(i=0;i<cellRow_.size();i++){
70  if (y>=cellRow_.at(i).first&&y<=cellRow_.at(i).second) break;
71  }
72  if (i>=cellRow_.size()) return 0;
73  y_idx = i+1;
74  start_idx=0;end_idx=cellColumn_.size();
75  for(i=start_idx;i<end_idx;i++) {
76  if (x<=cellColumn_.at(i).first&&x>cellColumn_.at(i).second) break;
77  }
78  if (i>=end_idx) return 0;
79  x_idx=i+1-start_idx;
80  return 100*y_idx+x_idx;
81 }
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 82 of file CTPPSToFDetector.cc.

References cellColumn_, cellRow_, and createfilelist::int.

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

83 {
84  if (cell_id==0) return false;
85  //if(!isValidCellId(cell_id)) return 0;
86  unsigned int y_idx=int(cell_id*0.01);
87  unsigned int x_idx=cell_id-y_idx*100;
88  x = (cellColumn_.at(x_idx-1).first+cellColumn_.at(x_idx-1).second)/2.0;
89  y = (cellRow_.at(y_idx-1).first+cellRow_.at(y_idx-1).second)/2.0;
90  return true;
91 }
std::vector< std::pair< double, double > > cellRow_
std::vector< std::pair< double, double > > cellColumn_
int CTPPSToFDetector::get_CellId ( int  idx)
inline

Definition at line 19 of file CTPPSToFDetector.h.

References theToFInfo.

19  {if (idx>=(int)theToFInfo.size()) return 0;
20  std::map<int,std::vector<double> >::const_iterator it=theToFInfo.begin();
21  std::advance(it,idx);
22  return it->first;
23  }
std::map< int, std::vector< double > > theToFInfo
int CTPPSToFDetector::get_CellMultiplicity ( )
inline

Definition at line 24 of file CTPPSToFDetector.h.

References theToFInfo.

24 {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 28 of file CTPPSToFDetector.h.

References nHits_.

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

Definition at line 29 of file CTPPSToFDetector.h.

References theToFInfo.

29  {if (!theToFInfo.count(cell)) return std::vector<double>();
30  return theToFInfo.at(cell);
31  }; // 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 32 of file CTPPSToFDetector.h.

References AddHit(), and nADC_.

32  {
33  if (!nADC_.count(cell)) return 0;
34  if ((int)nADC_.at(cell).size()<hit) return 0;
35  return nADC_.at(cell).at(hit);
36  }
std::map< int, std::vector< int > > nADC_
double CTPPSToFDetector::getHeight ( )
inline

Definition at line 14 of file CTPPSToFDetector.h.

References detH_.

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

Definition at line 25 of file CTPPSToFDetector.h.

References theToFInfo.

25  {if (!theToFInfo.count(cellid)) return 0;
26  return (int)theToFInfo.at(cellid).size();}; // return the hit multiplicity of the given cell
std::map< int, std::vector< double > > theToFInfo
double CTPPSToFDetector::getPosition ( )
inline

Definition at line 16 of file CTPPSToFDetector.h.

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

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

Definition at line 15 of file CTPPSToFDetector.h.

References detW_.

15 {return detW_;};

Member Data Documentation

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

Definition at line 50 of file CTPPSToFDetector.h.

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

double CTPPSToFDetector::cellH_
private

Definition at line 46 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

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

Definition at line 51 of file CTPPSToFDetector.h.

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

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

Definition at line 45 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

double CTPPSToFDetector::cellWq_
private

Definition at line 44 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

double CTPPSToFDetector::detH_
private

Definition at line 54 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector(), and getHeight().

int CTPPSToFDetector::detId_
private

Definition at line 57 of file CTPPSToFDetector.h.

double CTPPSToFDetector::detPosition_
private

Definition at line 55 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector(), and getPosition().

double CTPPSToFDetector::detW_
private

Definition at line 53 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector(), and getWidth().

int CTPPSToFDetector::fToFResolution_
private

Definition at line 49 of file CTPPSToFDetector.h.

Referenced by AddHit().

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

Definition at line 59 of file CTPPSToFDetector.h.

Referenced by AddHit(), and getADC().

int CTPPSToFDetector::nCellX_
private

Definition at line 40 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

int CTPPSToFDetector::nCellY_
private

Definition at line 43 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

int CTPPSToFDetector::nHits_
private

Definition at line 58 of file CTPPSToFDetector.h.

Referenced by AddHit(), and get_nHits_().

double CTPPSToFDetector::pitchX_
private

Definition at line 47 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

double CTPPSToFDetector::pitchY_
private

Definition at line 48 of file CTPPSToFDetector.h.

Referenced by CTPPSToFDetector().

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