Commit 62cecb63 authored by Sergey Zharko's avatar Sergey Zharko
Browse files

L1Algo init: updates

parent c7a86743
......@@ -95,6 +95,7 @@ CbmL1* CbmL1::fInstance = 0;
CbmL1::CbmL1() : FairTask("L1")
{
if (!fInstance) fInstance = this;
if (!fpInitManager) { fpInitManager = algo_static.GetInitManager(); }
}
CbmL1::CbmL1(const char* name, Int_t iVerbose, Int_t _fPerformance, int fSTAPDataMode_, TString fSTAPDataDir_,
......@@ -106,6 +107,7 @@ CbmL1::CbmL1(const char* name, Int_t iVerbose, Int_t _fPerformance, int fSTAPDat
, fFindParticlesMode(findParticleMode_)
{
if (!fInstance) fInstance = this;
if (!fpInitManager) { fpInitManager = algo_static.GetInitManager(); }
}
CbmL1::~CbmL1()
......@@ -386,9 +388,10 @@ InitStatus CbmL1::Init()
NTOFStation = 0;
NStation = 0;
// TODO: Replace algo initialization in the constructor (S.Zharko)
algo = &algo_static;
L1Vector<fscal> geo("geo");
geo.reserve(10000);
......@@ -629,10 +632,6 @@ InitStatus CbmL1::Init()
CbmMuchLayer* layer = station->GetLayer((ist - NMvdStations - NStsStations) % 3);
// CbmMuchModuleGem* module = (CbmMuchModuleGem*) CbmMuchGeoScheme::Instance()->GetModule(0,0,0,0);
// vector<CbmMuchPad*> pads = module->GetPads();
z = layer->GetZ();
geo.push_back(2);
......@@ -824,37 +823,34 @@ InitStatus CbmL1::Init()
********************************************************************************************************************/
{ //L1Algo new init start
// Step 0: Get reference to the L1Algo initialization manager
L1InitManager* initMan = algo->GetInitManager();
// Step 1: Initialize magnetic field function
// Set magnetic field slices
auto fieldGetterFcn = [](const double(&inPos)[3], double(&outB)[3]) {
CbmKF::Instance()->GetMagneticField()->GetFieldValue(inPos, outB);
};
initMan->SetFieldFunction(fieldGetterFcn);
fpInitManager->SetFieldFunction(fieldGetterFcn);
// Step 2: Initialize target
auto& target = CbmKF::Instance()->vTargets[0];
initMan->SetTargetPosition(target.x, target.y, target.z);
fpInitManager->SetTargetPosition(target.x, target.y, target.z);
// Step 3: Initialize primary vertex field
initMan->InitTargetField(2.5);
fpInitManager->InitTargetField(2.5);
// Step 4: initialize IDs of detectors active in tracking
// TODO: temporary for tests, must be initialized somewhere in run_reco.C or similar (S.Zh.)
fActiveTrackingDetectorIDs = {L1DetectorID::kMvd, L1DetectorID::kSts};
initMan->SetActiveDetectorIDs(fActiveTrackingDetectorIDs);
fpInitManager->SetActiveDetectorIDs(fActiveTrackingDetectorIDs);
constexpr double PI = 3.14159265358; // TODO: why cmath is not used? (S.Zh.)
// Step 5: initialize number of stations for each detector ID
initMan->SetStationsNumberCrosscheck(L1DetectorID::kMvd, NMvdStations);
initMan->SetStationsNumberCrosscheck(L1DetectorID::kSts, NStsStations);
initMan->SetStationsNumberCrosscheck(L1DetectorID::kMuch, NMuchStations);
initMan->SetStationsNumberCrosscheck(L1DetectorID::kTrd, NTrdStations);
initMan->SetStationsNumberCrosscheck(L1DetectorID::kTof, NTOFStation);
fpInitManager->SetStationsNumberCrosscheck(L1DetectorID::kMvd, NMvdStations);
fpInitManager->SetStationsNumberCrosscheck(L1DetectorID::kSts, NStsStations);
fpInitManager->SetStationsNumberCrosscheck(L1DetectorID::kMuch, NMuchStations);
fpInitManager->SetStationsNumberCrosscheck(L1DetectorID::kTrd, NTrdStations);
fpInitManager->SetStationsNumberCrosscheck(L1DetectorID::kTof, NTOFStation);
// Step 6: setup station info
......@@ -879,7 +875,7 @@ InitStatus CbmL1::Init()
fscal mvdFrontSigma = mvdStationPar->GetXRes(iSt) / 10000;
fscal mvdBackSigma = mvdStationPar->GetYRes(iSt) / 10000;
stationInfo.SetFrontBackStripsGeometry(mvdFrontPhi, mvdFrontSigma, mvdBackPhi, mvdBackSigma);
initMan->AddStation(stationInfo);
fpInitManager->AddStation(stationInfo);
}
// Setup STS stations info
......@@ -907,7 +903,7 @@ InitStatus CbmL1::Init()
fscal stsFrontSigma = cbmSts->GetSensorPitch(0) / sqrt(12);
fscal stsBackSigma = stsFrontSigma;
stationInfo->SetFrontBackStripsGeometry(stsFrontPhi, stsFrontSigma, stsBackPhi, stsBackSigma);
initMan->AddStation(stationInfo);
fpInitManager->AddStation(stationInfo);
}
// Setup MuCh stations info
......@@ -932,7 +928,7 @@ InitStatus CbmL1::Init()
fscal muchFrontSigma = 0.1;
fscal muchBackSigma = 0.1;
stationInfo.SetFrontBackStripsGeometry(muchFrontPhi, muchFrontSigma, muchBackPhi, muchBackSigma);
initMan->AddStation(stationInfo);
fpInitManager->AddStation(stationInfo);
}
// Setup TRD stations info
......@@ -958,6 +954,7 @@ InitStatus CbmL1::Init()
fscal trdFrontSigma = 1.;
fscal trdBackSigma = 1.;
stationInfo.SetFrontBackStripsGeometry(trdFrontPhi, trdFrontSigma, trdBackPhi, trdBackSigma);
fpInitManager->AddStation(stationInfo);
}
// Setup TOF stations info
......@@ -976,6 +973,7 @@ InitStatus CbmL1::Init()
fscal tofFrontSigma = 1.;
fscal tofBackSigma = 1.;
stationInfo.SetFrontBackStripsGeometry(tofFrontPhi, tofFrontSigma, tofBackPhi, tofBackSigma);
fpInitManager->AddStation(stationInfo);
}
//initMan->PrintStations(/*vebosity = */ 1);
......@@ -1112,25 +1110,25 @@ InitStatus CbmL1::Init()
trackingIterAllPrimJump.SetMaxInvMom(1.0 / 0.3);
trackingIterAllSecJump.SetMaxInvMom(1.0 / 0.3);
initMan->SetCAIterationsNumberCrosscheck(4);
fpInitManager->SetCAIterationsNumberCrosscheck(4);
// Initialize CA track finder iterations sequence
initMan->PushBackCAIteration(trackingIterFastPrim);
initMan->PushBackCAIteration(trackingIterAllPrim);
initMan->PushBackCAIteration(trackingIterAllPrimJump);
initMan->PushBackCAIteration(trackingIterAllSec);
fpInitManager->PushBackCAIteration(trackingIterFastPrim);
fpInitManager->PushBackCAIteration(trackingIterAllPrim);
fpInitManager->PushBackCAIteration(trackingIterAllPrimJump);
fpInitManager->PushBackCAIteration(trackingIterAllSec);
}
else {
initMan->SetCAIterationsNumberCrosscheck(4);
fpInitManager->SetCAIterationsNumberCrosscheck(4);
// Initialize CA track finder iterations sequence
initMan->PushBackCAIteration(trackingIterFastPrim);
initMan->PushBackCAIteration(trackingIterAllPrim);
initMan->PushBackCAIteration(trackingIterAllPrimJump);
initMan->PushBackCAIteration(trackingIterAllSec);
//initMan->PushBackCAIteration(trackingIterAllPrimE);
//initMan->PushBackCAIteration(trackingIterAllSecE);
//initMan->PushBackCAIteration(trackingIterFastPrimJump);
//initMan->PushBackCAIteration(trackingIterFastPrim2);
//initMan->PushBackCAIteration(trackingIterAllSecJump);
fpInitManager->PushBackCAIteration(trackingIterFastPrim);
fpInitManager->PushBackCAIteration(trackingIterAllPrim);
fpInitManager->PushBackCAIteration(trackingIterAllPrimJump);
fpInitManager->PushBackCAIteration(trackingIterAllSec);
//fpInitManager->PushBackCAIteration(trackingIterAllPrimE);
//fpInitManager->PushBackCAIteration(trackingIterAllSecE);
//fpInitManager->PushBackCAIteration(trackingIterFastPrimJump);
//fpInitManager->PushBackCAIteration(trackingIterFastPrim2);
//fpInitManager->PushBackCAIteration(trackingIterAllSecJump);
}
// Set special cuts
......
......@@ -98,22 +98,6 @@ enum class L1DetectorID
kTrd
};
/// Enumeration for the CA Track finder iterations
/// NOTE: L1CAItrationType
enum class L1CAIterationType
{
kFastPrim, ///< primary fast tracks
kAllPrim, ///< primary all tracks
kAllPrimJump, ///< primary all tracks with jumped triplets
kAllSec, ///< secondary all tracks
kAllPrimE, ///< primary all electron tracks
kAllSecE, ///< secondary all electron tracks
kFastPrimJump, ///< primary fast tracks with jumped triplets
kAllSecJump, ///< secondary all tracks with jumped triplets
kEND ///< dummy item, represents number of iterations
};
// TODO: insert documentation! (S.Zh.)
//
/// L1Algo runtime constants modification can be performed in run_reco.C. Example:
......@@ -158,8 +142,8 @@ public:
~CbmL1(/*if (targetFieldSlice) delete;*/);
//L1Parameters* GetParameters() { return &fParameters; }
/// Gets a pointer to L1InitManager (for access in run_reco.C)
L1InitManager* GetInitManager() { return fpInitManager; }
/// Gets a set of active detectors used in tracking
// TODO: think about return (value, reference or const reference?) (S.Zh.)
std::set<L1DetectorID> GetActiveTrackingDetectorIDs() const { return fActiveTrackingDetectorIDs; }
......
......@@ -664,14 +664,14 @@ private:
fvec fMaxInvMom {L1Utils::kNaN}; // max considered q/p for tracks
fvec fMaxSlopePV {L1Utils::kNaN}; // max slope (tx\ty) in prim vertex
float fMaxSlope {L1Utils::kNaN}; // max slope (tx\ty) in 3d hit position of a triplet
fvec fCbmTargetX {L1Utils::kNaN}; // target position
fvec fCbmTargetX {L1Utils::kNaN}; // target position
fvec fCbmTargetY {L1Utils::kNaN};
fvec fCbmTargetZ {L1Utils::kNaN};
fvec fTargX {L1Utils::kNaN}; // target position for the current iteration
fvec fTargY {L1Utils::kNaN};
fvec fTargZ {L1Utils::kNaN};
L1FieldValue fTargB _fvecalignment {}; // field in the target point
L1FieldValue fTargB _fvecalignment {}; // field in the target point
L1XYMeasurementInfo TargetXYInfo _fvecalignment {}; // target constraint [cm]
......
......@@ -119,7 +119,8 @@ std::string L1CAIteration::ToString(int indentLevel) const
constexpr char indentChar = '\t';
std::string indent(indentLevel, indentChar);
aStream << indent << "L1CAIteration: " << fName << '\n';
aStream << indent << indentChar << "Is primary: " << fControlFlags[static_cast<int>(ControlFlag::kePrimary)] << '\n';
aStream << indent << indentChar
<< "Is primary: " << fControlFlags[static_cast<int>(ControlFlag::kePrimary)] << '\n';
aStream << indent << indentChar << "Track chi2 cut: " << fTrackChi2Cut << '\n';
aStream << indent << indentChar << "Triplet chi2 cut: " << fTripletChi2Cut << '\n';
aStream << indent << indentChar << "Doublet chi2 cut: " << fDoubletChi2Cut << '\n';
......
......@@ -19,7 +19,8 @@
/// flags.
///
class L1CAIteration {
enum class ControlFlag {
enum class ControlFlag
{
kePrimary, ///< true - track is primary, false - track is secondary (not primary)
keEnd
};
......@@ -65,7 +66,7 @@ public:
float GetTrackChi2Cut() const { return fTrackChi2Cut; }
/// Gets triplet chi2 upper cut
float GetTripletChi2Cut() const { return fTripletChi2Cut; }
/// flag check: primary tracks - true, secondary tracks - false
bool IsPrimary() const { return fControlFlags[static_cast<int>(ControlFlag::kePrimary)]; }
......@@ -123,7 +124,6 @@ private:
float fMaxDZ {0.f}; ///> Correction for accounting overlaping and iff z
float fTargetPosSigmaX {0}; ///> Constraint on target position in X direction [cm]
float fTargetPosSigmaY {0}; ///> Constraint on target position in Y direction [cm]
};
#endif // L1CAIteration_h
;/* Copyright (C) 2010-2018 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
; /* Copyright (C) 2010-2018 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Maksym Zyzak [committer] */
......
......@@ -1372,6 +1372,7 @@ inline void L1Algo::DupletsStaPort(
/// Find the doublets. Reformat data in the portion of doublets.
// TODO: repalce with constexpr if (C++17) (S.Zharko)
#ifdef DOUB_PERFORMANCE
L1Vector<THitI> hitsl_2("L1CATrackFinder::hitsl_2");
#endif // DOUB_PERFORMANCE
......@@ -1866,7 +1867,7 @@ void L1Algo::CATrackFinder()
//if ((isec == kAllPrimIter) || (isec == kAllPrimEIter) || (isec == kAllSecEIter))
// if (fTrackingMode == kMcbm) fMaxInvMom = 1 / 0.1; // max considered q/p
fMaxSlopePV = caIteration.GetMaxSlopePV(); //1.1;
//fMaxSlopePV = 1.1;
//if ( // (isec == kAllPrimIter) || (isec == kAllPrimEIter) || (isec == kAllPrimJumpIter) ||
......@@ -1883,12 +1884,14 @@ void L1Algo::CATrackFinder()
float SigmaTargetX = caIteration.GetTargetPosSigmaX();
float SigmaTargetY = caIteration.GetTargetPosSigmaY(); // target constraint [cm]
// Select magnetic field. For primary tracks - vtxFieldValue, for secondary tracks - st.fieldSlice
if (caIteration.IsPrimary()) { fTargB = vtxFieldValue; }
else { vStations[0].fieldSlice.GetFieldValue(0, 0, fTargB); } // NOTE: calculates field fTargB in the center of 0th station
if (caIteration.IsPrimary()) { fTargB = vtxFieldValue; }
else {
vStations[0].fieldSlice.GetFieldValue(0, 0, fTargB);
} // NOTE: calculates field fTargB in the center of 0th station
//if ((isec == kFastPrimIter) || (isec == kFastPrimIter2) || (isec == kFastPrimJumpIter) || (isec == kAllPrimIter)
// || (isec == kAllPrimEIter) || (isec == kAllPrimJumpIter)) { // target
// fTargB = vtxFieldValue;
......@@ -1912,7 +1915,7 @@ void L1Algo::CATrackFinder()
/// Set correction in order to take into account overlaping and iff z.
/// The reason is that low momentum tracks are too curved and goes not from target direction. That's why sort by hit_y/hit_z is not work idealy
/// If sort by y then it is max diff between same station's modules (~0.4cm)
fMaxDZ = caIteration.GetMaxDZ(); //0;
fMaxDZ = caIteration.GetMaxDZ(); //0;
//fMaxDZ = 0;
//if ((isec == kAllPrimIter) || (isec == kAllPrimEIter) || (isec == kAllPrimJumpIter) || (isec == kAllSecIter)
// || (isec == kAllSecEIter) || (isec == kAllSecJumpIter))
......
......@@ -154,7 +154,7 @@ void L1InitManager::PushBackCAIteration(const L1CAIteration& iteration)
// TODO: probably some checks must be inserted here (S.Zharko)
bool control = fInitController.GetFlag(InitKey::keCAIterationsNumberCrosscheck);
//std::cout << "L1InitManager::PushBackCAIteration " << control << '\n';
L1MASSERT(0, control, //fInitController.GetFlag(InitKey::keCAIterationsNumberCrosscheck),
L1MASSERT(0, control, //fInitController.GetFlag(InitKey::keCAIterationsNumberCrosscheck),
"Attempt to push back a CA track finder iteration before the number of iterations was defined");
L1Vector<L1CAIteration>& iterationsContainer = fpParameters->CAIterationsContainer();
......
......@@ -189,6 +189,7 @@ private:
/* Stations related fields */
std::set<L1BaseStationInfo> fStationsInfo {}; ///< Set of L1BaseStationInfo objects
/// Map of station numbers used for initialization crosscheck
L1DetectorIDIntMap_t fStationsNumberCrosscheck {};
/// A function which returns magnetic field vector B in a radius-vector xyz
......
......@@ -11,17 +11,17 @@
#define L1Utils_h 1
#include <iomanip>
#include <limits>
#include <map>
#include <sstream>
#include <string>
#include <unordered_map>
#include <limits>
/// Class contains some utility functions for L1Algo
struct L1Utils {
/// Some constants
static constexpr float kNaN {std::numeric_limits<float>::signaling_NaN()};
static constexpr float kNaN {std::numeric_limits<float>::signaling_NaN()};
/// Hash for unordered_map with enum class keys
struct EnumClassHash {
......@@ -78,4 +78,4 @@ struct L1Utils {
}
};
#endif // L1Utils_h
#endif // L1Utils_h
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment