- }
- //////////////////////////////////
- // Loop clusters
- //////////////////////////////////
- for(int ic=0; ic<AliTRDseedV1::kNtb; ic++){
- if(!(cl = tracklet->GetClusters(ic))) continue;
- if((fLimitChargeIntegration) && (!cl->IsInChamber())) continue;
-
- Double_t ycluster = cl->GetY();
- Int_t time = cl->GetPadTime();
- Double_t timeis = time/fSf;
- //See if cross two pad rows
- Int_t row = cl->GetPadRow();
- if(rowp==-1) rowp = row;
- if(row != rowp) crossrow = 1;
-
- fLinearFitterTracklet->AddPoint(&timeis,ycluster,1);
- nbli++;
-
-
- }
-
- ////////////////////////////////////
- // Do the straight line fit now
- ///////////////////////////////////
- if(nbli <= 2){
- fLinearFitterTracklet->ClearPoints();
- return kFALSE;
- }
- TVectorD pars;
- 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
- ///////////////////////////////
-
-
- 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
- }
-
-
- Int_t layer = GetLayer(fDetectorPreviousTrack);
-
- (* fDebugStreamer) << "FindP1TrackPHtrackletV1"<<
- //"snpright="<<snpright<<
- "nbli="<<nbli<<
- "nbclusters="<<nbclusters<<
- "detector="<<fDetectorPreviousTrack<<
- "layer="<<layer<<
- "snp="<<snp<<
- "tnp="<<tnp<<
- "tgl="<<tgl<<
- "tnt="<<tnt<<
- "dydt="<<dydt<<
- "dzdx="<<dzdx<<
- "crossrow="<<crossrow<<
- "errorpar="<<errorpar<<
- "pointError="<<pointError<<
- "\n";
-
- }
-
- /////////////////////////
- // Cuts quality
- ////////////////////////
-
- if(nbclusters < fNumberClusters) return kFALSE;
- if(nbclusters > fNumberClustersf) return kFALSE;
- if(pointError >= 0.3) return kFALSE;
- if(crossrow == 1) return kTRUE;
-
- ///////////////////////
- // Fill
- //////////////////////
-
- if(fLinearFitterOn){
- //Add to the linear fitter of the detector
- if( TMath::Abs(snp) < 1.){
- Double_t x = tnp-dzdx*tnt;
- if(fLinearFitterDebugOn) {
- (GetLinearFitter(fDetectorPreviousTrack,kTRUE))->AddPoint(&x,dydt);
- fEntriesLinearFitter[fDetectorPreviousTrack]++;
- }
- fLinearVdriftFit->Update(fDetectorPreviousTrack,x,pars[1]);
- }
- }
-
- return kTRUE;
-}
-//____________Offine tracking in the AliTRDtracker_____________________________
-Bool_t AliTRDCalibraFillHisto::HandlePRFtracklet(const AliTRDtrack *t, Int_t index0, Int_t index1)
-{
- //
- // PRF width calibration
- // Assume a Gaussian shape: determinate the position of the three pad clusters
- // Fit with a straight line
- // Take the fitted values for all the clusters (3 or 2 pad clusters)
- // Fill the PRF as function of angle of the track
- //
- //
-
-
- //////////////////////////
- // variables
- /////////////////////////
- Int_t npoints = index1-index0; // number of total points
- Int_t nb3pc = 0; // number of three pads clusters used for fit
- Int_t detector = ((AliTRDcluster *) t->GetCluster(index0))->GetDetector(); // detector
- // To see the difference due to the fit
- Double_t *padPositions;
- padPositions = new Double_t[npoints];
- for(Int_t k = 0; k < npoints; k++){
- padPositions[k] = 0.0;
- }
- // Take the tgl and snp with the track t now
- Double_t tgl = t->GetTglPlane(GetLayer(detector)); //dz/dl and not dz/dx
- Double_t snp = t->GetSnpPlane(GetLayer(detector)); // sin angle in xy plan
- Float_t dzdx = 0.0; // dzdx
- Float_t tnp = 0.0;
- if(TMath::Abs(snp) < 1.0){
- tnp = snp / TMath::Sqrt((1.-snp)*(1.+snp));
- dzdx = tgl*TMath::Sqrt(1+tnp*tnp);
- }
- // linear fitter
- fLinearFitterTracklet->ClearPoints();
-
- ///////////////////////////
- // calcul the tnp group
- ///////////////////////////
- Bool_t echec = kFALSE;
- Double_t shift = 0.0;
- //Calculate the shift in x coresponding to this tnp
- if(fNgroupprf != 0.0){
- shift = -3.0*(fNgroupprf-1)-1.5;
- Double_t limithigh = -0.2*(fNgroupprf-1);
- if((tnp < (-0.2*fNgroupprf)) || (tnp > (0.2*fNgroupprf))) echec = kTRUE;
- else{
- while(tnp > limithigh){
- limithigh += 0.2;
- shift += 3.0;
- }
- }
- }
- if(echec) {
- delete [] padPositions;
- return kFALSE;
- }
-
- //////////////////////
- // loop clusters
- /////////////////////
- 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
- Float_t xcenter = 0.0;
- Bool_t echec1 = kTRUE;
- if((time<=7) || (time>=21)) continue;
- // Center 3 balanced: position with the center of the pad
- if ((((Float_t) signals[3]) > 0.0) &&
- (((Float_t) signals[2]) > 0.0) &&
- (((Float_t) signals[4]) > 0.0)) {
- echec1 = kFALSE;
- // Security if the denomiateur is 0
- if ((((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3]))) /
- ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))) != 1.0) {
- xcenter = 0.5 * (TMath::Log((Float_t) (((Float_t) signals[4]) / ((Float_t) signals[2]))))
- / (TMath::Log(((Float_t) (((Float_t) signals[3]) * ((Float_t) signals[3])))
- / ((Float_t) (((Float_t) signals[2]) * ((Float_t) signals[4])))));
- }
- else {
- echec1 = kTRUE;
- }
- }
- if(TMath::Abs(xcenter) > 0.5) echec = kTRUE;
- if(echec) continue;
- //if no echec: calculate with the position of the pad
- // Position of the cluster
- Double_t padPosition = xcenter + cl->GetPadCol();
- padPositions[k] = padPosition;
- nb3pc++;
- fLinearFitterTracklet->AddPoint(&time, padPosition,1);
- }//clusters loop
-
-
- /////////////////////////////
- // fit
- ////////////////////////////
- if(nb3pc < 3) {
- delete [] padPositions;
- fLinearFitterTracklet->ClearPoints();
- return kFALSE;
- }
- fLinearFitterTracklet->Eval();
- TVectorD line(2);
- fLinearFitterTracklet->GetParameters(line);
- Float_t pointError = -1.0;
- if( fLinearFitterTracklet->GetChisquare()>=0.0) {
- pointError = TMath::Sqrt( fLinearFitterTracklet->GetChisquare()/(nb3pc-2));
- }
- fLinearFitterTracklet->ClearPoints();
-
- /////////////////////////////////////////////////////
- // Now fill the PRF: second loop over clusters
- /////////////////////////////////////////////////////
- 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
- 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
- Float_t ycenter = 0.0; // relative center charge
- Float_t ymin = 0.0; // relative left charge
- Float_t ymax = 0.0; // relative right charge
-
- //Requiere simply two pads clusters at least
- if(((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[2]) > 0.0)) ||
- ((((Float_t) signals[3]) > 0.0) && (((Float_t) signals[4]) > 0.0))){
- Float_t sum = ((Float_t) signals[2]) + ((Float_t) signals[3]) + ((Float_t) signals[4]);
- if(sum > 0.0) ycenter = ((Float_t) signals[3])/ sum;
- if(sum > 0.0) ymin = ((Float_t) signals[2])/ sum;
- if(sum > 0.0) ymax = ((Float_t) signals[4])/ sum;
- }
-
- //calibration group
- Int_t rowcl = cl->GetPadRow(); // row of cluster
- Int_t colcl = cl->GetPadCol(); // col of cluster
- Int_t grouplocal = CalculateCalibrationGroup(2,rowcl,colcl); // calcul the corresponding group
- 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 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
- Float_t signal1 = (Float_t)signals[1]; // signal at the border
- Float_t signal3 = (Float_t)signals[3]; // signal
- Float_t signal2 = (Float_t)signals[2]; // signal
- Float_t signal4 = (Float_t)signals[4]; // signal
- Float_t signal5 = (Float_t)signals[5]; // signal at the border
-
- //////////////////////////////
- // debug
- /////////////////////////////
- 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
- }
-
-
- x = xdiff;
- Int_t type=0;
- Float_t y = ycenter;
- (* fDebugStreamer) << "HandlePRFtracklet"<<
- "caligroup="<<caligroup<<
- "detector="<<detector<<
- "layer="<<layer<<
- "stack="<< stack <<
- "npoints="<<npoints<<
- "Np="<<nb3pc<<
- "ep="<<ep<<
- "type="<<type<<
- "snp="<<snp<<
- "tnp="<<tnp<<
- "tgl="<<tgl<<
- "dzdx="<<dzdx<<
- "padPos="<<padPos<<
- "padPosition="<<padPositions[k]<<
- "padPosTracklet="<<padPosTracklet<<
- "x="<<x<<
- "y="<<y<<
- "xcl="<<xcl<<
- "qcl="<<qcl<<
- "signal1="<<signal1<<
- "signal2="<<signal2<<
- "signal3="<<signal3<<
- "signal4="<<signal4<<
- "signal5="<<signal5<<
- "time="<<time<<
- "\n";
- x=-(xdiff+1);
- y = ymin;
- type=-1;
- (* fDebugStreamer) << "HandlePRFtracklet"<<
- "caligroup="<<caligroup<<
- "detector="<<detector<<
- "layer="<<layer<<
- "stack="<<stack<<
- "npoints="<<npoints<<
- "Np="<<nb3pc<<
- "ep="<<ep<<
- "type="<<type<<
- "snp="<<snp<<
- "tnp="<<tnp<<
- "tgl="<<tgl<<
- "dzdx="<<dzdx<<
- "padPos="<<padPos<<
- "padPosition="<<padPositions[k]<<
- "padPosTracklet="<<padPosTracklet<<
- "x="<<x<<
- "y="<<y<<
- "xcl="<<xcl<<
- "qcl="<<qcl<<
- "signal1="<<signal1<<
- "signal2="<<signal2<<
- "signal3="<<signal3<<
- "signal4="<<signal4<<
- "signal5="<<signal5<<
- "time="<<time<<
- "\n";
- x=1-xdiff;
- y = ymax;
- type=1;
- (* fDebugStreamer) << "HandlePRFtracklet"<<
- "caligroup="<<caligroup<<
- "detector="<<detector<<
- "layer="<<layer<<
- "stack="<<stack<<
- "npoints="<<npoints<<
- "Np="<<nb3pc<<
- "ep="<<ep<<
- "type="<<type<<
- "snp="<<snp<<
- "tnp="<<tnp<<
- "tgl="<<tgl<<
- "dzdx="<<dzdx<<
- "padPos="<<padPos<<
- "padPosition="<<padPositions[k]<<
- "padPosTracklet="<<padPosTracklet<<
- "x="<<x<<
- "y="<<y<<
- "xcl="<<xcl<<
- "qcl="<<qcl<<
- "signal1="<<signal1<<
- "signal2="<<signal2<<
- "signal3="<<signal3<<
- "signal4="<<signal4<<
- "signal5="<<signal5<<
- "time="<<time<<
- "\n";
-
- }