1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 This class provides the calibration of the time dependence of the TPC gain due to pressure and temperature changes etc.
21 //0. Libraries to load
22 gSystem->Load("libANALYSIS");
23 gSystem->Load("libSTAT");
24 gSystem->Load("libTPCcalib");
27 //1. Do calibration ...
32 //2. Visualize results
34 TFile fcalib("CalibObjects.root");
35 TObjArray * array = (TObjArray*)fcalib.Get("TPCCalib");
36 AliTPCcalibTimeGain * gain = ( AliTPCcalibTimeGain *)array->FindObject("calibTimeGain");
37 TGraphErrors * gr = gain->GetGraphGainVsTime(0,1000)
39 // gain->GetHistGainTime()->GetAxis(1)->SetRangeUser(1213.8e6,1214.3e6)
40 TH2D * GainTime = gain->GetHistGainTime()->Projection(0,1)
41 GainTime->GetXaxis()->SetTimeDisplay(kTRUE)
42 GainTime->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}")
43 GainTime->Draw("colz")
46 // MakeSlineFit example
48 AliSplineFit *fit = AliTPCcalibTimeGain::MakeSplineFit(gr)
50 TGraph * grfit = fit.MakeGraph(gr->GetX()[0],gr->GetX()[gr->GetN()-1],50000,0);
52 gr->SetMarkerStyle(25);
54 grfit->SetLineColor(2);
58 // QA - dE/dx resoultion as a function of time
61 TGraph * grSigma = AliTPCcalibBase::FitSlicesSigma(gain->GetHistGainTime(),0,1,1800,5)
63 TCanvas *c1 = new TCanvas("c1","transparent pad",200,10,700,500);
64 TPad *pad1 = new TPad("pad1","",0,0,1,1);
65 TPad *pad2 = new TPad("pad2","",0,0,1,1);
66 pad2->SetFillStyle(4000); //will be transparent
70 GainTime->Draw("colz")
76 Double_t ymin = -0.04;
78 Double_t dy = (ymax-ymin)/0.8;
79 Double_t xmin = GainTime->GetXaxis()->GetXmin()
80 Double_t xmax = GainTime->GetXaxis()->GetXmax()
81 Double_t dx = (xmax-xmin)/0.8; //10 per cent margins left and right
82 pad2->Range(xmin-0.1*dx,ymin-0.1*dy,xmax+0.1*dx,ymax+0.1*dy);
85 grSigma->SetLineColor(2);
86 grSigma->SetLineWidth(2);
88 TGaxis *axis = new TGaxis(xmax,ymin,xmax,ymax,ymin,ymax,50510,"+L");
89 axis->SetLabelColor(kRed);
90 axis->SetTitle("dE/dx resolution #sigma_{dE/dx}");
93 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
95 ----> make Attachment study
97 TFile fcalib("CalibObjects40366b.root");
98 TObjArray * array = (TObjArray*)fcalib.Get("TPCCalib");
99 AliTPCcalibTimeGain * gain = ( AliTPCcalibTimeGain *)array->FindObject("calibTimeGain");
100 TGraphErrors * grAttach = gain->GetGraphAttachment(2000,4)
102 TCanvas *c1 = new TCanvas("c1","transparent pad",200,10,700,500);
103 TPad *pad1 = new TPad("pad1","",0,0,1,1);
104 TPad *pad2 = new TPad("pad2","",0,0,1,1);
105 pad2->SetFillStyle(4000); //will be transparent
109 gain->GetHistGainTime()->GetAxis(1)->SetRangeUser(1213.8e6,1214.3e6)
110 TH2D * GainTime = gain->GetHistGainTime()->Projection(0,1)
111 GainTime->GetXaxis()->SetTimeDisplay(kTRUE)
112 GainTime->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}")
113 GainTime->Draw("colz")
117 Double_t ymin = -0.001;
118 Double_t ymax = 0.001;
119 Double_t dy = (ymax-ymin)/0.8;
120 Double_t xmin = GainTime->GetXaxis()->GetXmin()
121 Double_t xmax = GainTime->GetXaxis()->GetXmax()
122 Double_t dx = (xmax-xmin)/0.8; //10 per cent margins left and right
123 pad2->Range(xmin-0.1*dx,ymin-0.1*dy,xmax+0.1*dx,ymax+0.1*dy);
126 grAttach->SetLineColor(2);
127 grAttach->SetLineWidth(2);
129 TGaxis *axis = new TGaxis(xmax,ymin,xmax,ymax,ymin,ymax,50510,"+L");
130 axis->SetLabelColor(kRed);
131 axis->SetTitle("attachment coefficient b");
138 #include "Riostream.h"
144 #include "THnSparse.h"
145 #include "TGraphErrors.h"
151 #include "TVectorD.h"
152 #include "TProfile.h"
153 #include "TGraphErrors.h"
156 #include "AliTPCclusterMI.h"
157 #include "AliTPCseed.h"
158 #include "AliESDVertex.h"
159 //#include "AliESDEvent.h"
160 #include "AliESDfriend.h"
161 //#include "AliESDInputHandler.h"
162 #include "AliAnalysisManager.h"
164 #include "AliVEvent.h"
165 #include "AliVTrack.h"
166 #include "AliVfriendEvent.h"
167 #include "AliVfriendTrack.h"
169 #include "AliTracker.h"
171 #include "AliTPCCalROC.h"
172 #include "AliESDv0.h"
176 #include "AliTPCcalibTimeGain.h"
178 #include "TTreeStream.h"
179 #include "AliTPCTracklet.h"
180 #include "TTimeStamp.h"
181 #include "AliTPCcalibDB.h"
182 #include "AliTPCcalibLaser.h"
183 #include "AliDCSSensorArray.h"
184 #include "AliDCSSensor.h"
186 ClassImp(AliTPCcalibTimeGain)
188 Double_t AliTPCcalibTimeGain::fgMergeEntriesCut=10000000.;
190 AliTPCcalibTimeGain::AliTPCcalibTimeGain()
195 fIntegrationTimeDeDx(0),
199 fCutRequireITSrefit(0),
211 fUseCookAnalytical(0),
213 fLowMemoryConsumption(0)
216 // Default constructor
218 AliDebug(5,"Default Constructor");
222 AliTPCcalibTimeGain::AliTPCcalibTimeGain(const Text_t *name, const Text_t *title, UInt_t StartTime, UInt_t EndTime, Int_t deltaIntegrationTimeGain)
227 fIntegrationTimeDeDx(0),
231 fCutRequireITSrefit(0),
243 fUseCookAnalytical(0),
245 fLowMemoryConsumption(0)
248 // No default constructor
253 AliDebug(5,"Non Default Constructor");
255 fIntegrationTimeDeDx = deltaIntegrationTimeGain;
257 Double_t deltaTime = EndTime - StartTime;
260 // main histogram for time dependence: dE/dx, time, type (1-muon cosmic,2-pion beam data, 3&4 - proton points at higher dE/dx), meanDriftlength, momenta (only filled if enough space is available), run number, eta
261 Int_t timeBins = TMath::Nint(deltaTime/deltaIntegrationTimeGain);
262 Int_t binsGainTime[7] = {150, static_cast<Int_t>(timeBins), 4, 25, 200, 10000000, 20};
263 Double_t xminGainTime[7] = {0.5, static_cast<Double_t>(StartTime), 0.5, 0, 0.1, -0.5, -1};
264 Double_t xmaxGainTime[7] = { 8, static_cast<Double_t>(EndTime), 4.5, 250, 50, 9999999.5, 1};
265 fHistGainTime = new THnSparseF("HistGainTime","dEdx time dep.;dEdx,time,type,driftlength,momenta,run number, eta;dEdx",7,binsGainTime,xminGainTime,xmaxGainTime);
266 BinLogX(fHistGainTime, 4);
268 fHistDeDxTotal = new TH2F("DeDx","dEdx; momentum p (GeV); TPC signal (a.u.)",250,0.01,100.,1000,0.,8);
269 BinLogX(fHistDeDxTotal);
272 // default track selection cuts
275 fCutRequireITSrefit = kFALSE;
279 // default values for MIP window selection
280 fMinMomentumMIP = 0.4;
281 fMaxMomentumMIP = 0.6;
282 fAlephParameters[0] = 0.07657; // the following parameters work for most of the periods and are therefore default
283 fAlephParameters[1] = 10.6654; // but they can be overwritten in the train setup of cpass0
284 fAlephParameters[2] = 2.51466e-14;
285 fAlephParameters[3] = 2.05379;
286 fAlephParameters[4] = 1.84288;
288 // default values for dE/dx
293 fUseShapeNorm = kTRUE;
294 fUsePosNorm = kFALSE;
295 fUsePadNorm = kFALSE;
296 fUseCookAnalytical = kFALSE;
299 fLowMemoryConsumption = kTRUE;
306 AliTPCcalibTimeGain::~AliTPCcalibTimeGain(){
310 delete fHistGainTime;
312 delete fHistDeDxTotal;
316 void AliTPCcalibTimeGain::Process(AliVEvent *event) {
320 //Printf("AliTPCcalibTimeGain::Process(event)...");
323 Printf("ERROR AliTPCcalibTimeGain::Process(): event not available");
327 AliVfriendEvent *friendEvent=event->FindFriend();
330 Printf("ERROR AliTPCcalibTimeGain::Process(): friendEvent not available");
333 //Printf("friendEvent->TestSkipBit() = %d",friendEvent->TestSkipBit() );
334 if (friendEvent->TestSkipBit()) {
338 if (fIsCosmic) { // this should be removed at some point based on trigger mask !?
339 ProcessCosmicEvent(event);
341 ProcessBeamEvent(event);
347 void AliTPCcalibTimeGain::ProcessCosmicEvent(AliVEvent *event) {
349 // Process in case of cosmic event
351 //Printf("AliTPCcalibTimeGain::ProcessCosmicEvent(event)...");
353 AliVfriendEvent *friendEvent=event->FindFriend();
355 Printf("ERROR AliTPCcalibTimeGain::ProcessCosmicEvent(): ESDfriend not available");
359 UInt_t time = event->GetTimeStamp();
360 Int_t nFriendTracks = friendEvent->GetNumberOfTracks();
361 Int_t runNumber = event->GetRunNumber();
365 for (Int_t i=0;i<nFriendTracks;++i) {
367 AliVTrack *track = event->GetVTrack(i);
368 if (!track) continue;
369 const AliVfriendTrack *friendTrack = friendEvent->GetTrack(i);
370 if (!friendTrack) continue;
371 const AliExternalTrackParam * trackIn = track->GetInnerParam();
372 const AliExternalTrackParam * trackOut = friendTrack->GetTPCOut();
373 if (!trackIn) continue;
374 if (!trackOut) continue;
376 // calculate necessary track parameters
377 Double_t meanP = trackIn->GetP();
378 Double_t meanDrift = 250 - 0.5*TMath::Abs(trackIn->GetZ() + trackOut->GetZ());
379 Int_t nclsDeDx = track->GetTPCNcls();
381 // exclude tracks which do not look like primaries or are simply too short or on wrong sectors
382 if (nclsDeDx < 60) continue;
383 if (TMath::Abs(trackIn->GetTgl()) > 1) continue;
384 if (TMath::Abs(trackIn->GetSnp()) > 0.6) continue;
387 TObject *calibObject;
388 AliTPCseed *seed = 0;
389 for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
390 if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
394 Double_t tpcSignal = GetTPCdEdx(seed);
395 if (nclsDeDx > 100) fHistDeDxTotal->Fill(meanP, tpcSignal);
397 if (fLowMemoryConsumption) {
398 if (meanP < 20) continue;
399 meanP = 30; // set all momenta to one in order to save memory
401 //dE/dx, time, type (1-muon cosmic,2-pion beam data), momenta
402 Double_t vec[6] = {tpcSignal,static_cast<Double_t>(time),1,meanDrift,meanP,static_cast<Double_t>(runNumber)};
403 fHistGainTime->Fill(vec);
412 void AliTPCcalibTimeGain::ProcessBeamEvent(AliVEvent *event) {
414 // Process in case of beam event
416 //Printf("AliTPCcalibTimeGain::ProcessBeamEvent(event)...");
418 AliVfriendEvent *friendEvent=event->FindFriend();
420 Printf("ERROR AliTPCcalibTimeGain::ProcessBeamEvent(): ESDfriend not available");
424 UInt_t time = event->GetTimeStamp();
425 if (!time) Printf("ERROR: no time stamp available!");
426 Int_t nFriendTracks = friendEvent->GetNumberOfTracks();
427 Int_t runNumber = event->GetRunNumber();
431 for (Int_t i=0;i<nFriendTracks;++i) { // begin track loop
433 AliVTrack *track = event->GetVTrack(i);
434 if (!track) {Printf("***ERROR*** : track not available"); continue;}
435 const AliVfriendTrack *friendTrack = friendEvent->GetTrack(i);
437 Printf("ERROR ProcessBeamEvent(): friendTrack is not available!");
441 const AliExternalTrackParam * trackIn = track->GetInnerParam();
442 const AliExternalTrackParam * trackOut = friendTrack->GetTPCOut();
443 if (!trackIn) continue;
444 if (!trackOut) continue;
446 // calculate necessary track parameters
447 Double_t meanP = trackIn->GetP();
448 Double_t meanDrift = 250 - 0.5*TMath::Abs(trackIn->GetZ() + trackOut->GetZ());
449 Int_t nCrossedRows = track->GetTPCCrossedRows();
452 // exclude tracks which do not look like primaries or are simply too short or on wrong sectors
453 // fCutCrossRows = 80, fCutEtaWindow = 0.8, fCutRequireITSrefit, fCutMaxDcaXY = 3.5, fCutMaxDcaZ = 25
455 if (nCrossedRows < fCutCrossRows) continue;
456 if (TMath::Abs(trackIn->Eta()) > fCutEtaWindow) continue;
458 UInt_t status = track->GetStatus();
459 if ((status&AliVTrack::kTPCrefit)==0) continue;
460 if ((status&AliVTrack::kITSrefit)==0 && fCutRequireITSrefit) continue; // ITS cluster
462 Float_t dca[2], cov[3];
463 track->GetImpactParameters(dca,cov);
464 if (TMath::Abs(dca[0]) > fCutMaxDcaXY || TMath::Abs(dca[0]) < 0.0000001) continue; // cut in xy
465 if (((status&AliVTrack::kITSrefit) == 1 && TMath::Abs(dca[1]) > 3.) || TMath::Abs(dca[1]) > fCutMaxDcaZ ) continue;
467 Double_t eta = trackIn->Eta();
470 TObject *calibObject;
471 AliTPCseed *seed = 0;
472 for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
473 if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
477 Int_t particleCase = 0;
478 if (meanP < fMaxMomentumMIP && meanP > fMinMomentumMIP) particleCase = 2; // MIP pions
479 if (meanP < 0.57 && meanP > 0.56) particleCase = 3; // protons 1
480 if (meanP < 0.66 && meanP > 0.65) particleCase = 4; // protons 2
482 if (fLowMemoryConsumption && particleCase == 0) continue;
484 Double_t tpcSignal = GetTPCdEdx(seed);
486 // flattens signal in MIP window
488 if (particleCase == 2) {
489 Float_t corrFactor = AliExternalTrackParam::BetheBlochAleph(meanP/0.13957,
494 fAlephParameters[4]);
495 tpcSignal /= corrFactor;
497 //Printf("Fill DeDx histo..");
498 fHistDeDxTotal->Fill(meanP, tpcSignal);
500 //dE/dx, time, type (1-muon cosmic,2-pion beam data, 3&4 protons), momenta, runNumner, eta
501 Double_t vec[7] = {tpcSignal,static_cast<Double_t>(time),static_cast<Double_t>(particleCase),meanDrift,meanP,static_cast<Double_t>(runNumber), eta};
502 //Printf("Fill Gain histo in track loop...");
503 fHistGainTime->Fill(vec);
508 // V0 loop -- in beam events the cosmic part of the histogram is filled with GammaConversions
510 for(Int_t iv0 = 0; iv0 < event->GetNumberOfV0s(); iv0++) {
511 //AliESDv0 * v0 = event->GetV0(iv0);
513 event->GetV0(v0dummy, iv0);
514 AliESDv0 *v0 = &v0dummy;
516 if (!v0) Printf("ERROR AliTPCcalibTimeGain::ProcessBeamEvent(): ESDv0 not available! ");
518 if (!v0->GetOnFlyStatus()) continue;
519 if (v0->GetEffMass(0,0) > 0.02) continue; // select low inv. mass
521 v0->GetXYZ(xyz[0], xyz[1], xyz[2]);
522 if (TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]) < 3 || TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]) > 30) continue;
524 // "loop over daughters"
526 for(Int_t idaughter = 0; idaughter < 2; idaughter++) { // daughter loop
527 Int_t index = idaughter == 0 ? v0->GetPindex() : v0->GetNindex();
528 AliVTrack * trackP = event->GetVTrack(index);
529 if (!trackP) Printf("***ERROR*** trackP not available!");
530 const AliVfriendTrack *friendTrackP = friendEvent->GetTrack(index);
531 if (!friendTrackP) continue;
532 const AliExternalTrackParam * trackPIn = trackP->GetInnerParam();
533 const AliExternalTrackParam * trackPOut = friendTrackP->GetTPCOut();
534 if (!trackPIn) continue;
535 if (!trackPOut) continue;
536 // calculate necessary track parameters
537 Double_t meanP = trackPIn->GetP();
538 Double_t meanDrift = 250 - 0.5*TMath::Abs(trackPIn->GetZ() + trackPOut->GetZ());
539 Int_t nclsDeDx = trackP->GetTPCNcls();
540 // exclude tracks which do not look like primaries or are simply too short or on wrong sectors
541 if (nclsDeDx < 60) continue;
542 if (TMath::Abs(trackPIn->GetTgl()) > 1) continue;
544 TObject *calibObject;
545 AliTPCseed *seed = 0;
546 for (Int_t l=0;(calibObject=friendTrackP->GetCalibObject(l));++l) {
547 if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
550 if (fLowMemoryConsumption) {
551 if (meanP > fMaxMomentumMIP || meanP < fMinMomentumMIP) continue;
552 meanP = 0.45; // set all momenta to one in order to save memory
554 Double_t tpcSignal = GetTPCdEdx(seed);
555 //dE/dx, time, type (1-muon cosmic,2-pion beam data), momenta
556 Double_t vec[6] = {tpcSignal,static_cast<Double_t>(time),1,meanDrift,meanP,static_cast<Double_t>(runNumber)};
557 //Printf("Fill Gain histo in v0 loop...");
558 fHistGainTime->Fill(vec);
567 Float_t AliTPCcalibTimeGain::GetTPCdEdx(AliTPCseed * seed) {
569 // calculate tpc dEdx
573 if (!fUseCookAnalytical) {
574 signal = (1/fMIP)*seed->CookdEdxNorm(fLowerTrunc,fUpperTrunc,fUseMax,0,159,fUseShapeNorm,fUsePosNorm,fUsePadNorm,0);
576 signal = (1/fMIP)*seed->CookdEdxAnalytical(fLowerTrunc,fUpperTrunc,fUseMax);
583 void AliTPCcalibTimeGain::AnalyzeRun(Int_t minEntries) {
585 // Analyze results of calibration
588 fHistGainTime->GetAxis(2)->SetRangeUser(0.51,1.49); // only cosmics
589 fHistGainTime->GetAxis(4)->SetRangeUser(20,100); // only Fermi-Plateau muons
591 fHistGainTime->GetAxis(2)->SetRangeUser(1.51,2.49); // only beam data
592 fHistGainTime->GetAxis(4)->SetRangeUser(0.39,0.51); // only MIP pions
595 fGainVsTime = AliTPCcalibBase::FitSlices(fHistGainTime,0,1,minEntries,10);
601 TGraphErrors * AliTPCcalibTimeGain::GetGraphGainVsTime(Int_t runNumber, Int_t minEntries) {
603 // Analyze results and get the graph
605 if (runNumber == 0) {
607 AnalyzeRun(minEntries);
610 // 1st check if the current run was cosmic or beam event
611 fHistGainTime->GetAxis(5)->SetRangeUser(runNumber,runNumber);
612 AnalyzeRun(minEntries);
614 if (fGainVsTime->GetN() == 0) return 0;
618 Long64_t AliTPCcalibTimeGain::Merge(TCollection *li) {
622 TIterator* iter = li->MakeIterator();
623 AliTPCcalibTimeGain* cal = 0;
625 while ((cal = (AliTPCcalibTimeGain*)iter->Next())) {
626 if (!cal->InheritsFrom(AliTPCcalibTimeGain::Class())) {
627 Error("Merge","Attempt to add object of class %s to a %s", cal->ClassName(), this->ClassName());
631 // add histograms here...
632 if (cal->GetHistGainTime() && fHistGainTime )
634 if ((fHistGainTime->GetEntries() + cal->GetHistGainTime()->GetEntries()) < fgMergeEntriesCut)
636 //AliInfo(Form("fHistGainTime has %.0f tracks, going to add %.0f\n",fHistGainTime->GetEntries(),cal->GetHistGainTime()->GetEntries()));
637 fHistGainTime->Add(cal->GetHistGainTime());
641 AliInfo(Form("fHistGainTime full (has %.0f merged tracks, max allowed: %.0f)",fHistGainTime->GetEntries(),fgMergeEntriesCut));
645 if (cal->GetHistDeDxTotal()) fHistDeDxTotal->Add(cal->GetHistDeDxTotal());
654 AliSplineFit * AliTPCcalibTimeGain::MakeSplineFit(TGraphErrors * graph) {
656 // make spline fit of gain
658 AliSplineFit *fit = new AliSplineFit();
659 fit->SetGraph(graph);
660 fit->SetMinPoints(graph->GetN()+1);
661 fit->InitKnots(graph,2,0,0.001);
669 TGraphErrors * AliTPCcalibTimeGain::GetGraphAttachment(Int_t minEntries, Int_t nmaxBin, Float_t /*fracLow*/, Float_t /*fracUp*/) {
671 // For each time bin the driftlength-dependence of the signal is fitted.
673 TH3D * hist = fHistGainTime->Projection(1, 0, 3);
674 Double_t *xvec = new Double_t[hist->GetNbinsX()];
675 Double_t *yvec = new Double_t[hist->GetNbinsX()];
676 Double_t *xerr = new Double_t[hist->GetNbinsX()];
677 Double_t *yerr = new Double_t[hist->GetNbinsX()];
679 TH2D * projectionHist = 0x0;
681 for(Int_t i=1; i < hist->GetNbinsX(); i++) {
685 for (Int_t idelta=0; idelta<nmaxBin; idelta++){
687 imin = TMath::Max(i-idelta,1);
688 imax = TMath::Min(i+idelta,hist->GetNbinsX());
689 nsum = TMath::Nint(hist->Integral(imin,imax,1,hist->GetNbinsY()-1,1,hist->GetNbinsZ()-1));
691 if (nsum>minEntries) break;
693 if (nsum<minEntries) continue;
695 hist->GetXaxis()->SetRange(imin,imax);
696 projectionHist = (TH2D*)hist->Project3D("yzNUFNOF");
699 projectionHist->FitSlicesY(0,2, projectionHist->GetNbinsX()-2,0,"QNR",&arr);
700 TH1D * histAttach = (TH1D*)arr.At(1);
701 TF1 pol1("polynom1","pol1",10,240);
702 histAttach->Fit(&pol1,"QNR");
703 xvec[counter] = 0.5*(hist->GetXaxis()->GetBinCenter(imin)+hist->GetXaxis()->GetBinCenter(imax));
704 yvec[counter] = pol1.GetParameter(1)/pol1.GetParameter(0);
706 yerr[counter] = pol1.GetParError(1)/pol1.GetParameter(0);
709 delete projectionHist;
712 TGraphErrors * graphErrors = new TGraphErrors(counter, xvec, yvec, xerr, yerr);
724 void AliTPCcalibTimeGain::BinLogX(THnSparse *h, Int_t axisDim) {
726 // Method for the correct logarithmic binning of histograms
728 TAxis *axis = h->GetAxis(axisDim);
729 int bins = axis->GetNbins();
731 Double_t from = axis->GetXmin();
732 Double_t to = axis->GetXmax();
733 Double_t *newBins = new Double_t[bins + 1];
736 Double_t factor = pow(to/from, 1./bins);
738 for (int i = 1; i <= bins; i++) {
739 newBins[i] = factor * newBins[i-1];
741 axis->Set(bins, newBins);
747 void AliTPCcalibTimeGain::BinLogX(TH1 *h) {
749 // Method for the correct logarithmic binning of histograms
751 TAxis *axis = h->GetXaxis();
752 int bins = axis->GetNbins();
754 Double_t from = axis->GetXmin();
755 Double_t to = axis->GetXmax();
756 Double_t *newBins = new Double_t[bins + 1];
759 Double_t factor = pow(to/from, 1./bins);
761 for (int i = 1; i <= bins; i++) {
762 newBins[i] = factor * newBins[i-1];
764 axis->Set(bins, newBins);
771 void AliTPCcalibTimeGain::CalculateBetheAlephParams(TH2F *hist, Double_t * ini) {
773 // Fit the bethe bloch params
775 //{0.0762*MIP,10.632,1.34e-05,1.863,1.948}
776 const Double_t sigma = 0.06;
778 TH2F *histBG = new TH2F("histBG","dEdxBg; #beta #gamma; TPC signal (a.u.)",TMath::Nint(0.5*hist->GetNbinsX()),0.1,5000.,hist->GetNbinsY(),hist->GetYaxis()->GetXmin(),hist->GetYaxis()->GetXmax());
781 TF1 *foElectron = new TF1("foElectron", "AliExternalTrackParam::BetheBlochAleph(x/0.000511,[0],[1],[2],[3],[4])",0.01,100);
782 TF1 *foMuon = new TF1("foMuon", "AliExternalTrackParam::BetheBlochAleph(x/0.1056,[0],[1],[2],[3],[4])",0.01,100);
783 TF1 *foPion = new TF1("foPion", "AliExternalTrackParam::BetheBlochAleph(x/0.138,[0],[1],[2],[3],[4])",0.01,100);
784 TF1 *foKaon = new TF1("foKaon", "AliExternalTrackParam::BetheBlochAleph(x/0.498,[0],[1],[2],[3],[4])",0.01,100);
785 TF1 *foProton = new TF1("foProton", "AliExternalTrackParam::BetheBlochAleph(x/0.938,[0],[1],[2],[3],[4])",0.01,100);
786 foElectron->SetParameters(ini);
787 foMuon->SetParameters(ini);
788 foPion->SetParameters(ini);
789 foKaon->SetParameters(ini);
790 foProton->SetParameters(ini);
792 TCanvas *canvCheck1 = new TCanvas();
794 foElectron->Draw("same");
795 foMuon->Draw("same");
796 foPion->Draw("same");
797 foKaon->Draw("same");
798 foProton->Draw("same");
800 // Loop over all points of the input histogram
802 for(Int_t i=1; i < hist->GetNbinsX(); i++) {
803 Double_t x = hist->GetXaxis()->GetBinCenter(i);
804 for(Int_t j=1; j < hist->GetNbinsY(); j++) {
805 Long64_t n = hist->GetBin(i, j);
806 Double_t y = hist->GetYaxis()->GetBinCenter(j);
807 Double_t entries = hist->GetBinContent(n);
810 // 1. identify protons
812 if (TMath::Abs(y - foProton->Eval(x))/foProton->Eval(x) < 4*sigma && x < 0.65 ) {
813 for(Int_t iEntries =0; iEntries < entries; iEntries++) histBG->Fill(x/mass, y);
816 // 2. identify electrons
819 if (TMath::Abs(y - foElectron->Eval(x))/foElectron->Eval(x) < 4*sigma && (x>0.25&&x<0.7) && fIsCosmic) {
820 for(Int_t iEntries =0; iEntries < entries; iEntries++) histBG->Fill(x/mass, y);
823 if (TMath::Abs(y - foElectron->Eval(x))/foElectron->Eval(x) < 2*sigma && ((x>0.25&&x<0.35) || (x>1.5&&x<1.8) || (x>0.65&&x<0.7))) {
824 for(Int_t iEntries =0; iEntries < entries; iEntries++) histBG->Fill(x/mass, y);
828 // 3. identify either muons or pions depending on cosmic or not
831 if (TMath::Abs(y - foMuon->Eval(x))/foMuon->Eval(x) < 4*sigma && x > 0.25 && x < 100 ) {
832 for(Int_t iEntries =0; iEntries < entries; iEntries++) histBG->Fill(x/mass, y);
836 if (TMath::Abs(y - foPion->Eval(x))/foPion->Eval(x) < 4*sigma && x > 0.15 && x < 2) {
837 for(Int_t iEntries =0; iEntries < entries; iEntries++) histBG->Fill(x/mass, y);
841 // 4. for pp also Kaons must be included
844 if (TMath::Abs(y - foKaon->Eval(x))/foKaon->Eval(x) < 4*sigma && x > 0.2 && x < 0.3 ) {
845 for(Int_t iEntries =0; iEntries < entries; iEntries++) histBG->Fill(x/mass, y);
851 // Fit Aleph-Parameters to the obtained profile
852 TF1 * funcAlephD = new TF1("AlephParametrizationD", "AliExternalTrackParam::BetheBlochAleph(x,[0],[1],[2],[3],[4])",0.3,10000);
853 funcAlephD->SetParameters(ini);
855 TCanvas *canvCheck2 = new TCanvas();
859 TObjArray * arr = new TObjArray();
860 histBG->FitSlicesY(0,0,-1,0,"QN",arr);
861 TH1D * fitMean = (TH1D*) arr->At(1);
862 fitMean->Draw("same");
864 funcAlephD->SetParLimits(2,1e-3,1e-7);
865 funcAlephD->SetParLimits(3,0.5,3.5);
866 funcAlephD->SetParLimits(4,0.5,3.5);
867 fitMean->Fit(funcAlephD, "QNR");
868 funcAlephD->Draw("same");
870 for(Int_t i=0;i<5;i++) ini[i] = funcAlephD->GetParameter(i);
872 foElectron->SetParameters(ini);
873 foMuon->SetParameters(ini);
874 foPion->SetParameters(ini);
875 foKaon->SetParameters(ini);
876 foProton->SetParameters(ini);
878 TCanvas *canvCheck3 = new TCanvas();
880 foElectron->Draw("same");
881 foMuon->Draw("same");
882 foPion->Draw("same");
883 foKaon->Draw("same");
884 foProton->Draw("same");