Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:31

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