Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
#include "iostream"
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <algorithm>
#include <cmath>

#include "TH1F.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TDirectory.h"
#include "TString.h"
#include "TLatex.h"


void plotEmulation(){//main

  TFile *file = TFile::Open("./SpyDisplay.root");

  unsigned int runNumber = 128646;

  const unsigned int nEvts = 9;
  unsigned int evtNumber[nEvts] = {1,56,100,186,228,289,342,378,389};

  const unsigned int nDets = 11;
  unsigned int detId[nDets] = {436265548,436265552,436265556,436265560,436265576, 
			       436265580,436265584,436265588,436265592,
			       369121566,369124733};


  TString lBaseDir = "SiStripSpyDisplay/Display/run";
  lBaseDir += runNumber;
  lBaseDir += "_event";

  gStyle->SetOptStat(0);

  TLatex lat;
 
  TCanvas *myc = new TCanvas("myc","",800,800);
  myc->Divide(2,2);
 
  TString lEvtDir;

  for (unsigned int iDet(0); iDet<nDets; iDet++){

    TH1F *p_mode[4][nEvts];

    for (unsigned int iEv(0); iEv<nEvts; iEv++){

      lEvtDir = lBaseDir;
      lEvtDir += evtNumber[iEv];
      lEvtDir += "/detID_";

      TString lDetDir;

      lDetDir = lEvtDir;
      lDetDir += detId[iDet];
      lDetDir += "/";

      if (file->cd(lDetDir)){
	p_mode[0][iEv] = (TH1F*)gDirectory->Get("ReorderedModuleRaw");
	p_mode[1][iEv] = (TH1F*)gDirectory->Get("PedestalValues");
	p_mode[2][iEv] = (TH1F*)gDirectory->Get("PostPedestal");
	p_mode[3][iEv] = (TH1F*)gDirectory->Get("PostCommonMode");
      }
      else {
	std::cout << " -- Dir " << lDetDir << " not found." << std::endl;
      }

      for (unsigned int i(0); i<4; i++){
	myc->cd(i+1);
	if (!p_mode[i][iEv]) continue;
	p_mode[i][iEv]->SetLineColor(iEv+1);
	if (iEv == 0) p_mode[i][iEv]->Draw();
	else p_mode[i][iEv]->Draw("same");
      }

 
    }//loop on evts

    TString save = "PLOTS/";
    std::ostringstream lmkdir;
    lmkdir << "PLOTS/" << runNumber;
    mkdir(lmkdir.str().c_str(),0755);
    save += runNumber;
    save += "/FEDEmulation_";
    save += detId[iDet];
    save += ".png";
    
    myc->Print(save);
      


  }//loop on detids


}//main