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>
54 #include "AliTRDCalibraFillHisto.h"
55 #include "AliTRDCalibraMode.h"
56 #include "AliTRDCalibraVector.h"
57 #include "AliTRDCalibraVdriftLinearFit.h"
58 #include "AliTRDcalibDB.h"
59 #include "AliTRDCommonParam.h"
60 #include "AliTRDmcmTracklet.h"
61 #include "AliTRDpadPlane.h"
62 #include "AliTRDcluster.h"
63 #include "AliTRDtrack.h"
64 #include "AliTRDRawStreamV2.h"
65 #include "AliRawReader.h"
66 #include "AliRawReaderDate.h"
67 #include "AliTRDgeometry.h"
68 #include "./Cal/AliTRDCalROC.h"
69 #include "./Cal/AliTRDCalDet.h"
76 ClassImp(AliTRDCalibraFillHisto)
78 AliTRDCalibraFillHisto* AliTRDCalibraFillHisto::fgInstance = 0;
79 Bool_t AliTRDCalibraFillHisto::fgTerminated = kFALSE;
81 //_____________singleton implementation_________________________________________________
82 AliTRDCalibraFillHisto *AliTRDCalibraFillHisto::Instance()
85 // Singleton implementation
88 if (fgTerminated != kFALSE) {
92 if (fgInstance == 0) {
93 fgInstance = new AliTRDCalibraFillHisto();
100 //______________________________________________________________________________________
101 void AliTRDCalibraFillHisto::Terminate()
104 // Singleton implementation
105 // Deletes the instance of this class
108 fgTerminated = kTRUE;
110 if (fgInstance != 0) {
117 //______________________________________________________________________________________
118 AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
122 ,fMcmTracking(kFALSE)
123 ,fMcmCorrectAngle(kFALSE)
129 ,fLinearFitterOn(kFALSE)
130 ,fLinearFitterDebugOn(kFALSE)
132 ,fThresholdClusterPRF2(15.0)
133 ,fCalibraMode(new AliTRDCalibraMode())
136 ,fDetectorAliTRDtrack(kFALSE)
137 ,fDetectorPreviousTrack(-1)
146 ,fNumberBinCharge(100)
149 ,fListClusters(new TObjArray())
158 ,fGoodTracklet(kTRUE)
161 ,fEntriesLinearFitter(0x0)
166 ,fLinearFitterArray(540)
167 ,fLinearVdriftFit(0x0)
174 // Default constructor
178 // Init some default values
181 fNumberUsedCh[0] = 0;
182 fNumberUsedCh[1] = 0;
183 fNumberUsedPh[0] = 0;
184 fNumberUsedPh[1] = 0;
186 fGeo = new AliTRDgeometry();
190 //______________________________________________________________________________________
191 AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c)
194 ,fMITracking(c.fMITracking)
195 ,fMcmTracking(c.fMcmTracking)
196 ,fMcmCorrectAngle(c.fMcmCorrectAngle)
199 ,fPRF2dOn(c.fPRF2dOn)
200 ,fHisto2d(c.fHisto2d)
201 ,fVector2d(c.fVector2d)
202 ,fLinearFitterOn(c.fLinearFitterOn)
203 ,fLinearFitterDebugOn(c.fLinearFitterDebugOn)
204 ,fRelativeScale(c.fRelativeScale)
205 ,fThresholdClusterPRF2(c.fThresholdClusterPRF2)
208 ,fDebugLevel(c.fDebugLevel)
209 ,fDetectorAliTRDtrack(c.fDetectorAliTRDtrack)
210 ,fDetectorPreviousTrack(c.fDetectorPreviousTrack)
211 ,fMCMPrevious(c.fMCMPrevious)
212 ,fROBPrevious(c.fROBPrevious)
213 ,fNumberClusters(c.fNumberClusters)
214 ,fProcent(c.fProcent)
215 ,fDifference(c.fDifference)
216 ,fNumberTrack(c.fNumberTrack)
217 ,fTimeMax(c.fTimeMax)
219 ,fNumberBinCharge(c.fNumberBinCharge)
220 ,fNumberBinPRF(c.fNumberBinPRF)
221 ,fNgroupprf(c.fNgroupprf)
222 ,fListClusters(new TObjArray())
231 ,fGoodTracklet(c.fGoodTracklet)
232 ,fGoodTrack(c.fGoodTrack)
234 ,fEntriesLinearFitter(0x0)
239 ,fLinearFitterArray(540)
240 ,fLinearVdriftFit(0x0)
249 if(c.fCalibraMode) fCalibraMode = new AliTRDCalibraMode(*c.fCalibraMode);
250 if(c.fCalibraVector) fCalibraVector = new AliTRDCalibraVector(*c.fCalibraVector);
252 fPH2d = new TProfile2D(*c.fPH2d);
253 fPH2d->SetDirectory(0);
256 fPRF2d = new TProfile2D(*c.fPRF2d);
257 fPRF2d->SetDirectory(0);
260 fCH2d = new TH2I(*c.fCH2d);
261 fCH2d->SetDirectory(0);
263 if(c.fLinearVdriftFit){
264 fLinearVdriftFit = new AliTRDCalibraVdriftLinearFit(*c.fLinearVdriftFit);
267 if(c.fCalDetGain) fCalDetGain = new AliTRDCalDet(*c.fCalDetGain);
268 if(c.fCalDetT0) fCalDetT0 = new AliTRDCalDet(*c.fCalDetT0);
269 if(c.fCalROCGain) fCalROCGain = new AliTRDCalROC(*c.fCalROCGain);
270 if(c.fCalROCT0) fCalROCT0 = new AliTRDCalROC(*c.fCalROCT0);
275 fGeo = new AliTRDgeometry();
278 //____________________________________________________________________________________
279 AliTRDCalibraFillHisto::~AliTRDCalibraFillHisto()
282 // AliTRDCalibraFillHisto destructor
286 if ( fDebugStreamer ) delete fDebugStreamer;
288 if ( fCalDetGain ) delete fCalDetGain;
289 if ( fCalDetT0 ) delete fCalDetT0;
290 if ( fCalROCGain ) delete fCalROCGain;
291 if ( fCalROCT0 ) delete fCalROCT0;
299 //_____________________________________________________________________________
300 void AliTRDCalibraFillHisto::Destroy()
313 //_____________________________________________________________________________
314 void AliTRDCalibraFillHisto::ClearHistos()
335 //____________Functions for initialising the AliTRDCalibraFillHisto in the code_________
336 Bool_t AliTRDCalibraFillHisto::Init2Dhistos()
339 // For the offline tracking
340 // This function will be called in the function AliReconstruction::Run()
341 // Init the calibration mode (Nz, Nrphi), the 2D histograms if fHisto2d = kTRUE,
346 //Init the tracklet parameters
347 fPar0 = new Double_t[fTimeMax];
348 fPar1 = new Double_t[fTimeMax];
349 fPar2 = new Double_t[fTimeMax];
350 fPar3 = new Double_t[fTimeMax];
351 fPar4 = new Double_t[fTimeMax];
353 for(Int_t k = 0; k < fTimeMax; k++){
363 //____________Functions for initialising the AliTRDCalibraFillHisto in the code_________
364 Bool_t AliTRDCalibraFillHisto::Init2Dhistostrack()
367 // For the offline tracking
368 // This function will be called in the function AliReconstruction::Run()
369 // Init the calibration mode (Nz, Nrphi), the 2D histograms if fHisto2d = kTRUE,
374 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
376 AliInfo("Could not get calibDB");
379 AliTRDCommonParam *parCom = AliTRDCommonParam::Instance();
381 AliInfo("Could not get CommonParam");
386 fTimeMax = cal->GetNumberOfTimeBins();
387 fSf = parCom->GetSamplingFrequency();
390 //calib object from database used for reconstruction
391 if(fCalDetGain) delete fCalDetGain;
392 fCalDetGain = new AliTRDCalDet(*(cal->GetGainFactorDet()));
393 if(fCalDetT0) delete fCalDetT0;
394 fCalDetT0 = new AliTRDCalDet(*(cal->GetT0Det()));
396 // Calcul Xbins Chambd0, Chamb2
397 Int_t ntotal0 = CalculateTotalNumberOfBins(0);
398 Int_t ntotal1 = CalculateTotalNumberOfBins(1);
399 Int_t ntotal2 = CalculateTotalNumberOfBins(2);
401 // If vector method On initialised all the stuff
403 fCalibraVector = new AliTRDCalibraVector();
404 fCalibraVector->SetNumberBinCharge(fNumberBinCharge);
405 fCalibraVector->SetTimeMax(fTimeMax);
406 if(fNgroupprf != 0) {
407 fCalibraVector->SetNumberBinPRF(2*fNgroupprf*fNumberBinPRF);
408 fCalibraVector->SetPRFRange((Float_t)(3.0*fNgroupprf));
411 fCalibraVector->SetNumberBinPRF(fNumberBinPRF);
412 fCalibraVector->SetPRFRange(1.5);
414 for(Int_t k = 0; k < 3; k++){
415 fCalibraVector->SetDetCha0(k,fCalibraMode->GetDetChamb0(k));
416 fCalibraVector->SetDetCha2(k,fCalibraMode->GetDetChamb2(k));
418 TString namech("Nz");
419 namech += fCalibraMode->GetNz(0);
421 namech += fCalibraMode->GetNrphi(0);
422 fCalibraVector->SetNameCH((const char* ) namech);
423 TString nameph("Nz");
424 nameph += fCalibraMode->GetNz(1);
426 nameph += fCalibraMode->GetNrphi(1);
427 fCalibraVector->SetNamePH((const char* ) nameph);
428 TString nameprf("Nz");
429 nameprf += fCalibraMode->GetNz(2);
431 nameprf += fCalibraMode->GetNrphi(2);
433 nameprf += fNgroupprf;
434 fCalibraVector->SetNamePRF((const char* ) nameprf);
437 // Create the 2D histos corresponding to the pad groupCalibration mode
440 AliInfo(Form("The pad calibration mode for the relative gain calibration: Nz %d, and Nrphi %d"
441 ,fCalibraMode->GetNz(0)
442 ,fCalibraMode->GetNrphi(0)));
444 // Create the 2D histo
449 fAmpTotal = new Float_t[TMath::Max(fCalibraMode->GetDetChamb2(0),fCalibraMode->GetDetChamb0(0))];
450 for (Int_t k = 0; k < TMath::Max(fCalibraMode->GetDetChamb2(0),fCalibraMode->GetDetChamb0(0)); k++) {
454 fEntriesCH = new Int_t[ntotal0];
455 for(Int_t k = 0; k < ntotal0; k++){
462 AliInfo(Form("The pad calibration mode for the drift velocity calibration: Nz %d, and Nrphi %d"
463 ,fCalibraMode->GetNz(1)
464 ,fCalibraMode->GetNrphi(1)));
466 // Create the 2D histo
471 fPHPlace = new Short_t[fTimeMax];
472 for (Int_t k = 0; k < fTimeMax; k++) {
475 fPHValue = new Float_t[fTimeMax];
476 for (Int_t k = 0; k < fTimeMax; k++) {
480 if (fLinearFitterOn) {
481 //fLinearFitterArray.Expand(540);
482 fLinearFitterArray.SetName("ArrayLinearFitters");
483 fEntriesLinearFitter = new Int_t[540];
484 for(Int_t k = 0; k < 540; k++){
485 fEntriesLinearFitter[k] = 0;
487 fLinearVdriftFit = new AliTRDCalibraVdriftLinearFit();
492 AliInfo(Form("The pad calibration mode for the PRF calibration: Nz %d, and Nrphi %d"
493 ,fCalibraMode->GetNz(2)
494 ,fCalibraMode->GetNrphi(2)));
495 // Create the 2D histo
497 CreatePRF2d(ntotal2);
505 //____________Functions for filling the histos in the code_____________________
507 //____________Offine tracking in the AliTRDtracker_____________________________
508 Bool_t AliTRDCalibraFillHisto::ResetTrack()
511 // For the offline tracking
512 // This function will be called in the function
513 // AliTRDtracker::FollowBackPropagation() at the beginning
514 // Reset the parameter to know we have a new TRD track
517 fDetectorAliTRDtrack = kFALSE;
518 //fGoodTrack = kTRUE;
522 //____________Offine tracking in the AliTRDtracker_____________________________
523 void AliTRDCalibraFillHisto::ResetfVariables()
526 // Reset values per tracklet
529 // Reset the list of clusters
530 fListClusters->Clear();
532 //Reset the tracklet parameters
533 for(Int_t k = 0; k < fTimeMax; k++){
541 ResetfVariablestrack();
544 //____________Offine tracking in the AliTRDtracker_____________________________
545 void AliTRDCalibraFillHisto::ResetfVariablestrack()
548 // Reset values per tracklet
551 //Reset good tracklet
552 fGoodTracklet = kTRUE;
554 // Reset the fPHValue
556 //Reset the fPHValue and fPHPlace
557 for (Int_t k = 0; k < fTimeMax; k++) {
563 // Reset the fAmpTotal where we put value
565 for (Int_t k = 0; k < fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0); k++) {
570 //____________Offline tracking in the AliTRDtracker____________________________
571 Bool_t AliTRDCalibraFillHisto::UpdateHistograms(AliTRDtrack *t)
574 // For the offline tracking
575 // This function will be called in the function
576 // AliTRDtracker::FollowBackPropagation() in the loop over the clusters
578 // Fill the 2D histos or the vectors with the info of the clusters at
579 // the end of a detectors if the track is "good"
584 AliTRDcluster *cl = 0x0;
588 // reset if good track
592 // loop over the clusters
593 while((cl = t->GetCluster(index1))){
595 // Localisation of the detector
596 Int_t detector = cl->GetDetector();
599 // Fill the infos for the previous clusters if not the same
600 // detector anymore but this time it should be the same track
601 if ((detector != fDetectorPreviousTrack) &&
602 (index0 != index1)) {
606 //printf("detector %d, fPreviousdetector %d, plane %d, planeprevious %d, index0 %d, index1 %d la\n",detector,fDetectorPreviousTrack,GetPlane(detector),GetPlane(fDetectorPreviousTrack),index0,index1);
608 //If the same track, then look if the previous detector is in
609 //the same plane, if yes: not a good track
611 //if (fDetectorAliTRDtrack &&
612 // (GetPlane(detector) <= GetPlane(fDetectorPreviousTrack))) {
614 if ((GetPlane(detector) >= GetPlane(fDetectorPreviousTrack))) {
618 // Fill only if the track doesn't touch a masked pad or doesn't
619 // appear in the middle (fGoodTrack)
620 if (fGoodTrack && fGoodTracklet) {
622 // drift velocity unables to cut bad tracklets
623 Bool_t pass = FindP1TrackPHtrack(t,index0,index1);
627 FillTheInfoOfTheTrackCH();
632 FillTheInfoOfTheTrackPH();
635 if(pass && fPRF2dOn) HandlePRFtrack(t,index0,index1);
641 ResetfVariablestrack();
644 } // Fill at the end the charge
646 // Calcul the position of the detector and take the calib objects
647 if (detector != fDetectorPreviousTrack) {
649 //Localise the detector
650 LocalisationDetectorXbins(detector);
653 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
655 AliInfo("Could not get calibDB");
660 if( fCalROCGain ) delete fCalROCGain;
661 fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
662 if( fCalROCT0 ) delete fCalROCT0;
663 fCalROCT0 = new AliTRDCalROC(*(cal->GetT0ROC(detector)));
667 // Reset the detectbjobsor
668 fDetectorPreviousTrack = detector;
670 // Store the info bis of the tracklet
671 Int_t *rowcol = CalculateRowCol(cl);
672 CheckGoodTracklet(detector,rowcol);
673 Int_t group[2] = {0,0};
674 if(fCH2dOn) group[0] = CalculateCalibrationGroup(0,rowcol);
675 if(fPH2dOn) group[1] = CalculateCalibrationGroup(1,rowcol);
676 StoreInfoCHPHtrack(cl,t,index1,group,rowcol);
680 } // while on clusters
682 // Fill the last plane
683 if( index0 != index1 ){
685 //printf("fPreviousdetector %d, planeprevious %d, index0 %d, index1 %d li\n",fDetectorPreviousTrack,GetPlane(fDetectorPreviousTrack),index0,index1);
689 if (fGoodTrack && fGoodTracklet) {
691 // drift velocity unables to cut bad tracklets
692 Bool_t pass = FindP1TrackPHtrack(t,index0,index1);
696 FillTheInfoOfTheTrackCH();
701 FillTheInfoOfTheTrackPH();
704 if(pass && fPRF2dOn) HandlePRFtrack(t,index0,index1);
711 ResetfVariablestrack();
716 //____________Offline tracking in the AliTRDtracker____________________________
717 Bool_t AliTRDCalibraFillHisto::UpdateHistograms(AliTRDcluster *cl, AliTRDtrack *t)
720 // For the offline tracking
721 // This function will be called in the function
722 // AliTRDtracker::FollowBackPropagation() in the loop over the clusters
724 // Fill the 2D histos or the vectors with the info of the clusters at
725 // the end of a detectors if the track is "good"
728 // Localisation of the detector
729 Int_t detector = cl->GetDetector();
731 // Fill the infos for the previous clusters if not the same
732 // detector anymore or if not the same track
733 if (((detector != fDetectorPreviousTrack) || (!fDetectorAliTRDtrack)) &&
734 (fDetectorPreviousTrack != -1)) {
738 // If the same track, then look if the previous detector is in
739 // the same plane, if yes: not a good track
741 if (fDetectorAliTRDtrack &&
742 (GetPlane(detector) <= GetPlane(fDetectorPreviousTrack))) {
744 //if (fDetectorAliTRDtrack &&
745 // (GetPlane(detector) >= GetPlane(fDetectorPreviousTrack))) {
749 // Fill only if the track doesn't touch a masked pad or doesn't
750 // appear in the middle (fGoodTrack)
751 if (fGoodTrack && fGoodTracklet) {
753 // drift velocity unables to cut bad tracklets
754 Bool_t pass = FindP1TrackPH();
758 FillTheInfoOfTheTrackCH();
763 FillTheInfoOfTheTrackPH();
766 if(pass && fPRF2dOn) HandlePRF();
772 if(!fDetectorAliTRDtrack) fGoodTrack = kTRUE;
774 } // Fill at the end the charge
776 // Calcul the position of the detector and take the calib objects
777 if (detector != fDetectorPreviousTrack) {
778 //Localise the detector
779 LocalisationDetectorXbins(detector);
782 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
784 AliInfo("Could not get calibDB");
789 if( fCalROCGain ) delete fCalROCGain;
790 fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
791 if( fCalROCT0 ) delete fCalROCT0;
792 fCalROCT0 = new AliTRDCalROC(*(cal->GetT0ROC(detector)));
795 // Reset the detector
796 fDetectorPreviousTrack = detector;
797 fDetectorAliTRDtrack = kTRUE;
799 // Store the infos of the tracklets
800 AliTRDcluster *kcl = new AliTRDcluster(*cl);
801 fListClusters->Add((TObject *)kcl);
802 Int_t time = cl->GetLocalTimeBin();
803 fPar0[time] = t->GetY();
804 fPar1[time] = t->GetZ();
805 fPar2[time] = t->GetSnp();
806 fPar3[time] = t->GetTgl();
807 fPar4[time] = t->GetSigned1Pt();
809 // Store the info bis of the tracklet
810 Int_t *rowcol = CalculateRowCol(cl);
811 CheckGoodTracklet(detector,rowcol);
812 Int_t group[2] = {0,0};
813 if(fCH2dOn) group[0] = CalculateCalibrationGroup(0,rowcol);
814 if(fPH2dOn) group[1] = CalculateCalibrationGroup(1,rowcol);
815 StoreInfoCHPH(cl,t,group,rowcol);
820 //____________Online trackling in AliTRDtrigger________________________________
821 Bool_t AliTRDCalibraFillHisto::UpdateHistogramcm(AliTRDmcmTracklet *trk)
825 // This function will be called in the function AliTRDtrigger::TestTracklet
826 // before applying the pt cut on the tracklets
827 // Fill the infos for the tracklets fTrkTest if the tracklets is "good"
830 // Localisation of the Xbins involved
831 Int_t idect = trk->GetDetector();
832 fDetectorPreviousTrack = idect;
833 LocalisationDetectorXbins(idect);
835 // Get the parameter object
836 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
838 AliInfo("Could not get calibDB");
846 if( fCalROCGain ) delete fCalROCGain;
847 fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(idect)));
848 if( fCalROCT0 ) delete fCalROCT0;
849 fCalROCT0 = new AliTRDCalROC(*(cal->GetT0ROC(idect)));
851 // Row of the tracklet and position in the pad groups
852 Int_t *rowcol = new Int_t[2];
853 rowcol[0] = trk->GetRow();
854 Int_t group[3] = {-1,-1,-1};
856 // Eventuelle correction due to track angle in z direction
857 Float_t correction = 1.0;
858 if (fMcmCorrectAngle) {
859 Float_t z = trk->GetRowz();
860 Float_t r = trk->GetTime0();
861 correction = r / TMath::Sqrt((r*r+z*z));
864 // Boucle sur les clusters
865 // Condition on number of cluster: don't come from the middle of the detector
866 if (trk->GetNclusters() >= fNumberClusters) {
868 for (Int_t icl = 0; icl < trk->GetNclusters(); icl++) {
870 Float_t amp[3] = { 0.0, 0.0, 0.0 };
871 Int_t time = trk->GetClusterTime(icl);
872 rowcol[1] = trk->GetClusterCol(icl);
874 amp[0] = trk->GetClusterADC(icl)[0] * correction;
875 amp[1] = trk->GetClusterADC(icl)[1] * correction;
876 amp[2] = trk->GetClusterADC(icl)[2] * correction;
879 if ((amp[0] < 0.0) ||
885 // Col of cluster and position in the pad groups
887 group[0] = CalculateCalibrationGroup(0,rowcol);
888 fAmpTotal[(Int_t) group[0]] += (Float_t) (amp[0]+amp[1]+amp[2]);
891 group[1] = CalculateCalibrationGroup(1,rowcol);
892 fPHPlace[time] = group[1];
893 fPHValue[time] = (Float_t) (amp[0]+amp[1]+amp[2]);
895 if(fPRF2dOn) group[2] = CalculateCalibrationGroup(2,rowcol);
897 // See if we are not near a masked pad fGoodTracklet
898 CheckGoodTracklet(idect,rowcol);
900 // Fill PRF direct without tnp bins...only for monitoring...
901 if (fPRF2dOn && fGoodTracklet) {
903 if ((amp[0] > fThresholdClusterPRF2) &&
904 (amp[1] > fThresholdClusterPRF2) &&
905 (amp[2] > fThresholdClusterPRF2) &&
906 ((amp[0]*amp[2]/(amp[1]*amp[1])) < 0.06)) {
908 // Security of the denomiateur is 0
909 if ((((Float_t) (((Float_t) amp[1]) * ((Float_t) amp[1])))
910 / ((Float_t) (((Float_t) amp[0]) * ((Float_t) amp[2])))) != 1.0) {
911 Float_t xcenter = 0.5 * (TMath::Log(amp[2] / amp[0]))
912 / (TMath::Log((amp[1]*amp[1]) / (amp[0]*amp[2])));
913 Float_t ycenter = amp[1] / (amp[0] + amp[1] + amp[2]);
915 if (TMath::Abs(xcenter) < 0.5) {
916 Float_t yminus = amp[0] / (amp[0]+amp[1]+amp[2]);
917 Float_t ymax = amp[2] / (amp[0]+amp[1]+amp[2]);
918 // Fill only if it is in the drift region!
919 if (((Float_t) time / fSf) > 0.3) {
921 fPRF2d->Fill(xcenter,(fCalibraMode->GetXbins(2)+group[2]+0.5),ycenter);
922 fPRF2d->Fill(-(xcenter+1.0),(fCalibraMode->GetXbins(2)+group[2]+0.5),yminus);
923 fPRF2d->Fill((1.0-xcenter),(fCalibraMode->GetXbins(2)+group[2]+0.5),ymax);
926 fCalibraVector->UpdateVectorPRF(idect,group[2],xcenter,ycenter);
927 fCalibraVector->UpdateVectorPRF(idect,group[2],-(xcenter+1.0),yminus);
928 fCalibraVector->UpdateVectorPRF(idect,group[2],(1.0-xcenter),ymax);
930 }//in the drift region
932 }//denominateur security
933 }//cluster shape and thresholds
940 if (fCH2dOn) FillTheInfoOfTheTrackCH();
941 if (fPH2dOn) FillTheInfoOfTheTrackPH();
946 } // Condition on number of clusters
951 //_____________________________________________________________________________
952 Int_t *AliTRDCalibraFillHisto::CalculateRowCol(AliTRDcluster *cl) const
955 // Calculate the row and col number of the cluster
959 Int_t *rowcol = new Int_t[2];
963 // Localisation of the detector
964 Int_t detector = cl->GetDetector();
965 Int_t chamber = GetChamber(detector);
966 Int_t plane = GetPlane(detector);
968 // Localisation of the cluster
969 Double_t pos[3] = { 0.0, 0.0, 0.0 };
970 pos[0] = ((AliCluster *)cl)->GetX();
974 // Position of the cluster
975 AliTRDpadPlane *padplane = fGeo->GetPadPlane(plane,chamber);
976 Int_t row = padplane->GetPadRowNumber(pos[2]);
977 //Do not take from here because it was corrected from ExB already....
978 //Double_t offsetz = padplane->GetPadRowOffset(row,pos[2]);
979 //Double_t offsettilt = padplane->GetTiltOffset(offsetz);
980 //Int_t col = padplane->GetPadColNumber(pos[1] + offsettilt,offsetz);
981 //Int_t col = padplane->GetPadColNumber(pos[1]+offsettilt);
982 Int_t col = cl->GetPadCol();
990 //_____________________________________________________________________________
991 void AliTRDCalibraFillHisto::CheckGoodTracklet(Int_t detector, Int_t *rowcol)
994 // See if we are not near a masked pad
997 Int_t row = rowcol[0];
998 Int_t col = rowcol[1];
1000 if (!IsPadOn(detector, col, row)) {
1001 fGoodTracklet = kFALSE;
1005 if (!IsPadOn(detector, col-1, row)) {
1006 fGoodTracklet = kFALSE;
1011 if (!IsPadOn(detector, col+1, row)) {
1012 fGoodTracklet = kFALSE;
1017 //_____________________________________________________________________________
1018 Bool_t AliTRDCalibraFillHisto::IsPadOn(Int_t detector, Int_t col, Int_t row) const
1021 // Look in the choosen database if the pad is On.
1022 // If no the track will be "not good"
1025 // Get the parameter object
1026 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
1028 AliInfo("Could not get calibDB");
1032 if (!cal->IsChamberInstalled(detector) ||
1033 cal->IsChamberMasked(detector) ||
1034 cal->IsPadMasked(detector,col,row)) {
1042 //_____________________________________________________________________________
1043 Int_t AliTRDCalibraFillHisto::CalculateCalibrationGroup(Int_t i, Int_t *rowcol) const
1046 // Calculate the calibration group number for i
1049 // Row of the cluster and position in the pad groups
1051 if (fCalibraMode->GetNnZ(i) != 0) {
1052 posr = (Int_t) rowcol[0] / fCalibraMode->GetNnZ(i);
1056 // Col of the cluster and position in the pad groups
1058 if (fCalibraMode->GetNnRphi(i) != 0) {
1059 posc = (Int_t) rowcol[1] / fCalibraMode->GetNnRphi(i);
1062 return posc*fCalibraMode->GetNfragZ(i)+posr;
1065 //____________________________________________________________________________________
1066 Int_t AliTRDCalibraFillHisto::CalculateTotalNumberOfBins(Int_t i)
1069 // Calculate the total number of calibration groups
1073 fCalibraMode->ModePadCalibration(2,i);
1074 fCalibraMode->ModePadFragmentation(0,2,0,i);
1075 fCalibraMode->SetDetChamb2(i);
1076 ntotal += 6 * 18 * fCalibraMode->GetDetChamb2(i);
1077 fCalibraMode->ModePadCalibration(0,i);
1078 fCalibraMode->ModePadFragmentation(0,0,0,i);
1079 fCalibraMode->SetDetChamb0(i);
1080 ntotal += 6 * 4 * 18 * fCalibraMode->GetDetChamb0(i);
1081 AliInfo(Form("Total number of Xbins: %d for i %d",ntotal,i));
1085 //____________Set the pad calibration variables for the detector_______________
1086 Bool_t AliTRDCalibraFillHisto::LocalisationDetectorXbins(Int_t detector)
1089 // For the detector calcul the first Xbins and set the number of row
1090 // and col pads per calibration groups, the number of calibration
1091 // groups in the detector.
1094 // first Xbins of the detector
1096 fCalibraMode->CalculXBins(detector,0);
1099 fCalibraMode->CalculXBins(detector,1);
1102 fCalibraMode->CalculXBins(detector,2);
1105 // fragmentation of idect
1106 for (Int_t i = 0; i < 3; i++) {
1107 fCalibraMode->ModePadCalibration((Int_t) GetChamber(detector),i);
1108 fCalibraMode->ModePadFragmentation((Int_t) GetPlane(detector)
1109 , (Int_t) GetChamber(detector)
1110 , (Int_t) GetSector(detector),i);
1116 //_____________________________________________________________________________
1117 void AliTRDCalibraFillHisto::StoreInfoCHPH(AliTRDcluster *cl, AliTRDtrack *t, Int_t *group, Int_t *rowcol)
1120 // Store the infos in fAmpTotal, fPHPlace and fPHValue
1123 // Charge in the cluster
1124 Float_t q = TMath::Abs(cl->GetQ());
1125 Int_t time = cl->GetLocalTimeBin();
1127 //Correct for the gain coefficient used in the database for reconstruction
1128 Float_t correctthegain = fCalDetGain->GetValue(fDetectorPreviousTrack)*fCalROCGain->GetValue(rowcol[1],rowcol[0]);
1129 Float_t correcttheT0 = fCalDetT0->GetValue(fDetectorPreviousTrack)+fCalROCT0->GetValue(rowcol[1],rowcol[0]);
1131 // we substract correcttheT0 in AliTRDclusterizerV1::MakeClusters (line 458)
1132 Int_t timec = Arrondi((Double_t)(time+correcttheT0));
1133 if((correcttheT0+0.5)==(int(correcttheT0+0.5))) {
1136 if( timec < 0 ) return;
1139 // Correction due to the track angle
1140 Float_t correction = 1.0;
1141 Float_t normalisation = 6.67;
1142 // we divide with gain in AliTRDclusterizerV1::Transform...
1143 if( correctthegain > 0 ) normalisation /= correctthegain;
1144 if ((q >0) && (t->GetNdedx() > 0)) {
1145 correction = t->GetClusterdQdl((t->GetNdedx() - 1)) / (normalisation);
1148 // Fill the fAmpTotal with the charge
1150 fAmpTotal[(Int_t) group[0]] += correction;
1153 // Fill the fPHPlace and value
1155 fPHPlace[timec] = group[1];
1156 fPHValue[timec] = correction;
1160 //_____________________________________________________________________________
1161 void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(AliTRDcluster *cl, AliTRDtrack *t, Int_t index, Int_t *group, Int_t *rowcol)
1164 // Store the infos in fAmpTotal, fPHPlace and fPHValue
1167 // Charge in the cluster
1168 Float_t q = TMath::Abs(cl->GetQ());
1169 Int_t time = cl->GetLocalTimeBin();
1171 //Correct for the gain coefficient used in the database for reconstruction
1172 Float_t correctthegain = fCalDetGain->GetValue(fDetectorPreviousTrack)*fCalROCGain->GetValue(rowcol[1],rowcol[0]);
1173 Float_t correcttheT0 = fCalDetT0->GetValue(fDetectorPreviousTrack)+fCalROCT0->GetValue(rowcol[1],rowcol[0]);
1175 // we substract correcttheT0 in AliTRDclusterizerV1::MakeClusters (line 458)
1176 Int_t timec = Arrondi((Double_t)(time+correcttheT0));
1177 if((correcttheT0+0.5)==(int(correcttheT0+0.5))) {
1180 if( timec < 0 ) return;
1182 // Correction due to the track angle
1183 Float_t correction = 1.0;
1184 Float_t normalisation = 6.67;
1185 // we divide with gain in AliTRDclusterizerV1::Transform...
1186 if( correctthegain > 0 ) normalisation /= correctthegain;
1188 correction = t->GetClusterdQdl(index) / (normalisation);
1191 // Fill the fAmpTotal with the charge
1193 fAmpTotal[(Int_t) group[0]] += correction;
1196 // Fill the fPHPlace and value
1198 fPHPlace[timec] = group[1];
1199 fPHValue[timec] = correction;
1203 //_____________________________________________________________________
1204 Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliTRDRawStreamV2 *rawStream, Bool_t nocheck)
1207 // Event Processing loop - AliTRDRawStreamV2
1208 // 0 timebin problem
1213 Int_t withInput = 1;
1215 Int_t phvalue[21][36];
1216 for(Int_t k = 0; k < 36; k++){
1217 for(Int_t j = 0; j < 21; j++){
1222 fDetectorPreviousTrack = -1;
1225 Int_t nbtimebin = 0;
1226 Int_t baseline = 10;
1228 // For selecting the signal
1229 Double_t mean[21] = {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
1230 Int_t first[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1231 Int_t select[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1237 while (rawStream->Next()) {
1239 Int_t idetector = rawStream->GetDet(); // current detector
1240 Int_t imcm = rawStream->GetMCM(); // current MCM
1241 Int_t irob = rawStream->GetROB(); // current ROB
1243 if(((fMCMPrevious != imcm) || (fDetectorPreviousTrack != idetector) || (fROBPrevious != irob)) && (fDetectorPreviousTrack != -1)){
1245 // take the mean values and check the first time bin
1246 for(Int_t j = 0; j < 21; j++){
1247 if(TMath::RMS(fTimeMax,phvalue[j]) != 0.0) mean[j] = TMath::Mean(fTimeMax,phvalue[j]);
1249 if(phvalue[j][0] > 200.0) first[j] = 1;
1254 for(Int_t j = 1; j < 20; j++){
1255 if((first[j-1] == 0) && (first[j] ==0) && (first[j+1] == 0) && (mean[j-1] > (baseline+5.0)) && (mean[j] > (baseline+10.0)) && (mean[j+1] > (baseline+5.0)) && (mean[j] >= mean[j-1]) && (mean[j] >= mean[j+1])){
1262 for(Int_t j = 1; j < 20; j++){
1265 for(Int_t k = 0; k < fTimeMax; k++){
1266 if((phvalue[j][k] >= phvalue[j-1][k]) && (phvalue[j][k] >= phvalue[j+1][k])){
1267 UpdateDAQ(fDetectorPreviousTrack,0,0,k,(phvalue[j-1][k]+phvalue[j][k]+phvalue[j+1][k]),fTimeMax);
1270 if((j < 19) && (phvalue[j+1][k] >= phvalue[j][k]) && (phvalue[j+1][k] >= phvalue[j+2][k])){
1271 UpdateDAQ(fDetectorPreviousTrack,0,0,k,(phvalue[j][k]+phvalue[j+1][k]+phvalue[j+2][k]),fTimeMax);
1273 else UpdateDAQ(fDetectorPreviousTrack,0,0,k,(3*baseline),fTimeMax);
1280 for(Int_t k = 0; k < 36; k++){
1281 for(Int_t j = 0; j < 21; j++){
1282 phvalue[j][k] = baseline;
1287 fDetectorPreviousTrack = idetector;
1288 fMCMPrevious = imcm;
1289 fROBPrevious = irob;
1291 nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
1292 if(nbtimebin == 0) return 0;
1293 if((fTimeMax != 0) && (nbtimebin != fTimeMax)) return 0;
1294 fTimeMax = nbtimebin;
1296 //baseline = rawStream->GetCommonAdditive(); // common additive baseline
1298 Int_t iTimeBin = rawStream->GetTimeBin(); // current time bin
1299 Int_t *signal = rawStream->GetSignals(); // current ADC signal
1300 Int_t col = (rawStream->GetCol())%18; // current COL MCM
1302 if((col < 0) || (col >= 21)) return 0;
1303 if((imcm>=16) || (imcm < 0)) return 0;
1305 Int_t fin = TMath::Min(fTimeMax,(iTimeBin+3));
1307 for(Int_t itime = iTimeBin; itime < fin; itime++){
1308 if(signal[n]> (baseline+3)) phvalue[col][itime] = signal[n];
1313 // fill the last one
1314 if(fDetectorPreviousTrack != -1){
1316 // take the mean values and check the first time bin
1317 for(Int_t j = 0; j < 21; j++){
1318 if(TMath::RMS(fTimeMax,phvalue[j]) != 0.0) mean[j] = TMath::Mean(fTimeMax,phvalue[j]);
1320 if(phvalue[j][0] > 200.0) first[j] = 1;
1325 for(Int_t j = 1; j < 20; j++){
1326 if((first[j-1] == 0) && (first[j] ==0) && (first[j+1] == 0) && (mean[j-1] > (baseline+5.0)) && (mean[j] > (baseline+10.0)) && (mean[j+1] > (baseline+5.0)) && (mean[j] >= mean[j-1]) && (mean[j] >= mean[j+1])){
1333 for(Int_t j = 1; j < 20; j++){
1336 for(Int_t k = 0; k < fTimeMax; k++){
1337 if((phvalue[j][k] >= phvalue[j-1][k]) && (phvalue[j][k] >= phvalue[j+1][k])){
1338 UpdateDAQ(fDetectorPreviousTrack,0,0,k,(phvalue[j-1][k]+phvalue[j][k]+phvalue[j+1][k]),fTimeMax);
1341 if((j < 19) && (phvalue[j+1][k] >= phvalue[j][k]) && (phvalue[j+1][k] >= phvalue[j+2][k])){
1342 UpdateDAQ(fDetectorPreviousTrack,0,0,k,(phvalue[j][k]+phvalue[j+1][k]+phvalue[j+2][k]),fTimeMax);
1344 else UpdateDAQ(fDetectorPreviousTrack,0,0,k,(3*baseline),fTimeMax);
1351 for(Int_t k = 0; k < 36; k++){
1352 for(Int_t j = 0; j < 21; j++){
1353 phvalue[j][k] = baseline;
1361 while (rawStream->Next()) {
1363 Int_t idetector = rawStream->GetDet(); // current detector
1364 Int_t imcm = rawStream->GetMCM(); // current MCM
1365 Int_t irob = rawStream->GetROB(); // current ROB
1367 if(((fMCMPrevious != imcm) || (fDetectorPreviousTrack != idetector) || (fROBPrevious != irob)) && (fDetectorPreviousTrack != -1)){
1369 // take the mean values and check the first time bin
1370 for(Int_t j = 0; j < 21; j++){
1371 if(TMath::RMS(fTimeMax,phvalue[j]) != 0.0) mean[j] = TMath::Mean(fTimeMax,phvalue[j]);
1373 if(phvalue[j][0] > 200.0) first[j] = 1;
1378 for(Int_t j = 1; j < 20; j++){
1379 if((first[j-1] == 0) && (first[j] ==0) && (first[j+1] == 0) && (mean[j-1] > (baseline+5.0)) && (mean[j] > (baseline+10.0)) && (mean[j+1] > (baseline+5.0)) && (mean[j] >= mean[j-1]) && (mean[j] >= mean[j+1])){
1386 for(Int_t j = 1; j < 20; j++){
1389 for(Int_t k = 0; k < fTimeMax; k++){
1390 if((phvalue[j][k] >= phvalue[j-1][k]) && (phvalue[j][k] >= phvalue[j+1][k])){
1391 UpdateDAQ(fDetectorPreviousTrack,0,0,k,(phvalue[j-1][k]+phvalue[j][k]+phvalue[j+1][k]),fTimeMax);
1394 if((j < 19) && (phvalue[j+1][k] >= phvalue[j][k]) && (phvalue[j+1][k] >= phvalue[j+2][k])){
1395 UpdateDAQ(fDetectorPreviousTrack,0,0,k,(phvalue[j][k]+phvalue[j+1][k]+phvalue[j+2][k]),fTimeMax);
1397 else UpdateDAQ(fDetectorPreviousTrack,0,0,k,3*baseline,fTimeMax);
1404 for(Int_t k = 0; k < 36; k++){
1405 for(Int_t j = 0; j < 21; j++){
1406 phvalue[j][k] = baseline;
1411 fDetectorPreviousTrack = idetector;
1412 fMCMPrevious = imcm;
1413 fROBPrevious = irob;
1417 //baseline = rawStream->GetCommonAdditive(); // common baseline
1419 nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
1420 Int_t iTimeBin = rawStream->GetTimeBin(); // current time bin
1421 Int_t *signal = rawStream->GetSignals(); // current ADC signal
1422 Int_t col = (rawStream->GetCol())%18; // current COL MCM
1424 Int_t fin = TMath::Min(nbtimebin,(iTimeBin+3));
1427 if((col < 0) || (col >= 21)) return 0;
1428 if((imcm>=16) || (imcm < 0)) return 0;
1430 for(Int_t itime = iTimeBin; itime < fin; itime++){
1431 if(signal[n]>13) phvalue[col][itime] = signal[n];
1436 // fill the last one
1437 if(fDetectorPreviousTrack != -1){
1439 // take the mean values and check the first time bin
1440 for(Int_t j = 0; j < 21; j++){
1441 if(TMath::RMS(fTimeMax,phvalue[j]) != 0.0) mean[j] = TMath::Mean(fTimeMax,phvalue[j]);
1443 if(phvalue[j][0] > 200.0) first[j] = 1;
1448 for(Int_t j = 1; j < 20; j++){
1449 if((first[j-1] == 0) && (first[j] ==0) && (first[j+1] == 0) && (mean[j-1] > (baseline+5.0)) && (mean[j] > (baseline+10.0)) && (mean[j+1] > (baseline+5.0)) && (mean[j] >= mean[j-1]) && (mean[j] >= mean[j+1])){
1456 for(Int_t j = 1; j < 20; j++){
1459 for(Int_t k = 0; k < fTimeMax; k++){
1460 if((phvalue[j][k] >= phvalue[j-1][k]) && (phvalue[j][k] >= phvalue[j+1][k])){
1461 UpdateDAQ(fDetectorPreviousTrack,0,0,k,(phvalue[j-1][k]+phvalue[j][k]+phvalue[j+1][k]),fTimeMax);
1464 if((j < 19) && (phvalue[j+1][k] >= phvalue[j][k]) && (phvalue[j+1][k] >= phvalue[j+2][k])){
1465 UpdateDAQ(fDetectorPreviousTrack,0,0,k,(phvalue[j][k]+phvalue[j+1][k]+phvalue[j+2][k]),fTimeMax);
1467 else UpdateDAQ(fDetectorPreviousTrack,0,0,k,3*baseline,fTimeMax);
1474 for(Int_t k = 0; k < 36; k++){
1475 for(Int_t j = 0; j < 21; j++){
1476 phvalue[j][k] = baseline;
1485 //_____________________________________________________________________
1486 Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliRawReader *rawReader, Bool_t nocheck)
1489 // Event processing loop - AliRawReader
1493 AliTRDRawStreamV2 rawStream(rawReader);
1495 rawReader->Select("TRD");
1497 return ProcessEventDAQ(&rawStream, nocheck);
1499 //_________________________________________________________________________
1500 Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(
1502 eventHeaderStruct *event,
1505 eventHeaderStruct* /*event*/,
1512 // process date event
1515 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
1516 Int_t result=ProcessEventDAQ(rawReader, nocheck);
1520 Fatal("AliTRDCalibraFillHisto", "this class was compiled without DATE");
1525 //____________Online trackling in AliTRDtrigger________________________________
1526 Bool_t AliTRDCalibraFillHisto::UpdateDAQ(Int_t det, Int_t /*row*/, Int_t /*col*/, Int_t timebin, Int_t signal, Int_t nbtimebins)
1530 // Fill a simple average pulse height
1533 // Localisation of the Xbins involved
1534 //LocalisationDetectorXbins(det);
1536 // Row and position in the pad groups
1538 //if (fCalibraMode->GetNnZ(1) != 0) {
1539 // posr = (Int_t) row / fCalibraMode->GetNnZ(1);
1542 // Col of cluster and position in the pad groups
1544 //if (fCalibraMode->GetNnRphi(1) != 0) {
1545 // posc = (Int_t) col / fCalibraMode->GetNnRphi(1);
1548 //fPH2d->Fill((Float_t) timebin/fSf,(fCalibraMode->GetXbins(1)+posc*fCalibraMode->GetNfragZ(1)+posr)+0.5,(Float_t) signal);
1550 ((TProfile2D *)GetPH2d(nbtimebins,fSf))->Fill((Float_t) timebin/fSf,det+0.5,(Float_t) signal);
1555 //____________Write_____________________________________________________
1556 //_____________________________________________________________________
1557 void AliTRDCalibraFillHisto::Write2d(const Char_t *filename, Bool_t append)
1560 // Write infos to file
1564 if ( fDebugStreamer ) {
1565 delete fDebugStreamer;
1566 fDebugStreamer = 0x0;
1569 AliInfo(Form("Numbertrack: %d Numberusedch[0]: %d, Numberusedch[1]: %d Numberusedph[0]: %d, Numberusedph[1]: %d"
1574 ,fNumberUsedPh[1]));
1576 TDirectory *backup = gDirectory;
1582 option = "recreate";
1584 TFile f(filename,option.Data());
1586 TStopwatch stopwatch;
1589 f.WriteTObject(fCalibraVector);
1594 f.WriteTObject(fCH2d);
1599 f.WriteTObject(fPH2d);
1604 f.WriteTObject(fPRF2d);
1607 if(fLinearFitterOn){
1608 AnalyseLinearFitter();
1609 f.WriteTObject(fLinearVdriftFit);
1614 if ( backup ) backup->cd();
1616 AliInfo(Form("Execution time Write2d: R:%.2fs C:%.2fs"
1617 ,stopwatch.RealTime(),stopwatch.CpuTime()));
1619 //___________________________________________probe the histos__________________________________________________
1620 Double_t *AliTRDCalibraFillHisto::StatH(TH2 *h, Int_t i)
1623 // Check the number of stats in h, 0 is TH2I 1 is TProfile2D
1624 // debug mode with 2 for TH2I and 3 for TProfile2D
1625 // It gives a pointer to a Double_t[7] with the info following...
1626 // [0] : number of calibration groups with entries
1627 // [1] : minimal number of entries found
1628 // [2] : calibration group number of the min
1629 // [3] : maximal number of entries found
1630 // [4] : calibration group number of the max
1631 // [5] : mean number of entries found
1632 // [6] : mean relative error
1635 Double_t *info = new Double_t[7];
1637 // Number of Xbins (detectors or groups of pads)
1638 Int_t nbins = h->GetNbinsY(); //number of calibration groups
1639 Int_t nxbins = h->GetNbinsX(); //number of bins per histo
1642 Double_t nbwe = 0; //number of calibration groups with entries
1643 Double_t minentries = 0; //minimal number of entries found
1644 Double_t maxentries = 0; //maximal number of entries found
1645 Double_t placemin = 0; //calibration group number of the min
1646 Double_t placemax = -1; //calibration group number of the max
1647 Double_t meanstats = 0.0; //mean number of entries over the calibration group with at least ome entry
1648 Double_t meanrelativerror = 0.0; //mean relativ error in the TProfile2D
1650 Double_t counter = 0;
1653 TH1F *nbEntries = 0x0;//distribution of the number of entries
1654 TH1F *nbEntriesPerGroup = 0x0;//Number of entries per group
1655 TProfile *nbEntriesPerSp = 0x0;//Number of entries for one supermodule
1657 // Beginning of the loop over the calibration groups
1658 for (Int_t idect = 0; idect < nbins; idect++) {
1660 TH1I *projch = (TH1I *) h->ProjectionX("projch",idect+1,idect+1,(Option_t *)"e");
1661 projch->SetDirectory(0);
1663 // Number of entries for this calibration group
1664 Double_t nentries = 0.0;
1666 for (Int_t k = 0; k < nxbins; k++) {
1667 nentries += h->GetBinContent(h->GetBin(k+1,idect+1));
1671 for (Int_t k = 0; k < nxbins; k++) {
1672 nentries += ((TProfile2D *)h)->GetBinEntries(h->GetBin(k+1,idect+1));
1673 if(h->GetBinContent(h->GetBin(k+1,idect+1)) != 0) {
1674 meanrelativerror += (h->GetBinError(h->GetBin(k+1,idect+1))/(TMath::Abs(h->GetBinContent(h->GetBin(k+1,idect+1)))));
1682 if((!((Bool_t)nbEntries)) && (nentries > 0)){
1683 nbEntries = new TH1F("Number of entries","Number of entries"
1684 ,100,(Int_t)nentries/2,nentries*2);
1685 nbEntries->SetDirectory(0);
1686 nbEntriesPerGroup = new TH1F("Number of entries per group","Number of entries per group"
1688 nbEntriesPerGroup->SetDirectory(0);
1689 nbEntriesPerSp = new TProfile("Number of entries per supermodule","Number of entries per supermodule"
1690 ,(Int_t)(nbins/18),0,(Int_t)(nbins/18));
1691 nbEntriesPerSp->SetDirectory(0);
1694 if(nentries > 0) nbEntries->Fill(nentries);
1695 nbEntriesPerGroup->Fill(idect+0.5,nentries);
1696 nbEntriesPerSp->Fill((idect%((Int_t)(nbins/18)))+0.5,nentries);
1701 if(nentries > maxentries){
1702 maxentries = nentries;
1706 minentries = nentries;
1708 if(nentries < minentries){
1709 minentries = nentries;
1715 meanstats += nentries;
1717 }//calibration groups loop
1719 if(nbwe > 0) meanstats /= nbwe;
1720 if(counter > 0) meanrelativerror /= counter;
1722 AliInfo(Form("There are %f calibration groups with entries",nbwe));
1723 AliInfo(Form("The minimum number of entries is %f for the group %f",minentries,placemin));
1724 AliInfo(Form("The maximum number of entries is %f for the group %f",maxentries,placemax));
1725 AliInfo(Form("The mean number of entries is %f",meanstats));
1726 if((i%2) == 1) AliInfo(Form("The mean relative error is %f",meanrelativerror));
1729 info[1] = minentries;
1731 info[3] = maxentries;
1733 info[5] = meanstats;
1734 info[6] = meanrelativerror;
1737 gStyle->SetPalette(1);
1738 gStyle->SetOptStat(1111);
1739 gStyle->SetPadBorderMode(0);
1740 gStyle->SetCanvasColor(10);
1741 gStyle->SetPadLeftMargin(0.13);
1742 gStyle->SetPadRightMargin(0.01);
1743 TCanvas *stat = new TCanvas("stat","",50,50,600,800);
1746 nbEntries->Draw("");
1748 nbEntriesPerSp->SetStats(0);
1749 nbEntriesPerSp->Draw("");
1750 TCanvas *stat1 = new TCanvas("stat1","",50,50,600,800);
1752 nbEntriesPerGroup->SetStats(0);
1753 nbEntriesPerGroup->Draw("");
1759 //____________________________________________________________________________
1760 Double_t *AliTRDCalibraFillHisto::GetMeanMedianRMSNumberCH()
1763 // Return a Int_t[4] with:
1764 // 0 Mean number of entries
1765 // 1 median of number of entries
1766 // 2 rms of number of entries
1767 // 3 number of group with entries
1770 Double_t *stat = new Double_t[4];
1773 Int_t nbofgroups = CalculateTotalNumberOfBins(0);
1774 Double_t *weight = new Double_t[nbofgroups];
1775 Int_t *nonul = new Int_t[nbofgroups];
1777 for(Int_t k = 0; k < nbofgroups; k++){
1778 if(fEntriesCH[k] > 0) {
1780 nonul[(Int_t)stat[3]] = fEntriesCH[k];
1783 else weight[k] = 0.0;
1785 stat[0] = TMath::Mean(nbofgroups,fEntriesCH,weight);
1786 stat[1] = TMath::Median(nbofgroups,fEntriesCH,weight);
1787 stat[2] = TMath::RMS((Int_t)stat[3],nonul);
1792 //____________________________________________________________________________
1793 Double_t *AliTRDCalibraFillHisto::GetMeanMedianRMSNumberLinearFitter() const
1796 // Return a Int_t[4] with:
1797 // 0 Mean number of entries
1798 // 1 median of number of entries
1799 // 2 rms of number of entries
1800 // 3 number of group with entries
1803 Double_t *stat = new Double_t[4];
1806 Int_t nbofgroups = 540;
1807 Double_t *weight = new Double_t[nbofgroups];
1808 Int_t *nonul = new Int_t[nbofgroups];
1810 for(Int_t k = 0; k < nbofgroups; k++){
1811 if(fEntriesLinearFitter[k] > 0) {
1813 nonul[(Int_t) stat[3]] = fEntriesLinearFitter[k];
1816 else weight[k] = 0.0;
1818 stat[0] = TMath::Mean(nbofgroups,fEntriesLinearFitter,weight);
1819 stat[1] = TMath::Median(nbofgroups,fEntriesLinearFitter,weight);
1820 stat[2] = TMath::RMS((Int_t)stat[3],nonul);
1825 //_____________________________________________________________________________
1826 void AliTRDCalibraFillHisto::SetNumberGroupsPRF(Short_t numberGroupsPRF)
1829 // Should be between 0 and 6
1832 if ((numberGroupsPRF < 0) || (numberGroupsPRF > 6)) {
1833 AliInfo("The number of groups must be between 0 and 6!");
1836 fNgroupprf = numberGroupsPRF;
1840 //_____________________________________________________________________________
1841 void AliTRDCalibraFillHisto::SetRelativeScale(Float_t RelativeScale)
1844 // Set the factor that will divide the deposited charge
1845 // to fit in the histo range [0,300]
1848 if (RelativeScale > 0.0) {
1849 fRelativeScale = RelativeScale;
1852 AliInfo("RelativeScale must be strict positif!");
1857 //_____________________________________________________________________________
1858 void AliTRDCalibraFillHisto::SetNz(Int_t i, Short_t Nz)
1861 // Set the mode of calibration group in the z direction for the parameter i
1866 fCalibraMode->SetNz(i, Nz);
1869 AliInfo("You have to choose between 0 and 4");
1874 //_____________________________________________________________________________
1875 void AliTRDCalibraFillHisto::SetNrphi(Int_t i, Short_t Nrphi)
1878 // Set the mode of calibration group in the rphi direction for the parameter i
1883 fCalibraMode->SetNrphi(i ,Nrphi);
1886 AliInfo("You have to choose between 0 and 6");
1890 //____________Protected Functions______________________________________________
1891 //____________Create the 2D histo to be filled online__________________________
1893 //_____________________________________________________________________________
1894 void AliTRDCalibraFillHisto::CreatePRF2d(Int_t nn)
1897 // Create the 2D histos: here we have 2*fNgroupprf bins in tnp of 0.2 amplitude each
1898 // If fNgroupprf is zero then no binning in tnp
1902 name += fCalibraMode->GetNz(2);
1904 name += fCalibraMode->GetNrphi(2);
1908 if(fNgroupprf != 0){
1910 fPRF2d = new TProfile2D("PRF2d",(const Char_t *) name
1911 ,2*fNgroupprf*fNumberBinPRF,-3.0*fNgroupprf,3.0*fNgroupprf,nn,0,nn);
1912 fPRF2d->SetYTitle("Det/pad groups");
1913 fPRF2d->SetXTitle("Position x/W [pad width units]");
1914 fPRF2d->SetZTitle("Q_{i}/Q_{total}");
1915 fPRF2d->SetStats(0);
1918 fPRF2d = new TProfile2D("PRF2d",(const Char_t *) name
1919 ,fNumberBinPRF,-1.5,1.5,nn,0,nn);
1920 fPRF2d->SetYTitle("Det/pad groups");
1921 fPRF2d->SetXTitle("Position x/W [pad width units]");
1922 fPRF2d->SetZTitle("Q_{i}/Q_{total}");
1923 fPRF2d->SetStats(0);
1928 //_____________________________________________________________________________
1929 void AliTRDCalibraFillHisto::CreatePH2d(Int_t nn)
1932 // Create the 2D histos
1936 name += fCalibraMode->GetNz(1);
1938 name += fCalibraMode->GetNrphi(1);
1940 fPH2d = new TProfile2D("PH2d",(const Char_t *) name
1941 ,fTimeMax,-0.5/fSf,(Float_t) (fTimeMax-0.5)/fSf
1943 fPH2d->SetYTitle("Det/pad groups");
1944 fPH2d->SetXTitle("time [#mus]");
1945 fPH2d->SetZTitle("<PH> [a.u.]");
1949 //_____________________________________________________________________________
1950 void AliTRDCalibraFillHisto::CreateCH2d(Int_t nn)
1953 // Create the 2D histos
1957 name += fCalibraMode->GetNz(0);
1959 name += fCalibraMode->GetNrphi(0);
1961 fCH2d = new TH2I("CH2d",(const Char_t *) name
1962 ,fNumberBinCharge,0,300,nn,0,nn);
1963 fCH2d->SetYTitle("Det/pad groups");
1964 fCH2d->SetXTitle("charge deposit [a.u]");
1965 fCH2d->SetZTitle("counts");
1971 //____________Offine tracking in the AliTRDtracker_____________________________
1972 void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackCH()
1975 // For the offline tracking or mcm tracklets
1976 // This function will be called in the functions UpdateHistogram...
1977 // to fill the info of a track for the relativ gain calibration
1980 Int_t nb = 0; // Nombre de zones traversees
1981 Int_t fd = -1; // Premiere zone non nulle
1982 Float_t totalcharge = 0.0; // Total charge for the supermodule histo
1987 // See if the track goes through different zones
1988 for (Int_t k = 0; k < fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0); k++) {
1989 if (fAmpTotal[k] > 0.0) {
1990 totalcharge += fAmpTotal[k];
2003 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
2005 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/fRelativeScale);
2006 //fCH2d->Fill(fAmpTotal[fd]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+0.5);
2009 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/fRelativeScale);
2013 if ((fAmpTotal[fd] > 0.0) &&
2014 (fAmpTotal[fd+1] > 0.0)) {
2015 // One of the two very big
2016 if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+1]) {
2018 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/fRelativeScale);
2019 //fCH2d->Fill(fAmpTotal[fd]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+0.5);
2022 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/fRelativeScale);
2025 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
2027 if (fAmpTotal[fd+1] > fProcent*fAmpTotal[fd]) {
2029 FillCH2d(fCalibraMode->GetXbins(0)+fd+1,fAmpTotal[fd+1]/fRelativeScale);
2030 //fCH2d->Fill(fAmpTotal[fd+1]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+1.5);
2033 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd+1,fAmpTotal[fd+1]/fRelativeScale);
2036 fEntriesCH[fCalibraMode->GetXbins(0)+fd+1]++;
2039 if (fCalibraMode->GetNfragZ(0) > 1) {
2040 if (fAmpTotal[fd] > 0.0) {
2041 if ((fd+fCalibraMode->GetNfragZ(0)) < (fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0))) {
2042 if (fAmpTotal[fd+fCalibraMode->GetNfragZ(0)] > 0.0) {
2043 // One of the two very big
2044 if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]) {
2046 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/fRelativeScale);
2047 //fCH2d->Fill(fAmpTotal[fd]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+0.5);
2050 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/fRelativeScale);
2053 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
2055 if (fAmpTotal[fd+fCalibraMode->GetNfragZ(0)] > fProcent*fAmpTotal[fd]) {
2057 FillCH2d(fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0),fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/fRelativeScale);
2058 //fCH2d->Fill(fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0)+0.5);
2061 fEntriesCH[fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0)]++;
2063 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd+fCalibraMode->GetNfragZ(0),fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/fRelativeScale);
2074 //____________Offine tracking in the AliTRDtracker_____________________________
2075 void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH()
2078 // For the offline tracking or mcm tracklets
2079 // This function will be called in the functions UpdateHistogram...
2080 // to fill the info of a track for the drift velocity calibration
2083 Int_t nb = 1; // Nombre de zones traversees 1, 2 ou plus de 3
2084 Int_t fd1 = -1; // Premiere zone non nulle
2085 Int_t fd2 = -1; // Deuxieme zone non nulle
2086 Int_t k1 = -1; // Debut de la premiere zone
2087 Int_t k2 = -1; // Debut de la seconde zone
2089 // See if the track goes through different zones
2090 for (Int_t k = 0; k < fTimeMax; k++) {
2091 if (fPHValue[k] > 0.0) {
2096 if (fPHPlace[k] != fd1) {
2102 if (fPHPlace[k] != fd2) {
2114 for (Int_t i = 0; i < fTimeMax; i++) {
2116 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2119 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2124 if ((fd1 == fd2+1) ||
2126 // One of the two fast all the think
2127 if (k2 > (k1+fDifference)) {
2128 //we choose to fill the fd1 with all the values
2130 for (Int_t i = 0; i < fTimeMax; i++) {
2132 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2135 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2139 if ((k2+fDifference) < fTimeMax) {
2140 //we choose to fill the fd2 with all the values
2142 for (Int_t i = 0; i < fTimeMax; i++) {
2144 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2147 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2152 // Two zones voisines sinon rien!
2153 if (fCalibraMode->GetNfragZ(1) > 1) {
2155 if ((fd1+fCalibraMode->GetNfragZ(1)) < (fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1))) {
2156 if (fd2 == (fd1+fCalibraMode->GetNfragZ(1))) {
2157 // One of the two fast all the think
2158 if (k2 > (k1+fDifference)) {
2159 //we choose to fill the fd1 with all the values
2161 for (Int_t i = 0; i < fTimeMax; i++) {
2163 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2166 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2170 if ((k2+fDifference) < fTimeMax) {
2171 //we choose to fill the fd2 with all the values
2173 for (Int_t i = 0; i < fTimeMax; i++) {
2175 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2178 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2184 // Two zones voisines sinon rien!
2186 if ((fd1 - fCalibraMode->GetNfragZ(1)) >= 0) {
2187 if (fd2 == (fd1 - fCalibraMode->GetNfragZ(1))) {
2188 // One of the two fast all the think
2189 if (k2 > (k1 + fDifference)) {
2190 //we choose to fill the fd1 with all the values
2192 for (Int_t i = 0; i < fTimeMax; i++) {
2194 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2197 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2201 if ((k2+fDifference) < fTimeMax) {
2202 //we choose to fill the fd2 with all the values
2204 for (Int_t i = 0; i < fTimeMax; i++) {
2206 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2209 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2220 //____________Offine tracking in the AliTRDtracker_____________________________
2221 Bool_t AliTRDCalibraFillHisto::FindP1TrackPH()
2224 // For the offline tracking
2225 // This function will be called in the functions UpdateHistogram...
2226 // to fill the find the parameter P1 of a track for the drift velocity calibration
2230 //Number of points: if less than 3 return kFALSE
2231 Int_t npoints = fListClusters->GetEntriesFast();
2232 if(npoints <= 2) return kFALSE;
2235 TLinearFitter linearFitterTracklet = TLinearFitter(2,"pol1"); // TLinearFitter per tracklet
2236 Double_t snp = 0.0; // sin angle in the plan yx track
2237 Double_t y = 0.0; // y clusters in the middle of the chamber
2238 Double_t z = 0.0; // z cluster in the middle of the chamber
2239 Double_t dydt = 0.0; // dydt tracklet after straight line fit
2240 Double_t tnp = 0.0; // tan angle in the plan xy track
2241 Double_t tgl = 0.0; // dz/dl and not dz/dx!
2242 Double_t errorpar = 0.0; // error after straight line fit on dy/dt
2243 Double_t pointError = 0.0; // error after straight line fit
2244 Int_t detector = ((AliTRDcluster *) fListClusters->At(0))->GetDetector(); //detector
2245 Int_t snpright = 1; // if we took in the middle snp
2246 Int_t crossrow = 0; // if it crosses a pad row
2247 Double_t tiltingangle = 0; // tiltingangle of the pad
2248 Float_t dzdx = 0; // dz/dx now from dz/dl
2249 Int_t nbli = 0; // number linear fitter points
2250 AliTRDpadPlane *padplane = fGeo->GetPadPlane(GetPlane(detector),GetChamber(detector));
2252 linearFitterTracklet.StoreData(kFALSE);
2253 linearFitterTracklet.ClearPoints();
2255 //if more than one row
2256 Int_t rowp = -1; // if it crosses a pad row
2259 tiltingangle = padplane->GetTiltingAngle();
2260 Float_t tnt = TMath::Tan(tiltingangle/180.*TMath::Pi()); // tan tiltingangle
2263 for(Int_t k = 0; k < npoints; k++){
2265 AliTRDcluster *cl = (AliTRDcluster *) fListClusters->At(k);
2266 Double_t ycluster = cl->GetY();
2267 Int_t time = cl->GetLocalTimeBin();
2268 Double_t timeis = time/fSf;
2269 //See if cross two pad rows
2270 Int_t row = padplane->GetPadRowNumber(cl->GetZ());
2271 if(k==0) rowp = row;
2272 if(row != rowp) crossrow = 1;
2273 //Take in the middle of the chamber
2275 if(time > (Int_t) 10) {
2277 //if(time < (Int_t) 11) {
2283 linearFitterTracklet.AddPoint(&timeis,ycluster,1);
2287 if(((AliTRDcluster *) fListClusters->At(0))->GetLocalTimeBin() < 10) snpright = 0;
2289 //if(((AliTRDcluster *) fListClusters->At(0))->GetLocalTimeBin() >= 11) snpright = 0;
2290 if(nbli <= 2) return kFALSE;
2292 // Do the straight line fit now
2294 linearFitterTracklet.Eval();
2295 linearFitterTracklet.GetParameters(pars);
2296 pointError = TMath::Sqrt(linearFitterTracklet.GetChisquare()/nbli);
2297 errorpar = linearFitterTracklet.GetParError(1)*pointError;
2300 if( TMath::Abs(snp) < 1.){
2301 tnp = snp / (TMath::Sqrt(1-(snp*snp)));
2303 dzdx = tgl*TMath::Sqrt(1+tnp*tnp);
2305 if(fDebugLevel > 0){
2306 if ( !fDebugStreamer ) {
2308 TDirectory *backup = gDirectory;
2309 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
2310 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2313 (* fDebugStreamer) << "VDRIFT0"<<
2314 "npoints="<<npoints<<
2318 (* fDebugStreamer) << "VDRIFT"<<
2319 "snpright="<<snpright<<
2320 "npoints="<<npoints<<
2322 "detector="<<detector<<
2331 "crossrow="<<crossrow<<
2332 "errorpar="<<errorpar<<
2333 "pointError="<<pointError<<
2338 if(npoints < fNumberClusters) return kFALSE;
2339 if(snpright == 0) return kFALSE;
2340 if(pointError >= 0.1) return kFALSE;
2341 if(crossrow == 1) return kFALSE;
2343 if(fLinearFitterOn){
2344 //Add to the linear fitter of the detector
2345 if( TMath::Abs(snp) < 1.){
2346 Double_t x = tnp-dzdx*tnt;
2347 (GetLinearFitter(detector,kTRUE))->AddPoint(&x,dydt);
2348 if(fLinearFitterDebugOn) {
2349 fLinearVdriftFit->Update(detector,x,pars[1]);
2351 fEntriesLinearFitter[detector]++;
2354 //AliInfo("End of FindP1TrackPH with success!")
2358 //____________Offine tracking in the AliTRDtracker_____________________________
2359 Bool_t AliTRDCalibraFillHisto::HandlePRF()
2362 // For the offline tracking
2363 // Fit the tracklet with a line and take the position as reference for the PRF
2367 Int_t npoints = fListClusters->GetEntriesFast(); // number of total points
2368 Int_t nb3pc = 0; // number of three pads clusters used for fit
2369 Int_t detector = ((AliTRDcluster *) fListClusters->At(0))->GetDetector(); // detector
2372 // To see the difference due to the fit
2373 Double_t *padPositions;
2374 padPositions = new Double_t[npoints];
2375 for(Int_t k = 0; k < npoints; k++){
2376 padPositions[k] = 0.0;
2380 //Find the position by a fit
2381 TLinearFitter fitter(2,"pol1");
2382 fitter.StoreData(kFALSE);
2383 fitter.ClearPoints();
2384 for(Int_t k = 0; k < npoints; k++){
2386 AliTRDcluster *cl = (AliTRDcluster *) fListClusters->At(k);
2387 Short_t *signals = cl->GetSignals();
2388 Double_t time = cl->GetLocalTimeBin();
2389 //Calculate x if possible
2390 Float_t xcenter = 0.0;
2391 Bool_t echec = kTRUE;
2392 if((time<=7) || (time>=21)) continue;
2393 // Center 3 balanced: position with the center of the pad
2394 if ((((Float_t) signals[3]) > 0.0) &&
2395 (((Float_t) signals[2]) > 0.0) &&
2396 (((Float_t) signals[4]) > 0.0)) {
2398 // Security if the denomiateur is 0
2399 if ((((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) /
2400 ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))) != 1.0) {
2401 xcenter = 0.5 * (TMath::Log((Float_t) (((Float_t) signals[4]) / ((Float_t) signals[2]))))
2402 / (TMath::Log(((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3])))
2403 / ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))));
2409 if(TMath::Abs(xcenter) > 0.5) echec = kTRUE;
2411 //if no echec: calculate with the position of the pad
2412 // Position of the cluster
2413 Double_t padPosition = xcenter + cl->GetPadCol();
2414 padPositions[k] = padPosition;
2416 fitter.AddPoint(&time, padPosition,1);
2419 //printf("nb3pc %d, npoints %d\n",nb3pc,npoints);
2420 if(nb3pc < 3) return kFALSE;
2423 fitter.GetParameters(line);
2424 Float_t pointError = -1.0;
2425 pointError = TMath::Sqrt(fitter.GetChisquare()/nb3pc);
2429 for(Int_t k = 0; k < npoints; k++){
2431 AliTRDcluster *cl = (AliTRDcluster *) fListClusters->At(k);
2432 Short_t *signals = cl->GetSignals(); // signal
2433 Double_t time = cl->GetLocalTimeBin(); // time bin
2434 Float_t padPosTracklet = line[0]+line[1]*time; // reconstruct position from fit
2435 Float_t padPos = cl->GetPadCol(); // middle pad
2436 Double_t dpad = padPosTracklet - padPos; // reconstruct position relative to middle pad from fit
2437 Float_t ycenter = 0.0; // relative center charge
2438 Float_t ymin = 0.0; // relative left charge
2439 Float_t ymax = 0.0; // relative right charge
2440 Double_t tgl = fPar3[(Int_t)time]; // dz/dl and not dz/dx
2441 Double_t pt = fPar4[(Int_t)time]; // pt
2442 Float_t dzdx = 0.0; // dzdx
2445 //Requiere simply two pads clusters at least
2446 if(((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[2]) > 0.0)) ||
2447 ((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[4]) > 0.0))){
2448 Float_t sum = ((Float_t) signals[2]) + ((Float_t) signals[3]) + ((Float_t) signals[4]);
2449 if(sum > 0.0) ycenter = ((Float_t) signals[3])/ sum;
2450 if(sum > 0.0) ymin = ((Float_t) signals[2])/ sum;
2451 if(sum > 0.0) ymax = ((Float_t) signals[4])/ sum;
2455 Int_t *rowcol = CalculateRowCol(cl); // calcul col and row pad of the cluster
2456 Int_t grouplocal = CalculateCalibrationGroup(2,rowcol); // calcul the corresponding group
2457 Int_t caligroup = fCalibraMode->GetXbins(2)+ grouplocal; // calcul the corresponding group
2458 Double_t snp = fPar2[(Int_t)time]; // sin angle in xy plan
2459 Float_t xcl = cl->GetY(); // y cluster
2460 Float_t qcl = cl->GetQ(); // charge cluster
2461 Int_t plane = GetPlane(detector); // plane
2462 Int_t chamber = GetChamber(detector); // chamber
2463 Double_t xdiff = dpad; // reconstructed position constant
2464 Double_t x = dpad; // reconstructed position moved
2465 Float_t ep = pointError; // error of fit
2466 Float_t signal1 = (Float_t)signals[1]; // signal at the border
2467 Float_t signal3 = (Float_t)signals[3]; // signal
2468 Float_t signal2 = (Float_t)signals[2]; // signal
2469 Float_t signal4 = (Float_t)signals[4]; // signal
2470 Float_t signal5 = (Float_t)signals[5]; // signal at the border
2472 if(TMath::Abs(snp) < 1.0){
2473 tnp = snp / (TMath::Sqrt(1-snp*snp));
2474 dzdx = tgl*TMath::Sqrt(1+tnp*tnp);
2478 if(fDebugLevel > 0){
2479 if ( !fDebugStreamer ) {
2481 TDirectory *backup = gDirectory;
2482 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
2483 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2486 (* fDebugStreamer) << "PRF0"<<
2487 "caligroup="<<caligroup<<
2488 "detector="<<detector<<
2490 "chamber="<<chamber<<
2491 "npoints="<<npoints<<
2500 "padPosition="<<padPositions[k]<<
2501 "padPosTracklet="<<padPosTracklet<<
2503 "ycenter="<<ycenter<<
2508 "signal1="<<signal1<<
2509 "signal2="<<signal2<<
2510 "signal3="<<signal3<<
2511 "signal4="<<signal4<<
2512 "signal5="<<signal5<<
2517 Float_t y = ycenter;
2518 (* fDebugStreamer) << "PRFALL"<<
2519 "caligroup="<<caligroup<<
2520 "detector="<<detector<<
2522 "chamber="<<chamber<<
2523 "npoints="<<npoints<<
2533 "padPosition="<<padPositions[k]<<
2534 "padPosTracklet="<<padPosTracklet<<
2539 "signal1="<<signal1<<
2540 "signal2="<<signal2<<
2541 "signal3="<<signal3<<
2542 "signal4="<<signal4<<
2543 "signal5="<<signal5<<
2549 (* fDebugStreamer) << "PRFALL"<<
2550 "caligroup="<<caligroup<<
2551 "detector="<<detector<<
2553 "chamber="<<chamber<<
2554 "npoints="<<npoints<<
2564 "padPosition="<<padPositions[k]<<
2565 "padPosTracklet="<<padPosTracklet<<
2570 "signal1="<<signal1<<
2571 "signal2="<<signal2<<
2572 "signal3="<<signal3<<
2573 "signal4="<<signal4<<
2574 "signal5="<<signal5<<
2581 (* fDebugStreamer) << "PRFALL"<<
2582 "caligroup="<<caligroup<<
2583 "detector="<<detector<<
2585 "chamber="<<chamber<<
2586 "npoints="<<npoints<<
2596 "padPosition="<<padPositions[k]<<
2597 "padPosTracklet="<<padPosTracklet<<
2602 "signal1="<<signal1<<
2603 "signal2="<<signal2<<
2604 "signal3="<<signal3<<
2605 "signal4="<<signal4<<
2606 "signal5="<<signal5<<
2613 if(npoints < fNumberClusters) continue;
2614 if(nb3pc <= 5) continue;
2615 if((time >= 21) || (time < 7)) continue;
2616 if(TMath::Abs(snp) >= 1.0) continue;
2617 if(qcl < 80) continue;
2619 Bool_t echec = kFALSE;
2620 Double_t shift = 0.0;
2621 //Calculate the shift in x coresponding to this tnp
2622 if(fNgroupprf != 0.0){
2623 shift = -3.0*(fNgroupprf-1)-1.5;
2624 Double_t limithigh = -0.2*(fNgroupprf-1);
2625 if((tnp < (-0.2*fNgroupprf)) || (tnp > (0.2*fNgroupprf))) echec = kTRUE;
2627 while(tnp > limithigh){
2633 if (fHisto2d && !echec) {
2634 if(TMath::Abs(dpad) < 1.5) {
2635 fPRF2d->Fill(shift+dpad,(caligroup+0.5),ycenter);
2636 fPRF2d->Fill(shift-dpad,(caligroup+0.5),ycenter);
2638 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
2639 fPRF2d->Fill(shift-(dpad+1.0),(caligroup+0.5),ymin);
2640 fPRF2d->Fill(shift+(dpad+1.0),(caligroup+0.5),ymin);
2642 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
2643 fPRF2d->Fill(shift+1.0-dpad,(caligroup+0.5),ymax);
2644 fPRF2d->Fill(shift-1.0+dpad,(caligroup+0.5),ymax);
2647 //Not equivalent anymore here!
2648 if (fVector2d && !echec) {
2649 if(TMath::Abs(dpad) < 1.5) {
2650 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+dpad,ycenter);
2651 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-dpad,ycenter);
2653 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
2654 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-(dpad+1.0),ymin);
2655 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+(dpad+1.0),ymin);
2657 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
2658 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+1.0-dpad,ymax);
2659 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-1.0+dpad,ymax);
2666 //____________Offine tracking in the AliTRDtracker_____________________________
2667 Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrack(AliTRDtrack *t, Int_t index0, Int_t index1)
2670 // For the offline tracking
2671 // This function will be called in the functions UpdateHistogram...
2672 // to fill the find the parameter P1 of a track for the drift velocity calibration
2676 //Number of points: if less than 3 return kFALSE
2677 Int_t npoints = index1-index0;
2678 if(npoints <= 2) return kFALSE;
2681 TLinearFitter linearFitterTracklet = TLinearFitter(2,"pol1"); // TLinearFitter per tracklet
2682 Double_t snp = 0.0; // sin angle in the plan yx track
2683 Double_t y = 0.0; // y clusters in the middle of the chamber
2684 Double_t z = 0.0; // z cluster in the middle of the chamber
2685 Double_t dydt = 0.0; // dydt tracklet after straight line fit
2686 Double_t tnp = 0.0; // tan angle in the plan xy track
2687 Double_t tgl = 0.0; // dz/dl and not dz/dx!
2688 Double_t errorpar = 0.0; // error after straight line fit on dy/dt
2689 Double_t pointError = 0.0; // error after straight line fit
2690 Int_t detector = ((AliTRDcluster *) t->GetCluster(index0))->GetDetector(); //detector
2691 //Int_t snpright = 1; // if we took in the middle snp
2692 Int_t crossrow = 0; // if it crosses a pad row
2693 Double_t tiltingangle = 0; // tiltingangle of the pad
2694 Float_t dzdx = 0; // dz/dx now from dz/dl
2695 Int_t nbli = 0; // number linear fitter points
2696 AliTRDpadPlane *padplane = fGeo->GetPadPlane(GetPlane(detector),GetChamber(detector));
2698 linearFitterTracklet.StoreData(kFALSE);
2699 linearFitterTracklet.ClearPoints();
2701 //if more than one row
2702 Int_t rowp = -1; // if it crosses a pad row
2705 tiltingangle = padplane->GetTiltingAngle();
2706 Float_t tnt = TMath::Tan(tiltingangle/180.*TMath::Pi()); // tan tiltingangle
2709 for(Int_t k = 0; k < npoints; k++){
2711 AliTRDcluster *cl = (AliTRDcluster *) t->GetCluster(k+index0);
2712 Double_t ycluster = cl->GetY();
2713 Int_t time = cl->GetLocalTimeBin();
2714 Double_t timeis = time/fSf;
2715 //See if cross two pad rows
2716 Int_t row = padplane->GetPadRowNumber(cl->GetZ());
2717 if(k==0) rowp = row;
2718 if(row != rowp) crossrow = 1;
2719 //Take in the middle of the chamber
2721 //if(time > (Int_t) 10) {
2723 if(time < (Int_t) 11) {
2727 linearFitterTracklet.AddPoint(&timeis,ycluster,1);
2731 // take now the snp, tnp and tgl from the track
2732 snp = t->GetSnpPlane(GetPlane(detector));
2733 tgl = t->GetTglPlane(GetPlane(detector));
2736 //if(((AliTRDcluster *) t->GetCluster(index0))->GetLocalTimeBin() < 10) snpright = 0;
2738 //if(((AliTRDcluster *) t->GetCluster(index0))->GetLocalTimeBin() >= 11) snpright = 0;
2739 if(nbli <= 2) return kFALSE;
2741 // Do the straight line fit now
2743 linearFitterTracklet.Eval();
2744 linearFitterTracklet.GetParameters(pars);
2745 pointError = TMath::Sqrt(linearFitterTracklet.GetChisquare()/nbli);
2746 errorpar = linearFitterTracklet.GetParError(1)*pointError;
2749 if( TMath::Abs(snp) < 1.){
2750 tnp = snp / (TMath::Sqrt(1-(snp*snp)));
2752 dzdx = tgl*TMath::Sqrt(1+tnp*tnp);
2754 if(fDebugLevel > 0){
2755 if ( !fDebugStreamer ) {
2757 TDirectory *backup = gDirectory;
2758 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
2759 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2763 (* fDebugStreamer) << "VDRIFT"<<
2764 //"snpright="<<snpright<<
2765 "npoints="<<npoints<<
2767 "detector="<<detector<<
2776 "crossrow="<<crossrow<<
2777 "errorpar="<<errorpar<<
2778 "pointError="<<pointError<<
2783 if(npoints < fNumberClusters) return kFALSE;
2784 //if(snpright == 0) return kFALSE;
2785 if(pointError >= 0.1) return kFALSE;
2786 if(crossrow == 1) return kFALSE;
2788 if(fLinearFitterOn){
2789 //Add to the linear fitter of the detector
2790 if( TMath::Abs(snp) < 1.){
2791 Double_t x = tnp-dzdx*tnt;
2792 (GetLinearFitter(detector,kTRUE))->AddPoint(&x,dydt);
2793 if(fLinearFitterDebugOn) {
2794 fLinearVdriftFit->Update(detector,x,pars[1]);
2796 fEntriesLinearFitter[detector]++;
2799 //AliInfo("End of FindP1TrackPH with success!")
2803 //____________Offine tracking in the AliTRDtracker_____________________________
2804 Bool_t AliTRDCalibraFillHisto::HandlePRFtrack(AliTRDtrack *t, Int_t index0, Int_t index1)
2807 // For the offline tracking
2808 // Fit the tracklet with a line and take the position as reference for the PRF
2812 Int_t npoints = index1-index0; // number of total points
2813 Int_t nb3pc = 0; // number of three pads clusters used for fit
2814 Int_t detector = ((AliTRDcluster *) t->GetCluster(index0))->GetDetector(); // detector
2817 // To see the difference due to the fit
2818 Double_t *padPositions;
2819 padPositions = new Double_t[npoints];
2820 for(Int_t k = 0; k < npoints; k++){
2821 padPositions[k] = 0.0;
2825 //Find the position by a fit
2826 TLinearFitter fitter(2,"pol1");
2827 fitter.StoreData(kFALSE);
2828 fitter.ClearPoints();
2829 for(Int_t k = 0; k < npoints; k++){
2831 AliTRDcluster *cl = (AliTRDcluster *) t->GetCluster(k+index0);
2832 Short_t *signals = cl->GetSignals();
2833 Double_t time = cl->GetLocalTimeBin();
2834 //Calculate x if possible
2835 Float_t xcenter = 0.0;
2836 Bool_t echec = kTRUE;
2837 if((time<=7) || (time>=21)) continue;
2838 // Center 3 balanced: position with the center of the pad
2839 if ((((Float_t) signals[3]) > 0.0) &&
2840 (((Float_t) signals[2]) > 0.0) &&
2841 (((Float_t) signals[4]) > 0.0)) {
2843 // Security if the denomiateur is 0
2844 if ((((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) /
2845 ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))) != 1.0) {
2846 xcenter = 0.5 * (TMath::Log((Float_t) (((Float_t) signals[4]) / ((Float_t) signals[2]))))
2847 / (TMath::Log(((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3])))
2848 / ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))));
2854 if(TMath::Abs(xcenter) > 0.5) echec = kTRUE;
2856 //if no echec: calculate with the position of the pad
2857 // Position of the cluster
2858 Double_t padPosition = xcenter + cl->GetPadCol();
2859 padPositions[k] = padPosition;
2861 fitter.AddPoint(&time, padPosition,1);
2864 //printf("nb3pc %d, npoints %d\n",nb3pc,npoints);
2865 if(nb3pc < 3) return kFALSE;
2868 fitter.GetParameters(line);
2869 Float_t pointError = -1.0;
2870 pointError = TMath::Sqrt(fitter.GetChisquare()/nb3pc);
2872 // Take the tgl and snp with the track t now
2873 Double_t tgl = t->GetTglPlane(GetPlane(detector)); //dz/dl and not dz/dx
2874 Double_t snp = t->GetSnpPlane(GetPlane(detector)); // sin angle in xy plan
2875 Float_t dzdx = 0.0; // dzdx
2877 if(TMath::Abs(snp) < 1.0){
2878 tnp = snp / (TMath::Sqrt(1-snp*snp));
2879 dzdx = tgl*TMath::Sqrt(1+tnp*tnp);
2884 for(Int_t k = 0; k < npoints; k++){
2886 AliTRDcluster *cl = (AliTRDcluster *) t->GetCluster(k+index0);
2887 Short_t *signals = cl->GetSignals(); // signal
2888 Double_t time = cl->GetLocalTimeBin(); // time bin
2889 Float_t padPosTracklet = line[0]+line[1]*time; // reconstruct position from fit
2890 Float_t padPos = cl->GetPadCol(); // middle pad
2891 Double_t dpad = padPosTracklet - padPos; // reconstruct position relative to middle pad from fit
2892 Float_t ycenter = 0.0; // relative center charge
2893 Float_t ymin = 0.0; // relative left charge
2894 Float_t ymax = 0.0; // relative right charge
2898 //Requiere simply two pads clusters at least
2899 if(((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[2]) > 0.0)) ||
2900 ((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[4]) > 0.0))){
2901 Float_t sum = ((Float_t) signals[2]) + ((Float_t) signals[3]) + ((Float_t) signals[4]);
2902 if(sum > 0.0) ycenter = ((Float_t) signals[3])/ sum;
2903 if(sum > 0.0) ymin = ((Float_t) signals[2])/ sum;
2904 if(sum > 0.0) ymax = ((Float_t) signals[4])/ sum;
2908 Int_t *rowcol = CalculateRowCol(cl); // calcul col and row pad of the cluster
2909 Int_t grouplocal = CalculateCalibrationGroup(2,rowcol); // calcul the corresponding group
2910 Int_t caligroup = fCalibraMode->GetXbins(2)+ grouplocal; // calcul the corresponding group
2911 Float_t xcl = cl->GetY(); // y cluster
2912 Float_t qcl = cl->GetQ(); // charge cluster
2913 Int_t plane = GetPlane(detector); // plane
2914 Int_t chamber = GetChamber(detector); // chamber
2915 Double_t xdiff = dpad; // reconstructed position constant
2916 Double_t x = dpad; // reconstructed position moved
2917 Float_t ep = pointError; // error of fit
2918 Float_t signal1 = (Float_t)signals[1]; // signal at the border
2919 Float_t signal3 = (Float_t)signals[3]; // signal
2920 Float_t signal2 = (Float_t)signals[2]; // signal
2921 Float_t signal4 = (Float_t)signals[4]; // signal
2922 Float_t signal5 = (Float_t)signals[5]; // signal at the border
2926 if(fDebugLevel > 0){
2927 if ( !fDebugStreamer ) {
2929 TDirectory *backup = gDirectory;
2930 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
2931 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2934 (* fDebugStreamer) << "PRF0"<<
2935 "caligroup="<<caligroup<<
2936 "detector="<<detector<<
2938 "chamber="<<chamber<<
2939 "npoints="<<npoints<<
2947 "padPosition="<<padPositions[k]<<
2948 "padPosTracklet="<<padPosTracklet<<
2950 "ycenter="<<ycenter<<
2955 "signal1="<<signal1<<
2956 "signal2="<<signal2<<
2957 "signal3="<<signal3<<
2958 "signal4="<<signal4<<
2959 "signal5="<<signal5<<
2964 Float_t y = ycenter;
2965 (* fDebugStreamer) << "PRFALL"<<
2966 "caligroup="<<caligroup<<
2967 "detector="<<detector<<
2969 "chamber="<<chamber<<
2970 "npoints="<<npoints<<
2979 "padPosition="<<padPositions[k]<<
2980 "padPosTracklet="<<padPosTracklet<<
2985 "signal1="<<signal1<<
2986 "signal2="<<signal2<<
2987 "signal3="<<signal3<<
2988 "signal4="<<signal4<<
2989 "signal5="<<signal5<<
2995 (* fDebugStreamer) << "PRFALL"<<
2996 "caligroup="<<caligroup<<
2997 "detector="<<detector<<
2999 "chamber="<<chamber<<
3000 "npoints="<<npoints<<
3009 "padPosition="<<padPositions[k]<<
3010 "padPosTracklet="<<padPosTracklet<<
3015 "signal1="<<signal1<<
3016 "signal2="<<signal2<<
3017 "signal3="<<signal3<<
3018 "signal4="<<signal4<<
3019 "signal5="<<signal5<<
3026 (* fDebugStreamer) << "PRFALL"<<
3027 "caligroup="<<caligroup<<
3028 "detector="<<detector<<
3030 "chamber="<<chamber<<
3031 "npoints="<<npoints<<
3040 "padPosition="<<padPositions[k]<<
3041 "padPosTracklet="<<padPosTracklet<<
3046 "signal1="<<signal1<<
3047 "signal2="<<signal2<<
3048 "signal3="<<signal3<<
3049 "signal4="<<signal4<<
3050 "signal5="<<signal5<<
3057 if(npoints < fNumberClusters) continue;
3058 if(nb3pc <= 5) continue;
3059 if((time >= 21) || (time < 7)) continue;
3060 if(TMath::Abs(snp) >= 1.0) continue;
3061 if(qcl < 80) continue;
3063 Bool_t echec = kFALSE;
3064 Double_t shift = 0.0;
3065 //Calculate the shift in x coresponding to this tnp
3066 if(fNgroupprf != 0.0){
3067 shift = -3.0*(fNgroupprf-1)-1.5;
3068 Double_t limithigh = -0.2*(fNgroupprf-1);
3069 if((tnp < (-0.2*fNgroupprf)) || (tnp > (0.2*fNgroupprf))) echec = kTRUE;
3071 while(tnp > limithigh){
3077 if (fHisto2d && !echec) {
3078 if(TMath::Abs(dpad) < 1.5) {
3079 fPRF2d->Fill(shift+dpad,(caligroup+0.5),ycenter);
3080 fPRF2d->Fill(shift-dpad,(caligroup+0.5),ycenter);
3082 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
3083 fPRF2d->Fill(shift-(dpad+1.0),(caligroup+0.5),ymin);
3084 fPRF2d->Fill(shift+(dpad+1.0),(caligroup+0.5),ymin);
3086 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
3087 fPRF2d->Fill(shift+1.0-dpad,(caligroup+0.5),ymax);
3088 fPRF2d->Fill(shift-1.0+dpad,(caligroup+0.5),ymax);
3091 //Not equivalent anymore here!
3092 if (fVector2d && !echec) {
3093 if(TMath::Abs(dpad) < 1.5) {
3094 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+dpad,ycenter);
3095 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-dpad,ycenter);
3097 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
3098 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-(dpad+1.0),ymin);
3099 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+(dpad+1.0),ymin);
3101 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
3102 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+1.0-dpad,ymax);
3103 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-1.0+dpad,ymax);
3111 //____________Some basic geometry function_____________________________________
3113 //_____________________________________________________________________________
3114 Int_t AliTRDCalibraFillHisto::GetPlane(Int_t d) const
3117 // Reconstruct the plane number from the detector number
3120 return ((Int_t) (d % 6));
3124 //_____________________________________________________________________________
3125 Int_t AliTRDCalibraFillHisto::GetChamber(Int_t d) const
3128 // Reconstruct the chamber number from the detector number
3132 return ((Int_t) (d % 30) / fgkNplan);
3136 //_____________________________________________________________________________
3137 Int_t AliTRDCalibraFillHisto::GetSector(Int_t d) const
3140 // Reconstruct the sector number from the detector number
3144 return ((Int_t) (d / fg));
3147 //_____________________________________________________________________
3148 TProfile2D* AliTRDCalibraFillHisto::GetPH2d(Int_t nbtimebin, Float_t samplefrequency)
3151 // return pointer to fPH2d TProfile2D
3152 // create a new TProfile2D if it doesn't exist allready
3158 fTimeMax = nbtimebin;
3159 fSf = samplefrequency;
3162 AliInfo(Form("The pad calibration mode for the drift velocity calibration: Nz %d, and Nrphi %d"
3163 ,fCalibraMode->GetNz(1)
3164 ,fCalibraMode->GetNrphi(1)));
3166 // Calcul the number of Xbins
3168 fCalibraMode->ModePadCalibration(2,1);
3169 fCalibraMode->ModePadFragmentation(0,2,0,1);
3170 fCalibraMode->SetDetChamb2(1);
3171 ntotal1 += 6 * 18 * fCalibraMode->GetDetChamb2(1);
3172 fCalibraMode->ModePadCalibration(0,1);
3173 fCalibraMode->ModePadFragmentation(0,0,0,1);
3174 fCalibraMode->SetDetChamb0(1);
3175 ntotal1 += 6 * 4 * 18 * fCalibraMode->GetDetChamb0(1);
3176 AliInfo(Form("Total number of Xbins: %d",ntotal1));
3178 CreatePH2d(ntotal1);
3185 //_____________________________________________________________________
3186 TLinearFitter* AliTRDCalibraFillHisto::GetLinearFitter(Int_t detector, Bool_t force)
3189 // return pointer to TLinearFitter Calibration
3190 // if force is true create a new TLinearFitter if it doesn't exist allready
3193 if ((!force) || (fLinearFitterArray.UncheckedAt(detector))){
3194 return (TLinearFitter*)fLinearFitterArray.UncheckedAt(detector);
3197 // if we are forced and TLinearFitter doesn't yet exist create it
3199 // new TLinearFitter
3200 TLinearFitter *linearfitter = new TLinearFitter(2,"pol1");
3201 fLinearFitterArray.AddAt(linearfitter,detector);
3202 return linearfitter;
3205 //_____________________________________________________________________
3206 void AliTRDCalibraFillHisto::FillCH2d(Int_t x, Float_t y)
3209 // FillCH2d: Marian style
3212 //skip simply the value out of range
3213 if((y>=300.0) || (y<0.0)) return;
3215 //Calcul the y place
3216 Int_t yplace = (Int_t) (fNumberBinCharge*y/300.0)+1;
3217 Int_t place = (fNumberBinCharge+2)*(x+1)+yplace;
3220 fCH2d->GetArray()[place]++;
3224 //____________________________________________________________________________
3225 void AliTRDCalibraFillHisto::AnalyseLinearFitter()
3228 // Analyse array of linear fitter because can not be written
3229 // Store two arrays: one with the param the other one with the error param + number of entries
3232 for(Int_t k = 0; k < 540; k++){
3233 TLinearFitter *linearfitter = GetLinearFitter(k);
3234 if((linearfitter!=0) && (fEntriesLinearFitter[k]>10)){
3235 TVectorD *par = new TVectorD(2);
3236 TVectorD pare = TVectorD(2);
3237 TVectorD *parE = new TVectorD(3);
3238 linearfitter->Eval();
3239 linearfitter->GetParameters(*par);
3240 linearfitter->GetErrors(pare);
3241 Float_t ppointError = TMath::Sqrt(TMath::Abs(linearfitter->GetChisquare())/fEntriesLinearFitter[k]);
3242 (*parE)[0] = pare[0]*ppointError;
3243 (*parE)[1] = pare[1]*ppointError;
3244 (*parE)[2] = (Double_t) fEntriesLinearFitter[k];
3245 ((TObjArray *)fLinearVdriftFit->GetPArray())->AddAt(par,k);
3246 ((TObjArray *)fLinearVdriftFit->GetEArray())->AddAt(parE,k);
3250 //________________________________________________________________________________
3251 Int_t AliTRDCalibraFillHisto::Arrondi(Double_t x) const
3253 // Partie entiere of the (x+0.5)
3258 //if (x + 0.5 == Float_t(i) && i & 1) i--;
3261 //if (x - 0.5 == Float_t(i) && i & 1) i++;