Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 23:29:40

0001 // -*- C++ -*-
0002 //
0003 // Package:    SiStripQuality
0004 // Class:      SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy
0005 //
0006 /**\class SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy.h CalibTracker/SiStripQuality/src/SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy.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_SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy_H
0020 #define CalibTracker_SiStripQuality_SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy_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 #include "DQMServices/Core/interface/DQMStore.h"
0038 
0039 class SiStripQuality;
0040 class TrackerTopology;
0041 
0042 class SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy {
0043 public:
0044   typedef dqm::legacy::DQMStore DQMStore;
0045   typedef dqm::legacy::MonitorElement MonitorElement;
0046   typedef SiStrip::QualityHistosMap HistoMap;
0047 
0048   SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy(const edm::ParameterSet&, const TrackerTopology*);
0049 
0050   virtual ~SiStripBadAPVandHotStripAlgorithmFromClusterOccupancy();
0051 
0052   void setProbabilityThreshold(long double prob) { prob_ = prob; }
0053   void setMinNumEntries(unsigned short m) { MinNumEntries_ = m; }
0054   void setMinNumEntriesPerStrip(unsigned short m) { MinNumEntriesPerStrip_ = m; }
0055   void setLowOccupancyThreshold(long double low_occupancy) { lowoccupancy_ = low_occupancy; }
0056   void setHighOccupancyThreshold(long double high_occupancy) { highoccupancy_ = high_occupancy; }
0057   void setAbsoluteLowThreshold(long double absolute_low) { absolutelow_ = absolute_low; }
0058   void setNumberIterations(int number_iterations) { numberiterations_ = number_iterations; }
0059   void setAbsoluteOccupancyThreshold(long double absolute_occupancy) { absolute_occupancy_ = absolute_occupancy; }
0060   void setNumberOfEvents(double Nevents) { Nevents_ = Nevents; }
0061   void setMinNumOfEvents();
0062   void setOutputFileName(std::string OutputFileName,
0063                          bool WriteOutputFile,
0064                          std::string DQMOutfileName,
0065                          bool WriteDQMHistograms) {
0066     OutFileName_ = OutputFileName;
0067     WriteOutputFile_ = WriteOutputFile;
0068     DQMOutfileName_ = DQMOutfileName;
0069     WriteDQMHistograms_ = WriteDQMHistograms;
0070   }
0071   void setTrackerGeometry(const TrackerGeometry* tkgeom) { TkGeom = tkgeom; }
0072   void extractBadAPVSandStrips(SiStripQuality*, HistoMap&, const SiStripQuality*);
0073 
0074 private:
0075   struct Apv {
0076     uint32_t detrawId;
0077     int modulePosition;
0078     int numberApvs;
0079     double apvMedian[6];
0080     int apvabsoluteOccupancy[6];
0081     TH1F* th1f[6];
0082     int NEntries[6];
0083     int NEmptyBins[6];
0084   };
0085 
0086   void CalculateMeanAndRMS(const std::vector<Apv>&, std::pair<double, double>*, int);
0087 
0088   void AnalyzeOccupancy(SiStripQuality*,
0089                         std::vector<Apv>&,
0090                         std::pair<double, double>*,
0091                         std::vector<unsigned int>&,
0092                         const SiStripQuality*);
0093 
0094   void iterativeSearch(Apv&, std::vector<unsigned int>&, int);
0095 
0096   void evaluatePoissonian(std::vector<long double>&, long double& meanVal);
0097 
0098   void setBasicTreeParameters(int detid);
0099 
0100   void initializeDQMHistograms();
0101 
0102   void fillStripDQMHistograms();
0103 
0104   long double prob_;
0105   long double ratio_;
0106   unsigned short MinNumEntries_;
0107   unsigned short MinNumEntriesPerStrip_;
0108   long double lowoccupancy_;
0109   long double highoccupancy_;
0110   long double absolutelow_;
0111   int numberiterations_;
0112   double Nevents_;
0113   long double absolute_occupancy_;
0114   double minNevents_;
0115   std::string OutFileName_;
0116   bool WriteOutputFile_;
0117   std::string DQMOutfileName_;
0118   bool WriteDQMHistograms_;
0119   bool UseInputDB_;
0120   const TrackerGeometry* TkGeom;
0121   const TrackerTopology* tTopo;
0122 
0123   SiStripQuality* pQuality;
0124 
0125   double stripOccupancy[6][128];
0126   double stripWeight[6][128];
0127 
0128   std::vector<Apv> medianValues_TIB_Layer1;
0129   std::pair<double, double> MeanAndRms_TIB_Layer1[7];
0130   std::vector<Apv> medianValues_TIB_Layer2;
0131   std::pair<double, double> MeanAndRms_TIB_Layer2[7];
0132   std::vector<Apv> medianValues_TIB_Layer3;
0133   std::pair<double, double> MeanAndRms_TIB_Layer3[7];
0134   std::vector<Apv> medianValues_TIB_Layer4;
0135   std::pair<double, double> MeanAndRms_TIB_Layer4[7];
0136 
0137   std::vector<Apv> medianValues_TOB_Layer1;
0138   std::pair<double, double> MeanAndRms_TOB_Layer1[7];
0139   std::vector<Apv> medianValues_TOB_Layer2;
0140   std::pair<double, double> MeanAndRms_TOB_Layer2[7];
0141   std::vector<Apv> medianValues_TOB_Layer3;
0142   std::pair<double, double> MeanAndRms_TOB_Layer3[7];
0143   std::vector<Apv> medianValues_TOB_Layer4;
0144   std::pair<double, double> MeanAndRms_TOB_Layer4[7];
0145   std::vector<Apv> medianValues_TOB_Layer5;
0146   std::pair<double, double> MeanAndRms_TOB_Layer5[7];
0147   std::vector<Apv> medianValues_TOB_Layer6;
0148   std::pair<double, double> MeanAndRms_TOB_Layer6[7];
0149 
0150   std::vector<Apv> medianValues_TIDPlus_Disc1;
0151   std::pair<double, double> MeanAndRms_TIDPlus_Disc1[7];
0152   std::vector<Apv> medianValues_TIDPlus_Disc2;
0153   std::pair<double, double> MeanAndRms_TIDPlus_Disc2[7];
0154   std::vector<Apv> medianValues_TIDPlus_Disc3;
0155   std::pair<double, double> MeanAndRms_TIDPlus_Disc3[7];
0156 
0157   std::vector<Apv> medianValues_TIDMinus_Disc1;
0158   std::pair<double, double> MeanAndRms_TIDMinus_Disc1[7];
0159   std::vector<Apv> medianValues_TIDMinus_Disc2;
0160   std::pair<double, double> MeanAndRms_TIDMinus_Disc2[7];
0161   std::vector<Apv> medianValues_TIDMinus_Disc3;
0162   std::pair<double, double> MeanAndRms_TIDMinus_Disc3[7];
0163 
0164   std::vector<Apv> medianValues_TECPlus_Disc1;
0165   std::pair<double, double> MeanAndRms_TECPlus_Disc1[7];
0166   std::vector<Apv> medianValues_TECPlus_Disc2;
0167   std::pair<double, double> MeanAndRms_TECPlus_Disc2[7];
0168   std::vector<Apv> medianValues_TECPlus_Disc3;
0169   std::pair<double, double> MeanAndRms_TECPlus_Disc3[7];
0170   std::vector<Apv> medianValues_TECPlus_Disc4;
0171   std::pair<double, double> MeanAndRms_TECPlus_Disc4[7];
0172   std::vector<Apv> medianValues_TECPlus_Disc5;
0173   std::pair<double, double> MeanAndRms_TECPlus_Disc5[7];
0174   std::vector<Apv> medianValues_TECPlus_Disc6;
0175   std::pair<double, double> MeanAndRms_TECPlus_Disc6[7];
0176   std::vector<Apv> medianValues_TECPlus_Disc7;
0177   std::pair<double, double> MeanAndRms_TECPlus_Disc7[7];
0178   std::vector<Apv> medianValues_TECPlus_Disc8;
0179   std::pair<double, double> MeanAndRms_TECPlus_Disc8[7];
0180   std::vector<Apv> medianValues_TECPlus_Disc9;
0181   std::pair<double, double> MeanAndRms_TECPlus_Disc9[7];
0182 
0183   std::vector<Apv> medianValues_TECMinus_Disc1;
0184   std::pair<double, double> MeanAndRms_TECMinus_Disc1[7];
0185   std::vector<Apv> medianValues_TECMinus_Disc2;
0186   std::pair<double, double> MeanAndRms_TECMinus_Disc2[7];
0187   std::vector<Apv> medianValues_TECMinus_Disc3;
0188   std::pair<double, double> MeanAndRms_TECMinus_Disc3[7];
0189   std::vector<Apv> medianValues_TECMinus_Disc4;
0190   std::pair<double, double> MeanAndRms_TECMinus_Disc4[7];
0191   std::vector<Apv> medianValues_TECMinus_Disc5;
0192   std::pair<double, double> MeanAndRms_TECMinus_Disc5[7];
0193   std::vector<Apv> medianValues_TECMinus_Disc6;
0194   std::pair<double, double> MeanAndRms_TECMinus_Disc6[7];
0195   std::vector<Apv> medianValues_TECMinus_Disc7;
0196   std::pair<double, double> MeanAndRms_TECMinus_Disc7[7];
0197   std::vector<Apv> medianValues_TECMinus_Disc8;
0198   std::pair<double, double> MeanAndRms_TECMinus_Disc8[7];
0199   std::vector<Apv> medianValues_TECMinus_Disc9;
0200   std::pair<double, double> MeanAndRms_TECMinus_Disc9[7];
0201 
0202   TFile* f;
0203   TTree* apvtree;
0204 
0205   uint32_t detrawid;
0206   int subdetid;
0207   int layer_ring;
0208   int disc;
0209   int isback;
0210   int isexternalstring;
0211   int iszminusside;
0212   int rodstringpetal;
0213   int isstereo;
0214   int module_number;
0215   int number_strips;
0216   int number_apvs;
0217   int apv_number;
0218 
0219   float global_position_x;
0220   float global_position_y;
0221   float global_position_z;
0222   float strip_global_position_x;
0223   float strip_global_position_y;
0224   float strip_global_position_z;
0225 
0226   int apvAbsoluteOccupancy;
0227   double apvMedianOccupancy;
0228   int isBad;
0229 
0230   TTree* striptree;
0231   int strip_number;
0232   int apv_channel;
0233 
0234   int isHot;
0235   int hotStripsPerAPV;
0236   int hotStripsPerModule;
0237   double singleStripOccupancy;
0238   int stripHits;
0239   double medianAPVHits;
0240   double avgAPVHits;
0241   double poissonProb;
0242 
0243   int ishot[128];
0244   int hotstripsperapv[6];
0245   int hotstripspermodule;
0246   double stripoccupancy[128];
0247   int striphits[128];
0248   double poissonprob[128];
0249   double medianapvhits[6];
0250   double avgapvhits[6];
0251 
0252   std::stringstream ss;
0253 
0254   std::ostringstream oss;
0255 
0256   DQMStore* dqmStore;
0257 
0258   MonitorElement* tmp;
0259   TProfile* tmp_prof;
0260 
0261   // Histograms
0262   // indexes in these arrays are [SubDetId-2][LayerN]
0263   // histograms for [SubDetId-2][0] are global for the subdetector
0264   // histogram for [0][0] is global for the tracker
0265 
0266   TH2F* medianVsAbsoluteOccupancy[5][10];
0267   TH1F* medianOccupancy[5][10];
0268   TH1F* absoluteOccupancy[5][10];
0269 
0270   std::vector<TH2F*> distanceVsStripNumber;
0271   std::vector<TProfile*> pfxDistanceVsStripNumber;
0272   std::vector<TH1F*> projXDistanceVsStripNumber;
0273   std::vector<TH1F*> projYDistanceVsStripNumber;
0274 
0275   std::vector<TH2F*> occupancyVsStripNumber;
0276   std::vector<TProfile*> pfxOccupancyVsStripNumber;
0277   std::vector<TH1F*> projYOccupancyVsStripNumber;
0278   std::vector<TH2F*> occupancyHotStripsVsStripNumber;
0279   std::vector<TProfile*> pfxOccupancyHotStripsVsStripNumber;
0280   std::vector<TH1F*> projYOccupancyHotStripsVsStripNumber;
0281   std::vector<TH2F*> occupancyGoodStripsVsStripNumber;
0282   std::vector<TProfile*> pfxOccupancyGoodStripsVsStripNumber;
0283   std::vector<TH1F*> projYOccupancyGoodStripsVsStripNumber;
0284 
0285   std::vector<TH2F*> poissonProbVsStripNumber;
0286   std::vector<TProfile*> pfxPoissonProbVsStripNumber;
0287   std::vector<TH1F*> projYPoissonProbVsStripNumber;
0288   std::vector<TH2F*> poissonProbHotStripsVsStripNumber;
0289   std::vector<TProfile*> pfxPoissonProbHotStripsVsStripNumber;
0290   std::vector<TH1F*> projYPoissonProbHotStripsVsStripNumber;
0291   std::vector<TH2F*> poissonProbGoodStripsVsStripNumber;
0292   std::vector<TProfile*> pfxPoissonProbGoodStripsVsStripNumber;
0293   std::vector<TH1F*> projYPoissonProbGoodStripsVsStripNumber;
0294 
0295   std::vector<TH2F*> nHitsVsStripNumber;
0296   std::vector<TProfile*> pfxNHitsVsStripNumber;
0297   std::vector<TH1F*> projXNHitsVsStripNumber;
0298   std::vector<TH1F*> projYNHitsVsStripNumber;
0299   std::vector<TH2F*> nHitsHotStripsVsStripNumber;
0300   std::vector<TProfile*> pfxNHitsHotStripsVsStripNumber;
0301   std::vector<TH1F*> projXNHitsHotStripsVsStripNumber;
0302   std::vector<TH1F*> projYNHitsHotStripsVsStripNumber;
0303   std::vector<TH2F*> nHitsGoodStripsVsStripNumber;
0304   std::vector<TProfile*> pfxNHitsGoodStripsVsStripNumber;
0305   std::vector<TH1F*> projXNHitsGoodStripsVsStripNumber;
0306   std::vector<TH1F*> projYNHitsGoodStripsVsStripNumber;
0307 
0308   std::vector<std::string> subDetName;
0309   std::vector<unsigned int> nLayers;
0310   std::vector<std::string> layerName;
0311 
0312   std::vector<unsigned int> vHotStripsInModule;
0313   unsigned int distance;
0314   unsigned int distanceR, distanceL;
0315 
0316   std::string outfilename;
0317 };
0318 #endif