2 macro to extract the OCDB entries
4 input: CalibObjects.root
5 ouput: TimeGain and TimeVdrift calibration objects for TPC and TRD
8 .L $ALICE_ROOT/PWGPP/CalibMacros/CPass1/makeOCDB.C
13 void printCalibStat(Int_t run, const char * fname, TTreeSRedirector * pcstream);
15 void makeOCDB(Int_t runNumber, TString targetOCDBstorage="", TString sourceOCDBstorage="raw://")
18 // extract OCDB entries for detectors participating in the calibration for the current run
21 gROOT->Macro("$ALICE_ROOT/PWGPP/CalibMacros/CPass1/LoadLibraries.C");
22 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/CalibMacros/CPass1/ConfigCalibTrain.C");
24 // switch off log info
25 AliLog::SetClassDebugLevel("AliESDEvent",0);
28 printf("runNumber from runCalibTrain = %d\n",runNumber);
29 ConfigCalibTrain(runNumber, sourceOCDBstorage.Data());
31 // check the presence of the detectors
32 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
33 AliGRPObject* grpData = dynamic_cast<AliGRPObject*>(entry->GetObject());
34 if (!grpData) {printf("Failed to get GRP data for run",runNumber); return;}
35 Int_t activeDetectors = grpData->GetDetectorMask();
36 TString detStr = AliDAQ::ListOfTriggeredDetectors(activeDetectors);
37 printf("Detectors in the data:\n%s\n",detStr.Data());
39 // Steering Tasks - set output storage
40 // DefaultStorage set already before - in ConfigCalibTrain.C
41 //targetOCDBstorage+="?se=ALICE::CERN::SE";
43 // for tests, the target OCDB has to be different from raw://, but since the calibration procedure may need to read the OCDB,
44 // one cannot set the target OCDB as new default storage, since it could it that it does not contain all the necessary entries.
45 // This is true only if the target OCDB storage is different from the one used as default source and to configure the train
46 if (targetOCDBstorage != sourceOCDBstorage) AliCDBManager::Instance()->SetSpecificStorage("*/*/*", targetOCDBstorage.Data());
48 if (gSystem->AccessPathName("TPC", kFileExists)==0) {
49 AliCDBManager::Instance()->SetSpecificStorage("TPC/Calib/Correction","local://");
52 if (targetOCDBstorage.Length()==0) targetOCDBstorage+="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
53 TString ocdbLocal = "local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
56 AliTPCPreprocessorOffline* procesTPC=0;
57 if (detStr.Contains("TPC")){
58 Printf("\n******* Calibrating TPC *******");
59 procesTPC = new AliTPCPreprocessorOffline;
60 // switch on parameter validation
61 procesTPC->SetTimeGainRange(0.5,4.0);
62 procesTPC->SwitchOnValidation();
63 // Make timegain calibration
64 //proces.CalibTimeGain("CalibObjects.root", runNumber,AliCDBRunRange::Infinity(),targetOCDBstorage);
65 //procesTPC->CalibTimeGain("CalibObjects.root", runNumber,runNumber,ocdbLocal);
66 // Make vdrift calibration
67 //proces.CalibTimeVdrift("CalibObjects.root",runNumber,AliCDBRunRange::Infinity(),targetOCDBstorage);
68 //procesTPC->CalibTimeVdrift("CalibObjects.root",runNumber,runNumber,ocdbLocal);
72 AliTOFAnalysisTaskCalibPass0 *procesTOF=0;
73 if ( detStr.Contains("TOF") && detStr.Contains("TPC")){
74 procesTOF = new AliTOFAnalysisTaskCalibPass0;
75 Printf("\n******* Calibrating TOF *******");
76 procesTOF->ProcessOutput("CalibObjects.root", targetOCDBstorage);
80 AliT0PreprocessorOffline *procesT0= 0;
81 if ( detStr.Contains("T0")) {
82 Printf("\n******* Calibrating T0 *******");
83 procesT0 = new AliT0PreprocessorOffline;
84 // Make calibration of channels offset
85 procesT0->setDArun(177000);
86 procesT0->Process("CalibObjects.root",runNumber, runNumber, targetOCDBstorage);
90 AliTRDPreprocessorOffline *procesTRD = 0;
91 if ( detStr.Contains("TRD")){
92 Printf("\n******* Calibrating TRD *******");
93 procesTRD = new AliTRDPreprocessorOffline;
94 procesTRD->SetLinearFitForVdrift(kTRUE);
95 procesTRD->SetMinStatsVdriftT0PH(600*10);
96 procesTRD->SetMinStatsVdriftLinear(50);
97 procesTRD->SetMinStatsGain(600);
98 procesTRD->SetLimitValidateNoData(60);
99 procesTRD->SetLimitValidateBadCalib(60);
100 procesTRD->SetAlternativeDriftVelocityFit(kTRUE);
101 procesTRD->Init("CalibObjects.root");
102 Int_t versionVdriftUsed = procesTRD->GetVersionVdriftUsed();
103 Int_t subversionVdriftUsed = procesTRD->GetSubVersionVdriftUsed();
104 Int_t versionGainUsed = procesTRD->GetVersionGainUsed();
105 Int_t subversionGainUsed = procesTRD->GetSubVersionGainUsed();
106 Int_t versionExBUsed = procesTRD->GetVersionExBUsed();
107 Int_t subversionExBUsed = procesTRD->GetSubVersionExBUsed();
108 printf("version and subversion vdrift %d and %d\n",versionVdriftUsed,subversionVdriftUsed);
109 printf("version and subversion gain %d and %d\n",versionGainUsed,subversionGainUsed);
110 printf("version and subversion exb %d and %d\n",versionExBUsed,subversionExBUsed);
111 procesTRD->Process("CalibObjects.root",runNumber,runNumber,targetOCDBstorage);
114 // switched OFF at CPass1 in any case
117 AliMeanVertexPreprocessorOffline * procesMeanVtx=0;
118 if ( detStr.Contains("ITSSPD")) {
119 Printf("\n******* Calibrating MeanVertex *******");
120 procesMeanVtx = new AliMeanVertexPreprocessorOffline;
121 procesMeanVtx->ProcessOutput("CalibObjects.root", targetOCDBstorage, runNumber);
126 // Print calibration status into the stdout
128 Int_t trdStatus = (procesTRD) ? procesTRD->GetStatus():0;
129 Int_t tofStatus = (procesTOF) ? procesTOF->GetStatus():0;
130 Int_t t0Status = (procesT0) ? procesT0->GetStatus():0;
131 Int_t tpcStatus = (procesTPC) ? ((procesTPC->ValidateTimeDrift() || procesTPC->ValidateTimeGain())==kFALSE):0;
134 printf("CPass1 calibration status\n");
135 printf("TRD calibration status=%d\n",trdStatus);
136 printf("TOF calibration status=%d\n",tofStatus);
137 printf("TPC calibration status=%d\n",tpcStatus);
138 printf("T0 calibration status=%d\n",t0Status);
140 TTreeSRedirector *pcstream = new TTreeSRedirector("cpassStat.root","recreate");
141 printCalibStat(runNumber, "CalibObjects.root",pcstream);
147 // function to print statistics used to calibrate the various detectors
149 void printCalibStat(Int_t run, const char * fname, TTreeSRedirector * pcstream){
152 // Dump the statistical information about all histograms in the calibration files
153 // into the statistical tree, print on the screen (log files) as well
156 // 1. Default dump for all histograms
157 // Information to dump:
158 // stat =Entries, Mean, MeanError, RMS, MaxBin
159 // Branch naming convention:
160 // <detName>_<hisName><statName>
162 // 2. Detector statistical information - to be implemented by expert
163 // - First version implemented by MI
167 TFile *fin = TFile::Open(fname);
169 const Double_t kMaxHis=10000;
171 TList * keyList = fin->GetListOfKeys();
172 Int_t nkeys=keyList->GetEntries();
173 Double_t *hisEntries = new Double_t[kMaxHis];
174 Double_t *hisMean = new Double_t[kMaxHis];
175 Double_t *hisMeanError = new Double_t[kMaxHis];
176 Double_t *hisRMS = new Double_t[kMaxHis];
177 Double_t *hisMaxBin = new Double_t[kMaxHis];
180 if (pcstream) (*pcstream)<<"calibStatAll"<<"run="<<run;
181 for (Int_t ikey=0; ikey<nkeys; ikey++){
182 TObject * object = fin->Get(keyList->At(ikey)->GetName());
183 if (!object) continue;
184 if (object->InheritsFrom("TCollection")==0) continue;
185 TSeqCollection *collection = (TSeqCollection*)object;
186 Int_t nentries= collection->GetEntries();
187 for (Int_t ihis=0; ihis<nentries; ihis++){
188 TObject * ohis = collection->At(ihis);
190 if (ohis->InheritsFrom("TH1")==0) continue;
191 TH1* phis = (TH1*)ohis;
192 hisEntries[counter]=phis->GetEntries();
194 if (ohis->InheritsFrom("TH2")) idim=2;
195 if (ohis->InheritsFrom("TH3")) idim=3;
196 hisMean[counter]=phis->GetMean(idim);
197 hisMeanError[counter]=phis->GetMeanError(idim);
198 hisRMS[counter]=phis->GetRMS(idim);
199 hisMaxBin[counter]=phis->GetBinCenter(phis->GetMaximumBin());
200 if (pcstream) (*pcstream)<<"calibStatAll"<<
201 Form("%s_%sEntries=",keyList->At(ikey)->GetName(), phis->GetName())<<hisEntries[counter]<<
202 Form("%s_%sMean=",keyList->At(ikey)->GetName(), phis->GetName())<<hisMean[counter]<<
203 Form("%s_%sMeanError=",keyList->At(ikey)->GetName(), phis->GetName())<<hisMeanError[counter]<<
204 Form("%s_%sRMS=",keyList->At(ikey)->GetName(), phis->GetName())<<hisRMS[counter]<<
205 Form("%s_%sMaxBin=",keyList->At(ikey)->GetName(), phis->GetName())<<hisMaxBin[counter];
206 //printf("Histo:\t%s_%s\t%f\t%d\n",keyList->At(ikey)->GetName(), phis->GetName(), hisEntries[counter],idim);
213 // Expert dump example (MI first iteration):
220 TList * TOFCalib = (TList*)fin->Get("TOFHistos");
222 TH1 *histoEvents = (TH1*)TOFCalib->FindObject("hHistoVertexTimestamp");
223 TH1 *histoTracks = (TH1*)TOFCalib->FindObject("hHistoDeltatTimestamp");
224 if (histoEvents && histoTracks){
225 tofEvents = TMath::Nint(histoEvents->GetEntries());
226 tofTracks = TMath::Nint(histoTracks->GetEntries());
230 printf("Monalisa TOFevents\t%d\n",tofEvents);
231 if (pcstream) (*pcstream)<<"calibStatAll"<<"TOFevents="<<tofEvents;
232 printf("Monalisa TOFtracks\t%d\n",tofTracks);
233 if (pcstream) (*pcstream)<<"calibStatAll"<<"TOFtracks="<<tofTracks;
236 // 1.) TPC dump - usefull events/tracks for the calibration
240 TList * TPCCalib = (TList*)fin->Get("TPCCalib");
242 AliTPCcalibTime * calibTime = (AliTPCcalibTime *)TPCCalib->FindObject("calibTime");
244 tpcEvents = TMath::Nint(calibTime->GetTPCVertexHisto(0)->GetEntries());
245 tpcTracks = TMath::Nint(calibTime->GetResHistoTPCITS(0)->GetEntries());
248 printf("Monalisa TPCevents\t%d\n",tpcEvents);
249 if (pcstream) (*pcstream)<<"calibStatAll"<<"TPCevents="<<tpcEvents;
250 printf("Monalisa TPCtracks\t%d\n",tpcTracks);
251 if (pcstream) (*pcstream)<<"calibStatAll"<<"TPCtracks="<<tpcTracks;
258 TList * TRDCalib = (TList*)fin->Get("TRDCalib");
260 TH1 *histoEvents = (TH1*)TRDCalib->FindObject("NEventsInput_AliTRDCalibTask");
261 TH1 *histoTracks = (TH1*)TRDCalib->FindObject("AbsoluteGain_AliTRDCalibTask");
262 if (histoEvents && histoTracks){
263 trdEvents= TMath::Nint(histoEvents->GetEntries());
264 trdTracks= TMath::Nint(histoTracks->GetEntries());
268 printf("Monalisa TRDevents\t%d\n",trdEvents);
269 if (pcstream) (*pcstream)<<"calibStatAll"<<"TRDevents="<<trdEvents;
270 printf("Monalisa TRDtracks\t%d\n",trdTracks);
271 if (pcstream) (*pcstream)<<"calibStatAll"<<"TRDtracks="<<trdTracks;
277 TList * T0Calib = (TList*)fin->Get("T0Calib");
279 TH1 *histoEvents = (TH1*) T0Calib->FindObject("fTzeroORAplusORC");
281 T0Events= TMath::Nint(histoEvents->GetEntries());
285 printf("Monalisa T0events\t%d\n",T0Events);
286 if (pcstream) (*pcstream)<<"calibStatAll"<<"T0events="<<T0Events;
289 // 4. Mean vertex - dump
290 // Not present in CPass1
292 Int_t meanVertexEvents=0;
293 TList * meanVertexCalib = (TList*)fin->Get("MeanVertex");
294 if (meanVertexCalib) {
295 TH1 *histoEvents = (TH1*) meanVertexCalib->FindObject("hTRKVertexX");
297 meanVertexEvents = TMath::Nint(histoEvents->GetEntries());
299 delete meanVertexCalib;
301 printf("Monalisa MeanVertexevents\t%d\n",meanVertexEvents);
302 if (pcstream) (*pcstream)<<"calibStatAll"<<"MeanVertexevents="<<meanVertexEvents;
310 TList * SDDCalib = (TList*)fin->Get("clistSDDCalib");
312 TH1 *histoEvents = (TH1*) SDDCalib->FindObject("hNEvents");
314 sddEvents = TMath::Nint(histoEvents->GetBinContent(4));
315 sddTracks = TMath::Nint(histoEvents->GetBinContent(5));
319 printf("Monalisa SDDevents\t%d\n",sddEvents);
320 if (pcstream) (*pcstream)<<"calibStatAll"<<"SDDevents="<<sddEvents;
321 printf("Monalisa SDDtracks\t%d\n",sddTracks);
322 if (pcstream) (*pcstream)<<"calibStatAll"<<"SDDtracks="<<sddTracks;
325 if (pcstream) (*pcstream)<<"calibStatAll"<<"\n";