]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGPP/TRD/macros/ProcessTRDRunQA.C
Move the two other macros as well
[u/mrichter/AliRoot.git] / PWGPP / TRD / macros / ProcessTRDRunQA.C
CommitLineData
6cc4cb8f 1/*
2 author: Ionut-Cristian Arsene
3 email: i.c.arsene@cern.ch
4
5 Macro to process the TRD QA output for a given run and obtain:
6 1. Detailed QA plots
7 2. QA trending values
8 3. Trending values for calibration extracted from OCDB
9 4. Other OCDB parameters (e.g. beam intensity)
10 */
11
12AliCDBEntry* GetCDBentry(TString path, Bool_t owner);
13
14//_________________________________________________________________________________
15void ProcessTRDRunQA(TString qaFile, Int_t runNumber, TString dataType,
16 Int_t year, TString period, TString pass,
17 TString ocdbStorage) {
18 //
19 // Process run level QA
20 // Create standard QA plots and trending tree in the current directory
21
22 // Load needed libraries
23 gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT -I$ALICE_ROOT/TRD");
24 gSystem->Load("libSTEERBase");
25 gSystem->Load("libSTAT");
26 gSystem->Load("libANALYSIS");
27 gSystem->Load("libANALYSISalice");
28 gSystem->Load("libTENDER");
29 gSystem->Load("libTENDERSupplies");
30 gSystem->Load("libCORRFW");
31 gSystem->Load("libPWGPP");
32
33 // Initialize a tree streamer
34 TTreeSRedirector *treeStreamer = new TTreeSRedirector("trending.root","RECREATE");
35 (*treeStreamer)<< "trending"
36 << "run=" << runNumber;
37
38 // connect to grid if its the case
39 if(qaFile.Contains("alien://") || ocdbStorage.Contains("alien://") || ocdbStorage[0]=='\0')
40 TGrid::Connect("alien://");
41
42 // trending values from the ESD task ------------------------------------------------
43 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/TRD/macros/makeResults.C");
44 Double_t esdTrendValues[100];
45 for(Int_t i=0;i<100;i++) esdTrendValues[i]=0.0;
46 makeSummaryESD(qaFile.Data(), esdTrendValues, 1);
47 const Int_t kNESDtrends = 24;
48 const TString kESDTrendNames[kNESDtrends] = {
49 "TPCTRDmatchEffPosAll","TPCTRDmatchEffPosAllErr",
50 "TPCTRDmatchEffNegAll","TPCTRDmatchEffNegAllErr",
51 "TRDTOFmatchEffPosAll","TRDTOFmatchEffPosAllErr",
52 "TRDTOFmatchEffNegAll","TRDTOFmatchEffNegAllErr",
53 "AvTRDtrkltsPerTrackAll", "AvTRDtrkltsPerTrackAllErr",
54 "AvNclsPerTrackAll", "AvNclsPerTrackAllErr",
55 "PHplateauHeight", "PHplateauHeightErr",
56 "PHplateauSlope", "PHplateauSlopeErr",
57 "QtotLandauMPV1GeVAll", "QtotLandauWidth1GeVAll",
58 "PHplateauHeightAbsolute", "PHplateauHeightErrAbsolute",
59 "PHplateauSlopeAbsolute", "PHplateauSlopeErrAbsolute",
60 "QtotLandauMPV1GeVAllAbsolute", "QtotLandauWidth1GeVAllAbsolute"
61 };
62 for(Int_t i=0; i<kNESDtrends; ++i)
63 (*treeStreamer)<< "trending" << Form("%s=",kESDTrendNames[i].Data()) << esdTrendValues[i];
64
65 // process the QA output from the other tasks----------------------------------------
66 if(dataType.Contains("sim"))
67 makeResults("PID DET", qaFile.Data());
68 else
69 makeResults("NOMC PID DET", qaFile.Data());
70
71 TFile *trendFile = new TFile("TRD.Trend.root","READ");
72 if(!trendFile || !trendFile->IsOpen() ){
73 printf("E-Couldn't open the TRD.Trend.root file. No tree.\n");
74 if(trendFile)delete trendFile;trendFile=0;
75 return;
76 }
77 TKey *tk(NULL); AliTRDtrendValue *tv(NULL); Int_t itv(0);
78 Double_t trendValues[100]={0.0};
79 TIterator *it(trendFile->GetListOfKeys()->MakeIterator());
80 while((tk = (TKey*)it->Next()) && itv < 5000){
81 if(!(tv = (AliTRDtrendValue*)trendFile->Get(tk->GetName()))) continue;
82 trendValues[itv] = tv->GetVal();
83 TString trendName = tv->GetName();
84 (*treeStreamer)<< "trending" << Form("%s=", trendName.Data()) << trendValues[itv];
85 itv++;
86 }
87
88 // get OCDB information---------------------------------------------------------------
89 // switch off grid infos to reduce output and logfilesize
90 AliLog::SetGlobalLogLevel(AliLog::kFatal);
91 AliCDBManager* man=AliCDBManager::Instance();
92 if(ocdbStorage[0]=='\0')
93 man->SetDefaultStorage(Form("alien://folder=/alice/data/%d/OCDB/", year));
94 else
95 man->SetDefaultStorage(ocdbStorage.Data());
96 man->SetRun(runNumber);
97
98 AliCDBEntry* entryExB = 0x0;
99 AliCDBEntry* entryGainFactor = 0x0;
100 AliCDBEntry* entryT0 = 0x0;
101 AliCDBEntry* entryVdrift = 0x0;
102 entryExB = man->Get("TRD/Calib/ChamberExB");
103 entryGainFactor = man->Get("TRD/Calib/ChamberGainFactor");
104 entryT0 = man->Get("TRD/Calib/ChamberT0");
105 entryVdrift = man->Get("TRD/Calib/ChamberVdrift");
106 AliTRDCalDet *caldetExB=0x0;
107 AliTRDCalDet *caldetGainFactor=0x0;
108 AliTRDCalDet *caldetT0=0x0;
109 AliTRDCalDet *caldetVdrift=0x0;
110 if(entryExB) caldetExB = (AliTRDCalDet*)entryExB->GetObject();
111 if(entryGainFactor) caldetGainFactor = (AliTRDCalDet*)entryGainFactor->GetObject();
112 if(entryT0) caldetT0 = (AliTRDCalDet*)entryT0->GetObject();
113 if(entryVdrift) caldetVdrift = (AliTRDCalDet*)entryVdrift->GetObject();
114 // get the values
115 Double_t meanExB = (caldetExB ? caldetExB->CalcMean(1) : 0.0);
116 Double_t rmsExB = (caldetExB ? caldetExB->CalcRMS(1) : 0.0);
117 Double_t meanGainFactor = (caldetGainFactor ? caldetGainFactor->CalcMean(1) : 0.0);
118 Double_t rmsGainFactor = (caldetGainFactor ? caldetGainFactor->CalcRMS(1) : 0.0);
119 Double_t meanT0 = (caldetT0 ? caldetT0->CalcMean(1) : 0.0);
120 Double_t rmsT0 = (caldetT0 ? caldetT0->CalcRMS(1) : 0.0);
121 Double_t meanVdrift = (caldetVdrift ? caldetVdrift->CalcMean(1) : 0.0);
122 Double_t rmsVdrift = (caldetVdrift ? caldetVdrift->CalcRMS(1) : 0.0);
123 (*treeStreamer)<< "trending"
124 << "meanExB=" << meanExB
125 << "rmsExB=" << rmsExB
126 << "meanGainFactor=" << meanGainFactor
127 << "rmsGainFactor=" << rmsGainFactor
128 << "meanT0=" << meanT0
129 << "rmsT0=" << rmsT0
130 << "meanVdrift=" << meanVdrift
131 << "rmsVdrift=" << rmsVdrift;
132
133 // Get the beam luminosity
134 AliCDBEntry *entryLHCData = man->Get("GRP/GRP/LHCData");
135 AliLHCData *lhcData = (entryLHCData ? (AliLHCData*)entryLHCData->GetObject() : 0x0);
136 Double_t beamIntensityA=0.0;
137 Double_t beamIntensityC=0.0;
138 if(lhcData) {
139 Int_t nLumiMeasA=lhcData->GetNLuminosityTotal(0); Int_t nA=0;
140 Int_t nLumiMeasC=lhcData->GetNLuminosityTotal(1); Int_t nC=0;
141 // Sum up the measurements
142 AliLHCDipValF *dipVal0,*dipVal1;
143 for(Int_t iLumiMeas=0;iLumiMeas<nLumiMeasA;iLumiMeas++){
144 dipVal0 = lhcData->GetLuminosityTotal(0,iLumiMeas);
145 if(dipVal0) {
146 beamIntensityA += dipVal0->GetValue();
147 ++nA;
148 }
149 }
150 beamIntensityA /= Double_t(nA);
151 for(Int_t iLumiMeas=0;iLumiMeas<nLumiMeasC;iLumiMeas++){
152 dipVal1 = lhcData->GetLuminosityTotal(1,iLumiMeas);
153 if(dipVal1) {
154 beamIntensityC += dipVal1->GetValue();
155 ++nC;
156 }
157 }
158 beamIntensityC /= Double_t(nC);
159 }
160 (*treeStreamer)<< "trending"
161 << "beamIntensityA=" << beamIntensityA
162 << "beamIntensityC=" << beamIntensityC;
163
164 (*treeStreamer)<< "trending"
165 << "\n";
166 delete treeStreamer;
167}