CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DQMOffline/CalibTracker/src/StripValidationPlots.cc

Go to the documentation of this file.
00001 // system include files
00002 #include <memory>
00003 
00004 // user include files
00005 #include "FWCore/Framework/interface/Frameworkfwd.h"
00006 #include "FWCore/Framework/interface/EDAnalyzer.h"
00007 
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "FWCore/Framework/interface/MakerMacros.h"
00010 
00011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00012 
00013 #include "FWCore/ServiceRegistry/interface/Service.h"
00014 
00015 #include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h"
00016 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00017 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00018 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00019 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00020 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00021 #include "DataFormats/Common/interface/DetSetVector.h"
00022 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00023 
00024 #include "DQMServices/Core/interface/DQMStore.h"
00025 #include "DQMServices/Core/interface/MonitorElement.h"
00026 
00027 #include "TH1F.h"
00028 #include "TFile.h"
00029 #include "TCanvas.h"
00030 #include "TH1.h"
00031 #include "TH2F.h"
00032 #include "TH1D.h"
00033 #include "TProfile.h"
00034 #include "TStyle.h"
00035 #include "TTree.h"
00036 
00037 #include <sstream>
00038 #include <iostream>
00039 #include <vector>
00040 
00041 //
00042 // class decleration
00043 //
00044 
00045 class StripValidationPlots : public edm::EDAnalyzer {
00046    public:
00047       explicit StripValidationPlots(const edm::ParameterSet&);
00048       ~StripValidationPlots();
00049 
00050 
00051    private:
00052       virtual void beginJob() ;
00053       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00054       virtual void endJob() ;
00055 
00056   std::ostringstream oss;
00057 
00058   DQMStore* dqmStore_;
00059 
00060   MonitorElement* tmp;
00061   TProfile* tmp_prof;
00062 
00063   // Histograms
00064   std::vector<TH2F*> distanceVsStripNumber;
00065   std::vector<TProfile*> pfxDistanceVsStripNumber;
00066   std::vector<TH1F*> projXDistanceVsStripNumber;
00067   std::vector<TH1F*> projYDistanceVsStripNumber;
00068 
00069   std::vector<TH2F*> occupancyVsStripNumber;
00070   std::vector<TProfile*> pfxOccupancyVsStripNumber;
00071   std::vector<TH1F*> projYOccupancyVsStripNumber;
00072   std::vector<TH2F*> occupancyHotStripsVsStripNumber;
00073   std::vector<TProfile*> pfxOccupancyHotStripsVsStripNumber;
00074   std::vector<TH1F*> projYOccupancyHotStripsVsStripNumber;
00075   std::vector<TH2F*> occupancyGoodStripsVsStripNumber;
00076   std::vector<TProfile*> pfxOccupancyGoodStripsVsStripNumber;
00077   std::vector<TH1F*> projYOccupancyGoodStripsVsStripNumber;
00078 
00079   std::vector<TH2F*> poissonProbVsStripNumber;
00080   std::vector<TProfile*> pfxPoissonProbVsStripNumber;
00081   std::vector<TH1F*> projYPoissonProbVsStripNumber;
00082   std::vector<TH2F*> poissonProbHotStripsVsStripNumber;
00083   std::vector<TProfile*> pfxPoissonProbHotStripsVsStripNumber;
00084   std::vector<TH1F*> projYPoissonProbHotStripsVsStripNumber;
00085   std::vector<TH2F*> poissonProbGoodStripsVsStripNumber;
00086   std::vector<TProfile*> pfxPoissonProbGoodStripsVsStripNumber;
00087   std::vector<TH1F*> projYPoissonProbGoodStripsVsStripNumber;
00088    
00089   std::vector<TH2F*> nHitsVsStripNumber;
00090   std::vector<TProfile*> pfxNHitsVsStripNumber;
00091   std::vector<TH1F*> projXNHitsVsStripNumber;
00092   std::vector<TH1F*> projYNHitsVsStripNumber;
00093   std::vector<TH2F*> nHitsHotStripsVsStripNumber;
00094   std::vector<TProfile*> pfxNHitsHotStripsVsStripNumber;
00095   std::vector<TH1F*> projXNHitsHotStripsVsStripNumber;
00096   std::vector<TH1F*> projYNHitsHotStripsVsStripNumber;
00097   std::vector<TH2F*> nHitsGoodStripsVsStripNumber;
00098   std::vector<TProfile*> pfxNHitsGoodStripsVsStripNumber;
00099   std::vector<TH1F*> projXNHitsGoodStripsVsStripNumber;
00100   std::vector<TH1F*> projYNHitsGoodStripsVsStripNumber;
00101    
00102   std::vector<std::string> subDetName;
00103 
00104   std::string infilename;
00105   std::string outfilename;
00106 
00107   TFile* infile;
00108   TTree* intree;
00109 
00110   // Declaration of leaf types
00111   Int_t           DetRawId;
00112   Int_t           SubDetId;
00113   Int_t           Layer_Ring;
00114   Int_t           Disc;
00115   Int_t           IsBack;
00116   Int_t           IsExternalString;
00117   Int_t           IsZMinusSide;
00118   Int_t           RodStringPetal;
00119   Int_t           IsStereo;
00120   Int_t           ModulePosition;
00121   Int_t           NumberOfStrips;
00122   Int_t           StripNumber;
00123   Int_t           APVChannel;
00124   Float_t         StripGlobalPositionX;
00125   Float_t         StripGlobalPositionY;
00126   Float_t         StripGlobalPositionZ;
00127   Int_t           IsHot;
00128   Int_t           HotStripsPerAPV;
00129   Int_t           HotStripsPerModule;
00130   Double_t        StripOccupancy;
00131   Int_t           StripHits;
00132   Double_t        PoissonProb;
00133 
00134 
00135   Int_t savedDetRawId;
00136   Int_t savedNStrips;
00137   Int_t savedSubDetId;
00138   Int_t firstEntry;
00139   std::vector<unsigned int> vHotStripsInModule;
00140   unsigned int distance;
00141   unsigned int distanceR, distanceL;
00142   unsigned int nReadStrips[768][5];
00143 
00144       // ----------member data ---------------------------
00145 };
00146 
00147 //
00148 // constants, enums and typedefs
00149 //
00150 
00151 //
00152 // static data member definitions
00153 //
00154 
00155 //
00156 // constructors and destructor
00157 //
00158 StripValidationPlots::StripValidationPlots(const edm::ParameterSet& iConfig) : infilename(iConfig.getUntrackedParameter<std::string>("inputFilename","in.root")),
00159                                                                                outfilename(iConfig.getUntrackedParameter<std::string>("outputFilename","out.root"))
00160 
00161 {
00162    //now do what ever initialization is needed
00163 
00164 }
00165 
00166 
00167 StripValidationPlots::~StripValidationPlots()
00168 {
00169  
00170    // do anything here that needs to be done at desctruction time
00171    // (e.g. close files, deallocate resources etc.)
00172 
00173 }
00174 
00175 
00176 //
00177 // member functions
00178 //
00179 
00180 // ------------ method called to for each event  ------------
00181 void
00182 StripValidationPlots::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00183 {
00184 
00185 }
00186 
00187 
00188 // ------------ method called once each job just before starting event loop  ------------
00189 void 
00190 StripValidationPlots::beginJob()
00191 {
00192   oss.str("");
00193   oss << 1; //runNumber
00194 
00195   dqmStore_ = edm::Service<DQMStore>().operator->();
00196   dqmStore_->setCurrentFolder("ChannelStatusPlots");
00197 
00198   for (int i=0; i<768; i++)
00199     {
00200       for (int j=0; j<5; j++)
00201         nReadStrips[i][j]=0;
00202     }
00203 
00204   // Initialize histograms
00205   subDetName.push_back(""); subDetName.push_back("TIB"); subDetName.push_back("TID"); subDetName.push_back("TOB"); subDetName.push_back("TEC");
00206   std::string histoName;
00207   std::string histoTitle;
00208   for(unsigned int i = 0; i < subDetName.size(); i++)
00209   {
00210     histoName = "distanceVsStripNumber" + subDetName[i];
00211     histoTitle = "Distance between hot strips vs. strip number";
00212     if(i!=0)
00213       histoTitle += " in " + subDetName[i];
00214     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 999, 0.5, 999.5);
00215     distanceVsStripNumber.push_back(tmp->getTH2F());
00216 
00217     histoName = "pfxDistanceVsStripNumber" + subDetName[i];
00218     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
00219     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
00220     pfxDistanceVsStripNumber.push_back(tmp->getTProfile());
00221     pfxDistanceVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
00222     pfxDistanceVsStripNumber[i]->GetYaxis()->SetTitle("Distance");
00223 
00224     histoName = "projXDistanceVsStripNumber" + subDetName[i];
00225     histoTitle = "Number of hot strips vs. strip number";
00226     if(i!=0)
00227       histoTitle += " in " + subDetName[i];
00228     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
00229     projXDistanceVsStripNumber.push_back(tmp->getTH1F());
00230     projXDistanceVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
00231     projXDistanceVsStripNumber[i]->GetYaxis()->SetTitle("N_{hot}");
00232     
00233     histoName = "projYDistanceVsStripNumber" + subDetName[i];
00234     histoTitle = "Distribution of distance between hot strips";
00235     if(i!=0)
00236       histoTitle += " in " + subDetName[i];
00237     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 999, 0.5, 999.5);
00238     projYDistanceVsStripNumber.push_back(tmp->getTH1F());
00239     projYDistanceVsStripNumber[i]->GetXaxis()->SetTitle("Distance");
00240     projYDistanceVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
00241     
00242     //
00243     histoName = "occupancyVsStripNumber" + subDetName[i];
00244     histoTitle = "Occupancy of strips vs. strip number";
00245     if(i!=0)
00246       histoTitle += " in " + subDetName[i];
00247     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -8.,0.);
00248     occupancyVsStripNumber.push_back(tmp->getTH2F());
00249     
00250     histoName = "pfxOccupancyVsStripNumber" + subDetName[i];
00251     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
00252     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
00253     pfxOccupancyVsStripNumber.push_back(tmp->getTProfile());
00254     pfxOccupancyVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
00255     pfxOccupancyVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Occupancy)");
00256     
00257     histoName = "projYOccupancyVsStripNumber" + subDetName[i];
00258     histoTitle = "Distribution of strip occupancy";
00259     if(i!=0)
00260       histoTitle += " in " + subDetName[i];
00261     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -8., 0.);
00262     projYOccupancyVsStripNumber.push_back(tmp->getTH1F());
00263     projYOccupancyVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
00264     projYOccupancyVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
00265     
00266     //
00267     histoName = "occupancyHotStripsVsStripNumber" + subDetName[i];
00268     histoTitle = "Occupancy of hot strips vs. strip number";
00269     if(i!=0)
00270       histoTitle += " in " + subDetName[i];
00271     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -8., 0.);
00272     occupancyHotStripsVsStripNumber.push_back(tmp->getTH2F());
00273     
00274     histoName = "pfxOccupancyHotStripsVsStripNumber" + subDetName[i];
00275     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
00276     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
00277     pfxOccupancyHotStripsVsStripNumber.push_back(tmp->getTProfile());
00278     pfxOccupancyHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
00279     pfxOccupancyHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Occupancy)");
00280     
00281     histoName = "projYOccupancyHotStripsVsStripNumber" + subDetName[i];
00282     histoTitle = "Distribution of hot strip occupancy";
00283     if(i!=0)
00284       histoTitle += " in " + subDetName[i];
00285     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -8., 0.);
00286     projYOccupancyHotStripsVsStripNumber.push_back(tmp->getTH1F());
00287     projYOccupancyHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
00288     projYOccupancyHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
00289     
00290     //
00291     histoName = "occupancyGoodStripsVsStripNumber" + subDetName[i];
00292     histoTitle = "Occupancy of good strips vs. strip number";
00293     if(i!=0)
00294       histoTitle += " in " + subDetName[i];
00295     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -8., 0.);
00296     occupancyGoodStripsVsStripNumber.push_back(tmp->getTH2F());
00297     
00298     histoName = "pfxOccupancyGoodStripsVsStripNumber" + subDetName[i];
00299     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
00300     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
00301     pfxOccupancyGoodStripsVsStripNumber.push_back(tmp->getTProfile());
00302     pfxOccupancyGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
00303     pfxOccupancyGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Occupancy)");
00304     
00305     histoName = "projYOccupancyGoodStripsVsStripNumber" + subDetName[i];
00306     histoTitle = "Distribution of good strip occupancy";
00307     if(i!=0)
00308       histoTitle += " in " + subDetName[i];
00309     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -8., 0.);
00310     projYOccupancyGoodStripsVsStripNumber.push_back(tmp->getTH1F());
00311     projYOccupancyGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
00312     projYOccupancyGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
00313     
00314     //
00315     histoName = "poissonProbVsStripNumber" + subDetName[i];
00316     histoTitle = "Poisson probability of strips vs. strip number";
00317     if(i!=0)
00318       histoTitle += " in " + subDetName[i];
00319     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -18., 0.);
00320     poissonProbVsStripNumber.push_back(tmp->getTH2F());
00321     
00322     histoName = "pfxPoissonProbVsStripNumber" + subDetName[i];
00323     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
00324     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
00325     pfxPoissonProbVsStripNumber.push_back(tmp->getTProfile());
00326     pfxPoissonProbVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
00327     pfxPoissonProbVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Probability)");
00328     
00329     histoName = "projYPoissonProbVsStripNumber" + subDetName[i];
00330     histoTitle = "Distribution of strip Poisson probability";
00331     if(i!=0)
00332       histoTitle += " in " + subDetName[i];
00333     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -18., 0.);
00334     projYPoissonProbVsStripNumber.push_back(tmp->getTH1F());
00335     projYPoissonProbVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Probability)");
00336     projYPoissonProbVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
00337     
00338     //
00339     histoName = "poissonProbHotStripsVsStripNumber" + subDetName[i];
00340     histoTitle = "Poisson probability of hot strips vs. strip number";
00341     if(i!=0)
00342       histoTitle += " in " + subDetName[i];
00343     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -18., 0.);
00344     poissonProbHotStripsVsStripNumber.push_back(tmp->getTH2F());
00345     
00346     histoName = "pfxPoissonProbHotStripsVsStripNumber" + subDetName[i];
00347     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
00348     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
00349     pfxPoissonProbHotStripsVsStripNumber.push_back(tmp->getTProfile());
00350     pfxPoissonProbHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
00351     pfxPoissonProbHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Probability)");
00352     
00353     histoName = "projYPoissonProbHotStripsVsStripNumber" + subDetName[i];
00354     histoTitle = "Distribution of hot strip Poisson probability";
00355     if(i!=0)
00356       histoTitle += " in " + subDetName[i];
00357     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -18., 0.);
00358     projYPoissonProbHotStripsVsStripNumber.push_back(tmp->getTH1F());
00359     projYPoissonProbHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Probability)");
00360     projYPoissonProbHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
00361     
00362     //
00363     histoName = "poissonProbGoodStripsVsStripNumber" + subDetName[i];
00364     histoTitle = "Poisson probability of good strips vs. strip number";
00365     if(i!=0)
00366       histoTitle += " in " + subDetName[i];
00367     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 1000, -18., 0.);
00368     poissonProbGoodStripsVsStripNumber.push_back(tmp->getTH2F());
00369     
00370     histoName = "pfxPoissonProbGoodStripsVsStripNumber" + subDetName[i];
00371     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
00372     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
00373     pfxPoissonProbGoodStripsVsStripNumber.push_back(tmp->getTProfile());
00374     pfxPoissonProbGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("Strip");
00375     pfxPoissonProbGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("log_{10}(Probability)");
00376     
00377     histoName = "projYPoissonProbGoodStripsVsStripNumber" + subDetName[i];
00378     histoTitle = "Distribution of good strip Poisson probability";
00379     if(i!=0)
00380       histoTitle += " in " + subDetName[i];
00381     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -18., 0.);
00382     projYPoissonProbGoodStripsVsStripNumber.push_back(tmp->getTH1F());
00383     projYPoissonProbGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("log_{10}(Probability)");
00384     projYPoissonProbGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
00385 
00386     //
00387     histoName = "nHitsVsStripNumber" + subDetName[i];
00388     histoTitle = "NHits in strips vs. strip number";
00389     if(i!=0)
00390       histoTitle += " in " + subDetName[i];
00391     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 10000, -0.5, 9999.5);
00392     nHitsVsStripNumber.push_back(tmp->getTH2F());
00393     
00394     histoName = "pfxNHitsVsStripNumber" + subDetName[i];
00395     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
00396     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
00397     pfxNHitsVsStripNumber.push_back(tmp->getTProfile());
00398     
00399     histoName = "projXNHitsVsStripNumber" + subDetName[i];
00400     histoTitle = "Cumulative nHits in strips vs. strip number";
00401     if(i!=0)
00402       histoTitle += " in " + subDetName[i];
00403     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
00404     projXNHitsVsStripNumber.push_back(tmp->getTH1F());
00405     
00406     histoName = "projYNHitsVsStripNumber" + subDetName[i];
00407     histoTitle = "Distribution of nHits for all strips";
00408     if(i!=0)
00409       histoTitle += " in " + subDetName[i];
00410     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 10000, -0.5, 9999.5);
00411     projYNHitsVsStripNumber.push_back(tmp->getTH1F());
00412     projYNHitsVsStripNumber[i]->GetXaxis()->SetTitle("N_{hits}");
00413     projYNHitsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
00414     
00415     //
00416     histoName = "nHitsHotStripsVsStripNumber" + subDetName[i];
00417     histoTitle = "NHits in hot strips vs. strip number";
00418     if(i!=0)
00419       histoTitle += " in " + subDetName[i];
00420     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 10000, -0.5, 9999.5);
00421     nHitsHotStripsVsStripNumber.push_back(tmp->getTH2F());
00422     
00423     histoName = "pfxNHitsHotStripsVsStripNumber" + subDetName[i];
00424     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
00425     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
00426     pfxNHitsHotStripsVsStripNumber.push_back(tmp->getTProfile());
00427     
00428     histoName = "projXNHitsHotStripsVsStripNumber" + subDetName[i];
00429     histoTitle = "Cumulative nHits in hot strips vs. strip number";
00430     if(i!=0)
00431       histoTitle += " in " + subDetName[i];
00432     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
00433     projXNHitsHotStripsVsStripNumber.push_back(tmp->getTH1F());
00434     
00435     histoName = "projYNHitsHotStripsVsStripNumber" + subDetName[i];
00436     histoTitle = "Distribution of nHits for hot strips";
00437     if(i!=0)
00438       histoTitle += " in " + subDetName[i];
00439     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 10000, -0.5, 9999.5);
00440     projYNHitsHotStripsVsStripNumber.push_back(tmp->getTH1F());
00441     projYNHitsHotStripsVsStripNumber[i]->GetXaxis()->SetTitle("N_{hits}");
00442     projYNHitsHotStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
00443     
00444     //
00445     histoName = "nHitsGoodStripsVsStripNumber" + subDetName[i];
00446     histoTitle = "NHits in good strips vs. strip number";
00447     if(i!=0)
00448       histoTitle += " in " + subDetName[i];
00449     tmp = dqmStore_->book2D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5, 10000, -0.5, 9999.5);
00450     nHitsGoodStripsVsStripNumber.push_back(tmp->getTH2F());
00451     
00452     histoName = "pfxNHitsGoodStripsVsStripNumber" + subDetName[i];
00453     tmp_prof = new TProfile(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
00454     tmp = dqmStore_->bookProfile(histoName.c_str(), tmp_prof);
00455     pfxNHitsGoodStripsVsStripNumber.push_back(tmp->getTProfile());
00456     
00457     histoName = "projXNHitsGoodStripsVsStripNumber" + subDetName[i];
00458     histoTitle = "Cumulative nHits in good strips vs. strip number";
00459     if(i!=0)
00460       histoTitle += " in " + subDetName[i];
00461     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 768, 0.5, 768.5);
00462     projXNHitsGoodStripsVsStripNumber.push_back(tmp->getTH1F());
00463     
00464     histoName = "projYNHitsGoodStripsVsStripNumber" + subDetName[i];
00465     histoTitle = "Distribution of nHits for good strips";
00466     if(i!=0)
00467       histoTitle += " in " + subDetName[i];
00468     tmp = dqmStore_->book1D(histoName.c_str(), histoTitle.c_str(), 10000, -0.5, 9999.5);
00469     projYNHitsGoodStripsVsStripNumber.push_back(tmp->getTH1F());
00470     projYNHitsGoodStripsVsStripNumber[i]->GetXaxis()->SetTitle("N_{hits}");
00471     projYNHitsGoodStripsVsStripNumber[i]->GetYaxis()->SetTitle("N_{strips}");
00472   }
00473 
00474 }
00475 
00476 // ------------ method called once each job just after ending the event loop  ------------
00477 void 
00478 StripValidationPlots::endJob() {
00479 
00480   infile = new TFile(infilename.c_str(),"READ");
00481   intree = (TTree*)infile->Get("stripOccupancy");
00482 
00483   intree->SetBranchAddress("DetRawId",             &DetRawId);
00484   intree->SetBranchAddress("SubDetId",             &SubDetId);
00485   intree->SetBranchAddress("Layer_Ring",           &Layer_Ring);
00486   intree->SetBranchAddress("Disc",                 &Disc);
00487   intree->SetBranchAddress("IsBack",               &IsBack);
00488   intree->SetBranchAddress("IsExternalString",     &IsExternalString);
00489   intree->SetBranchAddress("IsZMinusSide",         &IsZMinusSide);
00490   intree->SetBranchAddress("RodStringPetal",       &RodStringPetal);
00491   intree->SetBranchAddress("IsStereo",             &IsStereo);
00492   intree->SetBranchAddress("ModulePosition",       &ModulePosition);
00493   intree->SetBranchAddress("NumberOfStrips",       &NumberOfStrips);
00494   intree->SetBranchAddress("StripNumber",          &StripNumber);
00495   intree->SetBranchAddress("APVChannel",           &APVChannel);
00496   intree->SetBranchAddress("StripGlobalPositionX", &StripGlobalPositionX);
00497   intree->SetBranchAddress("StripGlobalPositionY", &StripGlobalPositionY);
00498   intree->SetBranchAddress("StripGlobalPositionZ", &StripGlobalPositionZ);
00499   intree->SetBranchAddress("IsHot",                &IsHot);
00500   intree->SetBranchAddress("HotStripsPerAPV",      &HotStripsPerAPV);
00501   intree->SetBranchAddress("HotStripsPerModule",   &HotStripsPerModule);
00502   intree->SetBranchAddress("StripOccupancy",       &StripOccupancy);
00503   intree->SetBranchAddress("StripHits",            &StripHits);
00504   intree->SetBranchAddress("PoissonProb",          &PoissonProb);
00505 
00506   for (int i=0; i<intree->GetEntries(); /* */)
00507     {
00508       intree->GetEntry(i);
00509 
00510       savedNStrips = NumberOfStrips;
00511       firstEntry = i;
00512       savedDetRawId = DetRawId;
00513       savedSubDetId = SubDetId;
00514       vHotStripsInModule.clear();
00515 
00516       for(int j = firstEntry; j < firstEntry + savedNStrips; j++)
00517         {
00518           intree->GetEntry(j);
00519 
00520           if(DetRawId != savedDetRawId)
00521             {
00522               std::cout << "ERROR! DetRawId changed but I expected to be on the same module!\n";
00523               return;
00524             }
00525        
00526           double logStripOccupancy = log10(StripOccupancy);
00527           double logPoissonProb = log10(fabs(PoissonProb));
00528 
00529           (nReadStrips[StripNumber-1][0])++;
00530           (nReadStrips[StripNumber-1][SubDetId-2])++;
00531           //std::cout << "StripNumber = " << StripNumber << ", SubDetId = " << SubDetId << ", nReadStripsAll = " << nReadStrips[StripNumber-1][0] << ", nReadStripsSubDet = " << nReadStrips[StripNumber-1][SubDetId-2] << std::endl;
00532           occupancyVsStripNumber[0]->Fill(StripNumber,logStripOccupancy);
00533           occupancyVsStripNumber[SubDetId-2]->Fill(StripNumber,logStripOccupancy);
00534           poissonProbVsStripNumber[0]->Fill(StripNumber,logPoissonProb);
00535           poissonProbVsStripNumber[SubDetId-2]->Fill(StripNumber,logPoissonProb);
00536           nHitsVsStripNumber[0]->Fill(StripNumber,StripHits);
00537           nHitsVsStripNumber[SubDetId-2]->Fill(StripNumber,StripHits);
00538        
00539           if(IsHot)
00540             {
00541               vHotStripsInModule.push_back(StripNumber);
00542               //          std::cout << "detId = " << DetRawId << ", StripN = " << StripNumber << ", StripOccupancy = " << StripOccupancy << " PoissonProb = " << PoissonProb << std::endl ;
00543               occupancyHotStripsVsStripNumber[0]->Fill(StripNumber,logStripOccupancy);
00544               occupancyHotStripsVsStripNumber[SubDetId-2]->Fill(StripNumber,logStripOccupancy);
00545               poissonProbHotStripsVsStripNumber[0]->Fill(StripNumber,logPoissonProb);
00546               poissonProbHotStripsVsStripNumber[SubDetId-2]->Fill(StripNumber,logPoissonProb);
00547               nHitsHotStripsVsStripNumber[0]->Fill(StripNumber,StripHits);
00548               nHitsHotStripsVsStripNumber[SubDetId-2]->Fill(StripNumber,StripHits);
00549             }
00550           else
00551             {
00552               occupancyGoodStripsVsStripNumber[0]->Fill(StripNumber,logStripOccupancy);
00553               occupancyGoodStripsVsStripNumber[SubDetId-2]->Fill(StripNumber,logStripOccupancy);
00554               poissonProbGoodStripsVsStripNumber[0]->Fill(StripNumber,logPoissonProb);
00555               poissonProbGoodStripsVsStripNumber[SubDetId-2]->Fill(StripNumber,logPoissonProb);
00556               nHitsGoodStripsVsStripNumber[0]->Fill(StripNumber,StripHits);
00557               nHitsGoodStripsVsStripNumber[SubDetId-2]->Fill(StripNumber,StripHits);
00558             }
00559         }
00560      
00561       if(vHotStripsInModule.size()==1)
00562         {
00563           distance = 999;
00564           distanceVsStripNumber[0]->Fill(vHotStripsInModule[0], distance);
00565           distanceVsStripNumber[savedSubDetId-2]->Fill(vHotStripsInModule[0], distance);
00566         }
00567       else if(vHotStripsInModule.size()>1)
00568         {
00569           for(unsigned int iVec = 0; iVec != vHotStripsInModule.size(); iVec++)
00570             {
00571               if(iVec==0)
00572                 distance = vHotStripsInModule[1] - vHotStripsInModule[0];
00573               else if(iVec==vHotStripsInModule.size()-1)
00574                 {
00575                   distance = vHotStripsInModule[vHotStripsInModule.size()-1] - vHotStripsInModule[vHotStripsInModule.size() -2];
00576                 }
00577               else if(vHotStripsInModule.size()>2)
00578                 {
00579                   distanceR = vHotStripsInModule[iVec + 1] -  vHotStripsInModule[iVec];
00580                   distanceL = vHotStripsInModule[iVec] - vHotStripsInModule[iVec - 1];
00581                   distance = distanceL>distanceR?distanceR:distanceL;
00582                 }
00583               else
00584                 {
00585                   std::cout << "ERROR! distance is never computed!!!\n";
00586                 }
00587               //          std::cout << "detId = " << savedDetRawId << ", StripN = " << vHotStripsInModule[iVec] << ", distance = " << distance << std::endl;
00588               distanceVsStripNumber[0]->Fill(vHotStripsInModule[iVec], distance);
00589               distanceVsStripNumber[savedSubDetId-2]->Fill(vHotStripsInModule[iVec], distance);
00590             }
00591         }
00592      
00593       i+=savedNStrips;
00594 
00595     }
00596 
00597 
00598   std::string histoName;
00599   std::string histoTitle;
00600 
00601   for(unsigned int i = 0; i < subDetName.size(); i++)
00602     {
00603       projYDistanceVsStripNumber[i]->Add((TH1F*)distanceVsStripNumber[i]->ProjectionY());
00604       pfxDistanceVsStripNumber[i]->Add(distanceVsStripNumber[i]->ProfileX(pfxDistanceVsStripNumber[i]->GetName(),1,998));
00605       projYNHitsVsStripNumber[i]->Add(nHitsVsStripNumber[i]->ProjectionY());
00606       projYNHitsGoodStripsVsStripNumber[i]->Add(nHitsGoodStripsVsStripNumber[i]->ProjectionY());
00607       projYNHitsHotStripsVsStripNumber[i]->Add(nHitsHotStripsVsStripNumber[i]->ProjectionY());
00608       projYOccupancyVsStripNumber[i]->Add(occupancyVsStripNumber[i]->ProjectionY());
00609       projYOccupancyGoodStripsVsStripNumber[i]->Add(occupancyGoodStripsVsStripNumber[i]->ProjectionY());
00610       projYOccupancyHotStripsVsStripNumber[i]->Add(occupancyHotStripsVsStripNumber[i]->ProjectionY());
00611       pfxOccupancyVsStripNumber[i]->Add(occupancyVsStripNumber[i]->ProfileX(pfxOccupancyVsStripNumber[i]->GetName(),-8.,0.));
00612       pfxOccupancyGoodStripsVsStripNumber[i]->Add(occupancyGoodStripsVsStripNumber[i]->ProfileX(pfxOccupancyGoodStripsVsStripNumber[i]->GetName(),-8.,0.));
00613       pfxOccupancyHotStripsVsStripNumber[i]->Add(occupancyHotStripsVsStripNumber[i]->ProfileX(pfxOccupancyHotStripsVsStripNumber[i]->GetName(),-8.,0.));
00614       projYPoissonProbVsStripNumber[i]->Add(poissonProbVsStripNumber[i]->ProjectionY());
00615       projYPoissonProbGoodStripsVsStripNumber[i]->Add(poissonProbGoodStripsVsStripNumber[i]->ProjectionY());
00616       projYPoissonProbHotStripsVsStripNumber[i]->Add(poissonProbHotStripsVsStripNumber[i]->ProjectionY());
00617       pfxPoissonProbVsStripNumber[i]->Add(poissonProbVsStripNumber[i]->ProfileX(pfxPoissonProbVsStripNumber[i]->GetName(),-18., 0.));
00618       pfxPoissonProbGoodStripsVsStripNumber[i]->Add(poissonProbGoodStripsVsStripNumber[i]->ProfileX(pfxPoissonProbGoodStripsVsStripNumber[i]->GetName(),-18., 0.));
00619       pfxPoissonProbHotStripsVsStripNumber[i]->Add(poissonProbHotStripsVsStripNumber[i]->ProfileX(pfxPoissonProbHotStripsVsStripNumber[i]->GetName(),-18., 0.));
00620       projXDistanceVsStripNumber[i]->Add(distanceVsStripNumber[i]->ProjectionX(projXDistanceVsStripNumber[i]->GetName(),1,998));
00621 
00622     }
00623 
00624   dqmStore_->cd();
00625   dqmStore_->save(outfilename.c_str(),"ChannelStatusPlots");
00626 
00627 }
00628 
00629 //define this as a plug-in
00630 DEFINE_FWK_MODULE(StripValidationPlots);