#ifndef HFORWARDTOOLS_H #define HFORWARDTOOLS_H #include "hforwardcand.h" #include "hgeomvector.h" #include "hvirtualcandsim.h" #include class HForwardCand; class HFRpcHit; class HCategory; #if defined(__GNUC__) || defined(__clang__) #define DEPRECATED __attribute__((deprecated)) #elif defined(_MSC_VER) #define DEPRECATED __declspec(deprecated) #else #pragma message("WARNING: You need to implement DEPRECATED for this compiler") #define DEPRECATED #endif namespace HForwardTools { Float_t calcFRpcHitDistance(HForwardCand* fcand, HFRpcHit* hit); void setHadesParams(HVirtualCand* fcand, TVector3 base, TVector3 dir); inline void setHadesParams(HForwardCand* fcand, Double_t params[5]) { setHadesParams(fcand, TVector3(params[0], params[1], params[4]), TVector3(params[2], params[3], 1.)); } TVector2 getPlaneIntersect(HGeomVector base, HGeomVector dir, Float_t z); TVector2 getPlaneIntersect(HForwardCand* fcand, Float_t z); inline Double_t dca(HGeomVector b1, HGeomVector d1, HGeomVector b2, HGeomVector d2) { return fabs((b2 - b1).scalarProduct(d1.vectorProduct(d2)) / d1.vectorProduct(d2).length()); } inline Double_t dca(TVector3 b1, TVector3 d1, TVector3 b2, TVector3 d2) { return fabs((b2 - b1).Dot(d1.Cross(d2)) / d1.Cross(d2).Mag()); } void getParams(HForwardCand* const fcand, Double_t* pars); void setParams(HForwardCand* fcand, Double_t* pars); /** Calculate distance between track and FRpc hit at the FRPc plane. */ Float_t getFRpcDistance(HForwardCand* fcand, HFRpcHit* hit); /** * Calculates: * t^2 c^2 * ------- - 1 = (gamma^2 - 1)^-1 * l^2 */ Float_t calcGammaSquaredMinusOne(Float_t length, Float_t tof); /** Calc momentum base on track lenght, time of flight and particle mass. */ Float_t calcMomentum(Float_t length, Float_t tof, Float_t mass); /** * Takes vertex coordinate and the frpchit to calculate the distance between both hits, and store * the distance in the candidate. Recalculates other properties of the track related to the hit. * If either the vertex is invalid or the frpchit is missing, the distance and related proeprties * are reset to invalid as well. * * Side effects: * - sets kErrorLength if: * - no fRPC hit (length set to -1) * - incorrect veretx given (length set to -10) */ void correctPathLength(HForwardCand* fcand, HGeomVector vertex, HFRpcHit* frpchit); void correctPathLength(HForwardCand* fcand, HGeomVector vertex, Int_t frpcidx); /** * Takes vertex time and frpchit time and calcualets TOF. * Side effects: * - sets kErrorTof if: * - no fRPC tof (tof set to -1) * - no correct start time (tof set to -10) * - fRPC tof outside window (tof_wl:tof_wu) */ void correctPathTof(HForwardCand* fcand, Float_t start_time, HFRpcHit* frpchit, Float_t tof_wl, Float_t tof_wu); /** * Update track physics properties based on measured quantities. * Side effects: * - sets kErrorGamma if: * - gamma^2-1 is negative * - clears kIsUsed if: * - any other error flag is not set */ DEPRECATED inline void correctTrackProperties(HForwardCand* fcand, Float_t mass) { fcand->calc4vectorProperties(mass); } /** * Fill the particle info for kine tracks */ Bool_t fillVirtualCandSimInfo(HVirtualCandSim* part, HCategory* pKine, Int_t track); /** Templates to easily get vectors objects from object having getX/Y/Z functions. */ template V make_vector(T* obj) { return V(obj->getX(), obj->getY(), obj->getZ()); } } // namespace HForwardTools #endif /* HFORWARDTOOLS_H */