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 "AliTRDmcm.h"
62 #include "AliTRDtrigParam.h"
63 #include "AliTRDpadPlane.h"
64 #include "AliTRDcluster.h"
65 #include "AliTRDtrack.h"
66 #include "AliTRDtrackV1.h"
67 #include "AliTRDrawStreamBase.h"
68 #include "AliRawReader.h"
69 #include "AliRawReaderDate.h"
70 #include "AliTRDgeometry.h"
71 #include "./Cal/AliTRDCalROC.h"
72 #include "./Cal/AliTRDCalDet.h"
79 ClassImp(AliTRDCalibraFillHisto)
81 AliTRDCalibraFillHisto* AliTRDCalibraFillHisto::fgInstance = 0;
82 Bool_t AliTRDCalibraFillHisto::fgTerminated = kFALSE;
84 //_____________singleton implementation_________________________________________________
85 AliTRDCalibraFillHisto *AliTRDCalibraFillHisto::Instance()
88 // Singleton implementation
91 if (fgTerminated != kFALSE) {
95 if (fgInstance == 0) {
96 fgInstance = new AliTRDCalibraFillHisto();
103 //______________________________________________________________________________________
104 void AliTRDCalibraFillHisto::Terminate()
107 // Singleton implementation
108 // Deletes the instance of this class
111 fgTerminated = kTRUE;
113 if (fgInstance != 0) {
120 //______________________________________________________________________________________
121 AliTRDCalibraFillHisto::AliTRDCalibraFillHisto()
124 ,fMcmCorrectAngle(kFALSE)
130 ,fLinearFitterOn(kFALSE)
131 ,fLinearFitterDebugOn(kFALSE)
133 ,fThresholdClusterPRF2(15.0)
134 ,fLimitChargeIntegration(kFALSE)
135 ,fCalibraMode(new AliTRDCalibraMode())
138 ,fDetectorPreviousTrack(-1)
142 ,fNumberClustersf(30)
148 ,fNumberBinCharge(100)
154 ,fGoodTracklet(kTRUE)
156 ,fEntriesLinearFitter(0x0)
161 ,fLinearFitterArray(540)
162 ,fLinearVdriftFit(0x0)
167 // Default constructor
171 // Init some default values
174 fNumberUsedCh[0] = 0;
175 fNumberUsedCh[1] = 0;
176 fNumberUsedPh[0] = 0;
177 fNumberUsedPh[1] = 0;
179 fGeo = new AliTRDgeometry();
183 //______________________________________________________________________________________
184 AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c)
187 ,fMcmCorrectAngle(c.fMcmCorrectAngle)
190 ,fPRF2dOn(c.fPRF2dOn)
191 ,fHisto2d(c.fHisto2d)
192 ,fVector2d(c.fVector2d)
193 ,fLinearFitterOn(c.fLinearFitterOn)
194 ,fLinearFitterDebugOn(c.fLinearFitterDebugOn)
195 ,fRelativeScale(c.fRelativeScale)
196 ,fThresholdClusterPRF2(c.fThresholdClusterPRF2)
197 ,fLimitChargeIntegration(c.fLimitChargeIntegration)
200 ,fDebugLevel(c.fDebugLevel)
201 ,fDetectorPreviousTrack(c.fDetectorPreviousTrack)
202 ,fMCMPrevious(c.fMCMPrevious)
203 ,fROBPrevious(c.fROBPrevious)
204 ,fNumberClusters(c.fNumberClusters)
205 ,fNumberClustersf(c.fNumberClustersf)
206 ,fProcent(c.fProcent)
207 ,fDifference(c.fDifference)
208 ,fNumberTrack(c.fNumberTrack)
209 ,fTimeMax(c.fTimeMax)
211 ,fNumberBinCharge(c.fNumberBinCharge)
212 ,fNumberBinPRF(c.fNumberBinPRF)
213 ,fNgroupprf(c.fNgroupprf)
217 ,fGoodTracklet(c.fGoodTracklet)
219 ,fEntriesLinearFitter(0x0)
224 ,fLinearFitterArray(540)
225 ,fLinearVdriftFit(0x0)
232 if(c.fCalibraMode) fCalibraMode = new AliTRDCalibraMode(*c.fCalibraMode);
233 if(c.fCalibraVector) fCalibraVector = new AliTRDCalibraVector(*c.fCalibraVector);
235 fPH2d = new TProfile2D(*c.fPH2d);
236 fPH2d->SetDirectory(0);
239 fPRF2d = new TProfile2D(*c.fPRF2d);
240 fPRF2d->SetDirectory(0);
243 fCH2d = new TH2I(*c.fCH2d);
244 fCH2d->SetDirectory(0);
246 if(c.fLinearVdriftFit){
247 fLinearVdriftFit = new AliTRDCalibraVdriftLinearFit(*c.fLinearVdriftFit);
250 if(c.fCalDetGain) fCalDetGain = new AliTRDCalDet(*c.fCalDetGain);
251 if(c.fCalROCGain) fCalROCGain = new AliTRDCalROC(*c.fCalROCGain);
256 fGeo = new AliTRDgeometry();
259 //____________________________________________________________________________________
260 AliTRDCalibraFillHisto::~AliTRDCalibraFillHisto()
263 // AliTRDCalibraFillHisto destructor
267 if ( fDebugStreamer ) delete fDebugStreamer;
269 if ( fCalDetGain ) delete fCalDetGain;
270 if ( fCalROCGain ) delete fCalROCGain;
277 //_____________________________________________________________________________
278 void AliTRDCalibraFillHisto::Destroy()
289 //_____________________________________________________________________________
290 void AliTRDCalibraFillHisto::DestroyDebugStreamer()
293 // Delete DebugStreamer
296 if ( fDebugStreamer ) delete fDebugStreamer;
299 //_____________________________________________________________________________
300 void AliTRDCalibraFillHisto::ClearHistos()
320 //////////////////////////////////////////////////////////////////////////////////
321 // calibration with AliTRDtrackV1: Init, Update
322 //////////////////////////////////////////////////////////////////////////////////
323 //____________Functions for initialising the AliTRDCalibraFillHisto in the code_________
324 Bool_t AliTRDCalibraFillHisto::Init2Dhistos()
327 // Init the histograms and stuff to be filled
332 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
334 AliInfo("Could not get calibDB");
337 AliTRDCommonParam *parCom = AliTRDCommonParam::Instance();
339 AliInfo("Could not get CommonParam");
344 fTimeMax = cal->GetNumberOfTimeBins();
345 fSf = parCom->GetSamplingFrequency();
347 fNumberClustersf = fTimeMax;
348 fNumberClusters = (Int_t)(0.6*fTimeMax);
350 //calib object from database used for reconstruction
351 if(fCalDetGain) delete fCalDetGain;
352 fCalDetGain = new AliTRDCalDet(*(cal->GetGainFactorDet()));
354 // Calcul Xbins Chambd0, Chamb2
355 Int_t ntotal0 = CalculateTotalNumberOfBins(0);
356 Int_t ntotal1 = CalculateTotalNumberOfBins(1);
357 Int_t ntotal2 = CalculateTotalNumberOfBins(2);
359 // If vector method On initialised all the stuff
361 fCalibraVector = new AliTRDCalibraVector();
362 fCalibraVector->SetNumberBinCharge(fNumberBinCharge);
363 fCalibraVector->SetTimeMax(fTimeMax);
364 if(fNgroupprf != 0) {
365 fCalibraVector->SetNumberBinPRF(2*fNgroupprf*fNumberBinPRF);
366 fCalibraVector->SetPRFRange((Float_t)(3.0*fNgroupprf));
369 fCalibraVector->SetNumberBinPRF(fNumberBinPRF);
370 fCalibraVector->SetPRFRange(1.5);
372 for(Int_t k = 0; k < 3; k++){
373 fCalibraVector->SetDetCha0(k,fCalibraMode->GetDetChamb0(k));
374 fCalibraVector->SetDetCha2(k,fCalibraMode->GetDetChamb2(k));
376 TString namech("Nz");
377 namech += fCalibraMode->GetNz(0);
379 namech += fCalibraMode->GetNrphi(0);
380 fCalibraVector->SetNameCH((const char* ) namech);
381 TString nameph("Nz");
382 nameph += fCalibraMode->GetNz(1);
384 nameph += fCalibraMode->GetNrphi(1);
385 fCalibraVector->SetNamePH((const char* ) nameph);
386 TString nameprf("Nz");
387 nameprf += fCalibraMode->GetNz(2);
389 nameprf += fCalibraMode->GetNrphi(2);
391 nameprf += fNgroupprf;
392 fCalibraVector->SetNamePRF((const char* ) nameprf);
395 // Create the 2D histos corresponding to the pad groupCalibration mode
398 AliInfo(Form("The pad calibration mode for the relative gain calibration: Nz %d, and Nrphi %d"
399 ,fCalibraMode->GetNz(0)
400 ,fCalibraMode->GetNrphi(0)));
402 // Create the 2D histo
407 fAmpTotal = new Float_t[TMath::Max(fCalibraMode->GetDetChamb2(0),fCalibraMode->GetDetChamb0(0))];
408 for (Int_t k = 0; k < TMath::Max(fCalibraMode->GetDetChamb2(0),fCalibraMode->GetDetChamb0(0)); k++) {
412 fEntriesCH = new Int_t[ntotal0];
413 for(Int_t k = 0; k < ntotal0; k++){
420 AliInfo(Form("The pad calibration mode for the drift velocity calibration: Nz %d, and Nrphi %d"
421 ,fCalibraMode->GetNz(1)
422 ,fCalibraMode->GetNrphi(1)));
424 // Create the 2D histo
429 fPHPlace = new Short_t[fTimeMax];
430 for (Int_t k = 0; k < fTimeMax; k++) {
433 fPHValue = new Float_t[fTimeMax];
434 for (Int_t k = 0; k < fTimeMax; k++) {
438 if (fLinearFitterOn) {
439 //fLinearFitterArray.Expand(540);
440 fLinearFitterArray.SetName("ArrayLinearFitters");
441 fEntriesLinearFitter = new Int_t[540];
442 for(Int_t k = 0; k < 540; k++){
443 fEntriesLinearFitter[k] = 0;
445 fLinearVdriftFit = new AliTRDCalibraVdriftLinearFit();
450 AliInfo(Form("The pad calibration mode for the PRF calibration: Nz %d, and Nrphi %d"
451 ,fCalibraMode->GetNz(2)
452 ,fCalibraMode->GetNrphi(2)));
453 // Create the 2D histo
455 CreatePRF2d(ntotal2);
462 //____________Offline tracking in the AliTRDtracker____________________________
463 Bool_t AliTRDCalibraFillHisto::UpdateHistograms(AliTRDtrack *t)
466 // Use AliTRDtrack for the calibration
470 AliTRDcluster *cl = 0x0; // pointeur to cluster
471 Int_t index0 = 0; // index of the first cluster in the current chamber
472 Int_t index1 = 0; // index of the current cluster in the current chamber
474 //////////////////////////////
475 // loop over the clusters
476 ///////////////////////////////
477 while((cl = t->GetCluster(index1))){
479 /////////////////////////////////////////////////////////////////////////
480 // Fill the infos for the previous clusters if not the same detector
481 ////////////////////////////////////////////////////////////////////////
482 Int_t detector = cl->GetDetector();
483 if ((detector != fDetectorPreviousTrack) &&
484 (index0 != index1)) {
488 //If the same track, then look if the previous detector is in
489 //the same plane, if yes: not a good track
490 if ((GetLayer(detector) == GetLayer(fDetectorPreviousTrack))) {
494 // Fill only if the track doesn't touch a masked pad or doesn't
497 // drift velocity unables to cut bad tracklets
498 Bool_t pass = FindP1TrackPHtracklet(t,index0,index1);
502 FillTheInfoOfTheTrackCH(index1-index0);
507 FillTheInfoOfTheTrackPH();
510 if(pass && fPRF2dOn) HandlePRFtracklet(t,index0,index1);
513 } // if a good tracklet
516 ResetfVariablestracklet();
519 } // Fill at the end the charge
522 /////////////////////////////////////////////////////////////
523 // Localise and take the calib gain object for the detector
524 ////////////////////////////////////////////////////////////
525 if (detector != fDetectorPreviousTrack) {
527 //Localise the detector
528 LocalisationDetectorXbins(detector);
531 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
533 AliInfo("Could not get calibDB");
538 if( fCalROCGain ) delete fCalROCGain;
539 fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
543 // Reset the detectbjobsor
544 fDetectorPreviousTrack = detector;
546 ///////////////////////////////////////
547 // Store the info of the cluster
548 ///////////////////////////////////////
549 Int_t row = cl->GetPadRow();
550 Int_t col = cl->GetPadCol();
551 CheckGoodTrackletV1(cl);
552 Int_t group[2] = {0,0};
553 if(fCH2dOn) group[0] = CalculateCalibrationGroup(0,row,col);
554 if(fPH2dOn) group[1] = CalculateCalibrationGroup(1,row,col);
555 StoreInfoCHPHtrack(cl,t->GetClusterdQdl(index1),group,row,col);
559 } // while on clusters
561 ///////////////////////////
562 // Fill the last plane
563 //////////////////////////
564 if( index0 != index1 ){
570 // drift velocity unables to cut bad tracklets
571 Bool_t pass = FindP1TrackPHtracklet(t,index0,index1);
575 FillTheInfoOfTheTrackCH(index1-index0);
580 FillTheInfoOfTheTrackPH();
583 if(pass && fPRF2dOn) HandlePRFtracklet(t,index0,index1);
585 } // if a good tracklet
590 ResetfVariablestracklet();
595 //____________Offline tracking in the AliTRDtracker____________________________
596 Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t)
599 // Use AliTRDtrackV1 for the calibration
603 const AliTRDseedV1 *tracklet = 0x0; // tracklet per plane
604 AliTRDcluster *cl = 0x0; // cluster attached now to the tracklet
605 Bool_t newtr = kTRUE; // new track
608 ///////////////////////////
609 // loop over the tracklet
610 ///////////////////////////
611 for(Int_t itr = 0; itr < 6; itr++){
613 if(!(tracklet = t->GetTracklet(itr))) continue;
614 if(!tracklet->IsOK()) continue;
616 ResetfVariablestracklet();
618 //////////////////////////////////////////
619 // localisation of the tracklet and dqdl
620 //////////////////////////////////////////
621 Int_t layer = tracklet->GetPlane();
623 while(!(cl = tracklet->GetClusters(ic++))) continue;
624 Int_t detector = cl->GetDetector();
625 if (detector != fDetectorPreviousTrack) {
626 // if not a new track
628 // don't use the rest of this track if in the same plane
629 if (layer == GetLayer(fDetectorPreviousTrack)) {
630 //printf("bad tracklet, same layer for detector %d\n",detector);
634 //Localise the detector bin
635 LocalisationDetectorXbins(detector);
637 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
639 AliInfo("Could not get calibDB");
643 if( fCalROCGain ) delete fCalROCGain;
644 fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
646 fDetectorPreviousTrack = detector;
650 ////////////////////////////
651 // loop over the clusters
652 ////////////////////////////
653 Int_t nbclusters = 0;
654 for(int jc=0; jc<AliTRDseed::knTimebins; jc++){
655 if(!(cl = tracklet->GetClusters(jc))) continue;
658 // Store the info bis of the tracklet
659 Int_t row = cl->GetPadRow();
660 Int_t col = cl->GetPadCol();
661 CheckGoodTrackletV1(cl);
662 Int_t group[2] = {0,0};
663 if(fCH2dOn) group[0] = CalculateCalibrationGroup(0,row,col);
664 if(fPH2dOn) group[1] = CalculateCalibrationGroup(1,row,col);
665 StoreInfoCHPHtrack(cl, tracklet->GetdQdl(jc),group,row,col);
668 ////////////////////////////////////////
669 // Fill the stuffs if a good tracklet
670 ////////////////////////////////////////
673 // drift velocity unables to cut bad tracklets
674 Bool_t pass = FindP1TrackPHtrackletV1(tracklet, nbclusters);
678 FillTheInfoOfTheTrackCH(nbclusters);
683 FillTheInfoOfTheTrackPH();
686 if(pass && fPRF2dOn) HandlePRFtrackletV1(tracklet,nbclusters);
688 } // if a good tracklet
694 ///////////////////////////////////////////////////////////////////////////////////
695 // Routine inside the update with AliTRDtrack
696 ///////////////////////////////////////////////////////////////////////////////////
697 //____________Offine tracking in the AliTRDtracker_____________________________
698 Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtracklet(AliTRDtrack *t, Int_t index0, Int_t index1)
701 // Drift velocity calibration:
702 // Fit the clusters with a straight line
703 // From the slope find the drift velocity
706 //Number of points: if less than 3 return kFALSE
707 Int_t npoints = index1-index0;
708 if(npoints <= 2) return kFALSE;
713 Int_t detector = ((AliTRDcluster *) t->GetCluster(index0))->GetDetector(); //detector
714 // parameters of the track
715 Double_t snp = t->GetSnpPlane(GetLayer(detector)); // sin angle in the plan yx track
716 Double_t tgl = t->GetTglPlane(GetLayer(detector)); // dz/dl and not dz/dx!
717 Double_t tnp = 0.0; // tan angle in the plan xy track
718 if( TMath::Abs(snp) < 1.){
719 tnp = snp / (TMath::Sqrt(1-(snp*snp)));
721 Float_t dzdx = tgl*TMath::Sqrt(1+tnp*tnp); // dz/dx now from dz/dl
722 // tilting pad and cross row
723 Int_t crossrow = 0; // if it crosses a pad row
724 Int_t rowp = -1; // if it crosses a pad row
725 AliTRDpadPlane *padplane = fGeo->GetPadPlane(GetLayer(detector),GetStack(detector));
726 Double_t tiltingangle = padplane->GetTiltingAngle(); // tiltingangle of the pad
727 Float_t tnt = TMath::Tan(tiltingangle/180.*TMath::Pi()); // tan tiltingangle
729 TLinearFitter linearFitterTracklet = TLinearFitter(2,"pol1"); // TLinearFitter per tracklet
730 Double_t dydt = 0.0; // dydt tracklet after straight line fit
731 Double_t errorpar = 0.0; // error after straight line fit on dy/dt
732 Double_t pointError = 0.0; // error after straight line fit
733 Int_t nbli = 0; // number linear fitter points
734 linearFitterTracklet.StoreData(kFALSE);
735 linearFitterTracklet.ClearPoints();
737 //////////////////////////////
738 // loop over clusters
739 ////////////////////////////
740 for(Int_t k = 0; k < npoints; k++){
742 AliTRDcluster *cl = (AliTRDcluster *) t->GetCluster(k+index0);
743 if((fLimitChargeIntegration) && (!cl->IsInChamber())) continue;
744 Double_t ycluster = cl->GetY();
745 Int_t time = cl->GetPadTime();
746 Double_t timeis = time/fSf;
747 //Double_t q = cl->GetQ();
748 //See if cross two pad rows
749 Int_t row = cl->GetPadRow();
751 if(row != rowp) crossrow = 1;
753 linearFitterTracklet.AddPoint(&timeis,ycluster,1);
758 //////////////////////////////
760 //////////////////////////////
761 if(nbli <= 2) return kFALSE;
763 linearFitterTracklet.Eval();
764 linearFitterTracklet.GetParameters(pars);
765 pointError = TMath::Sqrt(linearFitterTracklet.GetChisquare()/nbli);
766 errorpar = linearFitterTracklet.GetParError(1)*pointError;
769 /////////////////////////////
771 ////////////////////////////
773 if ( !fDebugStreamer ) {
775 TDirectory *backup = gDirectory;
776 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
777 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
781 (* fDebugStreamer) << "FindP1TrackPHtracklet0"<<
782 //"snpright="<<snpright<<
783 "npoints="<<npoints<<
785 "detector="<<detector<<
792 "crossrow="<<crossrow<<
793 "errorpar="<<errorpar<<
794 "pointError="<<pointError<<
798 Int_t nbclusters = index1-index0;
799 Int_t layer = GetLayer(fDetectorPreviousTrack);
801 (* fDebugStreamer) << "FindP1TrackPHtracklet1"<<
802 //"snpright="<<snpright<<
803 "nbclusters="<<nbclusters<<
804 "detector="<<fDetectorPreviousTrack<<
810 ///////////////////////////
812 ///////////////////////////
813 if(npoints < fNumberClusters) return kFALSE;
814 if(npoints > fNumberClustersf) return kFALSE;
815 if(pointError >= 0.1) return kFALSE;
816 if(crossrow == 1) return kFALSE;
818 ////////////////////////////
820 ////////////////////////////
822 //Add to the linear fitter of the detector
823 if( TMath::Abs(snp) < 1.){
824 Double_t x = tnp-dzdx*tnt;
825 (GetLinearFitter(detector,kTRUE))->AddPoint(&x,dydt);
826 if(fLinearFitterDebugOn) {
827 fLinearVdriftFit->Update(detector,x,pars[1]);
829 fEntriesLinearFitter[detector]++;
835 //____________Offine tracking in the AliTRDtracker_____________________________
836 Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters)
839 // Drift velocity calibration:
840 // Fit the clusters with a straight line
841 // From the slope find the drift velocity
844 ////////////////////////////////////////////////
845 //Number of points: if less than 3 return kFALSE
846 /////////////////////////////////////////////////
847 if(nbclusters <= 2) return kFALSE;
852 TLinearFitter linearFitterTracklet = TLinearFitter(2,"pol1"); // TLinearFitter per tracklet
853 // results of the linear fit
854 Double_t dydt = 0.0; // dydt tracklet after straight line fit
855 Double_t errorpar = 0.0; // error after straight line fit on dy/dt
856 Double_t pointError = 0.0; // error after straight line fit
857 // pad row problemes: avoid tracklet that cross pad rows, tilting angle in the constant
858 Int_t crossrow = 0; // if it crosses a pad row
859 Int_t rowp = -1; // if it crosses a pad row
860 Float_t tnt = tracklet->GetTilt(); // tan tiltingangle
862 linearFitterTracklet.StoreData(kFALSE);
863 linearFitterTracklet.ClearPoints();
865 ///////////////////////////////////////////
866 // Take the parameters of the track
867 //////////////////////////////////////////
868 // take now the snp, tnp and tgl from the track
869 Double_t snp = tracklet->GetSnp(); // sin dy/dx at the end of the chamber
870 Double_t tnp = 0.0; // dy/dx at the end of the chamber
871 if( TMath::Abs(snp) < 1.){
872 tnp = snp / (TMath::Sqrt(1-(snp*snp)));
874 Double_t tgl = tracklet->GetTgl(); // dz/dl
875 Double_t dzdx = tgl*TMath::Sqrt(1+tnp*tnp); // dz/dx calculated from dz/dl
877 //Double_t tnp = tracklet->GetYref(1); // dy/dx at the entrance of the chamber
878 //Double_t tgl = tracklet->GetZref(1); // dz/dl at the entrance of the chamber
879 //Double_t dzdx = tgl; //*TMath::Sqrt(1+tnp*tnp); // dz/dx from dz/dl
880 // at the end with correction due to linear fit
881 //Double_t tnp = tracklet->GetYfit(1); // dy/dx at the end of the chamber after fit correction
882 //Double_t tgl = tracklet->GetZfit(1); // dz/dl at the end of the chamber after fit correction
885 ////////////////////////////
886 // loop over the clusters
887 ////////////////////////////
889 AliTRDcluster *cl = 0x0;
890 for(int ic=0; ic<AliTRDseed::knTimebins; ic++){
891 if(!(cl = tracklet->GetClusters(ic))) continue;
892 if((fLimitChargeIntegration) && (!cl->IsInChamber())) continue;
894 Double_t ycluster = cl->GetY();
895 Int_t time = cl->GetPadTime();
896 Double_t timeis = time/fSf;
897 //See if cross two pad rows
898 Int_t row = cl->GetPadRow();
899 if(rowp==-1) rowp = row;
900 if(row != rowp) crossrow = 1;
902 linearFitterTracklet.AddPoint(&timeis,ycluster,1);
907 ////////////////////////////////////
908 // Do the straight line fit now
909 ///////////////////////////////////
911 linearFitterTracklet.Eval();
912 linearFitterTracklet.GetParameters(pars);
913 pointError = TMath::Sqrt(linearFitterTracklet.GetChisquare()/nbli);
914 errorpar = linearFitterTracklet.GetParError(1)*pointError;
917 ////////////////////////////////
919 ///////////////////////////////
923 if ( !fDebugStreamer ) {
925 TDirectory *backup = gDirectory;
926 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
927 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
931 Int_t layer = GetLayer(fDetectorPreviousTrack);
933 (* fDebugStreamer) << "FindP1TrackPHtrackletV1"<<
934 //"snpright="<<snpright<<
935 "nbclusters="<<nbclusters<<
936 "detector="<<fDetectorPreviousTrack<<
944 "crossrow="<<crossrow<<
945 "errorpar="<<errorpar<<
946 "pointError="<<pointError<<
951 /////////////////////////
953 ////////////////////////
955 if(nbclusters < fNumberClusters) return kFALSE;
956 if(nbclusters > fNumberClustersf) return kFALSE;
957 if(pointError >= 0.1) return kFALSE;
958 if(crossrow == 1) return kFALSE;
960 ///////////////////////
962 //////////////////////
965 //Add to the linear fitter of the detector
966 if( TMath::Abs(snp) < 1.){
967 Double_t x = tnp-dzdx*tnt;
968 (GetLinearFitter(fDetectorPreviousTrack,kTRUE))->AddPoint(&x,dydt);
969 if(fLinearFitterDebugOn) {
970 fLinearVdriftFit->Update(fDetectorPreviousTrack,x,pars[1]);
972 fEntriesLinearFitter[fDetectorPreviousTrack]++;
978 //____________Offine tracking in the AliTRDtracker_____________________________
979 Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, Int_t index1)
982 // PRF width calibration
983 // Assume a Gaussian shape: determinate the position of the three pad clusters
984 // Fit with a straight line
985 // Take the fitted values for all the clusters (3 or 2 pad clusters)
986 // Fill the PRF as function of angle of the track
991 //////////////////////////
993 /////////////////////////
994 Int_t npoints = index1-index0; // number of total points
995 Int_t nb3pc = 0; // number of three pads clusters used for fit
996 Int_t detector = ((AliTRDcluster *) t->GetCluster(index0))->GetDetector(); // detector
997 // To see the difference due to the fit
998 Double_t *padPositions;
999 padPositions = new Double_t[npoints];
1000 for(Int_t k = 0; k < npoints; k++){
1001 padPositions[k] = 0.0;
1003 // Take the tgl and snp with the track t now
1004 Double_t tgl = t->GetTglPlane(GetLayer(detector)); //dz/dl and not dz/dx
1005 Double_t snp = t->GetSnpPlane(GetLayer(detector)); // sin angle in xy plan
1006 Float_t dzdx = 0.0; // dzdx
1008 if(TMath::Abs(snp) < 1.0){
1009 tnp = snp / (TMath::Sqrt(1-snp*snp));
1010 dzdx = tgl*TMath::Sqrt(1+tnp*tnp);
1013 TLinearFitter fitter(2,"pol1");
1014 fitter.StoreData(kFALSE);
1015 fitter.ClearPoints();
1018 ///////////////////////////
1019 // calcul the tnp group
1020 ///////////////////////////
1021 Bool_t echec = kFALSE;
1022 Double_t shift = 0.0;
1023 //Calculate the shift in x coresponding to this tnp
1024 if(fNgroupprf != 0.0){
1025 shift = -3.0*(fNgroupprf-1)-1.5;
1026 Double_t limithigh = -0.2*(fNgroupprf-1);
1027 if((tnp < (-0.2*fNgroupprf)) || (tnp > (0.2*fNgroupprf))) echec = kTRUE;
1029 while(tnp > limithigh){
1035 if(echec) return kFALSE;
1038 //////////////////////
1040 /////////////////////
1041 for(Int_t k = 0; k < npoints; k++){
1043 AliTRDcluster *cl = (AliTRDcluster *) t->GetCluster(k+index0);
1044 Short_t *signals = cl->GetSignals();
1045 Double_t time = cl->GetPadTime();
1046 //Calculate x if possible
1047 Float_t xcenter = 0.0;
1048 Bool_t echec1 = kTRUE;
1049 if((time<=7) || (time>=21)) continue;
1050 // Center 3 balanced: position with the center of the pad
1051 if ((((Float_t) signals[3]) > 0.0) &&
1052 (((Float_t) signals[2]) > 0.0) &&
1053 (((Float_t) signals[4]) > 0.0)) {
1055 // Security if the denomiateur is 0
1056 if ((((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) /
1057 ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))) != 1.0) {
1058 xcenter = 0.5 * (TMath::Log((Float_t) (((Float_t) signals[4]) / ((Float_t) signals[2]))))
1059 / (TMath::Log(((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3])))
1060 / ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))));
1066 if(TMath::Abs(xcenter) > 0.5) echec = kTRUE;
1068 //if no echec: calculate with the position of the pad
1069 // Position of the cluster
1070 Double_t padPosition = xcenter + cl->GetPadCol();
1071 padPositions[k] = padPosition;
1073 fitter.AddPoint(&time, padPosition,1);
1077 /////////////////////////////
1079 ////////////////////////////
1080 if(nb3pc < 3) return kFALSE;
1083 fitter.GetParameters(line);
1084 Float_t pointError = -1.0;
1085 pointError = TMath::Sqrt(fitter.GetChisquare()/nb3pc);
1087 /////////////////////////////////////////////////////
1088 // Now fill the PRF: second loop over clusters
1089 /////////////////////////////////////////////////////
1090 for(Int_t k = 0; k < npoints; k++){
1092 AliTRDcluster *cl = (AliTRDcluster *) t->GetCluster(k+index0);
1093 Short_t *signals = cl->GetSignals(); // signal
1094 Double_t time = cl->GetPadTime(); // time bin
1095 Float_t padPosTracklet = line[0]+line[1]*time; // reconstruct position from fit
1096 Float_t padPos = cl->GetPadCol(); // middle pad
1097 Double_t dpad = padPosTracklet - padPos; // reconstruct position relative to middle pad from fit
1098 Float_t ycenter = 0.0; // relative center charge
1099 Float_t ymin = 0.0; // relative left charge
1100 Float_t ymax = 0.0; // relative right charge
1102 //Requiere simply two pads clusters at least
1103 if(((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[2]) > 0.0)) ||
1104 ((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[4]) > 0.0))){
1105 Float_t sum = ((Float_t) signals[2]) + ((Float_t) signals[3]) + ((Float_t) signals[4]);
1106 if(sum > 0.0) ycenter = ((Float_t) signals[3])/ sum;
1107 if(sum > 0.0) ymin = ((Float_t) signals[2])/ sum;
1108 if(sum > 0.0) ymax = ((Float_t) signals[4])/ sum;
1112 Int_t rowcl = cl->GetPadRow(); // row of cluster
1113 Int_t colcl = cl->GetPadCol(); // col of cluster
1114 Int_t grouplocal = CalculateCalibrationGroup(2,rowcl,colcl); // calcul the corresponding group
1115 Int_t caligroup = fCalibraMode->GetXbins(2)+ grouplocal; // calcul the corresponding group
1116 Float_t xcl = cl->GetY(); // y cluster
1117 Float_t qcl = cl->GetQ(); // charge cluster
1118 Int_t layer = GetLayer(detector); // layer
1119 Int_t stack = GetStack(detector); // stack
1120 Double_t xdiff = dpad; // reconstructed position constant
1121 Double_t x = dpad; // reconstructed position moved
1122 Float_t ep = pointError; // error of fit
1123 Float_t signal1 = (Float_t)signals[1]; // signal at the border
1124 Float_t signal3 = (Float_t)signals[3]; // signal
1125 Float_t signal2 = (Float_t)signals[2]; // signal
1126 Float_t signal4 = (Float_t)signals[4]; // signal
1127 Float_t signal5 = (Float_t)signals[5]; // signal at the border
1129 //////////////////////////////
1131 /////////////////////////////
1132 if(fDebugLevel > 0){
1133 if ( !fDebugStreamer ) {
1135 TDirectory *backup = gDirectory;
1136 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
1137 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
1143 Float_t y = ycenter;
1144 (* fDebugStreamer) << "HandlePRFtracklet"<<
1145 "caligroup="<<caligroup<<
1146 "detector="<<detector<<
1149 "npoints="<<npoints<<
1158 "padPosition="<<padPositions[k]<<
1159 "padPosTracklet="<<padPosTracklet<<
1164 "signal1="<<signal1<<
1165 "signal2="<<signal2<<
1166 "signal3="<<signal3<<
1167 "signal4="<<signal4<<
1168 "signal5="<<signal5<<
1174 (* fDebugStreamer) << "HandlePRFtracklet"<<
1175 "caligroup="<<caligroup<<
1176 "detector="<<detector<<
1179 "npoints="<<npoints<<
1188 "padPosition="<<padPositions[k]<<
1189 "padPosTracklet="<<padPosTracklet<<
1194 "signal1="<<signal1<<
1195 "signal2="<<signal2<<
1196 "signal3="<<signal3<<
1197 "signal4="<<signal4<<
1198 "signal5="<<signal5<<
1204 (* fDebugStreamer) << "HandlePRFtracklet"<<
1205 "caligroup="<<caligroup<<
1206 "detector="<<detector<<
1209 "npoints="<<npoints<<
1218 "padPosition="<<padPositions[k]<<
1219 "padPosTracklet="<<padPosTracklet<<
1224 "signal1="<<signal1<<
1225 "signal2="<<signal2<<
1226 "signal3="<<signal3<<
1227 "signal4="<<signal4<<
1228 "signal5="<<signal5<<
1234 ////////////////////////////
1236 ///////////////////////////
1237 if(npoints < fNumberClusters) continue;
1238 if(npoints > fNumberClustersf) continue;
1239 if(nb3pc <= 5) continue;
1240 if((time >= 21) || (time < 7)) continue;
1241 if(TMath::Abs(snp) >= 1.0) continue;
1242 if(TMath::Abs(qcl) < 80) continue;
1244 ////////////////////////////
1246 ///////////////////////////
1248 if(TMath::Abs(dpad) < 1.5) {
1249 fPRF2d->Fill(shift+dpad,(caligroup+0.5),ycenter);
1250 fPRF2d->Fill(shift-dpad,(caligroup+0.5),ycenter);
1252 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
1253 fPRF2d->Fill(shift-(dpad+1.0),(caligroup+0.5),ymin);
1254 fPRF2d->Fill(shift+(dpad+1.0),(caligroup+0.5),ymin);
1256 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
1257 fPRF2d->Fill(shift+1.0-dpad,(caligroup+0.5),ymax);
1258 fPRF2d->Fill(shift-1.0+dpad,(caligroup+0.5),ymax);
1262 if(TMath::Abs(dpad) < 1.5) {
1263 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+dpad,ycenter);
1264 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-dpad,ycenter);
1266 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
1267 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-(dpad+1.0),ymin);
1268 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+(dpad+1.0),ymin);
1270 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
1271 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+1.0-dpad,ymax);
1272 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-1.0+dpad,ymax);
1279 //____________Offine tracking in the AliTRDtracker_____________________________
1280 Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters)
1283 // PRF width calibration
1284 // Assume a Gaussian shape: determinate the position of the three pad clusters
1285 // Fit with a straight line
1286 // Take the fitted values for all the clusters (3 or 2 pad clusters)
1287 // Fill the PRF as function of angle of the track
1291 //printf("begin\n");
1292 ///////////////////////////////////////////
1293 // Take the parameters of the track
1294 //////////////////////////////////////////
1295 // take now the snp, tnp and tgl from the track
1296 Double_t snp = tracklet->GetSnp(); // sin dy/dx at the end of the chamber
1297 Double_t tnp = 0.0; // dy/dx at the end of the chamber
1298 if( TMath::Abs(snp) < 1.){
1299 tnp = snp / (TMath::Sqrt(1-(snp*snp)));
1301 Double_t tgl = tracklet->GetTgl(); // dz/dl
1302 Double_t dzdx = tgl*TMath::Sqrt(1+tnp*tnp); // dz/dx calculated from dz/dl
1304 //Double_t tnp = tracklet->GetYref(1); // dy/dx at the entrance of the chamber
1305 //Double_t tgl = tracklet->GetZref(1); // dz/dl at the entrance of the chamber
1306 //Double_t dzdx = tgl; //*TMath::Sqrt(1+tnp*tnp); // dz/dx from dz/dl
1307 // at the end with correction due to linear fit
1308 //Double_t tnp = tracklet->GetYfit(1); // dy/dx at the end of the chamber after fit correction
1309 //Double_t tgl = tracklet->GetZfit(1); // dz/dl at the end of the chamber after fit correction
1311 ///////////////////////////////
1312 // Calculate tnp group shift
1313 ///////////////////////////////
1314 Bool_t echec = kFALSE;
1315 Double_t shift = 0.0;
1316 //Calculate the shift in x coresponding to this tnp
1317 if(fNgroupprf != 0.0){
1318 shift = -3.0*(fNgroupprf-1)-1.5;
1319 Double_t limithigh = -0.2*(fNgroupprf-1);
1320 if((tnp < (-0.2*fNgroupprf)) || (tnp > (0.2*fNgroupprf))) echec = kTRUE;
1322 while(tnp > limithigh){
1328 // do nothing if out of tnp range
1329 //printf("echec %d\n",(Int_t)echec);
1330 if(echec) return kFALSE;
1332 ///////////////////////
1334 //////////////////////
1336 Int_t nb3pc = 0; // number of three pads clusters used for fit
1337 Double_t *padPositions; // to see the difference between the fit and the 3 pad clusters position
1338 padPositions = new Double_t[AliTRDseed::knTimebins];
1339 for(Int_t k = 0; k < AliTRDseed::knTimebins; k++){
1340 padPositions[k] = 0.0;
1342 TLinearFitter fitter(2,"pol1"); // TLinearFitter for the linear fit in the drift region
1343 fitter.StoreData(kFALSE);
1344 fitter.ClearPoints();
1346 //printf("loop clusters \n");
1347 ////////////////////////////
1348 // loop over the clusters
1349 ////////////////////////////
1350 AliTRDcluster *cl = 0x0;
1351 for(int ic=0; ic<AliTRDseed::knTimebins; ic++){
1352 if(!(cl = tracklet->GetClusters(ic))) continue;
1354 Double_t time = cl->GetPadTime();
1355 if((time<=7) || (time>=21)) continue;
1356 Short_t *signals = cl->GetSignals();
1357 Float_t xcenter = 0.0;
1358 Bool_t echec1 = kTRUE;
1360 /////////////////////////////////////////////////////////////
1361 // Center 3 balanced: position with the center of the pad
1362 /////////////////////////////////////////////////////////////
1363 if ((((Float_t) signals[3]) > 0.0) &&
1364 (((Float_t) signals[2]) > 0.0) &&
1365 (((Float_t) signals[4]) > 0.0)) {
1367 // Security if the denomiateur is 0
1368 if ((((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) /
1369 ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))) != 1.0) {
1370 xcenter = 0.5 * (TMath::Log((Float_t) (((Float_t) signals[4]) / ((Float_t) signals[2]))))
1371 / (TMath::Log(((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3])))
1372 / ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))));
1378 if(TMath::Abs(xcenter) > 0.5) echec1 = kTRUE;
1379 if(echec1) continue;
1381 ////////////////////////////////////////////////////////
1382 //if no echec1: calculate with the position of the pad
1383 // Position of the cluster
1384 // fill the linear fitter
1385 ///////////////////////////////////////////////////////
1386 Double_t padPosition = xcenter + cl->GetPadCol();
1387 padPositions[ic] = padPosition;
1389 fitter.AddPoint(&time, padPosition,1);
1394 //printf("Fin loop clusters \n");
1395 //////////////////////////////
1396 // fit with a straight line
1397 /////////////////////////////
1398 if(nb3pc < 3) return kFALSE;
1401 fitter.GetParameters(line);
1402 Float_t pointError = -1.0;
1403 if(fitter.GetChisquare()>=0.0) {
1404 pointError = TMath::Sqrt(fitter.GetChisquare()/nb3pc);
1407 //printf("PRF second loop \n");
1408 ////////////////////////////////////////////////
1409 // Fill the PRF: Second loop over clusters
1410 //////////////////////////////////////////////
1411 for(int ic=0; ic<AliTRDseed::knTimebins; ic++){
1412 if(!(cl = tracklet->GetClusters(ic))) continue;
1414 Short_t *signals = cl->GetSignals(); // signal
1415 Double_t time = cl->GetPadTime(); // time bin
1416 Float_t padPosTracklet = line[0]+line[1]*time; // reconstruct position from fit
1417 Float_t padPos = cl->GetPadCol(); // middle pad
1418 Double_t dpad = padPosTracklet - padPos; // reconstruct position relative to middle pad from fit
1419 Float_t ycenter = 0.0; // relative center charge
1420 Float_t ymin = 0.0; // relative left charge
1421 Float_t ymax = 0.0; // relative right charge
1423 ////////////////////////////////////////////////////////////////
1424 // Calculate ycenter, ymin and ymax even for two pad clusters
1425 ////////////////////////////////////////////////////////////////
1426 if(((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[2]) > 0.0)) ||
1427 ((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[4]) > 0.0))){
1428 Float_t sum = ((Float_t) signals[2]) + ((Float_t) signals[3]) + ((Float_t) signals[4]);
1429 if(sum > 0.0) ycenter = ((Float_t) signals[3])/ sum;
1430 if(sum > 0.0) ymin = ((Float_t) signals[2])/ sum;
1431 if(sum > 0.0) ymax = ((Float_t) signals[4])/ sum;
1434 /////////////////////////
1435 // Calibration group
1436 ////////////////////////
1437 Int_t rowcl = cl->GetPadRow(); // row of cluster
1438 Int_t colcl = cl->GetPadCol(); // col of cluster
1439 Int_t grouplocal = CalculateCalibrationGroup(2,rowcl,colcl); // calcul the corresponding group
1440 Int_t caligroup = fCalibraMode->GetXbins(2)+ grouplocal; // calcul the corresponding group
1441 Float_t xcl = cl->GetY(); // y cluster
1442 Float_t qcl = cl->GetQ(); // charge cluster
1443 Int_t layer = GetLayer(fDetectorPreviousTrack); // layer
1444 Int_t stack = GetStack(fDetectorPreviousTrack); // stack
1445 Double_t xdiff = dpad; // reconstructed position constant
1446 Double_t x = dpad; // reconstructed position moved
1447 Float_t ep = pointError; // error of fit
1448 Float_t signal1 = (Float_t)signals[1]; // signal at the border
1449 Float_t signal3 = (Float_t)signals[3]; // signal
1450 Float_t signal2 = (Float_t)signals[2]; // signal
1451 Float_t signal4 = (Float_t)signals[4]; // signal
1452 Float_t signal5 = (Float_t)signals[5]; // signal at the border
1454 /////////////////////
1456 ////////////////////
1458 if(fDebugLevel > 0){
1459 if ( !fDebugStreamer ) {
1461 TDirectory *backup = gDirectory;
1462 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
1463 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
1468 Float_t y = ycenter;
1469 (* fDebugStreamer) << "HandlePRFtrackletV1"<<
1470 "caligroup="<<caligroup<<
1471 "detector="<<fDetectorPreviousTrack<<
1474 "npoints="<<nbclusters<<
1483 "padPosition="<<padPositions[ic]<<
1484 "padPosTracklet="<<padPosTracklet<<
1489 "signal1="<<signal1<<
1490 "signal2="<<signal2<<
1491 "signal3="<<signal3<<
1492 "signal4="<<signal4<<
1493 "signal5="<<signal5<<
1499 (* fDebugStreamer) << "HandlePRFtrackletV1"<<
1500 "caligroup="<<caligroup<<
1501 "detector="<<fDetectorPreviousTrack<<
1504 "npoints="<<nbclusters<<
1513 "padPosition="<<padPositions[ic]<<
1514 "padPosTracklet="<<padPosTracklet<<
1519 "signal1="<<signal1<<
1520 "signal2="<<signal2<<
1521 "signal3="<<signal3<<
1522 "signal4="<<signal4<<
1523 "signal5="<<signal5<<
1529 (* fDebugStreamer) << "HandlePRFtrackletV1"<<
1530 "caligroup="<<caligroup<<
1531 "detector="<<fDetectorPreviousTrack<<
1534 "npoints="<<nbclusters<<
1543 "padPosition="<<padPositions[ic]<<
1544 "padPosTracklet="<<padPosTracklet<<
1549 "signal1="<<signal1<<
1550 "signal2="<<signal2<<
1551 "signal3="<<signal3<<
1552 "signal4="<<signal4<<
1553 "signal5="<<signal5<<
1559 /////////////////////
1561 /////////////////////
1562 if(nbclusters < fNumberClusters) continue;
1563 if(nbclusters > fNumberClustersf) continue;
1564 if(nb3pc <= 5) continue;
1565 if((time >= 21) || (time < 7)) continue;
1566 if(TMath::Abs(qcl) < 80) continue;
1567 if( TMath::Abs(snp) > 1.) continue;
1570 ////////////////////////
1572 ///////////////////////
1574 if(TMath::Abs(dpad) < 1.5) {
1575 fPRF2d->Fill(shift+dpad,(caligroup+0.5),ycenter);
1576 fPRF2d->Fill(shift-dpad,(caligroup+0.5),ycenter);
1577 //printf("place %f, ycenter %f\n",(shift+dpad),ycenter);
1579 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
1580 fPRF2d->Fill(shift-(dpad+1.0),(caligroup+0.5),ymin);
1581 fPRF2d->Fill(shift+(dpad+1.0),(caligroup+0.5),ymin);
1583 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
1584 fPRF2d->Fill(shift+1.0-dpad,(caligroup+0.5),ymax);
1585 fPRF2d->Fill(shift-1.0+dpad,(caligroup+0.5),ymax);
1590 if(TMath::Abs(dpad) < 1.5) {
1591 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+dpad,ycenter);
1592 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-dpad,ycenter);
1594 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
1595 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-(dpad+1.0),ymin);
1596 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+(dpad+1.0),ymin);
1598 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
1599 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+1.0-dpad,ymax);
1600 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-1.0+dpad,ymax);
1603 } // second loop over clusters
1609 ///////////////////////////////////////////////////////////////////////////////////////
1610 // Pad row col stuff: see if masked or not
1611 ///////////////////////////////////////////////////////////////////////////////////////
1612 //_____________________________________________________________________________
1613 void AliTRDCalibraFillHisto::CheckGoodTrackletV1(AliTRDcluster *cl)
1616 // See if we are not near a masked pad
1619 if(cl->IsMasked()) fGoodTracklet = kFALSE;
1623 //_____________________________________________________________________________
1624 void AliTRDCalibraFillHisto::CheckGoodTrackletV0(Int_t detector, Int_t row, Int_t col)
1627 // See if we are not near a masked pad
1630 if (!IsPadOn(detector, col, row)) {
1631 fGoodTracklet = kFALSE;
1635 if (!IsPadOn(detector, col-1, row)) {
1636 fGoodTracklet = kFALSE;
1641 if (!IsPadOn(detector, col+1, row)) {
1642 fGoodTracklet = kFALSE;
1647 //_____________________________________________________________________________
1648 Bool_t AliTRDCalibraFillHisto::IsPadOn(Int_t detector, Int_t row, Int_t col) const
1651 // Look in the choosen database if the pad is On.
1652 // If no the track will be "not good"
1655 // Get the parameter object
1656 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
1658 AliInfo("Could not get calibDB");
1662 if (!cal->IsChamberInstalled(detector) ||
1663 cal->IsChamberMasked(detector) ||
1664 cal->IsPadMasked(detector,col,row)) {
1672 ///////////////////////////////////////////////////////////////////////////////////////
1673 // Calibration groups: calculate the number of groups, localise...
1674 ////////////////////////////////////////////////////////////////////////////////////////
1675 //_____________________________________________________________________________
1676 Int_t AliTRDCalibraFillHisto::CalculateCalibrationGroup(Int_t i, Int_t row, Int_t col) const
1679 // Calculate the calibration group number for i
1682 // Row of the cluster and position in the pad groups
1684 if (fCalibraMode->GetNnZ(i) != 0) {
1685 posr = (Int_t) row / fCalibraMode->GetNnZ(i);
1689 // Col of the cluster and position in the pad groups
1691 if (fCalibraMode->GetNnRphi(i) != 0) {
1692 posc = (Int_t) col / fCalibraMode->GetNnRphi(i);
1695 return posc*fCalibraMode->GetNfragZ(i)+posr;
1698 //____________________________________________________________________________________
1699 Int_t AliTRDCalibraFillHisto::CalculateTotalNumberOfBins(Int_t i)
1702 // Calculate the total number of calibration groups
1706 fCalibraMode->ModePadCalibration(2,i);
1707 fCalibraMode->ModePadFragmentation(0,2,0,i);
1708 fCalibraMode->SetDetChamb2(i);
1709 ntotal += 6 * 18 * fCalibraMode->GetDetChamb2(i);
1710 fCalibraMode->ModePadCalibration(0,i);
1711 fCalibraMode->ModePadFragmentation(0,0,0,i);
1712 fCalibraMode->SetDetChamb0(i);
1713 ntotal += 6 * 4 * 18 * fCalibraMode->GetDetChamb0(i);
1714 AliInfo(Form("Total number of Xbins: %d for i %d",ntotal,i));
1718 //_____________________________________________________________________________
1719 void AliTRDCalibraFillHisto::SetNz(Int_t i, Short_t Nz)
1722 // Set the mode of calibration group in the z direction for the parameter i
1727 fCalibraMode->SetNz(i, Nz);
1730 AliInfo("You have to choose between 0 and 4");
1734 //_____________________________________________________________________________
1735 void AliTRDCalibraFillHisto::SetNrphi(Int_t i, Short_t Nrphi)
1738 // Set the mode of calibration group in the rphi direction for the parameter i
1743 fCalibraMode->SetNrphi(i ,Nrphi);
1746 AliInfo("You have to choose between 0 and 6");
1750 //____________Set the pad calibration variables for the detector_______________
1751 Bool_t AliTRDCalibraFillHisto::LocalisationDetectorXbins(Int_t detector)
1754 // For the detector calcul the first Xbins and set the number of row
1755 // and col pads per calibration groups, the number of calibration
1756 // groups in the detector.
1759 // first Xbins of the detector
1761 fCalibraMode->CalculXBins(detector,0);
1764 fCalibraMode->CalculXBins(detector,1);
1767 fCalibraMode->CalculXBins(detector,2);
1770 // fragmentation of idect
1771 for (Int_t i = 0; i < 3; i++) {
1772 fCalibraMode->ModePadCalibration((Int_t) GetStack(detector),i);
1773 fCalibraMode->ModePadFragmentation((Int_t) GetLayer(detector)
1774 , (Int_t) GetStack(detector)
1775 , (Int_t) GetSector(detector),i);
1781 //_____________________________________________________________________________
1782 void AliTRDCalibraFillHisto::SetNumberGroupsPRF(Short_t numberGroupsPRF)
1785 // Should be between 0 and 6
1788 if ((numberGroupsPRF < 0) || (numberGroupsPRF > 6)) {
1789 AliInfo("The number of groups must be between 0 and 6!");
1792 fNgroupprf = numberGroupsPRF;
1796 ///////////////////////////////////////////////////////////////////////////////////////////
1797 // Per tracklet: store or reset the info, fill the histos with the info
1798 //////////////////////////////////////////////////////////////////////////////////////////
1799 //_____________________________________________________________________________
1800 void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(AliTRDcluster *cl, Double_t dqdl, Int_t *group, Int_t row, Int_t col)
1803 // Store the infos in fAmpTotal, fPHPlace and fPHValue
1804 // Correct from the gain correction before
1807 // time bin of the cluster not corrected
1808 Int_t time = cl->GetPadTime();
1810 //Correct for the gain coefficient used in the database for reconstruction
1811 Float_t correctthegain = fCalDetGain->GetValue(fDetectorPreviousTrack)*fCalROCGain->GetValue(col,row);
1812 Float_t correction = 1.0;
1813 Float_t normalisation = 6.67;
1814 // we divide with gain in AliTRDclusterizer::Transform...
1815 if( correctthegain > 0 ) normalisation /= correctthegain;
1818 // take dd/dl corrected from the angle of the track
1819 correction = dqdl / (normalisation);
1822 // Fill the fAmpTotal with the charge
1824 if((!fLimitChargeIntegration) || (cl->IsInChamber())) fAmpTotal[(Int_t) group[0]] += correction;
1827 // Fill the fPHPlace and value
1829 fPHPlace[time] = group[1];
1830 fPHValue[time] = correction;
1834 //____________Offine tracking in the AliTRDtracker_____________________________
1835 void AliTRDCalibraFillHisto::ResetfVariablestracklet()
1838 // Reset values per tracklet
1841 //Reset good tracklet
1842 fGoodTracklet = kTRUE;
1844 // Reset the fPHValue
1846 //Reset the fPHValue and fPHPlace
1847 for (Int_t k = 0; k < fTimeMax; k++) {
1853 // Reset the fAmpTotal where we put value
1855 for (Int_t k = 0; k < fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0); k++) {
1860 //____________Offine tracking in the AliTRDtracker_____________________________
1861 void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackCH(Int_t nbclusters)
1864 // For the offline tracking or mcm tracklets
1865 // This function will be called in the functions UpdateHistogram...
1866 // to fill the info of a track for the relativ gain calibration
1869 Int_t nb = 0; // Nombre de zones traversees
1870 Int_t fd = -1; // Premiere zone non nulle
1871 Float_t totalcharge = 0.0; // Total charge for the supermodule histo
1873 if(nbclusters < fNumberClusters) return;
1874 if(nbclusters > fNumberClustersf) return;
1877 // See if the track goes through different zones
1878 for (Int_t k = 0; k < fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0); k++) {
1879 if (fAmpTotal[k] > 0.0) {
1880 totalcharge += fAmpTotal[k];
1893 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
1895 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/fRelativeScale);
1896 //fCH2d->Fill(fAmpTotal[fd]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+0.5);
1899 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/fRelativeScale);
1903 if ((fAmpTotal[fd] > 0.0) &&
1904 (fAmpTotal[fd+1] > 0.0)) {
1905 // One of the two very big
1906 if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+1]) {
1908 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/fRelativeScale);
1909 //fCH2d->Fill(fAmpTotal[fd]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+0.5);
1912 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/fRelativeScale);
1915 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
1917 if (fAmpTotal[fd+1] > fProcent*fAmpTotal[fd]) {
1919 FillCH2d(fCalibraMode->GetXbins(0)+fd+1,fAmpTotal[fd+1]/fRelativeScale);
1920 //fCH2d->Fill(fAmpTotal[fd+1]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+1.5);
1923 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd+1,fAmpTotal[fd+1]/fRelativeScale);
1926 fEntriesCH[fCalibraMode->GetXbins(0)+fd+1]++;
1929 if (fCalibraMode->GetNfragZ(0) > 1) {
1930 if (fAmpTotal[fd] > 0.0) {
1931 if ((fd+fCalibraMode->GetNfragZ(0)) < (fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0))) {
1932 if (fAmpTotal[fd+fCalibraMode->GetNfragZ(0)] > 0.0) {
1933 // One of the two very big
1934 if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]) {
1936 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/fRelativeScale);
1937 //fCH2d->Fill(fAmpTotal[fd]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+0.5);
1940 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/fRelativeScale);
1943 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
1945 if (fAmpTotal[fd+fCalibraMode->GetNfragZ(0)] > fProcent*fAmpTotal[fd]) {
1947 FillCH2d(fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0),fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/fRelativeScale);
1948 //fCH2d->Fill(fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0)+0.5);
1951 fEntriesCH[fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0)]++;
1953 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd+fCalibraMode->GetNfragZ(0),fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/fRelativeScale);
1964 //____________Offine tracking in the AliTRDtracker_____________________________
1965 void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH()
1968 // For the offline tracking or mcm tracklets
1969 // This function will be called in the functions UpdateHistogram...
1970 // to fill the info of a track for the drift velocity calibration
1973 Int_t nb = 1; // Nombre de zones traversees 1, 2 ou plus de 3
1974 Int_t fd1 = -1; // Premiere zone non nulle
1975 Int_t fd2 = -1; // Deuxieme zone non nulle
1976 Int_t k1 = -1; // Debut de la premiere zone
1977 Int_t k2 = -1; // Debut de la seconde zone
1978 Int_t nbclusters = 0; // number of clusters
1982 // See if the track goes through different zones
1983 for (Int_t k = 0; k < fTimeMax; k++) {
1984 if (fPHValue[k] > 0.0) {
1990 if (fPHPlace[k] != fd1) {
1996 if (fPHPlace[k] != fd2) {
2003 //printf("nbclusters %d, low limit %d, high limit %d\n",nbclusters,fNumberClusters,fNumberClustersf);
2005 if(nbclusters < fNumberClusters) return;
2006 if(nbclusters > fNumberClustersf) return;
2012 for (Int_t i = 0; i < fTimeMax; i++) {
2014 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2015 //printf("Fill the time bin %d with %f\n",i,fPHValue[i]);
2018 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2023 if ((fd1 == fd2+1) ||
2025 // One of the two fast all the think
2026 if (k2 > (k1+fDifference)) {
2027 //we choose to fill the fd1 with all the values
2029 for (Int_t i = 0; i < fTimeMax; i++) {
2031 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2034 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2038 if ((k2+fDifference) < fTimeMax) {
2039 //we choose to fill the fd2 with all the values
2041 for (Int_t i = 0; i < fTimeMax; i++) {
2043 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2046 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2051 // Two zones voisines sinon rien!
2052 if (fCalibraMode->GetNfragZ(1) > 1) {
2054 if ((fd1+fCalibraMode->GetNfragZ(1)) < (fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1))) {
2055 if (fd2 == (fd1+fCalibraMode->GetNfragZ(1))) {
2056 // One of the two fast all the think
2057 if (k2 > (k1+fDifference)) {
2058 //we choose to fill the fd1 with all the values
2060 for (Int_t i = 0; i < fTimeMax; i++) {
2062 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2065 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2069 if ((k2+fDifference) < fTimeMax) {
2070 //we choose to fill the fd2 with all the values
2072 for (Int_t i = 0; i < fTimeMax; i++) {
2074 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2077 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2083 // Two zones voisines sinon rien!
2085 if ((fd1 - fCalibraMode->GetNfragZ(1)) >= 0) {
2086 if (fd2 == (fd1 - fCalibraMode->GetNfragZ(1))) {
2087 // One of the two fast all the think
2088 if (k2 > (k1 + fDifference)) {
2089 //we choose to fill the fd1 with all the values
2091 for (Int_t i = 0; i < fTimeMax; i++) {
2093 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2096 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2100 if ((k2+fDifference) < fTimeMax) {
2101 //we choose to fill the fd2 with all the values
2103 for (Int_t i = 0; i < fTimeMax; i++) {
2105 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2108 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2119 //////////////////////////////////////////////////////////////////////////////////////////
2120 // DAQ process functions
2121 /////////////////////////////////////////////////////////////////////////////////////////
2122 //_____________________________________________________________________
2123 Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bool_t nocheck)
2126 // Event Processing loop - AliTRDrawStreamBase
2127 // TestBeam 2007 version
2128 // 0 timebin problem
2132 // Same algorithm as TestBeam but different reader
2135 Int_t withInput = 1;
2137 Double_t phvalue[16][144][36];
2138 for(Int_t k = 0; k < 36; k++){
2139 for(Int_t j = 0; j < 16; j++){
2140 for(Int_t c = 0; c < 144; c++){
2141 phvalue[j][c][k] = 0.0;
2146 fDetectorPreviousTrack = -1;
2149 Int_t nbtimebin = 0;
2150 Int_t baseline = 10;
2157 while (rawStream->Next()) {
2159 Int_t idetector = rawStream->GetDet(); // current detector
2160 Int_t imcm = rawStream->GetMCM(); // current MCM
2161 Int_t irob = rawStream->GetROB(); // current ROB
2163 //printf("Detector %d\n",idetector);
2165 if((fDetectorPreviousTrack != idetector) && (fDetectorPreviousTrack != -1)){
2168 withInput = TMath::Max(FillDAQ(phvalue),withInput);
2172 for(Int_t k = 0; k < 36; k++){
2173 for(Int_t j = 0; j < 16; j++){
2174 for(Int_t c = 0; c < 144; c++){
2175 phvalue[j][c][k] = 0.0;
2181 fDetectorPreviousTrack = idetector;
2182 fMCMPrevious = imcm;
2183 fROBPrevious = irob;
2185 nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
2186 if(nbtimebin == 0) return 0;
2187 if((fTimeMax != 0) && (nbtimebin != fTimeMax)) return 0;
2188 fTimeMax = nbtimebin;
2190 //baseline = rawStream->GetCommonAdditive(); // common additive baseline
2191 fNumberClustersf = fTimeMax;
2192 fNumberClusters = (Int_t)(0.6*fTimeMax);
2195 Int_t *signal = rawStream->GetSignals(); // current ADC signal
2196 Int_t col = rawStream->GetCol();
2197 Int_t row = rawStream->GetRow();
2200 //printf("detector %d, signal[0] %d, signal[1] %d, signal[2] %d, baseline %d\n",idetector,signal[0],signal[1],signal[2], baseline);
2203 for(Int_t itime = 0; itime < nbtimebin; itime++){
2204 phvalue[row][col][itime] = signal[itime]-baseline;
2208 // fill the last one
2209 if(fDetectorPreviousTrack != -1){
2212 withInput = TMath::Max(FillDAQ(phvalue),withInput);
2215 for(Int_t k = 0; k < 36; k++){
2216 for(Int_t j = 0; j < 16; j++){
2217 for(Int_t c = 0; c < 144; c++){
2218 phvalue[j][c][k] = 0.0;
2227 while (rawStream->Next()) {
2229 Int_t idetector = rawStream->GetDet(); // current detector
2230 Int_t imcm = rawStream->GetMCM(); // current MCM
2231 Int_t irob = rawStream->GetROB(); // current ROB
2233 //printf("Detector %d\n",idetector);
2235 if((fDetectorPreviousTrack != idetector) && (fDetectorPreviousTrack != -1)){
2238 withInput = TMath::Max(FillDAQ(phvalue),withInput);
2241 for(Int_t k = 0; k < 36; k++){
2242 for(Int_t j = 0; j < 16; j++){
2243 for(Int_t c = 0; c < 144; c++){
2244 phvalue[j][c][k] = 0.0;
2250 fDetectorPreviousTrack = idetector;
2251 fMCMPrevious = imcm;
2252 fROBPrevious = irob;
2254 //baseline = rawStream->GetCommonAdditive(); // common baseline
2256 fTimeMax = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
2257 fNumberClustersf = fTimeMax;
2258 fNumberClusters = (Int_t)(0.6*fTimeMax);
2259 Int_t *signal = rawStream->GetSignals(); // current ADC signal
2260 Int_t col = rawStream->GetCol();
2261 Int_t row = rawStream->GetRow();
2264 //printf("detector %d, signal[0] %d, signal[1] %d, signal[2] %d, baseline %d\n",idetector,signal[0],signal[1],signal[2], baseline);
2266 for(Int_t itime = 0; itime < fTimeMax; itime++){
2267 phvalue[row][col][itime] = signal[itime]-baseline;
2271 // fill the last one
2272 if(fDetectorPreviousTrack != -1){
2275 withInput = TMath::Max(FillDAQ(phvalue),withInput);
2278 for(Int_t k = 0; k < 36; k++){
2279 for(Int_t j = 0; j < 16; j++){
2280 for(Int_t c = 0; c < 144; c++){
2281 phvalue[j][c][k] = 0.0;
2291 //_____________________________________________________________________
2292 Int_t AliTRDCalibraFillHisto::ProcessEventDAQV1(AliTRDrawStreamBase *rawStream, Bool_t nocheck)
2295 // Event Processing loop - AliTRDrawStreamBase
2296 // Use old AliTRDmcmtracklet code
2297 // 0 timebin problem
2301 // Algorithm with mcm tracklet
2304 Int_t withInput = 1;
2306 AliTRDmcm mcm = AliTRDmcm(0);
2307 AliTRDtrigParam *param = AliTRDtrigParam::Instance();
2308 rawStream->SetSharedPadReadout(kTRUE);
2310 fDetectorPreviousTrack = -1;
2314 Int_t nbtimebin = 0;
2315 Int_t baseline = 10;
2322 while (rawStream->Next()) {
2324 Int_t idetector = rawStream->GetDet(); // current detector
2325 Int_t imcm = rawStream->GetMCM(); // current MCM
2326 Int_t irob = rawStream->GetROB(); // current ROB
2327 row = rawStream->GetRow();
2330 if(((fDetectorPreviousTrack != idetector) || (fMCMPrevious != imcm) || (fROBPrevious != irob)) && (fDetectorPreviousTrack != -1)){
2333 withInput = TMath::Max(FillDAQ(&mcm),withInput);
2339 mcm.SetChaId(idetector);
2341 mcm.SetColRange(0,21);
2344 if(fDetectorPreviousTrack == -1){
2347 mcm.SetChaId(idetector);
2349 mcm.SetColRange(0,21);
2353 fDetectorPreviousTrack = idetector;
2354 fMCMPrevious = imcm;
2355 fROBPrevious = irob;
2357 nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
2358 if(nbtimebin == 0) return 0;
2359 if((fTimeMax != 0) && (nbtimebin != fTimeMax)) return 0;
2360 fTimeMax = nbtimebin;
2361 fNumberClustersf = fTimeMax;
2362 fNumberClusters = (Int_t)(0.6*fTimeMax);
2363 param->SetTimeRange(0,fTimeMax);
2365 //baseline = rawStream->GetCommonAdditive(); // common additive baseline
2367 Int_t *signal = rawStream->GetSignals(); // current ADC signal
2368 Int_t adc = rawStream->GetADC();
2371 //printf("detector %d, signal[0] %d, signal[1] %d, signal[2] %d, baseline %d\n",idetector,signal[0],signal[1],signal[2], baseline);
2373 for(Int_t itime = 0; itime < nbtimebin; itime++){
2374 mcm.SetADC(adc,itime,(signal[itime]-baseline));
2378 // fill the last one
2379 if(fDetectorPreviousTrack != -1){
2382 withInput = TMath::Max(FillDAQ(&mcm),withInput);
2387 mcm.SetRobId(fROBPrevious);
2388 mcm.SetChaId(fDetectorPreviousTrack);
2390 mcm.SetColRange(0,21);
2397 while (rawStream->Next()) {
2399 Int_t idetector = rawStream->GetDet(); // current detector
2400 Int_t imcm = rawStream->GetMCM(); // current MCM
2401 Int_t irob = rawStream->GetROB(); // current ROB
2402 row = rawStream->GetRow();
2404 if(((fDetectorPreviousTrack != idetector) || (fMCMPrevious != imcm) || (fROBPrevious != irob)) && (fDetectorPreviousTrack != -1)){
2407 withInput = TMath::Max(FillDAQ(&mcm),withInput);
2413 mcm.SetChaId(idetector);
2415 mcm.SetColRange(0,21);
2419 fDetectorPreviousTrack = idetector;
2420 fMCMPrevious = imcm;
2421 fROBPrevious = irob;
2423 //baseline = rawStream->GetCommonAdditive(); // common baseline
2425 fTimeMax = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
2426 fNumberClustersf = fTimeMax;
2427 fNumberClusters = (Int_t)(0.6*fTimeMax);
2428 param->SetTimeRange(0,fTimeMax);
2429 Int_t *signal = rawStream->GetSignals(); // current ADC signal
2430 Int_t adc = rawStream->GetADC();
2433 //printf("detector %d, signal[0] %d, signal[1] %d, signal[2] %d, baseline %d\n",idetector,signal[0],signal[1],signal[2], baseline);
2435 for(Int_t itime = 0; itime < fTimeMax; itime++){
2436 mcm.SetADC(adc,itime,(signal[itime]-baseline));
2440 // fill the last one
2441 if(fDetectorPreviousTrack != -1){
2444 withInput = TMath::Max(FillDAQ(&mcm),withInput);
2448 mcm.SetRobId(fROBPrevious);
2449 mcm.SetChaId(fDetectorPreviousTrack);
2451 mcm.SetColRange(0,21);
2459 //_____________________________________________________________________
2460 Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliRawReader *rawReader, Bool_t nocheck)
2463 // Event processing loop - AliRawReader
2464 // Testbeam 2007 version
2467 AliTRDrawStreamBase rawStream(rawReader);
2469 rawReader->Select("TRD");
2471 return ProcessEventDAQ(&rawStream, nocheck);
2474 //_________________________________________________________________________
2475 Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(
2477 eventHeaderStruct *event,
2480 eventHeaderStruct* /*event*/,
2487 // process date event
2488 // Testbeam 2007 version
2491 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
2492 Int_t result=ProcessEventDAQ(rawReader, nocheck);
2496 Fatal("AliTRDCalibraFillHisto", "this class was compiled without DATE");
2501 //_____________________________________________________________________
2502 Int_t AliTRDCalibraFillHisto::ProcessEventDAQV1(AliRawReader *rawReader, Bool_t nocheck)
2505 // Event processing loop - AliRawReader
2506 // use the old mcm traklet code
2509 AliTRDrawStreamBase rawStream(rawReader);
2511 rawReader->Select("TRD");
2513 return ProcessEventDAQV1(&rawStream, nocheck);
2515 //_________________________________________________________________________
2516 Int_t AliTRDCalibraFillHisto::ProcessEventDAQV1(
2518 eventHeaderStruct *event,
2521 eventHeaderStruct* /*event*/,
2528 // process date event
2529 // use the old mcm tracklet code
2532 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
2533 Int_t result=ProcessEventDAQV1(rawReader, nocheck);
2537 Fatal("AliTRDCalibraFillHisto", "this class was compiled without DATE");
2542 //////////////////////////////////////////////////////////////////////////////
2543 // Routine inside the DAQ process
2544 /////////////////////////////////////////////////////////////////////////////
2545 //_______________________________________________________________________
2546 Int_t AliTRDCalibraFillHisto::FillDAQ(AliTRDmcm *mcm){
2549 // Return 2 if some tracklets are found and used, 1 if nothing
2556 for (Int_t iSeed = 0; iSeed < 4; iSeed++) {
2558 if (mcm->GetSeedCol()[iSeed] < 0) {
2562 nbev += TestTracklet(mcm->GetChaId(),mcm->GetRow(),iSeed,mcm);
2567 if(nbev > 0) nbev = 2;
2573 //__________________________________________________________________________
2574 Int_t AliTRDCalibraFillHisto::TestTracklet( Int_t idet, Int_t row, Int_t iSeed, AliTRDmcm *mcm){
2577 // Build the tracklet and return if the tracklet if finally used or not (1/0)
2582 AliTRDmcmTracklet mcmtracklet = AliTRDmcmTracklet();
2583 //mcmtracklet.Reset();
2584 mcmtracklet.SetDetector(idet);
2585 mcmtracklet.SetRow(row);
2586 mcmtracklet.SetN(0);
2588 Int_t iCol, iCol1, iCol2, track[3];
2589 iCol = mcm->GetSeedCol()[iSeed]; // 0....20 (MCM)
2590 mcm->GetColRange(iCol1,iCol2); // range in the pad plane
2593 for (Int_t iTime = 0; iTime < fTimeMax; iTime++) {
2595 amp[0] = mcm->GetADC(iCol-1,iTime);
2596 amp[1] = mcm->GetADC(iCol ,iTime);
2597 amp[2] = mcm->GetADC(iCol+1,iTime);
2599 if(mcm->IsCluster(iCol,iTime)) {
2601 mcmtracklet.AddCluster(iCol+iCol1,iTime,amp,track);
2604 else if ((iCol+1+1) < 21) {
2606 amp[0] = mcm->GetADC(iCol-1+1,iTime);
2607 amp[1] = mcm->GetADC(iCol +1,iTime);
2608 amp[2] = mcm->GetADC(iCol+1+1,iTime);
2610 if(mcm->IsCluster(iCol+1,iTime)) {
2612 mcmtracklet.AddCluster(iCol+1+iCol1,iTime,amp,track);
2621 nbev = UpdateHistogramcm(&mcmtracklet);
2626 //____________Online trackling in AliTRDtrigger________________________________
2627 Int_t AliTRDCalibraFillHisto::UpdateHistogramcm(AliTRDmcmTracklet *trk)
2630 // Return if the tracklet is finally used or not (1/0) for calibration
2635 //fGoodTracklet = kTRUE;
2637 // Localisation of the Xbins involved
2638 Int_t idect = trk->GetDetector();
2639 Int_t idectrue = trk->GetDetector();
2642 Int_t nbclusters = trk->GetNclusters();
2644 // Eventuelle correction due to track angle in z direction
2645 Float_t correction = 1.0;
2646 if (fMcmCorrectAngle) {
2647 Float_t z = trk->GetRowz();
2648 Float_t r = trk->GetTime0();
2649 correction = r / TMath::Sqrt((r*r+z*z));
2653 Int_t row = trk->GetRow();
2656 // Boucle sur les clusters
2657 // Condition on number of cluster: don't come from the middle of the detector
2660 for(Int_t k =0; k < 36; k++) amph[k]=0.0;
2661 Double_t ampTotal = 0.0;
2663 for (Int_t icl = 0; icl < trk->GetNclusters(); icl++) {
2665 Float_t amp[3] = { 0.0, 0.0, 0.0 };
2666 Int_t time = trk->GetClusterTime(icl);
2667 Int_t col = trk->GetClusterCol(icl);
2669 //CheckGoodTrackletV0(idect,row,col);
2671 amp[0] = trk->GetClusterADC(icl)[0] * correction;
2672 amp[1] = trk->GetClusterADC(icl)[1] * correction;
2673 amp[2] = trk->GetClusterADC(icl)[2] * correction;
2675 ampTotal += (Float_t) (amp[0]+amp[1]+amp[2]);
2676 amph[time]=amp[0]+amp[1]+amp[2];
2678 if(fDebugLevel > 0){
2679 if ( !fDebugStreamer ) {
2681 TDirectory *backup = gDirectory;
2682 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
2683 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2686 Double_t amp0 = amp[0];
2687 Double_t amp1 = amp[1];
2688 Double_t amp2 = amp[2];
2690 (* fDebugStreamer) << "UpdateHistogramcm0"<<
2691 "nbclusters="<<nbclusters<<
2698 "detector="<<idectrue<<
2702 } // Boucle clusters
2704 if((amph[0] > 100.0) || (!fGoodTracklet) || (trk->GetNclusters() < fNumberClusters) || (trk->GetNclusters() > fNumberClustersf)) used = 0;
2707 for(Int_t k = 0; k < fTimeMax; k++) UpdateDAQ(idect,0,0,k,amph[k],fTimeMax);
2708 //((TH2I *)GetCH2d()->Fill(ampTotal/30.0,idect));
2712 if(fDebugLevel > 0){
2713 if ( !fDebugStreamer ) {
2715 TDirectory *backup = gDirectory;
2716 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
2717 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2720 Double_t amph0 = amph[0];
2721 Double_t amphlast = amph[fTimeMax-1];
2722 Double_t rms = TMath::RMS(fTimeMax,amph);
2723 Int_t goodtracklet = (Int_t) fGoodTracklet;
2725 (* fDebugStreamer) << "UpdateHistogramcm1"<<
2726 "nbclusters="<<nbclusters<<
2727 "ampTotal="<<ampTotal<<
2729 "detector="<<idectrue<<
2731 "amphlast="<<amphlast<<
2732 "goodtracklet="<<goodtracklet<<
2740 //_______________________________________________________________________
2741 Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){
2744 // Look for the maximum by collapsing over the time
2745 // Sum over four pad col and two pad row
2751 Int_t idect = fDetectorPreviousTrack;
2752 //printf("Enter Detector %d\n",fDetectorPreviousTrack);
2754 for(Int_t tb = 0; tb < 36; tb++){
2758 //fGoodTracklet = kTRUE;
2759 //fDetectorPreviousTrack = 0;
2762 ///////////////////////////
2764 /////////////////////////
2768 Double_t integralMax = -1;
2770 for (Int_t ir = 1; ir <= 15; ir++)
2772 for (Int_t ic = 2; ic <= 142; ic++)
2774 Double_t integral = 0;
2775 for (Int_t ishiftR = 0; ishiftR < 2; ishiftR++)
2777 for (Int_t ishiftC = -2; ishiftC < 2; ishiftC++)
2779 if (ir + ishiftR >= 1 && ir + ishiftR <= 16 &&
2780 ic + ishiftC >= 1 && ic + ishiftC <= 144)
2783 for(Int_t tb = 0; tb< fTimeMax; tb++){
2784 integral += phvalue[ir + ishiftR-1][ic + ishiftC-1][tb];
2790 if (integralMax < integral)
2794 integralMax = integral;
2795 } // check max integral
2799 //printf("imaxRow %d, imaxCol %d, fTimeMax %d, integralMax %f\n",imaxRow,imaxCol,fTimeMax, integralMax);
2801 if((imaxRow == 0) || (imaxCol == 0)) {
2805 //CheckGoodTrackletV0(fDetectorPreviousTrack,imaxRow,imaxCol);
2806 //if(!fGoodTracklet) used = 1;;
2808 // /////////////////////////////////////////////////////
2809 // sum ober 2 row and 4 pad cols for each time bins
2810 // ////////////////////////////////////////////////////
2813 for (Int_t ir = imaxRow - 1; ir < imaxRow + 1; ir++)
2815 for (Int_t ic = imaxCol - 2; ic < imaxCol + 2; ic++)
2817 for(Int_t it = 0; it < fTimeMax; it++){
2818 sum[it] += phvalue[ir][ic][it];
2824 Double_t sumcharge = 0.0;
2825 for(Int_t it = 0; it < fTimeMax; it++){
2826 sumcharge += sum[it];
2827 if(sum[it] > 20.0) nbcl++;
2831 /////////////////////////////////////////////////////////
2833 ////////////////////////////////////////////////////////
2834 if(fDebugLevel > 0){
2835 if ( !fDebugStreamer ) {
2837 TDirectory *backup = gDirectory;
2838 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
2839 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2842 Double_t amph0 = sum[0];
2843 Double_t amphlast = sum[fTimeMax-1];
2844 Double_t rms = TMath::RMS(fTimeMax,sum);
2845 Int_t goodtracklet = (Int_t) fGoodTracklet;
2846 for(Int_t it = 0; it < fTimeMax; it++){
2847 Double_t clustera = sum[it];
2849 (* fDebugStreamer) << "FillDAQa"<<
2850 "ampTotal="<<sumcharge<<
2853 "detector="<<idect<<
2855 "amphlast="<<amphlast<<
2856 "goodtracklet="<<goodtracklet<<
2857 "clustera="<<clustera<<
2864 ////////////////////////////////////////////////////////
2866 ///////////////////////////////////////////////////////
2867 if(sum[0] > 100.0) used = 1;
2868 if(nbcl < fNumberClusters) used = 1;
2869 if(nbcl > fNumberClustersf) used = 1;
2871 //if(fDetectorPreviousTrack == 15){
2872 // printf("rms %f and first time bin %f\n",TMath::RMS(fTimeMax,sum),sum[0]);
2874 //if((TMath::RMS(fTimeMax,sum) <= 10.0) && (sum[0] > 200.0)) return 1;
2876 for(Int_t it = 0; it < fTimeMax; it++){
2877 UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax);
2881 //((TH2I *)GetCH2d()->Fill(sumcharge/30.0,fDetectorPreviousTrack));
2883 //printf("Pass Detector %d\n",fDetectorPreviousTrack);
2890 //____________Online trackling in AliTRDtrigger________________________________
2891 Bool_t AliTRDCalibraFillHisto::UpdateDAQ(Int_t det, Int_t /*row*/, Int_t /*col*/, Int_t timebin, Float_t signal, Int_t nbtimebins)
2895 // Fill a simple average pulse height
2899 ((TProfile2D *)GetPH2d(nbtimebins,fSf))->Fill((Float_t) timebin/fSf,det+0.5,(Float_t) signal);
2905 //____________Write_____________________________________________________
2906 //_____________________________________________________________________
2907 void AliTRDCalibraFillHisto::Write2d(const Char_t *filename, Bool_t append)
2910 // Write infos to file
2914 if ( fDebugStreamer ) {
2915 delete fDebugStreamer;
2916 fDebugStreamer = 0x0;
2919 AliInfo(Form("Numbertrack: %d Numberusedch[0]: %d, Numberusedch[1]: %d Numberusedph[0]: %d, Numberusedph[1]: %d"
2924 ,fNumberUsedPh[1]));
2926 TDirectory *backup = gDirectory;
2932 option = "recreate";
2934 TFile f(filename,option.Data());
2936 TStopwatch stopwatch;
2939 f.WriteTObject(fCalibraVector);
2944 f.WriteTObject(fCH2d);
2949 f.WriteTObject(fPH2d);
2954 f.WriteTObject(fPRF2d);
2957 if(fLinearFitterOn){
2958 AnalyseLinearFitter();
2959 f.WriteTObject(fLinearVdriftFit);
2964 if ( backup ) backup->cd();
2966 AliInfo(Form("Execution time Write2d: R:%.2fs C:%.2fs"
2967 ,stopwatch.RealTime(),stopwatch.CpuTime()));
2969 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
2971 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
2972 //___________________________________________probe the histos__________________________________________________
2973 Double_t *AliTRDCalibraFillHisto::StatH(TH2 *h, Int_t i)
2976 // Check the number of stats in h, 0 is TH2I 1 is TProfile2D
2977 // debug mode with 2 for TH2I and 3 for TProfile2D
2978 // It gives a pointer to a Double_t[7] with the info following...
2979 // [0] : number of calibration groups with entries
2980 // [1] : minimal number of entries found
2981 // [2] : calibration group number of the min
2982 // [3] : maximal number of entries found
2983 // [4] : calibration group number of the max
2984 // [5] : mean number of entries found
2985 // [6] : mean relative error
2988 Double_t *info = new Double_t[7];
2990 // Number of Xbins (detectors or groups of pads)
2991 Int_t nbins = h->GetNbinsY(); //number of calibration groups
2992 Int_t nxbins = h->GetNbinsX(); //number of bins per histo
2995 Double_t nbwe = 0; //number of calibration groups with entries
2996 Double_t minentries = 0; //minimal number of entries found
2997 Double_t maxentries = 0; //maximal number of entries found
2998 Double_t placemin = 0; //calibration group number of the min
2999 Double_t placemax = -1; //calibration group number of the max
3000 Double_t meanstats = 0.0; //mean number of entries over the calibration group with at least ome entry
3001 Double_t meanrelativerror = 0.0; //mean relativ error in the TProfile2D
3003 Double_t counter = 0;
3006 TH1F *nbEntries = 0x0;//distribution of the number of entries
3007 TH1F *nbEntriesPerGroup = 0x0;//Number of entries per group
3008 TProfile *nbEntriesPerSp = 0x0;//Number of entries for one supermodule
3010 // Beginning of the loop over the calibration groups
3011 for (Int_t idect = 0; idect < nbins; idect++) {
3013 TH1I *projch = (TH1I *) h->ProjectionX("projch",idect+1,idect+1,(Option_t *)"e");
3014 projch->SetDirectory(0);
3016 // Number of entries for this calibration group
3017 Double_t nentries = 0.0;
3019 for (Int_t k = 0; k < nxbins; k++) {
3020 nentries += h->GetBinContent(h->GetBin(k+1,idect+1));
3024 for (Int_t k = 0; k < nxbins; k++) {
3025 nentries += ((TProfile2D *)h)->GetBinEntries(h->GetBin(k+1,idect+1));
3026 if(h->GetBinContent(h->GetBin(k+1,idect+1)) != 0) {
3027 meanrelativerror += (h->GetBinError(h->GetBin(k+1,idect+1))/(TMath::Abs(h->GetBinContent(h->GetBin(k+1,idect+1)))));
3035 if((!((Bool_t)nbEntries)) && (nentries > 0)){
3036 nbEntries = new TH1F("Number of entries","Number of entries"
3037 ,100,(Int_t)nentries/2,nentries*2);
3038 nbEntries->SetDirectory(0);
3039 nbEntriesPerGroup = new TH1F("Number of entries per group","Number of entries per group"
3041 nbEntriesPerGroup->SetDirectory(0);
3042 nbEntriesPerSp = new TProfile("Number of entries per supermodule","Number of entries per supermodule"
3043 ,(Int_t)(nbins/18),0,(Int_t)(nbins/18));
3044 nbEntriesPerSp->SetDirectory(0);
3047 if(nentries > 0) nbEntries->Fill(nentries);
3048 nbEntriesPerGroup->Fill(idect+0.5,nentries);
3049 nbEntriesPerSp->Fill((idect%((Int_t)(nbins/18)))+0.5,nentries);
3054 if(nentries > maxentries){
3055 maxentries = nentries;
3059 minentries = nentries;
3061 if(nentries < minentries){
3062 minentries = nentries;
3068 meanstats += nentries;
3070 }//calibration groups loop
3072 if(nbwe > 0) meanstats /= nbwe;
3073 if(counter > 0) meanrelativerror /= counter;
3075 AliInfo(Form("There are %f calibration groups with entries",nbwe));
3076 AliInfo(Form("The minimum number of entries is %f for the group %f",minentries,placemin));
3077 AliInfo(Form("The maximum number of entries is %f for the group %f",maxentries,placemax));
3078 AliInfo(Form("The mean number of entries is %f",meanstats));
3079 if((i%2) == 1) AliInfo(Form("The mean relative error is %f",meanrelativerror));
3082 info[1] = minentries;
3084 info[3] = maxentries;
3086 info[5] = meanstats;
3087 info[6] = meanrelativerror;
3090 gStyle->SetPalette(1);
3091 gStyle->SetOptStat(1111);
3092 gStyle->SetPadBorderMode(0);
3093 gStyle->SetCanvasColor(10);
3094 gStyle->SetPadLeftMargin(0.13);
3095 gStyle->SetPadRightMargin(0.01);
3096 TCanvas *stat = new TCanvas("stat","",50,50,600,800);
3099 nbEntries->Draw("");
3101 nbEntriesPerSp->SetStats(0);
3102 nbEntriesPerSp->Draw("");
3103 TCanvas *stat1 = new TCanvas("stat1","",50,50,600,800);
3105 nbEntriesPerGroup->SetStats(0);
3106 nbEntriesPerGroup->Draw("");
3112 //____________________________________________________________________________
3113 Double_t *AliTRDCalibraFillHisto::GetMeanMedianRMSNumberCH()
3116 // Return a Int_t[4] with:
3117 // 0 Mean number of entries
3118 // 1 median of number of entries
3119 // 2 rms of number of entries
3120 // 3 number of group with entries
3123 Double_t *stat = new Double_t[4];
3126 Int_t nbofgroups = CalculateTotalNumberOfBins(0);
3127 Double_t *weight = new Double_t[nbofgroups];
3128 Int_t *nonul = new Int_t[nbofgroups];
3130 for(Int_t k = 0; k < nbofgroups; k++){
3131 if(fEntriesCH[k] > 0) {
3133 nonul[(Int_t)stat[3]] = fEntriesCH[k];
3136 else weight[k] = 0.0;
3138 stat[0] = TMath::Mean(nbofgroups,fEntriesCH,weight);
3139 stat[1] = TMath::Median(nbofgroups,fEntriesCH,weight);
3140 stat[2] = TMath::RMS((Int_t)stat[3],nonul);
3145 //____________________________________________________________________________
3146 Double_t *AliTRDCalibraFillHisto::GetMeanMedianRMSNumberLinearFitter() const
3149 // Return a Int_t[4] with:
3150 // 0 Mean number of entries
3151 // 1 median of number of entries
3152 // 2 rms of number of entries
3153 // 3 number of group with entries
3156 Double_t *stat = new Double_t[4];
3159 Int_t nbofgroups = 540;
3160 Double_t *weight = new Double_t[nbofgroups];
3161 Int_t *nonul = new Int_t[nbofgroups];
3163 for(Int_t k = 0; k < nbofgroups; k++){
3164 if(fEntriesLinearFitter[k] > 0) {
3166 nonul[(Int_t) stat[3]] = fEntriesLinearFitter[k];
3169 else weight[k] = 0.0;
3171 stat[0] = TMath::Mean(nbofgroups,fEntriesLinearFitter,weight);
3172 stat[1] = TMath::Median(nbofgroups,fEntriesLinearFitter,weight);
3173 stat[2] = TMath::RMS((Int_t)stat[3],nonul);
3178 //////////////////////////////////////////////////////////////////////////////////////
3180 //////////////////////////////////////////////////////////////////////////////////////
3181 //_____________________________________________________________________________
3182 void AliTRDCalibraFillHisto::CreatePRF2d(Int_t nn)
3185 // Create the 2D histos: here we have 2*fNgroupprf bins in tnp of 0.2 amplitude each
3186 // If fNgroupprf is zero then no binning in tnp
3190 name += fCalibraMode->GetNz(2);
3192 name += fCalibraMode->GetNrphi(2);
3196 if(fNgroupprf != 0){
3198 fPRF2d = new TProfile2D("PRF2d",(const Char_t *) name
3199 ,2*fNgroupprf*fNumberBinPRF,-3.0*fNgroupprf,3.0*fNgroupprf,nn,0,nn);
3200 fPRF2d->SetYTitle("Det/pad groups");
3201 fPRF2d->SetXTitle("Position x/W [pad width units]");
3202 fPRF2d->SetZTitle("Q_{i}/Q_{total}");
3203 fPRF2d->SetStats(0);
3206 fPRF2d = new TProfile2D("PRF2d",(const Char_t *) name
3207 ,fNumberBinPRF,-1.5,1.5,nn,0,nn);
3208 fPRF2d->SetYTitle("Det/pad groups");
3209 fPRF2d->SetXTitle("Position x/W [pad width units]");
3210 fPRF2d->SetZTitle("Q_{i}/Q_{total}");
3211 fPRF2d->SetStats(0);
3216 //_____________________________________________________________________________
3217 void AliTRDCalibraFillHisto::CreatePH2d(Int_t nn)
3220 // Create the 2D histos
3224 name += fCalibraMode->GetNz(1);
3226 name += fCalibraMode->GetNrphi(1);
3228 fPH2d = new TProfile2D("PH2d",(const Char_t *) name
3229 ,fTimeMax,-0.5/fSf,(Float_t) (fTimeMax-0.5)/fSf
3231 fPH2d->SetYTitle("Det/pad groups");
3232 fPH2d->SetXTitle("time [#mus]");
3233 fPH2d->SetZTitle("<PH> [a.u.]");
3237 //_____________________________________________________________________________
3238 void AliTRDCalibraFillHisto::CreateCH2d(Int_t nn)
3241 // Create the 2D histos
3245 name += fCalibraMode->GetNz(0);
3247 name += fCalibraMode->GetNrphi(0);
3249 fCH2d = new TH2I("CH2d",(const Char_t *) name
3250 ,fNumberBinCharge,0,300,nn,0,nn);
3251 fCH2d->SetYTitle("Det/pad groups");
3252 fCH2d->SetXTitle("charge deposit [a.u]");
3253 fCH2d->SetZTitle("counts");
3258 //////////////////////////////////////////////////////////////////////////////////
3259 // Set relative scale
3260 /////////////////////////////////////////////////////////////////////////////////
3261 //_____________________________________________________________________________
3262 void AliTRDCalibraFillHisto::SetRelativeScale(Float_t RelativeScale)
3265 // Set the factor that will divide the deposited charge
3266 // to fit in the histo range [0,300]
3269 if (RelativeScale > 0.0) {
3270 fRelativeScale = RelativeScale;
3273 AliInfo("RelativeScale must be strict positif!");
3277 //////////////////////////////////////////////////////////////////////////////////
3278 // Quick way to fill a histo
3279 //////////////////////////////////////////////////////////////////////////////////
3280 //_____________________________________________________________________
3281 void AliTRDCalibraFillHisto::FillCH2d(Int_t x, Float_t y)
3284 // FillCH2d: Marian style
3287 //skip simply the value out of range
3288 if((y>=300.0) || (y<0.0)) return;
3290 //Calcul the y place
3291 Int_t yplace = (Int_t) (fNumberBinCharge*y/300.0)+1;
3292 Int_t place = (fNumberBinCharge+2)*(x+1)+yplace;
3295 fCH2d->GetArray()[place]++;
3299 //////////////////////////////////////////////////////////////////////////////////
3300 // Geometrical functions
3301 ///////////////////////////////////////////////////////////////////////////////////
3302 //_____________________________________________________________________________
3303 Int_t AliTRDCalibraFillHisto::GetLayer(Int_t d) const
3306 // Reconstruct the layer number from the detector number
3309 return ((Int_t) (d % 6));
3313 //_____________________________________________________________________________
3314 Int_t AliTRDCalibraFillHisto::GetStack(Int_t d) const
3317 // Reconstruct the stack number from the detector number
3319 const Int_t kNlayer = 6;
3321 return ((Int_t) (d % 30) / kNlayer);
3325 //_____________________________________________________________________________
3326 Int_t AliTRDCalibraFillHisto::GetSector(Int_t d) const
3329 // Reconstruct the sector number from the detector number
3333 return ((Int_t) (d / fg));
3336 ///////////////////////////////////////////////////////////////////////////////////
3337 // Getter functions for DAQ of the CH2d and the PH2d
3338 //////////////////////////////////////////////////////////////////////////////////
3339 //_____________________________________________________________________
3340 TProfile2D* AliTRDCalibraFillHisto::GetPH2d(Int_t nbtimebin, Float_t samplefrequency)
3343 // return pointer to fPH2d TProfile2D
3344 // create a new TProfile2D if it doesn't exist allready
3350 fTimeMax = nbtimebin;
3351 fSf = samplefrequency;
3357 //_____________________________________________________________________
3358 TH2I* AliTRDCalibraFillHisto::GetCH2d()
3361 // return pointer to fCH2d TH2I
3362 // create a new TH2I if it doesn't exist allready
3371 ////////////////////////////////////////////////////////////////////////////////////////////
3372 // Drift velocity calibration
3373 ///////////////////////////////////////////////////////////////////////////////////////////
3374 //_____________________________________________________________________
3375 TLinearFitter* AliTRDCalibraFillHisto::GetLinearFitter(Int_t detector, Bool_t force)
3378 // return pointer to TLinearFitter Calibration
3379 // if force is true create a new TLinearFitter if it doesn't exist allready
3382 if ((!force) || (fLinearFitterArray.UncheckedAt(detector))){
3383 return (TLinearFitter*)fLinearFitterArray.UncheckedAt(detector);
3386 // if we are forced and TLinearFitter doesn't yet exist create it
3388 // new TLinearFitter
3389 TLinearFitter *linearfitter = new TLinearFitter(2,"pol1");
3390 fLinearFitterArray.AddAt(linearfitter,detector);
3391 return linearfitter;
3394 //____________________________________________________________________________
3395 void AliTRDCalibraFillHisto::AnalyseLinearFitter()
3398 // Analyse array of linear fitter because can not be written
3399 // Store two arrays: one with the param the other one with the error param + number of entries
3402 for(Int_t k = 0; k < 540; k++){
3403 TLinearFitter *linearfitter = GetLinearFitter(k);
3404 if((linearfitter!=0) && (fEntriesLinearFitter[k]>10)){
3405 TVectorD *par = new TVectorD(2);
3406 TVectorD pare = TVectorD(2);
3407 TVectorD *parE = new TVectorD(3);
3408 linearfitter->Eval();
3409 linearfitter->GetParameters(*par);
3410 linearfitter->GetErrors(pare);
3411 Float_t ppointError = TMath::Sqrt(TMath::Abs(linearfitter->GetChisquare())/fEntriesLinearFitter[k]);
3412 (*parE)[0] = pare[0]*ppointError;
3413 (*parE)[1] = pare[1]*ppointError;
3414 (*parE)[2] = (Double_t) fEntriesLinearFitter[k];
3415 ((TObjArray *)fLinearVdriftFit->GetPArray())->AddAt(par,k);
3416 ((TObjArray *)fLinearVdriftFit->GetEArray())->AddAt(parE,k);