]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCPreprocessorOffline.cxx
Add new class for drift velocity
[u/mrichter/AliRoot.git] / TPC / AliTPCPreprocessorOffline.cxx
CommitLineData
da268e11 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16
17
18/*
f12abd89 19 Responsible: marian.ivanov@cern.ch
20 Code to analyze the TPC calibration and to produce OCDB entries
21
22
da268e11 23 .x ~/rootlogon.C
24 gSystem->Load("libANALYSIS");
25 gSystem->Load("libTPCcalib");
da268e11 26
27 AliTPCPreprocessorOffline proces;
b322e06a 28 TString ocdbPath="local:////"
29 ocdbPath+=gSystem->GetFromPipe("pwd");
30
31 proces.CalibTimeGain("CalibObjects.root",run0,run1,ocdbPath);
32 proces.CalibTimeVdrift("CalibObjects.root",run0,run1,ocdbPath);
f12abd89 33 // take the raw calibration data from the file CalibObjects.root
34 // and make a OCDB entry with run validity run0-run1
35 // results are stored at the ocdbPath - local or alien ...
36 // default storage ""- data stored at current working directory
da268e11 37
68d461b2 38 e.g.
39 AliTPCPreprocessorOffline process;
40 process.CalibTimeGain("CalibObjects.root",114000,121040,0);
41 TFile oo("OCDB/TPC/Calib/TimeGain/Run114000_121040_v0_s0.root")
42 TObjArray * arr = AliCDBEntry->GetObject()
43 arr->At(4)->Draw("alp")
44
da268e11 45*/
f12abd89 46#include "Riostream.h"
47#include <fstream>
da268e11 48#include "TMap.h"
49#include "TGraphErrors.h"
50#include "AliExternalTrackParam.h"
51#include "TFile.h"
52#include "TGraph.h"
53#include "TMultiGraph.h"
54#include "TCanvas.h"
55#include "THnSparse.h"
56#include "TLegend.h"
57#include "TPad.h"
58#include "TH2D.h"
391ffdb2 59#include "TH3D.h"
da268e11 60#include "AliTPCROC.h"
61#include "AliTPCCalROC.h"
da268e11 62#include "AliESDfriend.h"
da268e11 63#include "AliTPCcalibTime.h"
64#include "AliSplineFit.h"
65#include "AliCDBMetaData.h"
66#include "AliCDBId.h"
67#include "AliCDBManager.h"
68#include "AliCDBStorage.h"
69#include "AliTPCcalibBase.h"
70#include "AliTPCcalibDB.h"
71#include "AliTPCcalibDButil.h"
72#include "AliRelAlignerKalman.h"
73#include "AliTPCParamSR.h"
74#include "AliTPCcalibTimeGain.h"
75#include "AliSplineFit.h"
76#include "AliTPCPreprocessorOffline.h"
da268e11 77
78
79ClassImp(AliTPCPreprocessorOffline)
80
81AliTPCPreprocessorOffline::AliTPCPreprocessorOffline():
f12abd89 82 TNamed("TPCPreprocessorOffline","TPCPreprocessorOffline"),
40120adc 83 fMinEntries(500), // minimal number of entries for fit
da268e11 84 startRun(0), // start Run - used to make fast selection in THnSparse
85 endRun(0), // end Run - used to make fast selection in THnSparse
86 startTime(0), // startTime - used to make fast selection in THnSparse
87 endTime(0), // endTime - used to make fast selection in THnSparse
88 ocdbStorage(""), // path to the OCDB storage
89 fVdriftArray(new TObjArray),
90 fTimeDrift(0),
91 fGraphMIP(0), // graph time dependence of MIP
92 fGraphCosmic(0), // graph time dependence at Plateu
391ffdb2 93 fGraphAttachmentMIP(0),
da268e11 94 fFitMIP(0), // fit of dependence - MIP
95 fFitCosmic(0), // fit of dependence - Plateu
96 fGainArray(new TObjArray), // array to be stored in the OCDB
97 fGainMIP(0), // calibration component for MIP
68d461b2 98 fGainCosmic(0), // calibration component for cosmic
99 fSwitchOnValidation(kFALSE) // flag to switch on validation of OCDB parameters
da268e11 100{
101 //
f12abd89 102 // default constructor
103 //
da268e11 104}
105
106AliTPCPreprocessorOffline::~AliTPCPreprocessorOffline() {
107 //
108 // Destructor
109 //
110}
111
112
113
114
40120adc 115void AliTPCPreprocessorOffline::GetRunRange(AliTPCcalibTime * const timeDrift){
da268e11 116 //
117 // find the fist and last run
118 //
f12abd89 119 TObjArray *hisArray =timeDrift->GetHistoDrift();
da268e11 120 {for (Int_t i=0; i<hisArray->GetEntriesFast(); i++){
121 THnSparse* addHist=(THnSparse*)hisArray->UncheckedAt(i);
40120adc 122 if (addHist->GetEntries()<fMinEntries) continue;
da268e11 123 if (!addHist) continue;
124 TH1D* histo =addHist->Projection(3);
125 TH1D* histoTime=addHist->Projection(0);
126 printf("%s\t%f\t%d\t%d\n",histo->GetName(), histo->GetEntries(),histo->FindFirstBinAbove(0),histo->FindLastBinAbove(0));
127
128 if (startRun<=0){
129 startRun=histo->FindFirstBinAbove(0);
130 endRun =histo->FindLastBinAbove(0);
131 }else{
132 startRun=TMath::Min(histo->FindFirstBinAbove(0),startRun);
133 endRun =TMath::Max(histo->FindLastBinAbove(0),endRun);
134 }
135 if (startTime==0){
136 startTime=histoTime->FindFirstBinAbove(0);
137 endTime =histoTime->FindLastBinAbove(0);
138 }else{
139 startTime=TMath::Min(histoTime->FindFirstBinAbove(0),startTime);
140 endTime =TMath::Max(histoTime->FindLastBinAbove(0),endTime);
141 }
142 delete histo;
143 delete histoTime;
144 }}
145 if (startRun<0) startRun=0;
146 if (endRun<0) endRun=100000000;
147 printf("Run range :\t%d-%d\n", startRun, endRun);
148 printf("Time range :\t%d-%d\n", startTime, endTime);
149
150}
151
152
153
40120adc 154void AliTPCPreprocessorOffline::CalibTimeVdrift(const Char_t* file, Int_t ustartRun, Int_t uendRun, TString pocdbStorage){
da268e11 155 //
40120adc 156 // make calibration of the drift velocity
157 // Input parameters:
158 // file - the location of input file
159 // ustartRun, uendrun - run validity period
160 // pocdbStorage - path to hte OCDB storage
161 // - if empty - local storage 'pwd' uesed
da268e11 162 if (pocdbStorage.Length()>0) ocdbStorage=pocdbStorage;
163 else
164 ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
165 //
166 // 1. Initialization and run range setting
167 TFile fcalib(file);
68d461b2 168 TObjArray * array = (TObjArray*)fcalib.Get("TPCCalib");
169 if (array){
170 fTimeDrift = (AliTPCcalibTime *)array->FindObject("calibTime");
171 } else {
172 fTimeDrift = (AliTPCcalibTime*)fcalib.Get("calibTime");
173 }
174 if(!fTimeDrift) return;
175
da268e11 176 startRun=ustartRun;
177 endRun=ustartRun;
178 TObjArray *hisArray =fTimeDrift->GetHistoDrift();
179 GetRunRange(fTimeDrift);
180 for (Int_t i=0; i<hisArray->GetEntriesFast(); i++){
181 THnSparse* addHist=(THnSparse*)hisArray->At(i);
182 if (!addHist) continue;
183 if (startTime<endTime) addHist->GetAxis(0)->SetRange(startTime-1,endTime+1);
184 if (startRun<endRun) addHist->GetAxis(3)->SetRange(startRun-1,endRun+1);
185 }
186 //
187 //
188 // 2. extraction of the information
189 //
190 fVdriftArray = new TObjArray();
191 AddAlignmentGraphs(fVdriftArray,fTimeDrift);
40120adc 192 AddHistoGraphs(fVdriftArray,fTimeDrift,fMinEntries);
da268e11 193 AddLaserGraphs(fVdriftArray,fTimeDrift);
194 //
195 // 3. Append QA plots
196 //
197 MakeDefaultPlots(fVdriftArray,fVdriftArray);
68d461b2 198
da268e11 199 //
68d461b2 200 // 4. validate OCDB entries
da268e11 201 //
68d461b2 202 if(fSwitchOnValidation==kTRUE && ValidateTimeDrift()==kFALSE) {
203 Printf("TPC time drift OCDB parameters out of range!");
204 return;
205 }
206
207 //
208 //
209 // 5. update of OCDB
da268e11 210 //
211 //
da268e11 212 UpdateOCDBDrift(ustartRun,uendRun,ocdbStorage);
213}
214
215void AliTPCPreprocessorOffline::UpdateOCDBDrift( Int_t ustartRun, Int_t uendRun, const char* storagePath ){
216 //
217 // Update OCDB
218 //
219 AliCDBMetaData *metaData= new AliCDBMetaData();
220 metaData->SetObjectClassName("TObjArray");
221 metaData->SetResponsible("Marian Ivanov");
222 metaData->SetBeamPeriod(1);
223 metaData->SetAliRootVersion("05-25-01"); //root version
224 metaData->SetComment("Calibration of the time dependence of the drift velocity");
225 AliCDBId* id1=NULL;
226 id1=new AliCDBId("TPC/Calib/TimeDrift", ustartRun, uendRun);
227 AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
228 gStorage->Put(fVdriftArray, (*id1), metaData);
229}
230
68d461b2 231Bool_t AliTPCPreprocessorOffline::ValidateTimeGain(Double_t minGain, Double_t maxGain)
232{
233 //
234 // Validate time gain corrections
235 //
236 Printf("ValidateTimeGain..." );
237
238 TGraphErrors *gr = (TGraphErrors*)fGainArray->FindObject("TGRAPHERRORS_MEAN_GAIN_BEAM_ALL");
239 if(!gr) return kFALSE;
240 if(gr->GetN()<1) return kFALSE;
241
242 // check whether gain in the range
243 for(Int_t iPoint=0; iPoint<gr->GetN(); iPoint++)
244 {
245 if(gr->GetY()[iPoint] < minGain || gr->GetY()[iPoint] > maxGain)
246 return kFALSE;
247 }
248
249return kTRUE;
250}
251
da268e11 252
68d461b2 253Bool_t AliTPCPreprocessorOffline::ValidateTimeDrift(Double_t maxVDriftCorr)
254{
255 //
256 // Validate time drift velocity corrections
257 //
258 Printf("ValidateTimeDrift..." );
259
260 TGraphErrors* gr = (TGraphErrors*)fVdriftArray->FindObject("ALIGN_ITSB_TPC_DRIFTVD");
261 if(!gr) return kFALSE;
262 if(gr->GetN()<1) return kFALSE;
263
264 // check whether drift velocity corrections in the range
265 for(Int_t iPoint = 0; iPoint<gr->GetN(); iPoint++)
266 {
267 if(TMath::Abs(gr->GetY()[iPoint]) > maxVDriftCorr)
268 return kFALSE;
269 }
270
271return kTRUE;
272}
da268e11 273
40120adc 274void AliTPCPreprocessorOffline::UpdateDriftParam(AliTPCParam *param, TObjArray *const arr, Int_t lstartRun){
da268e11 275 //
276 // update the OCDB entry for the nominal time0
277 //
278 //
279 // AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
280 AliTPCParam *paramNew = (AliTPCParam *)param->Clone();
281 TGraphErrors *grT = (TGraphErrors *)arr->FindObject("ALIGN_ITSM_TPC_T0");
282 Double_t deltaTcm = TMath::Median(grT->GetN(),grT->GetY());
283 Double_t deltaT = deltaTcm/param->GetDriftV();
284 paramNew->SetL1Delay(param->GetL1Delay()-deltaT);
285 paramNew->Update();
286
287 AliCDBMetaData *metaData= new AliCDBMetaData();
288 metaData->SetObjectClassName("TObjArray");
289 metaData->SetResponsible("Marian Ivanov");
290 metaData->SetBeamPeriod(1);
291 metaData->SetAliRootVersion("05-25-02"); //root version
292 metaData->SetComment("Updated calibration of nominal time 0");
293 AliCDBId* id1=NULL;
f12abd89 294 id1=new AliCDBId("TPC/Calib/Parameters", lstartRun, AliCDBRunRange::Infinity());
da268e11 295 AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage);
296 gStorage->Put(param, (*id1), metaData);
297
298}
299
300
301void AliTPCPreprocessorOffline::PrintArray(TObjArray *array){
302 //
40120adc 303 // Print the names of the entries in array
da268e11 304 //
305 Int_t entries = array->GetEntries();
306 for (Int_t i=0; i<entries; i++){
307 if (!array->At(i)) continue;
308 printf("%d\t %s\n", i, array->At(i)->GetName());
309 }
310}
311
312
313
314TGraphErrors* AliTPCPreprocessorOffline::FilterGraphDrift(TGraphErrors * graph, Float_t errSigmaCut, Float_t medianCutAbs){
315 // 2 filters:
316 // 1. filter graph - error cut errSigmaCut
317 // 2. filter graph - medianCutAbs around median
318 //
319 // errSigmaCut - cut on error
320 // medianCutAbs - cut on value around median
321 Double_t dummy=0; //
322 //
323 // 1. filter graph - error cut errSigmaCut
324 //
325 TGraphErrors *graphF;
326 graphF = AliTPCcalibDButil::FilterGraphMedianErr(graph,errSigmaCut,dummy);
327 delete graph;
328 if (!graphF) return 0;
329 graph = AliTPCcalibDButil::FilterGraphMedianErr(graphF,errSigmaCut,dummy);
330 delete graphF;
331 if (!graph) return 0;
332 //
333 // filter graph - kMedianCutAbs around median
334 //
335 graphF=FilterGraphMedianAbs(graph, medianCutAbs,dummy);
336 delete graph;
337 if (!graphF) return 0;
338 graph=FilterGraphMedianAbs(graphF, medianCutAbs,dummy);
339 delete graphF;
340 if (!graph) return 0;
341 return graph;
342}
343
344
345
346TGraphErrors* AliTPCPreprocessorOffline::FilterGraphMedianAbs(TGraphErrors * graph, Float_t cut,Double_t &medianY){
347 //
348 // filter outlyer measurement
349 // Only points around median +- cut filtered
350 //
351 if (!graph) return 0;
352 Int_t kMinPoints=2;
353 Int_t npoints0 = graph->GetN();
354 Int_t npoints=0;
355 Float_t rmsY=0;
356 Double_t *outx=new Double_t[npoints0];
357 Double_t *outy=new Double_t[npoints0];
358 Double_t *errx=new Double_t[npoints0];
359 Double_t *erry=new Double_t[npoints0];
360 //
361 //
362 if (npoints0<kMinPoints) return 0;
363 for (Int_t iter=0; iter<3; iter++){
364 npoints=0;
365 for (Int_t ipoint=0; ipoint<npoints0; ipoint++){
366 if (graph->GetY()[ipoint]==0) continue;
367 if (iter>0 &&TMath::Abs(graph->GetY()[ipoint]-medianY)>cut) continue;
368 outx[npoints] = graph->GetX()[ipoint];
369 outy[npoints] = graph->GetY()[ipoint];
370 errx[npoints] = graph->GetErrorX(ipoint);
371 erry[npoints] = graph->GetErrorY(ipoint);
372 npoints++;
373 }
374 if (npoints<=1) break;
375 medianY =TMath::Median(npoints,outy);
376 rmsY =TMath::RMS(npoints,outy);
377 }
378 TGraphErrors *graphOut=0;
379 if (npoints>1) graphOut= new TGraphErrors(npoints,outx,outy,errx,erry);
831e26ce 380 delete []outx;
381 delete []outy;
382 delete []errx;
383 delete []erry;
da268e11 384 return graphOut;
385}
386
387
40120adc 388void AliTPCPreprocessorOffline::AddHistoGraphs( TObjArray * vdriftArray, AliTPCcalibTime * const timeDrift, Int_t minEntries){
da268e11 389 //
390 // Add graphs corresponding to the alignment
391 //
392 const Double_t kErrSigmaCut=5; // error sigma cut - for filtering
393 const Double_t kMedianCutAbs=0.03; // error sigma cut - for filtering
394 //
395 TObjArray * array=timeDrift->GetHistoDrift();
396 if (array){
397 THnSparse* hist=NULL;
398 // 2.a) cosmics with different triggers
399 for (Int_t i=0; i<array->GetEntriesFast();i++){
400 hist=(THnSparseF*)array->UncheckedAt(i);
401 if(!hist) continue;
402 if (hist->GetEntries()<minEntries) continue;
403 //hist->Print();
404 TString name=hist->GetName();
405 Int_t dim[4]={0,1,2,3};
406 THnSparse* newHist=hist->Projection(4,dim);
407 newHist->SetName(name);
408 TGraphErrors* graph=AliTPCcalibBase::FitSlices(newHist,2,0,400,100,0.05,0.95, kTRUE);
409 printf("name=%s graph=%i, N=%i\n", name.Data(), graph==0, graph->GetN());
410 Int_t pos=name.Index("_");
411 name=name(pos,name.Capacity()-pos);
412 TString graphName=graph->ClassName();
413 graphName+=name;
414 graphName.ToUpper();
415 //
416 graph = FilterGraphDrift(graph, kErrSigmaCut, kMedianCutAbs);
417 if (!graph) {
418 printf("Graph =%s filtered out\n", name.Data());
419 continue;
831e26ce 420 }
421 if (graph){
422 graph->SetMarkerStyle(i%8+20);
423 graph->SetMarkerColor(i%7);
424 graph->GetXaxis()->SetTitle("Time");
425 graph->GetYaxis()->SetTitle("v_{dcor}");
426 graph->SetName(graphName);
427 graph->SetTitle(graphName);
428 printf("Graph %d\t=\t%s\n", i, graphName.Data());
429 vdriftArray->Add(graph);
da268e11 430 }
da268e11 431 }
432 }
433}
434
435
436
437
40120adc 438void AliTPCPreprocessorOffline::AddAlignmentGraphs( TObjArray * vdriftArray, AliTPCcalibTime *const timeDrift){
da268e11 439 //
440 // Add graphs corresponding to alignment to the object array
441 //
442 TObjArray *arrayITS=0;
443 TObjArray *arrayTOF=0;
444 TObjArray *arrayTRD=0;
445 TMatrixD *mstatITS=0;
446 TMatrixD *mstatTOF=0;
447 TMatrixD *mstatTRD=0;
448 //
449 arrayITS=timeDrift->GetAlignITSTPC();
450 arrayTRD=timeDrift->GetAlignTRDTPC();
451 arrayTOF=timeDrift->GetAlignTOFTPC();
452
453 if (arrayITS->GetEntries()>0) mstatITS= AliTPCcalibDButil::MakeStatRelKalman(arrayITS,0.9,50,0.025);
454 if (arrayTOF->GetEntries()>0) mstatTOF= AliTPCcalibDButil::MakeStatRelKalman(arrayTOF,0.9,1000,0.025);
455 if (arrayTRD->GetEntries()>0) mstatTRD= AliTPCcalibDButil::MakeStatRelKalman(arrayTRD,0.9,50,0.025);
456 //
457 TObjArray * arrayITSP= AliTPCcalibDButil::SmoothRelKalman(arrayITS,*mstatITS, 0, 5.);
458 TObjArray * arrayITSM= AliTPCcalibDButil::SmoothRelKalman(arrayITS,*mstatITS, 1, 5.);
459 TObjArray * arrayITSB= AliTPCcalibDButil::SmoothRelKalman(arrayITSP,arrayITSM);
460 TObjArray * arrayTOFP= AliTPCcalibDButil::SmoothRelKalman(arrayTOF,*mstatTOF, 0, 5.);
461 TObjArray * arrayTOFM= AliTPCcalibDButil::SmoothRelKalman(arrayTOF,*mstatTOF, 1, 5.);
462 TObjArray * arrayTOFB= AliTPCcalibDButil::SmoothRelKalman(arrayTOFP,arrayTOFM);
463
464 TObjArray * arrayTRDP= 0x0;
465 TObjArray * arrayTRDM= 0x0;
466 TObjArray * arrayTRDB= 0x0;
467 arrayTRDP= AliTPCcalibDButil::SmoothRelKalman(arrayTRD,*mstatTRD, 0, 5.);
468 arrayTRDM= AliTPCcalibDButil::SmoothRelKalman(arrayTRD,*mstatTRD, 1, 5.);
469 arrayTRDB= AliTPCcalibDButil::SmoothRelKalman(arrayTRDP,arrayTRDM);
470 //
471 //
472 Int_t entries=TMath::Max(arrayITS->GetEntriesFast(),arrayTOF->GetEntriesFast());
473 TObjArray *arrays[12]={arrayITS, arrayITSP, arrayITSM, arrayITSB,
474 arrayTRD, arrayTRDP, arrayTRDM, arrayTRDB,
475 arrayTOF, arrayTOFP, arrayTOFM, arrayTOFB};
476 TString grnames[12]={"ALIGN_ITS", "ALIGN_ITSP", "ALIGN_ITSM", "ALIGN_ITSB",
477 "ALIGN_TRD", "ALIGN_TRDP", "ALIGN_TRDM","ALIGN_TRDB",
478 "ALIGN_TOF", "ALIGN_TOFP", "ALIGN_TOFM","ALIGN_TOFB"};
479 TString grpar[9]={"DELTAPSI", "DELTATHETA", "DELTAPHI",
480 "DELTAX", "DELTAY", "DELTAZ",
481 "DRIFTVD", "T0", "VDGY"};
482
483
484 TVectorD vX(entries);
485 TVectorD vY(entries);
486 TVectorD vEx(entries);
487 TVectorD vEy(entries);
488 TObjArray *arr=0;
489 for (Int_t iarray=0; iarray<12; iarray++){
490 arr = arrays[iarray];
491 if (arr==0) continue;
492 for (Int_t ipar=0; ipar<9; ipar++){
493 Int_t counter=0;
494 for (Int_t itime=0; itime<arr->GetEntriesFast(); itime++){
495 AliRelAlignerKalman * kalman = (AliRelAlignerKalman *) arr->UncheckedAt(itime);
496 if (!kalman) continue;
497 vX[counter]=kalman->GetTimeStamp();
498 vY[counter]=(*(kalman->GetState()))[ipar];
499 if (ipar==6) vY[counter]=1./(*(kalman->GetState()))[ipar]-1;
500 vEx[counter]=0;
501 vEy[counter]=TMath::Sqrt((*(kalman->GetStateCov()))(ipar,ipar));
502 counter++;
503 }
504
505 TGraphErrors * graph=new TGraphErrors(counter, vX.GetMatrixArray(),
506 vY.GetMatrixArray(),
507 vEx.GetMatrixArray(),
508 vEy.GetMatrixArray());
509 TString grName=grnames[iarray];
510 grName+="_TPC_";
511 grName+=grpar[ipar];
512 graph->SetName(grName.Data());
513 vdriftArray->AddLast(graph);
514 }
515 }
516}
517
518
519
520
521void AliTPCPreprocessorOffline::AddLaserGraphs( TObjArray * vdriftArray, AliTPCcalibTime *timeDrift){
522 //
523 // add graphs for laser
524 //
525 const Double_t delayL0L1 = 0.071; //this is hack for 1/2 weeks
526 THnSparse *hisN=0;
527 TGraphErrors *grLaser[6]={0,0,0,0,0,0};
528 hisN = timeDrift->GetHistVdriftLaserA(0);
529 if (timeDrift->GetHistVdriftLaserA(0)){
530 grLaser[0]=MakeGraphFilter0(timeDrift->GetHistVdriftLaserA(0),0,2,5,delayL0L1);
531 grLaser[0]->SetName("GRAPH_MEAN_DELAY_LASER_ALL_A");
532 vdriftArray->AddLast(grLaser[0]);
533 }
534 if (timeDrift->GetHistVdriftLaserA(1)){
535 grLaser[1]=MakeGraphFilter0(timeDrift->GetHistVdriftLaserA(1),0,2,5);
536 grLaser[1]->SetName("GRAPH_MEAN_DRIFT_LASER_ALL_A");
537 vdriftArray->AddLast(grLaser[1]);
538 }
539 if (timeDrift->GetHistVdriftLaserA(2)){
540 grLaser[2]=MakeGraphFilter0(timeDrift->GetHistVdriftLaserA(2),0,2,5);
541 grLaser[2]->SetName("GRAPH_MEAN_GLOBALYGRADIENT_LASER_ALL_A");
542 vdriftArray->AddLast(grLaser[2]);
543 }
544 if (timeDrift->GetHistVdriftLaserC(0)){
545 grLaser[3]=MakeGraphFilter0(timeDrift->GetHistVdriftLaserC(0),0,2,5,delayL0L1);
546 grLaser[3]->SetName("GRAPH_MEAN_DELAY_LASER_ALL_C");
547 vdriftArray->AddLast(grLaser[3]);
548 }
549 if (timeDrift->GetHistVdriftLaserC(1)){
550 grLaser[4]=MakeGraphFilter0(timeDrift->GetHistVdriftLaserC(1),0,2,5);
551 grLaser[4]->SetName("GRAPH_MEAN_DRIFT_LASER_ALL_C");
552 vdriftArray->AddLast(grLaser[4]);
553 }
554 if (timeDrift->GetHistVdriftLaserC(2)){
555 grLaser[5]=MakeGraphFilter0(timeDrift->GetHistVdriftLaserC(2),0,2,5);
556 grLaser[5]->SetName("GRAPH_MEAN_GLOBALYGRADIENT_LASER_ALL_C");
557 vdriftArray->AddLast(grLaser[5]);
558 }
559 for (Int_t i=0; i<6;i++){
560 if (grLaser[i]) {
561 SetDefaultGraphDrift(grLaser[i], 1,(i+20));
562 grLaser[i]->GetYaxis()->SetTitle("Laser Correction");
563 }
564 }
565}
566
567
568TGraphErrors * AliTPCPreprocessorOffline::MakeGraphFilter0(THnSparse *hisN, Int_t itime, Int_t ival, Int_t minEntries, Double_t offset){
569 //
570 // Make graph with mean values and rms
571 //
572 hisN->GetAxis(itime)->SetRange(0,100000000);
573 hisN->GetAxis(ival)->SetRange(0,100000000);
574 TH1 * hisT = hisN->Projection(itime);
575 TH1 * hisV = hisN->Projection(ival);
576 //
577 Int_t firstBinA = hisT->FindFirstBinAbove(2);
578 Int_t lastBinA = hisT->FindLastBinAbove(2);
579 Int_t firstBinV = hisV->FindFirstBinAbove(0);
580 Int_t lastBinV = hisV->FindLastBinAbove(0);
581 hisN->GetAxis(itime)->SetRange(firstBinA,lastBinA);
582 hisN->GetAxis(ival)->SetRange(firstBinV,lastBinV);
583 Int_t entries=0;
68d461b2 584 for (Int_t ibin=firstBinA; ibin<=lastBinA; ibin++){
da268e11 585 Double_t cont = hisT->GetBinContent(ibin);
586 if (cont<minEntries) continue;
587 entries++;
588 }
589 TVectorD vecTime(entries);
590 TVectorD vecMean0(entries);
591 TVectorD vecRMS0(entries);
592 TVectorD vecMean1(entries);
593 TVectorD vecRMS1(entries);
594 entries=0;
68d461b2 595 for (Int_t ibin=firstBinA; ibin<=lastBinA; ibin++){
da268e11 596 Double_t cont = hisT->GetBinContent(ibin);
597 if (cont<minEntries) continue;
68d461b2 598 //hisN->GetAxis(itime)->SetRange(ibin-1,ibin+1);
599 Int_t minBin = ibin-1;
600 Int_t maxBin = ibin+1;
601 if(minBin <= 0) minBin = 1;
602 if(maxBin >= hisN->GetAxis(itime)->GetNbins()) maxBin = hisN->GetAxis(itime)->GetNbins()-1;
603 hisN->GetAxis(itime)->SetRange(minBin,maxBin);
604
da268e11 605 Double_t time = hisT->GetBinCenter(ibin);
606 TH1 * his = hisN->Projection(ival);
607 Double_t nentries0= his->GetBinContent(his->FindBin(0));
608 if (cont-nentries0<minEntries) continue;
609 //
610 his->SetBinContent(his->FindBin(0),0);
611 vecTime[entries]=time;
612 vecMean0[entries]=his->GetMean()+offset;
613 vecMean1[entries]=his->GetMeanError();
614 vecRMS0[entries] =his->GetRMS();
615 vecRMS1[entries] =his->GetRMSError();
616 delete his;
617 entries++;
68d461b2 618 }
da268e11 619 delete hisT;
620 delete hisV;
621 TGraphErrors * graph = new TGraphErrors(entries,vecTime.GetMatrixArray(), vecMean0.GetMatrixArray(), 0, vecMean1.GetMatrixArray());
622 return graph;
623}
624
625
626
627
628
629
630
631
632void AliTPCPreprocessorOffline::SetDefaultGraphDrift(TGraph *graph, Int_t color, Int_t style){
633 //
40120adc 634 // Set default style for QA views
da268e11 635 //
636 graph->GetXaxis()->SetTimeDisplay(kTRUE);
637 graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
638 graph->SetMaximum( 0.025);
639 graph->SetMinimum(-0.025);
640 graph->GetXaxis()->SetTitle("Time");
641 graph->GetYaxis()->SetTitle("v_{dcorr}");
642 //
643 graph->GetYaxis()->SetLabelSize(0.03);
644 graph->GetXaxis()->SetLabelSize(0.03);
645 //
646 graph->GetXaxis()->SetNdivisions(10,5,0);
647 graph->GetYaxis()->SetNdivisions(10,5,0);
648 //
649 graph->GetXaxis()->SetLabelOffset(0.02);
650 graph->GetYaxis()->SetLabelOffset(0.005);
651 //
652 graph->GetXaxis()->SetTitleOffset(1.3);
653 graph->GetYaxis()->SetTitleOffset(1.2);
654 //
655 graph->SetMarkerColor(color);
656 graph->SetLineColor(color);
657 graph->SetMarkerStyle(style);
658}
659
660void AliTPCPreprocessorOffline::SetPadStyle(TPad *pad, Float_t mx0, Float_t mx1, Float_t my0, Float_t my1){
40120adc 661 //
662 // Set default pad style for QA
663 //
da268e11 664 pad->SetTicks(1,1);
665 pad->SetMargin(mx0,mx1,my0,my1);
666}
667
668
68d461b2 669void AliTPCPreprocessorOffline::MakeDefaultPlots(TObjArray * const arr, TObjArray * /*picArray*/){
da268e11 670 //
40120adc 671 // 0. make a default QA plots
672 // 1. Store them in the array
da268e11 673 //
674 //
da268e11 675 Float_t mx0=0.12, mx1=0.1, my0=0.15, my1=0.1;
676 //
677 TGraphErrors* laserA =(TGraphErrors*)arr->FindObject("GRAPH_MEAN_DRIFT_LASER_ALL_A");
678 TGraphErrors* laserC =(TGraphErrors*)arr->FindObject("GRAPH_MEAN_DRIFT_LASER_ALL_C");
679 TGraphErrors* cosmic =(TGraphErrors*)arr->FindObject("TGRAPHERRORS_MEAN_VDRIFT_COSMICS_ALL");
680 TGraphErrors* cross =(TGraphErrors*)arr->FindObject("TGRAPHERRORS_VDRIFT_CROSS_ALL");
681 TGraphErrors* itstpcP =(TGraphErrors*)arr->FindObject("ALIGN_ITSP_TPC_DRIFTVD");
682 TGraphErrors* itstpcM =(TGraphErrors*)arr->FindObject("ALIGN_ITSM_TPC_DRIFTVD");
683 TGraphErrors* itstpcB =(TGraphErrors*)arr->FindObject("ALIGN_ITSB_TPC_DRIFTVD");
684 //
685 if (laserA) SetDefaultGraphDrift(laserA,2,25);
686 if (laserC) SetDefaultGraphDrift(laserC,4,26);
687 if (cosmic) SetDefaultGraphDrift(cosmic,3,27);
688 if (cross) SetDefaultGraphDrift(cross,4,28);
689 if (itstpcP) SetDefaultGraphDrift(itstpcP,2,29);
690 if (itstpcM) SetDefaultGraphDrift(itstpcM,4,30);
691 if (itstpcB) SetDefaultGraphDrift(itstpcB,1,31);
692 //
693 //
694 TPad *pad=0;
695 //
696 // Laser-Laser
697 //
698 if (laserA&&laserC){
699 pad = new TCanvas("TPCLaserVDrift","TPCLaserVDrift");
700 laserA->Draw("alp");
701 SetPadStyle(pad,mx0,mx1,my0,my1);
702 laserA->Draw("apl");
703 laserC->Draw("p");
704 TLegend *legend = new TLegend(mx0+0.01,1-my1-0.2, 0.5, 1-my1-0.01, "Drift velocity correction");
705 legend->AddEntry(laserA,"Laser A side");
706 legend->AddEntry(laserC,"Laser C side");
707 legend->Draw();
68d461b2 708 //picArray->AddLast(pad);
da268e11 709 }
710
831e26ce 711 if (itstpcP&&itstpcM&&itstpcB){
da268e11 712 pad = new TCanvas("ITSTPC","ITSTPC");
713 itstpcP->Draw("alp");
714 SetPadStyle(pad,mx0,mx1,my0,my1);
715 itstpcP->Draw("alp");
716 gPad->Clear();
717 itstpcM->Draw("apl");
718 itstpcP->Draw("p");
719 itstpcB->Draw("p");
720 TLegend *legend = new TLegend(mx0+0.01,1-my1-0.2, 0.5, 1-my1-0.01, "Drift velocity correction");
721 legend->AddEntry(itstpcP,"ITS-TPC smooth plus");
722 legend->AddEntry(itstpcM,"ITS-TPC smooth minus");
723 legend->AddEntry(itstpcB,"ITS-TPC smooth ");
724 legend->Draw();
68d461b2 725 //picArray->AddLast(pad);
da268e11 726 }
727
831e26ce 728 if (itstpcB&&laserA&&itstpcP&&itstpcM){
da268e11 729 pad = new TCanvas("ITSTPC_LASER","ITSTPC_LASER");
730 SetPadStyle(pad,mx0,mx1,my0,my1);
731 laserA->Draw("alp");
732 itstpcP->Draw("p");
733 itstpcM->Draw("p");
734 itstpcB->Draw("p");
735 TLegend *legend = new TLegend(mx0+0.01,1-my1-0.2, 0.5, 1-my1-0.01, "Drift velocity correction");
736 legend->AddEntry(laserA,"TPC laser");
737 legend->AddEntry(itstpcP,"ITS-TPC smooth plus");
738 legend->AddEntry(itstpcM,"ITS-TPC smooth minus");
739 legend->AddEntry(itstpcB,"ITS-TPC smooth ");
740 legend->Draw();
68d461b2 741 //picArray->AddLast(pad);
da268e11 742 }
743
744 if (itstpcP&&cross){
745 pad = new TCanvas("ITSTPC_CROSS","ITSTPC_CROSS");
746 SetPadStyle(pad,mx0,mx1,my0,my1);
747 itstpcP->Draw("alp");
748 pad->Clear();
749 cross->Draw("ap");
750 itstpcP->Draw("p");
751 //
752 TLegend *legend = new TLegend(mx0+0.01,1-my1-0.2, 0.5, 1-my1-0.01, "Drift velocity correction");
753
754 legend->AddEntry(cross,"TPC cross tracks");
755 legend->AddEntry(itstpcB,"ITS-TPC smooth");
756 legend->Draw();
68d461b2 757 //picArray->AddLast(pad);
da268e11 758 }
759 if (itstpcP&&cosmic){
760 pad = new TCanvas("ITSTPC_COSMIC","ITSTPC_COSMIC");
761 SetPadStyle(pad,mx0,mx1,my0,my1);
762 itstpcP->Draw("alp");
763 pad->Clear();
764 cosmic->Draw("ap");
765 itstpcP->Draw("p");
766 //
767 TLegend *legend = new TLegend(mx0+0.01,1-my1-0.2, 0.5, 1-my1-0.01, "Drift velocity correction");
768
769 legend->AddEntry(cosmic,"TPC cross tracks0 up-down");
770 legend->AddEntry(itstpcB,"ITS-TPC smooth");
771 legend->Draw();
68d461b2 772 //picArray->AddLast(pad);
da268e11 773 }
774}
775
776
777
778
40120adc 779void AliTPCPreprocessorOffline::CalibTimeGain(const Char_t* fileName, Int_t startRunNumber, Int_t endRunNumber, TString pocdbStorage){
da268e11 780 //
781 // Update OCDB gain
782 //
68d461b2 783 if (pocdbStorage.Length()==0) pocdbStorage+="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
784
785 //
786 // 1. Read gain values
787 //
da268e11 788 ReadGainGlobal(fileName);
68d461b2 789
790 //
791 // 2. Extract calibration values
792 //
da268e11 793 AnalyzeGain(startRunNumber,endRunNumber, 1000,1.43);
391ffdb2 794 AnalyzeAttachment(startRunNumber,endRunNumber);
da268e11 795
68d461b2 796 //
797 // 3. Make control plots
798 //
799 MakeQAPlot(1.43);
da268e11 800
68d461b2 801 //
802 // 4. validate OCDB entries
803 //
804 if(fSwitchOnValidation==kTRUE && ValidateTimeGain()==kFALSE) {
805 Printf("TPC time gain OCDB parameters out of range!");
806 return;
807 }
da268e11 808
68d461b2 809 //
810 // 5. Update OCDB
811 //
812 UpdateOCDBGain( startRunNumber, endRunNumber, pocdbStorage.Data());
813}
da268e11 814
40120adc 815void AliTPCPreprocessorOffline::ReadGainGlobal(const Char_t* fileName){
da268e11 816 //
817 // read calibration entries from file
818 //
819 TFile fcalib(fileName);
820 TObjArray * array = (TObjArray*)fcalib.Get("TPCCalib");
821 if (array){
822 fGainMIP = ( AliTPCcalibTimeGain *)array->FindObject("calibTimeGain");
823 fGainCosmic = ( AliTPCcalibTimeGain *)array->FindObject("calibTimeGainCosmic");
824 }else{
825 fGainMIP = ( AliTPCcalibTimeGain *)fcalib.Get("calibTimeGain");
826 fGainCosmic = ( AliTPCcalibTimeGain *)fcalib.Get("calibTimeGainCosmic");
827 }
828 TH1 * hisT=0;
829 Int_t firstBinA =0, lastBinA=0;
830
831 if (fGainCosmic){
832 hisT= fGainCosmic->GetHistGainTime()->Projection(1);
833 firstBinA = hisT->FindFirstBinAbove(2);
834 lastBinA = hisT->FindLastBinAbove(2);
835 fGainCosmic->GetHistGainTime()->GetAxis(1)->SetRange(firstBinA,lastBinA);
836 delete hisT;
837 }
838
839 if (fGainMIP){
840 hisT= fGainMIP->GetHistGainTime()->Projection(1);
841 firstBinA = hisT->FindFirstBinAbove(2);
842 lastBinA = hisT->FindLastBinAbove(2);
843 fGainMIP->GetHistGainTime()->GetAxis(1)->SetRange(firstBinA,lastBinA);
844 delete hisT;
845 }
846
847}
848
849
850
851Bool_t AliTPCPreprocessorOffline::AnalyzeGain(Int_t startRunNumber, Int_t endRunNumber, Int_t minEntriesGaussFit, Float_t FPtoMIPratio){
852 //
40120adc 853 // Analyze gain - produce the calibration graphs
da268e11 854 //
68d461b2 855
da268e11 856 // 1.) try to create MIP spline
68d461b2 857 if (fGainMIP)
858 {
859 fGainMIP->GetHistGainTime()->GetAxis(5)->SetRangeUser(startRunNumber, endRunNumber);
860 fGainMIP->GetHistGainTime()->GetAxis(2)->SetRangeUser(1.51,2.49); // only beam data
861 fGainMIP->GetHistGainTime()->GetAxis(4)->SetRangeUser(0.39,0.51); // only MIP pions
862 //
863 fGraphMIP = AliTPCcalibBase::FitSlices(fGainMIP->GetHistGainTime(),0,1,minEntriesGaussFit,10,0.1,0.7);
864 if (fGraphMIP->GetN()==0) fGraphMIP = 0x0;
865 if (fGraphMIP) fFitMIP = AliTPCcalibTimeGain::MakeSplineFit(fGraphMIP);
866 if (fGraphMIP) fGraphMIP->SetName("TGRAPHERRORS_MEAN_GAIN_BEAM_ALL");// set proper names according to naming convention
867 fGainArray->AddAt(fFitMIP,0);
868 }
da268e11 869
870 // 2.) try to create Cosmic spline
68d461b2 871 if (fGainCosmic)
872 {
6c8b3862 873 fGainCosmic->GetHistGainTime()->GetAxis(2)->SetRangeUser(0.51,1.49); // only cosmics
874 fGainCosmic->GetHistGainTime()->GetAxis(4)->SetRangeUser(20,100); // only Fermi-Plateau muons
875 //
876 fGraphCosmic = AliTPCcalibBase::FitSlices(fGainCosmic->GetHistGainTime(),0,1,minEntriesGaussFit,10);
877 if (fGraphCosmic->GetN()==0) fGraphCosmic = 0x0;
878 //
879 if (fGraphCosmic) {
880 for(Int_t i=0; i < fGraphCosmic->GetN(); i++) {
881 fGraphCosmic->GetY()[i] /= FPtoMIPratio;
882 fGraphCosmic->GetEY()[i] /= FPtoMIPratio;
883 }
da268e11 884 }
6c8b3862 885 //
886 if (fGraphCosmic) fFitCosmic = AliTPCcalibTimeGain::MakeSplineFit(fGraphCosmic);
887 if (fGraphCosmic) fGraphCosmic->SetName("TGRAPHERRORS_MEAN_GAIN_COSMIC_ALL"); // set proper names according to naming convention
888 fGainArray->AddAt(fFitCosmic,1);
da268e11 889 }
da268e11 890 // with naming convention and backward compatibility
891 fGainArray->AddAt(fGraphMIP,2);
892 fGainArray->AddAt(fGraphCosmic,3);
893 cout << "fGraphCosmic: " << fGraphCosmic << " fGraphMIP " << fGraphMIP << endl;
894 return kTRUE;
895
896}
897
391ffdb2 898Bool_t AliTPCPreprocessorOffline::AnalyzeAttachment(Int_t startRunNumber, Int_t endRunNumber, Int_t minEntriesFit) {
899 //
900 // determine slope as a function of mean driftlength
901 //
68d461b2 902 if(!fGainMIP) return kFALSE;
903
391ffdb2 904 fGainMIP->GetHistGainTime()->GetAxis(5)->SetRangeUser(startRunNumber, endRunNumber);
905 //
906 fGainMIP->GetHistGainTime()->GetAxis(2)->SetRangeUser(1.51,2.49); // only beam data
907 fGainMIP->GetHistGainTime()->GetAxis(4)->SetRangeUser(0.39,0.51); // only MIP pions
908 //
68d461b2 909 fGainMIP->GetHistGainTime()->GetAxis(3)->SetRangeUser(125,250);// only full tracking region (driftlength)
910 fGainMIP->GetHistGainTime()->GetAxis(0)->SetRangeUser(1.5,3.5);// only full tracking region (driftlength)
911 //
391ffdb2 912 TH3D * hist = fGainMIP->GetHistGainTime()->Projection(1, 0, 3);
913 //
914 Double_t *xvec = new Double_t[hist->GetNbinsX()];
915 Double_t *yvec = new Double_t[hist->GetNbinsX()];
916 Double_t *xerr = new Double_t[hist->GetNbinsX()];
917 Double_t *yerr = new Double_t[hist->GetNbinsX()];
918 Int_t counter = 0;
919 //
920 for(Int_t i=1; i < hist->GetNbinsX(); i++) {
921 Int_t nsum=0;
922 Int_t imin = i;
923 Int_t imax = i;
68d461b2 924 for (Int_t idelta=0; idelta<5; idelta++){
391ffdb2 925 //
926 imin = TMath::Max(i-idelta,1);
927 imax = TMath::Min(i+idelta,hist->GetNbinsX());
928 nsum = TMath::Nint(hist->Integral(imin,imax,1,hist->GetNbinsY()-1,1,hist->GetNbinsZ()-1));
929 //if (nsum==0) break;
930 if (nsum>minEntriesFit) break;
931 }
932 if (nsum<minEntriesFit) continue;
933 //
68d461b2 934 fGainMIP->GetHistGainTime()->GetAxis(1)->SetRangeUser(hist->GetXaxis()->GetBinCenter(imin-1),hist->GetXaxis()->GetBinCenter(imax+1)); // define time range
935 TH2D * histZdep = fGainMIP->GetHistGainTime()->Projection(0,3);
936 TObjArray arr;
937 histZdep->FitSlicesY(0,0,-1,0,"QNR",&arr);
938 TH1D * driftDep = (TH1D*)arr.At(1);
939 delete histZdep;
940 //TGraphErrors * driftDep = AliTPCcalibBase::FitSlices(fGainMIP->GetHistGainTime(),0,3,100,1,0.,1);
941 /*if (driftDep->GetN() < 4) {
391ffdb2 942 delete driftDep;
68d461b2 943 continue;
944 }*/
391ffdb2 945 //
68d461b2 946 //TObjArray arr;
391ffdb2 947 //
68d461b2 948 TF1 pol1("polynom1","pol1",125,240);
391ffdb2 949 //driftDep->Fit(&pol1,"QNRROB=0.8");
950 driftDep->Fit(&pol1,"QNR");
68d461b2 951 xvec[counter] = 0.5*(hist->GetXaxis()->GetBinCenter(imin-1)+hist->GetXaxis()->GetBinCenter(imax+1));
391ffdb2 952 yvec[counter] = pol1.GetParameter(1)/pol1.GetParameter(0);
68d461b2 953 xerr[counter] = hist->GetXaxis()->GetBinCenter(imax+1)-hist->GetXaxis()->GetBinCenter(imin-1);
391ffdb2 954 yerr[counter] = pol1.GetParError(1)/pol1.GetParameter(0);
955 counter++;
956 //
68d461b2 957 //delete driftDep;
391ffdb2 958 }
959 //
960 fGraphAttachmentMIP = new TGraphErrors(counter, xvec, yvec, xerr, yerr);
961 if (fGraphAttachmentMIP) fGraphAttachmentMIP->SetName("TGRAPHERRORS_MEAN_ATTACHMENT_BEAM_ALL");// set proper names according to naming convention
962 fGainArray->AddLast(fGraphAttachmentMIP);
963 //
964 delete [] xvec;
965 delete [] yvec;
966 delete [] xerr;
967 delete [] yerr;
968 delete hist;
969 //
970 if (counter < 1) return kFALSE;
971 return kTRUE;
391ffdb2 972
68d461b2 973}
391ffdb2 974
da268e11 975
976void AliTPCPreprocessorOffline::UpdateOCDBGain(Int_t startRunNumber, Int_t endRunNumber, const Char_t *storagePath){
977 //
978 // Update OCDB entry
979 //
980 AliCDBMetaData *metaData= new AliCDBMetaData();
981 metaData->SetObjectClassName("TObjArray");
982 metaData->SetResponsible("Alexander Kalweit");
983 metaData->SetBeamPeriod(1);
984 metaData->SetAliRootVersion("05-24-00"); //root version
985 metaData->SetComment("Calibration of the time dependence of the gain due to pressure and temperature changes.");
986 AliCDBId id1("TPC/Calib/TimeGain", startRunNumber, endRunNumber);
987 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage(storagePath);
988 gStorage->Put(fGainArray, id1, metaData);
989}
990
991void AliTPCPreprocessorOffline::MakeQAPlot(Float_t FPtoMIPratio) {
992 //
993 // Make QA plot to visualize results
994 //
995 //
996 //
997 if (fGraphCosmic) {
998 TCanvas * canvasCosmic = new TCanvas("gain Cosmic", "time dependent gain QA histogram cosmic");
999 canvasCosmic->cd();
1000 TH2D * gainHistoCosmic = fGainCosmic->GetHistGainTime()->Projection(0,1);
1001 gainHistoCosmic->SetDirectory(0);
1002 gainHistoCosmic->SetName("GainHistoCosmic");
1003 gainHistoCosmic->GetXaxis()->SetTimeDisplay(kTRUE);
1004 gainHistoCosmic->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
1005 gainHistoCosmic->Draw("colz");
1006 fGraphCosmic->SetMarkerStyle(25);
1007 fGraphCosmic->Draw("lp");
1008 fGraphCosmic->SetMarkerStyle(25);
1009 TGraph * grfFitCosmic = fFitCosmic->MakeGraph(fGraphCosmic->GetX()[0],fGraphCosmic->GetX()[fGraphCosmic->GetN()-1],50000,0);
1010 if (grfFitCosmic) {
1011 for(Int_t i=0; i < grfFitCosmic->GetN(); i++) {
1012 grfFitCosmic->GetY()[i] *= FPtoMIPratio;
1013 }
1014 for(Int_t i=0; i < fGraphCosmic->GetN(); i++) {
1015 fGraphCosmic->GetY()[i] *= FPtoMIPratio;
1016 }
831e26ce 1017
1018 fGraphCosmic->Draw("lp");
1019 grfFitCosmic->SetLineColor(2);
1020 grfFitCosmic->Draw("lu");
1021 fGainArray->AddLast(gainHistoCosmic);
1022 //fGainArray->AddLast(canvasCosmic->Clone());
1023 delete canvasCosmic;
da268e11 1024 }
da268e11 1025 }
1026 if (fFitMIP) {
1027 TCanvas * canvasMIP = new TCanvas("gain MIP", "time dependent gain QA histogram MIP");
1028 canvasMIP->cd();
1029 TH2D * gainHistoMIP = fGainMIP->GetHistGainTime()->Projection(0,1);
1030 gainHistoMIP->SetName("GainHistoCosmic");
1031 gainHistoMIP->SetDirectory(0);
1032 gainHistoMIP->GetXaxis()->SetTimeDisplay(kTRUE);
1033 gainHistoMIP->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
1034 gainHistoMIP->Draw("colz");
1035 fGraphMIP->SetMarkerStyle(25);
1036 fGraphMIP->Draw("lp");
1037 TGraph * grfFitMIP = fFitMIP->MakeGraph(fGraphMIP->GetX()[0],fGraphMIP->GetX()[fGraphMIP->GetN()-1],50000,0);
1038 grfFitMIP->SetLineColor(2);
1039 grfFitMIP->Draw("lu");
1040 fGainArray->AddLast(gainHistoMIP);
68d461b2 1041 //fGainArray->AddLast(canvasMIP->Clone());
da268e11 1042 delete canvasMIP;
1043 }
1044}
1045
1046
1047