// from ROOT #include "TRotation.h" // from hydra #include "hkalmdchit.h" #include "hkalmdcmeaslayer.h" #include #include using namespace std; ClassImp(HKalMdcHit) //_HADES_CLASS_DESCRIPTION /////////////////////////////////////////////////////////////////////////////// // // Class: HKalMdcHit // // A hit point is a measurement vector. // KalMdcHit provides the position vector of the hit with errors and the // measurement layer of the Mini Drift Chamber where the hit was registered. // The input for the position vector should already be in the sector coordinate // system. The class itself won't do the transformation from layer to sector // coordinates. // It is recommended to make the hit vector two-dimensional. This will reduce // the calculation time for the Kalman Filter. Since the hit must be on the // surface of a measurement layer the third hit coordinate can be calculated. // //----------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////// // ----------------------------------- // Ctors and Dtor // ----------------------------------- HKalMdcHit::HKalMdcHit(Int_t dim) : TObject(), hitVec(dim), errVec(dim), fErr(dim, dim) { // Creates an empty hit object. // dim: dimension of hit vector measLayer = NULL; } HKalMdcHit::HKalMdcHit(Double_t *hit, Double_t *err, const HKalMdcMeasLayer &layer, Int_t dim, Double_t w) : TObject(), hitVec(dim), errVec(dim), fErr(dim, dim) { // Creates a measurement hit with arrays as input for the coordinates. // hit: The hit coordinates (only the first dim coordinates will be used) // err: The error vector (only the first dim coordinates will be used) // layer: The measurement layer were the hit was detected. // dim: The dimension of the hit vector. for(Int_t i = 0; i < dim; i++) { hitVec(i) = hit[i]; errVec(i) = err[i]; fErr(i,i) = errVec(i) * errVec(i); } measLayer = (HKalMdcMeasLayer*)&layer; weight = w; } HKalMdcHit::HKalMdcHit(const TVector3 &hit, const TVector3 &err, const HKalMdcMeasLayer &layer, Int_t dim, Double_t w) : TObject(), hitVec(dim), errVec(dim), fErr(dim, dim) { // Creates a measurement hit with TVectors as input for the coordinates. // hit: The hit coordinates (only the first dim coordinates will be used) // err: The error vector (only the first dim coordinates will be used) // layer: The measurement layer were the hit was detected. // dim: The dimension of the hit vector. setHitAndErr(hit, err); measLayer = (HKalMdcMeasLayer*)&layer; weight = w; } HKalMdcHit::~HKalMdcHit() { } // ----------------------------------- // Implementation of protected methods // ----------------------------------- void HKalMdcHit::setHitVec(const TVectorD &newhit) { // Replace the hit vector with the coordinates stored in the parameter newhit. // The dimension of the object's hit vector dimension will not be changed. Int_t dim = getDimension(); for(Int_t i = 0; i < dim; i++) { hitVec(i) = newhit[i]; } } void HKalMdcHit::setHitVec(const TVector3 &newhit) { // Replace the hit vector with the coordinates stored in the parameter newhit. // The dimension of the object's hit vector dimension will not be changed. Int_t dim = getDimension(); for(Int_t i = 0; i < dim; i++) { hitVec(i) = newhit[i]; } } void HKalMdcHit::setHitAndErr(const TVectorD &newhit, const TVectorD &newerr) { // Replace the hit and error vectors with the coordinates stored in the parameters // newhit and newerr. // The dimension of the object's hit vector dimension will not be changed. Int_t dim = getDimension(); for(Int_t i = 0; i < dim; i++) { hitVec(i) = newhit[i]; errVec(i) = newerr[i]; fErr(i,i) = errVec(i) * errVec(i); } } void HKalMdcHit::setHitAndErr(const TVector3 &newhit, const TVector3 &newerr) { // Replace the hit and error vectors with the coordinates stored in the parameters // newhit and newerr. // The dimension of the object's hit vector dimension will not be changed. Int_t dim = getDimension(); for(Int_t i = 0; i < dim; i++) { hitVec(i) = newhit[i]; errVec(i) = newerr[i]; fErr(i,i) = newerr[i] * newerr[i]; } } // ----------------------------------- // Implementation of public methods // ----------------------------------- Bool_t HKalMdcHit::areCompetitors(const HKalMdcHit &hit1, const HKalMdcHit &hit2) { Int_t mod1 = hit1.getMeasLayer().getModule(); Int_t sec1 = hit1.getMeasLayer().getSector(); Int_t lay1 = hit1.getMeasLayer().getLayer(); Int_t mod2 = hit2.getMeasLayer().getModule(); Int_t sec2 = hit2.getMeasLayer().getSector(); Int_t lay2 = hit2.getMeasLayer().getLayer(); if(mod1 == mod2 && sec1 == sec2 && lay1 == lay2) { return kTRUE; } return kFALSE; } Int_t HKalMdcHit::Compare(const TObject *obj) const { if(getWeight() < ((const HKalMdcHit*)obj)->getWeight()) { return -1; } else if(getWeight() > ((const HKalMdcHit*)obj)->getWeight()) { return 1; } return 0; } void HKalMdcHit::print(const Option_t *opt) const { // Prints information about the hit object. // opt: Determines what information about the object will be printed. // If opt contains: // "Hit": print hit and error vectors. // "Lay": print geometry information about the hit's measurement layer. // "Mat": print material information about the hit's measurement layer. // If opt is empty all of the above will be printed. TString stropt(opt); // Print hit coordinates and errors. cout<print(opt); } else { cout<<"No measurement layer defined."<transform(transMat); } void HKalMdcHit::getHitVec3(TVector3& hit3) const { // Returns the hit coordinates as a TVector3. If the measurement vector dimension // is less than three then the third coordinate will be calculated. hit3.SetX(hitVec(0)); hit3.SetY(hitVec(1)); // To get the z coordinate, calculate the intersection with the hit's measurement layer. if(getDimension() < 3) { hit3.SetZ(0.); TVector3 pointIntersect = hit3; measLayer->findIntersection(pointIntersect, hit3, TVector3(0.,0.,1.)); hit3.SetZ(pointIntersect.z()); } else { hit3.SetZ(hitVec(2)); } } void HKalMdcHit::getErrVec3(TVector3& err3) const { // Returns the error vector as a TVector3. If the measurement vector dimension // is less than three then the error in z direction will be set to Zero. err3.SetX(errVec(0)); err3.SetY(errVec(1)); if(getDimension() < 3) { err3.SetZ(0); } else { err3.SetZ(errVec(2)); } }