Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:35:11

0001 // -*- C++ -*-
0002 //
0003 // Package:    SiStripQuality
0004 // Class:      SiStripBadAPVAlgorithmFromClusterOccupancy
0005 //
0006 /**\class SiStripBadAPVAlgorithmFromClusterOccupancy SiStripBadAPVAlgorithmFromClusterOccupancy.h CalibTracker/SiStripQuality/src/SiStripBadAPVAlgorithmFromClusterOccupancy.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Gordon KAUSSEN
0015 //         Created:  Wed Jan 28 09:11:10 CEST 2009
0016 //
0017 //
0018 
0019 #ifndef CalibTracker_SiStripQuality_SiStripBadAPVAlgorithmFromClusterOccupancy_H
0020 #define CalibTracker_SiStripQuality_SiStripBadAPVAlgorithmFromClusterOccupancy_H
0021 
0022 // system include files
0023 #include <memory>
0024 #include <vector>
0025 #include <map>
0026 #include <sstream>
0027 #include <iostream>
0028 
0029 #include "TMath.h"
0030 #include "TTree.h"
0031 #include "TFile.h"
0032 
0033 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0034 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0035 #include "CalibTracker/SiStripQuality/interface/SiStripQualityHistos.h"
0036 
0037 class SiStripQuality;
0038 class TrackerTopology;
0039 
0040 class SiStripBadAPVAlgorithmFromClusterOccupancy {
0041 public:
0042   typedef SiStrip::QualityHistosMap HistoMap;
0043 
0044   SiStripBadAPVAlgorithmFromClusterOccupancy(const edm::ParameterSet&, const TrackerTopology*);
0045 
0046   virtual ~SiStripBadAPVAlgorithmFromClusterOccupancy();
0047 
0048   void setLowOccupancyThreshold(long double low_occupancy) { lowoccupancy_ = low_occupancy; }
0049   void setHighOccupancyThreshold(long double high_occupancy) { highoccupancy_ = high_occupancy; }
0050   void setAbsoluteLowThreshold(long double absolute_low) { absolutelow_ = absolute_low; }
0051   void setNumberIterations(int number_iterations) { numberiterations_ = number_iterations; }
0052   void setAbsoluteOccupancyThreshold(long double occupancy) { occupancy_ = occupancy; }
0053   void setNumberOfEvents(double Nevents) { Nevents_ = Nevents; }
0054   void setMinNumOfEvents();
0055   void setOutputFileName(std::string OutputFileName, bool WriteOutputFile) {
0056     OutFileName_ = OutputFileName;
0057     WriteOutputFile_ = WriteOutputFile;
0058   }
0059   void setTrackerGeometry(const TrackerGeometry* tkgeom) { TkGeom = tkgeom; }
0060   void extractBadAPVs(SiStripQuality*, HistoMap&, const SiStripQuality*);
0061 
0062 private:
0063   struct Apv {
0064     uint32_t detrawId;
0065     int modulePosition;
0066     int numberApvs;
0067     double apvMedian[6];
0068     double apvabsoluteOccupancy[6];
0069   };
0070 
0071   void CalculateMeanAndRMS(const std::vector<Apv>&, std::pair<double, double>*, int);
0072 
0073   void AnalyzeOccupancy(SiStripQuality*,
0074                         std::vector<Apv>&,
0075                         std::pair<double, double>*,
0076                         std::vector<unsigned int>&,
0077                         const SiStripQuality*);
0078 
0079   struct pHisto {
0080     pHisto() : _NEntries(0), _NBins(0) {}
0081     TH1F* _th1f;
0082     int _NEntries;
0083     int _NBins;
0084   };
0085 
0086   long double lowoccupancy_;
0087   long double highoccupancy_;
0088   long double absolutelow_;
0089   int numberiterations_;
0090   double Nevents_;
0091   long double occupancy_;
0092   double minNevents_;
0093   std::string OutFileName_;
0094   bool WriteOutputFile_;
0095   bool UseInputDB_;
0096   const TrackerGeometry* TkGeom;
0097   const TrackerTopology* tTopo;
0098 
0099   SiStripQuality* pQuality;
0100 
0101   double stripOccupancy[6][128];
0102   double stripWeight[6][128];
0103 
0104   std::vector<Apv> medianValues_TIB_Layer1;
0105   std::pair<double, double> MeanAndRms_TIB_Layer1[7];
0106   std::vector<Apv> medianValues_TIB_Layer2;
0107   std::pair<double, double> MeanAndRms_TIB_Layer2[7];
0108   std::vector<Apv> medianValues_TIB_Layer3;
0109   std::pair<double, double> MeanAndRms_TIB_Layer3[7];
0110   std::vector<Apv> medianValues_TIB_Layer4;
0111   std::pair<double, double> MeanAndRms_TIB_Layer4[7];
0112 
0113   std::vector<Apv> medianValues_TOB_Layer1;
0114   std::pair<double, double> MeanAndRms_TOB_Layer1[7];
0115   std::vector<Apv> medianValues_TOB_Layer2;
0116   std::pair<double, double> MeanAndRms_TOB_Layer2[7];
0117   std::vector<Apv> medianValues_TOB_Layer3;
0118   std::pair<double, double> MeanAndRms_TOB_Layer3[7];
0119   std::vector<Apv> medianValues_TOB_Layer4;
0120   std::pair<double, double> MeanAndRms_TOB_Layer4[7];
0121   std::vector<Apv> medianValues_TOB_Layer5;
0122   std::pair<double, double> MeanAndRms_TOB_Layer5[7];
0123   std::vector<Apv> medianValues_TOB_Layer6;
0124   std::pair<double, double> MeanAndRms_TOB_Layer6[7];
0125 
0126   std::vector<Apv> medianValues_TIDPlus_Disc1;
0127   std::pair<double, double> MeanAndRms_TIDPlus_Disc1[7];
0128   std::vector<Apv> medianValues_TIDPlus_Disc2;
0129   std::pair<double, double> MeanAndRms_TIDPlus_Disc2[7];
0130   std::vector<Apv> medianValues_TIDPlus_Disc3;
0131   std::pair<double, double> MeanAndRms_TIDPlus_Disc3[7];
0132 
0133   std::vector<Apv> medianValues_TIDMinus_Disc1;
0134   std::pair<double, double> MeanAndRms_TIDMinus_Disc1[7];
0135   std::vector<Apv> medianValues_TIDMinus_Disc2;
0136   std::pair<double, double> MeanAndRms_TIDMinus_Disc2[7];
0137   std::vector<Apv> medianValues_TIDMinus_Disc3;
0138   std::pair<double, double> MeanAndRms_TIDMinus_Disc3[7];
0139 
0140   std::vector<Apv> medianValues_TECPlus_Disc1;
0141   std::pair<double, double> MeanAndRms_TECPlus_Disc1[7];
0142   std::vector<Apv> medianValues_TECPlus_Disc2;
0143   std::pair<double, double> MeanAndRms_TECPlus_Disc2[7];
0144   std::vector<Apv> medianValues_TECPlus_Disc3;
0145   std::pair<double, double> MeanAndRms_TECPlus_Disc3[7];
0146   std::vector<Apv> medianValues_TECPlus_Disc4;
0147   std::pair<double, double> MeanAndRms_TECPlus_Disc4[7];
0148   std::vector<Apv> medianValues_TECPlus_Disc5;
0149   std::pair<double, double> MeanAndRms_TECPlus_Disc5[7];
0150   std::vector<Apv> medianValues_TECPlus_Disc6;
0151   std::pair<double, double> MeanAndRms_TECPlus_Disc6[7];
0152   std::vector<Apv> medianValues_TECPlus_Disc7;
0153   std::pair<double, double> MeanAndRms_TECPlus_Disc7[7];
0154   std::vector<Apv> medianValues_TECPlus_Disc8;
0155   std::pair<double, double> MeanAndRms_TECPlus_Disc8[7];
0156   std::vector<Apv> medianValues_TECPlus_Disc9;
0157   std::pair<double, double> MeanAndRms_TECPlus_Disc9[7];
0158 
0159   std::vector<Apv> medianValues_TECMinus_Disc1;
0160   std::pair<double, double> MeanAndRms_TECMinus_Disc1[7];
0161   std::vector<Apv> medianValues_TECMinus_Disc2;
0162   std::pair<double, double> MeanAndRms_TECMinus_Disc2[7];
0163   std::vector<Apv> medianValues_TECMinus_Disc3;
0164   std::pair<double, double> MeanAndRms_TECMinus_Disc3[7];
0165   std::vector<Apv> medianValues_TECMinus_Disc4;
0166   std::pair<double, double> MeanAndRms_TECMinus_Disc4[7];
0167   std::vector<Apv> medianValues_TECMinus_Disc5;
0168   std::pair<double, double> MeanAndRms_TECMinus_Disc5[7];
0169   std::vector<Apv> medianValues_TECMinus_Disc6;
0170   std::pair<double, double> MeanAndRms_TECMinus_Disc6[7];
0171   std::vector<Apv> medianValues_TECMinus_Disc7;
0172   std::pair<double, double> MeanAndRms_TECMinus_Disc7[7];
0173   std::vector<Apv> medianValues_TECMinus_Disc8;
0174   std::pair<double, double> MeanAndRms_TECMinus_Disc8[7];
0175   std::vector<Apv> medianValues_TECMinus_Disc9;
0176   std::pair<double, double> MeanAndRms_TECMinus_Disc9[7];
0177 
0178   TFile* f;
0179   TTree* apvtree;
0180 
0181   uint32_t detrawid;
0182   int subdetid;
0183   int layer_ring;
0184   int disc;
0185   int isback;
0186   int isexternalstring;
0187   int iszminusside;
0188   int rodstringpetal;
0189   int isstereo;
0190   int module_number;
0191   int number_strips;
0192   int number_apvs;
0193   int apv_number;
0194 
0195   float global_position_x;
0196   float global_position_y;
0197   float global_position_z;
0198 
0199   double apvAbsoluteOccupancy;
0200   double apvMedianOccupancy;
0201 
0202   std::stringstream ss;
0203 };
0204 #endif