Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:56:56

0001 #include "iostream"
0002 #include <vector>
0003 #include <stdlib.h>
0004 #include <sys/stat.h>
0005 #include <sys/types.h>
0006 #include <unistd.h>
0007 #include <algorithm>
0008 #include <cmath>
0009 
0010 #include "TH1F.h"
0011 #include "TCanvas.h"
0012 #include "TFile.h"
0013 #include "TDirectory.h"
0014 #include "TString.h"
0015 #include "TLatex.h"
0016 
0017 
0018 void plotModule(){//main
0019 
0020   //TFile *file = TFile::Open("./FEDMonitorHistos_evt1_spy121834.root");
0021   TFile *file = TFile::Open("./SpyDisplay.root");
0022 
0023   unsigned int runNumber = 128646;
0024 
0025   const unsigned int nEvts = 5;
0026   unsigned int evtNumber[nEvts] = {1,2,3,4,5};
0027 
0028   const unsigned int nDets = 11;
0029   unsigned int detIdVec[nDets] = {436265548,436265552,436265556,436265560,436265576, 
0030                   436265580,436265584,436265588,436265592,
0031                   369121566,369124733};
0032 
0033   int pair = -1; // -1 = all
0034 
0035   TString lBaseDir = "SiStripSpyDisplay/Display/run";
0036   lBaseDir += runNumber;
0037   lBaseDir += "_event";
0038 
0039   TLatex lat;
0040   gStyle->SetOptStat(0);
0041       
0042   TCanvas *myc = new TCanvas("myc","",800,400);
0043 
0044 
0045   TString lEvtDir;
0046 
0047   for (unsigned int iEv(0); iEv<nEvts; iEv++){
0048 
0049     lEvtDir = lBaseDir;
0050     lEvtDir += evtNumber[iEv];
0051     lEvtDir += "/detID_";
0052 
0053     TString lDetDir;
0054 
0055     for (unsigned int iDet(0); iDet<nDets; iDet++){
0056 
0057       unsigned int detId = detIdVec[iDet];
0058       lDetDir = lEvtDir;
0059       lDetDir += detId;
0060       lDetDir += "/detID_";
0061       lDetDir += detId;
0062       lDetDir += "_APVpair_";
0063       
0064       TString lDir;
0065       
0066       myc->cd();
0067       
0068       TH1F *p_scopeMode[3];
0069     
0070       for (unsigned int lPair(0); lPair<3; lPair++){
0071     if (pair >= 0 && lPair != pair) continue;
0072     lDir = lDetDir;
0073     lDir += lPair;
0074     lDir += "/";
0075 
0076     if (file->cd(lDir)){
0077       p_scopeMode[lPair] = (TH1F*)gDirectory->Get("ScopeMode");
0078       if (!p_scopeMode[lPair]) continue;
0079       
0080       p_scopeMode[lPair]->SetMaximum(1100);
0081       p_scopeMode[lPair]->SetMinimum(0);
0082       
0083       TString leg = "Pair ";
0084       leg += lPair;
0085       
0086       if (lPair == 0 || pair >= 0) {
0087         p_scopeMode[lPair]->Draw();
0088         TString lLabel = "DetID ";
0089         lLabel += detId;
0090         if (pair >= 0) {
0091           lLabel += ", pair ";
0092           lLabel += pair;
0093         }
0094         lat.DrawLatex(50,1000,lLabel);
0095         if (!(pair >= 0)) lat.DrawLatex(200,900,leg);
0096       }
0097       else {
0098         p_scopeMode[lPair]->SetLineColor(lPair+1);
0099         p_scopeMode[lPair]->Draw("same");
0100         lat.SetTextColor(lPair+1);
0101         lat.DrawLatex(200,900-70*lPair,leg);
0102       }
0103       
0104       file->cd();
0105     }
0106     else {
0107       std::cout << " -- Pair " << lPair << " not found." << std::endl;
0108     }
0109     
0110       }//loop on pairs
0111 
0112       TString save = "PLOTS/";
0113       std::ostringstream lmkdir;
0114       lmkdir << "PLOTS/" << runNumber;
0115       mkdir(lmkdir.str().c_str(),0755);
0116       save += runNumber;
0117       save += "/Module";
0118       save += detId;
0119       save += "_evt";
0120       save += evtNumber[iEv];
0121       if (pair >= 0) {
0122     save += "_pair";
0123     save += pair;
0124       }
0125       save += ".png";
0126 
0127       myc->Print(save);
0128 
0129     }//loop on detids
0130 
0131   }//loop on evts
0132 
0133 }//main