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
42 // Setting the mirror SEs for the default storage
43 TString mirrorsStr("ALICE::CERN::OCDB,ALICE::FZK::SE,ALICE::LLNL::SE");
44 AliCDBManager::Instance()->SetMirrorSEs(mirrorsStr.Data());
45 printf("List of mirror SEs set to: \"%s\"\n",mirrorsStr.Data());
47 // activate target OCDB storage
48 AliCDBStorage* targetStorage = 0x0;
49 if (targetOCDBstorage.Length()==0) targetOCDBstorage+="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
50 else if (targetOCDBstorage.CompareTo("same",TString::kIgnoreCase) == 0 ){
51 targetStorage = AliCDBManager::Instance()->GetDefaultStorage();
54 targetStorage = AliCDBManager::Instance()->GetStorage(targetOCDBstorage.Data());
56 printf("** targetOCDBstorage: \"%s\"\n",targetOCDBstorage.Data());
58 // specific storage for TPC/Calib/Correction entry
59 if (gSystem->AccessPathName("TPC", kFileExists)==0) {
60 AliCDBManager::Instance()->SetSpecificStorage("TPC/Calib/Correction","local://");
64 AliTPCPreprocessorOffline *procesTPC = 0;
65 if (detStr.Contains("TPC")){
66 Printf("\n******* Calibrating TPC *******");
67 Printf("TPC won't be calibrated at CPass1 for the time being... Doing nothing here");
68 //procesTPC = new AliTPCPreprocessorOffline;
69 // switch on parameter validation
70 //procesTPC->SetTimeGainRange(0.5,4.0);
71 //procesTPC->SetMinTracksVdrift(100000);
72 //procesTPC->SwitchOnValidation();
73 // Make timegain calibration
74 //proces.CalibTimeGain("CalibObjects.root", runNumber,AliCDBRunRange::Infinity(),targetStorage);
75 // Make vdrift calibration
76 //proces.CalibTimeVdrift("CalibObjects.root",runNumber,AliCDBRunRange::Infinity(),targetStorage);
80 AliTOFAnalysisTaskCalibPass0 *procesTOF=0;
81 if (detStr.Contains("TOF") && detStr.Contains("TPC")){
82 procesTOF = new AliTOFAnalysisTaskCalibPass0;
83 Printf("\n******* Calibrating TOF *******");
84 procesTOF->ProcessOutput("CalibObjects.root", targetStorage);
88 AliT0PreprocessorOffline *procesT0= 0;
89 if (detStr.Contains("T0")) {
90 Printf("\n******* Calibrating T0 *******");
91 procesT0 = new AliT0PreprocessorOffline;
92 // Make calibration of channels offset
93 procesT0->setDArun(177000);
94 procesT0->Process("CalibObjects.root",runNumber, runNumber, targetStorage);
98 AliTRDPreprocessorOffline *procesTRD = 0;
99 if (detStr.Contains("TRD") && detStr.Contains("TPC")){
100 Printf("\n******* Calibrating TRD *******");
101 procesTRD = new AliTRDPreprocessorOffline;
102 procesTRD->SetLinearFitForVdrift(kTRUE);
103 procesTRD->SetMinStatsVdriftT0PH(600*10);
104 procesTRD->SetMinStatsVdriftLinear(50);
105 procesTRD->SetMinStatsGain(600);
106 procesTRD->SetLimitValidateNoData(60);
107 procesTRD->SetLimitValidateBadCalib(60);
108 procesTRD->SetAlternativeDriftVelocityFit(kTRUE);
109 procesTRD->Init("CalibObjects.root");
110 Int_t versionVdriftUsed = procesTRD->GetVersionVdriftUsed();
111 Int_t subversionVdriftUsed = procesTRD->GetSubVersionVdriftUsed();
112 Int_t versionGainUsed = procesTRD->GetVersionGainUsed();
113 Int_t subversionGainUsed = procesTRD->GetSubVersionGainUsed();
114 Int_t versionExBUsed = procesTRD->GetVersionExBUsed();
115 Int_t subversionExBUsed = procesTRD->GetSubVersionExBUsed();
116 printf("version and subversion vdrift %d and %d\n",versionVdriftUsed,subversionVdriftUsed);
117 printf("version and subversion gain %d and %d\n",versionGainUsed,subversionGainUsed);
118 printf("version and subversion exb %d and %d\n",versionExBUsed,subversionExBUsed);
119 procesTRD->Process("CalibObjects.root",runNumber,runNumber,targetStorage);
122 // switched OFF at CPass1 in any case
125 AliMeanVertexPreprocessorOffline * procesMeanVtx=0;
126 if (detStr.Contains("ITSSPD")) {
127 Printf("\n******* Calibrating MeanVertex *******");
128 procesMeanVtx = new AliMeanVertexPreprocessorOffline;
129 procesMeanVtx->ProcessOutput("CalibObjects.root", targetStorage, runNumber);
134 // Print calibration status into the stdout
136 Int_t trdStatus = (procesTRD) ? procesTRD->GetStatus():0;
137 Int_t tofStatus = (procesTOF) ? procesTOF->GetStatus():0;
138 Int_t t0Status = (procesT0) ? procesT0->GetStatus():0;
139 Int_t tpcStatus = (procesTPC) ? procesTPC->GetStatus():0;
142 printf("******* CPass1 calibration status *******\n");
143 printf("TRD calibration status=%d\n",trdStatus);
144 printf("TOF calibration status=%d\n",tofStatus);
145 printf("TPC calibration status=%d\n",tpcStatus);
146 printf("T0 calibration status=%d\n",t0Status);
148 TTreeSRedirector *pcstream = new TTreeSRedirector("cpassStat.root","recreate");
149 printCalibStat(runNumber, "CalibObjects.root",pcstream);
155 // function to print statistics used to calibrate the various detectors
157 void printCalibStat(Int_t run, const char * fname, TTreeSRedirector * pcstream){
160 // Dump the statistical information about all histograms in the calibration files
161 // into the statistical tree, print on the screen (log files) as well
164 // 1. Default dump for all histograms
165 // Information to dump:
166 // stat =Entries, Mean, MeanError, RMS, MaxBin
167 // Branch naming convention:
168 // <detName>_<hisName><statName>
170 // 2. Detector statistical information - to be implemented by expert
171 // - First version implemented by MI
175 TFile *fin = TFile::Open(fname);
177 const Double_t kMaxHis=10000;
179 TList * keyList = fin->GetListOfKeys();
180 Int_t nkeys=keyList->GetEntries();
181 Double_t *hisEntries = new Double_t[kMaxHis];
182 Double_t *hisMean = new Double_t[kMaxHis];
183 Double_t *hisMeanError = new Double_t[kMaxHis];
184 Double_t *hisRMS = new Double_t[kMaxHis];
185 Double_t *hisMaxBin = new Double_t[kMaxHis];
188 if (pcstream) (*pcstream)<<"calibStatAll"<<"run="<<run;
189 for (Int_t ikey=0; ikey<nkeys; ikey++){
190 TObject * object = fin->Get(keyList->At(ikey)->GetName());
191 if (!object) continue;
192 if (object->InheritsFrom("TCollection")==0) continue;
193 TSeqCollection *collection = (TSeqCollection*)object;
194 Int_t nentries= collection->GetEntries();
195 for (Int_t ihis=0; ihis<nentries; ihis++){
196 TObject * ohis = collection->At(ihis);
198 if (ohis->InheritsFrom("TH1")==0) continue;
199 TH1* phis = (TH1*)ohis;
200 hisEntries[counter]=phis->GetEntries();
202 if (ohis->InheritsFrom("TH2")) idim=2;
203 if (ohis->InheritsFrom("TH3")) idim=3;
204 hisMean[counter]=phis->GetMean(idim);
205 hisMeanError[counter]=phis->GetMeanError(idim);
206 hisRMS[counter]=phis->GetRMS(idim);
207 hisMaxBin[counter]=phis->GetBinCenter(phis->GetMaximumBin());
208 if (pcstream) (*pcstream)<<"calibStatAll"<<
209 Form("%s_%sEntries=",keyList->At(ikey)->GetName(), phis->GetName())<<hisEntries[counter]<<
210 Form("%s_%sMean=",keyList->At(ikey)->GetName(), phis->GetName())<<hisMean[counter]<<
211 Form("%s_%sMeanError=",keyList->At(ikey)->GetName(), phis->GetName())<<hisMeanError[counter]<<
212 Form("%s_%sRMS=",keyList->At(ikey)->GetName(), phis->GetName())<<hisRMS[counter]<<
213 Form("%s_%sMaxBin=",keyList->At(ikey)->GetName(), phis->GetName())<<hisMaxBin[counter];
214 //printf("Histo:\t%s_%s\t%f\t%d\n",keyList->At(ikey)->GetName(), phis->GetName(), hisEntries[counter],idim);
221 // Expert dump example (MI first iteration):
228 TList * TOFCalib = (TList*)fin->Get("TOFHistos");
230 TH1 *histoEvents = (TH1*)TOFCalib->FindObject("hHistoVertexTimestamp");
231 TH1 *histoTracks = (TH1*)TOFCalib->FindObject("hHistoDeltatTimestamp");
232 if (histoEvents && histoTracks){
233 tofEvents = TMath::Nint(histoEvents->GetEntries());
234 tofTracks = TMath::Nint(histoTracks->GetEntries());
238 printf("Monalisa TOFevents\t%d\n",tofEvents);
239 if (pcstream) (*pcstream)<<"calibStatAll"<<"TOFevents="<<tofEvents;
240 printf("Monalisa TOFtracks\t%d\n",tofTracks);
241 if (pcstream) (*pcstream)<<"calibStatAll"<<"TOFtracks="<<tofTracks;
244 // 1.) TPC dump - usefull events/tracks for the calibration
248 TList * TPCCalib = (TList*)fin->Get("TPCCalib");
250 AliTPCcalibTime * calibTime = (AliTPCcalibTime *)TPCCalib->FindObject("calibTime");
252 tpcEvents = TMath::Nint(calibTime->GetTPCVertexHisto(0)->GetEntries());
253 tpcTracks = TMath::Nint(calibTime->GetResHistoTPCITS(0)->GetEntries());
256 printf("Monalisa TPCevents\t%d\n",tpcEvents);
257 if (pcstream) (*pcstream)<<"calibStatAll"<<"TPCevents="<<tpcEvents;
258 printf("Monalisa TPCtracks\t%d\n",tpcTracks);
259 if (pcstream) (*pcstream)<<"calibStatAll"<<"TPCtracks="<<tpcTracks;
266 TList * TRDCalib = (TList*)fin->Get("TRDCalib");
268 TH1 *histoEvents = (TH1*)TRDCalib->FindObject("NEventsInput_AliTRDCalibTask");
269 TH1 *histoTracks = (TH1*)TRDCalib->FindObject("AbsoluteGain_AliTRDCalibTask");
270 if (histoEvents && histoTracks){
271 trdEvents= TMath::Nint(histoEvents->GetEntries());
272 trdTracks= TMath::Nint(histoTracks->GetEntries());
276 printf("Monalisa TRDevents\t%d\n",trdEvents);
277 if (pcstream) (*pcstream)<<"calibStatAll"<<"TRDevents="<<trdEvents;
278 printf("Monalisa TRDtracks\t%d\n",trdTracks);
279 if (pcstream) (*pcstream)<<"calibStatAll"<<"TRDtracks="<<trdTracks;
285 TList * T0Calib = (TList*)fin->Get("T0Calib");
287 TH1 *histoEvents = (TH1*) T0Calib->FindObject("fTzeroORAplusORC");
289 T0Events= TMath::Nint(histoEvents->GetEntries());
293 printf("Monalisa T0events\t%d\n",T0Events);
294 if (pcstream) (*pcstream)<<"calibStatAll"<<"T0events="<<T0Events;
297 // 4. Mean vertex - dump
298 // Not present in CPass1
300 Int_t meanVertexEvents=0;
301 TList * meanVertexCalib = (TList*)fin->Get("MeanVertex");
302 if (meanVertexCalib) {
303 TH1 *histoEvents = (TH1*) meanVertexCalib->FindObject("hTRKVertexX");
305 meanVertexEvents = TMath::Nint(histoEvents->GetEntries());
307 delete meanVertexCalib;
309 printf("Monalisa MeanVertexevents\t%d\n",meanVertexEvents);
310 if (pcstream) (*pcstream)<<"calibStatAll"<<"MeanVertexevents="<<meanVertexEvents;
318 TList * SDDCalib = (TList*)fin->Get("clistSDDCalib");
320 TH1 *histoEvents = (TH1*) SDDCalib->FindObject("hNEvents");
322 sddEvents = TMath::Nint(histoEvents->GetBinContent(4));
323 sddTracks = TMath::Nint(histoEvents->GetBinContent(5));
327 printf("Monalisa SDDevents\t%d\n",sddEvents);
328 if (pcstream) (*pcstream)<<"calibStatAll"<<"SDDevents="<<sddEvents;
329 printf("Monalisa SDDtracks\t%d\n",sddTracks);
330 if (pcstream) (*pcstream)<<"calibStatAll"<<"SDDtracks="<<sddTracks;
333 if (pcstream) (*pcstream)<<"calibStatAll"<<"\n";