Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:14

0001 #ifndef CTPPSToFDetector_h
0002 #define CTPPSToFDetector_h
0003 #include <vector>
0004 #include <map>
0005 #include <iterator>
0006 #include <iostream>
0007 
0008 class CTPPSToFDetector {
0009 public:
0010   CTPPSToFDetector(int ncellx,
0011                    int ncelly,
0012                    std::vector<double>& cellw,
0013                    double cellh,
0014                    double pitchx,
0015                    double pitchy,
0016                    double pos,
0017                    int res);
0018   CTPPSToFDetector(
0019       int ncellx, int ncelly, double cellw, double cellh, double pitchx, double pitchy, double pos, int res);
0020   virtual ~CTPPSToFDetector(){};
0021 
0022   double getHeight() { return detH_; };
0023   double getWidth() { return detW_; };
0024   double getPosition() { return detPosition_; };
0025   int findCellId(double x, double y);                      // return the cell id corresponding to the given position
0026   bool get_CellCenter(int cell_id, double& x, double& y);  // return false if it failed
0027   int get_CellId(int idx) {
0028     if (idx >= (int)theToFInfo.size())
0029       return 0;
0030     std::map<int, std::vector<double> >::const_iterator it = theToFInfo.begin();
0031     std::advance(it, idx);
0032     return it->first;
0033   }
0034   int get_CellMultiplicity() { return (int)theToFInfo.size(); };  // return the number of cells with hit
0035   int getMultiplicityByCell(int cellid) {
0036     if (!theToFInfo.count(cellid))
0037       return 0;
0038     return (int)theToFInfo.at(cellid).size();
0039   };  // return the hit multiplicity of the given cell
0040 
0041   int get_nHits_() { return nHits_; };  // return the total hit multiplicity (full det)
0042   std::vector<double> get_ToF(int cell) {
0043     if (!theToFInfo.count(cell))
0044       return std::vector<double>();
0045     return theToFInfo.at(cell);
0046   };  // return the tof of the given cell
0047   int getADC(int cell, int hit) {
0048     if (!nADC_.count(cell))
0049       return 0;
0050     if ((int)nADC_.at(cell).size() < hit)
0051       return 0;
0052     return nADC_.at(cell).at(hit);
0053   }
0054 
0055   void AddHit(double x, double y, double tof);
0056   void clear() {
0057     detId_ = 0;
0058     nHits_ = 0;
0059     theToFInfo.clear();
0060   };
0061 
0062 private:
0063   int nCellX_;
0064   int nCellY_;
0065   double cellWq_;                                       // width (X, horizontal dimension in mm)
0066   std::vector<double> cellW_;                           //move to vector - diamond geometry
0067   double cellH_;                                        // height(Y, vertical dimension in mm)
0068   double pitchX_;                                       // distance (in X) between cells
0069   double pitchY_;                                       // distance (in Y) between cells
0070   int fToFResolution_;                                  // in ps
0071   std::vector<std::pair<double, double> > cellColumn_;  // lower and upper limits of cells in X
0072   std::vector<std::pair<double, double> > cellRow_;     // lower and upper limits of cells in Y
0073                                                         //
0074   double detW_;                                         // detector width
0075   double detH_;                                         // detector height
0076   double detPosition_;                                  // detector position from beam (absolute value)
0077                                                         //
0078   int detId_;
0079   int nHits_;
0080   std::map<int, std::vector<int> > nADC_;  // fake ADC counter: in case of multiple hits in the same cell,
0081                                            // it  counts the number of overlaps
0082   std::map<int, std::vector<double> > theToFInfo;
0083 
0084   typedef std::map<int, std::vector<double> > theToFInfo_t;  // define a type for the tof info
0085 };
0086 #endif