X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=TRD%2FAliTRDCalibraFillHisto.cxx;h=4e0b3c68468ded28a3a6883c463c1cf7894b8b56;hb=132a16a18e5ed04406033e07e58309aa44ad5d39;hp=544664402c91e11818391ef5bfa7c52ebd8563fc;hpb=7bce990c5ebfc372365da3ac0a8d59c25a9a901c;p=u%2Fmrichter%2FAliRoot.git diff --git a/TRD/AliTRDCalibraFillHisto.cxx b/TRD/AliTRDCalibraFillHisto.cxx index 544664402c9..4e0b3c68468 100644 --- a/TRD/AliTRDCalibraFillHisto.cxx +++ b/TRD/AliTRDCalibraFillHisto.cxx @@ -1,17 +1,17 @@ -/************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ +//************************************************************************** +// * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * +// * * +// * Author: The ALICE Off-line Project. * +// * Contributors are mentioned in the code where appropriate. * +// * * +// * Permission to use, copy, modify and distribute this software and its * +// * documentation strictly for non-commercial purposes is hereby granted * +// * without fee, provided that the above copyright notice appears in all * +// * copies and that both the copyright notice and this permission notice * +//* appear in the supporting documentation. The authors make no claims * +//* about the suitability of this software for any purpose. It is * +//* provided "as is" without express or implied warranty. * +//**************************************************************************/ /* $Id$ */ @@ -48,6 +48,7 @@ #include #include #include +#include #include "AliLog.h" @@ -57,11 +58,9 @@ #include "AliTRDCalibraVdriftLinearFit.h" #include "AliTRDcalibDB.h" #include "AliTRDCommonParam.h" -#include "AliTRDmcmTracklet.h" -#include "AliTRDmcm.h" -#include "AliTRDtrigParam.h" #include "AliTRDpadPlane.h" #include "AliTRDcluster.h" +#include "AliTRDtrack.h" #include "AliTRDtrackV1.h" #include "AliTRDrawStreamBase.h" #include "AliRawReader.h" @@ -120,7 +119,7 @@ void AliTRDCalibraFillHisto::Terminate() AliTRDCalibraFillHisto::AliTRDCalibraFillHisto() :TObject() ,fGeo(0) - ,fMcmCorrectAngle(kFALSE) + ,fIsHLT(kFALSE) ,fCH2dOn(kFALSE) ,fPH2dOn(kFALSE) ,fPRF2dOn(kFALSE) @@ -131,26 +130,31 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto() ,fRelativeScale(0) ,fThresholdClusterPRF2(15.0) ,fLimitChargeIntegration(kFALSE) + ,fFillWithZero(kFALSE) + ,fNormalizeNbOfCluster(kFALSE) + ,fMaxCluster(0) + ,fNbMaxCluster(0) ,fCalibraMode(new AliTRDCalibraMode()) ,fDebugStreamer(0) ,fDebugLevel(0) ,fDetectorPreviousTrack(-1) ,fMCMPrevious(-1) ,fROBPrevious(-1) - ,fNumberClusters(18) + ,fNumberClusters(1) ,fNumberClustersf(30) ,fProcent(6.0) ,fDifference(17) ,fNumberTrack(0) ,fTimeMax(0) ,fSf(10.0) - ,fNumberBinCharge(100) - ,fNumberBinPRF(40) - ,fNgroupprf(0) + ,fNumberBinCharge(50) + ,fNumberBinPRF(10) + ,fNgroupprf(3) ,fAmpTotal(0x0) ,fPHPlace(0x0) ,fPHValue(0x0) ,fGoodTracklet(kTRUE) + ,fLinearFitterTracklet(0x0) ,fEntriesCH(0x0) ,fEntriesLinearFitter(0x0) ,fCalibraVector(0x0) @@ -183,7 +187,7 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto() AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c) :TObject(c) ,fGeo(0) - ,fMcmCorrectAngle(c.fMcmCorrectAngle) + ,fIsHLT(c.fIsHLT) ,fCH2dOn(c.fCH2dOn) ,fPH2dOn(c.fPH2dOn) ,fPRF2dOn(c.fPRF2dOn) @@ -194,6 +198,10 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c) ,fRelativeScale(c.fRelativeScale) ,fThresholdClusterPRF2(c.fThresholdClusterPRF2) ,fLimitChargeIntegration(c.fLimitChargeIntegration) + ,fFillWithZero(c.fFillWithZero) + ,fNormalizeNbOfCluster(c.fNormalizeNbOfCluster) + ,fMaxCluster(c.fMaxCluster) + ,fNbMaxCluster(c.fNbMaxCluster) ,fCalibraMode(0x0) ,fDebugStreamer(0) ,fDebugLevel(c.fDebugLevel) @@ -214,6 +222,7 @@ AliTRDCalibraFillHisto::AliTRDCalibraFillHisto(const AliTRDCalibraFillHisto &c) ,fPHPlace(0x0) ,fPHValue(0x0) ,fGoodTracklet(c.fGoodTracklet) + ,fLinearFitterTracklet(0x0) ,fEntriesCH(0x0) ,fEntriesLinearFitter(0x0) ,fCalibraVector(0x0) @@ -268,6 +277,18 @@ AliTRDCalibraFillHisto::~AliTRDCalibraFillHisto() if ( fCalDetGain ) delete fCalDetGain; if ( fCalROCGain ) delete fCalROCGain; + if( fLinearFitterTracklet ) { delete fLinearFitterTracklet; } + + delete [] fPHPlace; + delete [] fPHValue; + delete [] fEntriesCH; + delete [] fEntriesLinearFitter; + delete [] fAmpTotal; + + for(Int_t idet=0; idetGetNumberOfTimeBins(); fSf = parCom->GetSamplingFrequency(); - fRelativeScale = 20; + if(!fNormalizeNbOfCluster) fRelativeScale = 20.0; + else fRelativeScale = 1.18; fNumberClustersf = fTimeMax; - fNumberClusters = (Int_t)(0.6*fTimeMax); + fNumberClusters = (Int_t)(0.5*fTimeMax); - //calib object from database used for reconstruction - if(fCalDetGain) delete fCalDetGain; - fCalDetGain = new AliTRDCalDet(*(cal->GetGainFactorDet())); + // Init linear fitter + if(!fLinearFitterTracklet) { + fLinearFitterTracklet = new TLinearFitter(2,"pol1"); + fLinearFitterTracklet->StoreData(kTRUE); + } + //calib object from database used for reconstruction + if( fCalDetGain ){ + fCalDetGain->~AliTRDCalDet(); + new(fCalDetGain) AliTRDCalDet(*(cal->GetGainFactorDet())); + }else fCalDetGain = new AliTRDCalDet(*(cal->GetGainFactorDet())); + // Calcul Xbins Chambd0, Chamb2 Int_t ntotal0 = CalculateTotalNumberOfBins(0); Int_t ntotal1 = CalculateTotalNumberOfBins(1); @@ -372,23 +403,10 @@ Bool_t AliTRDCalibraFillHisto::Init2Dhistos() fCalibraVector->SetDetCha0(k,fCalibraMode->GetDetChamb0(k)); fCalibraVector->SetDetCha2(k,fCalibraMode->GetDetChamb2(k)); } - TString namech("Nz"); - namech += fCalibraMode->GetNz(0); - namech += "Nrphi"; - namech += fCalibraMode->GetNrphi(0); - fCalibraVector->SetNameCH((const char* ) namech); - TString nameph("Nz"); - nameph += fCalibraMode->GetNz(1); - nameph += "Nrphi"; - nameph += fCalibraMode->GetNrphi(1); - fCalibraVector->SetNamePH((const char* ) nameph); - TString nameprf("Nz"); - nameprf += fCalibraMode->GetNz(2); - nameprf += "Nrphi"; - nameprf += fCalibraMode->GetNrphi(2); - nameprf += "Ngp"; - nameprf += fNgroupprf; - fCalibraVector->SetNamePRF((const char* ) nameprf); + fCalibraVector->SetNzNrphi(0,fCalibraMode->GetNz(0),fCalibraMode->GetNrphi(0)); + fCalibraVector->SetNzNrphi(1,fCalibraMode->GetNz(1),fCalibraMode->GetNrphi(1)); + fCalibraVector->SetNzNrphi(2,fCalibraMode->GetNz(2),fCalibraMode->GetNrphi(2)); + fCalibraVector->SetNbGroupPRF(fNgroupprf); } // Create the 2D histos corresponding to the pad groupCalibration mode @@ -459,7 +477,7 @@ Bool_t AliTRDCalibraFillHisto::Init2Dhistos() } //____________Offline tracking in the AliTRDtracker____________________________ -Bool_t AliTRDCalibraFillHisto::UpdateHistograms(AliTRDtrack *t) +Bool_t AliTRDCalibraFillHisto::UpdateHistograms(const AliTRDtrack *t) { // // Use AliTRDtrack for the calibration @@ -486,7 +504,7 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistograms(AliTRDtrack *t) //If the same track, then look if the previous detector is in //the same plane, if yes: not a good track - if ((GetPlane(detector) == GetPlane(fDetectorPreviousTrack))) { + if ((GetLayer(detector) == GetLayer(fDetectorPreviousTrack))) { return kFALSE; } @@ -534,9 +552,13 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistograms(AliTRDtrack *t) } // Get calib objects - if( fCalROCGain ) delete fCalROCGain; - fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector))); - + if( fCalROCGain ){ + if(!fIsHLT){ + fCalROCGain->~AliTRDCalROC(); + new(fCalROCGain) AliTRDCalROC(*(cal->GetGainFactorROC(detector))); + } + }else fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector))); + } // Reset the detectbjobsor @@ -592,7 +614,7 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistograms(AliTRDtrack *t) } //____________Offline tracking in the AliTRDtracker____________________________ -Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t) +Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t) { // // Use AliTRDtrackV1 for the calibration @@ -600,8 +622,15 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t) const AliTRDseedV1 *tracklet = 0x0; // tracklet per plane - AliTRDcluster *cl = 0x0; // cluster attached now to the tracklet + AliTRDcluster *cl = 0x0; // cluster attached now to the tracklet + Bool_t newtr = kTRUE; // new track + // Get cal + AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); + if (!cal) { + AliInfo("Could not get calibDB"); + return kFALSE; + } /////////////////////////// // loop over the tracklet @@ -616,36 +645,39 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t) ////////////////////////////////////////// // localisation of the tracklet and dqdl ////////////////////////////////////////// - Int_t plane = tracklet->GetPlane(); + Int_t layer = tracklet->GetPlane(); Int_t ic = 0; while(!(cl = tracklet->GetClusters(ic++))) continue; Int_t detector = cl->GetDetector(); if (detector != fDetectorPreviousTrack) { - // don't use the rest of this track if in the same plane - if ((plane == GetPlane(fDetectorPreviousTrack))) { - break; + // if not a new track + if(!newtr){ + // don't use the rest of this track if in the same plane + if (layer == GetLayer(fDetectorPreviousTrack)) { + //printf("bad tracklet, same layer for detector %d\n",detector); + break; + } } //Localise the detector bin LocalisationDetectorXbins(detector); - // Get cal - AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); - if (!cal) { - AliInfo("Could not get calibDB"); - return kFALSE; - } // Get calib objects - if( fCalROCGain ) delete fCalROCGain; - fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector))); + if( fCalROCGain ){ + if(!fIsHLT){ + fCalROCGain->~AliTRDCalROC(); + new(fCalROCGain) AliTRDCalROC(*(cal->GetGainFactorROC(detector))); + } + }else fCalROCGain = new AliTRDCalROC(*(cal->GetGainFactorROC(detector))); + // reset fDetectorPreviousTrack = detector; } - + newtr = kFALSE; //////////////////////////// // loop over the clusters //////////////////////////// Int_t nbclusters = 0; - for(int jc=0; jcGetClusters(jc))) continue; nbclusters++; @@ -663,10 +695,12 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t) // Fill the stuffs if a good tracklet //////////////////////////////////////// if (fGoodTracklet) { - + // drift velocity unables to cut bad tracklets Bool_t pass = FindP1TrackPHtrackletV1(tracklet, nbclusters); + //printf("pass %d and nbclusters %d\n",pass,nbclusters); + // Gain calibration if (fCH2dOn) { FillTheInfoOfTheTrackCH(nbclusters); @@ -680,10 +714,8 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t) if(pass && fPRF2dOn) HandlePRFtrackletV1(tracklet,nbclusters); } // if a good tracklet - } - - + return kTRUE; } @@ -691,7 +723,7 @@ Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t) // Routine inside the update with AliTRDtrack /////////////////////////////////////////////////////////////////////////////////// //____________Offine tracking in the AliTRDtracker_____________________________ -Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtracklet(AliTRDtrack *t, Int_t index0, Int_t index1) +Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtracklet(const AliTRDtrack *t, Int_t index0, Int_t index1) { // // Drift velocity calibration: @@ -708,27 +740,25 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtracklet(AliTRDtrack *t, Int_t index //////////////// Int_t detector = ((AliTRDcluster *) t->GetCluster(index0))->GetDetector(); //detector // parameters of the track - Double_t snp = t->GetSnpPlane(GetPlane(detector)); // sin angle in the plan yx track - Double_t tgl = t->GetTglPlane(GetPlane(detector)); // dz/dl and not dz/dx! + Double_t snp = t->GetSnpPlane(GetLayer(detector)); // sin angle in the plan yx track + Double_t tgl = t->GetTglPlane(GetLayer(detector)); // dz/dl and not dz/dx! Double_t tnp = 0.0; // tan angle in the plan xy track if( TMath::Abs(snp) < 1.){ - tnp = snp / (TMath::Sqrt(1-(snp*snp))); + tnp = snp / TMath::Sqrt((1.-snp)*(1.+snp)); } Float_t dzdx = tgl*TMath::Sqrt(1+tnp*tnp); // dz/dx now from dz/dl // tilting pad and cross row Int_t crossrow = 0; // if it crosses a pad row Int_t rowp = -1; // if it crosses a pad row - AliTRDpadPlane *padplane = fGeo->GetPadPlane(GetPlane(detector),GetChamber(detector)); + AliTRDpadPlane *padplane = fGeo->GetPadPlane(GetLayer(detector),GetStack(detector)); Double_t tiltingangle = padplane->GetTiltingAngle(); // tiltingangle of the pad Float_t tnt = TMath::Tan(tiltingangle/180.*TMath::Pi()); // tan tiltingangle // linear fit - TLinearFitter linearFitterTracklet = TLinearFitter(2,"pol1"); // TLinearFitter per tracklet + fLinearFitterTracklet->ClearPoints(); Double_t dydt = 0.0; // dydt tracklet after straight line fit Double_t errorpar = 0.0; // error after straight line fit on dy/dt Double_t pointError = 0.0; // error after straight line fit Int_t nbli = 0; // number linear fitter points - linearFitterTracklet.StoreData(kFALSE); - linearFitterTracklet.ClearPoints(); ////////////////////////////// // loop over clusters @@ -746,7 +776,7 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtracklet(AliTRDtrack *t, Int_t index if(k==0) rowp = row; if(row != rowp) crossrow = 1; - linearFitterTracklet.AddPoint(&timeis,ycluster,1); + fLinearFitterTracklet->AddPoint(&timeis,ycluster,1); nbli++; } @@ -754,14 +784,18 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtracklet(AliTRDtrack *t, Int_t index ////////////////////////////// // linear fit ////////////////////////////// - if(nbli <= 2) return kFALSE; + if(nbli <= 2){ + fLinearFitterTracklet->ClearPoints(); + return kFALSE; + } TVectorD pars; - linearFitterTracklet.Eval(); - linearFitterTracklet.GetParameters(pars); - pointError = TMath::Sqrt(linearFitterTracklet.GetChisquare()/nbli); - errorpar = linearFitterTracklet.GetParError(1)*pointError; + fLinearFitterTracklet->Eval(); + fLinearFitterTracklet->GetParameters(pars); + pointError = TMath::Sqrt(fLinearFitterTracklet->GetChisquare()/(nbli-2)); + errorpar = fLinearFitterTracklet->GetParError(1)*pointError; dydt = pars[1]; - + fLinearFitterTracklet->ClearPoints(); + ///////////////////////////// // debug //////////////////////////// @@ -792,13 +826,13 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtracklet(AliTRDtrack *t, Int_t index Int_t nbclusters = index1-index0; - Int_t plane = GetPlane(fDetectorPreviousTrack); + Int_t layer = GetLayer(fDetectorPreviousTrack); (* fDebugStreamer) << "FindP1TrackPHtracklet1"<< //"snpright="<GetTilt(); // tan tiltingangle - - linearFitterTracklet.StoreData(kFALSE); - linearFitterTracklet.ClearPoints(); + fLinearFitterTracklet->ClearPoints(); + /////////////////////////////////////////// // Take the parameters of the track @@ -865,7 +897,7 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track Double_t snp = tracklet->GetSnp(); // sin dy/dx at the end of the chamber Double_t tnp = 0.0; // dy/dx at the end of the chamber if( TMath::Abs(snp) < 1.){ - tnp = snp / (TMath::Sqrt(1-(snp*snp))); + tnp = snp / TMath::Sqrt((1.-snp)*(1.+snp)); } Double_t tgl = tracklet->GetTgl(); // dz/dl Double_t dzdx = tgl*TMath::Sqrt(1+tnp*tnp); // dz/dx calculated from dz/dl @@ -883,7 +915,7 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track //////////////////////////// Int_t nbli = 0; AliTRDcluster *cl = 0x0; - for(int ic=0; icGetClusters(ic))) continue; if((fLimitChargeIntegration) && (!cl->IsInChamber())) continue; @@ -895,20 +927,32 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track if(rowp==-1) rowp = row; if(row != rowp) crossrow = 1; - linearFitterTracklet.AddPoint(&timeis,ycluster,1); + fLinearFitterTracklet->AddPoint(&timeis,ycluster,1); nbli++; + ////////////////////////////// + // Check no shared clusters + ////////////////////////////// + for(int icc=AliTRDseedV1::kNtb; iccGetClusters(icc))) crossrow = 1; + } } //////////////////////////////////// // Do the straight line fit now /////////////////////////////////// + if(nbli <= 2){ + fLinearFitterTracklet->ClearPoints(); + return kFALSE; + } TVectorD pars; - linearFitterTracklet.Eval(); - linearFitterTracklet.GetParameters(pars); - pointError = TMath::Sqrt(linearFitterTracklet.GetChisquare()/nbli); - errorpar = linearFitterTracklet.GetParError(1)*pointError; + fLinearFitterTracklet->Eval(); + fLinearFitterTracklet->GetParameters(pars); + pointError = TMath::Sqrt(fLinearFitterTracklet->GetChisquare()/(nbli-2)); + errorpar = fLinearFitterTracklet->GetParError(1)*pointError; dydt = pars[1]; + //printf("chis %f, nbli %d, pointError %f, parError %f, errorpar %f\n",fLinearFitterTracklet->GetChisquare(),nbli,pointError,fLinearFitterTracklet->GetParError(1),errorpar); + fLinearFitterTracklet->ClearPoints(); //////////////////////////////// // Debug stuff @@ -924,13 +968,14 @@ Bool_t AliTRDCalibraFillHisto::FindP1TrackPHtrackletV1(const AliTRDseedV1 *track } - Int_t plane = GetPlane(fDetectorPreviousTrack); - + Int_t layer = GetLayer(fDetectorPreviousTrack); + (* fDebugStreamer) << "FindP1TrackPHtrackletV1"<< //"snpright="<ClearPoints(); /////////////////////////// // calcul the tnp group @@ -1028,8 +1070,10 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, I } } } - if(echec) return kFALSE; - + if(echec) { + delete [] padPositions; + return kFALSE; + } ////////////////////// // loop clusters @@ -1037,6 +1081,7 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, I for(Int_t k = 0; k < npoints; k++){ //Take the cluster AliTRDcluster *cl = (AliTRDcluster *) t->GetCluster(k+index0); + if(!cl) continue; Short_t *signals = cl->GetSignals(); Double_t time = cl->GetPadTime(); //Calculate x if possible @@ -1066,19 +1111,26 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, I Double_t padPosition = xcenter + cl->GetPadCol(); padPositions[k] = padPosition; nb3pc++; - fitter.AddPoint(&time, padPosition,1); + fLinearFitterTracklet->AddPoint(&time, padPosition,1); }//clusters loop ///////////////////////////// // fit //////////////////////////// - if(nb3pc < 3) return kFALSE; - fitter.Eval(); + if(nb3pc < 3) { + delete [] padPositions; + fLinearFitterTracklet->ClearPoints(); + return kFALSE; + } + fLinearFitterTracklet->Eval(); TVectorD line(2); - fitter.GetParameters(line); + fLinearFitterTracklet->GetParameters(line); Float_t pointError = -1.0; - pointError = TMath::Sqrt(fitter.GetChisquare()/nb3pc); + if( fLinearFitterTracklet->GetChisquare()>=0.0) { + pointError = TMath::Sqrt( fLinearFitterTracklet->GetChisquare()/(nb3pc-2)); + } + fLinearFitterTracklet->ClearPoints(); ///////////////////////////////////////////////////// // Now fill the PRF: second loop over clusters @@ -1086,8 +1138,8 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, I for(Int_t k = 0; k < npoints; k++){ //Take the cluster AliTRDcluster *cl = (AliTRDcluster *) t->GetCluster(k+index0); - Short_t *signals = cl->GetSignals(); // signal - Double_t time = cl->GetPadTime(); // time bin + Short_t *signals = cl->GetSignals(); // signal + Double_t time = cl->GetPadTime(); // time bin Float_t padPosTracklet = line[0]+line[1]*time; // reconstruct position from fit Float_t padPos = cl->GetPadCol(); // middle pad Double_t dpad = padPosTracklet - padPos; // reconstruct position relative to middle pad from fit @@ -1111,8 +1163,8 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, I Int_t caligroup = fCalibraMode->GetXbins(2)+ grouplocal; // calcul the corresponding group Float_t xcl = cl->GetY(); // y cluster Float_t qcl = cl->GetQ(); // charge cluster - Int_t plane = GetPlane(detector); // plane - Int_t chamber = GetChamber(detector); // chamber + Int_t layer = GetLayer(detector); // layer + Int_t stack = GetStack(detector); // stack Double_t xdiff = dpad; // reconstructed position constant Double_t x = dpad; // reconstructed position moved Float_t ep = pointError; // error of fit @@ -1140,8 +1192,8 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(AliTRDtrack *t, Int_t index0, I (* fDebugStreamer) << "HandlePRFtracklet"<< "caligroup="<GetSnp(); // sin dy/dx at the end of the chamber Double_t tnp = 0.0; // dy/dx at the end of the chamber if( TMath::Abs(snp) < 1.){ - tnp = snp / (TMath::Sqrt(1-(snp*snp))); + tnp = snp / TMath::Sqrt((1.-snp)*(1.+snp)); } Double_t tgl = tracklet->GetTgl(); // dz/dl Double_t dzdx = tgl*TMath::Sqrt(1+tnp*tnp); // dz/dx calculated from dz/dl @@ -1321,6 +1375,7 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, } } // do nothing if out of tnp range + //printf("echec %d\n",(Int_t)echec); if(echec) return kFALSE; /////////////////////// @@ -1328,22 +1383,22 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, ////////////////////// Int_t nb3pc = 0; // number of three pads clusters used for fit - Double_t *padPositions; // to see the difference between the fit and the 3 pad clusters position - padPositions = new Double_t[AliTRDseed::knTimebins]; - for(Int_t k = 0; k < AliTRDseed::knTimebins; k++){ - padPositions[k] = 0.0; - } - TLinearFitter fitter(2,"pol1"); // TLinearFitter for the linear fit in the drift region - fitter.StoreData(kFALSE); - fitter.ClearPoints(); - + // to see the difference between the fit and the 3 pad clusters position + Double_t padPositions[AliTRDseedV1::kNtb]; + memset(padPositions, 0, AliTRDseedV1::kNtb*sizeof(Double_t)); + fLinearFitterTracklet->ClearPoints(); + + //printf("loop clusters \n"); //////////////////////////// // loop over the clusters //////////////////////////// AliTRDcluster *cl = 0x0; - for(int ic=0; icGetClusters(ic+AliTRDseedV1::kNtb))) continue; + } if(!(cl = tracklet->GetClusters(ic))) continue; - Double_t time = cl->GetPadTime(); if((time<=7) || (time>=21)) continue; Short_t *signals = cl->GetSignals(); @@ -1379,30 +1434,40 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, Double_t padPosition = xcenter + cl->GetPadCol(); padPositions[ic] = padPosition; nb3pc++; - fitter.AddPoint(&time, padPosition,1); + fLinearFitterTracklet->AddPoint(&time, padPosition,1); }//clusters loop - + //printf("Fin loop clusters \n"); ////////////////////////////// // fit with a straight line ///////////////////////////// - if(nb3pc < 3) return kFALSE; - fitter.Eval(); + if(nb3pc < 3){ + fLinearFitterTracklet->ClearPoints(); + return kFALSE; + } + fLinearFitterTracklet->Eval(); TVectorD line(2); - fitter.GetParameters(line); + fLinearFitterTracklet->GetParameters(line); Float_t pointError = -1.0; - pointError = TMath::Sqrt(fitter.GetChisquare()/nb3pc); - + if( fLinearFitterTracklet->GetChisquare()>=0.0) { + pointError = TMath::Sqrt( fLinearFitterTracklet->GetChisquare()/(nb3pc-2)); + } + fLinearFitterTracklet->ClearPoints(); + + //printf("PRF second loop \n"); //////////////////////////////////////////////// // Fill the PRF: Second loop over clusters ////////////////////////////////////////////// - for(int ic=0; icGetClusters(ic+AliTRDseedV1::kNtb))) continue; + // if(!(cl = tracklet->GetClusters(ic))) continue; Short_t *signals = cl->GetSignals(); // signal - Double_t time = cl->GetPadTime(); // time bin + Double_t time = cl->GetPadTime(); // time bin Float_t padPosTracklet = line[0]+line[1]*time; // reconstruct position from fit Float_t padPos = cl->GetPadCol(); // middle pad Double_t dpad = padPosTracklet - padPos; // reconstruct position relative to middle pad from fit @@ -1430,8 +1495,8 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, Int_t caligroup = fCalibraMode->GetXbins(2)+ grouplocal; // calcul the corresponding group Float_t xcl = cl->GetY(); // y cluster Float_t qcl = cl->GetQ(); // charge cluster - Int_t plane = GetPlane(fDetectorPreviousTrack); // plane - Int_t chamber = GetChamber(fDetectorPreviousTrack); // chamber + Int_t layer = GetLayer(fDetectorPreviousTrack); // layer + Int_t stack = GetStack(fDetectorPreviousTrack); // stack Double_t xdiff = dpad; // reconstructed position constant Double_t x = dpad; // reconstructed position moved Float_t ep = pointError; // error of fit @@ -1441,6 +1506,8 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, Float_t signal4 = (Float_t)signals[4]; // signal Float_t signal5 = (Float_t)signals[5]; // signal at the border + + ///////////////////// // Debug stuff //////////////////// @@ -1459,8 +1526,8 @@ Bool_t AliTRDCalibraFillHisto::HandlePRFtrackletV1(const AliTRDseedV1 *tracklet, (* fDebugStreamer) << "HandlePRFtrackletV1"<< "caligroup="<GetNz(i)==10) && (fCalibraMode->GetNrphi(i)==10)){ + ntotal = 18; + AliInfo(Form("Total number of Xbins: %d for i %d",ntotal,i)); + return ntotal; + } + + // More fCalibraMode->ModePadCalibration(2,i); fCalibraMode->ModePadFragmentation(0,2,0,i); fCalibraMode->SetDetChamb2(i); @@ -1737,6 +1819,35 @@ void AliTRDCalibraFillHisto::SetNrphi(Int_t i, Short_t Nrphi) } } + +//_____________________________________________________________________________ +void AliTRDCalibraFillHisto::SetAllTogether(Int_t i) +{ + // + // Set the mode of calibration group all together + // + if(fVector2d == kTRUE) { + AliInfo("Can not work with the vector method"); + return; + } + fCalibraMode->SetAllTogether(i); + +} + +//_____________________________________________________________________________ +void AliTRDCalibraFillHisto::SetPerSuperModule(Int_t i) +{ + // + // Set the mode of calibration group per supermodule + // + if(fVector2d == kTRUE) { + AliInfo("Can not work with the vector method"); + return; + } + fCalibraMode->SetPerSuperModule(i); + +} + //____________Set the pad calibration variables for the detector_______________ Bool_t AliTRDCalibraFillHisto::LocalisationDetectorXbins(Int_t detector) { @@ -1759,9 +1870,9 @@ Bool_t AliTRDCalibraFillHisto::LocalisationDetectorXbins(Int_t detector) // fragmentation of idect for (Int_t i = 0; i < 3; i++) { - fCalibraMode->ModePadCalibration((Int_t) GetChamber(detector),i); - fCalibraMode->ModePadFragmentation((Int_t) GetPlane(detector) - , (Int_t) GetChamber(detector) + fCalibraMode->ModePadCalibration((Int_t) GetStack(detector),i); + fCalibraMode->ModePadFragmentation((Int_t) GetLayer(detector) + , (Int_t) GetStack(detector) , (Int_t) GetSector(detector),i); } @@ -1787,7 +1898,7 @@ void AliTRDCalibraFillHisto::SetNumberGroupsPRF(Short_t numberGroupsPRF) // Per tracklet: store or reset the info, fill the histos with the info ////////////////////////////////////////////////////////////////////////////////////////// //_____________________________________________________________________________ -void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(AliTRDcluster *cl, Double_t dqdl, Int_t *group, Int_t row, Int_t col) +void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(const AliTRDcluster *cl,const Double_t dqdl,const Int_t *group,const Int_t row,const Int_t col) { // // Store the infos in fAmpTotal, fPHPlace and fPHValue @@ -1796,9 +1907,14 @@ void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(AliTRDcluster *cl, Double_t dqdl // time bin of the cluster not corrected Int_t time = cl->GetPadTime(); - + Float_t charge = TMath::Abs(cl->GetQ()); + + //printf("Store::time %d, amplitude %f\n",time,dqdl); + //Correct for the gain coefficient used in the database for reconstruction - Float_t correctthegain = fCalDetGain->GetValue(fDetectorPreviousTrack)*fCalROCGain->GetValue(col,row); + Float_t correctthegain = 1.0; + if(fIsHLT) correctthegain = fCalDetGain->GetValue(fDetectorPreviousTrack); + else correctthegain = fCalDetGain->GetValue(fDetectorPreviousTrack)*fCalROCGain->GetValue(col,row); Float_t correction = 1.0; Float_t normalisation = 6.67; // we divide with gain in AliTRDclusterizer::Transform... @@ -1811,13 +1927,16 @@ void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(AliTRDcluster *cl, Double_t dqdl // Fill the fAmpTotal with the charge if (fCH2dOn) { - if((!fLimitChargeIntegration) || (cl->IsInChamber())) fAmpTotal[(Int_t) group[0]] += correction; + if((!fLimitChargeIntegration) || (cl->IsInChamber())) { + //printf("Store::group %d, amplitude %f\n",group[0],correction); + fAmpTotal[(Int_t) group[0]] += correction; + } } // Fill the fPHPlace and value if (fPH2dOn) { fPHPlace[time] = group[1]; - fPHValue[time] = correction; + fPHValue[time] = charge; } } @@ -1860,12 +1979,21 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackCH(Int_t nbclusters) Int_t fd = -1; // Premiere zone non nulle Float_t totalcharge = 0.0; // Total charge for the supermodule histo + //printf("CH2d nbclusters %d, fNumberClusters %d, fNumberClustersf %d\n",nbclusters,fNumberClusters,fNumberClustersf); + if(nbclusters < fNumberClusters) return; if(nbclusters > fNumberClustersf) return; - + + + // Normalize with the number of clusters + Double_t normalizeCst = fRelativeScale; + if(fNormalizeNbOfCluster) normalizeCst = normalizeCst*nbclusters; + + //printf("Number of groups in one detector %d\n",fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0)); // See if the track goes through different zones for (Int_t k = 0; k < fCalibraMode->GetNfragZ(0)*fCalibraMode->GetNfragRphi(0); k++) { + //printf("fAmpTotal %f for %d\n",fAmpTotal[k],k); if (fAmpTotal[k] > 0.0) { totalcharge += fAmpTotal[k]; nb++; @@ -1875,6 +2003,7 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackCH(Int_t nbclusters) } } + //printf("CH2d: nb %d, fd %d, calibration group %d, amplitude %f, detector %d\n",nb,fd,fCalibraMode->GetXbins(0),fAmpTotal[fd]/normalizeCst,fDetectorPreviousTrack); switch (nb) { @@ -1882,11 +2011,11 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackCH(Int_t nbclusters) fNumberUsedCh[0]++; fEntriesCH[fCalibraMode->GetXbins(0)+fd]++; if (fHisto2d) { - FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/fRelativeScale); - //fCH2d->Fill(fAmpTotal[fd]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+0.5); + FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/normalizeCst); + //fCH2d->Fill(fAmpTotal[fd]/normalizeCst,fCalibraMode->GetXbins(0)+fd+0.5); } if (fVector2d) { - fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/fRelativeScale); + fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/normalizeCst); } break; case 2: @@ -1895,22 +2024,22 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackCH(Int_t nbclusters) // One of the two very big if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+1]) { if (fHisto2d) { - FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/fRelativeScale); - //fCH2d->Fill(fAmpTotal[fd]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+0.5); + FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/normalizeCst); + //fCH2d->Fill(fAmpTotal[fd]/normalizeCst,fCalibraMode->GetXbins(0)+fd+0.5); } if (fVector2d) { - fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/fRelativeScale); + fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/normalizeCst); } fNumberUsedCh[1]++; fEntriesCH[fCalibraMode->GetXbins(0)+fd]++; } if (fAmpTotal[fd+1] > fProcent*fAmpTotal[fd]) { if (fHisto2d) { - FillCH2d(fCalibraMode->GetXbins(0)+fd+1,fAmpTotal[fd+1]/fRelativeScale); - //fCH2d->Fill(fAmpTotal[fd+1]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+1.5); + FillCH2d(fCalibraMode->GetXbins(0)+fd+1,fAmpTotal[fd+1]/normalizeCst); + //fCH2d->Fill(fAmpTotal[fd+1]/normalizeCst,fCalibraMode->GetXbins(0)+fd+1.5); } if (fVector2d) { - fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd+1,fAmpTotal[fd+1]/fRelativeScale); + fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd+1,fAmpTotal[fd+1]/normalizeCst); } fNumberUsedCh[1]++; fEntriesCH[fCalibraMode->GetXbins(0)+fd+1]++; @@ -1923,24 +2052,24 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackCH(Int_t nbclusters) // One of the two very big if (fAmpTotal[fd] > fProcent*fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]) { if (fHisto2d) { - FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/fRelativeScale); - //fCH2d->Fill(fAmpTotal[fd]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+0.5); + FillCH2d(fCalibraMode->GetXbins(0)+fd,fAmpTotal[fd]/normalizeCst); + //fCH2d->Fill(fAmpTotal[fd]/normalizeCst,fCalibraMode->GetXbins(0)+fd+0.5); } if (fVector2d) { - fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/fRelativeScale); + fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd,fAmpTotal[fd]/normalizeCst); } fNumberUsedCh[1]++; fEntriesCH[fCalibraMode->GetXbins(0)+fd]++; } if (fAmpTotal[fd+fCalibraMode->GetNfragZ(0)] > fProcent*fAmpTotal[fd]) { if (fHisto2d) { - FillCH2d(fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0),fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/fRelativeScale); - //fCH2d->Fill(fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/fRelativeScale,fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0)+0.5); + FillCH2d(fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0),fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/normalizeCst); + //fCH2d->Fill(fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/normalizeCst,fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0)+0.5); } fNumberUsedCh[1]++; fEntriesCH[fCalibraMode->GetXbins(0)+fd+fCalibraMode->GetNfragZ(0)]++; if (fVector2d) { - fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd+fCalibraMode->GetNfragZ(0),fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/fRelativeScale); + fCalibraVector->UpdateVectorCH(fDetectorPreviousTrack,fd+fCalibraMode->GetNfragZ(0),fAmpTotal[fd+fCalibraMode->GetNfragZ(0)]/normalizeCst); } } } @@ -1990,6 +2119,18 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH() } } + // See if noise before and after + if(fMaxCluster > 0) { + if(fPHValue[0] > fMaxCluster) return; + if(fTimeMax > fNbMaxCluster) { + for(Int_t k = (fTimeMax-fNbMaxCluster); k < fTimeMax; k++){ + if(fPHValue[k] > fMaxCluster) return; + } + } + } + + //printf("nbclusters %d, low limit %d, high limit %d\n",nbclusters,fNumberClusters,fNumberClustersf); + if(nbclusters < fNumberClusters) return; if(nbclusters > fNumberClustersf) return; @@ -1999,11 +2140,17 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH() fNumberUsedPh[0]++; for (Int_t i = 0; i < fTimeMax; i++) { if (fHisto2d) { - fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]); + if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]); + else { + if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]); + } //printf("Fill the time bin %d with %f\n",i,fPHValue[i]); } if (fVector2d) { - fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]); + if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]); + else { + if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]); + } } } break; @@ -2016,10 +2163,16 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH() fNumberUsedPh[1]++; for (Int_t i = 0; i < fTimeMax; i++) { if (fHisto2d) { - fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]); + if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]); + else { + if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]); + } } if (fVector2d) { - fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]); + if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]); + else { + if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]); + } } } } @@ -2028,10 +2181,16 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH() fNumberUsedPh[1]++; for (Int_t i = 0; i < fTimeMax; i++) { if (fHisto2d) { - fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]); + if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]); + else { + if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]); + } } if (fVector2d) { - fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]); + if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]); + else { + if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]); + } } } } @@ -2047,10 +2206,16 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH() fNumberUsedPh[1]++; for (Int_t i = 0; i < fTimeMax; i++) { if (fHisto2d) { - fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]); + if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]); + else { + if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]); + } } if (fVector2d) { - fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]); + if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]); + else { + if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]); + } } } } @@ -2059,10 +2224,16 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH() fNumberUsedPh[1]++; for (Int_t i = 0; i < fTimeMax; i++) { if (fHisto2d) { - fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]); + if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]); + else { + if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]); + } } if (fVector2d) { - fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]); + if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]); + else { + if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]); + } } } } @@ -2078,10 +2249,16 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH() fNumberUsedPh[1]++; for (Int_t i = 0; i < fTimeMax; i++) { if (fHisto2d) { - fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]); + if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]); + else { + if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd1)+0.5,(Float_t) fPHValue[i]); + } } if (fVector2d) { - fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]); + if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]); + else { + if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd1,i,fPHValue[i]); + } } } } @@ -2090,10 +2267,16 @@ void AliTRDCalibraFillHisto::FillTheInfoOfTheTrackPH() fNumberUsedPh[1]++; for (Int_t i = 0; i < fTimeMax; i++) { if (fHisto2d) { - fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]); + if(fFillWithZero) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]); + else { + if(((Float_t) fPHValue[i] > 0.0)) fPH2d->Fill((Float_t) i/fSf,(fCalibraMode->GetXbins(1)+fd2)+0.5,(Float_t) fPHValue[i]); + } } if (fVector2d) { - fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]); + if(fFillWithZero) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]); + else { + if(((Float_t) fPHValue[i] > 0.0)) fCalibraVector->UpdateVectorPH(fDetectorPreviousTrack,fd2,i,fPHValue[i]); + } } } } @@ -2116,7 +2299,6 @@ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bo // 0 timebin problem // 1 no input // 2 input - // // Same algorithm as TestBeam but different reader // @@ -2275,174 +2457,6 @@ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliTRDrawStreamBase *rawStream, Bo return withInput; -} -//_____________________________________________________________________ -Int_t AliTRDCalibraFillHisto::ProcessEventDAQV1(AliTRDrawStreamBase *rawStream, Bool_t nocheck) -{ - // - // Event Processing loop - AliTRDrawStreamBase - // Use old AliTRDmcmtracklet code - // 0 timebin problem - // 1 no input - // 2 input - // - // Algorithm with mcm tracklet - // - - Int_t withInput = 1; - - AliTRDmcm mcm = AliTRDmcm(0); - AliTRDtrigParam *param = AliTRDtrigParam::Instance(); - rawStream->SetSharedPadReadout(kTRUE); - - fDetectorPreviousTrack = -1; - fMCMPrevious = -1; - fROBPrevious = -1; - Int_t row = -1; - Int_t nbtimebin = 0; - Int_t baseline = 10; - - - if(!nocheck){ - - fTimeMax = 0; - - while (rawStream->Next()) { - - Int_t idetector = rawStream->GetDet(); // current detector - Int_t imcm = rawStream->GetMCM(); // current MCM - Int_t irob = rawStream->GetROB(); // current ROB - row = rawStream->GetRow(); - - - if(((fDetectorPreviousTrack != idetector) || (fMCMPrevious != imcm) || (fROBPrevious != irob)) && (fDetectorPreviousTrack != -1)){ - - // Fill - withInput = TMath::Max(FillDAQ(&mcm),withInput); - - - // reset - mcm.Reset(); - mcm.SetRobId(irob); - mcm.SetChaId(idetector); - mcm.SetRow(row); - mcm.SetColRange(0,21); - - } - if(fDetectorPreviousTrack == -1){ - - mcm.SetRobId(irob); - mcm.SetChaId(idetector); - mcm.SetRow(row); - mcm.SetColRange(0,21); - - } - - fDetectorPreviousTrack = idetector; - fMCMPrevious = imcm; - fROBPrevious = irob; - - nbtimebin = rawStream->GetNumberOfTimeBins(); // number of time bins read from data - if(nbtimebin == 0) return 0; - if((fTimeMax != 0) && (nbtimebin != fTimeMax)) return 0; - fTimeMax = nbtimebin; - fNumberClustersf = fTimeMax; - fNumberClusters = (Int_t)(0.6*fTimeMax); - param->SetTimeRange(0,fTimeMax); - - //baseline = rawStream->GetCommonAdditive(); // common additive baseline - - Int_t *signal = rawStream->GetSignals(); // current ADC signal - Int_t adc = rawStream->GetADC(); - - - //printf("detector %d, signal[0] %d, signal[1] %d, signal[2] %d, baseline %d\n",idetector,signal[0],signal[1],signal[2], baseline); - - for(Int_t itime = 0; itime < nbtimebin; itime++){ - mcm.SetADC(adc,itime,(signal[itime]-baseline)); - } - } - - // fill the last one - if(fDetectorPreviousTrack != -1){ - - // Fill - withInput = TMath::Max(FillDAQ(&mcm),withInput); - - - // reset - mcm.Reset(); - mcm.SetRobId(fROBPrevious); - mcm.SetChaId(fDetectorPreviousTrack); - mcm.SetRow(row); - mcm.SetColRange(0,21); - - } - - } - else{ - - while (rawStream->Next()) { - - Int_t idetector = rawStream->GetDet(); // current detector - Int_t imcm = rawStream->GetMCM(); // current MCM - Int_t irob = rawStream->GetROB(); // current ROB - row = rawStream->GetRow(); - - if(((fDetectorPreviousTrack != idetector) || (fMCMPrevious != imcm) || (fROBPrevious != irob)) && (fDetectorPreviousTrack != -1)){ - - // Fill - withInput = TMath::Max(FillDAQ(&mcm),withInput); - - - // reset - mcm.Reset(); - mcm.SetRobId(irob); - mcm.SetChaId(idetector); - mcm.SetRow(row); - mcm.SetColRange(0,21); - - } - - fDetectorPreviousTrack = idetector; - fMCMPrevious = imcm; - fROBPrevious = irob; - - //baseline = rawStream->GetCommonAdditive(); // common baseline - - fTimeMax = rawStream->GetNumberOfTimeBins(); // number of time bins read from data - fNumberClustersf = fTimeMax; - fNumberClusters = (Int_t)(0.6*fTimeMax); - param->SetTimeRange(0,fTimeMax); - Int_t *signal = rawStream->GetSignals(); // current ADC signal - Int_t adc = rawStream->GetADC(); - - - //printf("detector %d, signal[0] %d, signal[1] %d, signal[2] %d, baseline %d\n",idetector,signal[0],signal[1],signal[2], baseline); - - for(Int_t itime = 0; itime < fTimeMax; itime++){ - mcm.SetADC(adc,itime,(signal[itime]-baseline)); - } - } - - // fill the last one - if(fDetectorPreviousTrack != -1){ - - // Fill - withInput = TMath::Max(FillDAQ(&mcm),withInput); - - // reset - mcm.Reset(); - mcm.SetRobId(fROBPrevious); - mcm.SetChaId(fDetectorPreviousTrack); - mcm.SetRow(row); - mcm.SetColRange(0,21); - - } - } - - return withInput; - } //_____________________________________________________________________ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliRawReader *rawReader, Bool_t nocheck) @@ -2462,10 +2476,10 @@ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ(AliRawReader *rawReader, Bool_t no //_________________________________________________________________________ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ( #ifdef ALI_DATE - eventHeaderStruct *event, + const eventHeaderStruct *event, Bool_t nocheck #else - eventHeaderStruct* /*event*/, + const eventHeaderStruct* /*event*/, Bool_t /*nocheck*/ #endif @@ -2485,247 +2499,11 @@ Int_t AliTRDCalibraFillHisto::ProcessEventDAQ( return 0; #endif -} -//_____________________________________________________________________ -Int_t AliTRDCalibraFillHisto::ProcessEventDAQV1(AliRawReader *rawReader, Bool_t nocheck) -{ - // - // Event processing loop - AliRawReader - // use the old mcm traklet code - // - - AliTRDrawStreamBase rawStream(rawReader); - - rawReader->Select("TRD"); - - return ProcessEventDAQV1(&rawStream, nocheck); -} -//_________________________________________________________________________ -Int_t AliTRDCalibraFillHisto::ProcessEventDAQV1( -#ifdef ALI_DATE - eventHeaderStruct *event, - Bool_t nocheck -#else - eventHeaderStruct* /*event*/, - Bool_t /*nocheck*/ - -#endif - ) -{ - // - // process date event - // use the old mcm tracklet code - // -#ifdef ALI_DATE - AliRawReader *rawReader = new AliRawReaderDate((void*)event); - Int_t result=ProcessEventDAQV1(rawReader, nocheck); - delete rawReader; - return result; -#else - Fatal("AliTRDCalibraFillHisto", "this class was compiled without DATE"); - return 0; -#endif - } ////////////////////////////////////////////////////////////////////////////// // Routine inside the DAQ process ///////////////////////////////////////////////////////////////////////////// //_______________________________________________________________________ -Int_t AliTRDCalibraFillHisto::FillDAQ(AliTRDmcm *mcm){ - - // - // Return 2 if some tracklets are found and used, 1 if nothing - // - - Int_t nbev = 0; - - if(mcm->Run()){ - - for (Int_t iSeed = 0; iSeed < 4; iSeed++) { - - if (mcm->GetSeedCol()[iSeed] < 0) { - continue; - } - - nbev += TestTracklet(mcm->GetChaId(),mcm->GetRow(),iSeed,mcm); - } - - } - - if(nbev > 0) nbev = 2; - else nbev = 1; - - return nbev; - -} -//__________________________________________________________________________ -Int_t AliTRDCalibraFillHisto::TestTracklet( Int_t idet, Int_t row, Int_t iSeed, AliTRDmcm *mcm){ - - // - // Build the tracklet and return if the tracklet if finally used or not (1/0) - // - - Int_t nbev = 0; - - AliTRDmcmTracklet mcmtracklet = AliTRDmcmTracklet(); - //mcmtracklet.Reset(); - mcmtracklet.SetDetector(idet); - mcmtracklet.SetRow(row); - mcmtracklet.SetN(0); - - Int_t iCol, iCol1, iCol2, track[3]; - iCol = mcm->GetSeedCol()[iSeed]; // 0....20 (MCM) - mcm->GetColRange(iCol1,iCol2); // range in the pad plane - - Float_t amp[3]; - for (Int_t iTime = 0; iTime < fTimeMax; iTime++) { - - amp[0] = mcm->GetADC(iCol-1,iTime); - amp[1] = mcm->GetADC(iCol ,iTime); - amp[2] = mcm->GetADC(iCol+1,iTime); - - if(mcm->IsCluster(iCol,iTime)) { - - mcmtracklet.AddCluster(iCol+iCol1,iTime,amp,track); - - } - else if ((iCol+1+1) < 21) { - - amp[0] = mcm->GetADC(iCol-1+1,iTime); - amp[1] = mcm->GetADC(iCol +1,iTime); - amp[2] = mcm->GetADC(iCol+1+1,iTime); - - if(mcm->IsCluster(iCol+1,iTime)) { - - mcmtracklet.AddCluster(iCol+1+iCol1,iTime,amp,track); - - } - - } - - } - - - nbev = UpdateHistogramcm(&mcmtracklet); - - return nbev; - -} -//____________Online trackling in AliTRDtrigger________________________________ -Int_t AliTRDCalibraFillHisto::UpdateHistogramcm(AliTRDmcmTracklet *trk) -{ - // - // Return if the tracklet is finally used or not (1/0) for calibration - // - - Int_t used = 1; - - //fGoodTracklet = kTRUE; - - // Localisation of the Xbins involved - Int_t idect = trk->GetDetector(); - Int_t idectrue = trk->GetDetector(); - //idect = 0; - - Int_t nbclusters = trk->GetNclusters(); - - // Eventuelle correction due to track angle in z direction - Float_t correction = 1.0; - if (fMcmCorrectAngle) { - Float_t z = trk->GetRowz(); - Float_t r = trk->GetTime0(); - correction = r / TMath::Sqrt((r*r+z*z)); - } - - //row - Int_t row = trk->GetRow(); - - - // Boucle sur les clusters - // Condition on number of cluster: don't come from the middle of the detector - - Double_t amph[36]; - for(Int_t k =0; k < 36; k++) amph[k]=0.0; - Double_t ampTotal = 0.0; - - for (Int_t icl = 0; icl < trk->GetNclusters(); icl++) { - - Float_t amp[3] = { 0.0, 0.0, 0.0 }; - Int_t time = trk->GetClusterTime(icl); - Int_t col = trk->GetClusterCol(icl); - - //CheckGoodTrackletV0(idect,row,col); - - amp[0] = trk->GetClusterADC(icl)[0] * correction; - amp[1] = trk->GetClusterADC(icl)[1] * correction; - amp[2] = trk->GetClusterADC(icl)[2] * correction; - - ampTotal += (Float_t) (amp[0]+amp[1]+amp[2]); - amph[time]=amp[0]+amp[1]+amp[2]; - - if(fDebugLevel > 0){ - if ( !fDebugStreamer ) { - //debug stream - TDirectory *backup = gDirectory; - fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root"); - if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer - } - - Double_t amp0 = amp[0]; - Double_t amp1 = amp[1]; - Double_t amp2 = amp[2]; - - (* fDebugStreamer) << "UpdateHistogramcm0"<< - "nbclusters="< 100.0) || (!fGoodTracklet) || (trk->GetNclusters() < fNumberClusters) || (trk->GetNclusters() > fNumberClustersf)) used = 0; - - if (used == 1) { - for(Int_t k = 0; k < fTimeMax; k++) UpdateDAQ(idect,0,0,k,amph[k],fTimeMax); - //((TH2I *)GetCH2d()->Fill(ampTotal/30.0,idect)); - } // Condition cut - - - if(fDebugLevel > 0){ - if ( !fDebugStreamer ) { - //debug stream - TDirectory *backup = gDirectory; - fDebugStreamer = new TTreeSRedirector("TRDdebugCalibraFill.root"); - if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer - } - - Double_t amph0 = amph[0]; - Double_t amphlast = amph[fTimeMax-1]; - Double_t rms = TMath::RMS(fTimeMax,amph); - Int_t goodtracklet = (Int_t) fGoodTracklet; - - (* fDebugStreamer) << "UpdateHistogramcm1"<< - "nbclusters="< 200.0)) return 1; if(used == 0){ for(Int_t it = 0; it < fTimeMax; it++){ - UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax); + if(fFillWithZero) UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax); + else{ + if(sum[it] > 0.0) UpdateDAQ(fDetectorPreviousTrack,0,0,it,sum[it],fTimeMax); + } } @@ -3288,10 +3069,10 @@ void AliTRDCalibraFillHisto::FillCH2d(Int_t x, Float_t y) // Geometrical functions /////////////////////////////////////////////////////////////////////////////////// //_____________________________________________________________________________ -Int_t AliTRDCalibraFillHisto::GetPlane(Int_t d) const +Int_t AliTRDCalibraFillHisto::GetLayer(Int_t d) const { // - // Reconstruct the plane number from the detector number + // Reconstruct the layer number from the detector number // return ((Int_t) (d % 6)); @@ -3299,14 +3080,14 @@ Int_t AliTRDCalibraFillHisto::GetPlane(Int_t d) const } //_____________________________________________________________________________ -Int_t AliTRDCalibraFillHisto::GetChamber(Int_t d) const +Int_t AliTRDCalibraFillHisto::GetStack(Int_t d) const { // - // Reconstruct the chamber number from the detector number + // Reconstruct the stack number from the detector number // - Int_t fgkNplan = 6; + const Int_t kNlayer = 6; - return ((Int_t) (d % 30) / fgkNplan); + return ((Int_t) (d % 30) / kNlayer); } @@ -3405,4 +3186,3 @@ void AliTRDCalibraFillHisto::AnalyseLinearFitter() } } } -