Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 23:30:59

0001 /**********************************************************************
0002  *
0003  * Author: F.Ferro - INFN Genova
0004  * September 2016
0005  *
0006  **********************************************************************/
0007 #ifndef RecoPPS_Local_RPixDetClusterizer_H
0008 #define RecoPPS_Local_RPixDetClusterizer_H
0009 
0010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0011 
0012 #include "DataFormats/Common/interface/DetSetVector.h"
0013 
0014 #include "DataFormats/CTPPSDigi/interface/CTPPSPixelDigi.h"
0015 #include "DataFormats/CTPPSDigi/interface/CTPPSPixelDigiCollection.h"
0016 #include "DataFormats/CTPPSReco/interface/CTPPSPixelCluster.h"
0017 
0018 #include "CondFormats/PPSObjects/interface/CTPPSPixelGainCalibrations.h"
0019 #include "CondFormats/PPSObjects/interface/CTPPSPixelAnalysisMask.h"
0020 
0021 #include <vector>
0022 #include <set>
0023 
0024 class RPixCalibDigi : public CTPPSPixelDigi {
0025 public:
0026   RPixCalibDigi(unsigned char row, unsigned char col, unsigned short adc, unsigned short ele)
0027       : CTPPSPixelDigi(row, col, adc) {
0028     electrons_ = ele;
0029   }
0030 
0031   RPixCalibDigi() : CTPPSPixelDigi() { electrons_ = 0; }
0032 
0033   int electrons() const { return electrons_; }
0034   void set_electrons(int a) { electrons_ = a; }
0035 
0036 private:
0037   int electrons_;
0038 };
0039 
0040 class RPixDetClusterizer {
0041 public:
0042   RPixDetClusterizer(edm::ParameterSet const &conf);
0043 
0044   void buildClusters(unsigned int detId,
0045                      const std::vector<CTPPSPixelDigi> &digi,
0046                      std::vector<CTPPSPixelCluster> &clusters,
0047                      const CTPPSPixelGainCalibrations *pcalibration,
0048                      const CTPPSPixelAnalysisMask *mask);
0049   int calibrate(unsigned int, int, int, int, const CTPPSPixelGainCalibrations *pcalibration);
0050 
0051   void make_cluster(RPixCalibDigi const &aSeed, std::vector<CTPPSPixelCluster> &clusters);
0052   ~RPixDetClusterizer();
0053 
0054 private:
0055   std::set<CTPPSPixelDigi> rpix_digi_set_;
0056   std::map<unsigned int, RPixCalibDigi> calib_rpix_digi_map_;
0057   const edm::ParameterSet &params_;
0058   int verbosity_;
0059   unsigned short SeedADCThreshold_;
0060   unsigned short ADCThreshold_;
0061   double ElectronADCGain_;
0062   int VcaltoElectronGain_;
0063   int VcaltoElectronOffset_;
0064   bool doSingleCalibration_;
0065   std::string CalibrationFile_;
0066   std::vector<RPixCalibDigi> SeedVector_;
0067 };
0068 
0069 class RPixTempCluster {
0070 public:
0071   RPixTempCluster() {
0072     isize = 0;
0073     curr = 0;
0074   }
0075   ~RPixTempCluster() {}
0076 
0077   static constexpr unsigned short MAXSIZE = 256;
0078   unsigned short adc[MAXSIZE];
0079   uint8_t row[MAXSIZE];
0080   uint8_t col[MAXSIZE];
0081   unsigned short isize;
0082   unsigned short curr;
0083 
0084   // stack interface (unsafe ok for use below)
0085   unsigned short top() const { return curr; }
0086   void pop() { ++curr; }
0087   bool empty() { return curr == isize; }
0088 
0089   bool addPixel(unsigned char myrow, unsigned char mycol, unsigned short const iadc) {
0090     if (isize == MAXSIZE)
0091       return false;
0092     adc[isize] = iadc;
0093     row[isize] = myrow;
0094     col[isize++] = mycol;
0095     return true;
0096   }
0097 };
0098 
0099 #endif