Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:16

0001 #include "TH1F.h"
0002 #include "TCanvas.h"
0003 #include "TObject.h"
0004 #include "TFile.h"
0005 #include "TPaveStats.h"
0006 #include "TGraphErrors.h"
0007 #include "TGaxis.h"
0008 #include "TROOT.h"
0009 #include "TF1.h"
0010 #include "TLegend.h"
0011 #include "TKey.h"
0012 #include "TClass.h"
0013 
0014 #include "iostream"
0015 #include "vector"
0016 #include "math.h"
0017 #include "map"
0018 
0019     
0020    
0021 
0022 void  displayBaselineMacro(TString file, int limit){
0023   TFile *f;//, *fo;
0024   TString BaseDir;
0025   TString dir[4];
0026   TString fullPath, title, subDet, genSubDet;
0027   TCanvas *C;
0028     C = new TCanvas();
0029     f = new TFile(file);
0030 //    fo = new TFile(ofile, "RECREATE");
0031     //BaseDir="DQMData/Results/SpyChannel/";
0032     dir[0]="baselineAna/ProcessedRawDigis";
0033     dir[1]="baselineAna/Baseline";
0034     dir[2]="baselineAna/Clusters";
0035     dir[3]="baselineAna/RawDigis";
0036     f->cd();
0037 //  fo->Write();
0038 //  fo->Close();
0039     f->cd(dir[0]);
0040     
0041     TIter nextkey(gDirectory->GetListOfKeys());
0042     TKey *key;
0043     int objcounter=1;
0044     int histolimit =0;
0045     while ((key = (TKey*)nextkey())) {
0046         if(histolimit< limit){
0047         histolimit++;
0048       TObject *obj = key->ReadObj();
0049       
0050 
0051       if ( obj->IsA()->InheritsFrom( "TH1" ) ) {
0052     
0053     std::cout << "Found object n: " << objcounter << " Name: " << obj->GetName() << " Title: " << obj->GetTitle()<< std::endl;
0054     ++objcounter;
0055     //if (strstr(obj->GetTitle(),"470116592")!=NULL)
0056     //  continue;
0057 
0058     C->Clear();
0059     TH1F* h = (TH1F*)key->ReadObj();
0060 
0061     //TLegend leg(0.6,0.9,0.8,1,"");
0062     //leg.AddEntry(h,"VR - Ped - apvCM_{mean}","lep");
0063 
0064     h->SetLineWidth(2);
0065     h->SetXTitle("StripNumber");
0066     h->SetYTitle("Charge (ADC counts)");
0067     h->Draw("hist p l");
0068     f->cd();
0069     //f->cd(dir[1]);
0070     TH1F* hb = (TH1F*) f->Get(dir[1]+"/"+obj->GetName());
0071     
0072     if(hb!=0){
0073       hb->SetLineWidth(2);
0074       hb->SetLineStyle(2);
0075       hb->SetLineColor(2);
0076       //leg.AddEntry(hb,"clusters","lep");
0077       hb->Draw("hist p l same");
0078     }
0079     
0080     f->cd();
0081     //f->cd(dir[1]);
0082     TH1F* hc = (TH1F*) f->Get(dir[2]+"/"+obj->GetName());
0083     
0084     if(hc!=0){
0085       hc->SetLineWidth(2);
0086       hc->SetLineStyle(2);
0087       hc->SetLineColor(3);
0088       //leg.AddEntry(hb,"clusters","lep");
0089       hc->Draw("hist p l same");
0090     }
0091     TH1F* hd = (TH1F*) f->Get(dir[3]+"/"+obj->GetName());
0092     
0093     if(hd!=0){
0094       hd->SetLineWidth(2);
0095       hd->SetLineStyle(2);
0096       hd->SetLineColor(6);
0097       //leg.AddEntry(hb,"clusters","lep");
0098       hd->Draw("hist p l same");
0099     }
0100     
0101     else
0102       std::cout << "not found " << obj->GetName()<< std::endl;
0103     //leg.Draw();
0104     
0105     
0106     C->Update();
0107 //  fo->cd();
0108 //  C->Write();
0109     
0110     C->SaveAs(TString("img/")+obj->GetName()+TString(".png"));
0111     
0112     
0113       }
0114     }  
0115   }
0116 }