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/CPass0/makeOCDB.C
13 void printCalibStat(Int_t run, const char * fname, TTreeSRedirector * pcstream);
16 void makeOCDB(Int_t runNumber, TString targetOCDBstorage="", TString sourceOCDBstorage="raw://")
20 // extract OCDB entries for detectors participating in the calibration for the current run
23 gROOT->Macro("$ALICE_ROOT/PWGPP/CalibMacros/CPass0/LoadLibraries.C");
24 gROOT->LoadMacro("$ALICE_ROOT/PWGPP/CalibMacros/CPass0/ConfigCalibTrain.C");
26 // switch off log info
27 AliLog::SetClassDebugLevel("AliESDEvent",0);
30 printf("runNumber from runCalibTrain = %d\n",runNumber);
31 ConfigCalibTrain(runNumber, sourceOCDBstorage.Data());
33 // check the presence of the detectors
34 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
35 AliGRPObject* grpData = dynamic_cast<AliGRPObject*>(entry->GetObject());
36 if (!grpData) {printf("Failed to get GRP data for run",runNumber); return;}
37 Int_t activeDetectors = grpData->GetDetectorMask();
38 TString detStr = AliDAQ::ListOfTriggeredDetectors(activeDetectors);
39 printf("Detectors in the data:\n%s\n",detStr.Data());
40 printf("Monalisa: Detectors in the data:\t%s\n",detStr.Data());
42 // Steering Tasks - set output storage
43 // DefaultStorage set already before - in ConfigCalibTrain.C
44 //targetOCDBstorage+="?se=ALICE::CERN::SE";
46 // for tests, the target OCDB has to be different from raw://, but since the calibration procedure may need to read the OCDB,
47 // one cannot set the target OCDB as new default storage, since it could it that it does not contain all the necessary entries.
48 // This is true only if the target OCDB storage is different from the one used as default source and to configure the train
49 if (targetOCDBstorage != sourceOCDBstorage) AliCDBManager::Instance()->SetSpecificStorage("*/*/*", targetOCDBstorage.Data());
51 if (gSystem->AccessPathName("TPC", kFileExists)==0) {
52 AliCDBManager::Instance()->SetSpecificStorage("TPC/Calib/Correction","local://");
55 if (targetOCDBstorage.Length()==0) targetOCDBstorage+="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
58 AliTPCPreprocessorOffline *procesTPC = 0;
59 if (detStr.Contains("TPC")){
60 Printf("\n******* Calibrating TPC *******");
61 procesTPC = new AliTPCPreprocessorOffline;
62 // switch on parameter validation
63 procesTPC->SetTimeGainRange(0.5,5.0);
64 procesTPC->SetMaxVDriftCorr(0.2);
65 procesTPC->SwitchOnValidation();
67 // Make timegain calibration
68 //proces.CalibTimeGain("CalibObjects.root", runNumber,AliCDBRunRange::Infinity(),targetOCDBstorage);
69 procesTPC->CalibTimeGain("CalibObjects.root", runNumber,runNumber,targetOCDBstorage);
71 // Make vdrift calibration
72 //proces.CalibTimeVdrift("CalibObjects.root",runNumber,AliCDBRunRange::Infinity(),targetOCDBstorage);
73 procesTPC->CalibTimeVdrift("CalibObjects.root",runNumber,runNumber,targetOCDBstorage);
77 AliTOFAnalysisTaskCalibPass0 *procesTOF=0;
78 if ( detStr.Contains("TOF") && detStr.Contains("TPC")){
79 procesTOF = new AliTOFAnalysisTaskCalibPass0;
80 Printf("\n******* Calibrating TOF *******");
81 procesTOF->ProcessOutput("CalibObjects.root", targetOCDBstorage);
85 AliT0PreprocessorOffline *procesT0= 0;
86 if ( detStr.Contains("T0")) {
87 Printf("\n******* Calibrating T0 *******");
88 // Make calibration of channels offset
89 procesT0= new AliT0PreprocessorOffline;
90 procesT0->Process("CalibObjects.root",runNumber, runNumber, targetOCDBstorage);
94 AliTRDPreprocessorOffline *procesTRD = 0;
95 if ( detStr.Contains("TRD") && detStr.Contains("TPC")){
96 Printf("\n******* Calibrating TRD *******");
97 procesTRD = new AliTRDPreprocessorOffline;
98 procesTRD->SetLinearFitForVdrift(kTRUE);
99 procesTRD->SetMinStatsVdriftT0PH(600*10);
100 procesTRD->SetMinStatsVdriftLinear(50);
101 procesTRD->SetMinStatsGain(600);
102 procesTRD->SetLimitValidateNoData(60);
103 procesTRD->SetLimitValidateBadCalib(60);
104 procesTRD->SetAlternativeDriftVelocityFit(kTRUE);
105 procesTRD->Init("CalibObjects.root");
106 Int_t versionVdriftUsed = procesTRD->GetVersionVdriftUsed();
107 Int_t subversionVdriftUsed = procesTRD->GetSubVersionVdriftUsed();
108 Int_t versionGainUsed = procesTRD->GetVersionGainUsed();
109 Int_t subversionGainUsed = procesTRD->GetSubVersionGainUsed();
110 Int_t versionExBUsed = procesTRD->GetVersionExBUsed();
111 Int_t subversionExBUsed = procesTRD->GetSubVersionExBUsed();
112 printf("version and subversion vdrift %d and %d\n",versionVdriftUsed,subversionVdriftUsed);
113 printf("version and subversion gain %d and %d\n",versionGainUsed,subversionGainUsed);
114 printf("version and subversion exb %d and %d\n",versionExBUsed,subversionExBUsed);
115 procesTRD->Process("CalibObjects.root",runNumber,runNumber,targetOCDBstorage);
119 AliMeanVertexPreprocessorOffline * procesMeanVtx=0;
120 if ( detStr.Contains("ITSSPD")) {
121 Printf("\n******* Calibrating MeanVertex *******");
122 procesMeanVtx = new AliMeanVertexPreprocessorOffline;
123 procesMeanVtx->ProcessOutput("CalibObjects.root", targetOCDBstorage, runNumber);
127 // Print calibration status into the stdout
129 Int_t trdStatus = (procesTRD) ? procesTRD->GetStatus():0;
130 Int_t tofStatus = (procesTOF) ? procesTOF->GetStatus():0;
131 Int_t t0Status = (procesT0) ? procesT0->GetStatus():0;
132 Int_t tpcStatus = (procesTPC) ? ((procesTPC->ValidateTimeDrift() || procesTPC->ValidateTimeGain())==kFALSE):0;
135 printf("******* CPass0 calibration status *******\n");
136 printf("TRD calibration status=%d\n",trdStatus);
137 printf("TOF calibration status=%d\n",tofStatus);
138 printf("TPC calibration status=%d\n",tpcStatus);
139 printf("T0 calibration status=%d\n",t0Status);
141 TTreeSRedirector *pcstream = new TTreeSRedirector("cpassStat.root","recreate");
142 printCalibStat(runNumber, "CalibObjects.root",pcstream);
148 // function to print statistics used to calibrate the various detectors
150 void printCalibStat(Int_t run, const char * fname, TTreeSRedirector * pcstream){
153 // Dump the statistical information about all histograms in the calibration files
154 // into the statistical tree, print on the screen (log files) as well
157 // 1. Default dump for all histograms
158 // Information to dump:
159 // stat =Entries, Mean, MeanError, RMS, MaxBin
160 // Branch naming convention:
161 // <detName>_<hisName><statName>
163 // 2. Detector statistical information - to be implemented by expert
164 // - First version implemented by MI
168 TFile *fin = TFile::Open(fname);
170 const Double_t kMaxHis=10000;
172 TList * keyList = fin->GetListOfKeys();
173 Int_t nkeys=keyList->GetEntries();
174 Double_t *hisEntries = new Double_t[kMaxHis];
175 Double_t *hisMean = new Double_t[kMaxHis];
176 Double_t *hisMeanError = new Double_t[kMaxHis];
177 Double_t *hisRMS = new Double_t[kMaxHis];
178 Double_t *hisMaxBin = new Double_t[kMaxHis];
181 if (pcstream) (*pcstream)<<"calibStatAll"<<"run="<<run;
182 for (Int_t ikey=0; ikey<nkeys; ikey++){
183 TObject * object = fin->Get(keyList->At(ikey)->GetName());
184 if (!object) continue;
185 if (object->InheritsFrom("TCollection")==0) continue;
186 TSeqCollection *collection = (TSeqCollection*)object;
187 Int_t nentries= collection->GetEntries();
188 for (Int_t ihis=0; ihis<nentries; ihis++){
189 TObject * ohis = collection->At(ihis);
191 if (ohis->InheritsFrom("TH1")==0) continue;
192 TH1* phis = (TH1*)ohis;
193 hisEntries[counter]=phis->GetEntries();
195 if (ohis->InheritsFrom("TH2")) idim=2;
196 if (ohis->InheritsFrom("TH3")) idim=3;
197 hisMean[counter]=phis->GetMean(idim);
198 hisMeanError[counter]=phis->GetMeanError(idim);
199 hisRMS[counter]=phis->GetRMS(idim);
200 hisMaxBin[counter]=phis->GetBinCenter(phis->GetMaximumBin());
201 if (pcstream) (*pcstream)<<"calibStatAll"<<
202 Form("%s_%sEntries=",keyList->At(ikey)->GetName(), phis->GetName())<<hisEntries[counter]<<
203 Form("%s_%sMean=",keyList->At(ikey)->GetName(), phis->GetName())<<hisMean[counter]<<
204 Form("%s_%sMeanError=",keyList->At(ikey)->GetName(), phis->GetName())<<hisMeanError[counter]<<
205 Form("%s_%sRMS=",keyList->At(ikey)->GetName(), phis->GetName())<<hisRMS[counter]<<
206 Form("%s_%sMaxBin=",keyList->At(ikey)->GetName(), phis->GetName())<<hisMaxBin[counter];
207 //printf("Histo:\t%s_%s\t%f\t%d\n",keyList->At(ikey)->GetName(), phis->GetName(), hisEntries[counter],idim);
214 // Expert dump example (MI first iteration):
221 TList * TOFCalib = (TList*)fin->Get("TOFHistos");
223 TH1 *histoEvents = (TH1*)TOFCalib->FindObject("hHistoVertexTimestamp");
224 TH1 *histoTracks = (TH1*)TOFCalib->FindObject("hHistoDeltatTimestamp");
225 if (histoEvents && histoTracks){
226 tofEvents = TMath::Nint(histoEvents->GetEntries());
227 tofTracks = TMath::Nint(histoTracks->GetEntries());
231 printf("Monalisa TOFevents\t%d\n",tofEvents);
232 if (pcstream) (*pcstream)<<"calibStatAll"<<"TOFevents="<<tofEvents;
233 printf("Monalisa TOFtracks\t%d\n",tofTracks);
234 if (pcstream) (*pcstream)<<"calibStatAll"<<"TOFtracks="<<tofTracks;
237 // 1.) TPC dump - usefull events/tracks for the calibration
241 TList * TPCCalib = (TList*)fin->Get("TPCCalib");
243 AliTPCcalibTime * calibTime = (AliTPCcalibTime *)TPCCalib->FindObject("calibTime");
245 tpcEvents = TMath::Nint(calibTime->GetTPCVertexHisto(0)->GetEntries());
246 tpcTracks = TMath::Nint(calibTime->GetResHistoTPCITS(0)->GetEntries());
249 printf("Monalisa TPCevents\t%d\n",tpcEvents);
250 if (pcstream) (*pcstream)<<"calibStatAll"<<"TPCevents="<<tpcEvents;
251 printf("Monalisa TPCtracks\t%d\n",tpcTracks);
252 if (pcstream) (*pcstream)<<"calibStatAll"<<"TPCtracks="<<tpcTracks;
259 TList * TRDCalib = (TList*)fin->Get("TRDCalib");
261 TH1 *histoEvents = (TH1*)TRDCalib->FindObject("NEventsInput_AliTRDCalibTask");
262 TH1 *histoTracks = (TH1*)TRDCalib->FindObject("AbsoluteGain_AliTRDCalibTask");
263 if (histoEvents && histoTracks){
264 trdEvents= TMath::Nint(histoEvents->GetEntries());
265 trdTracks= TMath::Nint(histoTracks->GetEntries());
269 printf("Monalisa TRDevents\t%d\n",trdEvents);
270 if (pcstream) (*pcstream)<<"calibStatAll"<<"TRDevents="<<trdEvents;
271 printf("Monalisa TRDtracks\t%d\n",trdTracks);
272 if (pcstream) (*pcstream)<<"calibStatAll"<<"TRDtracks="<<trdTracks;
278 TList * T0Calib = (TList*)fin->Get("T0Calib");
280 TH1 *histoEvents = (TH1*) T0Calib->FindObject("fTzeroORAplusORC");
282 T0Events= TMath::Nint(histoEvents->GetEntries());
286 printf("Monalisa T0events\t%d\n",T0Events);
287 if (pcstream) (*pcstream)<<"calibStatAll"<<"T0events="<<T0Events;
290 // 4. Mean vertex - dump
291 Int_t meanVertexEvents=0;
292 TList * meanVertexCalib = (TList*)fin->Get("MeanVertex");
293 if (meanVertexCalib) {
294 TH1 *histoEvents = (TH1*) meanVertexCalib->FindObject("hTRKVertexX");
296 meanVertexEvents = TMath::Nint(histoEvents->GetEntries());
298 delete meanVertexCalib;
300 printf("Monalisa MeanVertexevents\t%d\n",meanVertexEvents);
301 if (pcstream) (*pcstream)<<"calibStatAll"<<"MeanVertexevents="<<meanVertexEvents;
308 TList * SDDCalib = (TList*)fin->Get("clistSDDCalib");
310 TH1 *histoEvents = (TH1*) SDDCalib->FindObject("hNEvents");
312 sddEvents = TMath::Nint(histoEvents->GetBinContent(4));
313 sddTracks = TMath::Nint(histoEvents->GetBinContent(5));
317 printf("Monalisa SDDevents\t%d\n",sddEvents);
318 if (pcstream) (*pcstream)<<"calibStatAll"<<"SDDevents="<<sddEvents;
319 printf("Monalisa SDDtracks\t%d\n",sddTracks);
320 if (pcstream) (*pcstream)<<"calibStatAll"<<"SDDtracks="<<sddTracks;
323 if (pcstream) (*pcstream)<<"calibStatAll"<<"\n";