Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:09:18

0001 // system include files
0002 #include <memory>
0003 #include <sstream>
0004 #include <iostream>
0005 #include <vector>
0006 
0007 // user include files
0008 #include "FWCore/Framework/interface/Frameworkfwd.h"
0009 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/MakerMacros.h"
0012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0013 #include "FWCore/ServiceRegistry/interface/Service.h"
0014 #include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h"
0015 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0016 #include "DataFormats/Common/interface/DetSetVector.h"
0017 #include "DataFormats/Common/interface/DetSetVectorNew.h"
0018 #include "DQMServices/Core/interface/DQMStore.h"
0019 
0020 // ROOT includes
0021 #include "TCanvas.h"
0022 #include "TFile.h"
0023 #include "TH1.h"
0024 #include "TH1D.h"
0025 #include "TH1F.h"
0026 #include "TH2F.h"
0027 #include "TProfile.h"
0028 #include "TStyle.h"
0029 #include "TTree.h"
0030 
0031 //
0032 // class decleration
0033 //
0034 
0035 class StripValidationPlots : public edm::one::EDAnalyzer<> {
0036 public:
0037   typedef dqm::legacy::DQMStore DQMStore;
0038   typedef dqm::legacy::MonitorElement MonitorElement;
0039 
0040   explicit StripValidationPlots(const edm::ParameterSet&);
0041   ~StripValidationPlots() override = default;
0042 
0043 private:
0044   void beginJob() override;
0045   void analyze(const edm::Event&, const edm::EventSetup&) override;
0046   void endJob() override;
0047 
0048   std::ostringstream oss;
0049 
0050   DQMStore* dqmStore_;
0051 
0052   MonitorElement* tmp;
0053   TProfile* tmp_prof;
0054 
0055   // Histograms
0056   std::vector<TH2F*> distanceVsStripNumber;
0057   std::vector<TProfile*> pfxDistanceVsStripNumber;
0058   std::vector<TH1F*> projXDistanceVsStripNumber;
0059   std::vector<TH1F*> projYDistanceVsStripNumber;
0060 
0061   std::vector<TH2F*> occupancyVsStripNumber;
0062   std::vector<TProfile*> pfxOccupancyVsStripNumber;
0063   std::vector<TH1F*> projYOccupancyVsStripNumber;
0064   std::vector<TH2F*> occupancyHotStripsVsStripNumber;
0065   std::vector<TProfile*> pfxOccupancyHotStripsVsStripNumber;
0066   std::vector<TH1F*> projYOccupancyHotStripsVsStripNumber;
0067   std::vector<TH2F*> occupancyGoodStripsVsStripNumber;
0068   std::vector<TProfile*> pfxOccupancyGoodStripsVsStripNumber;
0069   std::vector<TH1F*> projYOccupancyGoodStripsVsStripNumber;
0070 
0071   std::vector<TH2F*> poissonProbVsStripNumber;
0072   std::vector<TProfile*> pfxPoissonProbVsStripNumber;
0073   std::vector<TH1F*> projYPoissonProbVsStripNumber;
0074   std::vector<TH2F*> poissonProbHotStripsVsStripNumber;
0075   std::vector<TProfile*> pfxPoissonProbHotStripsVsStripNumber;
0076   std::vector<TH1F*> projYPoissonProbHotStripsVsStripNumber;
0077   std::vector<TH2F*> poissonProbGoodStripsVsStripNumber;
0078   std::vector<TProfile*> pfxPoissonProbGoodStripsVsStripNumber;
0079   std::vector<TH1F*> projYPoissonProbGoodStripsVsStripNumber;
0080 
0081   std::vector<TH2F*> nHitsVsStripNumber;
0082   std::vector<TProfile*> pfxNHitsVsStripNumber;
0083   std::vector<TH1F*> projXNHitsVsStripNumber;
0084   std::vector<TH1F*> projYNHitsVsStripNumber;
0085   std::vector<TH2F*> nHitsHotStripsVsStripNumber;
0086   std::vector<TProfile*> pfxNHitsHotStripsVsStripNumber;
0087   std::vector<TH1F*> projXNHitsHotStripsVsStripNumber;
0088   std::vector<TH1F*> projYNHitsHotStripsVsStripNumber;
0089   std::vector<TH2F*> nHitsGoodStripsVsStripNumber;
0090   std::vector<TProfile*> pfxNHitsGoodStripsVsStripNumber;
0091   std::vector<TH1F*> projXNHitsGoodStripsVsStripNumber;
0092   std::vector<TH1F*> projYNHitsGoodStripsVsStripNumber;
0093 
0094   std::vector<std::string> subDetName;
0095 
0096   std::string infilename;
0097   std::string outfilename;
0098 
0099   TFile* infile;
0100   TTree* intree;
0101 
0102   // Declaration of leaf types
0103   Int_t DetRawId;
0104   Int_t SubDetId;
0105   Int_t Layer_Ring;
0106   Int_t Disc;
0107   Int_t IsBack;
0108   Int_t IsExternalString;
0109   Int_t IsZMinusSide;
0110   Int_t RodStringPetal;
0111   Int_t IsStereo;
0112   Int_t ModulePosition;
0113   Int_t NumberOfStrips;
0114   Int_t StripNumber;
0115   Int_t APVChannel;
0116   Float_t StripGlobalPositionX;
0117   Float_t StripGlobalPositionY;
0118   Float_t StripGlobalPositionZ;
0119   Int_t IsHot;
0120   Int_t HotStripsPerAPV;
0121   Int_t HotStripsPerModule;
0122   Double_t StripOccupancy;
0123   Int_t StripHits;
0124   Double_t PoissonProb;
0125 
0126   Int_t savedDetRawId;
0127   Int_t savedNStrips;
0128   Int_t savedSubDetId;
0129   Int_t firstEntry;
0130   std::vector<unsigned int> vHotStripsInModule;
0131   unsigned int distance;
0132   unsigned int distanceR, distanceL;
0133   unsigned int nReadStrips[768][5];
0134 
0135   // ----------member data ---------------------------
0136 };
0137 
0138 //
0139 // constructors and destructor
0140 //
0141 StripValidationPlots::StripValidationPlots(const edm::ParameterSet& iConfig)
0142     : infilename(iConfig.getUntrackedParameter<std::string>("inputFilename", "in.root")),
0143       outfilename(iConfig.getUntrackedParameter<std::string>("outputFilename", "out.root"))
0144 
0145 {
0146   //now do what ever initialization is needed
0147 }
0148 
0149 //
0150 // member functions
0151 //
0152 
0153 // ------------ method called to for each event  ------------
0154 void StripValidationPlots::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {}
0155 
0156 // ------------ method called once each job just before starting event loop  ------------
0157 void StripValidationPlots::beginJob() {
0158   oss.str("");
0159   oss << 1;  //runNumber
0160 
0161   dqmStore_ = edm::Service<DQMStore>().operator->();
0162   dqmStore_->setCurrentFolder("ChannelStatusPlots");
0163 
0164   for (int i = 0; i < 768; i++) {
0165     for (int j = 0; j < 5; j++)
0166       nReadStrips[i][j] = 0;
0167   }
0168 
0169   // Initialize histograms
0170   subDetName.push_back("");
0171   subDetName.push_back("TIB");
0172   subDetName.push_back("TID");
0173   subDetName.push_back("TOB");
0174   subDetName.push_back("TEC");
0175   std::string histoName;
0176   std::string histoTitle;
0177   for (unsigned int i = 0; i < subDetName.size(); i++) {
0178     histoName = "distanceVsStripNumber" + subDetName[i];
0179     histoTitle = "Distance between hot strips vs. strip number";
0180     if (i != 0)
0181       histoTitle += " in " + subDetName[i];
0182     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 999, 0.5, 999.5);
0183     distanceVsStripNumber.push_back(tmp->getTH2F());
0184 
0185     histoName = "pfxDistanceVsStripNumber" + subDetName[i];
0186     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
0187     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
0188     pfxDistanceVsStripNumber.push_back(tmp->getTProfile());
0189     pfxDistanceVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
0190     pfxDistanceVsStripNumber[i]->GetYaxis()->SetTitle("Distance");
0191 
0192     histoName = "projXDistanceVsStripNumber" + subDetName[i];
0193     histoTitle = "Number of hot strips vs. strip number";
0194     if (i != 0)
0195       histoTitle += " in " + subDetName[i];
0196     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
0197     projXDistanceVsStripNumber.push_back(tmp->getTH1F());
0198     projXDistanceVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
0199     projXDistanceVsStripNumber[i]->GetYaxis()->SetTitle("N_{hot}");
0200 
0201     histoName = "projYDistanceVsStripNumber" + subDetName[i];
0202     histoTitle = "Distribution of distance between hot strips";
0203     if (i != 0)
0204       histoTitle += " in " + subDetName[i];
0205     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 999, 0.5, 999.5);
0206     projYDistanceVsStripNumber.push_back(tmp->getTH1F());
0207     projYDistanceVsStripNumber[i]->GetXaxis()->SetTitle("Distance");
0208     projYDistanceVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
0209 
0210     //
0211     histoName = "occupancyVsStripNumber" + subDetName[i];
0212     histoTitle = "Occupancy of strips vs. strip number";
0213     if (i != 0)
0214       histoTitle += " in " + subDetName[i];
0215     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -8., 0.);
0216     occupancyVsStripNumber.push_back(tmp->getTH2F());
0217 
0218     histoName = "pfxOccupancyVsStripNumber" + subDetName[i];
0219     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
0220     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
0221     pfxOccupancyVsStripNumber.push_back(tmp->getTProfile());
0222     pfxOccupancyVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
0223     pfxOccupancyVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Occupancy)");
0224 
0225     histoName = "projYOccupancyVsStripNumber" + subDetName[i];
0226     histoTitle = "Distribution of strip occupancy";
0227     if (i != 0)
0228       histoTitle += " in " + subDetName[i];
0229     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -8., 0.);
0230     projYOccupancyVsStripNumber.push_back(tmp->getTH1F());
0231     projYOccupancyVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
0232     projYOccupancyVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
0233 
0234     //
0235     histoName = "occupancyHotStripsVsStripNumber" + subDetName[i];
0236     histoTitle = "Occupancy of hot strips vs. strip number";
0237     if (i != 0)
0238       histoTitle += " in " + subDetName[i];
0239     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -8., 0.);
0240     occupancyHotStripsVsStripNumber.push_back(tmp->getTH2F());
0241 
0242     histoName = "pfxOccupancyHotStripsVsStripNumber" + subDetName[i];
0243     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
0244     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
0245     pfxOccupancyHotStripsVsStripNumber.push_back(tmp->getTProfile());
0246     pfxOccupancyHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
0247     pfxOccupancyHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Occupancy)");
0248 
0249     histoName = "projYOccupancyHotStripsVsStripNumber" + subDetName[i];
0250     histoTitle = "Distribution of hot strip occupancy";
0251     if (i != 0)
0252       histoTitle += " in " + subDetName[i];
0253     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -8., 0.);
0254     projYOccupancyHotStripsVsStripNumber.push_back(tmp->getTH1F());
0255     projYOccupancyHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
0256     projYOccupancyHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
0257 
0258     //
0259     histoName = "occupancyGoodStripsVsStripNumber" + subDetName[i];
0260     histoTitle = "Occupancy of good strips vs. strip number";
0261     if (i != 0)
0262       histoTitle += " in " + subDetName[i];
0263     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -8., 0.);
0264     occupancyGoodStripsVsStripNumber.push_back(tmp->getTH2F());
0265 
0266     histoName = "pfxOccupancyGoodStripsVsStripNumber" + subDetName[i];
0267     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
0268     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
0269     pfxOccupancyGoodStripsVsStripNumber.push_back(tmp->getTProfile());
0270     pfxOccupancyGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
0271     pfxOccupancyGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Occupancy)");
0272 
0273     histoName = "projYOccupancyGoodStripsVsStripNumber" + subDetName[i];
0274     histoTitle = "Distribution of good strip occupancy";
0275     if (i != 0)
0276       histoTitle += " in " + subDetName[i];
0277     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -8., 0.);
0278     projYOccupancyGoodStripsVsStripNumber.push_back(tmp->getTH1F());
0279     projYOccupancyGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
0280     projYOccupancyGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
0281 
0282     //
0283     histoName = "poissonProbVsStripNumber" + subDetName[i];
0284     histoTitle = "Poisson probability of strips vs. strip number";
0285     if (i != 0)
0286       histoTitle += " in " + subDetName[i];
0287     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -18., 0.);
0288     poissonProbVsStripNumber.push_back(tmp->getTH2F());
0289 
0290     histoName = "pfxPoissonProbVsStripNumber" + subDetName[i];
0291     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
0292     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
0293     pfxPoissonProbVsStripNumber.push_back(tmp->getTProfile());
0294     pfxPoissonProbVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
0295     pfxPoissonProbVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Probability)");
0296 
0297     histoName = "projYPoissonProbVsStripNumber" + subDetName[i];
0298     histoTitle = "Distribution of strip Poisson probability";
0299     if (i != 0)
0300       histoTitle += " in " + subDetName[i];
0301     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -18., 0.);
0302     projYPoissonProbVsStripNumber.push_back(tmp->getTH1F());
0303     projYPoissonProbVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Probability)");
0304     projYPoissonProbVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
0305 
0306     //
0307     histoName = "poissonProbHotStripsVsStripNumber" + subDetName[i];
0308     histoTitle = "Poisson probability of hot strips vs. strip number";
0309     if (i != 0)
0310       histoTitle += " in " + subDetName[i];
0311     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -18., 0.);
0312     poissonProbHotStripsVsStripNumber.push_back(tmp->getTH2F());
0313 
0314     histoName = "pfxPoissonProbHotStripsVsStripNumber" + subDetName[i];
0315     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
0316     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
0317     pfxPoissonProbHotStripsVsStripNumber.push_back(tmp->getTProfile());
0318     pfxPoissonProbHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
0319     pfxPoissonProbHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Probability)");
0320 
0321     histoName = "projYPoissonProbHotStripsVsStripNumber" + subDetName[i];
0322     histoTitle = "Distribution of hot strip Poisson probability";
0323     if (i != 0)
0324       histoTitle += " in " + subDetName[i];
0325     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -18., 0.);
0326     projYPoissonProbHotStripsVsStripNumber.push_back(tmp->getTH1F());
0327     projYPoissonProbHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Probability)");
0328     projYPoissonProbHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
0329 
0330     //
0331     histoName = "poissonProbGoodStripsVsStripNumber" + subDetName[i];
0332     histoTitle = "Poisson probability of good strips vs. strip number";
0333     if (i != 0)
0334       histoTitle += " in " + subDetName[i];
0335     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -18., 0.);
0336     poissonProbGoodStripsVsStripNumber.push_back(tmp->getTH2F());
0337 
0338     histoName = "pfxPoissonProbGoodStripsVsStripNumber" + subDetName[i];
0339     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
0340     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
0341     pfxPoissonProbGoodStripsVsStripNumber.push_back(tmp->getTProfile());
0342     pfxPoissonProbGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
0343     pfxPoissonProbGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Probability)");
0344 
0345     histoName = "projYPoissonProbGoodStripsVsStripNumber" + subDetName[i];
0346     histoTitle = "Distribution of good strip Poisson probability";
0347     if (i != 0)
0348       histoTitle += " in " + subDetName[i];
0349     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -18., 0.);
0350     projYPoissonProbGoodStripsVsStripNumber.push_back(tmp->getTH1F());
0351     projYPoissonProbGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Probability)");
0352     projYPoissonProbGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
0353 
0354     //
0355     histoName = "nHitsVsStripNumber" + subDetName[i];
0356     histoTitle = "NHits in strips vs. strip number";
0357     if (i != 0)
0358       histoTitle += " in " + subDetName[i];
0359     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 10000, -0.5, 9999.5);
0360     nHitsVsStripNumber.push_back(tmp->getTH2F());
0361 
0362     histoName = "pfxNHitsVsStripNumber" + subDetName[i];
0363     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
0364     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
0365     pfxNHitsVsStripNumber.push_back(tmp->getTProfile());
0366 
0367     histoName = "projXNHitsVsStripNumber" + subDetName[i];
0368     histoTitle = "Cumulative nHits in strips vs. strip number";
0369     if (i != 0)
0370       histoTitle += " in " + subDetName[i];
0371     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
0372     projXNHitsVsStripNumber.push_back(tmp->getTH1F());
0373 
0374     histoName = "projYNHitsVsStripNumber" + subDetName[i];
0375     histoTitle = "Distribution of nHits for all strips";
0376     if (i != 0)
0377       histoTitle += " in " + subDetName[i];
0378     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 10000, -0.5, 9999.5);
0379     projYNHitsVsStripNumber.push_back(tmp->getTH1F());
0380     projYNHitsVsStripNumber[i]->GetXaxis()->SetTitle("N_{hits}");
0381     projYNHitsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
0382 
0383     //
0384     histoName = "nHitsHotStripsVsStripNumber" + subDetName[i];
0385     histoTitle = "NHits in hot strips vs. strip number";
0386     if (i != 0)
0387       histoTitle += " in " + subDetName[i];
0388     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 10000, -0.5, 9999.5);
0389     nHitsHotStripsVsStripNumber.push_back(tmp->getTH2F());
0390 
0391     histoName = "pfxNHitsHotStripsVsStripNumber" + subDetName[i];
0392     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
0393     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
0394     pfxNHitsHotStripsVsStripNumber.push_back(tmp->getTProfile());
0395 
0396     histoName = "projXNHitsHotStripsVsStripNumber" + subDetName[i];
0397     histoTitle = "Cumulative nHits in hot strips vs. strip number";
0398     if (i != 0)
0399       histoTitle += " in " + subDetName[i];
0400     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
0401     projXNHitsHotStripsVsStripNumber.push_back(tmp->getTH1F());
0402 
0403     histoName = "projYNHitsHotStripsVsStripNumber" + subDetName[i];
0404     histoTitle = "Distribution of nHits for hot strips";
0405     if (i != 0)
0406       histoTitle += " in " + subDetName[i];
0407     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 10000, -0.5, 9999.5);
0408     projYNHitsHotStripsVsStripNumber.push_back(tmp->getTH1F());
0409     projYNHitsHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("N_{hits}");
0410     projYNHitsHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
0411 
0412     //
0413     histoName = "nHitsGoodStripsVsStripNumber" + subDetName[i];
0414     histoTitle = "NHits in good strips vs. strip number";
0415     if (i != 0)
0416       histoTitle += " in " + subDetName[i];
0417     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 10000, -0.5, 9999.5);
0418     nHitsGoodStripsVsStripNumber.push_back(tmp->getTH2F());
0419 
0420     histoName = "pfxNHitsGoodStripsVsStripNumber" + subDetName[i];
0421     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
0422     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
0423     pfxNHitsGoodStripsVsStripNumber.push_back(tmp->getTProfile());
0424 
0425     histoName = "projXNHitsGoodStripsVsStripNumber" + subDetName[i];
0426     histoTitle = "Cumulative nHits in good strips vs. strip number";
0427     if (i != 0)
0428       histoTitle += " in " + subDetName[i];
0429     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
0430     projXNHitsGoodStripsVsStripNumber.push_back(tmp->getTH1F());
0431 
0432     histoName = "projYNHitsGoodStripsVsStripNumber" + subDetName[i];
0433     histoTitle = "Distribution of nHits for good strips";
0434     if (i != 0)
0435       histoTitle += " in " + subDetName[i];
0436     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 10000, -0.5, 9999.5);
0437     projYNHitsGoodStripsVsStripNumber.push_back(tmp->getTH1F());
0438     projYNHitsGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("N_{hits}");
0439     projYNHitsGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
0440   }
0441 }
0442 
0443 // ------------ method called once each job just after ending the event loop  ------------
0444 void StripValidationPlots::endJob() {
0445   infile = new TFile(infilename.c_str(), "READ");
0446   intree = (TTree*)infile->Get("stripOccupancy");
0447 
0448   intree->SetBranchAddress("DetRawId", &DetRawId);
0449   intree->SetBranchAddress("SubDetId", &SubDetId);
0450   intree->SetBranchAddress("Layer_Ring", &Layer_Ring);
0451   intree->SetBranchAddress("Disc", &Disc);
0452   intree->SetBranchAddress("IsBack", &IsBack);
0453   intree->SetBranchAddress("IsExternalString", &IsExternalString);
0454   intree->SetBranchAddress("IsZMinusSide", &IsZMinusSide);
0455   intree->SetBranchAddress("RodStringPetal", &RodStringPetal);
0456   intree->SetBranchAddress("IsStereo", &IsStereo);
0457   intree->SetBranchAddress("ModulePosition", &ModulePosition);
0458   intree->SetBranchAddress("NumberOfStrips", &NumberOfStrips);
0459   intree->SetBranchAddress("StripNumber", &StripNumber);
0460   intree->SetBranchAddress("APVChannel", &APVChannel);
0461   intree->SetBranchAddress("StripGlobalPositionX", &StripGlobalPositionX);
0462   intree->SetBranchAddress("StripGlobalPositionY", &StripGlobalPositionY);
0463   intree->SetBranchAddress("StripGlobalPositionZ", &StripGlobalPositionZ);
0464   intree->SetBranchAddress("IsHot", &IsHot);
0465   intree->SetBranchAddress("HotStripsPerAPV", &HotStripsPerAPV);
0466   intree->SetBranchAddress("HotStripsPerModule", &HotStripsPerModule);
0467   intree->SetBranchAddress("StripOccupancy", &StripOccupancy);
0468   intree->SetBranchAddress("StripHits", &StripHits);
0469   intree->SetBranchAddress("PoissonProb", &PoissonProb);
0470 
0471   for (int i = 0; i < intree->GetEntries(); /* */) {
0472     intree->GetEntry(i);
0473 
0474     savedNStrips = NumberOfStrips;
0475     firstEntry = i;
0476     savedDetRawId = DetRawId;
0477     savedSubDetId = SubDetId;
0478     vHotStripsInModule.clear();
0479 
0480     for (int j = firstEntry; j < firstEntry + savedNStrips; j++) {
0481       intree->GetEntry(j);
0482 
0483       if (DetRawId != savedDetRawId) {
0484         std::cout << "ERROR! DetRawId changed but I expected to be on the same module!\n";
0485         return;
0486       }
0487 
0488       double logStripOccupancy = log10(StripOccupancy);
0489       double logPoissonProb = log10(fabs(PoissonProb));
0490 
0491       (nReadStrips[StripNumber - 1][0])++;
0492       (nReadStrips[StripNumber - 1][SubDetId - 2])++;
0493       //std::cout << "StripNumber = " << StripNumber << ", SubDetId = " << SubDetId << ", nReadStripsAll = " << nReadStrips[StripNumber-1][0] << ", nReadStripsSubDet = " << nReadStrips[StripNumber-1][SubDetId-2] << std::endl;
0494       occupancyVsStripNumber[0]->Fill(StripNumber, logStripOccupancy);
0495       occupancyVsStripNumber[SubDetId - 2]->Fill(StripNumber, logStripOccupancy);
0496       poissonProbVsStripNumber[0]->Fill(StripNumber, logPoissonProb);
0497       poissonProbVsStripNumber[SubDetId - 2]->Fill(StripNumber, logPoissonProb);
0498       nHitsVsStripNumber[0]->Fill(StripNumber, StripHits);
0499       nHitsVsStripNumber[SubDetId - 2]->Fill(StripNumber, StripHits);
0500 
0501       if (IsHot) {
0502         vHotStripsInModule.push_back(StripNumber);
0503         //          std::cout << "detId = " << DetRawId << ", StripN = " << StripNumber << ", StripOccupancy = " << StripOccupancy << " PoissonProb = " << PoissonProb << std::endl ;
0504         occupancyHotStripsVsStripNumber[0]->Fill(StripNumber, logStripOccupancy);
0505         occupancyHotStripsVsStripNumber[SubDetId - 2]->Fill(StripNumber, logStripOccupancy);
0506         poissonProbHotStripsVsStripNumber[0]->Fill(StripNumber, logPoissonProb);
0507         poissonProbHotStripsVsStripNumber[SubDetId - 2]->Fill(StripNumber, logPoissonProb);
0508         nHitsHotStripsVsStripNumber[0]->Fill(StripNumber, StripHits);
0509         nHitsHotStripsVsStripNumber[SubDetId - 2]->Fill(StripNumber, StripHits);
0510       } else {
0511         occupancyGoodStripsVsStripNumber[0]->Fill(StripNumber, logStripOccupancy);
0512         occupancyGoodStripsVsStripNumber[SubDetId - 2]->Fill(StripNumber, logStripOccupancy);
0513         poissonProbGoodStripsVsStripNumber[0]->Fill(StripNumber, logPoissonProb);
0514         poissonProbGoodStripsVsStripNumber[SubDetId - 2]->Fill(StripNumber, logPoissonProb);
0515         nHitsGoodStripsVsStripNumber[0]->Fill(StripNumber, StripHits);
0516         nHitsGoodStripsVsStripNumber[SubDetId - 2]->Fill(StripNumber, StripHits);
0517       }
0518     }
0519 
0520     if (vHotStripsInModule.size() == 1) {
0521       distance = 999;
0522       distanceVsStripNumber[0]->Fill(vHotStripsInModule[0], distance);
0523       distanceVsStripNumber[savedSubDetId - 2]->Fill(vHotStripsInModule[0], distance);
0524     } else if (vHotStripsInModule.size() > 1) {
0525       for (unsigned int iVec = 0; iVec != vHotStripsInModule.size(); iVec++) {
0526         if (iVec == 0)
0527           distance = vHotStripsInModule[1] - vHotStripsInModule[0];
0528         else if (iVec == vHotStripsInModule.size() - 1) {
0529           distance =
0530               vHotStripsInModule[vHotStripsInModule.size() - 1] - vHotStripsInModule[vHotStripsInModule.size() - 2];
0531         } else if (vHotStripsInModule.size() > 2) {
0532           distanceR = vHotStripsInModule[iVec + 1] - vHotStripsInModule[iVec];
0533           distanceL = vHotStripsInModule[iVec] - vHotStripsInModule[iVec - 1];
0534           distance = distanceL > distanceR ? distanceR : distanceL;
0535         } else {
0536           std::cout << "ERROR! distance is never computed!!!\n";
0537         }
0538         //          std::cout << "detId = " << savedDetRawId << ", StripN = " << vHotStripsInModule[iVec] << ", distance = " << distance << std::endl;
0539         distanceVsStripNumber[0]->Fill(vHotStripsInModule[iVec], distance);
0540         distanceVsStripNumber[savedSubDetId - 2]->Fill(vHotStripsInModule[iVec], distance);
0541       }
0542     }
0543 
0544     i += savedNStrips;
0545   }
0546 
0547   std::string histoName;
0548   std::string histoTitle;
0549 
0550   for (unsigned int i = 0; i < subDetName.size(); i++) {
0551     projYDistanceVsStripNumber[i]->Add((TH1F*)distanceVsStripNumber[i]->ProjectionY());
0552     pfxDistanceVsStripNumber[i]->Add(
0553         distanceVsStripNumber[i]->ProfileX(pfxDistanceVsStripNumber[i]->GetName(), 1, 998));
0554     projYNHitsVsStripNumber[i]->Add(nHitsVsStripNumber[i]->ProjectionY());
0555     projYNHitsGoodStripsVsStripNumber[i]->Add(nHitsGoodStripsVsStripNumber[i]->ProjectionY());
0556     projYNHitsHotStripsVsStripNumber[i]->Add(nHitsHotStripsVsStripNumber[i]->ProjectionY());
0557     projYOccupancyVsStripNumber[i]->Add(occupancyVsStripNumber[i]->ProjectionY());
0558     projYOccupancyGoodStripsVsStripNumber[i]->Add(occupancyGoodStripsVsStripNumber[i]->ProjectionY());
0559     projYOccupancyHotStripsVsStripNumber[i]->Add(occupancyHotStripsVsStripNumber[i]->ProjectionY());
0560     pfxOccupancyVsStripNumber[i]->Add(
0561         occupancyVsStripNumber[i]->ProfileX(pfxOccupancyVsStripNumber[i]->GetName(), -8., 0.));
0562     pfxOccupancyGoodStripsVsStripNumber[i]->Add(
0563         occupancyGoodStripsVsStripNumber[i]->ProfileX(pfxOccupancyGoodStripsVsStripNumber[i]->GetName(), -8., 0.));
0564     pfxOccupancyHotStripsVsStripNumber[i]->Add(
0565         occupancyHotStripsVsStripNumber[i]->ProfileX(pfxOccupancyHotStripsVsStripNumber[i]->GetName(), -8., 0.));
0566     projYPoissonProbVsStripNumber[i]->Add(poissonProbVsStripNumber[i]->ProjectionY());
0567     projYPoissonProbGoodStripsVsStripNumber[i]->Add(poissonProbGoodStripsVsStripNumber[i]->ProjectionY());
0568     projYPoissonProbHotStripsVsStripNumber[i]->Add(poissonProbHotStripsVsStripNumber[i]->ProjectionY());
0569     pfxPoissonProbVsStripNumber[i]->Add(
0570         poissonProbVsStripNumber[i]->ProfileX(pfxPoissonProbVsStripNumber[i]->GetName(), -18., 0.));
0571     pfxPoissonProbGoodStripsVsStripNumber[i]->Add(
0572         poissonProbGoodStripsVsStripNumber[i]->ProfileX(pfxPoissonProbGoodStripsVsStripNumber[i]->GetName(), -18., 0.));
0573     pfxPoissonProbHotStripsVsStripNumber[i]->Add(
0574         poissonProbHotStripsVsStripNumber[i]->ProfileX(pfxPoissonProbHotStripsVsStripNumber[i]->GetName(), -18., 0.));
0575     projXDistanceVsStripNumber[i]->Add(
0576         distanceVsStripNumber[i]->ProjectionX(projXDistanceVsStripNumber[i]->GetName(), 1, 998));
0577   }
0578 
0579   dqmStore_->cd();
0580   dqmStore_->save(outfilename, "ChannelStatusPlots");
0581 }
0582 
0583 //define this as a plug-in
0584 DEFINE_FWK_MODULE(StripValidationPlots);