CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/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.3 2013/01/11 04:57:47 wmtan 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 #include "DQMServices/Core/interface/DQMStore.h"
00040 #include "DQMServices/Core/interface/MonitorElement.h"
00041 
00042 class SiStripQuality;
00043 class TrackerTopology;
00044 
00045 class SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy{
00046 
00047 public:
00048   typedef SiStrip::QualityHistosMap HistoMap;  
00049   
00050   SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy(const edm::ParameterSet&, const TrackerTopology*);
00051 
00052   virtual ~SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy();
00053 
00054   void setProbabilityThreshold(long double prob){prob_=prob;}
00055   void setMinNumEntries(unsigned short m){MinNumEntries_=m;}
00056   void setMinNumEntriesPerStrip(unsigned short m){MinNumEntriesPerStrip_=m;}
00057   void setLowOccupancyThreshold(long double low_occupancy){lowoccupancy_=low_occupancy;}
00058   void setHighOccupancyThreshold(long double high_occupancy){highoccupancy_=high_occupancy;}
00059   void setAbsoluteLowThreshold(long double absolute_low){absolutelow_=absolute_low;}
00060   void setNumberIterations(int number_iterations){numberiterations_=number_iterations;}
00061   void setAbsoluteOccupancyThreshold(long double absolute_occupancy){absolute_occupancy_=absolute_occupancy;}
00062   void setNumberOfEvents(double Nevents){Nevents_=Nevents;}
00063   void setMinNumOfEvents();
00064   void setOutputFileName(std::string OutputFileName, bool WriteOutputFile, std::string DQMOutfileName, bool WriteDQMHistograms){OutFileName_=OutputFileName; WriteOutputFile_=WriteOutputFile; DQMOutfileName_=DQMOutfileName; WriteDQMHistograms_=WriteDQMHistograms;}
00065   void setTrackerGeometry(const TrackerGeometry* tkgeom){TkGeom = tkgeom;}
00066   void extractBadAPVSandStrips(SiStripQuality*,HistoMap&,edm::ESHandle<SiStripQuality>&);
00067 
00068  private:
00069 
00070   struct Apv{   
00071 
00072     uint32_t detrawId;
00073     int modulePosition;
00074     int numberApvs;
00075     double apvMedian[6];
00076     int apvabsoluteOccupancy[6];
00077     TH1F* th1f[6];
00078     int NEntries[6];
00079     int NEmptyBins[6];
00080   };
00081 
00082   void CalculateMeanAndRMS(std::vector<Apv>, std::pair<double,double>*, int);
00083 
00084   void AnalyzeOccupancy(SiStripQuality*, std::vector<Apv>&, std::pair<double,double>*, std::vector<unsigned int>&, edm::ESHandle<SiStripQuality>&);
00085 
00086   void iterativeSearch(Apv&,std::vector<unsigned int>&,int);
00087 
00088   void evaluatePoissonian(std::vector<long double>& , long double& meanVal);
00089 
00090   void setBasicTreeParameters(int detid);
00091 
00092   void initializeDQMHistograms();
00093 
00094   void fillStripDQMHistograms();
00095 
00096   long double prob_;
00097   unsigned short MinNumEntries_;
00098   unsigned short MinNumEntriesPerStrip_;
00099   long double lowoccupancy_;
00100   long double highoccupancy_;
00101   long double absolutelow_;
00102   int numberiterations_;
00103   double Nevents_;
00104   long double absolute_occupancy_;
00105   double minNevents_;
00106   std::string OutFileName_;
00107   bool WriteOutputFile_;
00108   std::string DQMOutfileName_;
00109   bool WriteDQMHistograms_;
00110   bool UseInputDB_;
00111   const TrackerGeometry* TkGeom;
00112   const TrackerTopology* tTopo;
00113 
00114   SiStripQuality *pQuality;
00115 
00116   double stripOccupancy[6][128];
00117   double stripWeight[6][128];
00118 
00119   std::vector<Apv> medianValues_TIB_Layer1; std::pair<double,double> MeanAndRms_TIB_Layer1[7];
00120   std::vector<Apv> medianValues_TIB_Layer2; std::pair<double,double> MeanAndRms_TIB_Layer2[7];
00121   std::vector<Apv> medianValues_TIB_Layer3; std::pair<double,double> MeanAndRms_TIB_Layer3[7];
00122   std::vector<Apv> medianValues_TIB_Layer4; std::pair<double,double> MeanAndRms_TIB_Layer4[7];
00123 
00124   std::vector<Apv> medianValues_TOB_Layer1; std::pair<double,double> MeanAndRms_TOB_Layer1[7];
00125   std::vector<Apv> medianValues_TOB_Layer2; std::pair<double,double> MeanAndRms_TOB_Layer2[7];
00126   std::vector<Apv> medianValues_TOB_Layer3; std::pair<double,double> MeanAndRms_TOB_Layer3[7];
00127   std::vector<Apv> medianValues_TOB_Layer4; std::pair<double,double> MeanAndRms_TOB_Layer4[7];
00128   std::vector<Apv> medianValues_TOB_Layer5; std::pair<double,double> MeanAndRms_TOB_Layer5[7];
00129   std::vector<Apv> medianValues_TOB_Layer6; std::pair<double,double> MeanAndRms_TOB_Layer6[7];
00130 
00131   std::vector<Apv> medianValues_TIDPlus_Disc1; std::pair<double,double> MeanAndRms_TIDPlus_Disc1[7];
00132   std::vector<Apv> medianValues_TIDPlus_Disc2; std::pair<double,double> MeanAndRms_TIDPlus_Disc2[7];
00133   std::vector<Apv> medianValues_TIDPlus_Disc3; std::pair<double,double> MeanAndRms_TIDPlus_Disc3[7];
00134 
00135   std::vector<Apv> medianValues_TIDMinus_Disc1; std::pair<double,double> MeanAndRms_TIDMinus_Disc1[7];
00136   std::vector<Apv> medianValues_TIDMinus_Disc2; std::pair<double,double> MeanAndRms_TIDMinus_Disc2[7];
00137   std::vector<Apv> medianValues_TIDMinus_Disc3; std::pair<double,double> MeanAndRms_TIDMinus_Disc3[7];
00138 
00139   std::vector<Apv> medianValues_TECPlus_Disc1; std::pair<double,double> MeanAndRms_TECPlus_Disc1[7];
00140   std::vector<Apv> medianValues_TECPlus_Disc2; std::pair<double,double> MeanAndRms_TECPlus_Disc2[7];
00141   std::vector<Apv> medianValues_TECPlus_Disc3; std::pair<double,double> MeanAndRms_TECPlus_Disc3[7];
00142   std::vector<Apv> medianValues_TECPlus_Disc4; std::pair<double,double> MeanAndRms_TECPlus_Disc4[7];
00143   std::vector<Apv> medianValues_TECPlus_Disc5; std::pair<double,double> MeanAndRms_TECPlus_Disc5[7];
00144   std::vector<Apv> medianValues_TECPlus_Disc6; std::pair<double,double> MeanAndRms_TECPlus_Disc6[7];
00145   std::vector<Apv> medianValues_TECPlus_Disc7; std::pair<double,double> MeanAndRms_TECPlus_Disc7[7];
00146   std::vector<Apv> medianValues_TECPlus_Disc8; std::pair<double,double> MeanAndRms_TECPlus_Disc8[7];
00147   std::vector<Apv> medianValues_TECPlus_Disc9; std::pair<double,double> MeanAndRms_TECPlus_Disc9[7];
00148 
00149   std::vector<Apv> medianValues_TECMinus_Disc1; std::pair<double,double> MeanAndRms_TECMinus_Disc1[7];
00150   std::vector<Apv> medianValues_TECMinus_Disc2; std::pair<double,double> MeanAndRms_TECMinus_Disc2[7];
00151   std::vector<Apv> medianValues_TECMinus_Disc3; std::pair<double,double> MeanAndRms_TECMinus_Disc3[7];
00152   std::vector<Apv> medianValues_TECMinus_Disc4; std::pair<double,double> MeanAndRms_TECMinus_Disc4[7];
00153   std::vector<Apv> medianValues_TECMinus_Disc5; std::pair<double,double> MeanAndRms_TECMinus_Disc5[7];
00154   std::vector<Apv> medianValues_TECMinus_Disc6; std::pair<double,double> MeanAndRms_TECMinus_Disc6[7];
00155   std::vector<Apv> medianValues_TECMinus_Disc7; std::pair<double,double> MeanAndRms_TECMinus_Disc7[7];
00156   std::vector<Apv> medianValues_TECMinus_Disc8; std::pair<double,double> MeanAndRms_TECMinus_Disc8[7];
00157   std::vector<Apv> medianValues_TECMinus_Disc9; std::pair<double,double> MeanAndRms_TECMinus_Disc9[7];
00158 
00159 
00160   TFile* f;
00161   TTree* apvtree;
00162 
00163   uint32_t detrawid;
00164   int subdetid;
00165   int layer_ring;
00166   int disc;
00167   int isback;
00168   int isexternalstring;
00169   int iszminusside;
00170   int rodstringpetal;
00171   int isstereo;
00172   int module_number;
00173   int number_strips;
00174   int number_apvs;
00175   int apv_number;
00176 
00177   float global_position_x;
00178   float global_position_y;
00179   float global_position_z;
00180   float strip_global_position_x;
00181   float strip_global_position_y;
00182   float strip_global_position_z;
00183 
00184   int    apvAbsoluteOccupancy;
00185   double apvMedianOccupancy;
00186   int    isBad;
00187 
00188   TTree* striptree;
00189   int strip_number;
00190   int apv_channel;
00191 
00192   int isHot;
00193   int hotStripsPerAPV;
00194   int hotStripsPerModule;
00195   double singleStripOccupancy;
00196   int stripHits;
00197   double poissonProb;
00198 
00199   int ishot[128];
00200   int hotstripsperapv[6];
00201   int hotstripspermodule;
00202   double stripoccupancy[128];
00203   int striphits[128];
00204   double poissonprob[128];
00205 
00206   std::stringstream ss;
00207 
00208   std::ostringstream oss;
00209 
00210   DQMStore* dqmStore;
00211 
00212   MonitorElement* tmp;
00213   TProfile* tmp_prof;
00214 
00215   // Histograms
00216   // indexes in these arrays are [SubDetId-2][LayerN]
00217   // histograms for [SubDetId-2][0] are global for the subdetector
00218   // histogram for [0][0] is global for the tracker
00219   
00220   TH2F* medianVsAbsoluteOccupancy[5][10];
00221   TH1F* medianOccupancy[5][10];
00222   TH1F* absoluteOccupancy[5][10];
00223 
00224   std::vector<TH2F*> distanceVsStripNumber;
00225   std::vector<TProfile*> pfxDistanceVsStripNumber;
00226   std::vector<TH1F*> projXDistanceVsStripNumber;
00227   std::vector<TH1F*> projYDistanceVsStripNumber;
00228 
00229   std::vector<TH2F*> occupancyVsStripNumber;
00230   std::vector<TProfile*> pfxOccupancyVsStripNumber;
00231   std::vector<TH1F*> projYOccupancyVsStripNumber;
00232   std::vector<TH2F*> occupancyHotStripsVsStripNumber;
00233   std::vector<TProfile*> pfxOccupancyHotStripsVsStripNumber;
00234   std::vector<TH1F*> projYOccupancyHotStripsVsStripNumber;
00235   std::vector<TH2F*> occupancyGoodStripsVsStripNumber;
00236   std::vector<TProfile*> pfxOccupancyGoodStripsVsStripNumber;
00237   std::vector<TH1F*> projYOccupancyGoodStripsVsStripNumber;
00238 
00239   std::vector<TH2F*> poissonProbVsStripNumber;
00240   std::vector<TProfile*> pfxPoissonProbVsStripNumber;
00241   std::vector<TH1F*> projYPoissonProbVsStripNumber;
00242   std::vector<TH2F*> poissonProbHotStripsVsStripNumber;
00243   std::vector<TProfile*> pfxPoissonProbHotStripsVsStripNumber;
00244   std::vector<TH1F*> projYPoissonProbHotStripsVsStripNumber;
00245   std::vector<TH2F*> poissonProbGoodStripsVsStripNumber;
00246   std::vector<TProfile*> pfxPoissonProbGoodStripsVsStripNumber;
00247   std::vector<TH1F*> projYPoissonProbGoodStripsVsStripNumber;
00248    
00249   std::vector<TH2F*> nHitsVsStripNumber;
00250   std::vector<TProfile*> pfxNHitsVsStripNumber;
00251   std::vector<TH1F*> projXNHitsVsStripNumber;
00252   std::vector<TH1F*> projYNHitsVsStripNumber;
00253   std::vector<TH2F*> nHitsHotStripsVsStripNumber;
00254   std::vector<TProfile*> pfxNHitsHotStripsVsStripNumber;
00255   std::vector<TH1F*> projXNHitsHotStripsVsStripNumber;
00256   std::vector<TH1F*> projYNHitsHotStripsVsStripNumber;
00257   std::vector<TH2F*> nHitsGoodStripsVsStripNumber;
00258   std::vector<TProfile*> pfxNHitsGoodStripsVsStripNumber;
00259   std::vector<TH1F*> projXNHitsGoodStripsVsStripNumber;
00260   std::vector<TH1F*> projYNHitsGoodStripsVsStripNumber;
00261 
00262   std::vector<std::string> subDetName;
00263   std::vector<unsigned int> nLayers;
00264   std::vector<std::string> layerName;
00265 
00266   std::vector<unsigned int> vHotStripsInModule;
00267   unsigned int distance;
00268   unsigned int distanceR, distanceL;
00269 
00270   std::string outfilename;
00271 };
00272 #endif
00273