Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:52

0001 #include "iostream"
0002 #include <stdlib.h>
0003 #include <sys/stat.h>
0004 #include <sys/types.h>
0005 #include <unistd.h>
0006 #include <algorithm>
0007 #include <cmath>
0008 
0009 #include "TH1F.h"
0010 #include "TCanvas.h"
0011 #include "TFile.h"
0012 #include "TDirectory.h"
0013 #include "TString.h"
0014 #include "TLatex.h"
0015 
0016 
0017 void plotEmulation(){//main
0018 
0019   TFile *file = TFile::Open("./SpyDisplay.root");
0020 
0021   unsigned int runNumber = 128646;
0022 
0023   const unsigned int nEvts = 9;
0024   unsigned int evtNumber[nEvts] = {1,56,100,186,228,289,342,378,389};
0025 
0026   const unsigned int nDets = 11;
0027   unsigned int detId[nDets] = {436265548,436265552,436265556,436265560,436265576, 
0028                    436265580,436265584,436265588,436265592,
0029                    369121566,369124733};
0030 
0031 
0032   TString lBaseDir = "SiStripSpyDisplay/Display/run";
0033   lBaseDir += runNumber;
0034   lBaseDir += "_event";
0035 
0036   gStyle->SetOptStat(0);
0037 
0038   TLatex lat;
0039  
0040   TCanvas *myc = new TCanvas("myc","",800,800);
0041   myc->Divide(2,2);
0042  
0043   TString lEvtDir;
0044 
0045   for (unsigned int iDet(0); iDet<nDets; iDet++){
0046 
0047     TH1F *p_mode[4][nEvts];
0048 
0049     for (unsigned int iEv(0); iEv<nEvts; iEv++){
0050 
0051       lEvtDir = lBaseDir;
0052       lEvtDir += evtNumber[iEv];
0053       lEvtDir += "/detID_";
0054 
0055       TString lDetDir;
0056 
0057       lDetDir = lEvtDir;
0058       lDetDir += detId[iDet];
0059       lDetDir += "/";
0060 
0061       if (file->cd(lDetDir)){
0062     p_mode[0][iEv] = (TH1F*)gDirectory->Get("ReorderedModuleRaw");
0063     p_mode[1][iEv] = (TH1F*)gDirectory->Get("PedestalValues");
0064     p_mode[2][iEv] = (TH1F*)gDirectory->Get("PostPedestal");
0065     p_mode[3][iEv] = (TH1F*)gDirectory->Get("PostCommonMode");
0066       }
0067       else {
0068     std::cout << " -- Dir " << lDetDir << " not found." << std::endl;
0069       }
0070 
0071       for (unsigned int i(0); i<4; i++){
0072     myc->cd(i+1);
0073     if (!p_mode[i][iEv]) continue;
0074     p_mode[i][iEv]->SetLineColor(iEv+1);
0075     if (iEv == 0) p_mode[i][iEv]->Draw();
0076     else p_mode[i][iEv]->Draw("same");
0077       }
0078 
0079  
0080     }//loop on evts
0081 
0082     TString save = "PLOTS/";
0083     std::ostringstream lmkdir;
0084     lmkdir << "PLOTS/" << runNumber;
0085     mkdir(lmkdir.str().c_str(),0755);
0086     save += runNumber;
0087     save += "/FEDEmulation_";
0088     save += detId[iDet];
0089     save += ".png";
0090     
0091     myc->Print(save);
0092       
0093 
0094 
0095   }//loop on detids
0096 
0097 
0098 }//main