1 //**************************************************************************
2 // * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 // * Author: The ALICE Off-line Project. *
5 // * Contributors are mentioned in the code where appropriate. *
7 // * Permission to use, copy, modify and distribute this software and its *
8 // * documentation strictly for non-commercial purposes is hereby granted *
9 // * without fee, provided that the above copyright notice appears in all *
10 // * copies and that both the copyright notice and this permission notice *
11 //* appear in the supporting documentation. The authors make no claims *
12 //* about the suitability of this software for any purpose. It is *
13 //* provided "as is" without express or implied warranty. *
14 //**************************************************************************/
18 /////////////////////////////////////////////////////////////////////////////////
20 // AliTRDCalibraFillHisto
22 // This class is for the TRD calibration of the relative gain factor, the drift velocity,
23 // the time 0 and the pad response function. It fills histos or vectors.
24 // It can be used for the calibration per chamber but also per group of pads and eventually per pad.
25 // The user has to choose with the functions SetNz and SetNrphi the precision of the calibration (see AliTRDCalibraMode).
26 // 2D Histograms (Histo2d) or vectors (Vector2d), then converted in Trees, will be filled
27 // from RAW DATA in a run or from reconstructed TRD tracks during the offline tracking
28 // in the function "FollowBackProlongation" (AliTRDtracker)
29 // Per default the functions to fill are off.
32 // R. Bailhache (R.Bailhache@gsi.de)
34 //////////////////////////////////////////////////////////////////////////////////////
36 #include <TProfile2D.h>
41 #include <TObjArray.h>
46 #include <TStopwatch.h>
48 #include <TDirectory.h>
49 #include <TTreeStream.h>
51 #include <TLinearFitter.h>
55 #include "AliTRDCalibraFillHisto.h"
56 #include "AliTRDCalibraMode.h"
57 #include "AliTRDCalibraVector.h"
58 #include "AliTRDCalibraVdriftLinearFit.h"
59 #include "AliTRDcalibDB.h"
60 #include "AliTRDCommonParam.h"
61 #include "AliTRDpadPlane.h"
62 #include "AliTRDcluster.h"
63 #include "AliTRDtrack.h"
64 #include "AliTRDtrackV1.h"
65 #include "AliTRDrawStreamBase.h"
66 #include "AliRawReader.h"
67 #include "AliRawReaderDate.h"
68 #include "AliTRDgeometry.h"
69 #include "./Cal/AliTRDCalROC.h"
70 #include "./Cal/AliTRDCalDet.h"
77 ClassImp(AliTRDCalibraFillHisto)
79 AliTRDCalibraFillHisto* AliTRDCalibraFillHisto::fgInstance = 0;
80 Bool_t AliTRDCalibraFillHisto::fgTerminated = kFALSE;
82 //_____________singleton implementation_________________________________________________
83 AliTRDCalibraFillHisto *AliTRDCalibraFillHisto::Instance()
86 // Singleton implementation
89 if (fgTerminated != kFALSE) {
93 if (fgInstance == 0) {
94 fgInstance = new AliTRDCalibraFillHisto();
101 //______________________________________________________________________________________
102 void AliTRDCalibraFillHisto::Terminate()
105 // Singleton implementation
106 // Deletes the instance of this class
109 fgTerminated = kTRUE;
111 if (fgInstance != 0) {
118 //______________________________________________________________________________________
119 AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
128 ,fLinearFitterOn(kFALSE)
129 ,fLinearFitterDebugOn(kFALSE)
131 ,fThresholdClusterPRF2(15.0)
132 ,fLimitChargeIntegration(kFALSE)
133 ,fFillWithZero(kFALSE)
134 ,fNormalizeNbOfCluster(kFALSE)
137 ,fCalibraMode(new AliTRDCalibraMode())
140 ,fDetectorPreviousTrack(-1)
144 ,fNumberClustersf(30)
150 ,fNumberBinCharge(50)
156 ,fGoodTracklet(kTRUE)
157 ,fLinearFitterTracklet(0x0)
159 ,fEntriesLinearFitter(0x0)
164 ,fLinearFitterArray(540)
165 ,fLinearVdriftFit(0x0)
170 // Default constructor
174 // Init some default values
177 fNumberUsedCh[0] = 0;
178 fNumberUsedCh[1] = 0;
179 fNumberUsedPh[0] = 0;
180 fNumberUsedPh[1] = 0;
182 fGeo = new AliTRDgeometry();
186 //______________________________________________________________________________________
187 AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c)
193 ,fPRF2dOn(c.fPRF2dOn)
194 ,fHisto2d(c.fHisto2d)
195 ,fVector2d(c.fVector2d)
196 ,fLinearFitterOn(c.fLinearFitterOn)
197 ,fLinearFitterDebugOn(c.fLinearFitterDebugOn)
198 ,fRelativeScale(c.fRelativeScale)
199 ,fThresholdClusterPRF2(c.fThresholdClusterPRF2)
200 ,fLimitChargeIntegration(c.fLimitChargeIntegration)
201 ,fFillWithZero(c.fFillWithZero)
202 ,fNormalizeNbOfCluster(c.fNormalizeNbOfCluster)
203 ,fMaxCluster(c.fMaxCluster)
204 ,fNbMaxCluster(c.fNbMaxCluster)
207 ,fDebugLevel(c.fDebugLevel)
208 ,fDetectorPreviousTrack(c.fDetectorPreviousTrack)
209 ,fMCMPrevious(c.fMCMPrevious)
210 ,fROBPrevious(c.fROBPrevious)
211 ,fNumberClusters(c.fNumberClusters)
212 ,fNumberClustersf(c.fNumberClustersf)
213 ,fProcent(c.fProcent)
214 ,fDifference(c.fDifference)
215 ,fNumberTrack(c.fNumberTrack)
216 ,fTimeMax(c.fTimeMax)
218 ,fNumberBinCharge(c.fNumberBinCharge)
219 ,fNumberBinPRF(c.fNumberBinPRF)
220 ,fNgroupprf(c.fNgroupprf)
224 ,fGoodTracklet(c.fGoodTracklet)
225 ,fLinearFitterTracklet(0x0)
227 ,fEntriesLinearFitter(0x0)
232 ,fLinearFitterArray(540)
233 ,fLinearVdriftFit(0x0)
240 if(c.fCalibraMode) fCalibraMode = new AliTRDCalibraMode(*c.fCalibraMode);
241 if(c.fCalibraVector) fCalibraVector = new AliTRDCalibraVector(*c.fCalibraVector);
243 fPH2d = new TProfile2D(*c.fPH2d);
244 fPH2d->SetDirectory(0);
247 fPRF2d = new TProfile2D(*c.fPRF2d);
248 fPRF2d->SetDirectory(0);
251 fCH2d = new TH2I(*c.fCH2d);
252 fCH2d->SetDirectory(0);
254 if(c.fLinearVdriftFit){
255 fLinearVdriftFit = new AliTRDCalibraVdriftLinearFit(*c.fLinearVdriftFit);
258 if(c.fCalDetGain) fCalDetGain = new AliTRDCalDet(*c.fCalDetGain);
259 if(c.fCalROCGain) fCalROCGain = new AliTRDCalROC(*c.fCalROCGain);
264 fGeo = new AliTRDgeometry();
267 //____________________________________________________________________________________
268 AliTRDCalibraFillHisto::~AliTRDCalibraFillHisto()
271 // AliTRDCalibraFillHisto destructor
275 if ( fDebugStreamer ) delete fDebugStreamer;
277 if ( fCalDetGain ) delete fCalDetGain;
278 if ( fCalROCGain ) delete fCalROCGain;
280 if( fLinearFitterTracklet ) { delete fLinearFitterTracklet; }
284 delete [] fEntriesCH;
285 delete [] fEntriesLinearFitter;
288 for(Int_t idet=0; idet<AliTRDgeometry::kNdet; idet++){
289 TLinearFitter *f = (TLinearFitter*)fLinearFitterArray.At(idet);
297 //_____________________________________________________________________________
298 void AliTRDCalibraFillHisto::Destroy()
309 //_____________________________________________________________________________
310 void AliTRDCalibraFillHisto::DestroyDebugStreamer()
313 // Delete DebugStreamer
316 if ( fDebugStreamer ) delete fDebugStreamer;
317 fDebugStreamer = 0x0;
320 //_____________________________________________________________________________
321 void AliTRDCalibraFillHisto::ClearHistos()
341 //////////////////////////////////////////////////////////////////////////////////
342 // calibration with AliTRDtrackV1: Init, Update
343 //////////////////////////////////////////////////////////////////////////////////
344 //____________Functions for initialising the AliTRDCalibraFillHisto in the code_________
345 Bool_t AliTRDCalibraFillHisto::Init2Dhistos(Int_t nboftimebin)
348 // Init the histograms and stuff to be filled
353 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
355 AliInfo("Could not get calibDB");
358 AliTRDCommonParam *parCom = AliTRDCommonParam::Instance();
360 AliInfo("Could not get CommonParam");
365 if(nboftimebin > 0) fTimeMax = nboftimebin;
366 else fTimeMax = cal->GetNumberOfTimeBins();
367 fSf = parCom->GetSamplingFrequency();
368 if(!fNormalizeNbOfCluster) fRelativeScale = 20.0;
369 else fRelativeScale = 1.18;
370 fNumberClustersf = fTimeMax;
371 fNumberClusters = (Int_t)(0.5*fTimeMax);
373 // Init linear fitter
374 if(!fLinearFitterTracklet) {
375 fLinearFitterTracklet = new TLinearFitter(2,"pol1");
376 fLinearFitterTracklet->StoreData(kTRUE);
379 //calib object from database used for reconstruction
381 fCalDetGain->~AliTRDCalDet();
382 new(fCalDetGain) AliTRDCalDet(*(cal->GetGainFactorDet()));
383 }else fCalDetGain = new AliTRDCalDet(*(cal->GetGainFactorDet()));
385 // Calcul Xbins Chambd0, Chamb2
386 Int_t ntotal0 = CalculateTotalNumberOfBins(0);
387 Int_t ntotal1 = CalculateTotalNumberOfBins(1);
388 Int_t ntotal2 = CalculateTotalNumberOfBins(2);
390 // If vector method On initialised all the stuff
392 fCalibraVector = new AliTRDCalibraVector();
393 fCalibraVector->SetNumberBinCharge(fNumberBinCharge);
394 fCalibraVector->SetTimeMax(fTimeMax);
395 if(fNgroupprf != 0) {
396 fCalibraVector->SetNumberBinPRF(2*fNgroupprf*fNumberBinPRF);
397 fCalibraVector->SetPRFRange((Float_t)(3.0*fNgroupprf));
400 fCalibraVector->SetNumberBinPRF(fNumberBinPRF);
401 fCalibraVector->SetPRFRange(1.5);
403 for(Int_t k = 0; k < 3; k++){
404 fCalibraVector->SetDetCha0(k,fCalibraMode->GetDetChamb0(k));
405 fCalibraVector->SetDetCha2(k,fCalibraMode->GetDetChamb2(k));
407 fCalibraVector->SetNzNrphi(0,fCalibraMode->GetNz(0),fCalibraMode->GetNrphi(0));
408 fCalibraVector->SetNzNrphi(1,fCalibraMode->GetNz(1),fCalibraMode->GetNrphi(1));
409 fCalibraVector->SetNzNrphi(2,fCalibraMode->GetNz(2),fCalibraMode->GetNrphi(2));
410 fCalibraVector->SetNbGroupPRF(fNgroupprf);
413 // Create the 2D histos corresponding to the pad groupCalibration mode
416 AliInfo(Form("The pad calibration mode for the relative gain calibration: Nz %d, and Nrphi %d"
417 ,fCalibraMode->GetNz(0)
418 ,fCalibraMode->GetNrphi(0)));
420 // Create the 2D histo
425 fAmpTotal = new Float_t[TMath::Max(fCalibraMode->GetDetChamb2(0),fCalibraMode->GetDetChamb0(0))];
426 for (Int_t k = 0; k < TMath::Max(fCalibraMode->GetDetChamb2(0),fCalibraMode->GetDetChamb0(0)); k++) {
430 fEntriesCH = new Int_t[ntotal0];
431 for(Int_t k = 0; k < ntotal0; k++){
438 AliInfo(Form("The pad calibration mode for the drift velocity calibration: Nz %d, and Nrphi %d"
439 ,fCalibraMode->GetNz(1)
440 ,fCalibraMode->GetNrphi(1)));
442 // Create the 2D histo
447 fPHPlace = new Short_t[fTimeMax];
448 for (Int_t k = 0; k < fTimeMax; k++) {
451 fPHValue = new Float_t[fTimeMax];
452 for (Int_t k = 0; k < fTimeMax; k++) {
456 if (fLinearFitterOn) {
457 //fLinearFitterArray.Expand(540);
458 fLinearFitterArray.SetName("ArrayLinearFitters");
459 fEntriesLinearFitter = new Int_t[540];
460 for(Int_t k = 0; k < 540; k++){
461 fEntriesLinearFitter[k] = 0;
463 fLinearVdriftFit = new AliTRDCalibraVdriftLinearFit();
468 AliInfo(Form("The pad calibration mode for the PRF calibration: Nz %d, and Nrphi %d"
469 ,fCalibraMode->GetNz(2)
470 ,fCalibraMode->GetNrphi(2)));
471 // Create the 2D histo
473 CreatePRF2d(ntotal2);
480 //____________Offline tracking in the AliTRDtracker____________________________
481 Bool_t AliTRDCalibraFillHisto::UpdateHistograms(const AliTRDtrack *t)
484 // Use AliTRDtrack for the calibration
488 AliTRDcluster *cl = 0x0; // pointeur to cluster
489 Int_t index0 = 0; // index of the first cluster in the current chamber
490 Int_t index1 = 0; // index of the current cluster in the current chamber
492 //////////////////////////////
493 // loop over the clusters
494 ///////////////////////////////
495 while((cl = t->GetCluster(index1))){
497 /////////////////////////////////////////////////////////////////////////
498 // Fill the infos for the previous clusters if not the same detector
499 ////////////////////////////////////////////////////////////////////////
500 Int_t detector = cl->GetDetector();
501 if ((detector != fDetectorPreviousTrack) &&
502 (index0 != index1)) {
506 //If the same track, then look if the previous detector is in
507 //the same plane, if yes: not a good track
508 if ((GetLayer(detector) == GetLayer(fDetectorPreviousTrack))) {
512 // Fill only if the track doesn't touch a masked pad or doesn't
515 // drift velocity unables to cut bad tracklets
516 Bool_t pass = FindP1TrackPHtracklet(t,index0,index1);
520 FillTheInfoOfTheTrackCH(index1-index0);
525 FillTheInfoOfTheTrackPH();
528 if(pass && fPRF2dOn) HandlePRFtracklet(t,index0,index1);
531 } // if a good tracklet
534 ResetfVariablestracklet();
537 } // Fill at the end the charge
540 /////////////////////////////////////////////////////////////
541 // Localise and take the calib gain object for the detector
542 ////////////////////////////////////////////////////////////
543 if (detector != fDetectorPreviousTrack) {
545 //Localise the detector
546 LocalisationDetectorXbins(detector);
549 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
551 AliInfo("Could not get calibDB");
558 fCalROCGain->~AliTRDCalROC();
559 new(fCalROCGain) AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
561 }else fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
565 // Reset the detectbjobsor
566 fDetectorPreviousTrack = detector;
568 ///////////////////////////////////////
569 // Store the info of the cluster
570 ///////////////////////////////////////
571 Int_t row = cl->GetPadRow();
572 Int_t col = cl->GetPadCol();
573 CheckGoodTrackletV1(cl);
574 Int_t group[2] = {0,0};
575 if(fCH2dOn) group[0] = CalculateCalibrationGroup(0,row,col);
576 if(fPH2dOn) group[1] = CalculateCalibrationGroup(1,row,col);
577 StoreInfoCHPHtrack(cl,t->GetClusterdQdl(index1),group,row,col);
581 } // while on clusters
583 ///////////////////////////
584 // Fill the last plane
585 //////////////////////////
586 if( index0 != index1 ){
592 // drift velocity unables to cut bad tracklets
593 Bool_t pass = FindP1TrackPHtracklet(t,index0,index1);
597 FillTheInfoOfTheTrackCH(index1-index0);
602 FillTheInfoOfTheTrackPH();
605 if(pass && fPRF2dOn) HandlePRFtracklet(t,index0,index1);
607 } // if a good tracklet
612 ResetfVariablestracklet();
617 //____________Offline tracking in the AliTRDtracker____________________________
618 Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t)
621 // Use AliTRDtrackV1 for the calibration
625 const AliTRDseedV1 *tracklet = 0x0; // tracklet per plane
626 AliTRDcluster *cl = 0x0; // cluster attached now to the tracklet
627 Bool_t newtr = kTRUE; // new track
630 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
632 AliInfo("Could not get calibDB");
636 ///////////////////////////
637 // loop over the tracklet
638 ///////////////////////////
639 for(Int_t itr = 0; itr < 6; itr++){
641 if(!(tracklet = t->GetTracklet(itr))) continue;
642 if(!tracklet->IsOK()) continue;
644 ResetfVariablestracklet();
646 //////////////////////////////////////////
647 // localisation of the tracklet and dqdl
648 //////////////////////////////////////////
649 Int_t layer = tracklet->GetPlane();
651 while(!(cl = tracklet->GetClusters(ic++))) continue;
652 Int_t detector = cl->GetDetector();
653 if (detector != fDetectorPreviousTrack) {
654 // if not a new track
656 // don't use the rest of this track if in the same plane
657 if (layer == GetLayer(fDetectorPreviousTrack)) {
658 //printf("bad tracklet, same layer for detector %d\n",detector);
662 //Localise the detector bin
663 LocalisationDetectorXbins(detector);
667 fCalROCGain->~AliTRDCalROC();
668 new(fCalROCGain) AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
670 }else fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
673 fDetectorPreviousTrack = detector;
677 ////////////////////////////
678 // loop over the clusters
679 ////////////////////////////
680 Int_t nbclusters = 0;
681 for(int jc=0; jc<AliTRDseedV1::kNtb; jc++){
682 if(!(cl = tracklet->GetClusters(jc))) continue;
685 // Store the info bis of the tracklet
686 Int_t row = cl->GetPadRow();
687 Int_t col = cl->GetPadCol();
688 CheckGoodTrackletV1(cl);
689 Int_t group[2] = {0,0};
690 if(fCH2dOn) group[0] = CalculateCalibrationGroup(0,row,col);
691 if(fPH2dOn) group[1] = CalculateCalibrationGroup(1,row,col);
692 StoreInfoCHPHtrack(cl, tracklet->GetdQdl(jc),group,row,col);
695 ////////////////////////////////////////
696 // Fill the stuffs if a good tracklet
697 ////////////////////////////////////////
700 // drift velocity unables to cut bad tracklets
701 Bool_t pass = FindP1TrackPHtrackletV1(tracklet, nbclusters);
703 //printf("pass %d and nbclusters %d\n",pass,nbclusters);
707 FillTheInfoOfTheTrackCH(nbclusters);
712 FillTheInfoOfTheTrackPH();
715 if(pass && fPRF2dOn) HandlePRFtrackletV1(tracklet,nbclusters);
717 } // if a good tracklet
723 ///////////////////////////////////////////////////////////////////////////////////
724 // Routine inside the update with AliTRDtrack
725 ///////////////////////////////////////////////////////////////////////////////////
726 //____________Offine tracking in the AliTRDtracker_____________________________
727 Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtracklet(const AliTRDtrack *t, Int_t index0, Int_t index1)
730 // Drift velocity calibration:
731 // Fit the clusters with a straight line
732 // From the slope find the drift velocity
735 //Number of points: if less than 3 return kFALSE
736 Int_t npoints = index1-index0;
737 if(npoints <= 2) return kFALSE;
742 Int_t detector = ((AliTRDcluster *) t->GetCluster(index0))->GetDetector(); //detector
743 // parameters of the track
744 Double_t snp = t->GetSnpPlane(GetLayer(detector)); // sin angle in the plan yx track
745 Double_t tgl = t->GetTglPlane(GetLayer(detector)); // dz/dl and not dz/dx!
746 Double_t tnp = 0.0; // tan angle in the plan xy track
747 if( TMath::Abs(snp) < 1.){
748 tnp = snp / TMath::Sqrt((1.-snp)*(1.+snp));
750 Float_t dzdx = tgl*TMath::Sqrt(1+tnp*tnp); // dz/dx now from dz/dl
751 // tilting pad and cross row
752 Int_t crossrow = 0; // if it crosses a pad row
753 Int_t rowp = -1; // if it crosses a pad row
754 AliTRDpadPlane *padplane = fGeo->GetPadPlane(GetLayer(detector),GetStack(detector));
755 Double_t tiltingangle = padplane->GetTiltingAngle(); // tiltingangle of the pad
756 Float_t tnt = TMath::Tan(tiltingangle/180.*TMath::Pi()); // tan tiltingangle
758 fLinearFitterTracklet->ClearPoints();
759 Double_t dydt = 0.0; // dydt tracklet after straight line fit
760 Double_t errorpar = 0.0; // error after straight line fit on dy/dt
761 Double_t pointError = 0.0; // error after straight line fit
762 Int_t nbli = 0; // number linear fitter points
764 //////////////////////////////
765 // loop over clusters
766 ////////////////////////////
767 for(Int_t k = 0; k < npoints; k++){
769 AliTRDcluster *cl = (AliTRDcluster *) t->GetCluster(k+index0);
770 if((fLimitChargeIntegration) && (!cl->IsInChamber())) continue;
771 Double_t ycluster = cl->GetY();
772 Int_t time = cl->GetPadTime();
773 Double_t timeis = time/fSf;
774 //Double_t q = cl->GetQ();
775 //See if cross two pad rows
776 Int_t row = cl->GetPadRow();
778 if(row != rowp) crossrow = 1;
780 fLinearFitterTracklet->AddPoint(&timeis,ycluster,1);
785 //////////////////////////////
787 //////////////////////////////
789 fLinearFitterTracklet->ClearPoints();
793 fLinearFitterTracklet->Eval();
794 fLinearFitterTracklet->GetParameters(pars);
795 pointError = TMath::Sqrt(fLinearFitterTracklet->GetChisquare()/(nbli-2));
796 errorpar = fLinearFitterTracklet->GetParError(1)*pointError;
798 fLinearFitterTracklet->ClearPoints();
800 /////////////////////////////
802 ////////////////////////////
804 if ( !fDebugStreamer ) {
806 TDirectory *backup = gDirectory;
807 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
808 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
812 (* fDebugStreamer) << "FindP1TrackPHtracklet0"<<
813 //"snpright="<<snpright<<
814 "npoints="<<npoints<<
816 "detector="<<detector<<
823 "crossrow="<<crossrow<<
824 "errorpar="<<errorpar<<
825 "pointError="<<pointError<<
829 Int_t nbclusters = index1-index0;
830 Int_t layer = GetLayer(fDetectorPreviousTrack);
832 (* fDebugStreamer) << "FindP1TrackPHtracklet1"<<
833 //"snpright="<<snpright<<
834 "nbclusters="<<nbclusters<<
835 "detector="<<fDetectorPreviousTrack<<
841 ///////////////////////////
843 ///////////////////////////
844 if(npoints < fNumberClusters) return kFALSE;
845 if(npoints > fNumberClustersf) return kFALSE;
846 if(pointError >= 0.1) return kFALSE;
847 if(crossrow == 1) return kFALSE;
849 ////////////////////////////
851 ////////////////////////////
853 //Add to the linear fitter of the detector
854 if( TMath::Abs(snp) < 1.){
855 Double_t x = tnp-dzdx*tnt;
856 (GetLinearFitter(detector,kTRUE))->AddPoint(&x,dydt);
857 if(fLinearFitterDebugOn) {
858 fLinearVdriftFit->Update(detector,x,pars[1]);
860 fEntriesLinearFitter[detector]++;
866 //____________Offine tracking in the AliTRDtracker_____________________________
867 Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters)
870 // Drift velocity calibration:
871 // Fit the clusters with a straight line
872 // From the slope find the drift velocity
875 ////////////////////////////////////////////////
876 //Number of points: if less than 3 return kFALSE
877 /////////////////////////////////////////////////
878 if(nbclusters <= 2) return kFALSE;
883 // results of the linear fit
884 Double_t dydt = 0.0; // dydt tracklet after straight line fit
885 Double_t errorpar = 0.0; // error after straight line fit on dy/dt
886 Double_t pointError = 0.0; // error after straight line fit
887 // pad row problemes: avoid tracklet that cross pad rows, tilting angle in the constant
888 Int_t crossrow = 0; // if it crosses a pad row
889 Int_t rowp = -1; // if it crosses a pad row
890 Float_t tnt = tracklet->GetTilt(); // tan tiltingangle
891 fLinearFitterTracklet->ClearPoints();
894 ///////////////////////////////////////////
895 // Take the parameters of the track
896 //////////////////////////////////////////
897 // take now the snp, tnp and tgl from the track
898 Double_t snp = tracklet->GetSnp(); // sin dy/dx at the end of the chamber
899 Double_t tnp = 0.0; // dy/dx at the end of the chamber
900 if( TMath::Abs(snp) < 1.){
901 tnp = snp / TMath::Sqrt((1.-snp)*(1.+snp));
903 Double_t tgl = tracklet->GetTgl(); // dz/dl
904 Double_t dzdx = tgl*TMath::Sqrt(1+tnp*tnp); // dz/dx calculated from dz/dl
906 //Double_t tnp = tracklet->GetYref(1); // dy/dx at the entrance of the chamber
907 //Double_t tgl = tracklet->GetZref(1); // dz/dl at the entrance of the chamber
908 //Double_t dzdx = tgl; //*TMath::Sqrt(1+tnp*tnp); // dz/dx from dz/dl
909 // at the end with correction due to linear fit
910 //Double_t tnp = tracklet->GetYfit(1); // dy/dx at the end of the chamber after fit correction
911 //Double_t tgl = tracklet->GetZfit(1); // dz/dl at the end of the chamber after fit correction
914 ////////////////////////////
915 // loop over the clusters
916 ////////////////////////////
918 AliTRDcluster *cl = 0x0;
919 for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
920 if(!(cl = tracklet->GetClusters(ic))) continue;
921 if((fLimitChargeIntegration) && (!cl->IsInChamber())) continue;
923 Double_t ycluster = cl->GetY();
924 Int_t time = cl->GetPadTime();
925 Double_t timeis = time/fSf;
926 //See if cross two pad rows
927 Int_t row = cl->GetPadRow();
928 if(rowp==-1) rowp = row;
929 if(row != rowp) crossrow = 1;
931 fLinearFitterTracklet->AddPoint(&timeis,ycluster,1);
934 //////////////////////////////
935 // Check no shared clusters
936 //////////////////////////////
937 for(int icc=AliTRDseedV1::kNtb; icc<AliTRDseedV1::kNclusters; icc++){
938 if((cl = tracklet->GetClusters(icc))) crossrow = 1;
942 ////////////////////////////////////
943 // Do the straight line fit now
944 ///////////////////////////////////
946 fLinearFitterTracklet->ClearPoints();
950 fLinearFitterTracklet->Eval();
951 fLinearFitterTracklet->GetParameters(pars);
952 pointError = TMath::Sqrt(fLinearFitterTracklet->GetChisquare()/(nbli-2));
953 errorpar = fLinearFitterTracklet->GetParError(1)*pointError;
955 //printf("chis %f, nbli %d, pointError %f, parError %f, errorpar %f\n",fLinearFitterTracklet->GetChisquare(),nbli,pointError,fLinearFitterTracklet->GetParError(1),errorpar);
956 fLinearFitterTracklet->ClearPoints();
958 ////////////////////////////////
960 ///////////////////////////////
964 if ( !fDebugStreamer ) {
966 TDirectory *backup = gDirectory;
967 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
968 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
972 Int_t layer = GetLayer(fDetectorPreviousTrack);
974 (* fDebugStreamer) << "FindP1TrackPHtrackletV1"<<
975 //"snpright="<<snpright<<
977 "nbclusters="<<nbclusters<<
978 "detector="<<fDetectorPreviousTrack<<
986 "crossrow="<<crossrow<<
987 "errorpar="<<errorpar<<
988 "pointError="<<pointError<<
993 /////////////////////////
995 ////////////////////////
997 if(nbclusters < fNumberClusters) return kFALSE;
998 if(nbclusters > fNumberClustersf) return kFALSE;
999 if(pointError >= 0.3) return kFALSE;
1000 if(crossrow == 1) return kFALSE;
1002 ///////////////////////
1004 //////////////////////
1006 if(fLinearFitterOn){
1007 //Add to the linear fitter of the detector
1008 if( TMath::Abs(snp) < 1.){
1009 Double_t x = tnp-dzdx*tnt;
1010 (GetLinearFitter(fDetectorPreviousTrack,kTRUE))->AddPoint(&x,dydt);
1011 if(fLinearFitterDebugOn) {
1012 fLinearVdriftFit->Update(fDetectorPreviousTrack,x,pars[1]);
1014 fEntriesLinearFitter[fDetectorPreviousTrack]++;
1020 //____________Offine tracking in the AliTRDtracker_____________________________
1021 Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(const AliTRDtrack *t, Int_t index0, Int_t index1)
1024 // PRF width calibration
1025 // Assume a Gaussian shape: determinate the position of the three pad clusters
1026 // Fit with a straight line
1027 // Take the fitted values for all the clusters (3 or 2 pad clusters)
1028 // Fill the PRF as function of angle of the track
1033 //////////////////////////
1035 /////////////////////////
1036 Int_t npoints = index1-index0; // number of total points
1037 Int_t nb3pc = 0; // number of three pads clusters used for fit
1038 Int_t detector = ((AliTRDcluster *) t->GetCluster(index0))->GetDetector(); // detector
1039 // To see the difference due to the fit
1040 Double_t *padPositions;
1041 padPositions = new Double_t[npoints];
1042 for(Int_t k = 0; k < npoints; k++){
1043 padPositions[k] = 0.0;
1045 // Take the tgl and snp with the track t now
1046 Double_t tgl = t->GetTglPlane(GetLayer(detector)); //dz/dl and not dz/dx
1047 Double_t snp = t->GetSnpPlane(GetLayer(detector)); // sin angle in xy plan
1048 Float_t dzdx = 0.0; // dzdx
1050 if(TMath::Abs(snp) < 1.0){
1051 tnp = snp / TMath::Sqrt((1.-snp)*(1.+snp));
1052 dzdx = tgl*TMath::Sqrt(1+tnp*tnp);
1055 fLinearFitterTracklet->ClearPoints();
1057 ///////////////////////////
1058 // calcul the tnp group
1059 ///////////////////////////
1060 Bool_t echec = kFALSE;
1061 Double_t shift = 0.0;
1062 //Calculate the shift in x coresponding to this tnp
1063 if(fNgroupprf != 0.0){
1064 shift = -3.0*(fNgroupprf-1)-1.5;
1065 Double_t limithigh = -0.2*(fNgroupprf-1);
1066 if((tnp < (-0.2*fNgroupprf)) || (tnp > (0.2*fNgroupprf))) echec = kTRUE;
1068 while(tnp > limithigh){
1075 delete [] padPositions;
1079 //////////////////////
1081 /////////////////////
1082 for(Int_t k = 0; k < npoints; k++){
1084 AliTRDcluster *cl = (AliTRDcluster *) t->GetCluster(k+index0);
1086 Short_t *signals = cl->GetSignals();
1087 Double_t time = cl->GetPadTime();
1088 //Calculate x if possible
1089 Float_t xcenter = 0.0;
1090 Bool_t echec1 = kTRUE;
1091 if((time<=7) || (time>=21)) continue;
1092 // Center 3 balanced: position with the center of the pad
1093 if ((((Float_t) signals[3]) > 0.0) &&
1094 (((Float_t) signals[2]) > 0.0) &&
1095 (((Float_t) signals[4]) > 0.0)) {
1097 // Security if the denomiateur is 0
1098 if ((((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) /
1099 ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))) != 1.0) {
1100 xcenter = 0.5 * (TMath::Log((Float_t) (((Float_t) signals[4]) / ((Float_t) signals[2]))))
1101 / (TMath::Log(((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3])))
1102 / ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))));
1108 if(TMath::Abs(xcenter) > 0.5) echec = kTRUE;
1110 //if no echec: calculate with the position of the pad
1111 // Position of the cluster
1112 Double_t padPosition = xcenter + cl->GetPadCol();
1113 padPositions[k] = padPosition;
1115 fLinearFitterTracklet->AddPoint(&time, padPosition,1);
1119 /////////////////////////////
1121 ////////////////////////////
1123 delete [] padPositions;
1124 fLinearFitterTracklet->ClearPoints();
1127 fLinearFitterTracklet->Eval();
1129 fLinearFitterTracklet->GetParameters(line);
1130 Float_t pointError = -1.0;
1131 if( fLinearFitterTracklet->GetChisquare()>=0.0) {
1132 pointError = TMath::Sqrt( fLinearFitterTracklet->GetChisquare()/(nb3pc-2));
1134 fLinearFitterTracklet->ClearPoints();
1136 /////////////////////////////////////////////////////
1137 // Now fill the PRF: second loop over clusters
1138 /////////////////////////////////////////////////////
1139 for(Int_t k = 0; k < npoints; k++){
1141 AliTRDcluster *cl = (AliTRDcluster *) t->GetCluster(k+index0);
1142 Short_t *signals = cl->GetSignals(); // signal
1143 Double_t time = cl->GetPadTime(); // time bin
1144 Float_t padPosTracklet = line[0]+line[1]*time; // reconstruct position from fit
1145 Float_t padPos = cl->GetPadCol(); // middle pad
1146 Double_t dpad = padPosTracklet - padPos; // reconstruct position relative to middle pad from fit
1147 Float_t ycenter = 0.0; // relative center charge
1148 Float_t ymin = 0.0; // relative left charge
1149 Float_t ymax = 0.0; // relative right charge
1151 //Requiere simply two pads clusters at least
1152 if(((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[2]) > 0.0)) ||
1153 ((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[4]) > 0.0))){
1154 Float_t sum = ((Float_t) signals[2]) + ((Float_t) signals[3]) + ((Float_t) signals[4]);
1155 if(sum > 0.0) ycenter = ((Float_t) signals[3])/ sum;
1156 if(sum > 0.0) ymin = ((Float_t) signals[2])/ sum;
1157 if(sum > 0.0) ymax = ((Float_t) signals[4])/ sum;
1161 Int_t rowcl = cl->GetPadRow(); // row of cluster
1162 Int_t colcl = cl->GetPadCol(); // col of cluster
1163 Int_t grouplocal = CalculateCalibrationGroup(2,rowcl,colcl); // calcul the corresponding group
1164 Int_t caligroup = fCalibraMode->GetXbins(2)+ grouplocal; // calcul the corresponding group
1165 Float_t xcl = cl->GetY(); // y cluster
1166 Float_t qcl = cl->GetQ(); // charge cluster
1167 Int_t layer = GetLayer(detector); // layer
1168 Int_t stack = GetStack(detector); // stack
1169 Double_t xdiff = dpad; // reconstructed position constant
1170 Double_t x = dpad; // reconstructed position moved
1171 Float_t ep = pointError; // error of fit
1172 Float_t signal1 = (Float_t)signals[1]; // signal at the border
1173 Float_t signal3 = (Float_t)signals[3]; // signal
1174 Float_t signal2 = (Float_t)signals[2]; // signal
1175 Float_t signal4 = (Float_t)signals[4]; // signal
1176 Float_t signal5 = (Float_t)signals[5]; // signal at the border
1178 //////////////////////////////
1180 /////////////////////////////
1181 if(fDebugLevel > 0){
1182 if ( !fDebugStreamer ) {
1184 TDirectory *backup = gDirectory;
1185 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
1186 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
1192 Float_t y = ycenter;
1193 (* fDebugStreamer) << "HandlePRFtracklet"<<
1194 "caligroup="<<caligroup<<
1195 "detector="<<detector<<
1198 "npoints="<<npoints<<
1207 "padPosition="<<padPositions[k]<<
1208 "padPosTracklet="<<padPosTracklet<<
1213 "signal1="<<signal1<<
1214 "signal2="<<signal2<<
1215 "signal3="<<signal3<<
1216 "signal4="<<signal4<<
1217 "signal5="<<signal5<<
1223 (* fDebugStreamer) << "HandlePRFtracklet"<<
1224 "caligroup="<<caligroup<<
1225 "detector="<<detector<<
1228 "npoints="<<npoints<<
1237 "padPosition="<<padPositions[k]<<
1238 "padPosTracklet="<<padPosTracklet<<
1243 "signal1="<<signal1<<
1244 "signal2="<<signal2<<
1245 "signal3="<<signal3<<
1246 "signal4="<<signal4<<
1247 "signal5="<<signal5<<
1253 (* fDebugStreamer) << "HandlePRFtracklet"<<
1254 "caligroup="<<caligroup<<
1255 "detector="<<detector<<
1258 "npoints="<<npoints<<
1267 "padPosition="<<padPositions[k]<<
1268 "padPosTracklet="<<padPosTracklet<<
1273 "signal1="<<signal1<<
1274 "signal2="<<signal2<<
1275 "signal3="<<signal3<<
1276 "signal4="<<signal4<<
1277 "signal5="<<signal5<<
1283 ////////////////////////////
1285 ///////////////////////////
1286 if(npoints < fNumberClusters) continue;
1287 if(npoints > fNumberClustersf) continue;
1288 if(nb3pc <= 5) continue;
1289 if((time >= 21) || (time < 7)) continue;
1290 if(TMath::Abs(snp) >= 1.0) continue;
1291 if(TMath::Abs(qcl) < 80) continue;
1293 ////////////////////////////
1295 ///////////////////////////
1297 if(TMath::Abs(dpad) < 1.5) {
1298 fPRF2d->Fill(shift+dpad,(caligroup+0.5),ycenter);
1299 fPRF2d->Fill(shift-dpad,(caligroup+0.5),ycenter);
1301 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
1302 fPRF2d->Fill(shift-(dpad+1.0),(caligroup+0.5),ymin);
1303 fPRF2d->Fill(shift+(dpad+1.0),(caligroup+0.5),ymin);
1305 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
1306 fPRF2d->Fill(shift+1.0-dpad,(caligroup+0.5),ymax);
1307 fPRF2d->Fill(shift-1.0+dpad,(caligroup+0.5),ymax);
1311 if(TMath::Abs(dpad) < 1.5) {
1312 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+dpad,ycenter);
1313 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-dpad,ycenter);
1315 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
1316 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-(dpad+1.0),ymin);
1317 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+(dpad+1.0),ymin);
1319 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
1320 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+1.0-dpad,ymax);
1321 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-1.0+dpad,ymax);
1325 delete [] padPositions;
1329 //____________Offine tracking in the AliTRDtracker_____________________________
1330 Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters)
1333 // PRF width calibration
1334 // Assume a Gaussian shape: determinate the position of the three pad clusters
1335 // Fit with a straight line
1336 // Take the fitted values for all the clusters (3 or 2 pad clusters)
1337 // Fill the PRF as function of angle of the track
1341 //printf("begin\n");
1342 ///////////////////////////////////////////
1343 // Take the parameters of the track
1344 //////////////////////////////////////////
1345 // take now the snp, tnp and tgl from the track
1346 Double_t snp = tracklet->GetSnp(); // sin dy/dx at the end of the chamber
1347 Double_t tnp = 0.0; // dy/dx at the end of the chamber
1348 if( TMath::Abs(snp) < 1.){
1349 tnp = snp / TMath::Sqrt((1.-snp)*(1.+snp));
1351 Double_t tgl = tracklet->GetTgl(); // dz/dl
1352 Double_t dzdx = tgl*TMath::Sqrt(1+tnp*tnp); // dz/dx calculated from dz/dl
1354 //Double_t tnp = tracklet->GetYref(1); // dy/dx at the entrance of the chamber
1355 //Double_t tgl = tracklet->GetZref(1); // dz/dl at the entrance of the chamber
1356 //Double_t dzdx = tgl; //*TMath::Sqrt(1+tnp*tnp); // dz/dx from dz/dl
1357 // at the end with correction due to linear fit
1358 //Double_t tnp = tracklet->GetYfit(1); // dy/dx at the end of the chamber after fit correction
1359 //Double_t tgl = tracklet->GetZfit(1); // dz/dl at the end of the chamber after fit correction
1361 ///////////////////////////////
1362 // Calculate tnp group shift
1363 ///////////////////////////////
1364 Bool_t echec = kFALSE;
1365 Double_t shift = 0.0;
1366 //Calculate the shift in x coresponding to this tnp
1367 if(fNgroupprf != 0.0){
1368 shift = -3.0*(fNgroupprf-1)-1.5;
1369 Double_t limithigh = -0.2*(fNgroupprf-1);
1370 if((tnp < (-0.2*fNgroupprf)) || (tnp > (0.2*fNgroupprf))) echec = kTRUE;
1372 while(tnp > limithigh){
1378 // do nothing if out of tnp range
1379 //printf("echec %d\n",(Int_t)echec);
1380 if(echec) return kFALSE;
1382 ///////////////////////
1384 //////////////////////
1386 Int_t nb3pc = 0; // number of three pads clusters used for fit
1387 // to see the difference between the fit and the 3 pad clusters position
1388 Double_t padPositions[AliTRDseedV1::kNtb];
1389 memset(padPositions, 0, AliTRDseedV1::kNtb*sizeof(Double_t));
1390 fLinearFitterTracklet->ClearPoints();
1392 //printf("loop clusters \n");
1393 ////////////////////////////
1394 // loop over the clusters
1395 ////////////////////////////
1396 AliTRDcluster *cl = 0x0;
1397 for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
1398 // reject shared clusters on pad row
1399 if((ic+AliTRDseedV1::kNtb) < AliTRDseedV1::kNclusters) {
1400 if((cl = tracklet->GetClusters(ic+AliTRDseedV1::kNtb))) continue;
1402 if(!(cl = tracklet->GetClusters(ic))) continue;
1403 Double_t time = cl->GetPadTime();
1404 if((time<=7) || (time>=21)) continue;
1405 Short_t *signals = cl->GetSignals();
1406 Float_t xcenter = 0.0;
1407 Bool_t echec1 = kTRUE;
1409 /////////////////////////////////////////////////////////////
1410 // Center 3 balanced: position with the center of the pad
1411 /////////////////////////////////////////////////////////////
1412 if ((((Float_t) signals[3]) > 0.0) &&
1413 (((Float_t) signals[2]) > 0.0) &&
1414 (((Float_t) signals[4]) > 0.0)) {
1416 // Security if the denomiateur is 0
1417 if ((((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) /
1418 ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))) != 1.0) {
1419 xcenter = 0.5 * (TMath::Log((Float_t) (((Float_t) signals[4]) / ((Float_t) signals[2]))))
1420 / (TMath::Log(((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3])))
1421 / ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))));
1427 if(TMath::Abs(xcenter) > 0.5) echec1 = kTRUE;
1428 if(echec1) continue;
1430 ////////////////////////////////////////////////////////
1431 //if no echec1: calculate with the position of the pad
1432 // Position of the cluster
1433 // fill the linear fitter
1434 ///////////////////////////////////////////////////////
1435 Double_t padPosition = xcenter + cl->GetPadCol();
1436 padPositions[ic] = padPosition;
1438 fLinearFitterTracklet->AddPoint(&time, padPosition,1);
1443 //printf("Fin loop clusters \n");
1444 //////////////////////////////
1445 // fit with a straight line
1446 /////////////////////////////
1448 fLinearFitterTracklet->ClearPoints();
1451 fLinearFitterTracklet->Eval();
1453 fLinearFitterTracklet->GetParameters(line);
1454 Float_t pointError = -1.0;
1455 if( fLinearFitterTracklet->GetChisquare()>=0.0) {
1456 pointError = TMath::Sqrt( fLinearFitterTracklet->GetChisquare()/(nb3pc-2));
1458 fLinearFitterTracklet->ClearPoints();
1460 //printf("PRF second loop \n");
1461 ////////////////////////////////////////////////
1462 // Fill the PRF: Second loop over clusters
1463 //////////////////////////////////////////////
1464 for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
1465 // reject shared clusters on pad row
1466 if(((ic+AliTRDseedV1::kNtb) < AliTRDseedV1::kNclusters) && (cl = tracklet->GetClusters(ic+AliTRDseedV1::kNtb))) continue;
1468 if(!(cl = tracklet->GetClusters(ic))) continue;
1470 Short_t *signals = cl->GetSignals(); // signal
1471 Double_t time = cl->GetPadTime(); // time bin
1472 Float_t padPosTracklet = line[0]+line[1]*time; // reconstruct position from fit
1473 Float_t padPos = cl->GetPadCol(); // middle pad
1474 Double_t dpad = padPosTracklet - padPos; // reconstruct position relative to middle pad from fit
1475 Float_t ycenter = 0.0; // relative center charge
1476 Float_t ymin = 0.0; // relative left charge
1477 Float_t ymax = 0.0; // relative right charge
1479 ////////////////////////////////////////////////////////////////
1480 // Calculate ycenter, ymin and ymax even for two pad clusters
1481 ////////////////////////////////////////////////////////////////
1482 if(((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[2]) > 0.0)) ||
1483 ((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[4]) > 0.0))){
1484 Float_t sum = ((Float_t) signals[2]) + ((Float_t) signals[3]) + ((Float_t) signals[4]);
1485 if(sum > 0.0) ycenter = ((Float_t) signals[3])/ sum;
1486 if(sum > 0.0) ymin = ((Float_t) signals[2])/ sum;
1487 if(sum > 0.0) ymax = ((Float_t) signals[4])/ sum;
1490 /////////////////////////
1491 // Calibration group
1492 ////////////////////////
1493 Int_t rowcl = cl->GetPadRow(); // row of cluster
1494 Int_t colcl = cl->GetPadCol(); // col of cluster
1495 Int_t grouplocal = CalculateCalibrationGroup(2,rowcl,colcl); // calcul the corresponding group
1496 Int_t caligroup = fCalibraMode->GetXbins(2)+ grouplocal; // calcul the corresponding group
1497 Float_t xcl = cl->GetY(); // y cluster
1498 Float_t qcl = cl->GetQ(); // charge cluster
1499 Int_t layer = GetLayer(fDetectorPreviousTrack); // layer
1500 Int_t stack = GetStack(fDetectorPreviousTrack); // stack
1501 Double_t xdiff = dpad; // reconstructed position constant
1502 Double_t x = dpad; // reconstructed position moved
1503 Float_t ep = pointError; // error of fit
1504 Float_t signal1 = (Float_t)signals[1]; // signal at the border
1505 Float_t signal3 = (Float_t)signals[3]; // signal
1506 Float_t signal2 = (Float_t)signals[2]; // signal
1507 Float_t signal4 = (Float_t)signals[4]; // signal
1508 Float_t signal5 = (Float_t)signals[5]; // signal at the border
1512 /////////////////////
1514 ////////////////////
1516 if(fDebugLevel > 0){
1517 if ( !fDebugStreamer ) {
1519 TDirectory *backup = gDirectory;
1520 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
1521 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
1526 Float_t y = ycenter;
1527 (* fDebugStreamer) << "HandlePRFtrackletV1"<<
1528 "caligroup="<<caligroup<<
1529 "detector="<<fDetectorPreviousTrack<<
1532 "npoints="<<nbclusters<<
1541 "padPosition="<<padPositions[ic]<<
1542 "padPosTracklet="<<padPosTracklet<<
1547 "signal1="<<signal1<<
1548 "signal2="<<signal2<<
1549 "signal3="<<signal3<<
1550 "signal4="<<signal4<<
1551 "signal5="<<signal5<<
1557 (* fDebugStreamer) << "HandlePRFtrackletV1"<<
1558 "caligroup="<<caligroup<<
1559 "detector="<<fDetectorPreviousTrack<<
1562 "npoints="<<nbclusters<<
1571 "padPosition="<<padPositions[ic]<<
1572 "padPosTracklet="<<padPosTracklet<<
1577 "signal1="<<signal1<<
1578 "signal2="<<signal2<<
1579 "signal3="<<signal3<<
1580 "signal4="<<signal4<<
1581 "signal5="<<signal5<<
1587 (* fDebugStreamer) << "HandlePRFtrackletV1"<<
1588 "caligroup="<<caligroup<<
1589 "detector="<<fDetectorPreviousTrack<<
1592 "npoints="<<nbclusters<<
1601 "padPosition="<<padPositions[ic]<<
1602 "padPosTracklet="<<padPosTracklet<<
1607 "signal1="<<signal1<<
1608 "signal2="<<signal2<<
1609 "signal3="<<signal3<<
1610 "signal4="<<signal4<<
1611 "signal5="<<signal5<<
1617 /////////////////////
1619 /////////////////////
1620 if(nbclusters < fNumberClusters) continue;
1621 if(nbclusters > fNumberClustersf) continue;
1622 if(nb3pc <= 5) continue;
1623 if((time >= 21) || (time < 7)) continue;
1624 if(TMath::Abs(qcl) < 80) continue;
1625 if( TMath::Abs(snp) > 1.) continue;
1628 ////////////////////////
1630 ///////////////////////
1632 if(TMath::Abs(dpad) < 1.5) {
1633 fPRF2d->Fill(shift+dpad,(caligroup+0.5),ycenter);
1634 fPRF2d->Fill(shift-dpad,(caligroup+0.5),ycenter);
1635 //printf("place %f, ycenter %f\n",(shift+dpad),ycenter);
1637 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
1638 fPRF2d->Fill(shift-(dpad+1.0),(caligroup+0.5),ymin);
1639 fPRF2d->Fill(shift+(dpad+1.0),(caligroup+0.5),ymin);
1641 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
1642 fPRF2d->Fill(shift+1.0-dpad,(caligroup+0.5),ymax);
1643 fPRF2d->Fill(shift-1.0+dpad,(caligroup+0.5),ymax);
1648 if(TMath::Abs(dpad) < 1.5) {
1649 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+dpad,ycenter);
1650 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-dpad,ycenter);
1652 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
1653 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-(dpad+1.0),ymin);
1654 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+(dpad+1.0),ymin);
1656 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
1657 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+1.0-dpad,ymax);
1658 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-1.0+dpad,ymax);
1661 } // second loop over clusters
1666 ///////////////////////////////////////////////////////////////////////////////////////
1667 // Pad row col stuff: see if masked or not
1668 ///////////////////////////////////////////////////////////////////////////////////////
1669 //_____________________________________________________________________________
1670 void AliTRDCalibraFillHisto::CheckGoodTrackletV1(const AliTRDcluster *cl)
1673 // See if we are not near a masked pad
1676 if(cl->IsMasked()) fGoodTracklet = kFALSE;
1680 //_____________________________________________________________________________
1681 void AliTRDCalibraFillHisto::CheckGoodTrackletV0(const Int_t detector,const Int_t row,const Int_t col)
1684 // See if we are not near a masked pad
1687 if (!IsPadOn(detector, col, row)) {
1688 fGoodTracklet = kFALSE;
1692 if (!IsPadOn(detector, col-1, row)) {
1693 fGoodTracklet = kFALSE;
1698 if (!IsPadOn(detector, col+1, row)) {
1699 fGoodTracklet = kFALSE;
1704 //_____________________________________________________________________________
1705 Bool_t AliTRDCalibraFillHisto::IsPadOn(Int_t detector, Int_t row, Int_t col) const
1708 // Look in the choosen database if the pad is On.
1709 // If no the track will be "not good"
1712 // Get the parameter object
1713 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
1715 AliInfo("Could not get calibDB");
1719 if (!cal->IsChamberInstalled(detector) ||
1720 cal->IsChamberMasked(detector) ||
1721 cal->IsPadMasked(detector,col,row)) {
1729 ///////////////////////////////////////////////////////////////////////////////////////
1730 // Calibration groups: calculate the number of groups, localise...
1731 ////////////////////////////////////////////////////////////////////////////////////////
1732 //_____________________________________________________________________________
1733 Int_t AliTRDCalibraFillHisto::CalculateCalibrationGroup(Int_t i, Int_t row, Int_t col) const
1736 // Calculate the calibration group number for i
1739 // Row of the cluster and position in the pad groups
1741 if (fCalibraMode->GetNnZ(i) != 0) {
1742 posr = (Int_t) row / fCalibraMode->GetNnZ(i);
1746 // Col of the cluster and position in the pad groups
1748 if (fCalibraMode->GetNnRphi(i) != 0) {
1749 posc = (Int_t) col / fCalibraMode->GetNnRphi(i);
1752 return posc*fCalibraMode->GetNfragZ(i)+posr;
1755 //____________________________________________________________________________________
1756 Int_t AliTRDCalibraFillHisto::CalculateTotalNumberOfBins(Int_t i)
1759 // Calculate the total number of calibration groups
1765 if((fCalibraMode->GetNz(i)==100) && (fCalibraMode->GetNrphi(i)==100)){
1767 AliInfo(Form("Total number of Xbins: %d for i %d",ntotal,i));
1772 if((fCalibraMode->GetNz(i)==10) && (fCalibraMode->GetNrphi(i)==10)){
1774 AliInfo(Form("Total number of Xbins: %d for i %d",ntotal,i));
1779 fCalibraMode->ModePadCalibration(2,i);
1780 fCalibraMode->ModePadFragmentation(0,2,0,i);
1781 fCalibraMode->SetDetChamb2(i);
1782 ntotal += 6 * 18 * fCalibraMode->GetDetChamb2(i);
1783 fCalibraMode->ModePadCalibration(0,i);
1784 fCalibraMode->ModePadFragmentation(0,0,0,i);
1785 fCalibraMode->SetDetChamb0(i);
1786 ntotal += 6 * 4 * 18 * fCalibraMode->GetDetChamb0(i);
1787 AliInfo(Form("Total number of Xbins: %d for i %d",ntotal,i));
1791 //_____________________________________________________________________________
1792 void AliTRDCalibraFillHisto::SetNz(Int_t i, Short_t Nz)
1795 // Set the mode of calibration group in the z direction for the parameter i
1800 fCalibraMode->SetNz(i, Nz);
1803 AliInfo("You have to choose between 0 and 4");
1807 //_____________________________________________________________________________
1808 void AliTRDCalibraFillHisto::SetNrphi(Int_t i, Short_t Nrphi)
1811 // Set the mode of calibration group in the rphi direction for the parameter i
1816 fCalibraMode->SetNrphi(i ,Nrphi);
1819 AliInfo("You have to choose between 0 and 6");
1824 //_____________________________________________________________________________
1825 void AliTRDCalibraFillHisto::SetAllTogether(Int_t i)
1828 // Set the mode of calibration group all together
1830 if(fVector2d == kTRUE) {
1831 AliInfo("Can not work with the vector method");
1834 fCalibraMode->SetAllTogether(i);
1838 //_____________________________________________________________________________
1839 void AliTRDCalibraFillHisto::SetPerSuperModule(Int_t i)
1842 // Set the mode of calibration group per supermodule
1844 if(fVector2d == kTRUE) {
1845 AliInfo("Can not work with the vector method");
1848 fCalibraMode->SetPerSuperModule(i);
1852 //____________Set the pad calibration variables for the detector_______________
1853 Bool_t AliTRDCalibraFillHisto::LocalisationDetectorXbins(Int_t detector)
1856 // For the detector calcul the first Xbins and set the number of row
1857 // and col pads per calibration groups, the number of calibration
1858 // groups in the detector.
1861 // first Xbins of the detector
1863 fCalibraMode->CalculXBins(detector,0);
1866 fCalibraMode->CalculXBins(detector,1);
1869 fCalibraMode->CalculXBins(detector,2);
1872 // fragmentation of idect
1873 for (Int_t i = 0; i < 3; i++) {
1874 fCalibraMode->ModePadCalibration((Int_t) GetStack(detector),i);
1875 fCalibraMode->ModePadFragmentation((Int_t) GetLayer(detector)
1876 , (Int_t) GetStack(detector)
1877 , (Int_t) GetSector(detector),i);
1883 //_____________________________________________________________________________
1884 void AliTRDCalibraFillHisto::SetNumberGroupsPRF(Short_t numberGroupsPRF)
1887 // Should be between 0 and 6
1890 if ((numberGroupsPRF < 0) || (numberGroupsPRF > 6)) {
1891 AliInfo("The number of groups must be between 0 and 6!");
1894 fNgroupprf = numberGroupsPRF;
1898 ///////////////////////////////////////////////////////////////////////////////////////////
1899 // Per tracklet: store or reset the info, fill the histos with the info
1900 //////////////////////////////////////////////////////////////////////////////////////////
1901 //_____________________________________________________________________________
1902 void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(const AliTRDcluster *cl,const Double_t dqdl,const Int_t *group,const Int_t row,const Int_t col)
1905 // Store the infos in fAmpTotal, fPHPlace and fPHValue
1906 // Correct from the gain correction before
1909 // time bin of the cluster not corrected
1910 Int_t time = cl->GetPadTime();
1911 Float_t charge = TMath::Abs(cl->GetQ());
1913 //printf("Store::time %d, amplitude %f\n",time,dqdl);
1915 //Correct for the gain coefficient used in the database for reconstruction
1916 Float_t correctthegain = 1.0;
1917 if(fIsHLT) correctthegain = fCalDetGain->GetValue(fDetectorPreviousTrack);
1918 else correctthegain = fCalDetGain->GetValue(fDetectorPreviousTrack)*fCalROCGain->GetValue(col,row);
1919 Float_t correction = 1.0;
1920 Float_t normalisation = 6.67;
1921 // we divide with gain in AliTRDclusterizer::Transform...
1922 if( correctthegain > 0 ) normalisation /= correctthegain;
1925 // take dd/dl corrected from the angle of the track
1926 correction = dqdl / (normalisation);
1929 // Fill the fAmpTotal with the charge
1931 if((!fLimitChargeIntegration) || (cl->IsInChamber())) {
1932 //printf("Store::group %d, amplitude %f\n",group[0],correction);
1933 fAmpTotal[(Int_t) group[0]] += correction;
1937 // Fill the fPHPlace and value
1939 fPHPlace[time] = group[1];
1940 fPHValue[time] = charge;
1944 //____________Offine tracking in the AliTRDtracker_____________________________
1945 void AliTRDCalibraFillHisto::ResetfVariablestracklet()
1948 // Reset values per tracklet
1951 //Reset good tracklet
1952 fGoodTracklet = kTRUE;
1954 // Reset the fPHValue
1956 //Reset the fPHValue and fPHPlace
1957 for (Int_t k = 0; k < fTimeMax; k++) {
1963 // Reset the fAmpTotal where we put value
1965 for (Int_t k = 0; k < fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0); k++) {
1970 //____________Offine tracking in the AliTRDtracker_____________________________
1971 void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackCH(Int_t nbclusters)
1974 // For the offline tracking or mcm tracklets
1975 // This function will be called in the functions UpdateHistogram...
1976 // to fill the info of a track for the relativ gain calibration
1979 Int_t nb = 0; // Nombre de zones traversees
1980 Int_t fd = -1; // Premiere zone non nulle
1981 Float_t totalcharge = 0.0; // Total charge for the supermodule histo
1983 //printf("CH2d nbclusters %d, fNumberClusters %d, fNumberClustersf %d\n",nbclusters,fNumberClusters,fNumberClustersf);
1985 if(nbclusters < fNumberClusters) return;
1986 if(nbclusters > fNumberClustersf) return;
1989 // Normalize with the number of clusters
1990 Double_t normalizeCst = fRelativeScale;
1991 if(fNormalizeNbOfCluster) normalizeCst = normalizeCst*nbclusters;
1993 //printf("Number of groups in one detector %d\n",fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0));
1995 // See if the track goes through different zones
1996 for (Int_t k = 0; k < fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0); k++) {
1997 //printf("fAmpTotal %f for %d\n",fAmpTotal[k],k);
1998 if (fAmpTotal[k] > 0.0) {
1999 totalcharge += fAmpTotal[k];
2007 //printf("CH2d: nb %d, fd %d, calibration group %d, amplitude %f, detector %d\n",nb,fd,fCalibraMode->GetXbins(0),fAmpTotal[fd]/normalizeCst,fDetectorPreviousTrack);
2013 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
2015 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/normalizeCst);
2016 //fCH2d->Fill(fAmpTotal[fd]/normalizeCst,fCalibraMode->GetXbins(0)+fd+0.5);
2019 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/normalizeCst);
2023 if ((fAmpTotal[fd] > 0.0) &&
2024 (fAmpTotal[fd+1] > 0.0)) {
2025 // One of the two very big
2026 if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+1]) {
2028 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/normalizeCst);
2029 //fCH2d->Fill(fAmpTotal[fd]/normalizeCst,fCalibraMode->GetXbins(0)+fd+0.5);
2032 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/normalizeCst);
2035 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
2037 if (fAmpTotal[fd+1] > fProcent*fAmpTotal[fd]) {
2039 FillCH2d(fCalibraMode->GetXbins(0)+fd+1,fAmpTotal[fd+1]/normalizeCst);
2040 //fCH2d->Fill(fAmpTotal[fd+1]/normalizeCst,fCalibraMode->GetXbins(0)+fd+1.5);
2043 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd+1,fAmpTotal[fd+1]/normalizeCst);
2046 fEntriesCH[fCalibraMode->GetXbins(0)+fd+1]++;
2049 if (fCalibraMode->GetNfragZ(0) > 1) {
2050 if (fAmpTotal[fd] > 0.0) {
2051 if ((fd+fCalibraMode->GetNfragZ(0)) < (fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0))) {
2052 if (fAmpTotal[fd+fCalibraMode->GetNfragZ(0)] > 0.0) {
2053 // One of the two very big
2054 if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]) {
2056 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/normalizeCst);
2057 //fCH2d->Fill(fAmpTotal[fd]/normalizeCst,fCalibraMode->GetXbins(0)+fd+0.5);
2060 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/normalizeCst);
2063 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
2065 if (fAmpTotal[fd+fCalibraMode->GetNfragZ(0)] > fProcent*fAmpTotal[fd]) {
2067 FillCH2d(fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0),fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/normalizeCst);
2068 //fCH2d->Fill(fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/normalizeCst,fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0)+0.5);
2071 fEntriesCH[fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0)]++;
2073 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd+fCalibraMode->GetNfragZ(0),fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/normalizeCst);
2084 //____________Offine tracking in the AliTRDtracker_____________________________
2085 void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH()
2088 // For the offline tracking or mcm tracklets
2089 // This function will be called in the functions UpdateHistogram...
2090 // to fill the info of a track for the drift velocity calibration
2093 Int_t nb = 1; // Nombre de zones traversees 1, 2 ou plus de 3
2094 Int_t fd1 = -1; // Premiere zone non nulle
2095 Int_t fd2 = -1; // Deuxieme zone non nulle
2096 Int_t k1 = -1; // Debut de la premiere zone
2097 Int_t k2 = -1; // Debut de la seconde zone
2098 Int_t nbclusters = 0; // number of clusters
2102 // See if the track goes through different zones
2103 for (Int_t k = 0; k < fTimeMax; k++) {
2104 if (fPHValue[k] > 0.0) {
2110 if (fPHPlace[k] != fd1) {
2116 if (fPHPlace[k] != fd2) {
2123 // See if noise before and after
2124 if(fMaxCluster > 0) {
2125 if(fPHValue[0] > fMaxCluster) return;
2126 if(fTimeMax > fNbMaxCluster) {
2127 for(Int_t k = (fTimeMax-fNbMaxCluster); k < fTimeMax; k++){
2128 if(fPHValue[k] > fMaxCluster) return;
2133 //printf("nbclusters %d, low limit %d, high limit %d\n",nbclusters,fNumberClusters,fNumberClustersf);
2135 if(nbclusters < fNumberClusters) return;
2136 if(nbclusters > fNumberClustersf) return;
2142 for (Int_t i = 0; i < fTimeMax; i++) {
2144 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2146 if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2148 //printf("Fill the time bin %d with %f\n",i,fPHValue[i]);
2151 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2153 if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2159 if ((fd1 == fd2+1) ||
2161 // One of the two fast all the think
2162 if (k2 > (k1+fDifference)) {
2163 //we choose to fill the fd1 with all the values
2165 for (Int_t i = 0; i < fTimeMax; i++) {
2167 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2169 if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2173 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2175 if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2180 if ((k2+fDifference) < fTimeMax) {
2181 //we choose to fill the fd2 with all the values
2183 for (Int_t i = 0; i < fTimeMax; i++) {
2185 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2187 if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2191 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2193 if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2199 // Two zones voisines sinon rien!
2200 if (fCalibraMode->GetNfragZ(1) > 1) {
2202 if ((fd1+fCalibraMode->GetNfragZ(1)) < (fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1))) {
2203 if (fd2 == (fd1+fCalibraMode->GetNfragZ(1))) {
2204 // One of the two fast all the think
2205 if (k2 > (k1+fDifference)) {
2206 //we choose to fill the fd1 with all the values
2208 for (Int_t i = 0; i < fTimeMax; i++) {
2210 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2212 if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2216 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2218 if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2223 if ((k2+fDifference) < fTimeMax) {
2224 //we choose to fill the fd2 with all the values
2226 for (Int_t i = 0; i < fTimeMax; i++) {
2228 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2230 if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2234 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2236 if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2243 // Two zones voisines sinon rien!
2245 if ((fd1 - fCalibraMode->GetNfragZ(1)) >= 0) {
2246 if (fd2 == (fd1 - fCalibraMode->GetNfragZ(1))) {
2247 // One of the two fast all the think
2248 if (k2 > (k1 + fDifference)) {
2249 //we choose to fill the fd1 with all the values
2251 for (Int_t i = 0; i < fTimeMax; i++) {
2253 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2255 if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2259 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2261 if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2266 if ((k2+fDifference) < fTimeMax) {
2267 //we choose to fill the fd2 with all the values
2269 for (Int_t i = 0; i < fTimeMax; i++) {
2271 if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2273 if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2277 if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2279 if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2291 //////////////////////////////////////////////////////////////////////////////////////////
2292 // DAQ process functions
2293 /////////////////////////////////////////////////////////////////////////////////////////
2294 //_____________________________________________________________________
2295 Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bool_t nocheck)
2298 // Event Processing loop - AliTRDrawStreamBase
2299 // TestBeam 2007 version
2300 // 0 timebin problem
2303 // Same algorithm as TestBeam but different reader
2306 Int_t withInput = 1;
2308 Double_t phvalue[16][144][36];
2309 for(Int_t k = 0; k < 36; k++){
2310 for(Int_t j = 0; j < 16; j++){
2311 for(Int_t c = 0; c < 144; c++){
2312 phvalue[j][c][k] = 0.0;
2317 fDetectorPreviousTrack = -1;
2320 Int_t nbtimebin = 0;
2321 Int_t baseline = 10;
2328 while (rawStream->Next()) {
2330 Int_t idetector = rawStream->GetDet(); // current detector
2331 Int_t imcm = rawStream->GetMCM(); // current MCM
2332 Int_t irob = rawStream->GetROB(); // current ROB
2334 //printf("Detector %d\n",idetector);
2336 if((fDetectorPreviousTrack != idetector) && (fDetectorPreviousTrack != -1)){
2339 withInput = TMath::Max(FillDAQ(phvalue),withInput);
2343 for(Int_t k = 0; k < 36; k++){
2344 for(Int_t j = 0; j < 16; j++){
2345 for(Int_t c = 0; c < 144; c++){
2346 phvalue[j][c][k] = 0.0;
2352 fDetectorPreviousTrack = idetector;
2353 fMCMPrevious = imcm;
2354 fROBPrevious = irob;
2356 nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
2357 if(nbtimebin == 0) return 0;
2358 if((fTimeMax != 0) && (nbtimebin != fTimeMax)) return 0;
2359 fTimeMax = nbtimebin;
2361 //baseline = rawStream->GetCommonAdditive(); // common additive baseline
2362 fNumberClustersf = fTimeMax;
2363 fNumberClusters = (Int_t)(0.6*fTimeMax);
2366 Int_t *signal = rawStream->GetSignals(); // current ADC signal
2367 Int_t col = rawStream->GetCol();
2368 Int_t row = rawStream->GetRow();
2371 //printf("detector %d, signal[0] %d, signal[1] %d, signal[2] %d, baseline %d\n",idetector,signal[0],signal[1],signal[2], baseline);
2374 for(Int_t itime = 0; itime < nbtimebin; itime++){
2375 phvalue[row][col][itime] = signal[itime]-baseline;
2379 // fill the last one
2380 if(fDetectorPreviousTrack != -1){
2383 withInput = TMath::Max(FillDAQ(phvalue),withInput);
2386 for(Int_t k = 0; k < 36; k++){
2387 for(Int_t j = 0; j < 16; j++){
2388 for(Int_t c = 0; c < 144; c++){
2389 phvalue[j][c][k] = 0.0;
2398 while (rawStream->Next()) {
2400 Int_t idetector = rawStream->GetDet(); // current detector
2401 Int_t imcm = rawStream->GetMCM(); // current MCM
2402 Int_t irob = rawStream->GetROB(); // current ROB
2404 //printf("Detector %d\n",idetector);
2406 if((fDetectorPreviousTrack != idetector) && (fDetectorPreviousTrack != -1)){
2409 withInput = TMath::Max(FillDAQ(phvalue),withInput);
2412 for(Int_t k = 0; k < 36; k++){
2413 for(Int_t j = 0; j < 16; j++){
2414 for(Int_t c = 0; c < 144; c++){
2415 phvalue[j][c][k] = 0.0;
2421 fDetectorPreviousTrack = idetector;
2422 fMCMPrevious = imcm;
2423 fROBPrevious = irob;
2425 //baseline = rawStream->GetCommonAdditive(); // common baseline
2427 fTimeMax = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
2428 fNumberClustersf = fTimeMax;
2429 fNumberClusters = (Int_t)(0.6*fTimeMax);
2430 Int_t *signal = rawStream->GetSignals(); // current ADC signal
2431 Int_t col = rawStream->GetCol();
2432 Int_t row = rawStream->GetRow();
2435 //printf("detector %d, signal[0] %d, signal[1] %d, signal[2] %d, baseline %d\n",idetector,signal[0],signal[1],signal[2], baseline);
2437 for(Int_t itime = 0; itime < fTimeMax; itime++){
2438 phvalue[row][col][itime] = signal[itime]-baseline;
2442 // fill the last one
2443 if(fDetectorPreviousTrack != -1){
2446 withInput = TMath::Max(FillDAQ(phvalue),withInput);
2449 for(Int_t k = 0; k < 36; k++){
2450 for(Int_t j = 0; j < 16; j++){
2451 for(Int_t c = 0; c < 144; c++){
2452 phvalue[j][c][k] = 0.0;
2462 //_____________________________________________________________________
2463 Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliRawReader *rawReader, Bool_t nocheck)
2466 // Event processing loop - AliRawReader
2467 // Testbeam 2007 version
2470 AliTRDrawStreamBase rawStream(rawReader);
2472 rawReader->Select("TRD");
2474 return ProcessEventDAQ(&rawStream, nocheck);
2477 //_________________________________________________________________________
2478 Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(
2480 const eventHeaderStruct *event,
2483 const eventHeaderStruct* /*event*/,
2490 // process date event
2491 // Testbeam 2007 version
2494 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
2495 Int_t result=ProcessEventDAQ(rawReader, nocheck);
2499 Fatal("AliTRDCalibraFillHisto", "this class was compiled without DATE");
2504 //////////////////////////////////////////////////////////////////////////////
2505 // Routine inside the DAQ process
2506 /////////////////////////////////////////////////////////////////////////////
2507 //_______________________________________________________________________
2508 Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){
2511 // Look for the maximum by collapsing over the time
2512 // Sum over four pad col and two pad row
2518 Int_t idect = fDetectorPreviousTrack;
2519 //printf("Enter Detector %d\n",fDetectorPreviousTrack);
2521 for(Int_t tb = 0; tb < 36; tb++){
2525 //fGoodTracklet = kTRUE;
2526 //fDetectorPreviousTrack = 0;
2529 ///////////////////////////
2531 /////////////////////////
2535 Double_t integralMax = -1;
2537 for (Int_t ir = 1; ir <= 15; ir++)
2539 for (Int_t ic = 2; ic <= 142; ic++)
2541 Double_t integral = 0;
2542 for (Int_t ishiftR = 0; ishiftR < 2; ishiftR++)
2544 for (Int_t ishiftC = -2; ishiftC < 2; ishiftC++)
2546 if (ir + ishiftR >= 1 && ir + ishiftR <= 16 &&
2547 ic + ishiftC >= 1 && ic + ishiftC <= 144)
2550 for(Int_t tb = 0; tb< fTimeMax; tb++){
2551 integral += phvalue[ir + ishiftR-1][ic + ishiftC-1][tb];
2557 if (integralMax < integral)
2561 integralMax = integral;
2562 } // check max integral
2566 //printf("imaxRow %d, imaxCol %d, fTimeMax %d, integralMax %f\n",imaxRow,imaxCol,fTimeMax, integralMax);
2568 if((imaxRow == 0) || (imaxCol == 0)) {
2572 //CheckGoodTrackletV0(fDetectorPreviousTrack,imaxRow,imaxCol);
2573 //if(!fGoodTracklet) used = 1;;
2575 // /////////////////////////////////////////////////////
2576 // sum ober 2 row and 4 pad cols for each time bins
2577 // ////////////////////////////////////////////////////
2580 for (Int_t ir = imaxRow - 1; ir < imaxRow + 1; ir++)
2582 for (Int_t ic = imaxCol - 2; ic < imaxCol + 2; ic++)
2584 for(Int_t it = 0; it < fTimeMax; it++){
2585 sum[it] += phvalue[ir][ic][it];
2591 Double_t sumcharge = 0.0;
2592 for(Int_t it = 0; it < fTimeMax; it++){
2593 sumcharge += sum[it];
2594 if(sum[it] > 20.0) nbcl++;
2598 /////////////////////////////////////////////////////////
2600 ////////////////////////////////////////////////////////
2601 if(fDebugLevel > 0){
2602 if ( !fDebugStreamer ) {
2604 TDirectory *backup = gDirectory;
2605 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
2606 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2609 Double_t amph0 = sum[0];
2610 Double_t amphlast = sum[fTimeMax-1];
2611 Double_t rms = TMath::RMS(fTimeMax,sum);
2612 Int_t goodtracklet = (Int_t) fGoodTracklet;
2613 for(Int_t it = 0; it < fTimeMax; it++){
2614 Double_t clustera = sum[it];
2616 (* fDebugStreamer) << "FillDAQa"<<
2617 "ampTotal="<<sumcharge<<
2620 "detector="<<idect<<
2622 "amphlast="<<amphlast<<
2623 "goodtracklet="<<goodtracklet<<
2624 "clustera="<<clustera<<
2631 ////////////////////////////////////////////////////////
2633 ///////////////////////////////////////////////////////
2634 if(sum[0] > 100.0) used = 1;
2635 if(nbcl < fNumberClusters) used = 1;
2636 if(nbcl > fNumberClustersf) used = 1;
2638 //if(fDetectorPreviousTrack == 15){
2639 // printf("rms %f and first time bin %f\n",TMath::RMS(fTimeMax,sum),sum[0]);
2641 //if((TMath::RMS(fTimeMax,sum) <= 10.0) && (sum[0] > 200.0)) return 1;
2643 for(Int_t it = 0; it < fTimeMax; it++){
2644 if(fFillWithZero) UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax);
2646 if(sum[it] > 0.0) UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax);
2651 //((TH2I *)GetCH2d()->Fill(sumcharge/30.0,fDetectorPreviousTrack));
2653 //printf("Pass Detector %d\n",fDetectorPreviousTrack);
2660 //____________Online trackling in AliTRDtrigger________________________________
2661 Bool_t AliTRDCalibraFillHisto::UpdateDAQ(Int_t det, Int_t /*row*/, Int_t /*col*/, Int_t timebin, Float_t signal, Int_t nbtimebins)
2665 // Fill a simple average pulse height
2669 ((TProfile2D *)GetPH2d(nbtimebins,fSf))->Fill((Float_t) timebin/fSf,det+0.5,(Float_t) signal);
2675 //____________Write_____________________________________________________
2676 //_____________________________________________________________________
2677 void AliTRDCalibraFillHisto::Write2d(const Char_t *filename, Bool_t append)
2680 // Write infos to file
2684 if ( fDebugStreamer ) {
2685 delete fDebugStreamer;
2686 fDebugStreamer = 0x0;
2689 AliInfo(Form("Numbertrack: %d Numberusedch[0]: %d, Numberusedch[1]: %d Numberusedph[0]: %d, Numberusedph[1]: %d"
2694 ,fNumberUsedPh[1]));
2696 TDirectory *backup = gDirectory;
2702 option = "recreate";
2704 TFile f(filename,option.Data());
2706 TStopwatch stopwatch;
2709 f.WriteTObject(fCalibraVector);
2714 f.WriteTObject(fCH2d);
2719 f.WriteTObject(fPH2d);
2724 f.WriteTObject(fPRF2d);
2727 if(fLinearFitterOn){
2728 AnalyseLinearFitter();
2729 f.WriteTObject(fLinearVdriftFit);
2734 if ( backup ) backup->cd();
2736 AliInfo(Form("Execution time Write2d: R:%.2fs C:%.2fs"
2737 ,stopwatch.RealTime(),stopwatch.CpuTime()));
2739 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
2741 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
2742 //___________________________________________probe the histos__________________________________________________
2743 Double_t *AliTRDCalibraFillHisto::StatH(TH2 *h, Int_t i)
2746 // Check the number of stats in h, 0 is TH2I 1 is TProfile2D
2747 // debug mode with 2 for TH2I and 3 for TProfile2D
2748 // It gives a pointer to a Double_t[7] with the info following...
2749 // [0] : number of calibration groups with entries
2750 // [1] : minimal number of entries found
2751 // [2] : calibration group number of the min
2752 // [3] : maximal number of entries found
2753 // [4] : calibration group number of the max
2754 // [5] : mean number of entries found
2755 // [6] : mean relative error
2758 Double_t *info = new Double_t[7];
2760 // Number of Xbins (detectors or groups of pads)
2761 Int_t nbins = h->GetNbinsY(); //number of calibration groups
2762 Int_t nxbins = h->GetNbinsX(); //number of bins per histo
2765 Double_t nbwe = 0; //number of calibration groups with entries
2766 Double_t minentries = 0; //minimal number of entries found
2767 Double_t maxentries = 0; //maximal number of entries found
2768 Double_t placemin = 0; //calibration group number of the min
2769 Double_t placemax = -1; //calibration group number of the max
2770 Double_t meanstats = 0.0; //mean number of entries over the calibration group with at least ome entry
2771 Double_t meanrelativerror = 0.0; //mean relativ error in the TProfile2D
2773 Double_t counter = 0;
2776 TH1F *nbEntries = 0x0;//distribution of the number of entries
2777 TH1F *nbEntriesPerGroup = 0x0;//Number of entries per group
2778 TProfile *nbEntriesPerSp = 0x0;//Number of entries for one supermodule
2780 // Beginning of the loop over the calibration groups
2781 for (Int_t idect = 0; idect < nbins; idect++) {
2783 TH1I *projch = (TH1I *) h->ProjectionX("projch",idect+1,idect+1,(Option_t *)"e");
2784 projch->SetDirectory(0);
2786 // Number of entries for this calibration group
2787 Double_t nentries = 0.0;
2789 for (Int_t k = 0; k < nxbins; k++) {
2790 nentries += h->GetBinContent(h->GetBin(k+1,idect+1));
2794 for (Int_t k = 0; k < nxbins; k++) {
2795 nentries += ((TProfile2D *)h)->GetBinEntries(h->GetBin(k+1,idect+1));
2796 if(h->GetBinContent(h->GetBin(k+1,idect+1)) != 0) {
2797 meanrelativerror += (h->GetBinError(h->GetBin(k+1,idect+1))/(TMath::Abs(h->GetBinContent(h->GetBin(k+1,idect+1)))));
2805 if((!((Bool_t)nbEntries)) && (nentries > 0)){
2806 nbEntries = new TH1F("Number of entries","Number of entries"
2807 ,100,(Int_t)nentries/2,nentries*2);
2808 nbEntries->SetDirectory(0);
2809 nbEntriesPerGroup = new TH1F("Number of entries per group","Number of entries per group"
2811 nbEntriesPerGroup->SetDirectory(0);
2812 nbEntriesPerSp = new TProfile("Number of entries per supermodule","Number of entries per supermodule"
2813 ,(Int_t)(nbins/18),0,(Int_t)(nbins/18));
2814 nbEntriesPerSp->SetDirectory(0);
2817 if(nentries > 0) nbEntries->Fill(nentries);
2818 nbEntriesPerGroup->Fill(idect+0.5,nentries);
2819 nbEntriesPerSp->Fill((idect%((Int_t)(nbins/18)))+0.5,nentries);
2824 if(nentries > maxentries){
2825 maxentries = nentries;
2829 minentries = nentries;
2831 if(nentries < minentries){
2832 minentries = nentries;
2838 meanstats += nentries;
2840 }//calibration groups loop
2842 if(nbwe > 0) meanstats /= nbwe;
2843 if(counter > 0) meanrelativerror /= counter;
2845 AliInfo(Form("There are %f calibration groups with entries",nbwe));
2846 AliInfo(Form("The minimum number of entries is %f for the group %f",minentries,placemin));
2847 AliInfo(Form("The maximum number of entries is %f for the group %f",maxentries,placemax));
2848 AliInfo(Form("The mean number of entries is %f",meanstats));
2849 if((i%2) == 1) AliInfo(Form("The mean relative error is %f",meanrelativerror));
2852 info[1] = minentries;
2854 info[3] = maxentries;
2856 info[5] = meanstats;
2857 info[6] = meanrelativerror;
2860 gStyle->SetPalette(1);
2861 gStyle->SetOptStat(1111);
2862 gStyle->SetPadBorderMode(0);
2863 gStyle->SetCanvasColor(10);
2864 gStyle->SetPadLeftMargin(0.13);
2865 gStyle->SetPadRightMargin(0.01);
2866 TCanvas *stat = new TCanvas("stat","",50,50,600,800);
2869 nbEntries->Draw("");
2871 nbEntriesPerSp->SetStats(0);
2872 nbEntriesPerSp->Draw("");
2873 TCanvas *stat1 = new TCanvas("stat1","",50,50,600,800);
2875 nbEntriesPerGroup->SetStats(0);
2876 nbEntriesPerGroup->Draw("");
2882 //____________________________________________________________________________
2883 Double_t *AliTRDCalibraFillHisto::GetMeanMedianRMSNumberCH()
2886 // Return a Int_t[4] with:
2887 // 0 Mean number of entries
2888 // 1 median of number of entries
2889 // 2 rms of number of entries
2890 // 3 number of group with entries
2893 Double_t *stat = new Double_t[4];
2896 Int_t nbofgroups = CalculateTotalNumberOfBins(0);
2897 Double_t *weight = new Double_t[nbofgroups];
2898 Int_t *nonul = new Int_t[nbofgroups];
2900 for(Int_t k = 0; k < nbofgroups; k++){
2901 if(fEntriesCH[k] > 0) {
2903 nonul[(Int_t)stat[3]] = fEntriesCH[k];
2906 else weight[k] = 0.0;
2908 stat[0] = TMath::Mean(nbofgroups,fEntriesCH,weight);
2909 stat[1] = TMath::Median(nbofgroups,fEntriesCH,weight);
2910 stat[2] = TMath::RMS((Int_t)stat[3],nonul);
2915 //____________________________________________________________________________
2916 Double_t *AliTRDCalibraFillHisto::GetMeanMedianRMSNumberLinearFitter() const
2919 // Return a Int_t[4] with:
2920 // 0 Mean number of entries
2921 // 1 median of number of entries
2922 // 2 rms of number of entries
2923 // 3 number of group with entries
2926 Double_t *stat = new Double_t[4];
2929 Int_t nbofgroups = 540;
2930 Double_t *weight = new Double_t[nbofgroups];
2931 Int_t *nonul = new Int_t[nbofgroups];
2933 for(Int_t k = 0; k < nbofgroups; k++){
2934 if(fEntriesLinearFitter[k] > 0) {
2936 nonul[(Int_t) stat[3]] = fEntriesLinearFitter[k];
2939 else weight[k] = 0.0;
2941 stat[0] = TMath::Mean(nbofgroups,fEntriesLinearFitter,weight);
2942 stat[1] = TMath::Median(nbofgroups,fEntriesLinearFitter,weight);
2943 stat[2] = TMath::RMS((Int_t)stat[3],nonul);
2948 //////////////////////////////////////////////////////////////////////////////////////
2950 //////////////////////////////////////////////////////////////////////////////////////
2951 //_____________________________________________________________________________
2952 void AliTRDCalibraFillHisto::CreatePRF2d(Int_t nn)
2955 // Create the 2D histos: here we have 2*fNgroupprf bins in tnp of 0.2 amplitude each
2956 // If fNgroupprf is zero then no binning in tnp
2960 name += fCalibraMode->GetNz(2);
2962 name += fCalibraMode->GetNrphi(2);
2966 if(fNgroupprf != 0){
2968 fPRF2d = new TProfile2D("PRF2d",(const Char_t *) name
2969 ,2*fNgroupprf*fNumberBinPRF,-3.0*fNgroupprf,3.0*fNgroupprf,nn,0,nn);
2970 fPRF2d->SetYTitle("Det/pad groups");
2971 fPRF2d->SetXTitle("Position x/W [pad width units]");
2972 fPRF2d->SetZTitle("Q_{i}/Q_{total}");
2973 fPRF2d->SetStats(0);
2976 fPRF2d = new TProfile2D("PRF2d",(const Char_t *) name
2977 ,fNumberBinPRF,-1.5,1.5,nn,0,nn);
2978 fPRF2d->SetYTitle("Det/pad groups");
2979 fPRF2d->SetXTitle("Position x/W [pad width units]");
2980 fPRF2d->SetZTitle("Q_{i}/Q_{total}");
2981 fPRF2d->SetStats(0);
2986 //_____________________________________________________________________________
2987 void AliTRDCalibraFillHisto::CreatePH2d(Int_t nn)
2990 // Create the 2D histos
2994 name += fCalibraMode->GetNz(1);
2996 name += fCalibraMode->GetNrphi(1);
2998 fPH2d = new TProfile2D("PH2d",(const Char_t *) name
2999 ,fTimeMax,-0.5/fSf,(Float_t) (fTimeMax-0.5)/fSf
3001 fPH2d->SetYTitle("Det/pad groups");
3002 fPH2d->SetXTitle("time [#mus]");
3003 fPH2d->SetZTitle("<PH> [a.u.]");
3007 //_____________________________________________________________________________
3008 void AliTRDCalibraFillHisto::CreateCH2d(Int_t nn)
3011 // Create the 2D histos
3015 name += fCalibraMode->GetNz(0);
3017 name += fCalibraMode->GetNrphi(0);
3019 fCH2d = new TH2I("CH2d",(const Char_t *) name
3020 ,fNumberBinCharge,0,300,nn,0,nn);
3021 fCH2d->SetYTitle("Det/pad groups");
3022 fCH2d->SetXTitle("charge deposit [a.u]");
3023 fCH2d->SetZTitle("counts");
3028 //////////////////////////////////////////////////////////////////////////////////
3029 // Set relative scale
3030 /////////////////////////////////////////////////////////////////////////////////
3031 //_____________________________________________________________________________
3032 void AliTRDCalibraFillHisto::SetRelativeScale(Float_t RelativeScale)
3035 // Set the factor that will divide the deposited charge
3036 // to fit in the histo range [0,300]
3039 if (RelativeScale > 0.0) {
3040 fRelativeScale = RelativeScale;
3043 AliInfo("RelativeScale must be strict positif!");
3047 //////////////////////////////////////////////////////////////////////////////////
3048 // Quick way to fill a histo
3049 //////////////////////////////////////////////////////////////////////////////////
3050 //_____________________________________________________________________
3051 void AliTRDCalibraFillHisto::FillCH2d(Int_t x, Float_t y)
3054 // FillCH2d: Marian style
3057 //skip simply the value out of range
3058 if((y>=300.0) || (y<0.0)) return;
3060 //Calcul the y place
3061 Int_t yplace = (Int_t) (fNumberBinCharge*y/300.0)+1;
3062 Int_t place = (fNumberBinCharge+2)*(x+1)+yplace;
3065 fCH2d->GetArray()[place]++;
3069 //////////////////////////////////////////////////////////////////////////////////
3070 // Geometrical functions
3071 ///////////////////////////////////////////////////////////////////////////////////
3072 //_____________________________________________________________________________
3073 Int_t AliTRDCalibraFillHisto::GetLayer(Int_t d) const
3076 // Reconstruct the layer number from the detector number
3079 return ((Int_t) (d % 6));
3083 //_____________________________________________________________________________
3084 Int_t AliTRDCalibraFillHisto::GetStack(Int_t d) const
3087 // Reconstruct the stack number from the detector number
3089 const Int_t kNlayer = 6;
3091 return ((Int_t) (d % 30) / kNlayer);
3095 //_____________________________________________________________________________
3096 Int_t AliTRDCalibraFillHisto::GetSector(Int_t d) const
3099 // Reconstruct the sector number from the detector number
3103 return ((Int_t) (d / fg));
3106 ///////////////////////////////////////////////////////////////////////////////////
3107 // Getter functions for DAQ of the CH2d and the PH2d
3108 //////////////////////////////////////////////////////////////////////////////////
3109 //_____________________________________________________________________
3110 TProfile2D* AliTRDCalibraFillHisto::GetPH2d(Int_t nbtimebin, Float_t samplefrequency)
3113 // return pointer to fPH2d TProfile2D
3114 // create a new TProfile2D if it doesn't exist allready
3120 fTimeMax = nbtimebin;
3121 fSf = samplefrequency;
3127 //_____________________________________________________________________
3128 TH2I* AliTRDCalibraFillHisto::GetCH2d()
3131 // return pointer to fCH2d TH2I
3132 // create a new TH2I if it doesn't exist allready
3141 ////////////////////////////////////////////////////////////////////////////////////////////
3142 // Drift velocity calibration
3143 ///////////////////////////////////////////////////////////////////////////////////////////
3144 //_____________________________________________________________________
3145 TLinearFitter* AliTRDCalibraFillHisto::GetLinearFitter(Int_t detector, Bool_t force)
3148 // return pointer to TLinearFitter Calibration
3149 // if force is true create a new TLinearFitter if it doesn't exist allready
3152 if ((!force) || (fLinearFitterArray.UncheckedAt(detector))){
3153 return (TLinearFitter*)fLinearFitterArray.UncheckedAt(detector);
3156 // if we are forced and TLinearFitter doesn't yet exist create it
3158 // new TLinearFitter
3159 TLinearFitter *linearfitter = new TLinearFitter(2,"pol1");
3160 fLinearFitterArray.AddAt(linearfitter,detector);
3161 return linearfitter;
3164 //____________________________________________________________________________
3165 void AliTRDCalibraFillHisto::AnalyseLinearFitter()
3168 // Analyse array of linear fitter because can not be written
3169 // Store two arrays: one with the param the other one with the error param + number of entries
3172 for(Int_t k = 0; k < 540; k++){
3173 TLinearFitter *linearfitter = GetLinearFitter(k);
3174 if((linearfitter!=0) && (fEntriesLinearFitter[k]>10)){
3175 TVectorD *par = new TVectorD(2);
3176 TVectorD pare = TVectorD(2);
3177 TVectorD *parE = new TVectorD(3);
3178 linearfitter->Eval();
3179 linearfitter->GetParameters(*par);
3180 linearfitter->GetErrors(pare);
3181 Float_t ppointError = TMath::Sqrt(TMath::Abs(linearfitter->GetChisquare())/fEntriesLinearFitter[k]);
3182 (*parE)[0] = pare[0]*ppointError;
3183 (*parE)[1] = pare[1]*ppointError;
3184 (*parE)[2] = (Double_t) fEntriesLinearFitter[k];
3185 ((TObjArray *)fLinearVdriftFit->GetPArray())->AddAt(par,k);
3186 ((TObjArray *)fLinearVdriftFit->GetEArray())->AddAt(parE,k);