TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGPP / TRD / runQAesds.C
CommitLineData
1416eda5 1Int_t ExtractRunNumber(TString filename);
2void Plot(Int_t run);
3void runQAesds(const char *esdlist)
4{
5 ifstream input(esdlist);
6 string str;
7 getline(input, str);
8 TString tstr(str.c_str());
9 if(tstr.Contains("alien://")){
10 printf("Data from alien\n");
11 gSystem->Load("libRAliEn");
12 TGrid::Connect("alien://");
13 }
14
15 Int_t runnr = ExtractRunNumber(tstr);
16 printf("runnr %d\n", runnr);
17
18 gSystem->Load("libANALYSIS");
19 gSystem->Load("libANALYSISalice");
af472fff 20 gSystem->Load("libTender");
2bfe5463 21 gSystem->Load("libPWGPP");
1416eda5 22 AliLog::SetGlobalLogLevel(AliLog::kError);
23 gROOT->LoadMacro(Form("%s/PWG0/CreateESDChain.C", gSystem->ExpandPathName("$ALICE_ROOT")));
24 TChain *chain = CreateESDChain(esdlist, -1);
25 chain->SetBranchStatus("*FMD*",0);
26 chain->SetBranchStatus("*Calo*",0);
27 chain->SetBranchStatus("Tracks", 1);
28 chain->SetBranchStatus("ESDfriend*",1);
29 chain->Lookup();
30 chain->GetListOfFiles()->Print();
31 printf("\n ----> CHAIN HAS %d ENTRIES <----\n\n", (Int_t)chain->GetEntries());
32
33 AliAnalysisManager *TRDqa = new AliAnalysisManager("TRD Cosmics QA");
34 TRDqa->SetInputEventHandler(new AliESDInputHandler);
35 AliTRDinfoGen *info = new AliTRDinfoGen();
36 AliTRDcheckDET *detector = new AliTRDcheckDET();
37 detector->SetDebugLevel(10);
38 detector->SetMCdata(kFALSE);
39 detector->UseClustersOutsideChamber();
40 TRDqa->AddTask(info);
41 TRDqa->AddTask(detector);
42
43 AliAnalysisDataContainer *co[3];
44 TRDqa->ConnectInput( info, 0, TRDqa->GetCommonInputContainer());
45 co[0] = TRDqa->CreateContainer("trackInfo", TObjArray::Class(), AliAnalysisManager::kExchangeContainer);
46 co[1] = TRDqa->CreateContainer("eventInfo", AliTRDeventInfo::Class(), AliAnalysisManager::kExchangeContainer);
47 co[2] = TRDqa->CreateContainer("v0Info", TObjArray::Class(), AliAnalysisManager::kExchangeContainer);
48 TRDqa->ConnectOutput(info, 0, co[0]);
49 TRDqa->ConnectOutput(info, 1, co[1]);
50 TRDqa->ConnectOutput(info, 2, co[2]);
51 TRDqa->ConnectInput(detector, 0, co[0]);
52 TRDqa->ConnectInput(detector, 1, co[1]);
53 TRDqa->ConnectOutput(detector, 0, TRDqa->CreateContainer(detector->GetName(), TObjArray::Class(), AliAnalysisManager::kOutputContainer, Form("TRD.Perf%d.root", runnr)));
54
55 if(TRDqa->InitAnalysis()){
56 TRDqa->Print();
57 TRDqa->StartAnalysis("local", chain);
58 }
59 gSystem->Exec(Form("mv TRD.DebugPerformance.root TRD.DbgPerf%d.root", runnr));
60 Plot(runnr);
61}
62
63void Plot(Int_t run){
64 TFile *f=new TFile(Form("TRD.Perf%d.root",run));
65 TH1F *hNtrSec = (TH1F*)checkDET->FindObject("hNtrksSector");
66 TH1F *hNtrks = (TH1F*)checkDET->FindObject("hNtrks"); // tracks/event
67 TH1F *hNtlsSTA = (TH1F*)checkDET->FindObject("hNtlsSTA");
68 TH1F *hNtlsBAR = (TH1F*)checkDET->FindObject("hNtlsBAR");
69 TH1F *hNclTrk = (TH1F*)checkDET->FindObject("hNclTls");
70 TProfile *hPHp = (TProfile*) checkDET->FindObject("<PH>")->FindObject("hPHt");
71 f->Close();
72
73 TH2F *hPH = new TH2F("hPH", "PH", 30, 0, 30, 100, 0, 1000);
74 TString filename = Form("TRD.DbgPerf%d.root",run);
75 TChain *debchain = new TChain("PHt");
76 if(filename.EndsWith(".root")) {
77 debchain->AddFile(filename.Data());
78 debchain->Draw("Charge:Timebin>>hPH", "","colz");
79 } else{
80 cout << "No such file... " << filename <<endl;
81 }
82
83 const Float_t Ls1=0.04;
84 TCanvas *tc = new TCanvas ("Monitor", "Monitor",50,50,600,900);
85 tc->Divide(2,3);
86
87 tc->cd(1);
88 pad = tc->cd(1); pad->SetLogy();
89 hNtrks->GetXaxis()->SetTitle("Tracks per event");
90 hNtrks->GetXaxis()->SetTitleOffset(.9);
91 hNtrks->GetXaxis()->SetTitleSize(0.05);
92 hNtrks->GetYaxis()->SetTitle("");
93 //hNtrks->SetTitle(Form("%d",run));
94 hNtrks->SetLineWidth(2);
95 hNtrks->SetLabelSize(Ls1,"xy");
96 hNtrks->GetXaxis()->SetRangeUser(0,20);
97 hNtrks->Draw();
98 int Ntracks=hNtrks->Integral();
99 TLatex *text=new TLatex(8,10,Form("%d tracks",Ntracks));
100 text->SetTextSize(0.045); text->SetTextFont(42);
101 text->Draw("same");
102
103 tc->cd(2);
104 hNtrSec->GetXaxis()->SetTitle("Sector");
105 hNtrSec->GetXaxis()->SetTitleOffset(.9);
106 hNtrSec->GetXaxis()->SetTitleSize(0.05);
107 hNtrSec->GetYaxis()->SetTitle("Tracks");
108 //hNtrSec->GetYaxis()->SetTitleSize(0.05);
109 hNtrSec->GetYaxis()->SetTitleOffset(1.2);
110 hNtrSec->SetLineWidth(2);
111 hNtrSec->SetLabelSize(Ls1,"xy");
112 hNtrSec->Draw();
113
114 tc->cd(3);
115 hNtlsBAR->GetXaxis()->SetTitle("Tracklets per track");
116 hNtlsBAR->GetXaxis()->SetTitleOffset(.9);
117 hNtlsBAR->GetXaxis()->SetTitleSize(0.05);
118 hNtlsBAR->GetYaxis()->SetTitle("");
119 //hNtlsBAR->SetStats(1111);
120 hNtlsBAR->SetLabelSize(Ls1,"xy");
121 hNtlsBAR->SetLineWidth(2);
122 //hNtlsBAR->GetYaxis()->SetRangeUser(0,500);
123 hNtlsSTA->GetXaxis()->SetTitle("Tracklets per track");
124 hNtlsSTA->GetYaxis()->SetTitle("");
125 hNtlsBAR->SetLineColor(2); hNtlsBAR->Draw("");
126 hNtlsSTA->SetLineColor(4); hNtlsSTA->Draw("same");
127 leg = new TLegend(0.14,0.35,0.65,0.5);
128 leg->AddEntry(hNtlsBAR,"Barrel","l");
129 leg->AddEntry(hNtlsSTA,"Standalone","l");
130 leg->SetBorderSize(0);
131 leg->SetFillStyle(0);
132 leg->SetMargin(0.15); //separation symbol-text
133 leg->SetEntrySeparation(0.1); //this seems not to do much...
134 leg->Draw();
135
136 tc->cd(4);
137 hNclTrk->GetXaxis()->SetTitle("Clusters per tracklet");
138 hNclTrk->GetXaxis()->SetTitleOffset(.9);
139 hNclTrk->GetXaxis()->SetTitleSize(0.05);
140 hNclTrk->GetYaxis()->SetTitle("");
141 hNclTrk->SetLabelSize(Ls1,"xy");
142 hNclTrk->SetLineWidth(2);
143 hNclTrk->Draw();
144
145 tc->cd(5);
146 hPHp->GetXaxis()->SetTitle("Time bin (100 ns)");
147 hPHp->GetXaxis()->SetTitleOffset(.9);
148 hPHp->GetXaxis()->SetTitleSize(0.05);
149 hPHp->GetYaxis()->SetTitle("<PH> (ADC ch.)");
150 hPHp->GetYaxis()->SetTitleOffset(1.3);
151 hPHp->SetLabelSize(Ls1,"xy");
152 hPHp->SetLineWidth(2);
153 hPHp->Draw();
154
155 tc->cd(6);
156 hPH->GetXaxis()->SetTitle("Time bin (100 ns)");
157 hPH->GetXaxis()->SetTitleOffset(.9);
158 hPH->GetXaxis()->SetTitleSize(0.05);
159 hPH->GetYaxis()->SetTitle("Pulse Height (ADC ch.)");
160 hPH->GetYaxis()->SetTitleOffset(1.3);
161 hPH->SetLabelSize(Ls1,"xy");
162 hPH->SetLineWidth(2);
163 hPH->Draw("colz");
164
165 //tc->SaveAs(Form("Mon_run%dp%d.eps",run,pass));
166 tc->SaveAs(Form("Mon_run%d.gif",run));
167}
168
169Int_t ExtractRunNumber(TString filename){
170 TObjArray *toks = filename.Tokenize("/");
171 TObjString *file = dynamic_cast<TObjString *>(toks->At(toks->GetEntries() - 2));
172 TString &filestr = file->String();
173 TString runstr = filestr(2,9);
174 return runstr.Atoi();
2bfe5463 175}