diff --git a/Trigger/TrigFTK/TrigFTKSim/TrigFTKSim/FTKTrack.h b/Trigger/TrigFTK/TrigFTKSim/TrigFTKSim/FTKTrack.h index 36d5b57ba6954808fc3109f0107eb0d077604b77..4204f0fe15f93f8b2df06c3dfdf55defb8bffcea 100644 --- a/Trigger/TrigFTK/TrigFTKSim/TrigFTKSim/FTKTrack.h +++ b/Trigger/TrigFTK/TrigFTKSim/TrigFTKSim/FTKTrack.h @@ -32,12 +32,12 @@ private: float m_origchi2; // In the case of majority recovery, this is the chi2 of // the full fit. In all other cases m_chi2 == m_origchi2 - int m_invptfw; // curvature value in the output format of the FW + float m_invptfw; // curvature value in the output format of the FW int m_d0fw; // impact parameter as calculated by the FW int m_phifw; // phi value as caculated by the FW int m_z0fw; // z0 from the FW - int m_cthetafw; // - double m_chi2fw; // chisq calculation using the AUX card or SS board firmware-like code + int m_cthetafw; // cot(theta) using the AUX card or SS board firmware-like code + int m_chi2fw; // chisq calculation using the AUX card or SS board firmware-like code int m_nmissing; // number of missing coordinates unsigned int m_typemask; // set on in bits related to the step recovery were used, ex.: 0 no recovery, 01, rec 1st step, 11, recovery in the 1st and the 2nd stage @@ -97,12 +97,12 @@ public: float getChi2ndof() const { return m_chi2/(m_ncoords-m_nmissing-5); } const float& getOrigChi2() const { return m_origchi2; } float getOrigChi2ndof() const { return m_origchi2/(m_ncoords-m_nmissing-5); } - int getInvPtFW() const { return m_invptfw; } + float getInvPtFW() const { return m_invptfw; } int getIPFW() const { return m_d0fw; } int getPhiFW() const { return m_phifw; } int getZ0FW() const { return m_z0fw; } int getCTheta() const { return m_cthetafw; } - double getChi2FW() const { return m_chi2fw; } + int getChi2FW() const { return m_chi2fw; } const int& getNMissing() const { return m_nmissing; } const unsigned int& getTypeMask() const { return m_typemask; } const unsigned int& getBitmask() const { return m_bitmask; } @@ -145,11 +145,12 @@ public: void setCotTheta(float v) { m_ctheta = v; } void setChi2(float v) { m_chi2 = v; } void setOrigChi2(float v) { m_origchi2 = v; } - void getInvPtFW(int v) { m_invptfw = v; } - void getIPFW(int v) { m_d0fw = v; } - void getPhiFW(int v) { m_phifw = v; } - void getZ0FW(int v) { m_z0fw = v; } - void getCTheta(int v) { m_cthetafw = v; } + void setInvPtFW(float v) { m_invptfw = v; } + void setIPFW(int v) { m_d0fw = v; } + void setPhiFW(int v,bool ForceRange=true); + void setZ0FW(int v) { m_z0fw = v; } + void setCTheta(int v) { m_cthetafw = v; } + void setChi2FW(int v) { m_chi2fw = v; } void setChi2FW(double v) { m_chi2fw = v; } void setNMissing(int v) { m_nmissing = v; } void setTypeMask(unsigned int v) { m_typemask = v; } diff --git a/Trigger/TrigFTK/TrigFTKSim/src/FTKConstantBank.cxx b/Trigger/TrigFTK/TrigFTKSim/src/FTKConstantBank.cxx index 47673ab9b1ed6275e1513819d5bc2b72aac16320..8dd0f92f6436d7930481d9bbcf8d0a286104452e 100644 --- a/Trigger/TrigFTK/TrigFTKSim/src/FTKConstantBank.cxx +++ b/Trigger/TrigFTK/TrigFTKSim/src/FTKConstantBank.cxx @@ -459,6 +459,7 @@ int FTKConstantBank::linfit(int secid, FTKTrack &track) const if (nmissing!=guess_res) { // majority failed, this chi2 is used as a flag track.setChi2(0.); + track.setChi2FW(0); } else { // evaluate the chi2 @@ -529,6 +530,7 @@ void FTKConstantBank::linfit_chisq(int secid, FTKTrack &trk) const { } trk.setChi2(chi2); + trk.setChi2FW(round(chi2)); } @@ -566,15 +568,20 @@ void FTKConstantBank::linfit_pars_eval(int secid, FTKTrack &trk) const if (m_npars>3) { trk.setZ0(pars[3]); + trk.setZ0FW(round(pars[3])); trk.setZ0Raw(pars[3]); trk.setCotTheta(pars[4]); + trk.setCTheta(round(pars[4])); } //cout << "secid: " << secid << endl; // cy debug //cout << "phi after corrgen: " << pars[2] << endl; //cy debug trk.setHalfInvPt(pars[0]); + trk.setInvPtFW(round(pars[0]*1e5)/1e5); trk.setIP(pars[1]); + trk.setIPFW(round(pars[1])); trk.setIPRaw(pars[1]); trk.setPhi(pars[2]); // angle is moved within -pi to +pi + trk.setPhiFW(round(pars[2])); // angle is moved within -3 to +3 trk.setPhiRaw(pars[2]); // angle is moved within -pi to +pi // cout << "phi within [-pi,pi]: " << track.getPhi() << endl; // cy debug @@ -668,8 +675,8 @@ int FTKConstantBank::missing_point_guess(FTKTrack &track, int secid, float *newc a[0] -= m_maj_kk[secid][col][m_missid[0]]*coords[col]; a[1] -= m_maj_kk[secid][col][m_missid[1]]*coords[col]; if (cmDebug > 8) { - printf("\ta[0] = %f\n",a[0]); - printf("\ta[1] = %f\n",a[1]); + FTKSetup::PrintMessageFmt(ftk::info,"\ta[0] = %f\n",a[0]); + FTKSetup::PrintMessageFmt(ftk::info,"\ta[1] = %f\n",a[1]); } } @@ -761,12 +768,12 @@ int FTKConstantBank::missing_point_guess(FTKTrack &track, int secid, float *newc } if (cmDebug > 5) { FTKSetup::PrintMessage(ftk::debg,"new coordinates:\n"); - if (newcoords) - for (int i=0;i<m_ncoords;++i) - printf("\t%d: %f\n",i,newcoords[i]); - else - for (int i=0;i<m_ncoords;++i) - printf("\t%d: %f\n",i,coords[i]); + if (newcoords) { + for (int i=0;i<m_ncoords;++i) FTKSetup::PrintMessageFmt(ftk::debg,"\t%d: %f\n",i,newcoords[i]); + } + else { + for (int i=0;i<m_ncoords;++i) FTKSetup::PrintMessageFmt(ftk::info,"\t%d: %f\n",i,coords[i]); + } FTKSetup::PrintMessage(ftk::debg,"\n"); } @@ -1727,7 +1734,7 @@ void FTKConstantBank::linfit_chisq_aux(int secid, FTKTrack &trk) const { // Otherwise, set to the caluclated value, scaled back to nominal units. float fchi2 = oflhw ? 9999999. : chi2HW / pow(2.0, 2.*13);//EFF_SHIFT); //Rui's change to match fw - trk.setChi2FW(fchi2); + trk.setChi2FW(round(fchi2)); trk.setChi2 (fchi2); // any negative hits? diff --git a/Trigger/TrigFTK/TrigFTKSim/src/FTKTrack.cxx b/Trigger/TrigFTK/TrigFTKSim/src/FTKTrack.cxx index 563fd20ce1db4caa5fcd27c7bd54eb2a42f9907a..43459d0fedbc97d113cfd72ce21cd35471ae45dd 100644 --- a/Trigger/TrigFTK/TrigFTKSim/src/FTKTrack.cxx +++ b/Trigger/TrigFTK/TrigFTKSim/src/FTKTrack.cxx @@ -2,6 +2,7 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ +#include "TrigFTKSim/FTKSetup.h" #include "TrigFTKSim/FTKTrack.h" #include <iostream> @@ -116,42 +117,46 @@ FTKTrack::~FTKTrack() // if ForceRange==true, then phi = [-pi..pi) void FTKTrack::setPhi(float phi, bool ForceRange) { - if (ForceRange) { - // when phi is ridiculously large, there is no point in adjusting it - if(fabs(phi)>100) { - if(m_chi2<100) { // this is a BAD track, so fail it if chi2 hasn't done so already - std::cout << "FTKTrack warning: fitted phi = " << phi << ", but chi2 = " << m_chi2 - << ". Adjusting to chi2+=100!" << std::endl; - m_chi2+=100; // we want to fail this event anyway - } - } - else { - while (phi>= TMath::Pi()) phi -= TMath::TwoPi(); - while (phi< -TMath::Pi()) phi += TMath::TwoPi(); - } + if (ForceRange && fabs(phi)>100 && m_chi2<100) { + // when phi is ridiculously large, there is no point in adjusting it. Also, since this is a BAD track, fail it if chi2 hasn't done so already + FTKSetup::PrintMessageFmt(ftk::warn, "FTKTrack warning: fitted phi = %f, but chi2 = %f. Adjusting to chi2+=100!", phi, m_chi2); + m_chi2+=100; // we want to fail this event anyway + } + else if (ForceRange && fabs(phi)<100){ + while (phi>= TMath::Pi()) phi -= TMath::TwoPi(); + while (phi< -TMath::Pi()) phi += TMath::TwoPi(); } m_phi = phi; } // if ForceRange==true, then phi = [-pi..pi) void FTKTrack::setPhiRaw(float phi, bool ForceRange) { - if (ForceRange) { - // when phi is ridiculously large, there is no point in adjusting it - if(fabs(phi)>100) { - if(m_chi2<100) { // this is a BAD track, so fail it if chi2 hasn't done so already - std::cout << "FTKTrack warning: fitted phi = " << phi << ", but chi2 = " << m_chi2 - << ". Adjusting to chi2+=100!" << std::endl; - m_chi2+=100; // we want to fail this event anyway - } - } - else { - while (phi>= TMath::Pi()) phi -= TMath::TwoPi(); - while (phi< -TMath::Pi()) phi += TMath::TwoPi(); - } + if (ForceRange && fabs(phi)>100 && m_chi2<100) { + // when phi is ridiculously large, there is no point in adjusting it. Also, since this is a BAD track, fail it if chi2 hasn't done so already + FTKSetup::PrintMessageFmt(ftk::warn, "FTKTrack warning: fitted phi = %f, but chi2 = %f. Adjusting to chi2+=100!", phi, m_chi2); + m_chi2+=100; // we want to fail this event anyway + } + else if (ForceRange && fabs(phi)<100){ + while (phi>= TMath::Pi()) phi -= TMath::TwoPi(); + while (phi< -TMath::Pi()) phi += TMath::TwoPi(); } m_rawphi = phi; } +// if ForceRange==true, then phifw = [-3..3) +void FTKTrack::setPhiFW(int phifw, bool ForceRange) { + // when phifw is ridiculously large, there is no point in adjusting it. Also, since this is a BAD track, fail it if chi2 hasn't done so already + if (ForceRange && abs(phifw)>100 && m_chi2fw<100) { + FTKSetup::PrintMessageFmt(ftk::warn, "FTKTrack warning: fitted phifw = %d, but chi2fw = %d. Adjusting to chi2fw+=100!", phifw, m_chi2fw); + m_chi2fw+=100; // we want to fail this event anyway + } + else if (ForceRange && abs(phifw)<100) { + while (phifw>= round(TMath::Pi())) phifw -= round(TMath::TwoPi()); + while (phifw< -round(TMath::Pi())) phifw += round(TMath::TwoPi()); + } + m_phifw = phifw; +} + /** set the number of coordinates connected with this track, a dim=0 is used to cleanup array content */ void FTKTrack::setNCoords(int dim) diff --git a/Trigger/TrigFTK/TrigFTKSim/src/TrackFitter711.cxx b/Trigger/TrigFTK/TrigFTKSim/src/TrackFitter711.cxx index 03087186eb137af48fe6afd25c07e23bd10b833b..60238859c5831f9c4a0e20afb169773adeb7c39e 100644 --- a/Trigger/TrigFTK/TrigFTKSim/src/TrackFitter711.cxx +++ b/Trigger/TrigFTK/TrigFTKSim/src/TrackFitter711.cxx @@ -1281,23 +1281,42 @@ void TrackFitter711::processor_Extrapolate(const FTKRoad &road, all hits for previous steps as real*/ unsigned int cbitmask(m_incomplete_coordsmask_eff); newtrk.setHalfInvPt(curtrackI.getHalfInvPt()); + newtrk.setInvPtFW(round(curtrackI.getInvPtFW()*1e5)/1e5); /* Fix from corrgen: in the constant generation, tracks in regions 3, 4, and 5 has phi defined in the range [0:2 PI]. For the extrapolation only checks if the angle is in those regions and fix the definition */ - if (m_ssmap_complete->getRegionMap()->getNumRegions()==8 && region>=3 && region<=5 && curtrackI.getPhi()<=0) - newtrk.setPhi(curtrackI.getPhi()+2*M_PI,false); - else if (m_ssmap_complete->getRegionMap()->getNumRegions()==64 && (region==9 || region==10 || region==25 || region==26 || region==41 || region==42 || region==57 || region==58) && curtrackI.getPhi()<=0) - newtrk.setPhi(curtrackI.getPhi()); - else + if (m_ssmap_complete->getRegionMap()->getNumRegions()==8) { // 8 Regions, constant generation step + if (region>=3 && region<=5) { // Regions 3, 4, and 5 + if (curtrackI.getPhi()<=0) { // The angle should be defined in the range [0:2 PI]. Otherwise we fix it. + newtrk.setPhi(curtrackI.getPhi()+2*M_PI,false); + newtrk.setPhiFW(round(curtrackI.getPhiFW()+2*M_PI),false); + } + } + } + else if (m_ssmap_complete->getRegionMap()->getNumRegions()==64) { // 64 Regions, extrapolation step + if (region==9 || region==10 || region==25 || region==26 || region==41 || region==42 || region==57 || region==58) { // Regions 9, 10, 25, 26, 41, 42, 57, and 58 + if (curtrackI.getPhi()<=0) { + newtrk.setPhi(curtrackI.getPhi()+2*M_PI,false); + newtrk.setPhiFW(round(curtrackI.getPhiFW()+2*M_PI),false); + } + } + } + else { // In other cases we don't have to force phi to be in the range [0:2 PI]. newtrk.setPhi(curtrackI.getPhi()); + newtrk.setPhiFW(round(curtrackI.getPhiFW())); + } // set the incomplete track with some original info newtrk.setIP(curtrackI.getIP()); + newtrk.setIPFW(round(curtrackI.getIPFW())); newtrk.setCotTheta(curtrackI.getCotTheta()); + newtrk.setCTheta(round(curtrackI.getCTheta())); newtrk.setZ0(curtrackI.getZ0()); + newtrk.setZ0FW(round(curtrackI.getZ0FW())); newtrk.setChi2(curtrackI.getChi2()); + newtrk.setChi2FW(round(curtrackI.getChi2FW())); newtrk.setOrigChi2(curtrackI.getOrigChi2()); newtrk.setCombinationID(curtrackI.getCombinationID()); @@ -3183,23 +3202,42 @@ void TrackFitter711::prepareTrack() { all hits for previous steps as real*/ m_cbitmask = m_incomplete_coordsmask_eff; newtrk.setHalfInvPt(newtrkI.getHalfInvPt()); + newtrk.setInvPtFW(round(newtrkI.getInvPtFW()*1e5)/1e5); /* Fix from corrgen: in the constant generation, tracks in regions 3, 4, and 5 has phi defined in the range [0:2 PI]. For the extrapolation only checks if the angle is in those regions and fix the definition */ - if (m_ssmap_complete->getRegionMap()->getNumRegions()==8 && m_region_for_superexp>=3 && m_region_for_superexp<=5 && newtrkI.getPhi()<=0) - newtrk.setPhi(newtrkI.getPhi()+2*M_PI,false); - else if (m_ssmap_complete->getRegionMap()->getNumRegions()==64 && (m_region_for_superexp==9 || m_region_for_superexp==10 || m_region_for_superexp==25 || m_region_for_superexp==26 || m_region_for_superexp==41 || m_region_for_superexp==42 || m_region_for_superexp==57 || m_region_for_superexp==58) && newtrkI.getPhi()<=0) - newtrk.setPhi(newtrkI.getPhi()); - else - newtrk.setPhi(newtrkI.getPhi()); + if (m_ssmap_complete->getRegionMap()->getNumRegions()==8) { // 8 Regions, constant generation step + if (m_region_for_superexp>=3 && m_region_for_superexp<=5) { // Regions 3, 4, and 5 + if (newtrkI.getPhi()<=0) { // The angle should be defined in the range [0:2 PI]. Otherwise we fix it. + newtrk.setPhi(newtrkI.getPhi()+2*M_PI,false); + newtrk.setPhiFW(round(newtrkI.getPhiFW()+2*M_PI),false); + } + } + } + else if (m_ssmap_complete->getRegionMap()->getNumRegions()==64) { // 64 Regions, extrapolation step + if (m_region_for_superexp==9 || m_region_for_superexp==10 || m_region_for_superexp==25 || m_region_for_superexp==26 || m_region_for_superexp==41 || m_region_for_superexp==42 || m_region_for_superexp==57 || m_region_for_superexp==58) { // Regions 9, 10, 25, 26, 41, 42, 57, and 58 + if (newtrkI.getPhi()<=0) { + newtrk.setPhi(newtrkI.getPhi()+2*M_PI,false); + newtrk.setPhiFW(round(newtrkI.getPhiFW()+2*M_PI),false); + } + } + } + else { // In other cases we don't have to force phi to be in the range [0:2 PI]. + newtrk.setPhi(newtrkI.getPhi()); + newtrk.setPhiFW(round(newtrkI.getPhiFW())); + } // set the incomplete track with some original info newtrk.setIP(newtrkI.getIP()); + newtrk.setIPFW(round(newtrkI.getIPFW())); newtrk.setCotTheta(newtrkI.getCotTheta()); + newtrk.setCTheta(round(newtrkI.getCTheta())); newtrk.setZ0(newtrkI.getZ0()); + newtrk.setZ0FW(round(newtrkI.getZ0FW())); newtrk.setChi2(newtrkI.getChi2()); + newtrk.setChi2FW(round(newtrkI.getChi2FW())); newtrk.setOrigChi2(newtrkI.getOrigChi2()); newtrk.setCombinationID(newtrkI.getCombinationID());