Fork me on GitHub

Changeset a47edcc in git


Ignore:
Timestamp:
May 1, 2021, 2:15:02 PM (3 years ago)
Author:
Franco BEDESCHI <bed@…>
Branches:
master
Children:
46d3442
Parents:
53f4746
Message:

Fixed issue with backward generated tracks

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • examples/ExamplePVtxFit.C

    r53f4746 ra47edcc  
    1414
    1515#endif
     16
    1617
    1718
     
    4546                // Load selected branches with data from specified event
    4647                treeReader->ReadEntry(entry);
     48                //
    4749                Int_t Ntr = 0;  // # of tracks from primary vertex
    4850                Int_t NtrG = branchTrack->GetEntries();
    4951                TVectorD** pr = new TVectorD * [NtrG];
    5052                TMatrixDSym** cv = new TMatrixDSym * [NtrG];
     53                //
     54                // True vertex
     55                Double_t xpv, ypv, zpv;
    5156                // If event contains at least 1 track
    5257                //
     
    6065                                // Get associated generated particle
    6166                                GenParticle* gp = (GenParticle*)trk->Particle.GetObject();
     67                                TVector3 xg(1.e-3*gp->X,1.e-3*gp->Y,1.e-3*gp->Z);
     68                                TVector3 pg(gp->Px,gp->Py,gp->Pz);
     69                                Double_t Q = (Double_t)gp->Charge;
     70                                Double_t Bz = 2.0;
     71                                TVectorD genParM =TrkUtil:: XPtoPar(xg, pg, Q, Bz);
     72                                TVectorD genPar = TrkUtil::ParToMm(genParM);
    6273                                //
    6374                                // Position of origin in mm
     
    6576                                Double_t y = gp->Y;
    6677                                Double_t z = gp->Z;
     78                                Bool_t prim = kTRUE;    // Is primary?
     79                                Int_t mp = gp->M1;      // Mother
     80                                while(mp>0){
     81                                        GenParticle* gm =
     82                                        (GenParticle*)branchGenPart->At(mp);
     83                                        Double_t xm = gm->X;
     84                                        Double_t ym = gm->Y;
     85                                        Double_t zm = gm->Z;
     86                                        if(x!=xm || y!=ym || z!=zm){
     87                                                prim = kFALSE;
     88                                                break;
     89                                        }else mp = gm->M1;
     90                                }
    6791                                //
    6892                                // group tracks originating from the primary vertex
    69                                 if (x == 0.0 && y == 0.0)
     93                                if (prim)
    7094                                {
     95                                        //std::cout<<"Event: "<<entry<<", track: "<<it;
     96                                        //std::cout<<", x = "<<x<<", y = "<<y<<", z = "<<z<<std::endl;
     97                                        xpv = x;
     98                                        ypv = y;
     99                                        zpv = z;
    71100                                        //
    72101                                        // Reconstructed track parameters
     
    75104                                        Double_t obsC = trk->C;
    76105                                        Double_t obsZ0 = trk->DZ;
     106                                        //std::cout<<"Z0 track = "<< obsZ0
     107                                        //<<", gen Z0 = "<<genPar(3)
     108                                        //<<", gen cot = "<<genPar(4)<<std::endl;
    77109                                        Double_t obsCtg = trk->CtgTheta;
    78110                                        Double_t oPar[5] = { obsD0, obsPhi, obsC, obsZ0, obsCtg };
     
    96128                        Double_t Chi2 = Vtx->GetVtxChi2();
    97129                        Double_t Ndof = 2 * (Double_t)Ntr - 3;
    98                         Double_t PullX = xvtx(0) / TMath::Sqrt(covX(0, 0));
    99                         Double_t PullY = xvtx(1) / TMath::Sqrt(covX(1, 1));
    100                         Double_t PullZ = xvtx(2) / TMath::Sqrt(covX(2, 2));
     130                        Double_t PullX = (xvtx(0)-xpv) / TMath::Sqrt(covX(0, 0));
     131                        Double_t PullY = (xvtx(1)-ypv) / TMath::Sqrt(covX(1, 1));
     132                        Double_t PullZ = (xvtx(2)-zpv) / TMath::Sqrt(covX(2, 2));
     133                        //std::cout<<"**** True  vertex (x, y, z) "<<xpv<<", "
     134                        //<<ypv<<", "<<zpv<<std::endl;
     135                        //std::cout<<"**** Found vertex (x, y, z) "<<xvtx(0)<<", "
     136                        //<<xvtx(1)<<", "<<xvtx(2)<<std::endl;
    101137                        //
    102138                        // Fill histograms
  • external/TrackCovariance/TrkUtil.cc

    r53f4746 ra47edcc  
    4646        Double_t C = a / (2 * pt);                      // Half curvature
    4747        //std::cout << "ObsTrk::XPtoPar: fB = " << fB << ", a = " << a << ", pt = " << pt << ", C = " << C << std::endl;
    48         Double_t r2 = x.Perp2();
     48        Double_t r2 = x(0) * x(0) + x(1) * x(1);
    4949        Double_t cross = x(0) * p(1) - x(1) * p(0);
    5050        Double_t T = sqrt(pt * pt - 2 * a * cross + a * a * r2);
     
    6161        Double_t st = asin(B) / C;
    6262        Double_t ct = p(2) / pt;
    63         Double_t z0 = x(2) - ct * st;
     63        Double_t z0;
     64        Double_t dot = x(0) * p(0) + x(1) * p(1);
     65        if (dot > 0.0) z0 = x(2) - ct * st;
     66        else z0 = x(2) + ct * st;
    6467        //
    6568        Par(3) = z0;            // Store z0
     
    443446        TSpline3* sp3 = new TSpline3("sp3", bg, ncl, Npt);
    444447        if (begam > bg[0] && begam < bg[Npt - 1]) interp = sp3->Eval(begam);
    445         if(begam < bg[0]) interp = bg[0];
    446         if(begam > bg[Npt-1]) interp = bg[Npt-1];
    447448        return 100 * interp;
    448449}
  • external/TrackCovariance/TrkUtil.h

    r53f4746 ra47edcc  
    2525        // Service routines
    2626        //
    27         void SetB(Double_t Bz){ fBz = Bz; }
     27        void SetB(Double_t Bz) { fBz = Bz; }
    2828        TVectorD XPtoPar(TVector3 x, TVector3 p, Double_t Q);
    2929        TVector3 ParToP(TVectorD Par);
     
    5454                Double_t c = 2.99792458e8;      // speed of light m/sec
    5555                //return TMath::C()*1.0e-9;     // Incompatible with root5
    56                 return c*1.0e-9;                // Reduced speed of light
     56                return c*1.0e-9;                // Reduced speed of light       
    5757        }
    5858        //
     
    7171        // Cluster counting in gas
    7272        //
    73         void SetBfield(Double_t Bz){ fBz = Bz; }
    74         // Define gas volume (units = meters)
     73        void SetBfield(Double_t Bz) { fBz = Bz; }
     74        // Define gas volume (units = meters) 
    7575        void SetDchBoundaries(Double_t Rmin, Double_t Rmax, Double_t Zmin, Double_t Zmax);
    7676        // Gas mixture selection
Note: See TracChangeset for help on using the changeset viewer.