#include "AliLog.h"
+#include "AliESDtrack.h"
#include "AliTRDCalibraFillHisto.h"
#include "AliTRDCalibraMode.h"
#include "AliTRDCalibraVector.h"
#include "AliTRDCalibraVdriftLinearFit.h"
+#include "AliTRDCalibraExbAltFit.h"
#include "AliTRDcalibDB.h"
#include "AliTRDCommonParam.h"
#include "AliTRDpadPlane.h"
#include "AliRawReader.h"
#include "AliRawReaderDate.h"
#include "AliTRDgeometry.h"
+#include "AliTRDfeeParam.h"
#include "./Cal/AliTRDCalROC.h"
#include "./Cal/AliTRDCalPad.h"
#include "./Cal/AliTRDCalDet.h"
,fVector2d(kFALSE)
,fLinearFitterOn(kFALSE)
,fLinearFitterDebugOn(kFALSE)
+ ,fExbAltFitOn(kFALSE)
+ ,fScaleWithTPCSignal(kFALSE)
,fRelativeScale(0)
,fThresholdClusterPRF2(15.0)
,fLimitChargeIntegration(kFALSE)
,fNormalizeNbOfCluster(kFALSE)
,fMaxCluster(0)
,fNbMaxCluster(0)
+ ,fCutWithVdriftCalib(kFALSE)
+ ,fMinNbTRDtracklets(0)
+ ,fMinTRDMomentum(0.0)
,fFirstRunGain(0)
,fVersionGainUsed(0)
,fSubVersionGainUsed(0)
,fNumberTrack(0)
,fTimeMax(0)
,fSf(10.0)
+ ,fRangeHistoCharge(150)
,fNumberBinCharge(50)
,fNumberBinPRF(10)
,fNgroupprf(3)
,fCH2d(0x0)
,fLinearFitterArray(540)
,fLinearVdriftFit(0x0)
+ ,fExbAltFit(0x0)
,fCalDetGain(0x0)
,fCalROCGain(0x0)
{
,fVector2d(c.fVector2d)
,fLinearFitterOn(c.fLinearFitterOn)
,fLinearFitterDebugOn(c.fLinearFitterDebugOn)
+ ,fExbAltFitOn(c.fExbAltFitOn)
+ ,fScaleWithTPCSignal(c.fScaleWithTPCSignal)
,fRelativeScale(c.fRelativeScale)
,fThresholdClusterPRF2(c.fThresholdClusterPRF2)
,fLimitChargeIntegration(c.fLimitChargeIntegration)
,fNormalizeNbOfCluster(c.fNormalizeNbOfCluster)
,fMaxCluster(c.fMaxCluster)
,fNbMaxCluster(c.fNbMaxCluster)
+ ,fCutWithVdriftCalib(c.fCutWithVdriftCalib)
+ ,fMinNbTRDtracklets(c.fMinNbTRDtracklets)
+ ,fMinTRDMomentum(c.fMinTRDMomentum)
,fFirstRunGain(c.fFirstRunGain)
,fVersionGainUsed(c.fVersionGainUsed)
,fSubVersionGainUsed(c.fSubVersionGainUsed)
,fNumberTrack(c.fNumberTrack)
,fTimeMax(c.fTimeMax)
,fSf(c.fSf)
+ ,fRangeHistoCharge(c.fRangeHistoCharge)
,fNumberBinCharge(c.fNumberBinCharge)
,fNumberBinPRF(c.fNumberBinPRF)
,fNgroupprf(c.fNgroupprf)
,fCH2d(0x0)
,fLinearFitterArray(540)
,fLinearVdriftFit(0x0)
+ ,fExbAltFit(0x0)
,fCalDetGain(0x0)
,fCalROCGain(0x0)
{
if(c.fLinearVdriftFit){
fLinearVdriftFit = new AliTRDCalibraVdriftLinearFit(*c.fLinearVdriftFit);
}
+ if(c.fExbAltFit){
+ fExbAltFit = new AliTRDCalibraExbAltFit(*c.fExbAltFit);
+ }
if(c.fCalDetGain) fCalDetGain = new AliTRDCalDet(*c.fCalDetGain);
if(c.fCalROCGain) fCalROCGain = new AliTRDCalROC(*c.fCalROCGain);
if(f) { delete f;}
}
if(fLinearVdriftFit) delete fLinearVdriftFit;
+ if(fExbAltFit) delete fExbAltFit;
if (fGeo) {
delete fGeo;
}
nameee += "Nz";
fLinearVdriftFit->SetNameCalibUsed(nameee);
}
+ if(fExbAltFitOn){
+ fExbAltFit = new AliTRDCalibraExbAltFit();
+ }
if (fPRF2dOn) {
}
//____________Offline tracking in the AliTRDtracker____________________________
-Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t)
+Bool_t AliTRDCalibraFillHisto::UpdateHistogramsV1(const AliTRDtrackV1 *t,const AliESDtrack *esdtrack)
{
//
// Use AliTRDtrackV1 for the calibration
AliTRDcluster *cl = 0x0; // cluster attached now to the tracklet
AliTRDcluster *cls = 0x0; // shared 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;
- }
-*/
+
+
+ //
+ // Cut on the number of TRD tracklets
+ //
+ Int_t numberoftrdtracklets = t->GetNumberOfTracklets();
+ if(numberoftrdtracklets < fMinNbTRDtracklets) return kFALSE;
+
+ Double_t tpcsignal = 1.0;
+ if(esdtrack) tpcsignal = esdtrack->GetTPCsignal()/50.0;
+ if(fScaleWithTPCSignal && tpcsignal <0.00001) return kFALSE;
+
+ //
if (!fCalibDB) {
AliInfo("Could not get calibDB");
return kFALSE;
if(!tracklet->IsOK()) continue;
fNumberTrack++;
ResetfVariablestracklet();
+ Float_t momentum = t->GetMomentum(itr);
+ if(TMath::Abs(momentum) < fMinTRDMomentum) continue;
+
//////////////////////////////////////////
// localisation of the tracklet and dqdl
////////////////////////////
// loop over the clusters
////////////////////////////
+ Double_t chargeQ = 0.0;
Int_t nbclusters = 0;
for(int jc=0; jc<AliTRDseedV1::kNtb; jc++){
if(!(cl = tracklet->GetClusters(jc))) continue;
// Add the charge if shared cluster
cls = tracklet->GetClusters(jc+AliTRDseedV1::kNtb);
//
- StoreInfoCHPHtrack(cl, tracklet->GetdQdl(jc),group,row,col,cls);
+ //Scale with TPC signal or not
+ if(!fScaleWithTPCSignal) {
+ chargeQ += StoreInfoCHPHtrack(cl, tracklet->GetQperTB(jc),group,row,col,cls); //tracklet->GetdQdl(jc)
+ //printf("Do not scale now\n");
+ }
+ else {
+ chargeQ += StoreInfoCHPHtrack(cl, tracklet->GetQperTB(jc)/tpcsignal,group,row,col,cls); //tracklet->GetdQdl(jc)
+ }
+
}
////////////////////////////////////////
// Gain calibration
if (fCH2dOn) {
- FillTheInfoOfTheTrackCH(nbclusters);
+ if(fCutWithVdriftCalib) {
+ if(pass) FillTheInfoOfTheTrackCH(nbclusters);
+ } else {
+ FillTheInfoOfTheTrackCH(nbclusters);
+ }
}
// PH calibration
if (fPH2dOn) {
- FillTheInfoOfTheTrackPH();
+ if(fCutWithVdriftCalib) {
+ if(pass) FillTheInfoOfTheTrackPH();
+ }
+ else {
+ FillTheInfoOfTheTrackPH();
+ }
}
if(pass && fPRF2dOn) HandlePRFtrackletV1(tracklet,nbclusters);
-
+
+
+ /////////////////////////////////////////////////////////
+ // Debug
+ ////////////////////////////////////////////////////////
+ if(fDebugLevel > 0){
+ //printf("test\n");
+ 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
+ }
+
+ Int_t stacke = AliTRDgeometry::GetStack(detector);
+ Int_t sme = AliTRDgeometry::GetSector(detector);
+ Int_t layere = AliTRDgeometry::GetLayer(detector);
+ // Some variables
+ Float_t b[2] = {0.0,0.0};
+ Float_t bCov[3] = {0.0,0.0,0.0};
+ if(esdtrack) esdtrack->GetImpactParameters(b,bCov);
+ if (bCov[0]<=0 || bCov[2]<=0) {
+ bCov[0]=0; bCov[2]=0;
+ }
+ Float_t dcaxy = b[0];
+ Float_t dcaz = b[1];
+ Int_t tpcnbclusters = 0;
+ if(esdtrack) tpcnbclusters = esdtrack->GetTPCclusters(0);
+ Double_t ttpcsignal = 0.0;
+ if(esdtrack) ttpcsignal = esdtrack->GetTPCsignal();
+ Int_t cutvdriftlinear = 0;
+ if(!pass) cutvdriftlinear = 1;
+
+ (* fDebugStreamer) << "FillCharge"<<
+ "detector="<<detector<<
+ "stack="<<stacke<<
+ "sm="<<sme<<
+ "layere="<<layere<<
+ "dcaxy="<<dcaxy<<
+ "dcaz="<<dcaz<<
+ "nbtpccls="<<tpcnbclusters<<
+ "tpcsignal="<<ttpcsignal<<
+ "cutvdriftlinear="<<cutvdriftlinear<<
+ "ptrd="<<momentum<<
+ "nbtrdtracklet="<<numberoftrdtracklets<<
+ "charge="<<chargeQ<<
+ "\n";
+ }
+
+
} // if a good tracklet
}
//////////////////////////////////
// Loop clusters
//////////////////////////////////
+
+ Float_t sigArr[AliTRDfeeParam::GetNcol()];
+ memset(sigArr, 0, AliTRDfeeParam::GetNcol()*sizeof(sigArr[0]));
+ Int_t ncl=0, tbf=0, tbl=0;
+
for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
if(!(cl = tracklet->GetClusters(ic))) continue;
+
+ if(!tbf) tbf=ic;
+ tbl=ic;
+ ncl++;
+ Int_t col = cl->GetPadCol();
+ for(int ip=-1, jp=2; jp<5; ip++, jp++){
+ Int_t idx=col+ip;
+ if(idx<0 || idx>=AliTRDfeeParam::GetNcol()) continue;
+ sigArr[idx]+=((Float_t)cl->GetSignals()[jp]);
+ }
+
if((fLimitChargeIntegration) && (!cl->IsInChamber())) continue;
Double_t ycluster = cl->GetY();
TVectorD pars;
fLinearFitterTracklet->Eval();
fLinearFitterTracklet->GetParameters(pars);
- pointError = TMath::Sqrt(fLinearFitterTracklet->GetChisquare()/(nbli-2));
+ pointError = TMath::Sqrt(TMath::Abs(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();
+
+ ////////////////////////////////////
+ // Calc the projection of the clusters on the y direction
+ ///////////////////////////////////
+
+ Float_t signalSum(0.);
+ Float_t mean = 0.0, rms = 0.0;
+ Float_t dydx = tracklet->GetYref(1), tilt = tracklet->GetTilt(); // ,dzdx = tracklet->GetZref(1); (identical to the previous definition!)
+ Float_t dz = dzdx*(tbl-tbf)/10;
+ if(ncl>10){
+ for(Int_t ip(0); ip<AliTRDfeeParam::GetNcol(); ip++){
+ signalSum+=sigArr[ip];
+ mean+=ip*sigArr[ip];
+ }
+ if(signalSum > 0.0) mean/=signalSum;
+
+ for(Int_t ip = 0; ip<AliTRDfeeParam::GetNcol(); ip++)
+ rms+=sigArr[ip]*(ip-mean)*(ip-mean);
+
+ if(signalSum > 0.0) rms = TMath::Sqrt(TMath::Abs(rms/signalSum));
+
+ rms -= TMath::Abs(dz*tilt);
+ dydx -= dzdx*tilt;
+ }
////////////////////////////////
// Debug stuff
///////////////////////////////
- if(fDebugLevel > 0){
+ if(fDebugLevel > 1){
if ( !fDebugStreamer ) {
//debug stream
TDirectory *backup = gDirectory;
if ( backup ) backup->cd(); //we don't want to be cd'd to the debug streamer
}
-
+ float xcoord = tnp-dzdx*tnt;
+ float pt = tracklet->GetPt();
Int_t layer = GetLayer(fDetectorPreviousTrack);
(* fDebugStreamer) << "FindP1TrackPHtrackletV1"<<
"crossrow="<<crossrow<<
"errorpar="<<errorpar<<
"pointError="<<pointError<<
+ "xcoord="<<xcoord<<
+ "pt="<<pt<<
+ "rms="<<rms<<
+ "dydx="<<dydx<<
+ "dz="<<dz<<
+ "tilt="<<tilt<<
+ "ncl="<<ncl<<
"\n";
}
fLinearVdriftFit->Update(fDetectorPreviousTrack,x,pars[1]);
}
}
+ if(fExbAltFitOn){
+ fExbAltFit->Update(fDetectorPreviousTrack,dydx,rms);
+ }
return kTRUE;
}
// Debug stuff
////////////////////
- if(fDebugLevel > 0){
+ if(fDebugLevel > 1){
if ( !fDebugStreamer ) {
//debug stream
TDirectory *backup = gDirectory;
// Per tracklet: store or reset the info, fill the histos with the info
//////////////////////////////////////////////////////////////////////////////////////////
//_____________________________________________________________________________
-void AliTRDCalibraFillHisto::StoreInfoCHPHtrack(const AliTRDcluster *cl,const Double_t dqdl,const Int_t *group,const Int_t row,const Int_t col,const AliTRDcluster *cls)
+Float_t AliTRDCalibraFillHisto::StoreInfoCHPHtrack(const AliTRDcluster *cl,const Double_t dqdl,const Int_t *group,const Int_t row,const Int_t col,const AliTRDcluster *cls)
{
//
// Store the infos in fAmpTotal, fPHPlace and fPHValue
// Correct from the gain correction before
// cls is shared cluster if any
+ // Return the charge
+ //
//
//printf("StoreInfoCHPHtrack\n");
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;
+ Float_t normalisation = 1.13; //org: 6.67; 1st: 1.056; 2nd: 1.13;
// we divide with gain in AliTRDclusterizer::Transform...
if( correctthegain > 0 ) normalisation /= correctthegain;
fPHPlace[time] = group[1];
fPHValue[time] = charge;
}
+
+ return correction;
}
//____________Offine tracking in the AliTRDtracker_____________________________
/////////////////////////////////////////////////////////
// Debug
////////////////////////////////////////////////////////
- if(fDebugLevel > 0){
+ if(fDebugLevel > 1){
if ( !fDebugStreamer ) {
//debug stream
TDirectory *backup = gDirectory;
name += fCalibraMode->GetNrphi(0);
fCH2d = new TH2I("CH2d",(const Char_t *) name
- ,fNumberBinCharge,0,300,nn,0,nn);
+ ,(Int_t)fNumberBinCharge,0,fRangeHistoCharge,nn,0,nn);
fCH2d->SetYTitle("Det/pad groups");
fCH2d->SetXTitle("charge deposit [a.u]");
fCH2d->SetZTitle("counts");
{
//
// Set the factor that will divide the deposited charge
- // to fit in the histo range [0,300]
+ // to fit in the histo range [0,fRangeHistoCharge]
//
if (RelativeScale > 0.0) {
//
//skip simply the value out of range
- if((y>=300.0) || (y<0.0)) return;
+ if((y>=fRangeHistoCharge) || (y<0.0)) return;
+ if(fRangeHistoCharge < 0.0) return;
//Calcul the y place
- Int_t yplace = (Int_t) (fNumberBinCharge*y/300.0)+1;
+ Int_t yplace = (Int_t) (fNumberBinCharge*y/fRangeHistoCharge)+1;
Int_t place = (fNumberBinCharge+2)*(x+1)+yplace;
//Fill