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
607 ///////////////////////////
608 // loop over the tracklet
609 ///////////////////////////
610 for(Int_t itr = 0; itr < 6; itr++){
612 if(!(tracklet = t->GetTracklet(itr))) continue;
613 if(!tracklet->IsOK()) continue;
615 ResetfVariablestracklet();
617 //////////////////////////////////////////
618 // localisation of the tracklet and dqdl
619 //////////////////////////////////////////
620 Int_t layer = tracklet->GetPlane();
622 while(!(cl = tracklet->GetClusters(ic++))) continue;
623 Int_t detector = cl->GetDetector();
624 if (detector != fDetectorPreviousTrack) {
625 // don't use the rest of this track if in the same plane
626 if ((layer == GetLayer(fDetectorPreviousTrack))) {
629 //Localise the detector bin
630 LocalisationDetectorXbins(detector);
632 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
634 AliInfo("Could not get calibDB");
638 if( fCalROCGain ) delete fCalROCGain;
639 fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector)));
641 fDetectorPreviousTrack = detector;
645 ////////////////////////////
646 // loop over the clusters
647 ////////////////////////////
648 Int_t nbclusters = 0;
649 for(int jc=0; jc<AliTRDseed::knTimebins; jc++){
650 if(!(cl = tracklet->GetClusters(jc))) continue;
653 // Store the info bis of the tracklet
654 Int_t row = cl->GetPadRow();
655 Int_t col = cl->GetPadCol();
656 CheckGoodTrackletV1(cl);
657 Int_t group[2] = {0,0};
658 if(fCH2dOn) group[0] = CalculateCalibrationGroup(0,row,col);
659 if(fPH2dOn) group[1] = CalculateCalibrationGroup(1,row,col);
660 StoreInfoCHPHtrack(cl, tracklet->GetdQdl(jc),group,row,col);
663 ////////////////////////////////////////
664 // Fill the stuffs if a good tracklet
665 ////////////////////////////////////////
668 // drift velocity unables to cut bad tracklets
669 Bool_t pass = FindP1TrackPHtrackletV1(tracklet, nbclusters);
673 FillTheInfoOfTheTrackCH(nbclusters);
678 FillTheInfoOfTheTrackPH();
681 if(pass && fPRF2dOn) HandlePRFtrackletV1(tracklet,nbclusters);
683 } // if a good tracklet
691 ///////////////////////////////////////////////////////////////////////////////////
692 // Routine inside the update with AliTRDtrack
693 ///////////////////////////////////////////////////////////////////////////////////
694 //____________Offine tracking in the AliTRDtracker_____________________________
695 Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtracklet(AliTRDtrack *t, Int_t index0, Int_t index1)
698 // Drift velocity calibration:
699 // Fit the clusters with a straight line
700 // From the slope find the drift velocity
703 //Number of points: if less than 3 return kFALSE
704 Int_t npoints = index1-index0;
705 if(npoints <= 2) return kFALSE;
710 Int_t detector = ((AliTRDcluster *) t->GetCluster(index0))->GetDetector(); //detector
711 // parameters of the track
712 Double_t snp = t->GetSnpPlane(GetLayer(detector)); // sin angle in the plan yx track
713 Double_t tgl = t->GetTglPlane(GetLayer(detector)); // dz/dl and not dz/dx!
714 Double_t tnp = 0.0; // tan angle in the plan xy track
715 if( TMath::Abs(snp) < 1.){
716 tnp = snp / (TMath::Sqrt(1-(snp*snp)));
718 Float_t dzdx = tgl*TMath::Sqrt(1+tnp*tnp); // dz/dx now from dz/dl
719 // tilting pad and cross row
720 Int_t crossrow = 0; // if it crosses a pad row
721 Int_t rowp = -1; // if it crosses a pad row
722 AliTRDpadPlane *padplane = fGeo->GetPadPlane(GetLayer(detector),GetStack(detector));
723 Double_t tiltingangle = padplane->GetTiltingAngle(); // tiltingangle of the pad
724 Float_t tnt = TMath::Tan(tiltingangle/180.*TMath::Pi()); // tan tiltingangle
726 TLinearFitter linearFitterTracklet = TLinearFitter(2,"pol1"); // TLinearFitter per tracklet
727 Double_t dydt = 0.0; // dydt tracklet after straight line fit
728 Double_t errorpar = 0.0; // error after straight line fit on dy/dt
729 Double_t pointError = 0.0; // error after straight line fit
730 Int_t nbli = 0; // number linear fitter points
731 linearFitterTracklet.StoreData(kFALSE);
732 linearFitterTracklet.ClearPoints();
734 //////////////////////////////
735 // loop over clusters
736 ////////////////////////////
737 for(Int_t k = 0; k < npoints; k++){
739 AliTRDcluster *cl = (AliTRDcluster *) t->GetCluster(k+index0);
740 if((fLimitChargeIntegration) && (!cl->IsInChamber())) continue;
741 Double_t ycluster = cl->GetY();
742 Int_t time = cl->GetPadTime();
743 Double_t timeis = time/fSf;
744 //Double_t q = cl->GetQ();
745 //See if cross two pad rows
746 Int_t row = cl->GetPadRow();
748 if(row != rowp) crossrow = 1;
750 linearFitterTracklet.AddPoint(&timeis,ycluster,1);
755 //////////////////////////////
757 //////////////////////////////
758 if(nbli <= 2) return kFALSE;
760 linearFitterTracklet.Eval();
761 linearFitterTracklet.GetParameters(pars);
762 pointError = TMath::Sqrt(linearFitterTracklet.GetChisquare()/nbli);
763 errorpar = linearFitterTracklet.GetParError(1)*pointError;
766 /////////////////////////////
768 ////////////////////////////
770 if ( !fDebugStreamer ) {
772 TDirectory *backup = gDirectory;
773 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
774 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
778 (* fDebugStreamer) << "FindP1TrackPHtracklet0"<<
779 //"snpright="<<snpright<<
780 "npoints="<<npoints<<
782 "detector="<<detector<<
789 "crossrow="<<crossrow<<
790 "errorpar="<<errorpar<<
791 "pointError="<<pointError<<
795 Int_t nbclusters = index1-index0;
796 Int_t layer = GetLayer(fDetectorPreviousTrack);
798 (* fDebugStreamer) << "FindP1TrackPHtracklet1"<<
799 //"snpright="<<snpright<<
800 "nbclusters="<<nbclusters<<
801 "detector="<<fDetectorPreviousTrack<<
807 ///////////////////////////
809 ///////////////////////////
810 if(npoints < fNumberClusters) return kFALSE;
811 if(npoints > fNumberClustersf) return kFALSE;
812 if(pointError >= 0.1) return kFALSE;
813 if(crossrow == 1) return kFALSE;
815 ////////////////////////////
817 ////////////////////////////
819 //Add to the linear fitter of the detector
820 if( TMath::Abs(snp) < 1.){
821 Double_t x = tnp-dzdx*tnt;
822 (GetLinearFitter(detector,kTRUE))->AddPoint(&x,dydt);
823 if(fLinearFitterDebugOn) {
824 fLinearVdriftFit->Update(detector,x,pars[1]);
826 fEntriesLinearFitter[detector]++;
832 //____________Offine tracking in the AliTRDtracker_____________________________
833 Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters)
836 // Drift velocity calibration:
837 // Fit the clusters with a straight line
838 // From the slope find the drift velocity
841 ////////////////////////////////////////////////
842 //Number of points: if less than 3 return kFALSE
843 /////////////////////////////////////////////////
844 if(nbclusters <= 2) return kFALSE;
849 TLinearFitter linearFitterTracklet = TLinearFitter(2,"pol1"); // TLinearFitter per tracklet
850 // results of the linear fit
851 Double_t dydt = 0.0; // dydt tracklet after straight line fit
852 Double_t errorpar = 0.0; // error after straight line fit on dy/dt
853 Double_t pointError = 0.0; // error after straight line fit
854 // pad row problemes: avoid tracklet that cross pad rows, tilting angle in the constant
855 Int_t crossrow = 0; // if it crosses a pad row
856 Int_t rowp = -1; // if it crosses a pad row
857 Float_t tnt = tracklet->GetTilt(); // tan tiltingangle
859 linearFitterTracklet.StoreData(kFALSE);
860 linearFitterTracklet.ClearPoints();
862 ///////////////////////////////////////////
863 // Take the parameters of the track
864 //////////////////////////////////////////
865 // take now the snp, tnp and tgl from the track
866 Double_t snp = tracklet->GetSnp(); // sin dy/dx at the end of the chamber
867 Double_t tnp = 0.0; // dy/dx at the end of the chamber
868 if( TMath::Abs(snp) < 1.){
869 tnp = snp / (TMath::Sqrt(1-(snp*snp)));
871 Double_t tgl = tracklet->GetTgl(); // dz/dl
872 Double_t dzdx = tgl*TMath::Sqrt(1+tnp*tnp); // dz/dx calculated from dz/dl
874 //Double_t tnp = tracklet->GetYref(1); // dy/dx at the entrance of the chamber
875 //Double_t tgl = tracklet->GetZref(1); // dz/dl at the entrance of the chamber
876 //Double_t dzdx = tgl; //*TMath::Sqrt(1+tnp*tnp); // dz/dx from dz/dl
877 // at the end with correction due to linear fit
878 //Double_t tnp = tracklet->GetYfit(1); // dy/dx at the end of the chamber after fit correction
879 //Double_t tgl = tracklet->GetZfit(1); // dz/dl at the end of the chamber after fit correction
882 ////////////////////////////
883 // loop over the clusters
884 ////////////////////////////
886 AliTRDcluster *cl = 0x0;
887 for(int ic=0; ic<AliTRDseed::knTimebins; ic++){
888 if(!(cl = tracklet->GetClusters(ic))) continue;
889 if((fLimitChargeIntegration) && (!cl->IsInChamber())) continue;
891 Double_t ycluster = cl->GetY();
892 Int_t time = cl->GetPadTime();
893 Double_t timeis = time/fSf;
894 //See if cross two pad rows
895 Int_t row = cl->GetPadRow();
896 if(rowp==-1) rowp = row;
897 if(row != rowp) crossrow = 1;
899 linearFitterTracklet.AddPoint(&timeis,ycluster,1);
904 ////////////////////////////////////
905 // Do the straight line fit now
906 ///////////////////////////////////
908 linearFitterTracklet.Eval();
909 linearFitterTracklet.GetParameters(pars);
910 pointError = TMath::Sqrt(linearFitterTracklet.GetChisquare()/nbli);
911 errorpar = linearFitterTracklet.GetParError(1)*pointError;
914 ////////////////////////////////
916 ///////////////////////////////
920 if ( !fDebugStreamer ) {
922 TDirectory *backup = gDirectory;
923 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
924 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
928 Int_t layer = GetLayer(fDetectorPreviousTrack);
930 (* fDebugStreamer) << "FindP1TrackPHtrackletV1"<<
931 //"snpright="<<snpright<<
932 "nbclusters="<<nbclusters<<
933 "detector="<<fDetectorPreviousTrack<<
941 "crossrow="<<crossrow<<
942 "errorpar="<<errorpar<<
943 "pointError="<<pointError<<
948 /////////////////////////
950 ////////////////////////
952 if(nbclusters < fNumberClusters) return kFALSE;
953 if(nbclusters > fNumberClustersf) return kFALSE;
954 if(pointError >= 0.1) return kFALSE;
955 if(crossrow == 1) return kFALSE;
957 ///////////////////////
959 //////////////////////
962 //Add to the linear fitter of the detector
963 if( TMath::Abs(snp) < 1.){
964 Double_t x = tnp-dzdx*tnt;
965 (GetLinearFitter(fDetectorPreviousTrack,kTRUE))->AddPoint(&x,dydt);
966 if(fLinearFitterDebugOn) {
967 fLinearVdriftFit->Update(fDetectorPreviousTrack,x,pars[1]);
969 fEntriesLinearFitter[fDetectorPreviousTrack]++;
975 //____________Offine tracking in the AliTRDtracker_____________________________
976 Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, Int_t index1)
979 // PRF width calibration
980 // Assume a Gaussian shape: determinate the position of the three pad clusters
981 // Fit with a straight line
982 // Take the fitted values for all the clusters (3 or 2 pad clusters)
983 // Fill the PRF as function of angle of the track
988 //////////////////////////
990 /////////////////////////
991 Int_t npoints = index1-index0; // number of total points
992 Int_t nb3pc = 0; // number of three pads clusters used for fit
993 Int_t detector = ((AliTRDcluster *) t->GetCluster(index0))->GetDetector(); // detector
994 // To see the difference due to the fit
995 Double_t *padPositions;
996 padPositions = new Double_t[npoints];
997 for(Int_t k = 0; k < npoints; k++){
998 padPositions[k] = 0.0;
1000 // Take the tgl and snp with the track t now
1001 Double_t tgl = t->GetTglPlane(GetLayer(detector)); //dz/dl and not dz/dx
1002 Double_t snp = t->GetSnpPlane(GetLayer(detector)); // sin angle in xy plan
1003 Float_t dzdx = 0.0; // dzdx
1005 if(TMath::Abs(snp) < 1.0){
1006 tnp = snp / (TMath::Sqrt(1-snp*snp));
1007 dzdx = tgl*TMath::Sqrt(1+tnp*tnp);
1010 TLinearFitter fitter(2,"pol1");
1011 fitter.StoreData(kFALSE);
1012 fitter.ClearPoints();
1015 ///////////////////////////
1016 // calcul the tnp group
1017 ///////////////////////////
1018 Bool_t echec = kFALSE;
1019 Double_t shift = 0.0;
1020 //Calculate the shift in x coresponding to this tnp
1021 if(fNgroupprf != 0.0){
1022 shift = -3.0*(fNgroupprf-1)-1.5;
1023 Double_t limithigh = -0.2*(fNgroupprf-1);
1024 if((tnp < (-0.2*fNgroupprf)) || (tnp > (0.2*fNgroupprf))) echec = kTRUE;
1026 while(tnp > limithigh){
1032 if(echec) return kFALSE;
1035 //////////////////////
1037 /////////////////////
1038 for(Int_t k = 0; k < npoints; k++){
1040 AliTRDcluster *cl = (AliTRDcluster *) t->GetCluster(k+index0);
1041 Short_t *signals = cl->GetSignals();
1042 Double_t time = cl->GetPadTime();
1043 //Calculate x if possible
1044 Float_t xcenter = 0.0;
1045 Bool_t echec1 = kTRUE;
1046 if((time<=7) || (time>=21)) continue;
1047 // Center 3 balanced: position with the center of the pad
1048 if ((((Float_t) signals[3]) > 0.0) &&
1049 (((Float_t) signals[2]) > 0.0) &&
1050 (((Float_t) signals[4]) > 0.0)) {
1052 // Security if the denomiateur is 0
1053 if ((((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) /
1054 ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))) != 1.0) {
1055 xcenter = 0.5 * (TMath::Log((Float_t) (((Float_t) signals[4]) / ((Float_t) signals[2]))))
1056 / (TMath::Log(((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3])))
1057 / ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))));
1063 if(TMath::Abs(xcenter) > 0.5) echec = kTRUE;
1065 //if no echec: calculate with the position of the pad
1066 // Position of the cluster
1067 Double_t padPosition = xcenter + cl->GetPadCol();
1068 padPositions[k] = padPosition;
1070 fitter.AddPoint(&time, padPosition,1);
1074 /////////////////////////////
1076 ////////////////////////////
1077 if(nb3pc < 3) return kFALSE;
1080 fitter.GetParameters(line);
1081 Float_t pointError = -1.0;
1082 pointError = TMath::Sqrt(fitter.GetChisquare()/nb3pc);
1084 /////////////////////////////////////////////////////
1085 // Now fill the PRF: second loop over clusters
1086 /////////////////////////////////////////////////////
1087 for(Int_t k = 0; k < npoints; k++){
1089 AliTRDcluster *cl = (AliTRDcluster *) t->GetCluster(k+index0);
1090 Short_t *signals = cl->GetSignals(); // signal
1091 Double_t time = cl->GetPadTime(); // time bin
1092 Float_t padPosTracklet = line[0]+line[1]*time; // reconstruct position from fit
1093 Float_t padPos = cl->GetPadCol(); // middle pad
1094 Double_t dpad = padPosTracklet - padPos; // reconstruct position relative to middle pad from fit
1095 Float_t ycenter = 0.0; // relative center charge
1096 Float_t ymin = 0.0; // relative left charge
1097 Float_t ymax = 0.0; // relative right charge
1099 //Requiere simply two pads clusters at least
1100 if(((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[2]) > 0.0)) ||
1101 ((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[4]) > 0.0))){
1102 Float_t sum = ((Float_t) signals[2]) + ((Float_t) signals[3]) + ((Float_t) signals[4]);
1103 if(sum > 0.0) ycenter = ((Float_t) signals[3])/ sum;
1104 if(sum > 0.0) ymin = ((Float_t) signals[2])/ sum;
1105 if(sum > 0.0) ymax = ((Float_t) signals[4])/ sum;
1109 Int_t rowcl = cl->GetPadRow(); // row of cluster
1110 Int_t colcl = cl->GetPadCol(); // col of cluster
1111 Int_t grouplocal = CalculateCalibrationGroup(2,rowcl,colcl); // calcul the corresponding group
1112 Int_t caligroup = fCalibraMode->GetXbins(2)+ grouplocal; // calcul the corresponding group
1113 Float_t xcl = cl->GetY(); // y cluster
1114 Float_t qcl = cl->GetQ(); // charge cluster
1115 Int_t layer = GetLayer(detector); // layer
1116 Int_t stack = GetStack(detector); // stack
1117 Double_t xdiff = dpad; // reconstructed position constant
1118 Double_t x = dpad; // reconstructed position moved
1119 Float_t ep = pointError; // error of fit
1120 Float_t signal1 = (Float_t)signals[1]; // signal at the border
1121 Float_t signal3 = (Float_t)signals[3]; // signal
1122 Float_t signal2 = (Float_t)signals[2]; // signal
1123 Float_t signal4 = (Float_t)signals[4]; // signal
1124 Float_t signal5 = (Float_t)signals[5]; // signal at the border
1126 //////////////////////////////
1128 /////////////////////////////
1129 if(fDebugLevel > 0){
1130 if ( !fDebugStreamer ) {
1132 TDirectory *backup = gDirectory;
1133 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
1134 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
1140 Float_t y = ycenter;
1141 (* fDebugStreamer) << "HandlePRFtracklet"<<
1142 "caligroup="<<caligroup<<
1143 "detector="<<detector<<
1146 "npoints="<<npoints<<
1155 "padPosition="<<padPositions[k]<<
1156 "padPosTracklet="<<padPosTracklet<<
1161 "signal1="<<signal1<<
1162 "signal2="<<signal2<<
1163 "signal3="<<signal3<<
1164 "signal4="<<signal4<<
1165 "signal5="<<signal5<<
1171 (* fDebugStreamer) << "HandlePRFtracklet"<<
1172 "caligroup="<<caligroup<<
1173 "detector="<<detector<<
1176 "npoints="<<npoints<<
1185 "padPosition="<<padPositions[k]<<
1186 "padPosTracklet="<<padPosTracklet<<
1191 "signal1="<<signal1<<
1192 "signal2="<<signal2<<
1193 "signal3="<<signal3<<
1194 "signal4="<<signal4<<
1195 "signal5="<<signal5<<
1201 (* fDebugStreamer) << "HandlePRFtracklet"<<
1202 "caligroup="<<caligroup<<
1203 "detector="<<detector<<
1206 "npoints="<<npoints<<
1215 "padPosition="<<padPositions[k]<<
1216 "padPosTracklet="<<padPosTracklet<<
1221 "signal1="<<signal1<<
1222 "signal2="<<signal2<<
1223 "signal3="<<signal3<<
1224 "signal4="<<signal4<<
1225 "signal5="<<signal5<<
1231 ////////////////////////////
1233 ///////////////////////////
1234 if(npoints < fNumberClusters) continue;
1235 if(npoints > fNumberClustersf) continue;
1236 if(nb3pc <= 5) continue;
1237 if((time >= 21) || (time < 7)) continue;
1238 if(TMath::Abs(snp) >= 1.0) continue;
1239 if(TMath::Abs(qcl) < 80) continue;
1241 ////////////////////////////
1243 ///////////////////////////
1245 if(TMath::Abs(dpad) < 1.5) {
1246 fPRF2d->Fill(shift+dpad,(caligroup+0.5),ycenter);
1247 fPRF2d->Fill(shift-dpad,(caligroup+0.5),ycenter);
1249 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
1250 fPRF2d->Fill(shift-(dpad+1.0),(caligroup+0.5),ymin);
1251 fPRF2d->Fill(shift+(dpad+1.0),(caligroup+0.5),ymin);
1253 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
1254 fPRF2d->Fill(shift+1.0-dpad,(caligroup+0.5),ymax);
1255 fPRF2d->Fill(shift-1.0+dpad,(caligroup+0.5),ymax);
1259 if(TMath::Abs(dpad) < 1.5) {
1260 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+dpad,ycenter);
1261 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-dpad,ycenter);
1263 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
1264 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-(dpad+1.0),ymin);
1265 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+(dpad+1.0),ymin);
1267 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
1268 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+1.0-dpad,ymax);
1269 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-1.0+dpad,ymax);
1276 //____________Offine tracking in the AliTRDtracker_____________________________
1277 Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, Int_t nbclusters)
1280 // PRF width calibration
1281 // Assume a Gaussian shape: determinate the position of the three pad clusters
1282 // Fit with a straight line
1283 // Take the fitted values for all the clusters (3 or 2 pad clusters)
1284 // Fill the PRF as function of angle of the track
1288 ///////////////////////////////////////////
1289 // Take the parameters of the track
1290 //////////////////////////////////////////
1291 // take now the snp, tnp and tgl from the track
1292 Double_t snp = tracklet->GetSnp(); // sin dy/dx at the end of the chamber
1293 Double_t tnp = 0.0; // dy/dx at the end of the chamber
1294 if( TMath::Abs(snp) < 1.){
1295 tnp = snp / (TMath::Sqrt(1-(snp*snp)));
1297 Double_t tgl = tracklet->GetTgl(); // dz/dl
1298 Double_t dzdx = tgl*TMath::Sqrt(1+tnp*tnp); // dz/dx calculated from dz/dl
1300 //Double_t tnp = tracklet->GetYref(1); // dy/dx at the entrance of the chamber
1301 //Double_t tgl = tracklet->GetZref(1); // dz/dl at the entrance of the chamber
1302 //Double_t dzdx = tgl; //*TMath::Sqrt(1+tnp*tnp); // dz/dx from dz/dl
1303 // at the end with correction due to linear fit
1304 //Double_t tnp = tracklet->GetYfit(1); // dy/dx at the end of the chamber after fit correction
1305 //Double_t tgl = tracklet->GetZfit(1); // dz/dl at the end of the chamber after fit correction
1307 ///////////////////////////////
1308 // Calculate tnp group shift
1309 ///////////////////////////////
1310 Bool_t echec = kFALSE;
1311 Double_t shift = 0.0;
1312 //Calculate the shift in x coresponding to this tnp
1313 if(fNgroupprf != 0.0){
1314 shift = -3.0*(fNgroupprf-1)-1.5;
1315 Double_t limithigh = -0.2*(fNgroupprf-1);
1316 if((tnp < (-0.2*fNgroupprf)) || (tnp > (0.2*fNgroupprf))) echec = kTRUE;
1318 while(tnp > limithigh){
1324 // do nothing if out of tnp range
1325 if(echec) return kFALSE;
1327 ///////////////////////
1329 //////////////////////
1331 Int_t nb3pc = 0; // number of three pads clusters used for fit
1332 Double_t *padPositions; // to see the difference between the fit and the 3 pad clusters position
1333 padPositions = new Double_t[AliTRDseed::knTimebins];
1334 for(Int_t k = 0; k < AliTRDseed::knTimebins; k++){
1335 padPositions[k] = 0.0;
1337 TLinearFitter fitter(2,"pol1"); // TLinearFitter for the linear fit in the drift region
1338 fitter.StoreData(kFALSE);
1339 fitter.ClearPoints();
1341 ////////////////////////////
1342 // loop over the clusters
1343 ////////////////////////////
1344 AliTRDcluster *cl = 0x0;
1345 for(int ic=0; ic<AliTRDseed::knTimebins; ic++){
1346 if(!(cl = tracklet->GetClusters(ic))) continue;
1348 Double_t time = cl->GetPadTime();
1349 if((time<=7) || (time>=21)) continue;
1350 Short_t *signals = cl->GetSignals();
1351 Float_t xcenter = 0.0;
1352 Bool_t echec1 = kTRUE;
1354 /////////////////////////////////////////////////////////////
1355 // Center 3 balanced: position with the center of the pad
1356 /////////////////////////////////////////////////////////////
1357 if ((((Float_t) signals[3]) > 0.0) &&
1358 (((Float_t) signals[2]) > 0.0) &&
1359 (((Float_t) signals[4]) > 0.0)) {
1361 // Security if the denomiateur is 0
1362 if ((((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) /
1363 ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))) != 1.0) {
1364 xcenter = 0.5 * (TMath::Log((Float_t) (((Float_t) signals[4]) / ((Float_t) signals[2]))))
1365 / (TMath::Log(((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3])))
1366 / ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))));
1372 if(TMath::Abs(xcenter) > 0.5) echec1 = kTRUE;
1373 if(echec1) continue;
1375 ////////////////////////////////////////////////////////
1376 //if no echec1: calculate with the position of the pad
1377 // Position of the cluster
1378 // fill the linear fitter
1379 ///////////////////////////////////////////////////////
1380 Double_t padPosition = xcenter + cl->GetPadCol();
1381 padPositions[ic] = padPosition;
1383 fitter.AddPoint(&time, padPosition,1);
1389 //////////////////////////////
1390 // fit with a straight line
1391 /////////////////////////////
1392 if(nb3pc < 3) return kFALSE;
1395 fitter.GetParameters(line);
1396 Float_t pointError = -1.0;
1397 pointError = TMath::Sqrt(fitter.GetChisquare()/nb3pc);
1399 ////////////////////////////////////////////////
1400 // Fill the PRF: Second loop over clusters
1401 //////////////////////////////////////////////
1402 for(int ic=0; ic<AliTRDseed::knTimebins; ic++){
1403 if(!(cl = tracklet->GetClusters(ic))) continue;
1405 Short_t *signals = cl->GetSignals(); // signal
1406 Double_t time = cl->GetPadTime(); // time bin
1407 Float_t padPosTracklet = line[0]+line[1]*time; // reconstruct position from fit
1408 Float_t padPos = cl->GetPadCol(); // middle pad
1409 Double_t dpad = padPosTracklet - padPos; // reconstruct position relative to middle pad from fit
1410 Float_t ycenter = 0.0; // relative center charge
1411 Float_t ymin = 0.0; // relative left charge
1412 Float_t ymax = 0.0; // relative right charge
1414 ////////////////////////////////////////////////////////////////
1415 // Calculate ycenter, ymin and ymax even for two pad clusters
1416 ////////////////////////////////////////////////////////////////
1417 if(((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[2]) > 0.0)) ||
1418 ((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[4]) > 0.0))){
1419 Float_t sum = ((Float_t) signals[2]) + ((Float_t) signals[3]) + ((Float_t) signals[4]);
1420 if(sum > 0.0) ycenter = ((Float_t) signals[3])/ sum;
1421 if(sum > 0.0) ymin = ((Float_t) signals[2])/ sum;
1422 if(sum > 0.0) ymax = ((Float_t) signals[4])/ sum;
1425 /////////////////////////
1426 // Calibration group
1427 ////////////////////////
1428 Int_t rowcl = cl->GetPadRow(); // row of cluster
1429 Int_t colcl = cl->GetPadCol(); // col of cluster
1430 Int_t grouplocal = CalculateCalibrationGroup(2,rowcl,colcl); // calcul the corresponding group
1431 Int_t caligroup = fCalibraMode->GetXbins(2)+ grouplocal; // calcul the corresponding group
1432 Float_t xcl = cl->GetY(); // y cluster
1433 Float_t qcl = cl->GetQ(); // charge cluster
1434 Int_t layer = GetLayer(fDetectorPreviousTrack); // layer
1435 Int_t stack = GetStack(fDetectorPreviousTrack); // stack
1436 Double_t xdiff = dpad; // reconstructed position constant
1437 Double_t x = dpad; // reconstructed position moved
1438 Float_t ep = pointError; // error of fit
1439 Float_t signal1 = (Float_t)signals[1]; // signal at the border
1440 Float_t signal3 = (Float_t)signals[3]; // signal
1441 Float_t signal2 = (Float_t)signals[2]; // signal
1442 Float_t signal4 = (Float_t)signals[4]; // signal
1443 Float_t signal5 = (Float_t)signals[5]; // signal at the border
1445 /////////////////////
1447 ////////////////////
1449 if(fDebugLevel > 0){
1450 if ( !fDebugStreamer ) {
1452 TDirectory *backup = gDirectory;
1453 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
1454 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
1459 Float_t y = ycenter;
1460 (* fDebugStreamer) << "HandlePRFtrackletV1"<<
1461 "caligroup="<<caligroup<<
1462 "detector="<<fDetectorPreviousTrack<<
1465 "npoints="<<nbclusters<<
1474 "padPosition="<<padPositions[ic]<<
1475 "padPosTracklet="<<padPosTracklet<<
1480 "signal1="<<signal1<<
1481 "signal2="<<signal2<<
1482 "signal3="<<signal3<<
1483 "signal4="<<signal4<<
1484 "signal5="<<signal5<<
1490 (* fDebugStreamer) << "HandlePRFtrackletV1"<<
1491 "caligroup="<<caligroup<<
1492 "detector="<<fDetectorPreviousTrack<<
1495 "npoints="<<nbclusters<<
1504 "padPosition="<<padPositions[ic]<<
1505 "padPosTracklet="<<padPosTracklet<<
1510 "signal1="<<signal1<<
1511 "signal2="<<signal2<<
1512 "signal3="<<signal3<<
1513 "signal4="<<signal4<<
1514 "signal5="<<signal5<<
1520 (* fDebugStreamer) << "HandlePRFtrackletV1"<<
1521 "caligroup="<<caligroup<<
1522 "detector="<<fDetectorPreviousTrack<<
1525 "npoints="<<nbclusters<<
1534 "padPosition="<<padPositions[ic]<<
1535 "padPosTracklet="<<padPosTracklet<<
1540 "signal1="<<signal1<<
1541 "signal2="<<signal2<<
1542 "signal3="<<signal3<<
1543 "signal4="<<signal4<<
1544 "signal5="<<signal5<<
1550 /////////////////////
1552 /////////////////////
1553 if(nbclusters < fNumberClusters) continue;
1554 if(nbclusters > fNumberClustersf) continue;
1555 if(nb3pc <= 5) continue;
1556 if((time >= 21) || (time < 7)) continue;
1557 if(TMath::Abs(qcl) < 80) continue;
1558 if( TMath::Abs(snp) > 1.) continue;
1561 ////////////////////////
1563 ///////////////////////
1565 if(TMath::Abs(dpad) < 1.5) {
1566 fPRF2d->Fill(shift+dpad,(caligroup+0.5),ycenter);
1567 fPRF2d->Fill(shift-dpad,(caligroup+0.5),ycenter);
1568 //printf("place %f, ycenter %f\n",(shift+dpad),ycenter);
1570 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
1571 fPRF2d->Fill(shift-(dpad+1.0),(caligroup+0.5),ymin);
1572 fPRF2d->Fill(shift+(dpad+1.0),(caligroup+0.5),ymin);
1574 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
1575 fPRF2d->Fill(shift+1.0-dpad,(caligroup+0.5),ymax);
1576 fPRF2d->Fill(shift-1.0+dpad,(caligroup+0.5),ymax);
1581 if(TMath::Abs(dpad) < 1.5) {
1582 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+dpad,ycenter);
1583 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-dpad,ycenter);
1585 if((ymin > 0.0) && (TMath::Abs(dpad+1.0) < 1.5)) {
1586 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-(dpad+1.0),ymin);
1587 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+(dpad+1.0),ymin);
1589 if((ymax > 0.0) && (TMath::Abs(dpad-1.0) < 1.5)) {
1590 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift+1.0-dpad,ymax);
1591 fCalibraVector->UpdateVectorPRF(fDetectorPreviousTrack,grouplocal,shift-1.0+dpad,ymax);
1594 } // second loop over clusters
1600 ///////////////////////////////////////////////////////////////////////////////////////
1601 // Pad row col stuff: see if masked or not
1602 ///////////////////////////////////////////////////////////////////////////////////////
1603 //_____________________________________________________________________________
1604 void AliTRDCalibraFillHisto::CheckGoodTrackletV1(AliTRDcluster *cl)
1607 // See if we are not near a masked pad
1610 if(cl->IsMasked()) fGoodTracklet = kFALSE;
1614 //_____________________________________________________________________________
1615 void AliTRDCalibraFillHisto::CheckGoodTrackletV0(Int_t detector, Int_t row, Int_t col)
1618 // See if we are not near a masked pad
1621 if (!IsPadOn(detector, col, row)) {
1622 fGoodTracklet = kFALSE;
1626 if (!IsPadOn(detector, col-1, row)) {
1627 fGoodTracklet = kFALSE;
1632 if (!IsPadOn(detector, col+1, row)) {
1633 fGoodTracklet = kFALSE;
1638 //_____________________________________________________________________________
1639 Bool_t AliTRDCalibraFillHisto::IsPadOn(Int_t detector, Int_t row, Int_t col) const
1642 // Look in the choosen database if the pad is On.
1643 // If no the track will be "not good"
1646 // Get the parameter object
1647 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
1649 AliInfo("Could not get calibDB");
1653 if (!cal->IsChamberInstalled(detector) ||
1654 cal->IsChamberMasked(detector) ||
1655 cal->IsPadMasked(detector,col,row)) {
1663 ///////////////////////////////////////////////////////////////////////////////////////
1664 // Calibration groups: calculate the number of groups, localise...
1665 ////////////////////////////////////////////////////////////////////////////////////////
1666 //_____________________________________________________________________________
1667 Int_t AliTRDCalibraFillHisto::CalculateCalibrationGroup(Int_t i, Int_t row, Int_t col) const
1670 // Calculate the calibration group number for i
1673 // Row of the cluster and position in the pad groups
1675 if (fCalibraMode->GetNnZ(i) != 0) {
1676 posr = (Int_t) row / fCalibraMode->GetNnZ(i);
1680 // Col of the cluster and position in the pad groups
1682 if (fCalibraMode->GetNnRphi(i) != 0) {
1683 posc = (Int_t) col / fCalibraMode->GetNnRphi(i);
1686 return posc*fCalibraMode->GetNfragZ(i)+posr;
1689 //____________________________________________________________________________________
1690 Int_t AliTRDCalibraFillHisto::CalculateTotalNumberOfBins(Int_t i)
1693 // Calculate the total number of calibration groups
1697 fCalibraMode->ModePadCalibration(2,i);
1698 fCalibraMode->ModePadFragmentation(0,2,0,i);
1699 fCalibraMode->SetDetChamb2(i);
1700 ntotal += 6 * 18 * fCalibraMode->GetDetChamb2(i);
1701 fCalibraMode->ModePadCalibration(0,i);
1702 fCalibraMode->ModePadFragmentation(0,0,0,i);
1703 fCalibraMode->SetDetChamb0(i);
1704 ntotal += 6 * 4 * 18 * fCalibraMode->GetDetChamb0(i);
1705 AliInfo(Form("Total number of Xbins: %d for i %d",ntotal,i));
1709 //_____________________________________________________________________________
1710 void AliTRDCalibraFillHisto::SetNz(Int_t i, Short_t Nz)
1713 // Set the mode of calibration group in the z direction for the parameter i
1718 fCalibraMode->SetNz(i, Nz);
1721 AliInfo("You have to choose between 0 and 4");
1725 //_____________________________________________________________________________
1726 void AliTRDCalibraFillHisto::SetNrphi(Int_t i, Short_t Nrphi)
1729 // Set the mode of calibration group in the rphi direction for the parameter i
1734 fCalibraMode->SetNrphi(i ,Nrphi);
1737 AliInfo("You have to choose between 0 and 6");
1741 //____________Set the pad calibration variables for the detector_______________
1742 Bool_t AliTRDCalibraFillHisto::LocalisationDetectorXbins(Int_t detector)
1745 // For the detector calcul the first Xbins and set the number of row
1746 // and col pads per calibration groups, the number of calibration
1747 // groups in the detector.
1750 // first Xbins of the detector
1752 fCalibraMode->CalculXBins(detector,0);
1755 fCalibraMode->CalculXBins(detector,1);
1758 fCalibraMode->CalculXBins(detector,2);
1761 // fragmentation of idect
1762 for (Int_t i = 0; i < 3; i++) {
1763 fCalibraMode->ModePadCalibration((Int_t) GetStack(detector),i);
1764 fCalibraMode->ModePadFragmentation((Int_t) GetLayer(detector)
1765 , (Int_t) GetStack(detector)
1766 , (Int_t) GetSector(detector),i);
1772 //_____________________________________________________________________________
1773 void AliTRDCalibraFillHisto::SetNumberGroupsPRF(Short_t numberGroupsPRF)
1776 // Should be between 0 and 6
1779 if ((numberGroupsPRF < 0) || (numberGroupsPRF > 6)) {
1780 AliInfo("The number of groups must be between 0 and 6!");
1783 fNgroupprf = numberGroupsPRF;
1787 ///////////////////////////////////////////////////////////////////////////////////////////
1788 // Per tracklet: store or reset the info, fill the histos with the info
1789 //////////////////////////////////////////////////////////////////////////////////////////
1790 //_____________________________________________________________________________
1791 void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(AliTRDcluster *cl, Double_t dqdl, Int_t *group, Int_t row, Int_t col)
1794 // Store the infos in fAmpTotal, fPHPlace and fPHValue
1795 // Correct from the gain correction before
1798 // time bin of the cluster not corrected
1799 Int_t time = cl->GetPadTime();
1801 //Correct for the gain coefficient used in the database for reconstruction
1802 Float_t correctthegain = fCalDetGain->GetValue(fDetectorPreviousTrack)*fCalROCGain->GetValue(col,row);
1803 Float_t correction = 1.0;
1804 Float_t normalisation = 6.67;
1805 // we divide with gain in AliTRDclusterizer::Transform...
1806 if( correctthegain > 0 ) normalisation /= correctthegain;
1809 // take dd/dl corrected from the angle of the track
1810 correction = dqdl / (normalisation);
1813 // Fill the fAmpTotal with the charge
1815 if((!fLimitChargeIntegration) || (cl->IsInChamber())) fAmpTotal[(Int_t) group[0]] += correction;
1818 // Fill the fPHPlace and value
1820 fPHPlace[time] = group[1];
1821 fPHValue[time] = correction;
1825 //____________Offine tracking in the AliTRDtracker_____________________________
1826 void AliTRDCalibraFillHisto::ResetfVariablestracklet()
1829 // Reset values per tracklet
1832 //Reset good tracklet
1833 fGoodTracklet = kTRUE;
1835 // Reset the fPHValue
1837 //Reset the fPHValue and fPHPlace
1838 for (Int_t k = 0; k < fTimeMax; k++) {
1844 // Reset the fAmpTotal where we put value
1846 for (Int_t k = 0; k < fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0); k++) {
1851 //____________Offine tracking in the AliTRDtracker_____________________________
1852 void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackCH(Int_t nbclusters)
1855 // For the offline tracking or mcm tracklets
1856 // This function will be called in the functions UpdateHistogram...
1857 // to fill the info of a track for the relativ gain calibration
1860 Int_t nb = 0; // Nombre de zones traversees
1861 Int_t fd = -1; // Premiere zone non nulle
1862 Float_t totalcharge = 0.0; // Total charge for the supermodule histo
1864 if(nbclusters < fNumberClusters) return;
1865 if(nbclusters > fNumberClustersf) return;
1868 // See if the track goes through different zones
1869 for (Int_t k = 0; k < fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0); k++) {
1870 if (fAmpTotal[k] > 0.0) {
1871 totalcharge += fAmpTotal[k];
1884 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
1886 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/fRelativeScale);
1887 //fCH2d->Fill(fAmpTotal[fd]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+0.5);
1890 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/fRelativeScale);
1894 if ((fAmpTotal[fd] > 0.0) &&
1895 (fAmpTotal[fd+1] > 0.0)) {
1896 // One of the two very big
1897 if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+1]) {
1899 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/fRelativeScale);
1900 //fCH2d->Fill(fAmpTotal[fd]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+0.5);
1903 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/fRelativeScale);
1906 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
1908 if (fAmpTotal[fd+1] > fProcent*fAmpTotal[fd]) {
1910 FillCH2d(fCalibraMode->GetXbins(0)+fd+1,fAmpTotal[fd+1]/fRelativeScale);
1911 //fCH2d->Fill(fAmpTotal[fd+1]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+1.5);
1914 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd+1,fAmpTotal[fd+1]/fRelativeScale);
1917 fEntriesCH[fCalibraMode->GetXbins(0)+fd+1]++;
1920 if (fCalibraMode->GetNfragZ(0) > 1) {
1921 if (fAmpTotal[fd] > 0.0) {
1922 if ((fd+fCalibraMode->GetNfragZ(0)) < (fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0))) {
1923 if (fAmpTotal[fd+fCalibraMode->GetNfragZ(0)] > 0.0) {
1924 // One of the two very big
1925 if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]) {
1927 FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/fRelativeScale);
1928 //fCH2d->Fill(fAmpTotal[fd]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+0.5);
1931 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/fRelativeScale);
1934 fEntriesCH[fCalibraMode->GetXbins(0)+fd]++;
1936 if (fAmpTotal[fd+fCalibraMode->GetNfragZ(0)] > fProcent*fAmpTotal[fd]) {
1938 FillCH2d(fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0),fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/fRelativeScale);
1939 //fCH2d->Fill(fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0)+0.5);
1942 fEntriesCH[fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0)]++;
1944 fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd+fCalibraMode->GetNfragZ(0),fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/fRelativeScale);
1955 //____________Offine tracking in the AliTRDtracker_____________________________
1956 void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH()
1959 // For the offline tracking or mcm tracklets
1960 // This function will be called in the functions UpdateHistogram...
1961 // to fill the info of a track for the drift velocity calibration
1964 Int_t nb = 1; // Nombre de zones traversees 1, 2 ou plus de 3
1965 Int_t fd1 = -1; // Premiere zone non nulle
1966 Int_t fd2 = -1; // Deuxieme zone non nulle
1967 Int_t k1 = -1; // Debut de la premiere zone
1968 Int_t k2 = -1; // Debut de la seconde zone
1969 Int_t nbclusters = 0; // number of clusters
1973 // See if the track goes through different zones
1974 for (Int_t k = 0; k < fTimeMax; k++) {
1975 if (fPHValue[k] > 0.0) {
1981 if (fPHPlace[k] != fd1) {
1987 if (fPHPlace[k] != fd2) {
1994 if(nbclusters < fNumberClusters) return;
1995 if(nbclusters > fNumberClustersf) return;
2001 for (Int_t i = 0; i < fTimeMax; i++) {
2003 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2004 //printf("Fill the time bin %d with %f\n",i,fPHValue[i]);
2007 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2012 if ((fd1 == fd2+1) ||
2014 // One of the two fast all the think
2015 if (k2 > (k1+fDifference)) {
2016 //we choose to fill the fd1 with all the values
2018 for (Int_t i = 0; i < fTimeMax; i++) {
2020 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2023 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2027 if ((k2+fDifference) < fTimeMax) {
2028 //we choose to fill the fd2 with all the values
2030 for (Int_t i = 0; i < fTimeMax; i++) {
2032 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2035 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2040 // Two zones voisines sinon rien!
2041 if (fCalibraMode->GetNfragZ(1) > 1) {
2043 if ((fd1+fCalibraMode->GetNfragZ(1)) < (fCalibraMode->GetNfragZ(1)*fCalibraMode->GetNfragRphi(1))) {
2044 if (fd2 == (fd1+fCalibraMode->GetNfragZ(1))) {
2045 // One of the two fast all the think
2046 if (k2 > (k1+fDifference)) {
2047 //we choose to fill the fd1 with all the values
2049 for (Int_t i = 0; i < fTimeMax; i++) {
2051 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2054 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2058 if ((k2+fDifference) < fTimeMax) {
2059 //we choose to fill the fd2 with all the values
2061 for (Int_t i = 0; i < fTimeMax; i++) {
2063 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2066 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2072 // Two zones voisines sinon rien!
2074 if ((fd1 - fCalibraMode->GetNfragZ(1)) >= 0) {
2075 if (fd2 == (fd1 - fCalibraMode->GetNfragZ(1))) {
2076 // One of the two fast all the think
2077 if (k2 > (k1 + fDifference)) {
2078 //we choose to fill the fd1 with all the values
2080 for (Int_t i = 0; i < fTimeMax; i++) {
2082 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]);
2085 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]);
2089 if ((k2+fDifference) < fTimeMax) {
2090 //we choose to fill the fd2 with all the values
2092 for (Int_t i = 0; i < fTimeMax; i++) {
2094 fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]);
2097 fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]);
2108 //////////////////////////////////////////////////////////////////////////////////////////
2109 // DAQ process functions
2110 /////////////////////////////////////////////////////////////////////////////////////////
2111 //_____________________________________________________________________
2112 Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bool_t nocheck)
2115 // Event Processing loop - AliTRDrawStreamBase
2116 // TestBeam 2007 version
2117 // 0 timebin problem
2121 // Same algorithm as TestBeam but different reader
2124 Int_t withInput = 1;
2126 Double_t phvalue[16][144][36];
2127 for(Int_t k = 0; k < 36; k++){
2128 for(Int_t j = 0; j < 16; j++){
2129 for(Int_t c = 0; c < 144; c++){
2130 phvalue[j][c][k] = 0.0;
2135 fDetectorPreviousTrack = -1;
2138 Int_t nbtimebin = 0;
2139 Int_t baseline = 10;
2146 while (rawStream->Next()) {
2148 Int_t idetector = rawStream->GetDet(); // current detector
2149 Int_t imcm = rawStream->GetMCM(); // current MCM
2150 Int_t irob = rawStream->GetROB(); // current ROB
2152 //printf("Detector %d\n",idetector);
2154 if((fDetectorPreviousTrack != idetector) && (fDetectorPreviousTrack != -1)){
2157 withInput = TMath::Max(FillDAQ(phvalue),withInput);
2161 for(Int_t k = 0; k < 36; k++){
2162 for(Int_t j = 0; j < 16; j++){
2163 for(Int_t c = 0; c < 144; c++){
2164 phvalue[j][c][k] = 0.0;
2170 fDetectorPreviousTrack = idetector;
2171 fMCMPrevious = imcm;
2172 fROBPrevious = irob;
2174 nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
2175 if(nbtimebin == 0) return 0;
2176 if((fTimeMax != 0) && (nbtimebin != fTimeMax)) return 0;
2177 fTimeMax = nbtimebin;
2179 //baseline = rawStream->GetCommonAdditive(); // common additive baseline
2180 fNumberClustersf = fTimeMax;
2181 fNumberClusters = (Int_t)(0.6*fTimeMax);
2184 Int_t *signal = rawStream->GetSignals(); // current ADC signal
2185 Int_t col = rawStream->GetCol();
2186 Int_t row = rawStream->GetRow();
2189 //printf("detector %d, signal[0] %d, signal[1] %d, signal[2] %d, baseline %d\n",idetector,signal[0],signal[1],signal[2], baseline);
2192 for(Int_t itime = 0; itime < nbtimebin; itime++){
2193 phvalue[row][col][itime] = signal[itime]-baseline;
2197 // fill the last one
2198 if(fDetectorPreviousTrack != -1){
2201 withInput = TMath::Max(FillDAQ(phvalue),withInput);
2204 for(Int_t k = 0; k < 36; k++){
2205 for(Int_t j = 0; j < 16; j++){
2206 for(Int_t c = 0; c < 144; c++){
2207 phvalue[j][c][k] = 0.0;
2216 while (rawStream->Next()) {
2218 Int_t idetector = rawStream->GetDet(); // current detector
2219 Int_t imcm = rawStream->GetMCM(); // current MCM
2220 Int_t irob = rawStream->GetROB(); // current ROB
2222 //printf("Detector %d\n",idetector);
2224 if((fDetectorPreviousTrack != idetector) && (fDetectorPreviousTrack != -1)){
2227 withInput = TMath::Max(FillDAQ(phvalue),withInput);
2230 for(Int_t k = 0; k < 36; k++){
2231 for(Int_t j = 0; j < 16; j++){
2232 for(Int_t c = 0; c < 144; c++){
2233 phvalue[j][c][k] = 0.0;
2239 fDetectorPreviousTrack = idetector;
2240 fMCMPrevious = imcm;
2241 fROBPrevious = irob;
2243 //baseline = rawStream->GetCommonAdditive(); // common baseline
2245 fTimeMax = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
2246 fNumberClustersf = fTimeMax;
2247 fNumberClusters = (Int_t)(0.6*fTimeMax);
2248 Int_t *signal = rawStream->GetSignals(); // current ADC signal
2249 Int_t col = rawStream->GetCol();
2250 Int_t row = rawStream->GetRow();
2253 //printf("detector %d, signal[0] %d, signal[1] %d, signal[2] %d, baseline %d\n",idetector,signal[0],signal[1],signal[2], baseline);
2255 for(Int_t itime = 0; itime < fTimeMax; itime++){
2256 phvalue[row][col][itime] = signal[itime]-baseline;
2260 // fill the last one
2261 if(fDetectorPreviousTrack != -1){
2264 withInput = TMath::Max(FillDAQ(phvalue),withInput);
2267 for(Int_t k = 0; k < 36; k++){
2268 for(Int_t j = 0; j < 16; j++){
2269 for(Int_t c = 0; c < 144; c++){
2270 phvalue[j][c][k] = 0.0;
2280 //_____________________________________________________________________
2281 Int_t AliTRDCalibraFillHisto::ProcessEventDAQV1(AliTRDrawStreamBase *rawStream, Bool_t nocheck)
2284 // Event Processing loop - AliTRDrawStreamBase
2285 // Use old AliTRDmcmtracklet code
2286 // 0 timebin problem
2290 // Algorithm with mcm tracklet
2293 Int_t withInput = 1;
2295 AliTRDmcm mcm = AliTRDmcm(0);
2296 AliTRDtrigParam *param = AliTRDtrigParam::Instance();
2297 rawStream->SetSharedPadReadout(kTRUE);
2299 fDetectorPreviousTrack = -1;
2303 Int_t nbtimebin = 0;
2304 Int_t baseline = 10;
2311 while (rawStream->Next()) {
2313 Int_t idetector = rawStream->GetDet(); // current detector
2314 Int_t imcm = rawStream->GetMCM(); // current MCM
2315 Int_t irob = rawStream->GetROB(); // current ROB
2316 row = rawStream->GetRow();
2319 if(((fDetectorPreviousTrack != idetector) || (fMCMPrevious != imcm) || (fROBPrevious != irob)) && (fDetectorPreviousTrack != -1)){
2322 withInput = TMath::Max(FillDAQ(&mcm),withInput);
2328 mcm.SetChaId(idetector);
2330 mcm.SetColRange(0,21);
2333 if(fDetectorPreviousTrack == -1){
2336 mcm.SetChaId(idetector);
2338 mcm.SetColRange(0,21);
2342 fDetectorPreviousTrack = idetector;
2343 fMCMPrevious = imcm;
2344 fROBPrevious = irob;
2346 nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
2347 if(nbtimebin == 0) return 0;
2348 if((fTimeMax != 0) && (nbtimebin != fTimeMax)) return 0;
2349 fTimeMax = nbtimebin;
2350 fNumberClustersf = fTimeMax;
2351 fNumberClusters = (Int_t)(0.6*fTimeMax);
2352 param->SetTimeRange(0,fTimeMax);
2354 //baseline = rawStream->GetCommonAdditive(); // common additive baseline
2356 Int_t *signal = rawStream->GetSignals(); // current ADC signal
2357 Int_t adc = rawStream->GetADC();
2360 //printf("detector %d, signal[0] %d, signal[1] %d, signal[2] %d, baseline %d\n",idetector,signal[0],signal[1],signal[2], baseline);
2362 for(Int_t itime = 0; itime < nbtimebin; itime++){
2363 mcm.SetADC(adc,itime,(signal[itime]-baseline));
2367 // fill the last one
2368 if(fDetectorPreviousTrack != -1){
2371 withInput = TMath::Max(FillDAQ(&mcm),withInput);
2376 mcm.SetRobId(fROBPrevious);
2377 mcm.SetChaId(fDetectorPreviousTrack);
2379 mcm.SetColRange(0,21);
2386 while (rawStream->Next()) {
2388 Int_t idetector = rawStream->GetDet(); // current detector
2389 Int_t imcm = rawStream->GetMCM(); // current MCM
2390 Int_t irob = rawStream->GetROB(); // current ROB
2391 row = rawStream->GetRow();
2393 if(((fDetectorPreviousTrack != idetector) || (fMCMPrevious != imcm) || (fROBPrevious != irob)) && (fDetectorPreviousTrack != -1)){
2396 withInput = TMath::Max(FillDAQ(&mcm),withInput);
2402 mcm.SetChaId(idetector);
2404 mcm.SetColRange(0,21);
2408 fDetectorPreviousTrack = idetector;
2409 fMCMPrevious = imcm;
2410 fROBPrevious = irob;
2412 //baseline = rawStream->GetCommonAdditive(); // common baseline
2414 fTimeMax = rawStream->GetNumberOfTimeBins(); // number of time bins read from data
2415 fNumberClustersf = fTimeMax;
2416 fNumberClusters = (Int_t)(0.6*fTimeMax);
2417 param->SetTimeRange(0,fTimeMax);
2418 Int_t *signal = rawStream->GetSignals(); // current ADC signal
2419 Int_t adc = rawStream->GetADC();
2422 //printf("detector %d, signal[0] %d, signal[1] %d, signal[2] %d, baseline %d\n",idetector,signal[0],signal[1],signal[2], baseline);
2424 for(Int_t itime = 0; itime < fTimeMax; itime++){
2425 mcm.SetADC(adc,itime,(signal[itime]-baseline));
2429 // fill the last one
2430 if(fDetectorPreviousTrack != -1){
2433 withInput = TMath::Max(FillDAQ(&mcm),withInput);
2437 mcm.SetRobId(fROBPrevious);
2438 mcm.SetChaId(fDetectorPreviousTrack);
2440 mcm.SetColRange(0,21);
2448 //_____________________________________________________________________
2449 Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliRawReader *rawReader, Bool_t nocheck)
2452 // Event processing loop - AliRawReader
2453 // Testbeam 2007 version
2456 AliTRDrawStreamBase rawStream(rawReader);
2458 rawReader->Select("TRD");
2460 return ProcessEventDAQ(&rawStream, nocheck);
2463 //_________________________________________________________________________
2464 Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(
2466 eventHeaderStruct *event,
2469 eventHeaderStruct* /*event*/,
2476 // process date event
2477 // Testbeam 2007 version
2480 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
2481 Int_t result=ProcessEventDAQ(rawReader, nocheck);
2485 Fatal("AliTRDCalibraFillHisto", "this class was compiled without DATE");
2490 //_____________________________________________________________________
2491 Int_t AliTRDCalibraFillHisto::ProcessEventDAQV1(AliRawReader *rawReader, Bool_t nocheck)
2494 // Event processing loop - AliRawReader
2495 // use the old mcm traklet code
2498 AliTRDrawStreamBase rawStream(rawReader);
2500 rawReader->Select("TRD");
2502 return ProcessEventDAQV1(&rawStream, nocheck);
2504 //_________________________________________________________________________
2505 Int_t AliTRDCalibraFillHisto::ProcessEventDAQV1(
2507 eventHeaderStruct *event,
2510 eventHeaderStruct* /*event*/,
2517 // process date event
2518 // use the old mcm tracklet code
2521 AliRawReader *rawReader = new AliRawReaderDate((void*)event);
2522 Int_t result=ProcessEventDAQV1(rawReader, nocheck);
2526 Fatal("AliTRDCalibraFillHisto", "this class was compiled without DATE");
2531 //////////////////////////////////////////////////////////////////////////////
2532 // Routine inside the DAQ process
2533 /////////////////////////////////////////////////////////////////////////////
2534 //_______________________________________________________________________
2535 Int_t AliTRDCalibraFillHisto::FillDAQ(AliTRDmcm *mcm){
2538 // Return 2 if some tracklets are found and used, 1 if nothing
2545 for (Int_t iSeed = 0; iSeed < 4; iSeed++) {
2547 if (mcm->GetSeedCol()[iSeed] < 0) {
2551 nbev += TestTracklet(mcm->GetChaId(),mcm->GetRow(),iSeed,mcm);
2556 if(nbev > 0) nbev = 2;
2562 //__________________________________________________________________________
2563 Int_t AliTRDCalibraFillHisto::TestTracklet( Int_t idet, Int_t row, Int_t iSeed, AliTRDmcm *mcm){
2566 // Build the tracklet and return if the tracklet if finally used or not (1/0)
2571 AliTRDmcmTracklet mcmtracklet = AliTRDmcmTracklet();
2572 //mcmtracklet.Reset();
2573 mcmtracklet.SetDetector(idet);
2574 mcmtracklet.SetRow(row);
2575 mcmtracklet.SetN(0);
2577 Int_t iCol, iCol1, iCol2, track[3];
2578 iCol = mcm->GetSeedCol()[iSeed]; // 0....20 (MCM)
2579 mcm->GetColRange(iCol1,iCol2); // range in the pad plane
2582 for (Int_t iTime = 0; iTime < fTimeMax; iTime++) {
2584 amp[0] = mcm->GetADC(iCol-1,iTime);
2585 amp[1] = mcm->GetADC(iCol ,iTime);
2586 amp[2] = mcm->GetADC(iCol+1,iTime);
2588 if(mcm->IsCluster(iCol,iTime)) {
2590 mcmtracklet.AddCluster(iCol+iCol1,iTime,amp,track);
2593 else if ((iCol+1+1) < 21) {
2595 amp[0] = mcm->GetADC(iCol-1+1,iTime);
2596 amp[1] = mcm->GetADC(iCol +1,iTime);
2597 amp[2] = mcm->GetADC(iCol+1+1,iTime);
2599 if(mcm->IsCluster(iCol+1,iTime)) {
2601 mcmtracklet.AddCluster(iCol+1+iCol1,iTime,amp,track);
2610 nbev = UpdateHistogramcm(&mcmtracklet);
2615 //____________Online trackling in AliTRDtrigger________________________________
2616 Int_t AliTRDCalibraFillHisto::UpdateHistogramcm(AliTRDmcmTracklet *trk)
2619 // Return if the tracklet is finally used or not (1/0) for calibration
2624 //fGoodTracklet = kTRUE;
2626 // Localisation of the Xbins involved
2627 Int_t idect = trk->GetDetector();
2628 Int_t idectrue = trk->GetDetector();
2631 Int_t nbclusters = trk->GetNclusters();
2633 // Eventuelle correction due to track angle in z direction
2634 Float_t correction = 1.0;
2635 if (fMcmCorrectAngle) {
2636 Float_t z = trk->GetRowz();
2637 Float_t r = trk->GetTime0();
2638 correction = r / TMath::Sqrt((r*r+z*z));
2642 Int_t row = trk->GetRow();
2645 // Boucle sur les clusters
2646 // Condition on number of cluster: don't come from the middle of the detector
2649 for(Int_t k =0; k < 36; k++) amph[k]=0.0;
2650 Double_t ampTotal = 0.0;
2652 for (Int_t icl = 0; icl < trk->GetNclusters(); icl++) {
2654 Float_t amp[3] = { 0.0, 0.0, 0.0 };
2655 Int_t time = trk->GetClusterTime(icl);
2656 Int_t col = trk->GetClusterCol(icl);
2658 //CheckGoodTrackletV0(idect,row,col);
2660 amp[0] = trk->GetClusterADC(icl)[0] * correction;
2661 amp[1] = trk->GetClusterADC(icl)[1] * correction;
2662 amp[2] = trk->GetClusterADC(icl)[2] * correction;
2664 ampTotal += (Float_t) (amp[0]+amp[1]+amp[2]);
2665 amph[time]=amp[0]+amp[1]+amp[2];
2667 if(fDebugLevel > 0){
2668 if ( !fDebugStreamer ) {
2670 TDirectory *backup = gDirectory;
2671 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
2672 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2675 Double_t amp0 = amp[0];
2676 Double_t amp1 = amp[1];
2677 Double_t amp2 = amp[2];
2679 (* fDebugStreamer) << "UpdateHistogramcm0"<<
2680 "nbclusters="<<nbclusters<<
2687 "detector="<<idectrue<<
2691 } // Boucle clusters
2693 if((amph[0] > 100.0) || (!fGoodTracklet) || (trk->GetNclusters() < fNumberClusters) || (trk->GetNclusters() > fNumberClustersf)) used = 0;
2696 for(Int_t k = 0; k < fTimeMax; k++) UpdateDAQ(idect,0,0,k,amph[k],fTimeMax);
2697 //((TH2I *)GetCH2d()->Fill(ampTotal/30.0,idect));
2701 if(fDebugLevel > 0){
2702 if ( !fDebugStreamer ) {
2704 TDirectory *backup = gDirectory;
2705 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
2706 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2709 Double_t amph0 = amph[0];
2710 Double_t amphlast = amph[fTimeMax-1];
2711 Double_t rms = TMath::RMS(fTimeMax,amph);
2712 Int_t goodtracklet = (Int_t) fGoodTracklet;
2714 (* fDebugStreamer) << "UpdateHistogramcm1"<<
2715 "nbclusters="<<nbclusters<<
2716 "ampTotal="<<ampTotal<<
2718 "detector="<<idectrue<<
2720 "amphlast="<<amphlast<<
2721 "goodtracklet="<<goodtracklet<<
2729 //_______________________________________________________________________
2730 Int_t AliTRDCalibraFillHisto::FillDAQ(Double_t phvalue[16][144][36]){
2733 // Look for the maximum by collapsing over the time
2734 // Sum over four pad col and two pad row
2740 Int_t idect = fDetectorPreviousTrack;
2741 //printf("Enter Detector %d\n",fDetectorPreviousTrack);
2743 for(Int_t tb = 0; tb < 36; tb++){
2747 //fGoodTracklet = kTRUE;
2748 //fDetectorPreviousTrack = 0;
2751 ///////////////////////////
2753 /////////////////////////
2757 Double_t integralMax = -1;
2759 for (Int_t ir = 1; ir <= 15; ir++)
2761 for (Int_t ic = 2; ic <= 142; ic++)
2763 Double_t integral = 0;
2764 for (Int_t ishiftR = 0; ishiftR < 2; ishiftR++)
2766 for (Int_t ishiftC = -2; ishiftC < 2; ishiftC++)
2768 if (ir + ishiftR >= 1 && ir + ishiftR <= 16 &&
2769 ic + ishiftC >= 1 && ic + ishiftC <= 144)
2772 for(Int_t tb = 0; tb< fTimeMax; tb++){
2773 integral += phvalue[ir + ishiftR-1][ic + ishiftC-1][tb];
2779 if (integralMax < integral)
2783 integralMax = integral;
2784 } // check max integral
2788 //printf("imaxRow %d, imaxCol %d, fTimeMax %d, integralMax %f\n",imaxRow,imaxCol,fTimeMax, integralMax);
2790 if((imaxRow == 0) || (imaxCol == 0)) {
2794 //CheckGoodTrackletV0(fDetectorPreviousTrack,imaxRow,imaxCol);
2795 //if(!fGoodTracklet) used = 1;;
2797 // /////////////////////////////////////////////////////
2798 // sum ober 2 row and 4 pad cols for each time bins
2799 // ////////////////////////////////////////////////////
2802 for (Int_t ir = imaxRow - 1; ir < imaxRow + 1; ir++)
2804 for (Int_t ic = imaxCol - 2; ic < imaxCol + 2; ic++)
2806 for(Int_t it = 0; it < fTimeMax; it++){
2807 sum[it] += phvalue[ir][ic][it];
2813 Double_t sumcharge = 0.0;
2814 for(Int_t it = 0; it < fTimeMax; it++){
2815 sumcharge += sum[it];
2816 if(sum[it] > 20.0) nbcl++;
2820 /////////////////////////////////////////////////////////
2822 ////////////////////////////////////////////////////////
2823 if(fDebugLevel > 0){
2824 if ( !fDebugStreamer ) {
2826 TDirectory *backup = gDirectory;
2827 fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root");
2828 if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
2831 Double_t amph0 = sum[0];
2832 Double_t amphlast = sum[fTimeMax-1];
2833 Double_t rms = TMath::RMS(fTimeMax,sum);
2834 Int_t goodtracklet = (Int_t) fGoodTracklet;
2835 for(Int_t it = 0; it < fTimeMax; it++){
2836 Double_t clustera = sum[it];
2838 (* fDebugStreamer) << "FillDAQa"<<
2839 "ampTotal="<<sumcharge<<
2842 "detector="<<idect<<
2844 "amphlast="<<amphlast<<
2845 "goodtracklet="<<goodtracklet<<
2846 "clustera="<<clustera<<
2853 ////////////////////////////////////////////////////////
2855 ///////////////////////////////////////////////////////
2856 if(sum[0] > 100.0) used = 1;
2857 if(nbcl < fNumberClusters) used = 1;
2858 if(nbcl > fNumberClustersf) used = 1;
2860 //if(fDetectorPreviousTrack == 15){
2861 // printf("rms %f and first time bin %f\n",TMath::RMS(fTimeMax,sum),sum[0]);
2863 //if((TMath::RMS(fTimeMax,sum) <= 10.0) && (sum[0] > 200.0)) return 1;
2865 for(Int_t it = 0; it < fTimeMax; it++){
2866 UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax);
2870 //((TH2I *)GetCH2d()->Fill(sumcharge/30.0,fDetectorPreviousTrack));
2872 //printf("Pass Detector %d\n",fDetectorPreviousTrack);
2879 //____________Online trackling in AliTRDtrigger________________________________
2880 Bool_t AliTRDCalibraFillHisto::UpdateDAQ(Int_t det, Int_t /*row*/, Int_t /*col*/, Int_t timebin, Float_t signal, Int_t nbtimebins)
2884 // Fill a simple average pulse height
2888 ((TProfile2D *)GetPH2d(nbtimebins,fSf))->Fill((Float_t) timebin/fSf,det+0.5,(Float_t) signal);
2894 //____________Write_____________________________________________________
2895 //_____________________________________________________________________
2896 void AliTRDCalibraFillHisto::Write2d(const Char_t *filename, Bool_t append)
2899 // Write infos to file
2903 if ( fDebugStreamer ) {
2904 delete fDebugStreamer;
2905 fDebugStreamer = 0x0;
2908 AliInfo(Form("Numbertrack: %d Numberusedch[0]: %d, Numberusedch[1]: %d Numberusedph[0]: %d, Numberusedph[1]: %d"
2913 ,fNumberUsedPh[1]));
2915 TDirectory *backup = gDirectory;
2921 option = "recreate";
2923 TFile f(filename,option.Data());
2925 TStopwatch stopwatch;
2928 f.WriteTObject(fCalibraVector);
2933 f.WriteTObject(fCH2d);
2938 f.WriteTObject(fPH2d);
2943 f.WriteTObject(fPRF2d);
2946 if(fLinearFitterOn){
2947 AnalyseLinearFitter();
2948 f.WriteTObject(fLinearVdriftFit);
2953 if ( backup ) backup->cd();
2955 AliInfo(Form("Execution time Write2d: R:%.2fs C:%.2fs"
2956 ,stopwatch.RealTime(),stopwatch.CpuTime()));
2958 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
2960 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
2961 //___________________________________________probe the histos__________________________________________________
2962 Double_t *AliTRDCalibraFillHisto::StatH(TH2 *h, Int_t i)
2965 // Check the number of stats in h, 0 is TH2I 1 is TProfile2D
2966 // debug mode with 2 for TH2I and 3 for TProfile2D
2967 // It gives a pointer to a Double_t[7] with the info following...
2968 // [0] : number of calibration groups with entries
2969 // [1] : minimal number of entries found
2970 // [2] : calibration group number of the min
2971 // [3] : maximal number of entries found
2972 // [4] : calibration group number of the max
2973 // [5] : mean number of entries found
2974 // [6] : mean relative error
2977 Double_t *info = new Double_t[7];
2979 // Number of Xbins (detectors or groups of pads)
2980 Int_t nbins = h->GetNbinsY(); //number of calibration groups
2981 Int_t nxbins = h->GetNbinsX(); //number of bins per histo
2984 Double_t nbwe = 0; //number of calibration groups with entries
2985 Double_t minentries = 0; //minimal number of entries found
2986 Double_t maxentries = 0; //maximal number of entries found
2987 Double_t placemin = 0; //calibration group number of the min
2988 Double_t placemax = -1; //calibration group number of the max
2989 Double_t meanstats = 0.0; //mean number of entries over the calibration group with at least ome entry
2990 Double_t meanrelativerror = 0.0; //mean relativ error in the TProfile2D
2992 Double_t counter = 0;
2995 TH1F *nbEntries = 0x0;//distribution of the number of entries
2996 TH1F *nbEntriesPerGroup = 0x0;//Number of entries per group
2997 TProfile *nbEntriesPerSp = 0x0;//Number of entries for one supermodule
2999 // Beginning of the loop over the calibration groups
3000 for (Int_t idect = 0; idect < nbins; idect++) {
3002 TH1I *projch = (TH1I *) h->ProjectionX("projch",idect+1,idect+1,(Option_t *)"e");
3003 projch->SetDirectory(0);
3005 // Number of entries for this calibration group
3006 Double_t nentries = 0.0;
3008 for (Int_t k = 0; k < nxbins; k++) {
3009 nentries += h->GetBinContent(h->GetBin(k+1,idect+1));
3013 for (Int_t k = 0; k < nxbins; k++) {
3014 nentries += ((TProfile2D *)h)->GetBinEntries(h->GetBin(k+1,idect+1));
3015 if(h->GetBinContent(h->GetBin(k+1,idect+1)) != 0) {
3016 meanrelativerror += (h->GetBinError(h->GetBin(k+1,idect+1))/(TMath::Abs(h->GetBinContent(h->GetBin(k+1,idect+1)))));
3024 if((!((Bool_t)nbEntries)) && (nentries > 0)){
3025 nbEntries = new TH1F("Number of entries","Number of entries"
3026 ,100,(Int_t)nentries/2,nentries*2);
3027 nbEntries->SetDirectory(0);
3028 nbEntriesPerGroup = new TH1F("Number of entries per group","Number of entries per group"
3030 nbEntriesPerGroup->SetDirectory(0);
3031 nbEntriesPerSp = new TProfile("Number of entries per supermodule","Number of entries per supermodule"
3032 ,(Int_t)(nbins/18),0,(Int_t)(nbins/18));
3033 nbEntriesPerSp->SetDirectory(0);
3036 if(nentries > 0) nbEntries->Fill(nentries);
3037 nbEntriesPerGroup->Fill(idect+0.5,nentries);
3038 nbEntriesPerSp->Fill((idect%((Int_t)(nbins/18)))+0.5,nentries);
3043 if(nentries > maxentries){
3044 maxentries = nentries;
3048 minentries = nentries;
3050 if(nentries < minentries){
3051 minentries = nentries;
3057 meanstats += nentries;
3059 }//calibration groups loop
3061 if(nbwe > 0) meanstats /= nbwe;
3062 if(counter > 0) meanrelativerror /= counter;
3064 AliInfo(Form("There are %f calibration groups with entries",nbwe));
3065 AliInfo(Form("The minimum number of entries is %f for the group %f",minentries,placemin));
3066 AliInfo(Form("The maximum number of entries is %f for the group %f",maxentries,placemax));
3067 AliInfo(Form("The mean number of entries is %f",meanstats));
3068 if((i%2) == 1) AliInfo(Form("The mean relative error is %f",meanrelativerror));
3071 info[1] = minentries;
3073 info[3] = maxentries;
3075 info[5] = meanstats;
3076 info[6] = meanrelativerror;
3079 gStyle->SetPalette(1);
3080 gStyle->SetOptStat(1111);
3081 gStyle->SetPadBorderMode(0);
3082 gStyle->SetCanvasColor(10);
3083 gStyle->SetPadLeftMargin(0.13);
3084 gStyle->SetPadRightMargin(0.01);
3085 TCanvas *stat = new TCanvas("stat","",50,50,600,800);
3088 nbEntries->Draw("");
3090 nbEntriesPerSp->SetStats(0);
3091 nbEntriesPerSp->Draw("");
3092 TCanvas *stat1 = new TCanvas("stat1","",50,50,600,800);
3094 nbEntriesPerGroup->SetStats(0);
3095 nbEntriesPerGroup->Draw("");
3101 //____________________________________________________________________________
3102 Double_t *AliTRDCalibraFillHisto::GetMeanMedianRMSNumberCH()
3105 // Return a Int_t[4] with:
3106 // 0 Mean number of entries
3107 // 1 median of number of entries
3108 // 2 rms of number of entries
3109 // 3 number of group with entries
3112 Double_t *stat = new Double_t[4];
3115 Int_t nbofgroups = CalculateTotalNumberOfBins(0);
3116 Double_t *weight = new Double_t[nbofgroups];
3117 Int_t *nonul = new Int_t[nbofgroups];
3119 for(Int_t k = 0; k < nbofgroups; k++){
3120 if(fEntriesCH[k] > 0) {
3122 nonul[(Int_t)stat[3]] = fEntriesCH[k];
3125 else weight[k] = 0.0;
3127 stat[0] = TMath::Mean(nbofgroups,fEntriesCH,weight);
3128 stat[1] = TMath::Median(nbofgroups,fEntriesCH,weight);
3129 stat[2] = TMath::RMS((Int_t)stat[3],nonul);
3134 //____________________________________________________________________________
3135 Double_t *AliTRDCalibraFillHisto::GetMeanMedianRMSNumberLinearFitter() const
3138 // Return a Int_t[4] with:
3139 // 0 Mean number of entries
3140 // 1 median of number of entries
3141 // 2 rms of number of entries
3142 // 3 number of group with entries
3145 Double_t *stat = new Double_t[4];
3148 Int_t nbofgroups = 540;
3149 Double_t *weight = new Double_t[nbofgroups];
3150 Int_t *nonul = new Int_t[nbofgroups];
3152 for(Int_t k = 0; k < nbofgroups; k++){
3153 if(fEntriesLinearFitter[k] > 0) {
3155 nonul[(Int_t) stat[3]] = fEntriesLinearFitter[k];
3158 else weight[k] = 0.0;
3160 stat[0] = TMath::Mean(nbofgroups,fEntriesLinearFitter,weight);
3161 stat[1] = TMath::Median(nbofgroups,fEntriesLinearFitter,weight);
3162 stat[2] = TMath::RMS((Int_t)stat[3],nonul);
3167 //////////////////////////////////////////////////////////////////////////////////////
3169 //////////////////////////////////////////////////////////////////////////////////////
3170 //_____________________________________________________________________________
3171 void AliTRDCalibraFillHisto::CreatePRF2d(Int_t nn)
3174 // Create the 2D histos: here we have 2*fNgroupprf bins in tnp of 0.2 amplitude each
3175 // If fNgroupprf is zero then no binning in tnp
3179 name += fCalibraMode->GetNz(2);
3181 name += fCalibraMode->GetNrphi(2);
3185 if(fNgroupprf != 0){
3187 fPRF2d = new TProfile2D("PRF2d",(const Char_t *) name
3188 ,2*fNgroupprf*fNumberBinPRF,-3.0*fNgroupprf,3.0*fNgroupprf,nn,0,nn);
3189 fPRF2d->SetYTitle("Det/pad groups");
3190 fPRF2d->SetXTitle("Position x/W [pad width units]");
3191 fPRF2d->SetZTitle("Q_{i}/Q_{total}");
3192 fPRF2d->SetStats(0);
3195 fPRF2d = new TProfile2D("PRF2d",(const Char_t *) name
3196 ,fNumberBinPRF,-1.5,1.5,nn,0,nn);
3197 fPRF2d->SetYTitle("Det/pad groups");
3198 fPRF2d->SetXTitle("Position x/W [pad width units]");
3199 fPRF2d->SetZTitle("Q_{i}/Q_{total}");
3200 fPRF2d->SetStats(0);
3205 //_____________________________________________________________________________
3206 void AliTRDCalibraFillHisto::CreatePH2d(Int_t nn)
3209 // Create the 2D histos
3213 name += fCalibraMode->GetNz(1);
3215 name += fCalibraMode->GetNrphi(1);
3217 fPH2d = new TProfile2D("PH2d",(const Char_t *) name
3218 ,fTimeMax,-0.5/fSf,(Float_t) (fTimeMax-0.5)/fSf
3220 fPH2d->SetYTitle("Det/pad groups");
3221 fPH2d->SetXTitle("time [#mus]");
3222 fPH2d->SetZTitle("<PH> [a.u.]");
3226 //_____________________________________________________________________________
3227 void AliTRDCalibraFillHisto::CreateCH2d(Int_t nn)
3230 // Create the 2D histos
3234 name += fCalibraMode->GetNz(0);
3236 name += fCalibraMode->GetNrphi(0);
3238 fCH2d = new TH2I("CH2d",(const Char_t *) name
3239 ,fNumberBinCharge,0,300,nn,0,nn);
3240 fCH2d->SetYTitle("Det/pad groups");
3241 fCH2d->SetXTitle("charge deposit [a.u]");
3242 fCH2d->SetZTitle("counts");
3247 //////////////////////////////////////////////////////////////////////////////////
3248 // Set relative scale
3249 /////////////////////////////////////////////////////////////////////////////////
3250 //_____________________________________________________________________________
3251 void AliTRDCalibraFillHisto::SetRelativeScale(Float_t RelativeScale)
3254 // Set the factor that will divide the deposited charge
3255 // to fit in the histo range [0,300]
3258 if (RelativeScale > 0.0) {
3259 fRelativeScale = RelativeScale;
3262 AliInfo("RelativeScale must be strict positif!");
3266 //////////////////////////////////////////////////////////////////////////////////
3267 // Quick way to fill a histo
3268 //////////////////////////////////////////////////////////////////////////////////
3269 //_____________________________________________________________________
3270 void AliTRDCalibraFillHisto::FillCH2d(Int_t x, Float_t y)
3273 // FillCH2d: Marian style
3276 //skip simply the value out of range
3277 if((y>=300.0) || (y<0.0)) return;
3279 //Calcul the y place
3280 Int_t yplace = (Int_t) (fNumberBinCharge*y/300.0)+1;
3281 Int_t place = (fNumberBinCharge+2)*(x+1)+yplace;
3284 fCH2d->GetArray()[place]++;
3288 //////////////////////////////////////////////////////////////////////////////////
3289 // Geometrical functions
3290 ///////////////////////////////////////////////////////////////////////////////////
3291 //_____________________________________________________________________________
3292 Int_t AliTRDCalibraFillHisto::GetLayer(Int_t d) const
3295 // Reconstruct the layer number from the detector number
3298 return ((Int_t) (d % 6));
3302 //_____________________________________________________________________________
3303 Int_t AliTRDCalibraFillHisto::GetStack(Int_t d) const
3306 // Reconstruct the stack number from the detector number
3308 const Int_t kNlayer = 6;
3310 return ((Int_t) (d % 30) / kNlayer);
3314 //_____________________________________________________________________________
3315 Int_t AliTRDCalibraFillHisto::GetSector(Int_t d) const
3318 // Reconstruct the sector number from the detector number
3322 return ((Int_t) (d / fg));
3325 ///////////////////////////////////////////////////////////////////////////////////
3326 // Getter functions for DAQ of the CH2d and the PH2d
3327 //////////////////////////////////////////////////////////////////////////////////
3328 //_____________________________________________________________________
3329 TProfile2D* AliTRDCalibraFillHisto::GetPH2d(Int_t nbtimebin, Float_t samplefrequency)
3332 // return pointer to fPH2d TProfile2D
3333 // create a new TProfile2D if it doesn't exist allready
3339 fTimeMax = nbtimebin;
3340 fSf = samplefrequency;
3346 //_____________________________________________________________________
3347 TH2I* AliTRDCalibraFillHisto::GetCH2d()
3350 // return pointer to fCH2d TH2I
3351 // create a new TH2I if it doesn't exist allready
3360 ////////////////////////////////////////////////////////////////////////////////////////////
3361 // Drift velocity calibration
3362 ///////////////////////////////////////////////////////////////////////////////////////////
3363 //_____________________________________________________________________
3364 TLinearFitter* AliTRDCalibraFillHisto::GetLinearFitter(Int_t detector, Bool_t force)
3367 // return pointer to TLinearFitter Calibration
3368 // if force is true create a new TLinearFitter if it doesn't exist allready
3371 if ((!force) || (fLinearFitterArray.UncheckedAt(detector))){
3372 return (TLinearFitter*)fLinearFitterArray.UncheckedAt(detector);
3375 // if we are forced and TLinearFitter doesn't yet exist create it
3377 // new TLinearFitter
3378 TLinearFitter *linearfitter = new TLinearFitter(2,"pol1");
3379 fLinearFitterArray.AddAt(linearfitter,detector);
3380 return linearfitter;
3383 //____________________________________________________________________________
3384 void AliTRDCalibraFillHisto::AnalyseLinearFitter()
3387 // Analyse array of linear fitter because can not be written
3388 // Store two arrays: one with the param the other one with the error param + number of entries
3391 for(Int_t k = 0; k < 540; k++){
3392 TLinearFitter *linearfitter = GetLinearFitter(k);
3393 if((linearfitter!=0) && (fEntriesLinearFitter[k]>10)){
3394 TVectorD *par = new TVectorD(2);
3395 TVectorD pare = TVectorD(2);
3396 TVectorD *parE = new TVectorD(3);
3397 linearfitter->Eval();
3398 linearfitter->GetParameters(*par);
3399 linearfitter->GetErrors(pare);
3400 Float_t ppointError = TMath::Sqrt(TMath::Abs(linearfitter->GetChisquare())/fEntriesLinearFitter[k]);
3401 (*parE)[0] = pare[0]*ppointError;
3402 (*parE)[1] = pare[1]*ppointError;
3403 (*parE)[2] = (Double_t) fEntriesLinearFitter[k];
3404 ((TObjArray *)fLinearVdriftFit->GetPArray())->AddAt(par,k);
3405 ((TObjArray *)fLinearVdriftFit->GetEArray())->AddAt(parE,k);