Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:39

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   int verbosity_;
0058   unsigned short SeedADCThreshold_;
0059   unsigned short ADCThreshold_;
0060   double ElectronADCGain_;
0061   int VcaltoElectronGain_;
0062   int VcaltoElectronOffset_;
0063   bool doSingleCalibration_;
0064   std::string CalibrationFile_;
0065   std::vector<RPixCalibDigi> SeedVector_;
0066 };
0067 
0068 class RPixTempCluster {
0069 public:
0070   RPixTempCluster() {
0071     isize = 0;
0072     curr = 0;
0073   }
0074   ~RPixTempCluster() {}
0075 
0076   static constexpr unsigned short MAXSIZE = 256;
0077   unsigned short adc[MAXSIZE];
0078   uint8_t row[MAXSIZE];
0079   uint8_t col[MAXSIZE];
0080   unsigned short isize;
0081   unsigned short curr;
0082 
0083   // stack interface (unsafe ok for use below)
0084   unsigned short top() const { return curr; }
0085   void pop() { ++curr; }
0086   bool empty() { return curr == isize; }
0087 
0088   bool addPixel(unsigned char myrow, unsigned char mycol, unsigned short const iadc) {
0089     if (isize == MAXSIZE)
0090       return false;
0091     adc[isize] = iadc;
0092     row[isize] = myrow;
0093     col[isize++] = mycol;
0094     return true;
0095   }
0096 };
0097 
0098 #endif