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 AliExternalTrackParam trckIn;
373 track->GetTrackParamIp(trckIn);
374 if ( (track->GetTrackParamIp(trckIn)) < 0) continue;
375 AliExternalTrackParam * trackIn = &trckIn;
376 if (!trackIn) continue;
378 //const AliExternalTrackParam * trackOut = friendTrack->GetTPCOut();
379 AliExternalTrackParam trckOut;
380 friendTrack->GetTrackParamTPCOut(trckOut);
381 if ( (friendTrack->GetTrackParamTPCOut(trckOut)) < 0) continue;
382 AliExternalTrackParam * trackOut = &trckOut;
383 if (!trackOut) continue;
385 // calculate necessary track parameters
386 Double_t meanP = trackIn->GetP();
387 Double_t meanDrift = 250 - 0.5*TMath::Abs(trackIn->GetZ() + trackOut->GetZ());
388 Int_t nclsDeDx = track->GetTPCNcls();
390 // exclude tracks which do not look like primaries or are simply too short or on wrong sectors
391 if (nclsDeDx < 60) continue;
392 if (TMath::Abs(trackIn->GetTgl()) > 1) continue;
393 if (TMath::Abs(trackIn->GetSnp()) > 0.6) continue;
396 TObject *calibObject;
397 AliTPCseed *seed = 0;
398 for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
399 if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
403 Double_t tpcSignal = GetTPCdEdx(seed);
404 if (nclsDeDx > 100) fHistDeDxTotal->Fill(meanP, tpcSignal);
406 if (fLowMemoryConsumption) {
407 if (meanP < 20) continue;
408 meanP = 30; // set all momenta to one in order to save memory
410 //dE/dx, time, type (1-muon cosmic,2-pion beam data), momenta
411 Double_t vec[6] = {tpcSignal,static_cast<Double_t>(time),1,meanDrift,meanP,static_cast<Double_t>(runNumber)};
412 fHistGainTime->Fill(vec);
421 void AliTPCcalibTimeGain::ProcessBeamEvent(AliVEvent *event) {
423 // Process in case of beam event
425 //Printf("AliTPCcalibTimeGain::ProcessBeamEvent(event)...");
427 AliVfriendEvent *friendEvent=event->FindFriend();
429 //Printf("ERROR AliTPCcalibTimeGain::ProcessBeamEvent(): ESDfriend not available");
433 UInt_t time = event->GetTimeStamp();
434 if (!time) Printf("ERROR: no time stamp available!");
435 Int_t nFriendTracks = friendEvent->GetNumberOfTracks();
436 Int_t runNumber = event->GetRunNumber();
440 for (Int_t i=0;i<nFriendTracks;++i) { // begin track loop
442 AliVTrack *track = event->GetVTrack(i);
444 //Printf("***ERROR*** : track not available");
446 const AliVfriendTrack *friendTrack = friendEvent->GetTrack(i);
448 //Printf("ERROR ProcessBeamEvent(): friendTrack is not available!");
452 //const AliExternalTrackParam * trackIn = track->GetInnerParam();
453 AliExternalTrackParam trckIn;
454 track->GetTrackParamIp(trckIn);
455 if ( (track->GetTrackParamIp(trckIn)) < 0) continue;
456 AliExternalTrackParam * trackIn = &trckIn;
457 if (!trackIn) continue;
459 //const AliExternalTrackParam * trackOut = friendTrack->GetTPCOut();
460 AliExternalTrackParam trckOut;
461 friendTrack->GetTrackParamTPCOut(trckOut);
462 if ( (friendTrack->GetTrackParamTPCOut(trckOut)) < 0) continue;
463 AliExternalTrackParam * trackOut = &trckOut;
464 if (!trackOut) continue;
466 // calculate necessary track parameters
467 Double_t meanP = trackIn->GetP();
468 Double_t meanDrift = 250 - 0.5*TMath::Abs(trackIn->GetZ() + trackOut->GetZ());
469 Int_t nCrossedRows = track->GetTPCCrossedRows();
472 // exclude tracks which do not look like primaries or are simply too short or on wrong sectors
473 // fCutCrossRows = 80, fCutEtaWindow = 0.8, fCutRequireITSrefit, fCutMaxDcaXY = 3.5, fCutMaxDcaZ = 25
475 if (nCrossedRows < fCutCrossRows) continue;
476 if (TMath::Abs(trackIn->Eta()) > fCutEtaWindow) continue;
478 UInt_t status = track->GetStatus();
479 if ((status&AliVTrack::kTPCrefit)==0) continue;
480 if ((status&AliVTrack::kITSrefit)==0 && fCutRequireITSrefit) continue; // ITS cluster
482 Float_t dca[2], cov[3];
483 track->GetImpactParameters(dca,cov);
484 if (TMath::Abs(dca[0]) > fCutMaxDcaXY || TMath::Abs(dca[0]) < 0.0000001) continue; // cut in xy
485 if (((status&AliVTrack::kITSrefit) == 1 && TMath::Abs(dca[1]) > 3.) || TMath::Abs(dca[1]) > fCutMaxDcaZ ) continue;
487 Double_t eta = trackIn->Eta();
490 TObject *calibObject;
491 AliTPCseed *seed = 0;
492 for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
493 if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
497 Int_t particleCase = 0;
498 if (meanP < fMaxMomentumMIP && meanP > fMinMomentumMIP) particleCase = 2; // MIP pions
499 if (meanP < 0.57 && meanP > 0.56) particleCase = 3; // protons 1
500 if (meanP < 0.66 && meanP > 0.65) particleCase = 4; // protons 2
502 if (fLowMemoryConsumption && particleCase == 0) continue;
504 Double_t tpcSignal = GetTPCdEdx(seed);
506 // flattens signal in MIP window
508 if (particleCase == 2) {
509 Float_t corrFactor = AliExternalTrackParam::BetheBlochAleph(meanP/0.13957,
514 fAlephParameters[4]);
515 tpcSignal /= corrFactor;
517 //Printf("Fill DeDx histo..");
518 fHistDeDxTotal->Fill(meanP, tpcSignal);
520 //dE/dx, time, type (1-muon cosmic,2-pion beam data, 3&4 protons), momenta, runNumner, eta
521 Double_t vec[7] = {tpcSignal,static_cast<Double_t>(time),static_cast<Double_t>(particleCase),meanDrift,meanP,static_cast<Double_t>(runNumber), eta};
522 //Printf("Fill Gain histo in track loop...");
523 fHistGainTime->Fill(vec);
528 // V0 loop -- in beam events the cosmic part of the histogram is filled with GammaConversions
530 for(Int_t iv0 = 0; iv0 < event->GetNumberOfV0s(); iv0++) {
531 //AliESDv0 * v0 = event->GetV0(iv0);
533 event->GetV0(v0dummy, iv0);
534 AliESDv0 *v0 = &v0dummy;
536 //if (!v0) Printf("ERROR AliTPCcalibTimeGain::ProcessBeamEvent(): ESDv0 not available! ");
538 if (!v0->GetOnFlyStatus()) continue;
539 if (v0->GetEffMass(0,0) > 0.02) continue; // select low inv. mass
541 v0->GetXYZ(xyz[0], xyz[1], xyz[2]);
542 if (TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]) < 3 || TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]) > 30) continue;
544 // "loop over daughters"
546 for(Int_t idaughter = 0; idaughter < 2; idaughter++) { // daughter loop
547 Int_t index = idaughter == 0 ? v0->GetPindex() : v0->GetNindex();
548 AliVTrack * trackP = event->GetVTrack(index);
549 if (!trackP) continue; //Printf("***ERROR*** trackP not available!");
550 const AliVfriendTrack *friendTrackP = friendEvent->GetTrack(index);
551 if (!friendTrackP) continue;
552 //const AliExternalTrackParam * trackPIn = trackP->GetInnerParam();
553 AliExternalTrackParam trckPIn;
554 trackP->GetTrackParamIp(trckPIn);
555 if ( (trackP->GetTrackParamIp(trckPIn)) < 0) continue;
556 AliExternalTrackParam * trackPIn = &trckPIn;
557 if (!trackPIn) continue;
559 //const AliExternalTrackParam * trackPOut = friendTrackP->GetTPCOut();
560 AliExternalTrackParam trckPOut;
561 friendTrackP->GetTrackParamTPCOut(trckPOut);
562 if ( (friendTrackP->GetTrackParamTPCOut(trckPOut)) < 0) continue;
563 AliExternalTrackParam * trackPOut = &trckPOut;
564 if (!trackPOut) continue;
566 // calculate necessary track parameters
567 Double_t meanP = trackPIn->GetP();
568 Double_t meanDrift = 250 - 0.5*TMath::Abs(trackPIn->GetZ() + trackPOut->GetZ());
569 Int_t nclsDeDx = trackP->GetTPCNcls();
570 // exclude tracks which do not look like primaries or are simply too short or on wrong sectors
571 if (nclsDeDx < 60) continue;
572 if (TMath::Abs(trackPIn->GetTgl()) > 1) continue;
574 TObject *calibObject;
575 AliTPCseed *seed = 0;
576 for (Int_t l=0;(calibObject=friendTrackP->GetCalibObject(l));++l) {
577 if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
580 if (fLowMemoryConsumption) {
581 if (meanP > fMaxMomentumMIP || meanP < fMinMomentumMIP) continue;
582 meanP = 0.45; // set all momenta to one in order to save memory
584 Double_t tpcSignal = GetTPCdEdx(seed);
585 //dE/dx, time, type (1-muon cosmic,2-pion beam data), momenta
586 Double_t vec[6] = {tpcSignal,static_cast<Double_t>(time),1,meanDrift,meanP,static_cast<Double_t>(runNumber)};
587 //Printf("Fill Gain histo in v0 loop...");
588 fHistGainTime->Fill(vec);
597 Float_t AliTPCcalibTimeGain::GetTPCdEdx(AliTPCseed * seed) {
599 // calculate tpc dEdx
603 if (!fUseCookAnalytical) {
604 signal = (1/fMIP)*seed->CookdEdxNorm(fLowerTrunc,fUpperTrunc,fUseMax,0,159,fUseShapeNorm,fUsePosNorm,fUsePadNorm,0);
606 signal = (1/fMIP)*seed->CookdEdxAnalytical(fLowerTrunc,fUpperTrunc,fUseMax);
613 void AliTPCcalibTimeGain::AnalyzeRun(Int_t minEntries) {
615 // Analyze results of calibration
618 fHistGainTime->GetAxis(2)->SetRangeUser(0.51,1.49); // only cosmics
619 fHistGainTime->GetAxis(4)->SetRangeUser(20,100); // only Fermi-Plateau muons
621 fHistGainTime->GetAxis(2)->SetRangeUser(1.51,2.49); // only beam data
622 fHistGainTime->GetAxis(4)->SetRangeUser(0.39,0.51); // only MIP pions
625 fGainVsTime = AliTPCcalibBase::FitSlices(fHistGainTime,0,1,minEntries,10);
631 TGraphErrors * AliTPCcalibTimeGain::GetGraphGainVsTime(Int_t runNumber, Int_t minEntries) {
633 // Analyze results and get the graph
635 if (runNumber == 0) {
637 AnalyzeRun(minEntries);
640 // 1st check if the current run was cosmic or beam event
641 fHistGainTime->GetAxis(5)->SetRangeUser(runNumber,runNumber);
642 AnalyzeRun(minEntries);
644 if (fGainVsTime->GetN() == 0) return 0;
648 Long64_t AliTPCcalibTimeGain::Merge(TCollection *li) {
652 TIterator* iter = li->MakeIterator();
653 AliTPCcalibTimeGain* cal = 0;
655 while ((cal = (AliTPCcalibTimeGain*)iter->Next())) {
656 if (!cal->InheritsFrom(AliTPCcalibTimeGain::Class())) {
657 Error("Merge","Attempt to add object of class %s to a %s", cal->ClassName(), this->ClassName());
661 // add histograms here...
662 if (cal->GetHistGainTime() && fHistGainTime )
664 if ((fHistGainTime->GetEntries() + cal->GetHistGainTime()->GetEntries()) < fgMergeEntriesCut)
666 //AliInfo(Form("fHistGainTime has %.0f tracks, going to add %.0f\n",fHistGainTime->GetEntries(),cal->GetHistGainTime()->GetEntries()));
667 fHistGainTime->Add(cal->GetHistGainTime());
671 AliInfo(Form("fHistGainTime full (has %.0f merged tracks, max allowed: %.0f)",fHistGainTime->GetEntries(),fgMergeEntriesCut));
675 if (cal->GetHistDeDxTotal()) fHistDeDxTotal->Add(cal->GetHistDeDxTotal());
684 AliSplineFit * AliTPCcalibTimeGain::MakeSplineFit(TGraphErrors * graph) {
686 // make spline fit of gain
688 AliSplineFit *fit = new AliSplineFit();
689 fit->SetGraph(graph);
690 fit->SetMinPoints(graph->GetN()+1);
691 fit->InitKnots(graph,2,0,0.001);
699 TGraphErrors * AliTPCcalibTimeGain::GetGraphAttachment(Int_t minEntries, Int_t nmaxBin, Float_t /*fracLow*/, Float_t /*fracUp*/) {
701 // For each time bin the driftlength-dependence of the signal is fitted.
703 TH3D * hist = fHistGainTime->Projection(1, 0, 3);
704 Double_t *xvec = new Double_t[hist->GetNbinsX()];
705 Double_t *yvec = new Double_t[hist->GetNbinsX()];
706 Double_t *xerr = new Double_t[hist->GetNbinsX()];
707 Double_t *yerr = new Double_t[hist->GetNbinsX()];
709 TH2D * projectionHist = 0x0;
711 for(Int_t i=1; i < hist->GetNbinsX(); i++) {
715 for (Int_t idelta=0; idelta<nmaxBin; idelta++){
717 imin = TMath::Max(i-idelta,1);
718 imax = TMath::Min(i+idelta,hist->GetNbinsX());
719 nsum = TMath::Nint(hist->Integral(imin,imax,1,hist->GetNbinsY()-1,1,hist->GetNbinsZ()-1));
721 if (nsum>minEntries) break;
723 if (nsum<minEntries) continue;
725 hist->GetXaxis()->SetRange(imin,imax);
726 projectionHist = (TH2D*)hist->Project3D("yzNUFNOF");
729 projectionHist->FitSlicesY(0,2, projectionHist->GetNbinsX()-2,0,"QNR",&arr);
730 TH1D * histAttach = (TH1D*)arr.At(1);
731 TF1 pol1("polynom1","pol1",10,240);
732 histAttach->Fit(&pol1,"QNR");
733 xvec[counter] = 0.5*(hist->GetXaxis()->GetBinCenter(imin)+hist->GetXaxis()->GetBinCenter(imax));
734 yvec[counter] = pol1.GetParameter(1)/pol1.GetParameter(0);
736 yerr[counter] = pol1.GetParError(1)/pol1.GetParameter(0);
739 delete projectionHist;
742 TGraphErrors * graphErrors = new TGraphErrors(counter, xvec, yvec, xerr, yerr);
754 void AliTPCcalibTimeGain::BinLogX(THnSparse *h, Int_t axisDim) {
756 // Method for the correct logarithmic binning of histograms
758 TAxis *axis = h->GetAxis(axisDim);
759 int bins = axis->GetNbins();
761 Double_t from = axis->GetXmin();
762 Double_t to = axis->GetXmax();
763 Double_t *newBins = new Double_t[bins + 1];
766 Double_t factor = pow(to/from, 1./bins);
768 for (int i = 1; i <= bins; i++) {
769 newBins[i] = factor * newBins[i-1];
771 axis->Set(bins, newBins);
777 void AliTPCcalibTimeGain::BinLogX(TH1 *h) {
779 // Method for the correct logarithmic binning of histograms
781 TAxis *axis = h->GetXaxis();
782 int bins = axis->GetNbins();
784 Double_t from = axis->GetXmin();
785 Double_t to = axis->GetXmax();
786 Double_t *newBins = new Double_t[bins + 1];
789 Double_t factor = pow(to/from, 1./bins);
791 for (int i = 1; i <= bins; i++) {
792 newBins[i] = factor * newBins[i-1];
794 axis->Set(bins, newBins);
801 void AliTPCcalibTimeGain::CalculateBetheAlephParams(TH2F *hist, Double_t * ini) {
803 // Fit the bethe bloch params
805 //{0.0762*MIP,10.632,1.34e-05,1.863,1.948}
806 const Double_t sigma = 0.06;
808 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());
811 TF1 *foElectron = new TF1("foElectron", "AliExternalTrackParam::BetheBlochAleph(x/0.000511,[0],[1],[2],[3],[4])",0.01,100);
812 TF1 *foMuon = new TF1("foMuon", "AliExternalTrackParam::BetheBlochAleph(x/0.1056,[0],[1],[2],[3],[4])",0.01,100);
813 TF1 *foPion = new TF1("foPion", "AliExternalTrackParam::BetheBlochAleph(x/0.138,[0],[1],[2],[3],[4])",0.01,100);
814 TF1 *foKaon = new TF1("foKaon", "AliExternalTrackParam::BetheBlochAleph(x/0.498,[0],[1],[2],[3],[4])",0.01,100);
815 TF1 *foProton = new TF1("foProton", "AliExternalTrackParam::BetheBlochAleph(x/0.938,[0],[1],[2],[3],[4])",0.01,100);
816 foElectron->SetParameters(ini);
817 foMuon->SetParameters(ini);
818 foPion->SetParameters(ini);
819 foKaon->SetParameters(ini);
820 foProton->SetParameters(ini);
822 TCanvas *canvCheck1 = new TCanvas();
824 foElectron->Draw("same");
825 foMuon->Draw("same");
826 foPion->Draw("same");
827 foKaon->Draw("same");
828 foProton->Draw("same");
830 // Loop over all points of the input histogram
832 for(Int_t i=1; i < hist->GetNbinsX(); i++) {
833 Double_t x = hist->GetXaxis()->GetBinCenter(i);
834 for(Int_t j=1; j < hist->GetNbinsY(); j++) {
835 Long64_t n = hist->GetBin(i, j);
836 Double_t y = hist->GetYaxis()->GetBinCenter(j);
837 Double_t entries = hist->GetBinContent(n);
840 // 1. identify protons
842 if (TMath::Abs(y - foProton->Eval(x))/foProton->Eval(x) < 4*sigma && x < 0.65 ) {
843 for(Int_t iEntries =0; iEntries < entries; iEntries++) histBG->Fill(x/mass, y);
846 // 2. identify electrons
849 if (TMath::Abs(y - foElectron->Eval(x))/foElectron->Eval(x) < 4*sigma && (x>0.25&&x<0.7) && fIsCosmic) {
850 for(Int_t iEntries =0; iEntries < entries; iEntries++) histBG->Fill(x/mass, y);
853 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))) {
854 for(Int_t iEntries =0; iEntries < entries; iEntries++) histBG->Fill(x/mass, y);
858 // 3. identify either muons or pions depending on cosmic or not
861 if (TMath::Abs(y - foMuon->Eval(x))/foMuon->Eval(x) < 4*sigma && x > 0.25 && x < 100 ) {
862 for(Int_t iEntries =0; iEntries < entries; iEntries++) histBG->Fill(x/mass, y);
866 if (TMath::Abs(y - foPion->Eval(x))/foPion->Eval(x) < 4*sigma && x > 0.15 && x < 2) {
867 for(Int_t iEntries =0; iEntries < entries; iEntries++) histBG->Fill(x/mass, y);
871 // 4. for pp also Kaons must be included
874 if (TMath::Abs(y - foKaon->Eval(x))/foKaon->Eval(x) < 4*sigma && x > 0.2 && x < 0.3 ) {
875 for(Int_t iEntries =0; iEntries < entries; iEntries++) histBG->Fill(x/mass, y);
881 // Fit Aleph-Parameters to the obtained profile
882 TF1 * funcAlephD = new TF1("AlephParametrizationD", "AliExternalTrackParam::BetheBlochAleph(x,[0],[1],[2],[3],[4])",0.3,10000);
883 funcAlephD->SetParameters(ini);
885 TCanvas *canvCheck2 = new TCanvas();
889 TObjArray * arr = new TObjArray();
890 histBG->FitSlicesY(0,0,-1,0,"QN",arr);
891 TH1D * fitMean = (TH1D*) arr->At(1);
892 fitMean->Draw("same");
894 funcAlephD->SetParLimits(2,1e-3,1e-7);
895 funcAlephD->SetParLimits(3,0.5,3.5);
896 funcAlephD->SetParLimits(4,0.5,3.5);
897 fitMean->Fit(funcAlephD, "QNR");
898 funcAlephD->Draw("same");
900 for(Int_t i=0;i<5;i++) ini[i] = funcAlephD->GetParameter(i);
902 foElectron->SetParameters(ini);
903 foMuon->SetParameters(ini);
904 foPion->SetParameters(ini);
905 foKaon->SetParameters(ini);
906 foProton->SetParameters(ini);
908 TCanvas *canvCheck3 = new TCanvas();
910 foElectron->Draw("same");
911 foMuon->Draw("same");
912 foPion->Draw("same");
913 foKaon->Draw("same");
914 foProton->Draw("same");