2 /**************************************************************************
3 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
20 Basic calibration and QA class for the TPC gain calibration based on tracks from BEAM events.
23 Send comments etc. to: A.Kalweit@gsi.de, marian.ivanov@cern.ch
27 #include "Riostream.h"
40 #include "TGraphErrors.h"
42 #include "AliTPCcalibDB.h"
43 #include "AliTPCclusterMI.h"
44 #include "AliTPCClusterParam.h"
45 #include "AliTPCseed.h"
46 #include "AliESDVertex.h"
47 #include "AliESDEvent.h"
48 #include "AliESDfriend.h"
49 #include "AliESDInputHandler.h"
50 #include "AliAnalysisManager.h"
51 #include "AliTPCParam.h"
53 #include "AliComplexCluster.h"
54 #include "AliTPCclusterMI.h"
58 #include "AliTPCcalibGainMult.h"
60 #include "TTreeStream.h"
61 #include "TDatabasePDG.h"
62 #include "AliKFParticle.h"
63 #include "AliKFVertex.h"
65 #include "AliESDkink.h"
66 #include "AliRecoParam.h"
67 #include "AliTracker.h"
68 #include "AliTPCTransform.h"
69 #include "AliTPCROC.h"
70 #include "TStatToolkit.h"
72 ClassImp(AliTPCcalibGainMult)
74 Double_t AliTPCcalibGainMult::fgMergeEntriesCut=10000000.;
76 AliTPCcalibGainMult::AliTPCcalibGainMult()
84 fCutRequireITSrefit(0),
105 // Empty default cosntructor
107 AliDebug(5,"Default Constructor");
111 AliTPCcalibGainMult::AliTPCcalibGainMult(const Text_t *name, const Text_t *title)
119 fCutRequireITSrefit(0),
126 fHistClusterShape(0),
146 fLowerTrunc = 0.02; // IMPORTANT CHANGE --> REMOVE HARDWIRED TRUNCATION FROM TRACKER
148 fUseMax = kTRUE; // IMPORTANT CHANGE FOR PbPb; standard: kFALSE;
150 // define track cuts and default BB parameters for interpolation around mean
154 fCutRequireITSrefit = kFALSE;
157 // default values for MIP window selection
158 fMinMomentumMIP = 0.4;
159 fMaxMomentumMIP = 0.6;
160 fAlephParameters[0] = 0.07657; // the following parameters work for most of the periods and are therefore default
161 fAlephParameters[1] = 10.6654; // but they can be overwritten in the train setup of cpass0
162 fAlephParameters[2] = 2.51466e-14;
163 fAlephParameters[3] = 2.05379;
164 fAlephParameters[4] = 1.84288;
166 // basic QA histograms - mainly for debugging purposes
168 fHistNTracks = new TH1F("ntracks","Number of Tracks per Event; number of tracks per event; number of tracks",1001,-0.5,1000.5);
169 fHistClusterShape = new TH1F("fHistClusterShape","cluster shape; rms meas. / rms exp.;",300,0,3);
170 fHistQA = new TH3F("fHistQA","dEdx; momentum p (GeV); TPC signal (a.u.); pad",500,0.1,20.,500,0.,500,6,-0.5,5.5);
171 AliTPCcalibBase::BinLogX(fHistQA);
174 // MIP, sect, pad (short,med,long,full,oroc), run, ncl
175 Int_t binsGainSec[5] = { 145, 72, 4, 10000000, 65};
176 Double_t xminGainSec[5] = { 10., -0.5, -0.5, -0.5, -0.5};
177 Double_t xmaxGainSec[5] = {300., 71.5, 3.5, 9999999.5, 64.5};
178 TString axisNameSec[5]={"Q","sector","pad type","run", "ncl"};
179 TString axisTitleSec[5]={"Q (a.u)","sector","pad type","run","ncl"};
181 fHistGainSector = new THnSparseF("fHistGainSector","0:MIP, 1:sect, 2:pad, 3:run, 4:ncl", 5, binsGainSec, xminGainSec, xmaxGainSec);
182 for (Int_t iaxis=0; iaxis<5;iaxis++){
183 fHistGainSector->GetAxis(iaxis)->SetName(axisNameSec[iaxis]);
184 fHistGainSector->GetAxis(iaxis)->SetTitle(axisTitleSec[iaxis]);
187 // pad region equalization
189 Int_t binsPadEqual[5] = { 400, 400, 4, 5, 20};
190 Double_t xminPadEqual[5] = { 0.0, 0.0, -0.5, 0, -1.};
191 Double_t xmaxPadEqual[5] = { 2.0, 2.0, 3.5, 13000, +1};
192 TString axisNamePadEqual[5] = {"dEdxRatioMax","dEdxRatioTot","padType","mult","dipAngle"};
193 TString axisTitlePadEqual[5] = {"dEdx_padRegion/mean_dEdx Qmax", "dEdx_padRegion/mean_dEdx Qtot","padType","mult","tan(lambda)"};
195 fHistPadEqual = new THnSparseF("fHistPadEqual","0:dEdx_pad/dEdx_mean, 1:pad, 2:mult, 3:drift", 5, binsPadEqual, xminPadEqual, xmaxPadEqual);
196 for (Int_t iaxis=0; iaxis<5;iaxis++){
197 fHistPadEqual->GetAxis(iaxis)->SetName(axisNamePadEqual[iaxis]);
198 fHistPadEqual->GetAxis(iaxis)->SetTitle(axisTitlePadEqual[iaxis]);
201 // multiplicity dependence
202 // MIP Qmax, MIP Qtot, z, pad, vtx. contribut., ncl
203 Int_t binsGainMult[6] = { 145, 145, 25, 4, 100, 80};
204 Double_t xminGainMult[6] = { 10., 10., 0, -0.5, 0, -0.5};
205 Double_t xmaxGainMult[6] = {300., 300., 250, 3.5, 13000, 159.5};
206 TString axisNameMult[6]={"Qmax","Qtot","drift","padtype""multiplicity","ncl"};
207 TString axisTitleMult[6]={"Qmax (a.u)","Qtot (a.u.)","driftlenght l (cm)","Pad Type","multiplicity","ncl"};
209 fHistGainMult = new THnSparseF("fHistGainMult","MIP Qmax, MIP Qtot, z, type, vtx. contribut.", 6, binsGainMult, xminGainMult, xmaxGainMult);
210 for (Int_t iaxis=0; iaxis<6;iaxis++){
211 fHistGainMult->GetAxis(iaxis)->SetName(axisNameMult[iaxis]);
212 fHistGainMult->GetAxis(iaxis)->SetTitle(axisTitleMult[iaxis]);
215 // dip-angle (theta or eta) and inclination angle (local phi) dependence -- absolute calibration
217 // (0.) weighted dE/dx, (1.) 0:Qtot - 1:Qmax, (2.) tgl, (3.) 1./pT
218 Int_t binsTopology[4] = {145, 2, 20, 20};
219 Double_t xminTopology[4] = { 10, -0.5, -1, 0};
220 Double_t xmaxTopology[4] = { 10, 1.5, +1, 5};
221 TString axisNameTopology[4] = {"dEdx", "QtotQmax", "tgl", "1/pT"};
222 TString axisTitleTopology[4] = {"dEdx", "QtotQmax", "tgl", "1/pT"};
224 fHistTopology = new THnF("fHistTopology", "dEdx,QtotQmax,tgl, 1/pT", 4, binsTopology, xminTopology, xmaxTopology);
225 for (Int_t iaxis=0; iaxis<4;iaxis++){
226 fHistTopology->GetAxis(iaxis)->SetName(axisNameTopology[iaxis]);
227 fHistTopology->GetAxis(iaxis)->SetTitle(axisTitleTopology[iaxis]);
231 // dedx maps - bigger granulatity in phi -
232 // to construct the dedx sector/phi map
233 Int_t binsGainMap[4] = { 100, 90, 10, 6};
234 Double_t xminGainMap[4] = { 0.3, -TMath::Pi(), 0, 0};
235 Double_t xmaxGainMap[4] = { 2, TMath::Pi(), 1, 6};
236 TString axisNameMap[4] = {"Q_Qexp","phi", "1/Qexp","Pad Type"};
237 TString axisTitleMap[4] = {"Q/Q_{exp}","#phi (a.u.)","1/Q_{exp}","Pad Type"};
239 fHistdEdxMap = new THnSparseF("fHistdEdxMap","fHistdEdxMap", 4, binsGainMap, xminGainMap, xmaxGainMap);
240 for (Int_t iaxis=0; iaxis<4;iaxis++){
241 fHistdEdxMap->GetAxis(iaxis)->SetName(axisNameMap[iaxis]);
242 fHistdEdxMap->GetAxis(iaxis)->SetTitle(axisTitleMap[iaxis]);
248 Int_t binsGainMax[6] = { 100, 10, 10, 10, 5, 3};
249 Double_t xminGainMax[6] = { 0.5, 0, 0, 0, 0, 0};
250 Double_t xmaxGainMax[6] = { 1.5, 1, 1.0, 1.0, 3000, 3};
251 TString axisNameMax[6] = {"Q_Qexp","1/Qexp", "phi","theta","mult", "Pad Type"};
252 TString axisTitleMax[6] = {"Q/Q_{exp}","1/Qexp", "#phi","#theta","mult","Pad Type"};
254 fHistdEdxMax = new THnSparseF("fHistdEdxMax","fHistdEdxMax", 6, binsGainMax, xminGainMax, xmaxGainMax);
255 fHistdEdxTot = new THnSparseF("fHistdEdxTot","fHistdEdxTot", 6, binsGainMax, xminGainMax, xmaxGainMax);
256 for (Int_t iaxis=0; iaxis<6;iaxis++){
257 fHistdEdxMax->GetAxis(iaxis)->SetName(axisNameMax[iaxis]);
258 fHistdEdxMax->GetAxis(iaxis)->SetTitle(axisTitleMax[iaxis]);
259 fHistdEdxTot->GetAxis(iaxis)->SetName(axisNameMax[iaxis]);
260 fHistdEdxTot->GetAxis(iaxis)->SetTitle(axisTitleMax[iaxis]);
263 AliDebug(5,"Non Default Constructor");
267 AliTPCcalibGainMult::~AliTPCcalibGainMult(){
271 delete fHistNTracks; // histogram showing number of ESD tracks per event
272 delete fHistClusterShape; // histogram to check the cluster shape
273 delete fHistQA; // dE/dx histogram showing the final spectrum
275 delete fHistGainSector; // histogram which shows MIP peak for each of the 3x36 sectors (pad region)
276 delete fHistPadEqual; // histogram for the equalization of the gain in the different pad regions -> pass0
277 delete fHistGainMult; // histogram which shows decrease of MIP signal as a function
278 delete fHistTopology;
284 if (fBBParam) delete fBBParam;
289 void AliTPCcalibGainMult::Process(AliESDEvent *event) {
291 // Main function of the class
292 // 1. Select Identified particles - for identified particles the flag in the PID matrix is stored
293 // 1.a) ProcessV0s - select Electron (gamma coversion) and pion canditates (from K0s)
294 // 1.b) ProcessTOF - select - Proton, kaon and pions candidates
295 // AS THE TOF not calibrated yet in Pass0 - we are calibrating the TOF T0 in this function
296 // 1.c) ProcessCosmic - select cosmic mumn candidates - too few entries - not significant for the calibration
297 // 1.d) ProcessKinks - select Kaon and pion candidates. From our experience (see Kink debug streamer), the angular cut for kink daughter is not sufficient - big contamination - delta rays, hadronic interaction (proton)
298 // - NOT USED for the
300 // 2. Loop over tracks
301 // 2.a DumpTrack() - for identified particles dump the track and dEdx information into the tree (for later fitting)
302 // 3. Actual fitting for the moment macro
305 // Criteria for the track selection
307 // const Int_t kMinNCL=80; // minimal number of cluster - tracks accepted for the dedx calibration
308 //const Double_t kMaxEta=0.8; // maximal eta fo the track to be accepted
309 //const Double_t kMaxDCAR=10; // maximal DCA R of the track
310 //const Double_t kMaxDCAZ=5; // maximal DCA Z of the track
311 // const Double_t kMIPPt=0.525; // MIP pt
314 Printf("ERROR: ESD not available");
317 fCurrentEvent=event ;
318 fMagF = event->GetMagneticField();
319 Int_t ntracks=event->GetNumberOfTracks();
320 AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
322 //Printf("ERROR: esdFriend not available");
326 if (!(esdFriend->TestSkipBit())) fPIDMatrix= new TMatrixD(ntracks,5);
327 fHistNTracks->Fill(ntracks);
328 // ProcessCosmic(event); // usually not enogh statistic
330 if (esdFriend->TestSkipBit()) {
334 //ProcessV0s(event); //
335 //ProcessTOF(event); //
336 //ProcessKinks(event); // not relyable
338 UInt_t runNumber = event->GetRunNumber();
339 Int_t nContributors = event->GetNumberOfTracks();
343 for (Int_t i=0;i<ntracks;++i) {
345 AliESDtrack *track = event->GetTrack(i);
346 if (!track) continue;
348 AliExternalTrackParam * trackIn = (AliExternalTrackParam *)track->GetInnerParam();
349 if (!trackIn) continue;
351 // calculate necessary track parameters
352 Double_t meanP = trackIn->GetP();
353 Int_t ncls = track->GetTPCNcls();
354 Int_t nCrossedRows = track->GetTPCCrossedRows();
356 // correction factor of dE/dx in MIP window
357 Float_t corrFactorMip = AliExternalTrackParam::BetheBlochAleph(meanP/0.13957,
362 fAlephParameters[4]);
363 if (TMath::Abs(corrFactorMip) < 1e-10) continue;
365 if (nCrossedRows < fCutCrossRows) continue;
366 // exclude tracks which do not look like primaries or are simply too short or on wrong sectors
367 if (TMath::Abs(trackIn->Eta()) > fCutEtaWindow) continue;
369 UInt_t status = track->GetStatus();
370 if ((status&AliESDtrack::kTPCrefit)==0) continue;
371 if ((status&AliESDtrack::kITSrefit)==0 && fCutRequireITSrefit) continue; // ITS cluster
372 Float_t dca[2], cov[3];
373 track->GetImpactParameters(dca,cov);
374 Float_t primVtxDCA = TMath::Sqrt(dca[0]*dca[0]);
375 if (TMath::Abs(dca[0]) > fCutMaxDcaXY || TMath::Abs(dca[0]) < 0.0000001) continue; // cut in xy
376 if (((status&AliESDtrack::kITSrefit) == 1 && TMath::Abs(dca[1]) > 3.) || TMath::Abs(dca[1]) > fCutMaxDcaZ ) continue;
379 // fill Alexander QA histogram
381 if (primVtxDCA < 3 && track->GetNcls(0) > 3 && track->GetKinkIndex(0) == 0 && ncls > 100) fHistQA->Fill(meanP, track->GetTPCsignal(), 5);
384 AliESDfriendTrack *friendTrack = esdFriend->GetTrack(i);
385 if (!friendTrack) continue;
386 TObject *calibObject;
387 AliTPCseed *seed = 0;
388 for (Int_t l=0;(calibObject=friendTrack->GetCalibObject(l));++l) {
389 if ((seed=dynamic_cast<AliTPCseed*>(calibObject))) break;
391 //if (seed) DumpTrack(track, friendTrack,seed,i); // MI implementation for the identified particles
393 if (seed) { // seed the container with track parameters and the clusters
395 const AliExternalTrackParam * trackOut = friendTrack->GetTPCOut(); // tack at the outer radius of TPC
396 if (!trackIn) continue;
397 if (!trackOut) continue;
398 Double_t meanDrift = 250 - 0.5*TMath::Abs(trackIn->GetZ() + trackOut->GetZ());
399 Double_t dipAngleTgl = trackIn->GetTgl();
401 for (Int_t irow =0; irow<160;irow++) {
402 AliTPCTrackerPoint * point = seed->GetTrackPoint(irow);
403 if (point==0) continue;
404 AliTPCclusterMI * cl = seed->GetClusterPointer(irow);
407 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
408 fHistClusterShape->Fill(rsigmay);
414 Double_t signalShortMax = seed->CookdEdxAnalytical(fLowerTrunc,fUpperTrunc,1,0,62);
415 Double_t signalMedMax = seed->CookdEdxAnalytical(fLowerTrunc,fUpperTrunc,1,63,126);
416 Double_t signalLongMax = seed->CookdEdxAnalytical(fLowerTrunc,fUpperTrunc,1,127,159);
417 Double_t signalMax = seed->CookdEdxAnalytical(fLowerTrunc,fUpperTrunc,1,row0,row1);
418 Double_t signalArrayMax[4] = {signalShortMax, signalMedMax, signalLongMax, signalMax};
420 Double_t signalShortTot = seed->CookdEdxAnalytical(fLowerTrunc,fUpperTrunc,0,0,62);
421 Double_t signalMedTot = seed->CookdEdxAnalytical(fLowerTrunc,fUpperTrunc,0,63,126);
422 Double_t signalLongTot = seed->CookdEdxAnalytical(fLowerTrunc,fUpperTrunc,0,127,159);
424 Double_t signalTot = 0;
426 Double_t signalArrayTot[4] = {signalShortTot, signalMedTot, signalLongTot, signalTot};
428 Double_t mipSignalShort = fUseMax ? signalShortMax : signalShortTot;
429 Double_t mipSignalMed = fUseMax ? signalMedMax : signalMedTot;
430 Double_t mipSignalLong = fUseMax ? signalLongMax : signalLongTot;
431 Double_t mipSignalOroc = seed->CookdEdxAnalytical(fLowerTrunc,fUpperTrunc,fUseMax,63,159);
432 Double_t signal = fUseMax ? signalMax : signalTot;
434 fHistQA->Fill(meanP, mipSignalShort, 0);
435 fHistQA->Fill(meanP, mipSignalMed, 1);
436 fHistQA->Fill(meanP, mipSignalLong, 2);
437 fHistQA->Fill(meanP, signal, 3);
438 fHistQA->Fill(meanP, mipSignalOroc, 4);
440 // normalize pad regions to their common mean
442 Float_t meanMax = (63./159)*signalArrayMax[0] + (64./159)*signalArrayMax[1] + (32./159)*signalArrayMax[2];
443 Float_t meanTot = (63./159)*signalArrayTot[0] + (64./159)*signalArrayTot[1] + (32./159)*signalArrayTot[2];
444 //MY SUGGESTION COMMENT NEXT LINE
445 // if (meanMax < 1e-5 || meanTot < 1e-5) continue;
446 //AND INTRODUCE NEW LINE
448 const Double_t kMinAmp=0.001;
449 if (signalArrayMax[0]<=kMinAmp) continue;
450 if (signalArrayMax[1]<=kMinAmp) continue;
451 if (signalArrayMax[2]<=kMinAmp) continue;
452 if (signalArrayTot[0]<=kMinAmp) continue;
453 if (signalArrayTot[1]<=kMinAmp) continue;
454 if (signalArrayTot[2]<=kMinAmp) continue;
456 for(Int_t ipad = 0; ipad < 4; ipad ++) {
457 // "dEdxRatioMax","dEdxRatioTot","padType","mult","driftlength"
458 Double_t vecPadEqual[5] = {signalArrayMax[ipad]/meanMax, signalArrayTot[ipad]/meanTot, ipad, nContributors, dipAngleTgl};
459 if (fMinMomentumMIP > meanP && meanP < fMaxMomentumMIP) fHistPadEqual->Fill(vecPadEqual);
463 if (meanP < fMaxMomentumMIP && meanP > fMinMomentumMIP) {
464 Double_t vecMult[6] = {seed->CookdEdxAnalytical(fLowerTrunc,fUpperTrunc,1,row0,row1)/corrFactorMip,
465 seed->CookdEdxAnalytical(fLowerTrunc,fUpperTrunc,0,row0,row1)/corrFactorMip,
471 fHistGainMult->Fill(vecMult);
472 vecMult[0]=mipSignalShort/corrFactorMip; vecMult[1]=mipSignalShort/corrFactorMip; vecMult[3]=0;
473 fHistGainMult->Fill(vecMult);
474 vecMult[0]=mipSignalMed/corrFactorMip; vecMult[1]=mipSignalMed/corrFactorMip; vecMult[3]=1;
475 fHistGainMult->Fill(vecMult);
476 vecMult[0]=mipSignalLong/corrFactorMip; vecMult[1]=mipSignalLong/corrFactorMip; vecMult[3]=2;
477 fHistGainMult->Fill(vecMult);
479 // topology histogram (absolute)
480 // (0.) weighted dE/dx, (1.) 0:Qtot - 1:Qmax, (2.) tgl, (3.) 1./pT
481 Double_t vecTopolTot[4] = {meanTot, 0, dipAngleTgl, TMath::Abs(track->GetSigned1Pt())};
482 Double_t vecTopolMax[4] = {meanMax, 1, dipAngleTgl, TMath::Abs(track->GetSigned1Pt())};
483 fHistTopology->Fill(vecTopolTot);
484 fHistTopology->Fill(vecTopolMax);
488 if (fMinMomentumMIP < meanP || meanP > fMaxMomentumMIP) continue; // only MIP pions
489 //if (meanP > 0.5 || meanP < 0.4) continue; // only MIP pions
491 // for each track, we look at the three different pad regions, split it into tracklets, check if the sector does not change and fill the histogram
493 Bool_t isNotSplit[3] = {kTRUE, kTRUE, kTRUE}; // short, medium, long (true if the track is not split between two chambers)
495 Double_t sector[4] = {-1, -1, -1, -1}; // sector number short, medium, long, all
496 Int_t ncl[3] = {0,0,0};
499 for (Int_t irow=0; irow < 159; irow++){
501 if (irow > 62) padRegion = 1;
502 if (irow > 126) padRegion = 2;
504 AliTPCclusterMI* cluster = seed->GetClusterPointer(irow);
505 if (!cluster) continue;
506 if (sector[padRegion] == -1) {
507 sector[padRegion] = cluster->GetDetector();
510 if (sector[padRegion] != -1 && sector[padRegion] != cluster->GetDetector()) isNotSplit[padRegion] = kFALSE;
514 // MIP, sect, pad, run
516 Double_t vecMip[5] = {mipSignalShort/corrFactorMip, mipSignalMed/corrFactorMip, mipSignalLong/corrFactorMip, signal/corrFactorMip, mipSignalOroc/corrFactorMip};
518 for(Int_t ipad = 0; ipad < 3; ipad++) {
519 // AK. - run Number To be removed - not needed
520 Double_t vecGainSec[5] = {vecMip[ipad], sector[ipad], ipad, runNumber, ncl[ipad]};
521 if (isNotSplit[ipad]) fHistGainSector->Fill(vecGainSec);
531 void AliTPCcalibGainMult::MakeLookup(THnSparse * /*hist*/, Char_t * /*outputFile*/) {
533 // Not yet implemented
538 void AliTPCcalibGainMult::Analyze() {
548 Long64_t AliTPCcalibGainMult::Merge(TCollection *li) {
550 // merging of the component
553 const Int_t kMaxEntriesSparse=2000000; // MI- temporary - restrict the THnSparse size
554 TIterator* iter = li->MakeIterator();
555 AliTPCcalibGainMult* cal = 0;
557 while ((cal = (AliTPCcalibGainMult*)iter->Next())) {
558 if (!cal->InheritsFrom(AliTPCcalibGainMult::Class())) {
559 Error("Merge","Attempt to add object of class %s to a %s", cal->ClassName(), this->ClassName());
563 if (cal->GetHistNTracks()) fHistNTracks->Add(cal->GetHistNTracks());
564 if (cal->GetHistClusterShape()) fHistClusterShape->Add(cal->GetHistClusterShape());
565 if (cal->GetHistQA()) fHistQA->Add(cal->GetHistQA());
566 if (cal->GetHistGainSector() && fHistGainSector )
568 if ((fHistGainSector->GetEntries()+cal->GetHistGainSector()->GetEntries()) < fgMergeEntriesCut)
570 //AliInfo(Form("fHistGainSector has %.0f tracks, going to add %.0f\n",fHistGainSector->GetEntries(),cal->GetHistGainSector()->GetEntries()));
571 fHistGainSector->Add(cal->GetHistGainSector());
575 AliInfo(Form("fHistGainSector full (has %.0f entries, trying to add %.0f., max allowed: %.0f)",
576 fHistGainSector->GetEntries(),cal->GetHistGainSector()->GetEntries(),fgMergeEntriesCut));
579 if (cal->GetHistPadEqual()) fHistPadEqual->Add(cal->GetHistPadEqual());
580 if (cal->GetHistGainMult()) {
581 if (fHistGainMult->GetEntries()<kMaxEntriesSparse) fHistGainMult->Add(cal->GetHistGainMult());
583 if (cal->GetHistTopology()) {
584 fHistTopology->Add(cal->GetHistTopology());
587 if (cal->fHistdEdxMap){
588 if (fHistdEdxMap) fHistdEdxMap->Add(cal->fHistdEdxMap);
590 if (cal->fHistdEdxMax){
591 if (fHistdEdxMax) fHistdEdxMax->Add(cal->fHistdEdxMax);
593 if (cal->fHistdEdxTot){
594 if (fHistdEdxTot) fHistdEdxTot->Add(cal->fHistdEdxTot);
597 // Originally we tireied to write the tree to the same file as other calibration components
598 // We failed in merging => therefore this optio was disabled
600 // if (cal->fdEdxTree && cal->fdEdxTree->GetEntries()>0) {
602 // const Int_t kMax=100000;
603 // Int_t entriesSum = (Int_t)fdEdxTree->GetEntries();
604 // Int_t entriesCurrent = (Int_t)cal->fdEdxTree->GetEntries();
605 // Int_t entriesCp=TMath::Min((Int_t) entriesCurrent*(kMax*entriesSum),entriesCurrent);
606 // // cal->fdEdxTree->SetBranchStatus("track*",0);
607 // // cal->fdEdxTree->SetBranchStatus("vertex*",0);
608 // // cal->fdEdxTree->SetBranchStatus("tpcOut*",0);
609 // // cal->fdEdxTree->SetBranchStatus("vec*",0);
610 // // fdEdxTree->SetBranchStatus("track*",0);
611 // // fdEdxTree->SetBranchStatus("vertex*",0);
612 // // fdEdxTree->SetBranchStatus("tpcOut*",0);
613 // // fdEdxTree->SetBranchStatus("vec*",0);
614 // fdEdxTree->Print();
615 // fdEdxTree->Dump();
616 // fdEdxTree->GetEntry(0);
617 // for (Int_t i=0; i<entriesCurrent; i++){
618 // cal->fdEdxTree->CopyAddresses(fdEdxTree);
619 // cal->fdEdxTree->GetEntry(i);
620 // fdEdxTree->Fill();
622 // TObjArray *brarray = cal->fdEdxTree->GetListOfBranches();
623 // for (Int_t i=0; i<brarray->GetEntries(); i++) {TBranch * br = (TBranch *)brarray->At(i); br->SetAddress(0); }
626 // fdEdxTree = (TTree*)(cal->fdEdxTree->Clone());
627 // TObjArray *brarray = fdEdxTree->GetListOfBranches();
628 // for (Int_t i=0; i<brarray->GetEntries(); i++) {TBranch * br = (TBranch *)brarray->At(i); br->SetAddress(0);}
642 void AliTPCcalibGainMult::UpdateGainMap() {
644 // read in the old gain map and scale it appropriately...
647 gSystem->Load("libANALYSIS");
648 gSystem->Load("libTPCcalib");
650 TFile jj("Run0_999999999_v1_s0.root");
651 AliTPCCalPad * pad = AliCDBEntry->GetObject()->Clone();
652 TFile hh("output.root");
653 AliTPCcalibGainMult * gain = calibTracksGain;
654 TH2D * histGainSec = gain->GetHistGainSector()->Projection(0,1);
657 histGainSec->FitSlicesY(0, 0, -1, 0, "QNR", &arr);
658 TH1D * meanGainSec = arr->At(1);
659 Double_t gainsIROC[36];
660 Double_t gainsOROC[36];
663 for(Int_t isec = 1; isec < meanGainSec->GetNbinsX() + 1; isec++) {
664 cout << isec << " " << meanGainSec->GetXaxis()->GetBinCenter(isec) << " " <<meanGainSec->GetBinContent(isec) << endl;
665 gains[isec-1] = meanGainSec->GetBinContent(isec);
667 gainsIROC[isec-1] = meanGainSec->GetBinContent(isec);
669 gainsOROC[isec - 36 -1] = meanGainSec->GetBinContent(isec);
672 Double_t meanIroc = TMath::Mean(36, gainsIROC);
673 Double_t meanOroc = TMath::Mean(36, gainsIROC);
674 for(Int_t i = 0; i < 36; i++) gains[i] /= meanIroc;
675 for(Int_t i = 36; i < 72; i++) gains[i] /= meanOroc;
677 for(Int_t i = 0; i < 72; i++) {
678 AliTPCCalROC * chamber = pad->GetCalROC(i);
679 chamber->Multiply(gains[i]);
680 cout << i << " "<< chamber->GetMean() << endl;
685 AliCDBMetaData *metaData= new AliCDBMetaData();
686 metaData->SetObjectClassName("AliTPCCalPad");
687 metaData->SetResponsible("Alexander Kalweit");
688 metaData->SetBeamPeriod(1);
689 metaData->SetAliRootVersion("04-19-05"); //root version
690 metaData->SetComment("New gain map for 1600V OROC gain increase and equalization. Valid for runs starting after technical stop beginning of September.");
691 AliCDBId id1("TPC/Calib/GainFactorDedx", 131541, AliCDBRunRange::Infinity()); // important: new gain runs here..
692 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage("local:///d/alice05/akalweit/projects/OCDBupdate/HighGain_2010-09-03/OCDB/");
693 gStorage->Put(pad, id1, metaData);
698 void AliTPCcalibGainMult::UpdateClusterParam() {
703 gSystem->Load("libANALYSIS");
704 gSystem->Load("libTPCcalib");
706 TFile ff("OldClsParam.root");
707 AliTPCClusterParam * param = AliCDBEntry->GetObject()->Clone();
709 TFile hh("output.root");
710 AliTPCcalibGainMult * gain = calibGainMult;
711 TH2D * histGainSec = gain->GetHistGainSector()->Projection(0,2);
713 histGainSec->FitSlicesY(0, 0, -1, 0, "QNR", &arr);
714 histGainSec->Draw("colz");
715 TH1D * fitVal = arr.At(1);
716 fitVal->Draw("same");
717 param->GetQnormCorrMatrix()->Print();
718 param->GetQnormCorrMatrix()(0,5) *= fitVal->GetBinContent(1)/fitVal->GetBinContent(1); // short pads Qtot
719 param->GetQnormCorrMatrix()(1,5) *= fitVal->GetBinContent(2)/fitVal->GetBinContent(1); // med pads Qtot
720 param->GetQnormCorrMatrix()(2,5) *= fitVal->GetBinContent(3)/fitVal->GetBinContent(1); // long pads Qtot
722 param->GetQnormCorrMatrix()(3,5) *= fitVal->GetBinContent(1)/fitVal->GetBinContent(1); // short pads Qmax -> scaling assumed
723 param->GetQnormCorrMatrix()(4,5) *= fitVal->GetBinContent(2)/fitVal->GetBinContent(1); // med pads Qmax -> scaling assumed
724 param->GetQnormCorrMatrix()(5,5) *= fitVal->GetBinContent(3)/fitVal->GetBinContent(1); // long pads Qmax -> scaling assumed
726 TFile jj("newClusterParam.root","RECREATE");
728 param->GetQnormCorrMatrix()->Print();
732 AliCDBMetaData *metaData= new AliCDBMetaData();
733 metaData->SetObjectClassName("AliTPCClusterParam");
734 metaData->SetResponsible("Alexander Kalweit");
735 metaData->SetBeamPeriod(1);
736 metaData->SetAliRootVersion("04-19-04"); //root version
737 metaData->SetComment("1600V OROC / hard thres. / new algorithm");
738 AliCDBId id1("TPC/Calib/ClusterParam", 0, AliCDBRunRange::Infinity()); // important: new gain runs here..
739 AliCDBStorage * gStorage = AliCDBManager::Instance()->GetStorage("local:///lustre/alice/akalweit/baseline/CalibrationEntries/OldThres_NewAlgo_PP");
740 gStorage->Put(param, id1, metaData);
747 void AliTPCcalibGainMult::DumpTrack(AliESDtrack * track, AliESDfriendTrack *ftrack, AliTPCseed * seed, Int_t index){
749 // dump interesting tracks
750 // 1. track at MIP region
751 // 2. highly ionizing protons
752 // pidType: 0 - unselected
758 const Int_t kMax=10000;
759 const Int_t kMinRows=80;
760 const Double_t kDCAcut=30;
762 // Bethe Bloch paramerization
764 Double_t kp1= 0.0851148;
765 Double_t kp2= 9.25771;
766 Double_t kp3= 2.6558e-05;
767 Double_t kp4= 2.32742;
768 Double_t kp5= 1.83039;
777 static const AliTPCROC *roc = AliTPCROC::Instance();
778 static const TDatabasePDG *pdg = TDatabasePDG::Instance();
780 Int_t nclITS = track->GetNcls(0);
781 Int_t ncl = track->GetTPCncls();
782 Double_t ncl21 = track->GetTPCClusterInfo(3,1);
783 Double_t ncl20 = track->GetTPCClusterInfo(3,0);
786 if (ncl21<kMinRows) return;
787 static Int_t counter=0;
788 static Int_t counterHPT=0;
790 static TH1F *hisBB=new TH1F("hisBB","hisBB",20,0.1,1.00); // bethe bloch histogram =
791 // used to cover more homegenously differnt dEdx regions
792 static Double_t massPi = pdg->GetParticle("pi-")->Mass(); //
793 static Double_t massK = pdg->GetParticle("K-")->Mass();
794 static Double_t massP = pdg->GetParticle("proton")->Mass();
795 static Double_t massE = pdg->GetParticle("e-")->Mass();
796 static Double_t massMuon = pdg->GetParticle("mu-")->Mass();
797 static Double_t radius0= roc->GetPadRowRadiiLow(roc->GetNRows(0)/2);
798 static Double_t radius1= roc->GetPadRowRadiiUp(30);
799 static Double_t radius2= roc->GetPadRowRadiiUp(roc->GetNRows(36)-15);
801 AliESDVertex *vertex= (AliESDVertex *)fCurrentEvent->GetPrimaryVertex();
803 // Estimate current MIP position -
805 static Double_t mipArray[kMax]; // mip array
806 static Int_t counterMIP0=0;
807 static Double_t medianMIP0=100000; // current MIP median position - estimated after some mimnimum number of MIP tracks
809 if (TMath::Abs(track->GetP()-0.5)<0.1&&track->GetTPCsignal()/medianMIP0<1.5){
810 mipArray[counterMIP0%kMax]= track->GetTPCsignal();
812 if (counterMIP0>10) medianMIP0=TMath::Median(counterMIP0%kMax, mipArray);
814 // the PID as defiend from the external sources
816 Int_t isElectron = TMath::Nint((*fPIDMatrix)(index,0));
817 Int_t isMuon = TMath::Nint((*fPIDMatrix)(index,1));
818 Int_t isPion = TMath::Nint((*fPIDMatrix)(index,2));
819 Int_t isKaon = TMath::Nint((*fPIDMatrix)(index,3));
820 Int_t isProton = TMath::Nint((*fPIDMatrix)(index,4));
822 track->GetImpactParameters(dca[0],dca[1]);
824 if ( (isMuon==0 && isElectron==0) && (TMath::Sqrt(dca[0]*dca[0]+dca[1]*dca[1])>kDCAcut) ) return;
825 Double_t normdEdx= track->GetTPCsignal()/(medianMIP0); // TPC signal normalized to the MIP
827 AliExternalTrackParam * trackIn = (AliExternalTrackParam *)track->GetInnerParam();
828 AliExternalTrackParam * trackOut = (AliExternalTrackParam *)track->GetOuterParam();
829 AliExternalTrackParam * tpcOut = (AliExternalTrackParam *)ftrack->GetTPCOut();
830 if (!trackIn) return;
831 if (!trackOut) return;
833 if (trackIn->GetZ()*trackOut->GetZ()<0) return; // remove crossing tracks
835 // calculate local and global angle
836 Int_t side = (trackIn->GetZ()>0)? 1:-1;
837 Double_t tgl=trackIn->GetTgl();
838 Double_t gangle[3]={0,0,0};
839 Double_t langle[3]={0,0,0};
840 Double_t length[3]={0,0,0};
841 Double_t pxpypz[3]={0,0,0};
843 trackIn->GetXYZAt(radius0,bz,pxpypz); // get the global position at the middle of the IROC
844 gangle[0]=TMath::ATan2(pxpypz[1],pxpypz[0]); // global angle IROC
845 trackIn->GetXYZAt(radius1,bz,pxpypz); // get the global position at the middle of the OROC - medium pads
846 gangle[1]=TMath::ATan2(pxpypz[1],pxpypz[0]); // global angle OROC
847 trackOut->GetXYZAt(radius2,bz,pxpypz); // get the global position at the middle of OROC - long pads
848 gangle[2]=TMath::ATan2(pxpypz[1],pxpypz[0]);
850 trackIn->GetPxPyPzAt(radius0,bz,pxpypz); //get momentum vector
851 langle[0]=TMath::ATan2(pxpypz[1],pxpypz[0])-gangle[0]; //local angle between padrow and track IROC
852 trackIn->GetPxPyPzAt(radius1,bz,pxpypz);
853 langle[1]=TMath::ATan2(pxpypz[1],pxpypz[0])-gangle[1];
854 trackOut->GetPxPyPzAt(radius2,bz,pxpypz); // OROC medium
855 langle[2]=TMath::ATan2(pxpypz[1],pxpypz[0])-gangle[2];
856 for (Int_t i=0; i<3; i++){
857 if (langle[i]>TMath::Pi()) langle[i]-=TMath::TwoPi();
858 if (langle[i]<-TMath::Pi()) langle[i]+=TMath::TwoPi();
859 length[i]=TMath::Sqrt(1+langle[i]*langle[i]+tgl*tgl); // the tracklet length
862 // Select the kaons and Protons which are "isolated" in TPC dedx curve
865 Double_t dedxP = AliExternalTrackParam::BetheBlochAleph(track->GetInnerParam()->GetP()/massP,kp1,kp2,kp3,kp4,kp5);
866 Double_t dedxK = AliExternalTrackParam::BetheBlochAleph(track->GetInnerParam()->GetP()/massK,kp1,kp2,kp3,kp4,kp5);
867 if (dedxP>2 || dedxK>2){
868 if (track->GetP()<1.2 && normdEdx>1.8&&counterMIP0>10){ // not enough from TOF and V0s triggered by high dedx
869 // signing the Proton and kaon - using the "bitmask" bit 1 and 2 is dedicated for V0s and TOF selected
870 if ( TMath::Abs(normdEdx/dedxP-1)<0.3) isProton+=4;
871 if ( TMath::Abs(normdEdx/dedxK-1)<0.3) isKaon+=4;
872 if (normdEdx/dedxK>1.3) isProton+=8;
873 if (normdEdx/dedxP<0.7) isKaon+=8;
880 Bool_t isHighPt = ((TMath::Power(1/track->Pt(),4)*gRandom->Rndm())<0.005); // rnadomly selected HPT tracks
881 // there are selected for the QA of the obtained calibration
882 Bool_t isMIP = TMath::Abs(track->GetInnerParam()->P()-0.4)<0.005&&(counter<kMax); //
883 // REMINDER - it is not exactly MIP - we select the regtion where the Kaon and Electrons are well separated
885 if (isElectron>0) mass = massE;
886 if (isProton>0) mass = massP;
887 if (isKaon>0) mass = massK;
888 if (isMuon>0) mass = massMuon;
889 if (isPion>0) mass = massPi;
890 if (isHighPt) mass = massPi; //assign mass of pions
891 if (isMIP&&track->GetTPCsignal()/medianMIP0<1.5) mass = massPi; //assign mass of pions
894 // calculate expected dEdx
896 Double_t dedxDefPion= 0,dedxDefProton=0, dedxDefKaon=0;
897 Double_t pin=trackIn->GetP();
898 Double_t pout=trackOut->GetP();
899 Double_t p=(pin+pout)*0.5; // momenta as the mean between tpc momenta at inner and outer wall of the TPC
900 if (mass>0) dedxDef = AliExternalTrackParam::BetheBlochAleph(p/mass,kp1,kp2,kp3,kp4,kp5);
901 dedxDefPion = AliExternalTrackParam::BetheBlochAleph(p/massPi,kp1,kp2,kp3,kp4,kp5);
902 dedxDefProton = AliExternalTrackParam::BetheBlochAleph(p/massP,kp1,kp2,kp3,kp4,kp5);
903 dedxDefKaon = AliExternalTrackParam::BetheBlochAleph(p/massK,kp1,kp2,kp3,kp4,kp5);
905 // dEdx Truncated mean vectros with differnt tuncation
906 // 11 truncations array - 0-10 - 0~50% 11=100%
907 // 3 Regions - IROC,OROC0, OROC1
908 // 2 Q - total charge and max charge
909 // Log - Logarithmic mean used
910 // Up/Dwon - Upper half or lower half of truncation used
911 // RMS - rms of the distribction (otherwise truncated mean)
912 // M2 suffix - second moment ( truncated)
913 TVectorF truncUp(11);
914 TVectorF truncDown(11);
915 TVectorF vecAllMax(11);
916 TVectorF vecIROCMax(11);
917 TVectorF vecOROCMax(11);
918 TVectorF vecOROC0Max(11);
919 TVectorF vecOROC1Max(11);
921 TVectorF vecAllTot(11);
922 TVectorF vecIROCTot(11);
923 TVectorF vecOROCTot(11);
924 TVectorF vecOROC0Tot(11);
925 TVectorF vecOROC1Tot(11);
927 TVectorF vecAllTotLog(11);
928 TVectorF vecIROCTotLog(11);
929 TVectorF vecOROCTotLog(11);
930 TVectorF vecOROC0TotLog(11);
931 TVectorF vecOROC1TotLog(11);
933 TVectorF vecAllTotUp(11);
934 TVectorF vecIROCTotUp(11);
935 TVectorF vecOROCTotUp(11);
936 TVectorF vecOROC0TotUp(11);
937 TVectorF vecOROC1TotUp(11);
939 TVectorF vecAllTotDown(11);
940 TVectorF vecIROCTotDown(11);
941 TVectorF vecOROCTotDown(11);
942 TVectorF vecOROC0TotDown(11);
943 TVectorF vecOROC1TotDown(11);
945 TVectorF vecAllTotRMS(11);
946 TVectorF vecIROCTotRMS(11);
947 TVectorF vecOROCTotRMS(11);
948 TVectorF vecOROC0TotRMS(11);
949 TVectorF vecOROC1TotRMS(11);
951 TVectorF vecAllTotM2(11);
952 TVectorF vecIROCTotM2(11);
953 TVectorF vecOROCTotM2(11);
954 TVectorF vecOROC0TotM2(11);
955 TVectorF vecOROC1TotM2(11);
957 TVectorF vecAllTotMS(11);
958 TVectorF vecIROCTotMS(11);
959 TVectorF vecOROCTotMS(11);
960 TVectorF vecOROC0TotMS(11);
961 TVectorF vecOROC1TotMS(11);
963 // Differnt number of clusters definitions - in separate regions of the TPC
964 // 20 - ratio - found/findabel
965 // 21 - number of clusters used for given dEdx calculation
967 // suffix - 3 or 4 - number of padrows before and after given row to define findable row
969 Double_t ncl20All = seed->CookdEdxAnalytical(0.0,1, 1 ,0,159,3);
970 Double_t ncl20IROC = seed->CookdEdxAnalytical(0.,1, 1 ,0,63,3);
971 Double_t ncl20OROC = seed->CookdEdxAnalytical(0.,1, 1 ,64,159,3);
972 Double_t ncl20OROC0= seed->CookdEdxAnalytical(0.,1, 1 ,64,128,3);
973 Double_t ncl20OROC1= seed->CookdEdxAnalytical(0.,1, 1 ,129,159,3);
975 Double_t ncl20All4 = seed->CookdEdxAnalytical(0.0,1, 1 ,0,159,3,4);
976 Double_t ncl20IROC4 = seed->CookdEdxAnalytical(0.,1, 1 ,0,63,3,4);
977 Double_t ncl20OROC4 = seed->CookdEdxAnalytical(0.,1, 1 ,64,159,3,4);
978 Double_t ncl20OROC04= seed->CookdEdxAnalytical(0.,1, 1 ,64,128,3,4);
979 Double_t ncl20OROC14= seed->CookdEdxAnalytical(0.,1, 1 ,129,159,3,4);
981 Double_t ncl20All3 = seed->CookdEdxAnalytical(0.0,1, 1 ,0,159,3,3);
982 Double_t ncl20IROC3 = seed->CookdEdxAnalytical(0.,1, 1 ,0,63,3,3);
983 Double_t ncl20OROC3 = seed->CookdEdxAnalytical(0.,1, 1 ,64,159,3,3);
984 Double_t ncl20OROC03= seed->CookdEdxAnalytical(0.,1, 1 ,64,128,3,3);
985 Double_t ncl20OROC13= seed->CookdEdxAnalytical(0.,1, 1 ,129,159,3,3);
987 Double_t ncl21All = seed->CookdEdxAnalytical(0.0,1, 1 ,0,159,2);
988 Double_t ncl21IROC = seed->CookdEdxAnalytical(0.,1, 1 ,0,63,2);
989 Double_t ncl21OROC = seed->CookdEdxAnalytical(0.,1, 1 ,64,159,2);
990 Double_t ncl21OROC0= seed->CookdEdxAnalytical(0.,1, 1 ,64,128,2);
991 Double_t ncl21OROC1= seed->CookdEdxAnalytical(0.,1, 1 ,129,159,2);
992 // calculate truncated dEdx - mean rms M2 ...
994 for (Int_t ifracDown=0; ifracDown<1; ifracDown++){
995 for (Int_t ifracUp=0; ifracUp<11; ifracUp++){
996 Double_t fracDown = 0.0+Double_t(ifracDown)*0.05;
997 Double_t fracUp = 0.5+Double_t(ifracUp)*0.05;
998 vecAllMax[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 1 ,0,159,0);
999 vecIROCMax[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 1 ,0,63,0);
1000 vecOROCMax[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 1 ,64,159,0);
1001 vecOROC0Max[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 1 ,64,128,0);
1002 vecOROC1Max[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 1 ,129,159,0);
1004 vecAllTot[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,0,159,0);
1005 vecIROCTot[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,0,63,0);
1006 vecOROCTot[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,64,159,0);
1007 vecOROC0Tot[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,64,128,0);
1008 vecOROC1Tot[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,129,159,0);
1010 vecAllTotLog[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,0,159,0,2,1);
1011 vecIROCTotLog[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,0,63,0,2,1);
1012 vecOROCTotLog[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,64,159,0,2,1);
1013 vecOROC0TotLog[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,64,128,0,2,1);
1014 vecOROC1TotLog[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,129,159,0,2,1);
1016 vecAllTotUp[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,0,159,4,2,1);
1017 vecIROCTotUp[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,0,63,4,2,1);
1018 vecOROCTotUp[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,64,159,4,2,1);
1019 vecOROC0TotUp[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,64,128,4,2,1);
1020 vecOROC1TotUp[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,129,159,4,2,1);
1022 vecAllTotDown[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,0,159,5,2,1);
1023 vecIROCTotDown[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,0,63,5,2,1);
1024 vecOROCTotDown[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,64,159,5,2,1);
1025 vecOROC0TotDown[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,64,128,5,2,1);
1026 vecOROC1TotDown[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,129,159,5,2,1);
1028 vecAllTotRMS[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,0,159,1,2,0);
1029 vecIROCTotRMS[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,0,63,1,2,0);
1030 vecOROCTotRMS[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,64,159,1,2,0);
1031 vecOROC0TotRMS[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,64,128,1,2,0);
1032 vecOROC1TotRMS[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,129,159,1,2,0);
1034 vecAllTotM2[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,0,159,6,2,1);
1035 vecIROCTotM2[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,0,63,6,2,1);
1036 vecOROCTotM2[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,64,159,6,2,1);
1037 vecOROC0TotM2[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,64,128,6,2,1);
1038 vecOROC1TotM2[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,129,159,6,2,1);
1040 vecAllTotMS[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,0,159,8,2,1);
1041 vecIROCTotMS[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,0,63,8,2,1);
1042 vecOROCTotMS[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,64,159,8,2,1);
1043 vecOROC0TotMS[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,64,128,8,2,1);
1044 vecOROC1TotMS[ifrac]= seed->CookdEdxAnalytical(fracDown,fracUp, 0 ,129,159,8,2,1);
1045 truncUp[ifrac]=fracUp;
1046 truncDown[ifrac]=fracDown;
1053 if (((isKaon||isProton||isPion||isElectron||isMIP||isMuon)&&(!isHighPt)) && dedxDef>0) {
1055 Int_t ncont = vertex->GetNContributors();
1056 for (Int_t ipad=0; ipad<3; ipad++){
1057 // histogram with enahanced phi granularity - to make gain phi maps
1058 Double_t xxx[4]={0,gangle[ipad],1./dedxDef,ipad*2+((side>0)?0:1)};
1060 if (ipad==0) {xxx[0]=vecIROCTot[4]/medianMIP0; nclR=ncl21IROC/63.;}
1061 if (ipad==1) {xxx[0]=vecOROC0Tot[4]/medianMIP0;nclR=ncl21OROC0/63.;}
1062 if (ipad==2) {xxx[0]=vecOROC1Tot[4]/medianMIP0;nclR=ncl21OROC1/32.;}
1064 if (xxx[0]>0) xxx[0]=1./xxx[0];
1065 if (TMath::Abs(langle[ipad])<0.25&&nclR>0.4) fHistdEdxMap->Fill(xxx);
1067 for (Int_t ipad=0; ipad<3; ipad++){
1069 // this are histogram to define overall main gain correction
1070 // Maybe dead end - we can not put all info which can be used into the THnSparse
1071 // It is keeped there for educational point of view
1073 Double_t xxx[6]={0,1./dedxDef, TMath::Abs(langle[ipad]), TMath::Abs(tgl), ncont, ipad };
1074 if (ipad==0) {xxx[0]=vecIROCTot[4]/medianMIP0;}
1075 if (ipad==1) {xxx[0]=vecOROC0Tot[4]/medianMIP0;}
1076 if (ipad==2) {xxx[0]=vecOROC1Tot[4]/medianMIP0;}
1078 if (xxx[0]>0) xxx[0]=1./xxx[0];
1079 if (xxx[0]>0) fHistdEdxTot->Fill(xxx);
1080 if (ipad==0) {xxx[0]=vecIROCMax[4]/medianMIP0;}
1081 if (ipad==1) {xxx[0]=vecOROC0Max[4]/medianMIP0;}
1082 if (ipad==2) {xxx[0]=vecOROC1Max[4]/medianMIP0;}
1084 if (xxx[0]>0) xxx[0]=1./xxx[0];
1085 fHistdEdxMax->Fill(xxx);
1089 // Downscale selected tracks before filling the tree
1091 Bool_t isSelected = kFALSE;
1093 if (isKaon||isProton||isPion||isElectron||isMIP||isMuon) isSelected=kTRUE;
1095 if (!isSelected) isHighPt = ((TMath::Power(1/track->Pt(),4)*gRandom->Rndm())<0.005);
1096 //if (counter>kMax && ((1/track->Pt()*gRandom->Rndm())>kMax/counter)) return;
1097 isSelected|=isHighPt;
1101 // Equalize statistic in BB bins - special care about pions
1102 Int_t entriesBB = (Int_t)hisBB->GetEntries();
1103 if ((isElectron==0 &&isMuon==0 && p<2.) && entriesBB>20 &&dedxDef>0.01){
1104 Int_t bin = hisBB->GetXaxis()->FindBin(1./dedxDef);
1105 Double_t cont = hisBB->GetBinContent(bin);
1106 Double_t mean =(entriesBB)/20.;
1107 if ((isPion>0) && gRandom->Rndm()*cont > 0.1*mean) return;
1108 if ((isPion==0) && gRandom->Rndm()*cont > 0.25*mean) return;
1110 if (!isSelected) return;
1111 if (dedxDef>0.01) hisBB->Fill(1./dedxDef);
1113 if (isHighPt) counterHPT++;
1116 TTreeSRedirector * pcstream = GetDebugStreamer();
1117 Double_t ptrel0 = AliTPCcalibDB::GetPTRelative(fTime,fRun,0);
1118 Double_t ptrel1 = AliTPCcalibDB::GetPTRelative(fTime,fRun,1);
1119 Int_t sectorIn = Int_t(18+9*(trackIn->GetAlpha()/TMath::Pi()))%18;
1120 Int_t sectorOut = Int_t(18+9*(trackOut->GetAlpha()/TMath::Pi()))%18;
1123 (*pcstream)<<"dump"<<
1124 "vertex.="<<vertex<<
1128 "sectorIn="<<sectorIn<<
1129 "sectorOut="<<sectorOut<<
1133 "isProton="<<isProton<<
1136 "isElectron="<<isElectron<<
1138 "isHighPt="<<isHighPt<<
1140 "dedxDef="<<dedxDef<<
1141 "dedxDefPion="<<dedxDefPion<<
1142 "dedxDefKaon="<<dedxDefKaon<<
1143 "dedxDefProton="<<dedxDefProton<<
1150 "ncl20All="<<ncl20All<<
1151 "ncl20OROC="<<ncl20OROC<<
1152 "ncl20IROC="<<ncl20IROC<<
1153 "ncl20OROC0="<<ncl20OROC0<<
1154 "ncl20OROC1="<<ncl20OROC1<<
1156 "ncl20All4="<<ncl20All4<<
1157 "ncl20OROC4="<<ncl20OROC4<<
1158 "ncl20IROC4="<<ncl20IROC4<<
1159 "ncl20OROC04="<<ncl20OROC04<<
1160 "ncl20OROC14="<<ncl20OROC14<<
1162 "ncl20All3="<<ncl20All3<<
1163 "ncl20OROC3="<<ncl20OROC3<<
1164 "ncl20IROC3="<<ncl20IROC3<<
1165 "ncl20OROC03="<<ncl20OROC03<<
1166 "ncl20OROC13="<<ncl20OROC13<<
1168 "ncl21All="<<ncl21All<<
1169 "ncl21OROC="<<ncl21OROC<<
1170 "ncl21IROC="<<ncl21IROC<<
1171 "ncl21OROC0="<<ncl21OROC0<<
1172 "ncl21OROC1="<<ncl21OROC1<<
1174 "langle0="<<langle[0]<<
1175 "langle1="<<langle[1]<<
1176 "langle2="<<langle[2]<<
1177 "gangle0="<<gangle[0]<< //global angle phi IROC
1178 "gangle1="<<gangle[1]<< // OROC medium
1179 "gangle2="<<gangle[2]<< // OROC long
1188 //"trackIn.="<<trackIn<<
1189 //"trackOut.="<<trackOut<<
1190 //"tpcOut.="<<tpcOut<<
1192 "medianMIP0="<<medianMIP0<< // median MIP position as estimated from the array of (not only) "MIPS"
1194 "truncUp.="<<&truncUp<<
1195 "truncDown.="<<&truncDown<<
1196 "vecAllMax.="<<&vecAllMax<<
1197 "vecIROCMax.="<<&vecIROCMax<<
1198 "vecOROCMax.="<<&vecOROCMax<<
1199 "vecOROC0Max.="<<&vecOROC0Max<<
1200 "vecOROC1Max.="<<&vecOROC1Max<<
1202 "vecAllTot.="<<&vecAllTot<<
1203 "vecIROCTot.="<<&vecIROCTot<<
1204 "vecOROCTot.="<<&vecOROCTot<<
1205 "vecOROC0Tot.="<<&vecOROC0Tot<<
1206 "vecOROC1Tot.="<<&vecOROC1Tot<<
1208 "vecAllTotLog.="<<&vecAllTotLog<<
1209 "vecIROCTotLog.="<<&vecIROCTotLog<<
1210 "vecOROCTotLog.="<<&vecOROCTotLog<<
1211 "vecOROC0TotLog.="<<&vecOROC0TotLog<<
1212 "vecOROC1TotLog.="<<&vecOROC1TotLog<<
1214 "vecAllTotUp.="<<&vecAllTotUp<<
1215 "vecIROCTotUp.="<<&vecIROCTotUp<<
1216 "vecOROCTotUp.="<<&vecOROCTotUp<<
1217 "vecOROC0TotUp.="<<&vecOROC0TotUp<<
1218 "vecOROC1TotUp.="<<&vecOROC1TotUp<<
1220 "vecAllTotDown.="<<&vecAllTotDown<<
1221 "vecIROCTotDown.="<<&vecIROCTotDown<<
1222 "vecOROCTotDown.="<<&vecOROCTotDown<<
1223 "vecOROC0TotDown.="<<&vecOROC0TotDown<<
1224 "vecOROC1TotDown.="<<&vecOROC1TotDown<<
1226 "vecAllTotRMS.="<<&vecAllTotRMS<<
1227 "vecIROCTotRMS.="<<&vecIROCTotRMS<<
1228 "vecOROCTotRMS.="<<&vecOROCTotRMS<<
1229 "vecOROC0TotRMS.="<<&vecOROC0TotRMS<<
1230 "vecOROC1TotRMS.="<<&vecOROC1TotRMS<<
1232 "vecAllTotM2.="<<&vecAllTotM2<<
1233 "vecIROCTotM2.="<<&vecIROCTotM2<<
1234 "vecOROCTotM2.="<<&vecOROCTotM2<<
1235 "vecOROC0TotM2.="<<&vecOROC0TotM2<<
1236 "vecOROC1TotM2.="<<&vecOROC1TotM2<<
1238 "vecAllTotMS.="<<&vecAllTotMS<<
1239 "vecIROCTotMS.="<<&vecIROCTotMS<<
1240 "vecOROCTotMS.="<<&vecOROCTotMS<<
1241 "vecOROC0TotMS.="<<&vecOROC0TotMS<<
1242 "vecOROC1TotMS.="<<&vecOROC1TotMS<<
1250 void AliTPCcalibGainMult::ProcessV0s(AliESDEvent * event){
1252 // Select the K0s and gamma - and sign daughter products
1254 TTreeSRedirector * pcstream = GetDebugStreamer();
1255 AliKFParticle::SetField(event->GetMagneticField());
1256 AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
1258 //Printf("ERROR: esdFriend not available");
1261 if (esdFriend->TestSkipBit()) return;
1264 static const TDatabasePDG *pdg = TDatabasePDG::Instance();
1265 const Double_t kChi2Cut=5;
1266 const Double_t kMinR=2;
1267 const Int_t kMinNcl=110;
1268 const Double_t kMinREl=5;
1269 const Double_t kMaxREl=70;
1271 Int_t nv0 = event->GetNumberOfV0s();
1272 AliESDVertex *vertex= (AliESDVertex *)event->GetPrimaryVertex();
1273 AliKFVertex kfvertex=*vertex;
1275 for (Int_t iv0=0;iv0<nv0;iv0++){
1276 AliESDv0 *v0 = event->GetV0(iv0);
1278 if (v0->GetOnFlyStatus()<0.5) continue;
1279 if (v0->GetPindex()<0) continue;
1280 if (v0->GetNindex()<0) continue;
1281 if (TMath::Max(v0->GetPindex(), v0->GetNindex())>event->GetNumberOfTracks()) continue;
1284 AliExternalTrackParam pp=(v0->GetParamP()->GetSign()>0) ? (*(v0->GetParamP())):(*(v0->GetParamN()));
1285 AliExternalTrackParam pn=(v0->GetParamP()->GetSign()>0) ? (*(v0->GetParamN())):(*(v0->GetParamP()));
1286 AliKFParticle kfp1( pp, 211 );
1287 AliKFParticle kfp2( pn, -211 );
1289 AliKFParticle *v0KFK0 = new AliKFParticle(kfp1,kfp2);
1290 AliKFParticle *v0KFK0CV = new AliKFParticle(*v0KFK0);
1291 v0KFK0CV->SetProductionVertex(kfvertex);
1292 v0KFK0CV->TransportToProductionVertex();
1293 Double_t chi2K0 = v0KFK0CV->GetChi2();
1294 if (chi2K0>kChi2Cut) continue;
1295 if (v0->GetRr()<kMinR) continue;
1296 Bool_t isOKC=TMath::Max(v0->GetCausalityP()[0],v0->GetCausalityP()[1])<0.7&&TMath::Min(v0->GetCausalityP()[2],v0->GetCausalityP()[3])>0.2;
1298 Double_t effMass22=v0->GetEffMass(2,2);
1299 Double_t effMass42=v0->GetEffMass(4,2);
1300 Double_t effMass24=v0->GetEffMass(2,4);
1301 Double_t effMass00=v0->GetEffMass(0,0);
1302 AliKFParticle *v0KFK0CVM = new AliKFParticle(*v0KFK0CV);
1303 v0KFK0CVM->SetMassConstraint(pdg->GetParticle("K_S0")->Mass());
1304 Bool_t isV0= kFALSE;
1306 Double_t d22 = TMath::Abs(effMass22-pdg->GetParticle("K_S0")->Mass());
1307 Double_t d42 = TMath::Abs(effMass42-pdg->GetParticle("Lambda0")->Mass());
1308 Double_t d24 = TMath::Abs(effMass24-pdg->GetParticle("Lambda0")->Mass());
1309 Double_t d00 = TMath::Abs(effMass00);
1311 Bool_t isKaon = d22<0.01 && d22< 0.3 * TMath::Min(TMath::Min(d42,d24),d00);
1312 Bool_t isLambda = d42<0.01 && d42< 0.3 * TMath::Min(TMath::Min(d22,d24),d00);
1313 Bool_t isAntiLambda= d24<0.01 && d24< 0.3 * TMath::Min(TMath::Min(d22,d42),d00);
1314 Bool_t isGamma = d00<0.02 && d00< 0.3 * TMath::Min(TMath::Min(d42,d24),d22);
1316 if (isGamma && (isKaon||isLambda||isAntiLambda)) continue;
1317 if (isLambda && (isKaon||isGamma||isAntiLambda)) continue;
1318 if (isKaon && (isLambda||isGamma||isAntiLambda)) continue;
1319 Double_t sign= v0->GetParamP()->GetSign()* v0->GetParamN()->GetSign();
1320 if (sign>0) continue;
1321 isV0=isKaon||isLambda||isAntiLambda||isGamma;
1322 if (!(isV0)) continue;
1323 if (isGamma&&v0->GetRr()<kMinREl) continue;
1324 if (isGamma&&v0->GetRr()>kMaxREl) continue;
1325 if (!isOKC) continue;
1327 Int_t pindex = (v0->GetParamP()->GetSign()>0) ? v0->GetPindex() : v0->GetNindex();
1328 Int_t nindex = (v0->GetParamP()->GetSign()>0) ? v0->GetNindex() : v0->GetPindex();
1329 AliESDtrack * trackP = event->GetTrack(pindex);
1330 AliESDtrack * trackN = event->GetTrack(nindex);
1331 if (!trackN) continue;
1332 if (!trackP) continue;
1333 Int_t nclP= (Int_t)trackP->GetTPCClusterInfo(2,1);
1334 Int_t nclN= (Int_t)trackN->GetTPCClusterInfo(2,1);
1335 if (TMath::Min(nclP,nclN)<kMinNcl) continue;
1336 Double_t eta = TMath::Max(TMath::Abs(trackP->Eta()), TMath::Abs(trackN->Eta()));
1337 if (TMath::Abs(eta)>1) continue;
1340 AliESDfriendTrack *friendTrackP = esdFriend->GetTrack(pindex);
1341 AliESDfriendTrack *friendTrackN = esdFriend->GetTrack(nindex);
1342 if (!friendTrackP) continue;
1343 if (!friendTrackN) continue;
1344 TObject *calibObject;
1345 AliTPCseed *seedP = 0;
1346 AliTPCseed *seedN = 0;
1347 for (Int_t l=0;(calibObject=friendTrackP->GetCalibObject(l));++l) {
1348 if ((seedP=dynamic_cast<AliTPCseed*>(calibObject))) break;
1350 for (Int_t l=0;(calibObject=friendTrackN->GetCalibObject(l));++l) {
1351 if ((seedN=dynamic_cast<AliTPCseed*>(calibObject))) break;
1354 if ( TMath::Abs((trackP->GetTPCsignal()/(trackN->GetTPCsignal()+0.0001)-1)>0.3)) continue;
1356 if (isGamma) (*fPIDMatrix)(pindex, 0)+=2;
1357 if (isGamma) (*fPIDMatrix)(nindex, 0)+=2;
1359 if (isKaon) (*fPIDMatrix)(pindex, 2)+=2;
1360 if (isKaon) (*fPIDMatrix)(nindex, 2)+=2;
1364 (*pcstream)<<"v0s"<<
1365 "isGamma="<<isGamma<<
1367 "isLambda="<<isLambda<<
1368 "isAntiLambda="<<isAntiLambda<<
1370 "trackP.="<<trackP<<
1371 "trackN.="<<trackN<<
1381 void AliTPCcalibGainMult::ProcessCosmic(const AliESDEvent * event) {
1383 // Find cosmic pairs trigger by random trigger
1386 AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
1387 AliTPCParam *param = AliTPCcalibDB::Instance()->GetParameters();
1389 AliESDVertex *vertexSPD = (AliESDVertex *)event->GetPrimaryVertexSPD();
1390 AliESDVertex *vertexTPC = (AliESDVertex *)event->GetPrimaryVertexTPC();
1391 AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
1392 const Double_t kMinPt=4;
1393 const Double_t kMinPtMax=0.8;
1394 const Double_t kMinNcl=159*0.5;
1395 const Double_t kMaxDelta[5]={2,600,0.02,0.02,0.1};
1396 Int_t ntracks=event->GetNumberOfTracks();
1397 const Double_t kMaxImpact=80;
1398 // Float_t dcaTPC[2]={0,0};
1399 // Float_t covTPC[3]={0,0,0};
1401 UInt_t specie = event->GetEventSpecie(); // skip laser events
1402 if (specie==AliRecoParam::kCalib) return;
1405 for (Int_t itrack0=0;itrack0<ntracks;itrack0++) {
1406 AliESDtrack *track0 = event->GetTrack(itrack0);
1407 if (!track0) continue;
1408 if (!track0->IsOn(AliESDtrack::kTPCrefit)) continue;
1410 if (TMath::Abs(AliTracker::GetBz())>1&&track0->Pt()<kMinPt) continue;
1411 if (track0->GetTPCncls()<kMinNcl) continue;
1412 if (TMath::Abs(track0->GetY())<2*kMaxDelta[0]) continue;
1413 if (TMath::Abs(track0->GetY())>kMaxImpact) continue;
1414 if (track0->GetKinkIndex(0)>0) continue;
1415 const Double_t * par0=track0->GetParameter(); //track param at rhe DCA
1418 for (Int_t itrack1=itrack0+1;itrack1<ntracks;itrack1++) {
1419 AliESDtrack *track1 = event->GetTrack(itrack1);
1420 if (!track1) continue;
1421 if (!track1->IsOn(AliESDtrack::kTPCrefit)) continue;
1422 if (track1->GetKinkIndex(0)>0) continue;
1423 if (TMath::Abs(AliTracker::GetBz())>1&&track1->Pt()<kMinPt) continue;
1424 if (track1->GetTPCncls()<kMinNcl) continue;
1425 if (TMath::Abs(AliTracker::GetBz())>1&&TMath::Max(track1->Pt(), track0->Pt())<kMinPtMax) continue;
1426 if (TMath::Abs(track1->GetY())<2*kMaxDelta[0]) continue;
1427 if (TMath::Abs(track1->GetY())>kMaxImpact) continue;
1429 const Double_t* par1=track1->GetParameter(); //track param at rhe DCA
1431 Bool_t isPair=kTRUE;
1432 for (Int_t ipar=0; ipar<5; ipar++){
1433 if (ipar==4&&TMath::Abs(AliTracker::GetBz())<1) continue; // 1/pt not defined for B field off
1434 if (TMath::Abs(TMath::Abs(par0[ipar])-TMath::Abs(par1[ipar]))>kMaxDelta[ipar]) isPair=kFALSE;
1436 if (!isPair) continue;
1437 if (TMath::Abs(TMath::Abs(track0->GetAlpha()-track1->GetAlpha())-TMath::Pi())>kMaxDelta[2]) isPair=kFALSE;
1438 //delta with correct sign
1439 if (TMath::Abs(par0[0]+par1[0])>kMaxDelta[0]) isPair=kFALSE; //delta y opposite sign
1440 if (TMath::Abs(par0[3]+par1[3])>kMaxDelta[3]) isPair=kFALSE; //delta tgl opposite sign
1441 if (TMath::Abs(AliTracker::GetBz())>1 && TMath::Abs(par0[4]+par1[4])>kMaxDelta[4]) isPair=kFALSE; //delta 1/pt opposite sign
1442 if (!isPair) continue;
1443 TString filename(AliAnalysisManager::GetAnalysisManager()->GetTree()->GetCurrentFile()->GetName());
1444 Int_t eventNumber = event->GetEventNumberInFile();
1445 Bool_t hasFriend=(esdFriend) ? (esdFriend->GetTrack(itrack0)!=0):0;
1446 Bool_t hasITS=(track0->GetNcls(0)+track1->GetNcls(0)>4);
1447 AliInfo(Form("DUMPHPTCosmic:%s|%f|%d|%d|%d\n",filename.Data(),(TMath::Min(track0->Pt(),track1->Pt())), eventNumber,hasFriend,hasITS));
1450 TTreeSRedirector * pcstream = GetDebugStreamer();
1451 Int_t ntracksSPD = vertexSPD->GetNContributors();
1452 Int_t ntracksTPC = vertexTPC->GetNContributors();
1455 (*pcstream)<<"cosmicPairsAll"<<
1456 "run="<<fRun<< // run number
1457 "event="<<fEvent<< // event number
1458 "time="<<fTime<< // time stamp of event
1459 "trigger="<<fTrigger<< // trigger
1460 "triggerClass="<<&fTriggerClass<< // trigger
1461 "bz="<<fMagF<< // magnetic field
1463 "nSPD="<<ntracksSPD<<
1464 "nTPC="<<ntracksTPC<<
1465 "vSPD.="<<vertexSPD<< //primary vertex -SPD
1466 "vTPC.="<<vertexTPC<< //primary vertex -TPC
1467 "t0.="<<track0<< //track0
1468 "t1.="<<track1<< //track1
1472 AliESDfriendTrack *friendTrack0 = esdFriend->GetTrack(itrack0);
1473 if (!friendTrack0) continue;
1474 AliESDfriendTrack *friendTrack1 = esdFriend->GetTrack(itrack1);
1475 if (!friendTrack1) continue;
1476 TObject *calibObject;
1477 AliTPCseed *seed0 = 0;
1478 AliTPCseed *seed1 = 0;
1480 for (Int_t l=0;(calibObject=friendTrack0->GetCalibObject(l));++l) {
1481 if ((seed0=dynamic_cast<AliTPCseed*>(calibObject))) break;
1483 for (Int_t l=0;(calibObject=friendTrack1->GetCalibObject(l));++l) {
1484 if ((seed1=dynamic_cast<AliTPCseed*>(calibObject))) break;
1488 (*pcstream)<<"cosmicPairs"<<
1489 "run="<<fRun<< // run number
1490 "event="<<fEvent<< // event number
1491 "time="<<fTime<< // time stamp of event
1492 "trigger="<<fTrigger<< // trigger
1493 "triggerClass="<<&fTriggerClass<< // trigger
1494 "bz="<<fMagF<< // magnetic field
1496 "nSPD="<<ntracksSPD<<
1497 "nTPC="<<ntracksTPC<<
1498 "vSPD.="<<vertexSPD<< //primary vertex -SPD
1499 "vTPC.="<<vertexTPC<< //primary vertex -TPC
1500 "t0.="<<track0<< //track0
1501 "t1.="<<track1<< //track1
1502 "ft0.="<<friendTrack0<< //track0
1503 "ft1.="<<friendTrack1<< //track1
1504 "s0.="<<seed0<< //track0
1505 "s1.="<<seed1<< //track1
1508 if (!seed0) continue;
1509 if (!seed1) continue;
1510 Int_t nclA0=0, nclC0=0; // number of clusters
1511 Int_t nclA1=0, nclC1=0; // number of clusters
1513 for (Int_t irow=0; irow<159; irow++){
1514 AliTPCclusterMI *cluster0=seed0->GetClusterPointer(irow);
1515 AliTPCclusterMI *cluster1=seed1->GetClusterPointer(irow);
1517 if (cluster0->GetQ()>0 && cluster0->GetDetector()%36<18) nclA0++;
1518 if (cluster0->GetQ()>0 && cluster0->GetDetector()%36>=18) nclC0++;
1521 if (cluster1->GetQ()>0 && cluster1->GetDetector()%36<18) nclA1++;
1522 if (cluster1->GetQ()>0 && cluster1->GetDetector()%36>=18) nclC1++;
1525 Int_t cosmicType=0; // types of cosmic topology
1526 if ((nclA0>nclC0) && (nclA1>nclC1)) cosmicType=0; // AA side
1527 if ((nclA0<nclC0) && (nclA1<nclC1)) cosmicType=1; // CC side
1528 if ((nclA0>nclC0) && (nclA1<nclC1)) cosmicType=2; // AC side
1529 if ((nclA0<nclC0) && (nclA1>nclC1)) cosmicType=3; // CA side
1530 if (cosmicType<2) continue; // use only crossing tracks
1532 Double_t deltaTimeCluster=0;
1533 deltaTimeCluster=0.5*(track1->GetZ()-track0->GetZ())/param->GetZWidth();
1534 if (nclA0>nclC0) deltaTimeCluster*=-1; // if A side track
1536 for (Int_t irow=0; irow<159; irow++){
1537 AliTPCclusterMI *cluster0=seed0->GetClusterPointer(irow);
1538 if (cluster0 &&cluster0->GetX()>10){
1539 Double_t x0[3]={cluster0->GetRow(),cluster0->GetPad(),cluster0->GetTimeBin()+deltaTimeCluster};
1540 Int_t index0[1]={cluster0->GetDetector()};
1541 transform->Transform(x0,index0,0,1);
1542 cluster0->SetX(x0[0]);
1543 cluster0->SetY(x0[1]);
1544 cluster0->SetZ(x0[2]);
1547 AliTPCclusterMI *cluster1=seed1->GetClusterPointer(irow);
1548 if (cluster1&&cluster1->GetX()>10){
1549 Double_t x1[3]={cluster1->GetRow(),cluster1->GetPad(),cluster1->GetTimeBin()+deltaTimeCluster};
1550 Int_t index1[1]={cluster1->GetDetector()};
1551 transform->Transform(x1,index1,0,1);
1552 cluster1->SetX(x1[0]);
1553 cluster1->SetY(x1[1]);
1554 cluster1->SetZ(x1[2]);
1560 (*fPIDMatrix)(itrack0,1)+=4; //
1561 (*fPIDMatrix)(itrack1,1)+=4; //
1569 void AliTPCcalibGainMult::ProcessKinks(const AliESDEvent * event){
1573 AliKFParticle::SetField(event->GetMagneticField());
1574 AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
1576 //Printf("ERROR: esdFriend not available");
1579 // if (esdFriend->TestSkipBit()) return;
1582 const Double_t kChi2Cut=10;
1583 const Double_t kMinR=100;
1584 const Double_t kMaxR=230;
1585 const Int_t kMinNcl=110;
1587 Int_t nkinks = event->GetNumberOfKinks();
1588 AliESDVertex *vertex= (AliESDVertex *)event->GetPrimaryVertex();
1589 AliKFVertex kfvertex=*vertex;
1590 TTreeSRedirector * pcstream = GetDebugStreamer();
1592 for (Int_t ikink=0;ikink<nkinks;ikink++){
1593 AliESDkink *kink = event->GetKink(ikink);
1594 if (!kink) continue;
1595 if (kink->GetIndex(0)<0) continue;
1596 if (kink->GetIndex(1)<0) continue;
1597 if (TMath::Max(kink->GetIndex(1), kink->GetIndex(0))>event->GetNumberOfTracks()) continue;
1600 AliExternalTrackParam pd=kink->RefParamDaughter();
1601 AliExternalTrackParam pm=kink->RefParamMother();
1602 AliKFParticle kfpd( pd, 211 );
1603 AliKFParticle kfpm( pm, -13 );
1605 AliKFParticle *v0KF = new AliKFParticle(kfpm,kfpd);
1606 v0KF->SetVtxGuess(kink->GetPosition()[0],kink->GetPosition()[1],kink->GetPosition()[2]);
1607 Double_t chi2 = v0KF->GetChi2();
1608 AliESDtrack * trackM = event->GetTrack(kink->GetIndex(0));
1609 AliESDtrack * trackD = event->GetTrack(kink->GetIndex(1));
1610 if (!trackM) continue;
1611 if (!trackD) continue;
1612 Int_t nclM= (Int_t)trackM->GetTPCClusterInfo(2,1);
1613 Int_t nclD= (Int_t)trackD->GetTPCClusterInfo(2,1);
1614 Double_t eta = TMath::Max(TMath::Abs(trackM->Eta()), TMath::Abs(trackD->Eta()));
1615 Double_t kx= v0KF->GetX();
1616 Double_t ky= v0KF->GetY();
1617 Double_t kz= v0KF->GetZ();
1618 Double_t ex= v0KF->GetErrX();
1619 Double_t ey= v0KF->GetErrY();
1620 Double_t ez= v0KF->GetErrZ();
1622 Double_t radius=TMath::Sqrt(kx*kx+ky*ky);
1623 Double_t alpha=TMath::ATan2(ky,kx);
1624 if (!pd.Rotate(alpha)) continue;
1625 if (!pm.Rotate(alpha)) continue;
1626 if (!pd.PropagateTo(radius,event->GetMagneticField())) continue;
1627 if (!pm.PropagateTo(radius,event->GetMagneticField())) continue;
1628 Double_t pos[2]={0,kz};
1629 Double_t cov[3]={ex*ex+ey*ey,0,ez*ez};
1634 (*pcstream)<<"kinks"<<
1639 "trackM.="<<trackM<<
1640 "trackD.="<<trackD<<
1641 "pm.="<<&pm<< //updated parameters
1642 "pd.="<<&pd<< // updated parameters
1648 TCut cutQ="chi2<10&&kink.fRr>90&&kink.fRr<220";
1649 TCut cutRD="20*sqrt(pd.fC[14])<abs(pd.fP[4])&&trackD.fTPCsignal>10&&trackD.fTPCsignalN>50";
1653 if (chi2>kChi2Cut) continue;
1654 if (kink->GetR()<kMinR) continue;
1655 if (kink->GetR()>kMaxR) continue;
1656 if ((nclM+nclD)<kMinNcl) continue;
1657 if (TMath::Abs(eta)>1) continue;
1660 AliESDfriendTrack *friendTrackM = esdFriend->GetTrack(kink->GetIndex(0));
1661 AliESDfriendTrack *friendTrackD = esdFriend->GetTrack(kink->GetIndex(1));
1662 if (!friendTrackM) continue;
1663 if (!friendTrackD) continue;
1664 TObject *calibObject;
1665 AliTPCseed *seedM = 0;
1666 AliTPCseed *seedD = 0;
1667 for (Int_t l=0;(calibObject=friendTrackM->GetCalibObject(l));++l) {
1668 if ((seedM=dynamic_cast<AliTPCseed*>(calibObject))) break;
1670 for (Int_t l=0;(calibObject=friendTrackD->GetCalibObject(l));++l) {
1671 if ((seedD=dynamic_cast<AliTPCseed*>(calibObject))) break;
1676 void AliTPCcalibGainMult::DumpHPT(const AliESDEvent * event){
1678 // Function to select the HPT tracks and events
1679 // It is used to select event with HPT - list used later for the raw data downloading
1680 // - and reconstruction
1681 // Not actualy used for the calibration of the data
1683 TTreeSRedirector * pcstream = GetDebugStreamer();
1684 AliKFParticle::SetField(event->GetMagneticField());
1685 AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
1687 //Printf("ERROR: esdFriend not available");
1690 if (esdFriend->TestSkipBit()) return;
1692 Int_t ntracks=event->GetNumberOfTracks();
1694 for (Int_t i=0;i<ntracks;++i) {
1696 AliESDtrack *track = event->GetTrack(i);
1697 if (!track) continue;
1698 if (track->Pt()<4) continue;
1699 UInt_t status = track->GetStatus();
1701 AliExternalTrackParam * trackIn = (AliExternalTrackParam *)track->GetInnerParam();
1702 if (!trackIn) continue;
1703 if ((status&AliESDtrack::kTPCrefit)==0) continue;
1704 if ((status&AliESDtrack::kITSrefit)==0) continue;
1705 AliESDfriendTrack *friendTrack = esdFriend->GetTrack(i);
1706 if (!friendTrack) continue;
1707 AliExternalTrackParam * itsOut = (AliExternalTrackParam *)(friendTrack->GetITSOut());
1708 if (!itsOut) continue;
1709 AliExternalTrackParam * itsOut2 = (AliExternalTrackParam *)(friendTrack->GetITSOut()->Clone());
1710 AliExternalTrackParam * tpcIn2 = (AliExternalTrackParam *)(trackIn->Clone());
1711 if (!itsOut2->Rotate(trackIn->GetAlpha())) continue;
1712 //Double_t xmiddle=0.5*(itsOut2->GetX()+tpcIn2->GetX());
1713 Double_t xmiddle=(itsOut2->GetX());
1714 if (!itsOut2->PropagateTo(xmiddle,event->GetMagneticField())) continue;
1715 if (!tpcIn2->PropagateTo(xmiddle,event->GetMagneticField())) continue;
1717 AliExternalTrackParam * tpcInner = (AliExternalTrackParam *)(track->GetTPCInnerParam());
1718 if (!tpcInner) continue;
1719 tpcInner->Rotate(track->GetAlpha());
1720 tpcInner->PropagateTo(track->GetX(),event->GetMagneticField());
1724 AliExternalTrackParam * tpcInnerC = (AliExternalTrackParam *)(track->GetTPCInnerParam()->Clone());
1725 if (!tpcInnerC) continue;
1726 tpcInnerC->Rotate(track->GetAlpha());
1727 tpcInnerC->PropagateTo(track->GetX(),event->GetMagneticField());
1728 Double_t dz[2],cov[3];
1729 AliESDVertex *vtx= (AliESDVertex *)event->GetPrimaryVertex();
1731 if (!tpcInnerC->PropagateToDCA(vtx, event->GetMagneticField(), 3, dz, cov)) continue;
1732 Double_t covar[6]; vtx->GetCovMatrix(covar);
1733 Double_t p[2]={tpcInnerC->GetParameter()[0]-dz[0],tpcInnerC->GetParameter()[1]-dz[1]};
1734 Double_t c[3]={covar[2],0.,covar[5]};
1736 Double_t chi2C=tpcInnerC->GetPredictedChi2(p,c);
1737 tpcInnerC->Update(p,c);
1740 (*pcstream)<<"hpt"<<
1746 "tpcInner.="<<tpcInner<<
1747 "tpcInnerC.="<<tpcInnerC<<
1761 void AliTPCcalibGainMult::ProcessTOF(const AliESDEvent * event){
1763 // 1. Loop over tracks
1765 // 3. Sign positivelly identified tracks
1767 const Double_t kMaxDelta=1000;
1768 const Double_t kOrbit=50000; // distance in the time beween two orbits in the TOF time units - 50000=50 ns
1769 const Double_t kMaxD=20;
1770 const Double_t kRMS0=200;
1771 const Double_t kMaxDCAZ=10;
1772 AliESDVertex *vtx= (AliESDVertex *)event->GetPrimaryVertex();
1774 TTreeSRedirector * pcstream = GetDebugStreamer();
1775 AliKFParticle::SetField(event->GetMagneticField());
1776 AliESDfriend *esdFriend=static_cast<AliESDfriend*>(event->FindListObject("AliESDfriend"));
1778 //Printf("ERROR: esdFriend not available");
1781 //if (esdFriend->TestSkipBit()) return;
1783 Int_t ntracks=event->GetNumberOfTracks();
1785 Double_t deltaTPion[10000];
1786 Double_t medianT0=0;
1791 // Get Median time for pion hypothesy
1793 for (Int_t iter=0; iter<3; iter++){
1795 for (Int_t i=0;i<ntracks;++i) {
1797 AliESDtrack *track = event->GetTrack(i);
1798 if (!track) continue;
1799 if (!track->IsOn(AliESDtrack::kTIME)) continue;
1800 if (TMath::Abs(track->GetZ())>kMaxDCAZ) continue; // remove overlaped events
1801 if (TMath::Abs(track->GetTOFsignalDz())>kMaxD) continue;
1802 Double_t times[1000];
1803 track->GetIntegratedTimes(times);
1804 Int_t norbit=TMath::Nint((track->GetTOFsignal()-times[2])/kOrbit);
1805 Double_t torbit=norbit*kOrbit;
1806 if (iter==1 &&TMath::Abs(times[2]-times[3])<3*rms) continue; // skip umbigous points - kaon pion
1810 for (Int_t j=3; j<5; j++)
1811 if (TMath::Abs(track->GetTOFsignal()-times[j]-torbit-medianT0)<TMath::Abs(track->GetTOFsignal()-times[j]-torbit-medianT0)) indexBest=j;
1814 if (iter>0) if (TMath::Abs(track->GetTOFsignal()-times[indexBest]-torbit-medianT0)>3*(kRMS0+rms)) continue;
1815 if (iter>0) if (TMath::Abs(track->GetTOFsignal()-times[indexBest]-torbit-medianT0)>kMaxDelta) continue;
1816 deltaTPion[counter]=track->GetTOFsignal()-times[indexBest]-torbit;
1819 if (counter<2) return;
1820 medianT0=TMath::Median(counter,deltaTPion);
1821 meanT0=TMath::Median(counter,deltaTPion);
1822 rms=TMath::RMS(counter,deltaTPion);
1824 if (counter<3) return;
1828 for (Int_t i=0;i<ntracks;++i) {
1830 AliESDtrack *track = event->GetTrack(i);
1831 if (!track) continue;
1832 if (!track->IsOn(AliESDtrack::kTIME)) continue;
1833 if (TMath::Abs(track->GetZ())>kMaxDCAZ) continue; //remove overlapped events
1834 if (TMath::Abs(track->GetTOFsignalDz())>kMaxD) continue;
1835 Double_t times[1000];
1836 track->GetIntegratedTimes(times);
1837 Int_t norbit=TMath::Nint((track->GetTOFsignal()-times[2])/kOrbit);
1838 Double_t torbit=norbit*kOrbit;
1839 if (rms<=0) continue;
1841 Double_t tPion = (track->GetTOFsignal()-times[2]-medianT0-torbit);
1842 Double_t tKaon = (track->GetTOFsignal()-times[3]-medianT0-torbit);
1843 Double_t tProton= (track->GetTOFsignal()-times[4]-medianT0-torbit);
1844 Double_t tElectron= (track->GetTOFsignal()-times[0]-medianT0-torbit);
1846 Bool_t isPion = (TMath::Abs(tPion/rms)<6) && TMath::Abs(tPion)<(TMath::Min(TMath::Abs(tKaon), TMath::Abs(tProton))-rms);
1847 Bool_t isKaon = (TMath::Abs(tKaon/rms)<3) && TMath::Abs(tKaon)<0.2*(TMath::Min(TMath::Abs(tPion), TMath::Abs(tProton))-3*rms);
1848 Bool_t isProton = (TMath::Abs(tProton/rms)<6) && TMath::Abs(tProton)<0.5*(TMath::Min(TMath::Abs(tKaon), TMath::Abs(tPion))-rms);
1849 Bool_t isElectron = (TMath::Abs(tElectron/rms)<6) && TMath::Abs(tElectron)<0.2*(TMath::Min(TMath::Abs(tKaon), TMath::Abs(tPion))-rms) &&TMath::Abs(tElectron)<0.5*(TMath::Abs(tPion)-rms);
1851 if (isPion) (*fPIDMatrix)(i,2)+=1;
1852 if (isKaon) (*fPIDMatrix)(i,3)+=1;
1853 if (isProton) (*fPIDMatrix)(i,4)+=1;
1854 // if (isElectron) (*fPIDMatrix)(i,0)+=1;
1857 // debug streamer to dump the information
1858 (*pcstream)<<"tof"<<
1861 "isProton="<<isProton<<
1862 "isElectron="<<isElectron<<
1864 "counter="<<counter<<
1867 "medianT0="<<medianT0<<
1877 tof->SetAlias("isProton","(abs(track.fTOFsignal-track.fTrackTime[4]-medianT0-torbit)<(0.5*abs(track.fTOFsignal-track.fTrackTime[3]-medianT0-torbit)-rmsT0))");
1878 tof->SetAlias("isPion","(abs(track.fTOFsignal-track.fTrackTime[2]-medianT0-torbit)<(0.5*abs(track.fTOFsignal-track.fTrackTime[3]-medianT0-torbit)-rmsT0))");
1879 tof->SetAlias("isKaon","(abs(track.fTOFsignal-track.fTrackTime[3]-medianT0-torbit)<(0.5*abs(track.fTOFsignal-track.fTrackTime[2]-medianT0-torbit)-rmsT0))&&(abs(track.fTOFsignal-track.fTrackTime[3]-medianT0-torbit)<(0.5*abs(track.fTOFsignal-track.fTrackTime[4]-medianT0-torbit)-rmsT0))");
1886 TGraphErrors* AliTPCcalibGainMult::GetGainPerChamber(Int_t padRegion/*=1*/, Bool_t plotQA/*=kFALSE*/)
1889 // Extract gain variations per chamger for 'padRegion'
1892 if (padRegion<0||padRegion>2) return 0x0;
1894 if (!fHistGainSector) return NULL;
1895 if (!fHistGainSector->GetAxis(2)) return NULL;
1896 fHistGainSector->GetAxis(2)->SetRangeUser(padRegion,padRegion);
1897 TH2D * histGainSec = fHistGainSector->Projection(0,1);
1898 // TH1D* proj=fHistGainSector->Projection(0);
1899 // Double_t max=proj->GetBinCenter(proj->GetMaximumBin());
1903 // TF1 fg("gaus","gaus",histGainSec->GetYaxis()->GetXmin()+1,histGainSec->GetYaxis()->GetXmax()-1);
1904 // histGainSec->FitSlicesY(&fg, 0, -1, 0, "QNR", &arr);
1905 histGainSec->FitSlicesY(0, 0, -1, 0, "QNR", &arr);
1906 TH1D * meanGainSec = (TH1D*)arr.At(1);
1907 Double_t gainsIROC[36]={0.};
1908 Double_t gainsOROC[36]={0.};
1909 Double_t gains[72]={0.};
1910 Double_t gainsErr[72]={0.};
1911 TGraphErrors *gr=new TGraphErrors(36);
1913 for(Int_t isec = 1; isec < meanGainSec->GetNbinsX() + 1; isec++) {
1914 TH1D *slice=histGainSec->ProjectionY("_py",isec,isec);
1915 Double_t max=slice->GetBinCenter(slice->GetMaximumBin());
1916 TF1 fg("gaus","gaus",max-30,max+30);
1917 slice->Fit(&fg,"QNR");
1918 meanGainSec->SetBinContent(isec,fg.GetParameter(1));
1919 meanGainSec->SetBinError(isec,fg.GetParError(1));
1921 // cout << isec << " " << meanGainSec->GetXaxis()->GetBinCenter(isec) << " " <<meanGainSec->GetBinContent(isec) << endl;
1922 gains[isec-1] = meanGainSec->GetBinContent(isec);
1924 gainsIROC[isec-1] = meanGainSec->GetBinContent(isec);
1926 gainsOROC[isec - 36 -1] = meanGainSec->GetBinContent(isec);
1928 gainsErr[isec-1]=meanGainSec->GetBinError(isec);
1931 Double_t meanIroc = TMath::Median(36, gainsIROC);
1932 Double_t meanOroc = TMath::Median(36, gainsOROC);
1933 if (TMath::Abs(meanIroc)<1e-30) meanIroc=1.;
1934 if (TMath::Abs(meanOroc)<1e-30) meanOroc=1.;
1935 for(Int_t i = 0; i < 36; i++) {
1936 gains[i] /= meanIroc;
1937 gainsErr[i] /= meanIroc;
1940 for(Int_t i = 36; i < 72; i++){
1941 gains[i] /= meanOroc;
1942 gainsErr[i] /= meanOroc;
1946 for(Int_t i = 0; i < 72; i++) {
1947 if (padRegion==0 && i>35) continue;
1948 if ( (padRegion==1 || padRegion==2) && i<36) continue;
1950 if (gains[i]<1e-20 || gainsErr[i]/gains[i]>.2){
1951 AliWarning(Form("Invalid chamber gain in ROC/region: %d / %d", i, padRegion));
1956 gr->SetPoint(ipoint,i,gains[i]);
1957 gr->SetPointError(ipoint,0,gainsErr[i]);
1961 const char* names[3]={"SHORT","MEDIUM","LONG"};
1962 gr->SetNameTitle(Form("TGRAPHERRORS_MEAN_CHAMBERGAIN_%s_BEAM_ALL",names[padRegion]),Form("TGRAPHERRORS_MEAN_CHAMBERGAIN_%s_BEAM_ALL",names[padRegion]));
1965 //=====================================
1966 // Do QA plotting if requested
1968 TCanvas *c=(TCanvas*)gROOT->GetListOfCanvases()->FindObject("cQA");
1969 if (!c) c=new TCanvas("cQA","cQA");
1973 histGainSec->DrawCopy("colz");
1974 meanGainSec->DrawCopy("same");
1975 gr->SetMarkerStyle(20);
1976 gr->SetMarkerSize(.5);
1984 TGraphErrors* AliTPCcalibGainMult::GetGainPerChamberRobust(Int_t padRegion/*=1*/, Bool_t /*plotQA=kFALSE*/)
1987 // Extract gain variations per chamger for 'padRegion'
1988 // Use Robust mean - LTM with 60 % 0 should be similar to the truncated mean 60 %
1989 if (padRegion<0||padRegion>2) return 0x0;
1990 const Int_t colors[10]={1,2,4,6};
1991 const Int_t markers[10]={21,25,22,20};
1993 if (!fHistGainSector) return NULL;
1994 if (!fHistGainSector->GetAxis(2)) return NULL;
1995 fHistGainSector->GetAxis(2)->SetRangeUser(padRegion,padRegion);
1996 if (padRegion==0) fHistGainSector->GetAxis(1)->SetRangeUser(0.0,35.);
1997 if (padRegion>0) fHistGainSector->GetAxis(1)->SetRangeUser(36.,71.);
1999 TH2D * histGainSec = fHistGainSector->Projection(0,1);
2000 TGraphErrors * gr = TStatToolkit::MakeStat1D(histGainSec, 0, 0.6,2,markers[padRegion],colors[padRegion]);
2001 Double_t median = TMath::Median(gr->GetN(),gr->GetY());
2003 for (Int_t i=0; i<gr->GetN();i++) {
2004 gr->GetY()[i]/=median;
2005 gr->SetPointError(i,gr->GetErrorX(i),gr->GetErrorY(i)/median);
2008 const char* names[3]={"SHORT","MEDIUM","LONG"};
2009 gr->SetNameTitle(Form("TGRAPHERRORS_MEAN_CHAMBERGAIN_%s_BEAM_ALL",names[padRegion]),Form("TGRAPHERRORS_MEAN_CHAMBERGAIN_%s_BEAM_ALL",names[padRegion]));
2013 // void AliTPCcalibGainMult::Terminate(){
2015 // // Terminate function
2016 // // call base terminate + Eval of fitters
2018 // Info("AliTPCcalibGainMult","Terminate");
2019 // TTreeSRedirector *pcstream = GetDebugStreamer();
2021 // TTreeStream &stream = (*pcstream)<<"dump";
2022 // TTree* tree = stream.GetTree();
2023 // if (tree) if ( tree->GetEntries()>0){
2024 // TObjArray *array = tree->GetListOfBranches();
2025 // for (Int_t i=0; i<array->GetEntries(); i++) {TBranch * br = (TBranch *)array->At(i); br->SetAddress(0);}
2026 // gDirectory=gROOT;
2027 // fdEdxTree=tree->CloneTree(10000);
2030 // AliTPCcalibBase::Terminate();