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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
19 // Class for calibration of the cluster properties: //
20 // Cluster position resolution (RMS) and short term distortions (within pad or within time bin)
23 // 1. Creation of the residual/properties histograms
24 // 2. Filling of the histograms.
25 // 2.a Traklet fitting
26 // 2.b Resudual filling
27 // 3. Postprocessing: Creation of the tree with the mean values and RMS at different bins
28 // 4. : Paramaterization fitting.
29 // In old AliRoot the RMS paramterization was used to characterize cluster resolution
30 // Mean value /bias was neglected
31 // 5. To be implemented
32 // a.) lookup table for the distortion parmaterization - THn
33 // b.) Usage in the reconstruction
36 // 1. Creation of the histograms: MakeHistos()
38 // 6 n dimensional histograms are filled during the calibration:
39 // cluster performance bins
40 // 0 - variable of interest
41 // 1 - pad type - 0- IROC Short 1- OCROC medium 2 - OROC long pads
42 // 2 - drift length - drift length -0-1
43 // 3 - Qmax - Qmax - 2- 400
44 // 4 - cog - COG position - 0-1
45 // 5 - tan(phi) - local angle
47 // THnSparse *fHisDeltaY; // THnSparse - delta Y between the cluster and tracklet interpolation (+-X(5?) rows)
48 // THnSparse *fHisDeltaZ; // THnSparse - delta Z
49 // THnSparse *fHisRMSY; // THnSparse - rms Y
50 // THnSparse *fHisRMSZ; // THnSparse - rms Z
51 // THnSparse *fHisQmax; // THnSparse - qmax
52 // THnSparse *fHisQtot; // THnSparse - qtot
59 // The parameter 'clusterParam', a AliTPCClusterParam object //
60 // (needed for TPC cluster error and shape parameterization) //
62 // Normally you get this object out of the file 'TPCClusterParam.root' //
63 // In the parameter 'cuts' the cuts are specified, that decide //
64 // weather a track will be accepted for calibration or not. //
70 Raw Data -> Local Reconstruction -> Tracking -> Calibration -> RefData (component itself)
71 Offline/HLT Offline/HLT OCDB entries (AliTPCClusterParam)
75 Example usage - creation of the residual trees:
76 TFile f("CalibObjects.root");
77 AliTPCcalibTracks *calibTracks = ( AliTPCcalibTracks *)TPCCalib->FindObject("calibTracks");
78 TH2 * his2 = calibTracks->fHisDeltaY->Projection(0,4);
79 his2->SetName("his2");
83 TTreeSRedirector *pcstream = new TTreeSRedirector("clusterLookup.root");
84 AliTPCcalibTracks::MakeSummaryTree(calibTracks->fHisDeltaY, pcstream, 0);
85 AliTPCcalibTracks::MakeSummaryTree(calibTracks->fHisDeltaZ, pcstream, 1);
87 TFile fl("clusterLookup.root");
88 TCut cutNI="cogA==0&&angleA==0&&qmaxA==0&&zA==0&&ipadA==0"
93 ///////////////////////////////////////////////////////////////////////////////
106 #include <TProfile.h>
109 //#include <TPDGCode.h>
111 #include "TLinearFitter.h"
112 //#include "TMatrixD.h"
113 #include "TTreeStream.h"
116 #include <TGraph2DErrors.h>
117 #include "TPostScript.h"
123 #include <TCollection.h>
125 #include <TLinearFitter.h>
132 #include "AliTracker.h"
134 #include "AliESDtrack.h"
135 #include "AliESDfriend.h"
136 #include "AliESDfriendTrack.h"
137 #include "AliTPCseed.h"
138 #include "AliTPCclusterMI.h"
139 #include "AliTPCROC.h"
141 #include "AliTPCParamSR.h"
142 #include "AliTrackPointArray.h"
143 #include "AliTPCcalibTracks.h"
144 #include "AliTPCClusterParam.h"
145 #include "AliTPCcalibTracksCuts.h"
146 #include "AliTPCCalPad.h"
147 #include "AliTPCCalROC.h"
149 #include "TPaveText.h"
151 #include "TStatToolkit.h"
153 #include "THnSparse.h"
154 #include "AliRieman.h"
158 Double_t AliTPCcalibTracks::fgkMergeEntriesCut=10000000.; //10**7 clusters
160 ClassImp(AliTPCcalibTracks)
163 AliTPCcalibTracks::AliTPCcalibTracks():
167 fHisDeltaY(0), // THnSparse - delta Y
168 fHisDeltaZ(0), // THnSparse - delta Z
169 fHisRMSY(0), // THnSparse - rms Y
170 fHisRMSZ(0), // THnSparse - rms Z
171 fHisQmax(0), // THnSparse - qmax
172 fHisQtot(0), // THnSparse - qtot
173 fPtDownscaleRatio(20), // pt downscaling ratio (use subsample of data)
174 fQDownscaleRatio(20), // Q downscaling ratio (use subsample of dta)
184 fRejectedTracksHisto(0),
186 fCalPadClusterPerPad(0),
187 fCalPadClusterPerPadRaw(0)
190 // AliTPCcalibTracks default constructor
192 if (GetDebugLevel() > 0) cout << "AliTPCcalibTracks' default constructor called" << endl;
197 AliTPCcalibTracks::AliTPCcalibTracks(const AliTPCcalibTracks& calibTracks):
198 AliTPCcalibBase(calibTracks),
201 fHisDeltaY(0), // THnSparse - delta Y
202 fHisDeltaZ(0), // THnSparse - delta Z
203 fHisRMSY(0), // THnSparse - rms Y
204 fHisRMSZ(0), // THnSparse - rms Z
205 fHisQmax(0), // THnSparse - qmax
206 fHisQtot(0), // THnSparse - qtot
207 fPtDownscaleRatio(20), // pt downscaling ratio (use subsample of data)
208 fQDownscaleRatio(20), // Q downscaling ratio (use subsample of dta)
218 fRejectedTracksHisto(0),
220 fCalPadClusterPerPad(0),
221 fCalPadClusterPerPadRaw(0)
224 // AliTPCcalibTracks copy constructor
226 if (GetDebugLevel() > 0) cout << " ***** this is AliTPCcalibTracks' copy constructor ***** " << endl;
228 Bool_t dirStatus = TH1::AddDirectoryStatus();
229 TH1::AddDirectory(kFALSE);
233 (calibTracks.fArrayQDY) ? length = calibTracks.fArrayQDY->GetEntriesFast() : length = -1;
234 fArrayQDY= new TObjArray(length);
235 fArrayQDZ= new TObjArray(length);
236 fArrayQRMSY= new TObjArray(length);
237 fArrayQRMSZ= new TObjArray(length);
238 for (Int_t i = 0; i < length; i++) {
239 fArrayQDY->AddAt( ((TH1F*)calibTracks.fArrayQDY->At(i)->Clone()), i);
240 fArrayQDZ->AddAt( ((TH1F*)calibTracks.fArrayQDZ->At(i)->Clone()), i);
241 fArrayQRMSY->AddAt( ((TH1F*)calibTracks.fArrayQRMSY->At(i)->Clone()), i);
242 fArrayQRMSZ->AddAt( ((TH1F*)calibTracks.fArrayQRMSZ->At(i)->Clone()), i);
245 (calibTracks.fResolY) ? length = calibTracks.fResolY->GetEntriesFast() : length = -1;
246 fResolY = new TObjArray(length);
247 fResolZ = new TObjArray(length);
248 fRMSY = new TObjArray(length);
249 fRMSZ = new TObjArray(length);
250 for (Int_t i = 0; i < length; i++) {
251 fResolY->AddAt( ((TH1F*)calibTracks.fResolY->At(i)->Clone()), i);
252 fResolZ->AddAt( ((TH1F*)calibTracks.fResolZ->At(i)->Clone()), i);
253 fRMSY->AddAt( ((TH1F*)calibTracks.fRMSY->At(i)->Clone()), i);
254 fRMSZ->AddAt( ((TH1F*)calibTracks.fRMSZ->At(i)->Clone()), i);
258 fClusterCutHisto = (TH2I*)calibTracks.fClusterCutHisto->Clone();
259 fRejectedTracksHisto = (TH1I*)calibTracks.fRejectedTracksHisto->Clone();
260 fCalPadClusterPerPad = (AliTPCCalPad*)calibTracks.fCalPadClusterPerPad->Clone();
261 fCalPadClusterPerPadRaw = (AliTPCCalPad*)calibTracks.fCalPadClusterPerPadRaw->Clone();
263 fCuts = new AliTPCcalibTracksCuts(calibTracks.fCuts->GetMinClusters(), calibTracks.fCuts->GetMinRatio(),
264 calibTracks.fCuts->GetMax1pt(), calibTracks.fCuts->GetEdgeYXCutNoise(), calibTracks.fCuts->GetEdgeThetaCutNoise());
265 SetNameTitle(calibTracks.GetName(), calibTracks.GetTitle());
266 TH1::AddDirectory(dirStatus); // set status back to original status
267 // cout << "+++++ end of copy constructor +++++" << endl; // TO BE REMOVED
271 AliTPCcalibTracks & AliTPCcalibTracks::operator=(const AliTPCcalibTracks& calibTracks){
273 // assgnment operator
275 if (this != &calibTracks) {
276 new (this) AliTPCcalibTracks(calibTracks);
283 AliTPCcalibTracks::AliTPCcalibTracks(const Text_t *name, const Text_t *title, AliTPCClusterParam *clusterParam, AliTPCcalibTracksCuts* cuts, Int_t logLevel) :
287 fHisDeltaY(0), // THnSparse - delta Y
288 fHisDeltaZ(0), // THnSparse - delta Z
289 fHisRMSY(0), // THnSparse - rms Y
290 fHisRMSZ(0), // THnSparse - rms Z
291 fHisQmax(0), // THnSparse - qmax
292 fHisQtot(0), // THnSparse - qtot
293 fPtDownscaleRatio(20), // pt downscaling ratio (use subsample of data)
294 fQDownscaleRatio(20), // Q downscaling ratio (use subsample of dta)
304 fRejectedTracksHisto(0),
306 fCalPadClusterPerPad(0),
307 fCalPadClusterPerPadRaw(0)
310 // AliTPCcalibTracks constructor
311 // specify 'name' and 'title' of your object
312 // specify 'clusterParam', (needed for TPC cluster error and shape parameterization)
313 // In the parameter 'cuts' the cuts are specified, that decide
314 // weather a track will be accepted for calibration or not.
316 // fDebugLevel - debug output: -1: silence, 0: default, 1: things like constructor called, 5: write fDebugStreamer, 6: waste your screen
318 // All histograms are instatiated in this constructor.
321 this->SetTitle(title);
323 if (GetDebugLevel() > 0) cout << " ***** this is AliTPCcalibTracks' main constructor ***** " << endl;
324 G__SetCatchException(0);
326 fClusterParam = clusterParam;
328 fClusterParam->SetInstance(fClusterParam);
331 Error("AliTPCcalibTracks","No cluster parametrization found! A valid clusterParam object is needed in the constructor. (To be found in 'TPCClusterParam.root'.)");
334 SetDebugLevel(logLevel);
337 TH1::AddDirectory(kFALSE);
339 fRejectedTracksHisto = new TH1I("RejectedTracksHisto", "Rejected tracks, sorted by failed cut", 100, -1, 10);
340 fCalPadClusterPerPad = new AliTPCCalPad("fCalPadClusterPerPad", "clusters per pad");
341 fCalPadClusterPerPadRaw = new AliTPCCalPad("fCalPadClusterPerPadRaw", "clusters per pad, before cutting clusters");
342 fClusterCutHisto = new TH2I("fClusterCutHisto", "Cutted cluster over padRow; Cut Criterium; PadRow", 5,1,5, 160,0,159);
345 TH1::AddDirectory(kFALSE);
348 fResolY = new TObjArray(3);
349 fResolZ = new TObjArray(3);
350 fRMSY = new TObjArray(3);
351 fRMSZ = new TObjArray(3);
354 his3D = new TH3F("Resol Y0","Resol Y0", 5,20,250, 4, 0,1., 50, -1,1);
355 fResolY->AddAt(his3D,0);
356 his3D = new TH3F("Resol Y1","Resol Y1", 5,20,250, 4, 0,1., 50, -1,1);
357 fResolY->AddAt(his3D,1);
358 his3D = new TH3F("Resol Y2","Resol Y2", 5,20,250, 4, 0,0.8, 50, -1,1);
359 fResolY->AddAt(his3D,2);
361 his3D = new TH3F("Resol Z0","Resol Z0", 5,20,250, 4, 0,1, 50, -1,1);
362 fResolZ->AddAt(his3D,0);
363 his3D = new TH3F("Resol Z1","Resol Z1", 5,20,250, 4, 0,1, 50, -1,1);
364 fResolZ->AddAt(his3D,1);
365 his3D = new TH3F("Resol Z2","Resol Z2", 5,20,250, 4, 0,1, 50, -1,1);
366 fResolZ->AddAt(his3D,2);
368 his3D = new TH3F("RMS Y0","RMS Y0", 5,20,250, 4, 0,1., 50, 0,0.8);
369 fRMSY->AddAt(his3D,0);
370 his3D = new TH3F("RMS Y1","RMS Y1", 5,20,250, 4, 0,1., 50, 0,0.8);
371 fRMSY->AddAt(his3D,1);
372 his3D = new TH3F("RMS Y2","RMS Y2", 5,20,250, 4, 0,0.8, 50, 0,0.8);
373 fRMSY->AddAt(his3D,2);
375 his3D = new TH3F("RMS Z0","RMS Z0", 5,20,250, 4, 0,1, 50, 0,0.8);
376 fRMSZ->AddAt(his3D,0);
377 his3D = new TH3F("RMS Z1","RMS Z1", 5,20,250, 4, 0,1, 50, 0,0.8);
378 fRMSZ->AddAt(his3D,1);
379 his3D = new TH3F("RMS Z2","RMS Z2", 5,20,250, 4, 0,1, 50, 0,0.8);
380 fRMSZ->AddAt(his3D,2);
383 TH1::AddDirectory(kFALSE);
385 fArrayQDY = new TObjArray(300);
386 fArrayQDZ = new TObjArray(300);
387 fArrayQRMSY = new TObjArray(300);
388 fArrayQRMSZ = new TObjArray(300);
389 for (Int_t iq = 0; iq <= 10; iq++){
390 for (Int_t ipad = 0; ipad < 3; ipad++){
391 Int_t bin = GetBin(iq, ipad);
392 Float_t qmean = GetQ(bin);
394 snprintf(hname,100,"ResolY Pad%d Qmiddle%f",ipad, qmean);
395 his3D = new TH3F(hname, hname, 20,10,250, 20, 0,1.5, 100, -1,1);
396 fArrayQDY->AddAt(his3D, bin);
397 snprintf(hname,100,"ResolZ Pad%d Qmiddle%f",ipad, qmean);
398 his3D = new TH3F(hname, hname, 20,10,250, 20, 0,1.5, 100, -1,1);
399 fArrayQDZ->AddAt(his3D, bin);
400 snprintf(hname,100,"RMSY Pad%d Qmiddle%f",ipad, qmean);
401 his3D = new TH3F(hname, hname, 20,10,250, 20, 0,1.5, 100, 0,0.6);
402 fArrayQRMSY->AddAt(his3D, bin);
403 snprintf(hname,100,"RMSZ Pad%d Qmiddle%f",ipad, qmean);
404 his3D = new TH3F(hname, hname, 20,10,250, 20, 0,1.5, 100, 0,0.6);
405 fArrayQRMSZ->AddAt(his3D, bin);
411 if (GetDebugLevel() > 1) cout << "AliTPCcalibTracks object sucessfully constructed: " << GetName() << endl;
412 cout << "end of main constructor" << endl; // TO BE REMOVED
416 AliTPCcalibTracks::~AliTPCcalibTracks() {
418 // AliTPCcalibTracks destructor
421 if (GetDebugLevel() > 0) cout << "AliTPCcalibTracks' destuctor called." << endl;
426 length = fResolY->GetEntriesFast();
427 for (Int_t i = 0; i < length; i++){
428 delete fResolY->At(i);
429 delete fResolZ->At(i);
440 length = fArrayQDY->GetEntriesFast();
441 for (Int_t i = 0; i < length; i++){
442 delete fArrayQDY->At(i);
443 delete fArrayQDZ->At(i);
444 delete fArrayQRMSY->At(i);
445 delete fArrayQRMSZ->At(i);
456 delete fRejectedTracksHisto;
457 delete fClusterCutHisto;
458 if (fCalPadClusterPerPad) delete fCalPadClusterPerPad;
459 if (fCalPadClusterPerPadRaw) delete fCalPadClusterPerPadRaw;
460 delete fHisDeltaY; // THnSparse - delta Y
461 delete fHisDeltaZ; // THnSparse - delta Z
462 delete fHisRMSY; // THnSparse - rms Y
463 delete fHisRMSZ; // THnSparse - rms Z
464 delete fHisQmax; // THnSparse - qmax
465 delete fHisQtot; // THnSparse - qtot
471 void AliTPCcalibTracks::Process(AliTPCseed *track){
473 // To be called in the selector
474 // first AcceptTrack is evaluated, then calls all the following analyse functions:
475 // FillResolutionHistoLocal(track)
478 Double_t scalept= TMath::Min(1./TMath::Abs(track->GetParameter()[4]),2.)/0.5;
479 Bool_t isSelected = (TMath::Exp(scalept)>fPtDownscaleRatio*gRandom->Rndm());
480 if (!isSelected) return;
482 if (GetDebugLevel() > 5) Info("Process","Starting to process the track...");
483 Int_t accpetStatus = AcceptTrack(track);
484 if (accpetStatus == 0) {
485 FillResolutionHistoLocal(track);
487 else fRejectedTracksHisto->Fill(accpetStatus);
492 Int_t AliTPCcalibTracks::GetBin(Float_t q, Int_t pad){
494 // calculate bins for given q and pad type
497 Int_t res = TMath::Max( TMath::Nint((TMath::Sqrt(q) - 3.)), 0 );
504 Int_t AliTPCcalibTracks::GetBin(Int_t iq, Int_t pad){
506 // calculate bins for given iq and pad type
509 return iq * 3 + pad;;
513 Float_t AliTPCcalibTracks::GetQ(Int_t bin){
515 // returns to bin belonging charge
518 Int_t bin0 = bin / 3;
524 Float_t AliTPCcalibTracks::GetPad(Int_t bin){
526 // returns to bin belonging pad
534 Int_t AliTPCcalibTracks::AcceptTrack(AliTPCseed * track){
536 // Function, that decides wheather a given track is accepted for
537 // the analysis or not.
538 // The cuts are specified in the AliTPCcalibTracksCuts object 'fCuts'
539 // Returns 0 if a track is accepted or an integer different from 0
540 // to indicate the failed cut
542 const Int_t kMinClusters = fCuts->GetMinClusters();
543 const Float_t kMinRatio = fCuts->GetMinRatio();
544 const Float_t kMax1pt = fCuts->GetMax1pt();
545 const Float_t kEdgeYXCutNoise = fCuts->GetEdgeYXCutNoise();
546 const Float_t kEdgeThetaCutNoise = fCuts->GetEdgeThetaCutNoise();
549 // edge induced noise tracks - NEXT RELEASE will be removed during tracking
550 if ( TMath::Abs(track->GetY() / track->GetX()) > kEdgeYXCutNoise )
551 if ( TMath::Abs(track->GetTgl()) < kEdgeThetaCutNoise ) return 1;
552 if (track->GetNumberOfClusters() < kMinClusters) return 2;
553 Float_t ratio = track->GetNumberOfClusters() / (track->GetNFoundable() + 1.);
554 if (ratio < kMinRatio) return 3;
555 // Float_t mpt = track->Get1Pt(); // Get1Pt() doesn't exist any more
556 Float_t mpt = track->GetSigned1Pt();
557 if (TMath::Abs(mpt) > kMax1pt) return 4;
558 //if (TMath::Abs(track->GetZ())>240.) return kFALSE;
559 //if (TMath::Abs(track->GetZ())<10.) return kFALSE;
560 //if (TMath::Abs(track->GetTgl())>0.03) return kFALSE;
562 if (GetDebugLevel() > 20) Info("AcceptTrack","Track has been accepted.");
567 void AliTPCcalibTracks::FillResolutionHistoLocal(AliTPCseed * track){
569 // fill resolution histograms - localy - tracklet in the neighborhood
570 // write debug information to 'TPCSelectorDebug.root'
572 // _ the main function, called during track analysis _
574 // loop over all padrows along the track
575 // fit tracklets (length: 13 clusters) calculate mean chi^2 for this track-fit in Y and Z direction
577 // loop again over all padrows along the track
578 // fit tracklet (clusters in given padrow +- kDelta padrows)
579 // with polynom of 2nd order and two polynoms of 1st order
580 // take both polynoms of 1st order, calculate difference of their parameters
581 // add covariance matrixes and calculate chi2 of this difference
582 // if this chi2 is bigger than a given threshold, assume that the current cluster is
583 // a kink an goto next padrow
585 // fill fRMSY, fRMSZ, fArrayQRMSY and fArrayQRMSZ, fResolY, fResolZ, fArrayQDY, fArrayQDY
587 // write debug information to 'TPCSelectorDebug.root'
588 // only for every kDeltaWriteDebugStream'th padrow to reduce data volume
589 // and to avoid redundant data
595 if( fClusterParam && fClusterParam->GetWaveCorrectionMap() ){
596 cout<<"Map found "<<endl;
598 cout<<"Can't find the map "<<endl;
601 if( n%100 ==0 )cout<<n<<" Tracks processed"<<endl;
604 static TLinearFitter fFitterParY(3,"pol2"); //
605 static TLinearFitter fFitterParZ(3,"pol2"); //
606 static TLinearFitter fFitterParYWeight(3,"pol2"); //
607 static TLinearFitter fFitterParZWeight(3,"pol2"); //
608 fFitterParY.StoreData(kTRUE);
609 fFitterParZ.StoreData(kTRUE);
610 fFitterParYWeight.StoreData(kTRUE);
611 fFitterParZWeight.StoreData(kTRUE);
612 if (GetDebugLevel() > 5) Info("FillResolutionHistoLocal"," ***** Start of FillResolutionHistoLocal *****");
613 const Int_t kDelta = 10; // delta rows to fit
614 const Float_t kMinRatio = 0.75; // minimal ratio
615 const Float_t kChi2Cut = 10.; // cut chi2 - left right
616 const Float_t kSigmaCut = 3.; //sigma cut
617 const Float_t kdEdxCut=300;
618 const Float_t kPtCut=0.300;
620 if (track->GetTPCsignal()>kdEdxCut) return;
621 if (TMath::Abs(AliTracker::GetBz())>0.1 &&TMath::Abs(track->Pt())<kPtCut) return;
623 // estimate mean error
624 Int_t nTrackletsAll = 0; // number of tracklets for given track
625 Float_t csigmaY = 0; // mean sigma for tracklet refit in Y direction
626 Float_t csigmaZ = 0; // mean sigma for tracklet refit in Z direction
627 Int_t nClusters = 0; // working variable, number of clusters per tracklet
628 Int_t sectorG = -1; // working variable, sector of tracklet, has to stay constant for one tracklet
630 // ---------------------------------------------------------------------
631 for (Int_t irow = 0; irow < 159; irow++){
632 // loop over all rows along the track
633 // fit tracklets (length: 13 rows) with pol2 in Y and Z direction
634 // calculate mean chi^2 for this track-fit in Y and Z direction
635 AliTPCclusterMI * cluster0 = track->GetClusterPointer(irow);
636 if (!cluster0) continue; // no cluster found
637 Int_t sector = cluster0->GetDetector();
639 Int_t ipad = TMath::Nint(cluster0->GetPad());
640 Float_t value = fCalPadClusterPerPadRaw->GetCalROC(sector)->GetValue((sector<36)?irow:irow-64, TMath::Nint(cluster0->GetPad()));
641 fCalPadClusterPerPadRaw->GetCalROC(sector)->SetValue((sector<36)?irow:irow-64, ipad, value + 1 );
643 if (sector != sectorG){
644 // track leaves sector before it crossed enough rows to fit / initialization
646 fFitterParY.ClearPoints();
647 fFitterParZ.ClearPoints();
652 if (refX<1) refX=cluster0->GetX()+kDelta*0.5;
653 Double_t x = cluster0->GetX()-refX;
654 fFitterParY.AddPoint(&x, cluster0->GetY(), 1);
655 fFitterParZ.AddPoint(&x, cluster0->GetZ(), 1);
657 if ( nClusters >= kDelta + 3 ){
658 // if more than 13 (kDelta+3) clusters were added to the fitters
659 // fit the tracklet, increase trackletCounter
663 csigmaY += fFitterParY.GetChisquare() / (nClusters - 3.);
664 csigmaZ += fFitterParZ.GetChisquare() / (nClusters - 3.);
666 fFitterParY.ClearPoints();
667 fFitterParZ.ClearPoints();
671 } // for (Int_t irow = 0; irow < 159; irow++)
672 // mean chi^2 for all tracklet fits in Y and in Z direction:
673 csigmaY = TMath::Sqrt(TMath::Abs(csigmaY) / (nTrackletsAll+0.1));
674 csigmaZ = TMath::Sqrt(TMath::Abs(csigmaZ) / (nTrackletsAll+0.1));
675 if (csigmaY<=TMath::KUncertainty() || csigmaZ<= TMath::KUncertainty()) return;
676 // ---------------------------------------------------------------------
680 for (Int_t irow = kDelta; irow < 159-kDelta; irow++){
681 // loop again over all rows along the track
684 Int_t nclFound = 0; // number of clusters in the neighborhood
685 Int_t ncl0 = 0; // number of clusters in rows < rowOfCenterCluster
686 Int_t ncl1 = 0; // number of clusters in rows > rowOfCenterCluster
687 AliTPCclusterMI * cluster0 = track->GetClusterPointer(irow);
688 if (!cluster0) continue;
689 Int_t sector = cluster0->GetDetector();
690 Float_t xref = cluster0->GetX();
693 fFitterParY.ClearPoints();
694 fFitterParZ.ClearPoints();
695 fFitterParYWeight.ClearPoints();
696 fFitterParZWeight.ClearPoints();
697 // fit tracklet (clusters in given padrow +- kDelta padrows)
698 // with polynom of 2nd order and two polynoms of 1st order
699 // take both polynoms of 1st order, calculate difference of their parameters
700 // add covariance matrixes and calculate chi2 of this difference
701 // if this chi2 is bigger than a given threshold, assume that the current cluster is
702 // a kink an goto next padrow
704 // first fit the track angle for wave correction
706 AliRieman riemanFitAngle( 2*kDelta ); //SG
708 if( fClusterParam && fClusterParam->GetWaveCorrectionMap() ){
709 for (Int_t idelta = -kDelta; idelta <= kDelta; idelta++){
710 // loop over irow +- kDelta rows (neighboured rows)
711 if (idelta + irow < 0 || idelta + irow > 159) continue; // don't go out of ROC
712 AliTPCclusterMI * currentCluster = track->GetClusterPointer(irow + idelta);
713 if (!currentCluster) continue;
714 if (currentCluster->GetType() < 0) continue;
715 if (currentCluster->GetDetector() != sector) continue;
716 riemanFitAngle.AddPoint(currentCluster->GetX(), currentCluster->GetY(),currentCluster->GetZ(), csigmaY,csigmaZ);
718 if( riemanFitAngle.GetN()>3 ) riemanFitAngle.Update();
723 AliRieman riemanFit(2*kDelta);
724 AliRieman riemanFitW(2*kDelta);
725 for (Int_t idelta = -kDelta; idelta <= kDelta; idelta++){
726 // loop over irow +- kDelta rows (neighboured rows)
729 if (idelta == 0) continue; // don't use center cluster
730 if (idelta + irow < 0 || idelta + irow > 159) continue; // don't go out of ROC
731 AliTPCclusterMI * currentCluster = track->GetClusterPointer(irow + idelta);
732 if (!currentCluster) continue;
733 if (currentCluster->GetType() < 0) continue;
734 if (currentCluster->GetDetector() != sector) continue;
745 Int_t padSize = 0; // short pads
746 if (currentCluster->GetDetector() >= 36) {
747 padSize = 1; // medium pads
748 if (currentCluster->GetRow() > 63) padSize = 2; // long pads
750 dY = fClusterParam->GetWaveCorrection( padSize,
751 currentCluster->GetZ(),
752 currentCluster->GetMax(),
753 currentCluster->GetPad(),
754 riemanFitAngle.GetDYat(currentCluster->GetX())
757 riemanFit.AddPoint(currentCluster->GetX(), currentCluster->GetY()-dY,currentCluster->GetZ(), csigmaY,csigmaZ);
758 riemanFitW.AddPoint(currentCluster->GetX(), currentCluster->GetY()-dY,currentCluster->GetZ(), TMath::Abs(csigmaY*TMath::Sqrt(1+TMath::Abs(idelta))),TMath::Abs(csigmaZ*TMath::Sqrt(1+TMath::Abs(idelta))));
759 } // loop over neighbourhood for fitter filling
760 if (nclFound < kDelta * kMinRatio) fRejectedTracksHisto->Fill(10);
761 if (nclFound < kDelta * kMinRatio) fClusterCutHisto->Fill(1, irow);
762 if (nclFound < kDelta * kMinRatio) continue; // if not enough clusters (7.5) found in neighbourhood goto next padrow
765 Double_t chi2R=TMath::Sqrt(riemanFit.CalcChi2()/(2*nclFound-5));
766 Double_t chi2RW=TMath::Sqrt(riemanFitW.CalcChi2()/(2*nclFound-5));
767 Double_t paramYR[3], paramZR[3];
768 Double_t paramYRW[3], paramZRW[3];
770 paramYR[0] = riemanFit.GetYat(xref);
771 paramZR[0] = riemanFit.GetZat(xref);
772 paramYRW[0] = riemanFitW.GetYat(xref);
773 paramZRW[0] = riemanFitW.GetZat(xref);
775 paramYR[1] = riemanFit.GetDYat(xref);
776 paramZR[1] = riemanFit.GetDZat(xref);
777 paramYRW[1] = riemanFitW.GetDYat(xref);
778 paramZRW[1] = riemanFitW.GetDZat(xref);
781 if (chi2R>kChi2Cut) reject+=1;
782 if (chi2RW>kChi2Cut) reject+=2;
783 if (TMath::Abs(paramYR[0]-paramYRW[0])>kSigmaCut*csigmaY) reject+=4;
784 if (TMath::Abs(paramZR[0]-paramZRW[0])>kSigmaCut*csigmaZ) reject+=8;
785 if (TMath::Abs(paramYR[1]-paramYRW[1])>csigmaY) reject+=16;
786 if (TMath::Abs(paramZR[1]-paramZRW[1])>csigmaZ) reject+=32;
788 TTreeSRedirector *cstream = GetDebugStreamer();
789 // get fit parameters from pol2 fit:
790 Double_t tracky = paramYR[0];
791 Double_t trackz = paramZR[0];
792 Float_t deltay = cluster0->GetY()-tracky;
793 Float_t deltaz = cluster0->GetZ()-trackz;
794 Float_t angley = paramYR[1];
795 Float_t anglez = paramZR[1];
797 Int_t padSize = 0; // short pads
798 if (cluster0->GetDetector() >= 36) {
799 padSize = 1; // medium pads
800 if (cluster0->GetRow() > 63) padSize = 2; // long pads
802 Int_t ipad = TMath::Nint(cluster0->GetPad());
804 Float_t zdrift = 250 - TMath::Abs(cluster0->GetZ());
805 (*cstream)<<"Resol0"<<
806 "run="<<fRun<< // run number
807 "event="<<fEvent<< // event number
808 "time="<<fTime<< // time stamp of event
809 "trigger="<<fTrigger<< // trigger
810 "mag="<<fMagF<< // magnetic field
811 "padSize="<<padSize<<
814 "cl.="<<cluster0<< // cluster info
815 "xref="<<xref<< // cluster reference X
817 "yr="<<paramYR[0]<< // track position y - rieman fit
818 "zr="<<paramZR[0]<< // track position z - rieman fit
819 "yrW="<<paramYRW[0]<< // track position y - rieman fit - weight
820 "zrW="<<paramZRW[0]<< // track position z - rieman fit - weight
821 "dyr="<<paramYR[1]<< // track position y - rieman fit
822 "dzr="<<paramZR[1]<< // track position z - rieman fit
823 "dyrW="<<paramYRW[1]<< // track position y - rieman fit - weight
824 "dzrW="<<paramZRW[1]<< // track position z - rieman fit - weight
826 "angley="<<angley<< // angle par fit
827 "anglez="<<anglez<< // angle par fit
837 if (reject) continue;
840 // =========================================
841 // wirte collected information to histograms
842 // =========================================
844 Float_t value = fCalPadClusterPerPad->GetCalROC(sector)->GetValue((sector<36)?irow:irow-64, TMath::Nint(cluster0->GetPad()));
845 fCalPadClusterPerPad->GetCalROC(sector)->SetValue((sector<36)?irow:irow-64, ipad, value + 1 );
849 his3 = (TH3F*)fRMSY->At(padSize);
850 if (his3) his3->Fill(250 - TMath::Abs(cluster0->GetZ()), TMath::Abs(angley), TMath::Sqrt(TMath::Abs(cluster0->GetSigmaY2()) ));
851 his3 = (TH3F*)fRMSZ->At(padSize);
852 if (his3) his3->Fill( 250 - TMath::Abs(cluster0->GetZ()), TMath::Abs(anglez), TMath::Sqrt(TMath::Abs(cluster0->GetSigmaZ2()) ));
854 his3 = (TH3F*)fArrayQRMSY->At(GetBin(cluster0->GetMax(), padSize));
855 if (his3) his3->Fill( 250 - TMath::Abs(cluster0->GetZ()), TMath::Abs(angley), TMath::Sqrt(TMath::Abs(cluster0->GetSigmaY2()) ));
856 his3 = (TH3F*)fArrayQRMSZ->At(GetBin(cluster0->GetMax(), padSize));
857 if (his3) his3->Fill( 250 - TMath::Abs(cluster0->GetZ()), TMath::Abs(anglez), TMath::Sqrt(TMath::Abs(cluster0->GetSigmaZ2()) ));
860 his3 = (TH3F*)fResolY->At(padSize);
861 if (his3) his3->Fill( 250 - TMath::Abs(cluster0->GetZ()), TMath::Abs(angley), deltay );
862 his3 = (TH3F*)fResolZ->At(padSize);
863 if (his3) his3->Fill( 250 - TMath::Abs(cluster0->GetZ()), TMath::Abs(anglez), deltaz );
864 his3 = (TH3F*)fArrayQDY->At(GetBin(cluster0->GetMax(), padSize));
865 if (his3) his3->Fill( 250 - TMath::Abs(cluster0->GetZ()),TMath::Abs(angley), deltay );
866 his3 = (TH3F*)fArrayQDZ->At(GetBin(cluster0->GetMax(), padSize));
867 if (his3) his3->Fill( 250 - TMath::Abs(cluster0->GetZ()),TMath::Abs(anglez), deltaz );
868 //=============================================================================================
870 // Fill THN histograms
872 Double_t scaleQ= TMath::Min(Double_t(cluster0->GetMax()),200.)/30.;
873 Bool_t isSelected = (TMath::Exp(scaleQ)>fQDownscaleRatio*gRandom->Rndm());
874 if (!isSelected) continue;
876 xvar[1]=padSize; // pad type
877 xvar[2]=cluster0->GetZ(); //
878 xvar[3]=cluster0->GetMax();
881 double cog = cluster0->GetPad()-Int_t(cluster0->GetPad());// distance to the center of the pad
885 if( TMath::Abs(cog-0.5)<1.e-8 ) xvar[4]=-1; // fill one-pad clusters in the underflow bin
886 fHisDeltaY->Fill(xvar);
889 xvar[0]=TMath::Sqrt(cluster0->GetSigmaY2());
890 fHisRMSY->Fill(xvar);
893 xvar[4]=cluster0->GetTimeBin()-Int_t(cluster0->GetTimeBin()); // distance to the center of the time bin
895 fHisDeltaZ->Fill(xvar);
896 xvar[0]=TMath::Sqrt(cluster0->GetSigmaZ2());
897 fHisRMSZ->Fill(xvar);
899 } // loop over all padrows along the track: for (Int_t irow = 0; irow < 159; irow++)
900 } // FillResolutionHistoLocal(...)
909 void AliTPCcalibTracks::SetStyle() const {
911 // set style, can be called by all draw functions
913 gROOT->SetStyle("Plain");
914 gStyle->SetFillColor(10);
915 gStyle->SetPadColor(10);
916 gStyle->SetCanvasColor(10);
917 gStyle->SetStatColor(10);
918 gStyle->SetPalette(1,0);
919 gStyle->SetNumberContours(60);
924 void AliTPCcalibTracks::MakeReport(Int_t stat, const char* pathName){
926 // all functions are called, that produce pictures
927 // the histograms are written to the directory 'pathName'
928 // 'stat' is a threshhold: only histograms with more than 'stat' entries are wirtten to file
929 // 'stat' is also the number of minEntries for MakeResPlotsQTree
932 if (GetDebugLevel() > 0) Info("MakeReport","Writing plots and trees to '%s'.", pathName);
933 MakeResPlotsQTree(stat, pathName);
939 void AliTPCcalibTracks::MakeResPlotsQTree(Int_t minEntries, const char* pathName){
941 // Make tree with resolution parameters
942 // the result is written to 'resol.root' in directory 'pathname'
943 // file information are available in fileInfo
944 // available variables in the tree 'Resol':
945 // Entries: number of entries for this resolution point
946 // nbins: number of bins that were accumulated
947 // Dim: direction, Dim==0: y-direction, Dim==1: z-direction
948 // Pad: padSize; short, medium and long
949 // Length: pad length, 0.75, 1, 1.5
950 // QMean: mean charge of current charge bin and its neighbours, Qmean<0: integrated spectra
951 // Zc: center of middle bin in drift direction
952 // Zm: mean dirftlength for accumulated Delta-Histograms
953 // Zs: width of driftlength bin
954 // AngleC: center of middle bin in Angle-Direction
955 // AngleM: mean angle for accumulated Delta-Histograms
956 // AngleS: width of Angle-bin
957 // Resol: sigma for gaus fit through Delta-Histograms
958 // Sigma: error of sigma for gaus fit through Delta Histograms
959 // MeanR: mean of the Delta-Histogram
960 // SigmaR: rms of the Delta-Histogram
961 // RMSm: mean of the gaus fit through RMS-Histogram
962 // RMS: sigma of the gaus fit through RMS-Histogram
963 // RMSe0: error of mean of gaus fit in RMS-Histogram
964 // RMSe1: error of sigma of gaus fit in RMS-Histogram
967 if (GetDebugLevel() > -1) cout << " ***** this is MakeResPlotsQTree *****" << endl;
968 if (GetDebugLevel() > -1) cout << " relax, the calculation will take a while..." << endl;
970 gSystem->MakeDirectory(pathName);
971 gSystem->ChangeDirectory(pathName);
972 TString kFileName = "resol.root";
973 TTreeSRedirector fTreeResol(kFileName.Data());
975 TH3F *resArray[2][3][11];
976 TH3F *rmsArray[2][3][11];
978 // load histograms from fArrayQDY and fArrayQDZ
979 // into resArray and rmsArray
980 // that is all we need here
981 for (Int_t idim = 0; idim < 2; idim++){
982 for (Int_t ipad = 0; ipad < 3; ipad++){
983 for (Int_t iq = 0; iq <= 10; iq++){
984 rmsArray[idim][ipad][iq]=0;
985 resArray[idim][ipad][iq]=0;
986 Int_t bin = GetBin(iq,ipad);
988 if (idim == 0) hresl = (TH3F*)fArrayQDY->At(bin);
989 if (idim == 1) hresl = (TH3F*)fArrayQDZ->At(bin);
990 if (!hresl) continue;
991 resArray[idim][ipad][iq] = (TH3F*) hresl->Clone();
992 resArray[idim][ipad][iq]->SetDirectory(0);
994 if (idim == 0) hreslRMS = (TH3F*)fArrayQRMSY->At(bin);
995 if (idim == 1) hreslRMS = (TH3F*)fArrayQRMSZ->At(bin);
996 if (!hreslRMS) continue;
997 rmsArray[idim][ipad][iq] = (TH3F*) hreslRMS->Clone();
998 rmsArray[idim][ipad][iq]->SetDirectory(0);
1002 if (GetDebugLevel() > -1) cout << "Histograms loaded, starting to proces..." << endl;
1004 //--------------------------------------------------------------------------------------------
1008 Double_t zMean, angleMean, zCenter, angleCenter;
1009 Double_t zSigma, angleSigma;
1010 TH1D *projectionRes = new TH1D("projectionRes", "projectionRes", 50, -1, 1);
1011 TH1D *projectionRms = new TH1D("projectionRms", "projectionRms", 50, -1, 1);
1012 TF1 *fitFunction = new TF1("fitFunction", "gaus");
1013 Float_t entriesQ = 0;
1014 Int_t loopCounter = 1;
1016 for (Int_t idim = 0; idim < 2; idim++){
1017 // Loop y-z corrdinate
1018 for (Int_t ipad = 0; ipad < 3; ipad++){
1020 for (Int_t iq = -1; iq < 10; iq++){
1022 if (GetDebugLevel() > -1)
1023 cout << "Loop-counter, this is loop " << loopCounter << " of 66, ("
1024 << (Int_t)((loopCounter)/66.*100) << "% done), "
1025 << "idim = " << idim << ", ipad = " << ipad << ", iq = " << iq << " \r" << std::flush;
1034 // integrated spectra
1035 for (Int_t iql = 0; iql < 10; iql++){
1036 Int_t bin = GetBin(iql,ipad);
1037 TH3F *hresl = resArray[idim][ipad][iql];
1038 TH3F *hrmsl = rmsArray[idim][ipad][iql];
1039 if (!hresl) continue;
1040 if (!hrmsl) continue;
1041 entriesQ += hresl->GetEntries();
1042 qMean += hresl->GetEntries() * GetQ(bin);
1044 hres = (TH3F*)hresl->Clone();
1045 hrms = (TH3F*)hrmsl->Clone();
1053 qMean *= -1.; // integral mean charge
1056 // loop over neighboured Q-bins
1057 // accumulate entries from neighboured Q-bins
1058 for (Int_t iql = iq - 1; iql <= iq + 1; iql++){
1059 if (iql < 0) continue;
1060 Int_t bin = GetBin(iql,ipad);
1061 TH3F * hresl = resArray[idim][ipad][iql];
1062 TH3F * hrmsl = rmsArray[idim][ipad][iql];
1063 if (!hresl) continue;
1064 if (!hrmsl) continue;
1065 entriesQ += hresl->GetEntries();
1066 qMean += hresl->GetEntries() * GetQ(bin);
1068 hres = (TH3F*) hresl->Clone();
1069 hrms = (TH3F*) hrmsl->Clone();
1078 if (!hres) continue;
1079 if (!hrms) continue;
1081 TAxis *xAxisDriftLength = hres->GetXaxis(); // driftlength / z - axis
1082 TAxis *yAxisAngle = hres->GetYaxis(); // angle axis
1083 TAxis *zAxisDelta = hres->GetZaxis(); // delta axis
1084 TAxis *zAxisRms = hrms->GetZaxis(); // rms axis
1086 // loop over all angle bins
1087 for (Int_t ibinyAngle = 1; ibinyAngle <= yAxisAngle->GetNbins(); ibinyAngle++) {
1088 angleCenter = yAxisAngle->GetBinCenter(ibinyAngle);
1089 // loop over all driftlength bins
1090 for (Int_t ibinxDL = 1; ibinxDL <= xAxisDriftLength->GetNbins(); ibinxDL++) {
1091 zCenter = xAxisDriftLength->GetBinCenter(ibinxDL);
1092 zSigma = xAxisDriftLength->GetBinWidth(ibinxDL);
1093 angleSigma = yAxisAngle->GetBinWidth(ibinyAngle);
1094 zMean = zCenter; // changens, when more statistic is accumulated
1095 angleMean = angleCenter; // changens, when more statistic is accumulated
1097 // create 2 1D-Histograms, projectionRes and projectionRms
1098 // these histograms are delta histograms for given direction, padSize, chargeBin,
1099 // angleBin and driftLengthBin
1100 // later on they will be fitted with a gausian, its sigma is the resoltuion...
1101 snprintf(name,200,"%s, zCenter: %f, angleCenter: %f", hres->GetName(), zCenter, angleCenter);
1102 // TH1D * projectionRes = new TH1D(name, name, zAxisDelta->GetNbins(), zAxisDelta->GetXmin(), zAxisDelta->GetXmax());
1103 projectionRes->SetNameTitle(name, name);
1104 snprintf(name,200,"%s, zCenter: %f, angleCenter: %f", hrms->GetName(),zCenter,angleCenter);
1105 // TH1D * projectionRms = new TH1D(name, name, zAxisDelta->GetNbins(), zAxisRms->GetXmin(), zAxisRms->GetXmax());
1106 projectionRms->SetNameTitle(name, name);
1108 projectionRes->Reset();
1109 projectionRes->SetBins(zAxisDelta->GetNbins(), zAxisDelta->GetXmin(), zAxisDelta->GetXmax());
1110 projectionRms->Reset();
1111 projectionRms->SetBins(zAxisRms->GetNbins(), zAxisRms->GetXmin(), zAxisRms->GetXmax());
1112 projectionRes->SetDirectory(0);
1113 projectionRms->SetDirectory(0);
1115 Double_t entries = 0;
1116 Int_t nbins = 0; // counts, how many bins were accumulated
1121 // fill projectionRes and projectionRms for given dim, ipad and iq,
1122 // as well as for given angleBin and driftlengthBin
1123 // if this gives not enough statistic, include neighbourhood
1124 // (angle and driftlength) successifely
1125 for (Int_t dbin = 0; dbin <= 8; dbin++){ // delta-bins around centered angleBin and driftlengthBin
1126 for (Int_t dbiny2 = -1; dbiny2 <= 1; dbiny2++) { // delta-bins in angle direction
1127 for (Int_t dbinx2 = -3; dbinx2 <= 3; dbinx2++){ // delta-bins in driftlength direction
1128 if (TMath::Abs(dbinx2) + TMath::Abs(dbiny2) != dbin) continue; // add each bin only one time !
1129 Int_t binx2 = ibinxDL + dbinx2; // position variable in x (driftlength) direction
1130 Int_t biny2 = ibinyAngle + dbiny2; // position variable in y (angle) direction
1131 if (binx2 < 1 || biny2 < 1) continue; // don't go out of the histogram!
1132 if (binx2 >= xAxisDriftLength->GetNbins()) continue; // don't go out of the histogram!
1133 if (biny2 >= yAxisAngle->GetNbins()) continue; // don't go out of the histogram!
1134 nbins++; // count the number of accumulated bins
1135 // Fill resolution histo
1136 for (Int_t ibin3 = 1; ibin3 < zAxisDelta->GetNbins(); ibin3++) {
1137 // Int_t content = (Int_t)hres->GetBinContent(binx2, biny2, ibin3); // unused variable
1138 projectionRes->Fill(zAxisDelta->GetBinCenter(ibin3), hres->GetBinContent(binx2, biny2, ibin3));
1139 entries += hres->GetBinContent(binx2, biny2, ibin3);
1140 zMean += hres->GetBinContent(binx2, biny2, ibin3) * xAxisDriftLength->GetBinCenter(binx2);
1141 angleMean += hres->GetBinContent(binx2, biny2, ibin3) * yAxisAngle->GetBinCenter(biny2);
1144 for (Int_t ibin3 = 1; ibin3 < zAxisRms->GetNbins(); ibin3++) {
1145 projectionRms->Fill(zAxisRms->GetBinCenter(ibin3), hrms->GetBinContent(binx2, biny2, ibin3));
1148 if (entries > minEntries) break; // enough statistic accumulated
1150 if (entries > minEntries) break; // enough statistic accumulated
1152 if ( entries< minEntries) continue; // when it was absolutly impossible to get enough statistic, don't write this point into the resolution tree
1154 angleMean /= entries;
1156 if (entries > minEntries) {
1157 // when enough statistic is accumulated
1158 // fit Delta histograms with a gausian
1159 // of the gausian is the resolution (resol), its fit error is sigma
1160 // store also mean and RMS of the histogram
1161 Float_t xmin = projectionRes->GetMean() - 2. * projectionRes->GetRMS() - 0.2;
1162 Float_t xmax = projectionRes->GetMean() + 2. * projectionRes->GetRMS() + 0.2;
1164 // projectionRes->Fit("gaus", "q0", "", xmin, xmax);
1165 // Float_t resol = projectionRes->GetFunction("gaus")->GetParameter(2);
1166 // Float_t sigma = projectionRes->GetFunction("gaus")->GetParError(2);
1167 fitFunction->SetMaximum(xmax);
1168 fitFunction->SetMinimum(xmin);
1169 projectionRes->Fit("fitFunction", "qN0", "", xmin, xmax);
1170 Float_t resol = fitFunction->GetParameter(2);
1171 Float_t sigma = fitFunction->GetParError(2);
1173 Float_t meanR = projectionRes->GetMean();
1174 Float_t sigmaR = projectionRes->GetRMS();
1175 // fit also RMS histograms with a gausian
1176 // store mean and sigma of the gausian in rmsMean and rmsSigma
1177 // store also the fit errors in errorRMS and errorSigma
1178 xmin = projectionRms->GetMean() - 2. * projectionRes->GetRMS() - 0.2;
1179 xmax = projectionRms->GetMean() + 2. * projectionRes->GetRMS() + 0.2;
1181 // projectionRms->Fit("gaus","q0","",xmin,xmax);
1182 // Float_t rmsMean = projectionRms->GetFunction("gaus")->GetParameter(1);
1183 // Float_t rmsSigma = projectionRms->GetFunction("gaus")->GetParameter(2);
1184 // Float_t errorRMS = projectionRms->GetFunction("gaus")->GetParError(1);
1185 // Float_t errorSigma = projectionRms->GetFunction("gaus")->GetParError(2);
1186 projectionRms->Fit("fitFunction", "qN0", "", xmin, xmax);
1187 Float_t rmsMean = fitFunction->GetParameter(1);
1188 Float_t rmsSigma = fitFunction->GetParameter(2);
1189 Float_t errorRMS = fitFunction->GetParError(1);
1190 Float_t errorSigma = fitFunction->GetParError(2);
1192 Float_t length = 0.75;
1193 if (ipad == 1) length = 1;
1194 if (ipad == 2) length = 1.5;
1196 fTreeResol<<"Resol"<<
1197 "Entries="<<entries<< // number of entries for this resolution point
1198 "nbins="<<nbins<< // number of bins that were accumulated
1199 "Dim="<<idim<< // direction, Dim==0: y-direction, Dim==1: z-direction
1200 "Pad="<<ipad<< // padSize; short, medium and long
1201 "Length="<<length<< // pad length, 0.75, 1, 1.5
1202 "QMean="<<qMean<< // mean charge of current charge bin and its neighbours, Qmean<0: integrated spectra
1203 "Zc="<<zCenter<< // center of middle bin in drift direction
1204 "Zm="<<zMean<< // mean dirftlength for accumulated Delta-Histograms
1205 "Zs="<<zSigma<< // width of driftlength bin
1206 "AngleC="<<angleCenter<< // center of middle bin in Angle-Direction
1207 "AngleM="<<angleMean<< // mean angle for accumulated Delta-Histograms
1208 "AngleS="<<angleSigma<< // width of Angle-bin
1209 "Resol="<<resol<< // sigma for gaus fit through Delta-Histograms
1210 "Sigma="<<sigma<< // error of sigma for gaus fit through Delta Histograms
1211 "MeanR="<<meanR<< // mean of the Delta-Histogram
1212 "SigmaR="<<sigmaR<< // rms of the Delta-Histogram
1213 "RMSm="<<rmsMean<< // mean of the gaus fit through RMS-Histogram
1214 "RMSs="<<rmsSigma<< // sigma of the gaus fit through RMS-Histogram
1215 "RMSe0="<<errorRMS<< // error of mean of gaus fit in RMS-Histogram
1216 "RMSe1="<<errorSigma<< // error of sigma of gaus fit in RMS-Histogram
1218 if (GetDebugLevel() > 5) {
1219 projectionRes->SetDirectory(fTreeResol.GetFile());
1220 projectionRes->Write(projectionRes->GetName());
1221 projectionRes->SetDirectory(0);
1222 projectionRms->SetDirectory(fTreeResol.GetFile());
1223 projectionRms->Write(projectionRms->GetName());
1224 projectionRes->SetDirectory(0);
1226 } // if (projectionRes->GetSum() > minEntries)
1227 } // for (Int_t ibinxDL = 1; ibinxDL <= xAxisDriftLength->GetNbins(); ibinxDL++)
1228 } // for (Int_t ibinyAngle = 1; ibinyAngle <= yAxisAngle->GetNbins(); ibinyAngle++)
1233 delete projectionRes;
1234 delete projectionRms;
1236 // TFile resolFile(fTreeResol.GetFile());
1237 TObjString fileInfo(Form("Resolution tree, minEntries = %i", minEntries));
1238 fileInfo.Write("fileInfo");
1239 // resolFile.Close();
1240 // fTreeResol.GetFile()->Close();
1241 if (GetDebugLevel() > -1) cout << endl;
1242 if (GetDebugLevel() > -1) cout << "MakeResPlotsQTree done, results are in '"<< kFileName.Data() <<"'." << endl;
1243 gSystem->ChangeDirectory("..");
1250 Long64_t AliTPCcalibTracks::Merge(TCollection *collectionList) {
1252 // function to merge several AliTPCcalibTracks objects after PROOF calculation
1253 // The object's histograms are merged via their merge functions
1254 // Be carefull: histograms are linked to a file, switch this off by TH1::AddDirectory(kFALSE) !!!
1257 if (GetDebugLevel() > 0) cout << " ***** this is AliTPCcalibTracks::Merge(TCollection *collectionList) *****"<< endl;
1258 if (!collectionList) return 0;
1259 if (collectionList->IsEmpty()) return -1;
1261 if (GetDebugLevel() > 1) cout << "the collectionList contains " << collectionList->GetEntries() << " entries." << endl; // REMOVE THIS LINE!!!!!!!!!!!!!!!!!1
1262 if (GetDebugLevel() > 5) cout << " the list in the merge-function looks as follows: " << endl;
1263 collectionList->Print();
1265 // create a list for each data member
1266 TList* deltaYList = new TList;
1267 TList* deltaZList = new TList;
1268 TList* arrayAmpRowList = new TList;
1269 TList* rejectedTracksList = new TList;
1270 TList* clusterCutHistoList = new TList;
1271 TList* arrayAmpList = new TList;
1272 TList* arrayQDYList = new TList;
1273 TList* arrayQDZList = new TList;
1274 TList* arrayQRMSYList = new TList;
1275 TList* arrayQRMSZList = new TList;
1276 TList* resolYList = new TList;
1277 TList* resolZList = new TList;
1278 TList* rMSYList = new TList;
1279 TList* rMSZList = new TList;
1281 // TList* nRowsList = new TList;
1282 // TList* nSectList = new TList;
1283 // TList* fileNoList = new TList;
1285 TIterator *listIterator = collectionList->MakeIterator();
1286 AliTPCcalibTracks *calibTracks = 0;
1287 if (GetDebugLevel() > 1) cout << "start to iterate, filling lists" << endl;
1289 while ( (calibTracks = dynamic_cast<AliTPCcalibTracks*> (listIterator->Next())) ){
1290 // loop over all entries in the collectionList and get dataMembers into lists
1292 arrayQDYList->Add(calibTracks->GetfArrayQDY());
1293 arrayQDZList->Add(calibTracks->GetfArrayQDZ());
1294 arrayQRMSYList->Add(calibTracks->GetfArrayQRMSY());
1295 arrayQRMSZList->Add(calibTracks->GetfArrayQRMSZ());
1296 resolYList->Add(calibTracks->GetfResolY());
1297 resolZList->Add(calibTracks->GetfResolZ());
1298 rMSYList->Add(calibTracks->GetfRMSY());
1299 rMSZList->Add(calibTracks->GetfRMSZ());
1300 rejectedTracksList->Add(calibTracks->GetfRejectedTracksHisto());
1301 clusterCutHistoList->Add(calibTracks->GetfClusterCutHisto());
1303 if (fCalPadClusterPerPad && calibTracks->GetfCalPadClusterPerPad())
1304 fCalPadClusterPerPad->Add(calibTracks->GetfCalPadClusterPerPad());
1305 // fCalPadClusterPerPadRaw->Add(calibTracks->GetfCalPadClusterPerPadRaw());
1307 if (GetDebugLevel() > 5) cout << "filling lists, object " << counter << " added." << endl;
1308 AddHistos(calibTracks);
1312 // merge data members
1313 if (GetDebugLevel() > 0) cout << "histogram's merge-functins are called... " << endl;
1314 fClusterCutHisto->Merge(clusterCutHistoList);
1315 fRejectedTracksHisto->Merge(rejectedTracksList);
1317 TObjArray* objarray = 0;
1319 TList* histList = 0;
1320 TIterator *objListIterator = 0;
1323 if (GetDebugLevel() > 0) cout << "merging fArrayQDY..." << endl;
1325 for (Int_t i = 0; i < fArrayQDY->GetEntriesFast(); i++) { // loop over data member, i < 300
1326 objListIterator = arrayQDYList->MakeIterator();
1327 histList = new TList;
1328 while (( objarray = (TObjArray*)objListIterator->Next() )) {
1329 // loop over arrayQDYList, get TObjArray, get object at position i, cast it into TH3F
1330 hist = (TH3F*)(objarray->At(i));
1331 histList->Add(hist);
1333 ((TH3F*)(fArrayQDY->At(i)))->Merge(histList);
1335 delete objListIterator;
1338 if (GetDebugLevel() > 0) cout << "merging fArrayQDZ..." << endl;
1340 for (Int_t i = 0; i < fArrayQDZ->GetEntriesFast(); i++) { // loop over data member, i < 300
1341 objListIterator = arrayQDZList->MakeIterator();
1342 histList = new TList;
1343 while (( objarray = (TObjArray*)objListIterator->Next() )) {
1344 // loop over arrayQDZList, get TObjArray, get object at position i, cast it into TH3F
1345 hist = (TH3F*)(objarray->At(i));
1346 histList->Add(hist);
1348 ((TH3F*)(fArrayQDZ->At(i)))->Merge(histList);
1350 delete objListIterator;
1353 if (GetDebugLevel() > 0) cout << "merging fArrayQRMSY..." << endl;
1354 // merge fArrayQRMSY
1355 for (Int_t i = 0; i < fArrayQRMSY->GetEntriesFast(); i++) { // loop over data member, i < 300
1356 objListIterator = arrayQRMSYList->MakeIterator();
1357 histList = new TList;
1358 while (( objarray = (TObjArray*)objListIterator->Next() )) {
1359 // loop over arrayQDZList, get TObjArray, get object at position i, cast it into TH3F
1360 // if (!objarray) continue; // removed for coverity -> JMT
1361 hist = (TH3F*)(objarray->At(i));
1362 histList->Add(hist);
1364 ((TH3F*)(fArrayQRMSY->At(i)))->Merge(histList);
1366 delete objListIterator;
1369 if (GetDebugLevel() > 0) cout << "merging fArrayQRMSZ..." << endl;
1370 // merge fArrayQRMSZ
1371 for (Int_t i = 0; i < fArrayQRMSZ->GetEntriesFast(); i++) { // loop over data member, i < 300
1372 objListIterator = arrayQRMSZList->MakeIterator();
1373 histList = new TList;
1374 while (( objarray = (TObjArray*)objListIterator->Next() )) {
1375 // loop over arrayQDZList, get TObjArray, get object at position i, cast it into TH3F
1376 hist = (TH3F*)(objarray->At(i));
1377 histList->Add(hist);
1379 ((TH3F*)(fArrayQRMSZ->At(i)))->Merge(histList);
1381 delete objListIterator;
1389 if (GetDebugLevel() > 0) cout << "starting to merge the rest: fResolY, fResolZ , fRMSY, fRMSZ..." << endl;
1391 for (Int_t i = 0; i < fResolY->GetEntriesFast(); i++) { // loop over data member, i < 3
1392 objListIterator = resolYList->MakeIterator();
1393 histList = new TList;
1394 while (( objarray = (TObjArray*)objListIterator->Next() )) {
1395 // loop over arrayQDZList, get TObjArray, get object at position i, cast it into TH3F
1396 hist = (TH3F*)(objarray->At(i));
1397 histList->Add(hist);
1399 ((TH3F*)(fResolY->At(i)))->Merge(histList);
1401 delete objListIterator;
1405 for (Int_t i = 0; i < fResolZ->GetEntriesFast(); i++) { // loop over data member, i < 3
1406 objListIterator = resolZList->MakeIterator();
1407 histList = new TList;
1408 while (( objarray = (TObjArray*)objListIterator->Next() )) {
1409 // loop over arrayQDZList, get TObjArray, get object at position i, cast it into TH3F
1410 hist = (TH3F*)(objarray->At(i));
1411 histList->Add(hist);
1413 ((TH3F*)(fResolZ->At(i)))->Merge(histList);
1415 delete objListIterator;
1419 for (Int_t i = 0; i < fRMSY->GetEntriesFast(); i++) { // loop over data member, i < 3
1420 objListIterator = rMSYList->MakeIterator();
1421 histList = new TList;
1422 while (( objarray = (TObjArray*)objListIterator->Next() )) {
1423 // loop over arrayQDZList, get TObjArray, get object at position i, cast it into TH3F
1424 hist = (TH3F*)(objarray->At(i));
1425 histList->Add(hist);
1427 ((TH3F*)(fRMSY->At(i)))->Merge(histList);
1429 delete objListIterator;
1433 for (Int_t i = 0; i < fRMSZ->GetEntriesFast(); i++) { // loop over data member, i < 3
1434 objListIterator = rMSZList->MakeIterator();
1435 histList = new TList;
1436 while (( objarray = (TObjArray*)objListIterator->Next() )) {
1437 // loop over arrayQDZList, get TObjArray, get object at position i, cast it into TH3F
1438 hist = (TH3F*)(objarray->At(i));
1439 histList->Add(hist);
1441 ((TH3F*)(fRMSZ->At(i)))->Merge(histList);
1443 delete objListIterator;
1448 delete arrayAmpRowList;
1449 delete arrayAmpList;
1450 delete arrayQDYList;
1451 delete arrayQDZList;
1452 delete arrayQRMSYList;
1453 delete arrayQRMSZList;
1458 delete listIterator;
1460 if (GetDebugLevel() > 0) cout << "merging done!" << endl;
1468 void AliTPCcalibTracks::MakeHistos(){
1472 //THnSparse *fHisDeltaY; // THnSparse - delta Y
1473 //THnSparse *fHisDeltaZ; // THnSparse - delta Z
1474 //THnSparse *fHisRMSY; // THnSparse - rms Y
1475 //THnSparse *fHisRMSZ; // THnSparse - rms Z
1476 //THnSparse *fHisQmax; // THnSparse - qmax
1477 //THnSparse *fHisQtot; // THnSparse - qtot
1478 // cluster performance bins
1479 // 0 - variable of interest
1480 // 1 - pad type - 0- short 1-medium 2-long pads
1481 // 2 - drift length - drift length -0-1
1482 // 3 - Qmax - Qmax - 2- 400
1483 // 4 - cog - COG position - 0-1
1484 // 5 - tan(phi) - local y angle
1485 // 6 - tan(theta) - local z angle
1486 // 7 - sector - sector number
1487 Double_t xminTrack[8], xmaxTrack[8];
1489 TString axisName[8];
1496 xminTrack[1] =0; xmaxTrack[1]=3;
1497 axisName[1] ="pad type";
1500 xminTrack[2] =-250; xmaxTrack[2]=250;
1504 xminTrack[3] =1; xmaxTrack[3]=400;
1505 axisName[3] ="Qmax";
1508 xminTrack[4] =0; xmaxTrack[4]=1;
1512 xminTrack[5] =-1.5; xmaxTrack[5]=1.5;
1513 axisName[5] ="tan(angle)";
1516 xminTrack[0] =-1.5; xmaxTrack[0]=1.5;
1517 fHisDeltaY=new THnSparseF("#Delta_{y} (cm)","#Delta_{y} (cm)", 6, binsTrack,xminTrack, xmaxTrack);
1518 xminTrack[0] =-1.5; xmaxTrack[0]=1.5;
1519 fHisDeltaZ=new THnSparseF("#Delta_{z} (cm)","#Delta_{z} (cm)", 6, binsTrack,xminTrack, xmaxTrack);
1520 xminTrack[0] =0.; xmaxTrack[0]=0.5;
1521 fHisRMSY=new THnSparseF("#RMS_{y} (cm)","#RMS_{y} (cm)", 6, binsTrack,xminTrack, xmaxTrack);
1522 xminTrack[0] =0.; xmaxTrack[0]=0.5;
1523 fHisRMSZ=new THnSparseF("#RMS_{z} (cm)","#RMS_{z} (cm)", 6, binsTrack,xminTrack, xmaxTrack);
1524 xminTrack[0] =0.; xmaxTrack[0]=100;
1525 fHisQmax=new THnSparseF("Qmax (ADC)","Qmax (ADC)", 6, binsTrack,xminTrack, xmaxTrack);
1527 xminTrack[0] =0.; xmaxTrack[0]=250;
1528 fHisQtot=new THnSparseF("Qtot (ADC)","Qtot (ADC)", 6, binsTrack,xminTrack, xmaxTrack);
1531 for (Int_t ivar=0;ivar<6;ivar++){
1532 fHisDeltaY->GetAxis(ivar)->SetName(axisName[ivar].Data());
1533 fHisDeltaZ->GetAxis(ivar)->SetName(axisName[ivar].Data());
1534 fHisRMSY->GetAxis(ivar)->SetName(axisName[ivar].Data());
1535 fHisRMSZ->GetAxis(ivar)->SetName(axisName[ivar].Data());
1536 fHisQmax->GetAxis(ivar)->SetName(axisName[ivar].Data());
1537 fHisQtot->GetAxis(ivar)->SetName(axisName[ivar].Data());
1538 fHisDeltaY->GetAxis(ivar)->SetTitle(axisName[ivar].Data());
1539 fHisDeltaZ->GetAxis(ivar)->SetName(axisName[ivar].Data());
1540 fHisRMSY->GetAxis(ivar)->SetName(axisName[ivar].Data());
1541 fHisRMSZ->GetAxis(ivar)->SetName(axisName[ivar].Data());
1542 fHisQmax->GetAxis(ivar)->SetName(axisName[ivar].Data());
1543 fHisQtot->GetAxis(ivar)->SetName(axisName[ivar].Data());
1547 BinLogX(fHisDeltaY,3);
1548 BinLogX(fHisDeltaZ,3);
1549 BinLogX(fHisRMSY,3);
1550 BinLogX(fHisRMSZ,3);
1551 BinLogX(fHisQmax,3);
1552 BinLogX(fHisQtot,3);
1556 void AliTPCcalibTracks::AddHistos(AliTPCcalibTracks* calib){
1560 if (!calib->fHisDeltaY) return;
1561 if (calib->fHisDeltaY->GetEntries()> fgkMergeEntriesCut) return;
1562 if (calib->fHisDeltaY) fHisDeltaY->Add(calib->fHisDeltaY);
1563 if (calib->fHisDeltaZ) fHisDeltaZ->Add(calib->fHisDeltaZ);
1564 if (calib->fHisRMSY) fHisRMSY->Add(calib->fHisRMSY);
1565 if (calib->fHisRMSZ) fHisRMSZ->Add(calib->fHisRMSZ);
1570 void AliTPCcalibTracks::MakeSummaryTree(THnSparse *hisInput, TTreeSRedirector *pcstream, Int_t ptype){
1572 // Dump summary info
1575 // 1.OBJ: TAxis pad type
1577 // 3.OBJ: TAxis Qmax
1579 // 5.OBJ: TAxis tan(angle)
1581 if (ptype>3) return;
1582 Int_t idim[6]={0,1,2,3,4,5};
1583 TString hname[4]={"dy","dz","rmsy","rmsz"};
1585 Int_t nbins5=hisInput->GetAxis(5)->GetNbins();
1586 Int_t first5=hisInput->GetAxis(5)->GetFirst();
1587 Int_t last5 =hisInput->GetAxis(5)->GetLast();
1589 for (Int_t ibin5=first5-1; ibin5<=last5; ibin5+=1){ // axis 5 - local angle
1590 Bool_t bin5All=kTRUE;
1592 hisInput->GetAxis(5)->SetRange(TMath::Max(ibin5-1,first5),TMath::Min(ibin5+1,nbins5));
1593 if (ibin5==first5) hisInput->GetAxis(5)->SetRange(TMath::Max(ibin5,first5),TMath::Min(ibin5,nbins5));
1596 Double_t x5= hisInput->GetAxis(5)->GetBinCenter(ibin5);
1597 THnSparse * his5= hisInput->Projection(5,idim); //projected histogram according selection 5
1598 Int_t nbins4=his5->GetAxis(4)->GetNbins();
1599 Int_t first4=his5->GetAxis(4)->GetFirst();
1600 Int_t last4 =his5->GetAxis(4)->GetLast();
1602 for (Int_t ibin4=first4-1; ibin4<=last4; ibin4+=1){ // axis 4 - cog
1603 Bool_t bin4All=kTRUE;
1605 his5->GetAxis(4)->SetRange(TMath::Max(ibin4+1,first4),TMath::Min(ibin4-1,nbins4));
1606 if (ibin4==first4||ibin4==last4) his5->GetAxis(4)->SetRange(TMath::Max(ibin4,first4),TMath::Min(ibin4,nbins4));
1609 Double_t x4= his5->GetAxis(4)->GetBinCenter(ibin4);
1610 THnSparse * his4= his5->Projection(4,idim); //projected histogram according selection 4
1612 Int_t nbins3=his4->GetAxis(3)->GetNbins();
1613 Int_t first3=his4->GetAxis(3)->GetFirst();
1614 Int_t last3 =his4->GetAxis(3)->GetLast();
1616 for (Int_t ibin3=first3-1; ibin3<=last3; ibin3+=1){ // axis 3 - Qmax
1617 Bool_t bin3All=kTRUE;
1619 his4->GetAxis(3)->SetRange(TMath::Max(ibin3,first3),TMath::Min(ibin3,nbins3));
1622 Double_t x3= his4->GetAxis(3)->GetBinCenter(ibin3);
1623 THnSparse * his3= his4->Projection(3,idim); //projected histogram according selection 3
1625 Int_t nbins2 = his3->GetAxis(2)->GetNbins();
1626 Int_t first2 = his3->GetAxis(2)->GetFirst();
1627 Int_t last2 = his3->GetAxis(2)->GetLast();
1629 for (Int_t ibin2=first2-1; ibin2<=last2; ibin2+=1){ // axis 2 - z
1630 Bool_t bin2All=kTRUE;
1631 Double_t x2= his3->GetAxis(2)->GetBinCenter(ibin2);
1633 his3->GetAxis(2)->SetRange(TMath::Max(ibin2-1,first2),TMath::Min(ibin2+1,nbins2));
1634 if (ibin2==first2||ibin2==last2||TMath::Abs(x2)<20) his3->GetAxis(2)->SetRange(TMath::Max(ibin2,first2),TMath::Min(ibin2,nbins2));
1637 THnSparse * his2= his3->Projection(2,idim); //projected histogram according selection 2
1639 Int_t nbins1 = his2->GetAxis(1)->GetNbins();
1640 Int_t first1 = his2->GetAxis(1)->GetFirst();
1641 Int_t last1 = his2->GetAxis(1)->GetLast();
1642 for (Int_t ibin1=first1-1; ibin1<=last1; ibin1++){ //axis 1 - pad type
1643 Bool_t bin1All=kTRUE;
1645 his2->GetAxis(1)->SetRange(TMath::Max(ibin1,1),TMath::Min(ibin1,nbins1));
1648 Double_t x1= TMath::Nint(his2->GetAxis(1)->GetBinCenter(ibin1)-0.5);
1649 TH1 * hisDelta = his2->Projection(0);
1650 Double_t entries = hisDelta->GetEntries();
1651 Double_t mean=0, rms=0;
1653 mean = hisDelta->GetMean();
1654 rms = hisDelta->GetRMS();
1655 hisDelta->GetXaxis()->SetRangeUser(mean-4*rms,mean+4*rms);
1656 mean = hisDelta->GetMean();
1657 rms = hisDelta->GetRMS();
1660 (*pcstream)<<hname[ptype].Data()<<
1661 // flag - intgrated values for given bin
1662 "angleA="<<bin5All<<
1667 // center of bin value
1668 "angle="<<x5<< // local angle
1669 "cog="<<x4<< // distance cluster to center
1670 "qmax="<<x3<< // qmax
1671 "z="<<x2<< // z of the cluster
1672 "ipad="<<x1<< // type of the region
1675 "entries="<<entries<<
1678 "ptype="<<ptype<< //
1681 printf("%f\t%f\t%f\t%f\t%f\t%f\t%f\n",x5,x4,x3,x2,x1, entries,mean);
1694 int AliTPCcalibTracks::GetTHnStat(const THnBase *H, THnBase *&Mean, THnBase *&Sigma, THnBase *&Entr )
1698 // OBJ: TAxis var var
1699 // OBJ: TAxis axis 1
1700 // OBJ: TAxis axis 2
1705 // Mean, Sigma and Entr is THnF of mean, RMS and entries of var:
1707 // OBJ: TAxis axis 1
1708 // OBJ: TAxis axis 2
1718 int nDim = H->GetNdimensions();
1719 Long64_t nFilledBins = H->GetNbins();
1720 Long64_t nStatBins = 0;
1722 Int_t *nBins = new Int_t [nDim];
1723 Double_t *xMin = new Double_t [nDim];
1724 Double_t *xMax = new Double_t [nDim];
1725 Int_t *idx = new Int_t [nDim];
1727 TString nameMean = H->GetName();
1728 TString nameSigma = H->GetName();
1729 TString nameEntr = H->GetName();
1731 nameSigma+="_Sigma";
1734 ok = ok && ( nBins && xMin && xMax && idx );
1737 for( int i=0; i<nDim; i++){
1738 xMin[i] = H->GetAxis(i)->GetXmin();
1739 xMax[i] = H->GetAxis(i)->GetXmax();
1740 nBins[i] = H->GetAxis(i)->GetNbins();
1743 Mean = new THnSparseF( nameMean.Data(), nameMean.Data(), nDim-1, nBins+1, xMin+1, xMax+1 );
1744 Sigma = new THnSparseF( nameSigma.Data(), nameSigma.Data(), nDim-1, nBins+1, xMin+1, xMax+1 );
1745 Entr = new THnSparseF( nameEntr.Data(), nameEntr.Data(), nDim-1, nBins+1, xMin+1, xMax+1 );
1748 ok = ok && ( Mean && Sigma && Entr );
1751 for( int i=0; i<nDim-1; i++){
1752 const TAxis *ax = H->GetAxis(i+1);
1753 Mean->GetAxis(i)->SetName(ax->GetName());
1754 Mean->GetAxis(i)->SetTitle(ax->GetTitle());
1755 Sigma->GetAxis(i)->SetName(ax->GetName());
1756 Sigma->GetAxis(i)->SetTitle(ax->GetTitle());
1757 Entr->GetAxis(i)->SetName(ax->GetName());
1758 Entr->GetAxis(i)->SetTitle(ax->GetTitle());
1759 if( ax->GetXbins()->fN>0 ){
1760 Mean->GetAxis(i)->Set(ax->GetNbins(), ax->GetXbins()->GetArray());
1761 Sigma->GetAxis(i)->Set(ax->GetNbins(), ax->GetXbins()->GetArray());
1762 Entr->GetAxis(i)->Set(ax->GetNbins(), ax->GetXbins()->GetArray());
1768 for( Long64_t binS=0; binS<nFilledBins; binS++){
1769 H->GetBinContent(binS,idx);
1770 Mean->GetBin(idx+1,kTRUE);
1771 Sigma->GetBin(idx+1,kTRUE);
1772 Entr->GetBin(idx+1,kTRUE);
1775 nStatBins = Mean->GetNbins();
1780 Long64_t *hMap = new Long64_t[nFilledBins];
1781 Double_t *hVal = new Double_t[nFilledBins];
1782 Double_t *hEntr = new Double_t[nFilledBins];
1783 Double_t *meanD = new Double_t[nStatBins];
1784 Double_t *sigmaD = new Double_t[nStatBins];
1786 ok = ok && ( hMap && hVal && hEntr && meanD && sigmaD );
1788 // Map bins to Stat bins
1791 for( Long64_t binS=0; binS<nFilledBins; binS++){
1792 double val = H->GetBinContent(binS,idx);
1793 Long64_t bin = Mean->GetBin(idx+1,kFALSE);
1794 ok = ok && ( bin>=0 && bin<nStatBins && bin==Sigma->GetBin(idx+1,kFALSE) && bin== Entr->GetBin(idx+1,kFALSE) );
1797 cout << "AliTPCcalibTracks: GetSparseStat : Unexpected content of the input THn"<<endl;
1800 if( idx[0]<1 || idx[0]>nBins[0] ) bin = -1;
1802 hVal[binS] = idx[0];
1807 // do 2 iteration with cut at 4 Sigma
1809 for( int iter=0; ok && iter<2; iter++ ){
1813 for( Long64_t bin=0; bin < nStatBins; bin++){
1814 Entr->SetBinContent(bin, 0);
1819 // get Entries and Mean
1821 for( Long64_t binS=0; binS<nFilledBins; binS++){
1822 Long64_t bin = hMap[binS];
1823 Double_t val = hVal[binS];
1824 Double_t entr = hEntr[binS];
1825 if( bin < 0 ) continue;
1826 if( iter!=0 ){ // cut
1827 double s2 = Sigma->GetBinContent(bin);
1828 double d = val - Mean->GetBinContent(bin);
1829 if( d*d>s2*16 ) continue;
1831 meanD[bin]+= entr*val;
1832 Entr->AddBinContent(bin,entr);
1835 for( Long64_t bin=0; bin<nStatBins; bin++){
1836 double val = meanD[bin];
1837 double sum = Entr->GetBinContent(bin);
1839 Mean->SetBinContent(bin, val/sum );
1841 else Mean->SetBinContent(bin, 0);
1842 Entr->SetBinContent(bin, 0);
1847 for( Long64_t binS=0; binS<nFilledBins; binS++){
1848 Long64_t bin = hMap[binS];
1849 Double_t val = hVal[binS];
1850 Double_t entr = hEntr[binS];
1851 if( bin < 0 ) continue;
1852 double d2 = val - Mean->GetBinContent(bin);
1854 if( iter!=0 ){ // cut
1855 double s2 = Sigma->GetBinContent(bin);
1856 if( d2>s2*16 ) continue;
1858 sigmaD[bin] += entr*d2;
1859 Entr->AddBinContent(bin,entr);
1862 for( Long64_t bin=0; bin<nStatBins; bin++ ){
1863 double val = sigmaD[bin];
1864 double sum = Entr->GetBinContent(bin);
1865 if( sum>=1 && val>=0 ){
1866 Sigma->SetBinContent(bin, val/sum );
1868 else Sigma->SetBinContent(bin, 0);
1872 // scale the Mean and the Sigma
1875 double v0 = H->GetAxis(0)->GetBinCenter(1);
1876 double vscale = H->GetAxis(0)->GetBinWidth(1);
1878 for( Long64_t bin=0; bin<nStatBins; bin++){
1879 double m = Mean->GetBinContent(bin);
1880 double s2 = Sigma->GetBinContent(bin);
1881 double sum = Entr->GetBinContent(bin);
1882 if( sum>0 && s2>=0 ){
1883 Mean->SetBinContent(bin, v0 + (m-1)*vscale );
1884 Sigma->SetBinContent(bin, sqrt(s2)*vscale );
1887 Mean->SetBinContent(bin, 0);
1888 Sigma->SetBinContent(bin, 0);
1889 Entr->SetBinContent(bin, 0);
1905 cout << "AliTPCcalibTracks: GetSparseStat : No memory or internal Error "<<endl;
1920 int AliTPCcalibTracks::CreateWaveCorrection(const THnBase *DeltaY, THnBase *&MeanY, THnBase *&SigmaY, THnBase *&EntrY,
1921 Bool_t MirrorZ, Bool_t MirrorPad, Bool_t MirrorAngle, Int_t MinStat )
1923 // DeltaY is THnSparse:
1925 // OBJ: TAxis 0 var var
1926 // OBJ: TAxis 1 pad type pad type
1928 // OBJ: TAxis 3 Qmax Qmax
1929 // OBJ: TAxis 4 cog cog
1930 // OBJ: TAxis 5 tan(angle) tan(angle)
1937 int nDim = DeltaY->GetNdimensions();
1939 cout << "AliTPCcalibTracks: CreateWaveCorrection: Unknown input"<<endl;
1943 Int_t *nBins = new Int_t[nDim];
1944 Int_t *nBinsNew = new Int_t[nDim];
1945 Double_t *xMin = new Double_t[nDim];
1946 Double_t *xMax = new Double_t[nDim];
1947 Int_t *idx = new Int_t[nDim];
1948 THnSparseD *mergedDeltaY = 0;
1952 if( !nBins || !nBinsNew || !xMin || !xMax || !idx ){
1954 cout << "AliTPCcalibTracks: CreateWaveCorrection: Out of memory"<<endl;
1959 for( int i=0; i<nDim; i++){
1960 xMin[i] = DeltaY->GetAxis(i)->GetXmin();
1961 xMax[i] = DeltaY->GetAxis(i)->GetXmax();
1962 nBins[i] = DeltaY->GetAxis(i)->GetNbins();
1963 nBinsNew[i] = nBins[i];
1968 Int_t centralBin = DeltaY->GetAxis(4)->FindFixBin(0.5);
1969 xMin[4] = DeltaY->GetAxis(4)->GetBinLowEdge(centralBin);
1970 nBinsNew[4] = nBinsNew[4]-centralBin+1;
1975 Int_t centralBin = DeltaY->GetAxis(2)->FindFixBin(0.0);
1976 xMin[2] = DeltaY->GetAxis(2)->GetBinLowEdge(centralBin)-0.0;
1977 nBinsNew[2] = nBinsNew[2]-centralBin+1;
1982 Int_t centralBin = DeltaY->GetAxis(5)->FindFixBin(0.0);
1983 xMin[5] = DeltaY->GetAxis(5)->GetBinLowEdge(centralBin)-0.0;
1984 nBinsNew[5] = nBinsNew[5]-centralBin+1;
1989 mergedDeltaY = new THnSparseD("mergedDeltaY", "mergedDeltaY",nDim, nBinsNew, xMin, xMax );
1991 if( !mergedDeltaY ){
1992 cout << "AliTPCcalibTracks: CreateWaveCorrection: Can not copy a Sparse"<<endl;
1999 for( int i=0; i<nDim; i++){
2000 const TAxis *ax = DeltaY->GetAxis(i);
2001 mergedDeltaY->GetAxis(i)->SetName(ax->GetName());
2002 mergedDeltaY->GetAxis(i)->SetTitle(ax->GetTitle());
2003 if( ax->GetXbins()->fN>0 ){
2004 mergedDeltaY->GetAxis(i)->Set(ax->GetNbins(), ax->GetXbins()->GetArray());
2008 for( Long64_t binS=0; binS<DeltaY->GetNbins(); binS++){
2009 Double_t stat = DeltaY->GetBinContent(binS,idx);
2010 if( stat < 1 ) continue;
2013 if( MirrorPad && idx[4]>0){ // underflow reserved for contains one-pad clusters, don't mirror
2014 Double_t v = DeltaY->GetAxis(4)->GetBinCenter(idx[4]);
2015 if( v < 0.5 ) swap0 = !swap0;
2016 idx[4] = mergedDeltaY->GetAxis(4)->FindFixBin( 0.5 + TMath::Abs(0.5 - v) );
2020 Double_t v = DeltaY->GetAxis(2)->GetBinCenter(idx[2]);
2021 if( v < 0.0 ) swap0 = !swap0;
2022 if( idx[2]<=0 ) idx[2] = nBinsNew[2]+1;
2023 else idx[2] = mergedDeltaY->GetAxis(2)->FindFixBin( TMath::Abs(v) );
2027 Double_t v = DeltaY->GetAxis(5)->GetBinCenter(idx[5]);
2028 if( idx[5]<=0 ) idx[5] = nBinsNew[5]+1;
2029 else idx[5] = mergedDeltaY->GetAxis(5)->FindFixBin( TMath::Abs(v) );
2033 if( idx[0]<=0 ) idx[0] = nBinsNew[0]+1;
2034 else if( idx[0] >= nBins[0]+1 ) idx[0] = 0;
2036 Double_t v = DeltaY->GetAxis(0)->GetBinCenter(idx[0]);
2037 idx[0] = mergedDeltaY->GetAxis(0)->FindFixBin(-v);
2041 Long64_t bin = mergedDeltaY->GetBin(idx,kTRUE);
2043 cout << "AliTPCcalibTracks: CreateWaveCorrection : wrong bining"<<endl;
2046 mergedDeltaY->AddBinContent(bin,stat);
2049 ret = GetTHnStat(mergedDeltaY, MeanY, SigmaY, EntrY );
2054 MeanY->SetName("TPCWaveCorrectionMap");
2055 MeanY->SetTitle("TPCWaveCorrectionMap");
2056 SigmaY->SetName("TPCResolutionMap");
2057 SigmaY->SetTitle("TPCResolutionMap");
2058 EntrY->SetName("TPCWaveCorrectionEntr");
2059 EntrY->SetTitle("TPCWaveCorrectionEntr");
2061 for( Long64_t bin=0; bin<MeanY->GetNbins(); bin++){
2062 Double_t stat = EntrY->GetBinContent(bin,idx);
2064 // Normalize : Set no correction for one pad clusters
2066 if( idx[3]<=0 ) MeanY->SetBinContent(bin,0);
2068 // Suppress bins with low statistic
2071 EntrY->SetBinContent(bin,0);
2072 MeanY->SetBinContent(bin,0);
2073 SigmaY->SetBinContent(bin,-1);
2084 delete mergedDeltaY;
2098 int AliTPCcalibTracks::UpdateClusterParam( AliTPCClusterParam *cParam, Bool_t MirrorZ, Bool_t MirrorPad, Bool_t MirrorAngle, Int_t MinStat )
2100 if( !cParam || !fHisDeltaY) return -1;
2103 THnBase *sigmaY = 0;
2105 int ret = CreateWaveCorrection(fHisDeltaY, meanY, sigmaY, entrY, MirrorZ, MirrorAngle, MirrorPad, MinStat );
2106 if( ret<0 ) return ret;
2107 cParam->SetWaveCorrectionMap(meanY);
2108 cParam->SetResolutionYMap(sigmaY);