CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/CalibTracker/SiStripQuality/interface/SiStripBadAPVAlgorithmFromClusterOccupancy.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    SiStripQuality
00004 // Class:      SiStripBadAPVAlgorithmFromClusterOccupancy
00005 // 
00013 //
00014 // Original Author:  Gordon KAUSSEN
00015 //         Created:  Wed Jan 28 09:11:10 CEST 2009
00016 // $Id: SiStripBadAPVAlgorithmFromClusterOccupancy.h,v 1.6 2010/04/26 12:20:05 kaussen Exp $
00017 //
00018 //
00019 
00020 #ifndef CalibTracker_SiStripQuality_SiStripBadAPVAlgorithmFromClusterOccupancy_H
00021 #define CalibTracker_SiStripQuality_SiStripBadAPVAlgorithmFromClusterOccupancy_H
00022 
00023 // system include files
00024 #include <memory>
00025 #include <vector>
00026 #include <map>
00027 #include <sstream>
00028 #include <iostream>
00029 
00030 #include "TMath.h"
00031 #include "TTree.h"
00032 #include "TFile.h"
00033 
00034 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00035 #include "FWCore/Framework/interface/ESHandle.h"
00036 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00037 #include "CalibTracker/SiStripQuality/interface/SiStripQualityHistos.h"
00038 
00039 class SiStripQuality;
00040 
00041 class SiStripBadAPVAlgorithmFromClusterOccupancy{
00042 
00043 public:
00044   typedef SiStrip::QualityHistosMap HistoMap;  
00045   
00046   SiStripBadAPVAlgorithmFromClusterOccupancy(const edm::ParameterSet&);
00047 
00048   virtual ~SiStripBadAPVAlgorithmFromClusterOccupancy();
00049 
00050   void setLowOccupancyThreshold(long double low_occupancy){lowoccupancy_=low_occupancy;}
00051   void setHighOccupancyThreshold(long double high_occupancy){highoccupancy_=high_occupancy;}
00052   void setAbsoluteLowThreshold(long double absolute_low){absolutelow_=absolute_low;}
00053   void setNumberIterations(int number_iterations){numberiterations_=number_iterations;}
00054   void setAbsoluteOccupancyThreshold(long double occupancy){occupancy_=occupancy;}
00055   void setNumberOfEvents(double Nevents){Nevents_=Nevents;}
00056   void setMinNumOfEvents();
00057   void setOutputFileName(std::string OutputFileName, bool WriteOutputFile){OutFileName_=OutputFileName; WriteOutputFile_=WriteOutputFile;}
00058   void setTrackerGeometry(const TrackerGeometry* tkgeom){TkGeom = tkgeom;}
00059   void extractBadAPVs(SiStripQuality*,HistoMap&,edm::ESHandle<SiStripQuality>&);
00060 
00061  private:
00062 
00063   struct Apv{   
00064 
00065     uint32_t detrawId;
00066     int modulePosition;
00067     int numberApvs;
00068     double apvMedian[6];
00069     double apvabsoluteOccupancy[6];
00070   };
00071 
00072   void CalculateMeanAndRMS(std::vector<Apv>, std::pair<double,double>*, int);
00073 
00074   void AnalyzeOccupancy(SiStripQuality*, std::vector<Apv>&, std::pair<double,double>*, std::vector<unsigned int>&, edm::ESHandle<SiStripQuality>&);
00075 
00076   struct pHisto{   
00077 
00078     pHisto():_NEntries(0),_NBins(0){};
00079     TH1F* _th1f;
00080     int _NEntries;
00081     int _NBins;
00082   };
00083 
00084   long double lowoccupancy_;
00085   long double highoccupancy_;
00086   long double absolutelow_;
00087   int numberiterations_;
00088   double Nevents_;
00089   long double occupancy_;
00090   double minNevents_;
00091   std::string OutFileName_;
00092   bool WriteOutputFile_;
00093   bool UseInputDB_;
00094   const TrackerGeometry* TkGeom;
00095 
00096   SiStripQuality *pQuality;
00097 
00098   double stripOccupancy[6][128];
00099   double stripWeight[6][128];
00100 
00101   std::vector<Apv> medianValues_TIB_Layer1; std::pair<double,double> MeanAndRms_TIB_Layer1[7];
00102   std::vector<Apv> medianValues_TIB_Layer2; std::pair<double,double> MeanAndRms_TIB_Layer2[7];
00103   std::vector<Apv> medianValues_TIB_Layer3; std::pair<double,double> MeanAndRms_TIB_Layer3[7];
00104   std::vector<Apv> medianValues_TIB_Layer4; std::pair<double,double> MeanAndRms_TIB_Layer4[7];
00105 
00106   std::vector<Apv> medianValues_TOB_Layer1; std::pair<double,double> MeanAndRms_TOB_Layer1[7];
00107   std::vector<Apv> medianValues_TOB_Layer2; std::pair<double,double> MeanAndRms_TOB_Layer2[7];
00108   std::vector<Apv> medianValues_TOB_Layer3; std::pair<double,double> MeanAndRms_TOB_Layer3[7];
00109   std::vector<Apv> medianValues_TOB_Layer4; std::pair<double,double> MeanAndRms_TOB_Layer4[7];
00110   std::vector<Apv> medianValues_TOB_Layer5; std::pair<double,double> MeanAndRms_TOB_Layer5[7];
00111   std::vector<Apv> medianValues_TOB_Layer6; std::pair<double,double> MeanAndRms_TOB_Layer6[7];
00112 
00113   std::vector<Apv> medianValues_TIDPlus_Disc1; std::pair<double,double> MeanAndRms_TIDPlus_Disc1[7];
00114   std::vector<Apv> medianValues_TIDPlus_Disc2; std::pair<double,double> MeanAndRms_TIDPlus_Disc2[7];
00115   std::vector<Apv> medianValues_TIDPlus_Disc3; std::pair<double,double> MeanAndRms_TIDPlus_Disc3[7];
00116 
00117   std::vector<Apv> medianValues_TIDMinus_Disc1; std::pair<double,double> MeanAndRms_TIDMinus_Disc1[7];
00118   std::vector<Apv> medianValues_TIDMinus_Disc2; std::pair<double,double> MeanAndRms_TIDMinus_Disc2[7];
00119   std::vector<Apv> medianValues_TIDMinus_Disc3; std::pair<double,double> MeanAndRms_TIDMinus_Disc3[7];
00120 
00121   std::vector<Apv> medianValues_TECPlus_Disc1; std::pair<double,double> MeanAndRms_TECPlus_Disc1[7];
00122   std::vector<Apv> medianValues_TECPlus_Disc2; std::pair<double,double> MeanAndRms_TECPlus_Disc2[7];
00123   std::vector<Apv> medianValues_TECPlus_Disc3; std::pair<double,double> MeanAndRms_TECPlus_Disc3[7];
00124   std::vector<Apv> medianValues_TECPlus_Disc4; std::pair<double,double> MeanAndRms_TECPlus_Disc4[7];
00125   std::vector<Apv> medianValues_TECPlus_Disc5; std::pair<double,double> MeanAndRms_TECPlus_Disc5[7];
00126   std::vector<Apv> medianValues_TECPlus_Disc6; std::pair<double,double> MeanAndRms_TECPlus_Disc6[7];
00127   std::vector<Apv> medianValues_TECPlus_Disc7; std::pair<double,double> MeanAndRms_TECPlus_Disc7[7];
00128   std::vector<Apv> medianValues_TECPlus_Disc8; std::pair<double,double> MeanAndRms_TECPlus_Disc8[7];
00129   std::vector<Apv> medianValues_TECPlus_Disc9; std::pair<double,double> MeanAndRms_TECPlus_Disc9[7];
00130 
00131   std::vector<Apv> medianValues_TECMinus_Disc1; std::pair<double,double> MeanAndRms_TECMinus_Disc1[7];
00132   std::vector<Apv> medianValues_TECMinus_Disc2; std::pair<double,double> MeanAndRms_TECMinus_Disc2[7];
00133   std::vector<Apv> medianValues_TECMinus_Disc3; std::pair<double,double> MeanAndRms_TECMinus_Disc3[7];
00134   std::vector<Apv> medianValues_TECMinus_Disc4; std::pair<double,double> MeanAndRms_TECMinus_Disc4[7];
00135   std::vector<Apv> medianValues_TECMinus_Disc5; std::pair<double,double> MeanAndRms_TECMinus_Disc5[7];
00136   std::vector<Apv> medianValues_TECMinus_Disc6; std::pair<double,double> MeanAndRms_TECMinus_Disc6[7];
00137   std::vector<Apv> medianValues_TECMinus_Disc7; std::pair<double,double> MeanAndRms_TECMinus_Disc7[7];
00138   std::vector<Apv> medianValues_TECMinus_Disc8; std::pair<double,double> MeanAndRms_TECMinus_Disc8[7];
00139   std::vector<Apv> medianValues_TECMinus_Disc9; std::pair<double,double> MeanAndRms_TECMinus_Disc9[7];
00140 
00141 
00142   TFile* f;
00143   TTree* apvtree;
00144 
00145   uint32_t detrawid;
00146   int subdetid;
00147   int layer_ring;
00148   int disc;
00149   int isback;
00150   int isexternalstring;
00151   int iszminusside;
00152   int rodstringpetal;
00153   int isstereo;
00154   int module_number;
00155   int number_strips;
00156   int number_apvs;
00157   int apv_number;
00158 
00159   float global_position_x;
00160   float global_position_y;
00161   float global_position_z;
00162 
00163   double apvAbsoluteOccupancy;
00164   double apvMedianOccupancy;
00165 
00166   std::stringstream ss;   
00167 };
00168 #endif
00169