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