CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/CalibTracker/SiStripQuality/interface/SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    SiStripQuality
00004 // Class:      SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy
00005 // 
00013 //
00014 // Original Author:  Gordon KAUSSEN
00015 //         Created:  Wed Jan 28 09:11:10 CEST 2009
00016 // $Id: SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy.h,v 1.1 2010/09/14 12:23:35 kaussen Exp $
00017 //
00018 //
00019 
00020 #ifndef CalibTracker_SiStripQuality_SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy_H
00021 #define CalibTracker_SiStripQuality_SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy_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 SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy{
00042 
00043 public:
00044   typedef SiStrip::QualityHistosMap HistoMap;  
00045   
00046   SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy(const edm::ParameterSet&);
00047 
00048   virtual ~SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy();
00049 
00050   void setProbabilityThreshold(long double prob){prob_=prob;}
00051   void setMinNumEntries(unsigned short m){MinNumEntries_=m;}
00052   void setMinNumEntriesPerStrip(unsigned short m){MinNumEntriesPerStrip_=m;}
00053   void setLowOccupancyThreshold(long double low_occupancy){lowoccupancy_=low_occupancy;}
00054   void setHighOccupancyThreshold(long double high_occupancy){highoccupancy_=high_occupancy;}
00055   void setAbsoluteLowThreshold(long double absolute_low){absolutelow_=absolute_low;}
00056   void setNumberIterations(int number_iterations){numberiterations_=number_iterations;}
00057   void setAbsoluteOccupancyThreshold(long double absolute_occupancy){absolute_occupancy_=absolute_occupancy;}
00058   void setNumberOfEvents(double Nevents){Nevents_=Nevents;}
00059   void setMinNumOfEvents();
00060   void setOutputFileName(std::string OutputFileName, bool WriteOutputFile){OutFileName_=OutputFileName; WriteOutputFile_=WriteOutputFile;}
00061   void setTrackerGeometry(const TrackerGeometry* tkgeom){TkGeom = tkgeom;}
00062   void extractBadAPVSandStrips(SiStripQuality*,HistoMap&,edm::ESHandle<SiStripQuality>&);
00063 
00064  private:
00065 
00066   struct Apv{   
00067 
00068     uint32_t detrawId;
00069     int modulePosition;
00070     int numberApvs;
00071     double apvMedian[6];
00072     int apvabsoluteOccupancy[6];
00073     TH1F* th1f[6];
00074     int NEntries[6];
00075     int NEmptyBins[6];
00076   };
00077 
00078   void CalculateMeanAndRMS(std::vector<Apv>, std::pair<double,double>*, int);
00079 
00080   void AnalyzeOccupancy(SiStripQuality*, std::vector<Apv>&, std::pair<double,double>*, std::vector<unsigned int>&, edm::ESHandle<SiStripQuality>&);
00081 
00082   void iterativeSearch(Apv&,std::vector<unsigned int>&,int);
00083 
00084   void evaluatePoissonian(std::vector<long double>& , long double& meanVal);
00085 
00086   void setBasicTreeParameters(int detid);
00087 
00088   long double prob_;
00089   unsigned short MinNumEntries_;
00090   unsigned short MinNumEntriesPerStrip_;
00091   long double lowoccupancy_;
00092   long double highoccupancy_;
00093   long double absolutelow_;
00094   int numberiterations_;
00095   double Nevents_;
00096   long double absolute_occupancy_;
00097   double minNevents_;
00098   std::string OutFileName_;
00099   bool WriteOutputFile_;
00100   bool UseInputDB_;
00101   const TrackerGeometry* TkGeom;
00102 
00103   SiStripQuality *pQuality;
00104 
00105   double stripOccupancy[6][128];
00106   double stripWeight[6][128];
00107 
00108   std::vector<Apv> medianValues_TIB_Layer1; std::pair<double,double> MeanAndRms_TIB_Layer1[7];
00109   std::vector<Apv> medianValues_TIB_Layer2; std::pair<double,double> MeanAndRms_TIB_Layer2[7];
00110   std::vector<Apv> medianValues_TIB_Layer3; std::pair<double,double> MeanAndRms_TIB_Layer3[7];
00111   std::vector<Apv> medianValues_TIB_Layer4; std::pair<double,double> MeanAndRms_TIB_Layer4[7];
00112 
00113   std::vector<Apv> medianValues_TOB_Layer1; std::pair<double,double> MeanAndRms_TOB_Layer1[7];
00114   std::vector<Apv> medianValues_TOB_Layer2; std::pair<double,double> MeanAndRms_TOB_Layer2[7];
00115   std::vector<Apv> medianValues_TOB_Layer3; std::pair<double,double> MeanAndRms_TOB_Layer3[7];
00116   std::vector<Apv> medianValues_TOB_Layer4; std::pair<double,double> MeanAndRms_TOB_Layer4[7];
00117   std::vector<Apv> medianValues_TOB_Layer5; std::pair<double,double> MeanAndRms_TOB_Layer5[7];
00118   std::vector<Apv> medianValues_TOB_Layer6; std::pair<double,double> MeanAndRms_TOB_Layer6[7];
00119 
00120   std::vector<Apv> medianValues_TIDPlus_Disc1; std::pair<double,double> MeanAndRms_TIDPlus_Disc1[7];
00121   std::vector<Apv> medianValues_TIDPlus_Disc2; std::pair<double,double> MeanAndRms_TIDPlus_Disc2[7];
00122   std::vector<Apv> medianValues_TIDPlus_Disc3; std::pair<double,double> MeanAndRms_TIDPlus_Disc3[7];
00123 
00124   std::vector<Apv> medianValues_TIDMinus_Disc1; std::pair<double,double> MeanAndRms_TIDMinus_Disc1[7];
00125   std::vector<Apv> medianValues_TIDMinus_Disc2; std::pair<double,double> MeanAndRms_TIDMinus_Disc2[7];
00126   std::vector<Apv> medianValues_TIDMinus_Disc3; std::pair<double,double> MeanAndRms_TIDMinus_Disc3[7];
00127 
00128   std::vector<Apv> medianValues_TECPlus_Disc1; std::pair<double,double> MeanAndRms_TECPlus_Disc1[7];
00129   std::vector<Apv> medianValues_TECPlus_Disc2; std::pair<double,double> MeanAndRms_TECPlus_Disc2[7];
00130   std::vector<Apv> medianValues_TECPlus_Disc3; std::pair<double,double> MeanAndRms_TECPlus_Disc3[7];
00131   std::vector<Apv> medianValues_TECPlus_Disc4; std::pair<double,double> MeanAndRms_TECPlus_Disc4[7];
00132   std::vector<Apv> medianValues_TECPlus_Disc5; std::pair<double,double> MeanAndRms_TECPlus_Disc5[7];
00133   std::vector<Apv> medianValues_TECPlus_Disc6; std::pair<double,double> MeanAndRms_TECPlus_Disc6[7];
00134   std::vector<Apv> medianValues_TECPlus_Disc7; std::pair<double,double> MeanAndRms_TECPlus_Disc7[7];
00135   std::vector<Apv> medianValues_TECPlus_Disc8; std::pair<double,double> MeanAndRms_TECPlus_Disc8[7];
00136   std::vector<Apv> medianValues_TECPlus_Disc9; std::pair<double,double> MeanAndRms_TECPlus_Disc9[7];
00137 
00138   std::vector<Apv> medianValues_TECMinus_Disc1; std::pair<double,double> MeanAndRms_TECMinus_Disc1[7];
00139   std::vector<Apv> medianValues_TECMinus_Disc2; std::pair<double,double> MeanAndRms_TECMinus_Disc2[7];
00140   std::vector<Apv> medianValues_TECMinus_Disc3; std::pair<double,double> MeanAndRms_TECMinus_Disc3[7];
00141   std::vector<Apv> medianValues_TECMinus_Disc4; std::pair<double,double> MeanAndRms_TECMinus_Disc4[7];
00142   std::vector<Apv> medianValues_TECMinus_Disc5; std::pair<double,double> MeanAndRms_TECMinus_Disc5[7];
00143   std::vector<Apv> medianValues_TECMinus_Disc6; std::pair<double,double> MeanAndRms_TECMinus_Disc6[7];
00144   std::vector<Apv> medianValues_TECMinus_Disc7; std::pair<double,double> MeanAndRms_TECMinus_Disc7[7];
00145   std::vector<Apv> medianValues_TECMinus_Disc8; std::pair<double,double> MeanAndRms_TECMinus_Disc8[7];
00146   std::vector<Apv> medianValues_TECMinus_Disc9; std::pair<double,double> MeanAndRms_TECMinus_Disc9[7];
00147 
00148 
00149   TFile* f;
00150   TTree* apvtree;
00151 
00152   uint32_t detrawid;
00153   int subdetid;
00154   int layer_ring;
00155   int disc;
00156   int isback;
00157   int isexternalstring;
00158   int iszminusside;
00159   int rodstringpetal;
00160   int isstereo;
00161   int module_number;
00162   int number_strips;
00163   int number_apvs;
00164   int apv_number;
00165 
00166   float global_position_x;
00167   float global_position_y;
00168   float global_position_z;
00169   float strip_global_position_x;
00170   float strip_global_position_y;
00171   float strip_global_position_z;
00172 
00173   int    apvAbsoluteOccupancy;
00174   double apvMedianOccupancy;
00175   int    isBad;
00176 
00177   TTree* striptree;
00178   int strip_number;
00179   int apv_channel;
00180 
00181   int isHot;
00182   int hotStripsPerAPV;
00183   int hotStripsPerModule;
00184   double singleStripOccupancy;
00185   int stripHits;
00186   double poissonProb;
00187 
00188   int ishot[128];
00189   int hotstripsperapv[6];
00190   int hotstripspermodule;
00191   double stripoccupancy[128];
00192   int striphits[128];
00193   double poissonprob[128];
00194 
00195   std::stringstream ss;   
00196 };
00197 #endif
00198