Commit 5834131a authored by sergeizharko's avatar sergeizharko Committed by s.zharko@gsi.de
Browse files

COMMIT FROM 23.12.2021

  - cbmroot/reco/L1/L1Algo/L1BaseStationInfo.h:
    > a prototype of user-friendly interface to L1Station and other geometry inputs to L1Algo (experimental)
    > added setters and getters for L1Station data fields
    > added calculation of hidden L1Station properties
    > added Print() method
  - cbmroot/reco/L1/L1Algo/L1Parameters.h:
    > add new compile time constants: kMaxNFieldApproxCoefficients, kStationBits, kThreadBits, kTripletBits,
      kMaxNstations, kMaxNthreads, kMaxNtriplets
    > add new runtime "constants": fMaxDoubletsPerSinglet, fMaxTripletPerDoublets
    > add Print() method
  - cbmroot/reco/L1/L1Algo/L1Algo.h:
    > modifications according to the constants transfer to the L1Parameters class (example: fkMaxNthreads ==> L1Parameters::kMaxNthreads)
  - cbmroot/reco/L1/L1Algo/L1Algo.cxx:
    > add L1Parameters::Print() call from L1Algo::Init()
    > modifications according to the constants transfer to the L1Parameters class (example: fkMaxNthreads ==> L1Parameters::kMaxNthreads)
  - cbmroot/reco/L1/L1Algo/L1CATrackFinder.cxx:
    > modifications according to the constants transfer to the L1Parameters class (example: fkMaxNthreads ==> L1Parameters::kMaxNthreads)
  - cbmroot/reco/L1/L1Algo/L1TrackFitter.cxx:
    > modifications according to the constants transfer to the L1Parameters class (example: fkMaxNthreads ==> L1Parameters::kMaxNthreads)
  - cbmroot/reco/L1/L1Algo/L1Field.h:
    > magic constant '21' changed to L1Parameters::kMaxNFieldApproxCoefficients (compile time)
  - cmbroot/reco/L1/CbmL1.h:
    > add a L1Paramters class field (currently ptr to address in the heap) to CbmL1
    > add getter for the L1Parameters class field to CbmL1
  - cbmroot/reco/L1/CbmL1.cxx:
    > add transfer of the L1Parameters data from CbmL1 to L1Algo
    > modifications according to the constants transfer to the L1Parameters class (example: fkMaxNthreads ==> L1Parameters::kMaxNthreads)
  - cbmroot/macro/run/run_reco.C:
    > add example of L1Algo runtime constants modification
parent b4e190e6
......@@ -390,6 +390,11 @@ void run_reco(TString input = "", Int_t nTimeSlices = -1, Int_t firstTimeSlice =
std::cout << "Using material budget file " << parFile << std::endl;
l1->SetStsMaterialBudgetFileName(parFile.Data());
}
// ---- L1Algo runtime constants selection interface example ------
l1->GetL1Parameters()->SetMaxDoubletsPerSinglet(125);
// ----------------------------------------------------------------
run->AddTask(l1);
std::cout << "-I- " << myName << ": Added task " << l1->GetName() << std::endl;
......
......@@ -752,6 +752,14 @@ InitStatus CbmL1::Init()
LOG(error) << "-E- CbmL1: Read geometry from file " << fSTAPDataDir + "geo_algo.txt was NOT successful.";
}
if (fL1ParametersPtr) {
algo->SetL1Parameters(*fL1ParametersPtr);
delete fL1ParametersPtr;
} else {
LOG(error) << "-E- CbmL1: L1Parameters object was not transfered to the L1Algo core. Default parameters "
<< "will be used.";
}
algo->Init(geo, fUseHitErrors, fTrackingMode, fMissingHits);
geo.clear();
......@@ -1622,12 +1630,14 @@ void CbmL1::WriteSTAPAlgoData() // must be called after ReadEvent
// write StsHitsStartIndex and StsHitsStopIndex
n = 20;
for (int i = 0; i < n; i++) {
if (int(algo->fkMaxNstations) + 1 > i) fadata << algo->StsHitsStartIndex[i] << endl;
else
if (int(L1Parameters::kMaxNstations) + 1 > i) {
fadata << algo->StsHitsStartIndex[i] << endl;
} else {
fadata << 0 << endl;
}
};
for (int i = 0; i < n; i++) {
if (int(algo->fkMaxNstations) + 1 > i) fadata << algo->StsHitsStopIndex[i] << endl;
if (int(L1Parameters::kMaxNstations) + 1 > i) fadata << algo->StsHitsStopIndex[i] << endl;
else
fadata << 0 << endl;
};
......@@ -1651,7 +1661,7 @@ void CbmL1::WriteSTAPPerfData() // must be called after ReadEvent
TString fpdata_name = fSTAPDataDir + "data_perfo.txt";
// write data for performance in file
// if ( vNEvent <= maxNEvent ) {
if (1) {
if (1) {
if (vNEvent == 1) fpdata.open(fpdata_name, std::fstream::out); // begin new file
else
......@@ -1878,16 +1888,16 @@ void CbmL1::ReadSTAPAlgoData()
<< " have been read." << endl;
}
// read StsHitsStartIndex and StsHitsStopIndex
n = 20;
n = 20; // TODO: Why 20?
for (int i = 0; i < n; i++) {
int tmp;
fadata >> tmp;
if (int(algo->fkMaxNstations) + 1 > i) (const_cast<unsigned int&>(algo->StsHitsStartIndex[i]) = tmp);
if (int(L1Parameters::kMaxNstations) + 1 > i) (const_cast<unsigned int&>(algo->StsHitsStartIndex[i]) = tmp);
}
for (int i = 0; i < n; i++) {
int tmp;
fadata >> tmp;
if (int(algo->fkMaxNstations) + 1 > i) (const_cast<unsigned int&>(algo->StsHitsStopIndex[i]) = tmp);
if (int(L1Parameters::kMaxNstations) + 1 > i) (const_cast<unsigned int&>(algo->StsHitsStopIndex[i]) = tmp);
}
cout << "-I- CbmL1: CATrackFinder data for event " << nEvent << " has been read from file " << fadata_name
......
......@@ -117,6 +117,8 @@ public:
TString fSTAPDataDir_ = "./", int findParticleMode_ = 0);
~CbmL1(/*if (targetFieldSlice) delete;*/);
L1Parameters* GetL1Parameters() { return fL1ParametersPtr; }
void SetStsMaterialBudgetFileName(TString fileName) { fStsMatBudgetFileName = fileName; }
void SetMvdMaterialBudgetFileName(TString fileName) { fMvdMatBudgetFileName = fileName; }
......@@ -215,6 +217,7 @@ public:
private:
static CbmL1* fInstance;
L1Parameters* fL1ParametersPtr {new L1Parameters()}; ///< pointer to L1Algo parameters class instance
L1AlgoInputData* fData {nullptr};
......@@ -222,12 +225,12 @@ private:
int nMvdPoints {0};
L1Vector<int> vMCPoints_in_Time_Slice {"CbmL1::vMCPoints_in_Time_Slice"};
int NStation {0}; // number of all detector stations
int NMvdStations {0}; // number of mvd stations
int NStsStations {0}; // number of sts stations
int NMuchStations {0}; // number of much stations
int NTrdStations {0}; // number of trd stations
int NTOFStation {0}; // number of tof stations
int NStation {0}; ///< number of all detector stations
int NMvdStations {0}; ///< number of mvd stations
int NStsStations {0}; ///< number of sts stations
int NMuchStations {0}; ///< number of much stations
int NTrdStations {0}; ///< number of trd stations
int NTOFStation {0}; ///< number of tof stations
Int_t fPerformance {0}; // 0 - w\o perf. 1 - L1-Efficiency definition. 2 - QA-Eff.definition
double fTrackingTime {0.}; // time of track finding
......
......@@ -10,16 +10,16 @@
L1Algo::L1Algo(unsigned int nThreads)
{
SetNThreads(nThreads);
for (unsigned int i = 0; i < fkMaxNstations; i++) {
for (unsigned int i = 0; i < L1Parameters::kMaxNstations; i++) {
vGridTime[i].AllocateMemory(fNThreads);
}
}
void L1Algo::SetNThreads(unsigned int n)
{
if (n > static_cast<unsigned int>(fkMaxNthreads)) {
if (n > static_cast<unsigned int>(L1Parameters::kMaxNthreads)) { // TODO: Why do we need static_cast here?
LOG(fatal) << "L1Algo: n threads " << n << " is greater than the maximum "
<< static_cast<unsigned int>(fkMaxNthreads) << std::endl;
<< static_cast<unsigned int>(L1Parameters::kMaxNthreads); // The same
}
fNThreads = n;
......@@ -52,7 +52,7 @@ void L1Algo::SetNThreads(unsigned int n)
du[i].reserve(MaxPortionTriplets / fvecLen);
dv[i].reserve(MaxPortionTriplets / fvecLen);
for (unsigned int j = 0; j < fkMaxNstations; j++) {
for (unsigned int j = 0; j < L1Parameters::kMaxNstations; j++) {
fTriplets[j][i].SetName(std::stringstream() << "L1Algo::fTriplets[" << i << "][" << j << "]");
}
}
......@@ -61,6 +61,7 @@ void L1Algo::SetNThreads(unsigned int n)
void L1Algo::Init(const L1Vector<fscal>& geo, const bool UseHitErrors, const TrackingMode mode, const bool MissingHits)
{
fL1Parameters.Print(); // TODO: Wrap this line into debug
for (int iProc = 0; iProc < 4; iProc++) {
for (int i = 0; i < 8; i++) {
......@@ -282,7 +283,7 @@ void L1Algo::SetData(L1Vector<L1Hit>& StsHits_, int nStsStrips_, L1Vector<unsign
fRecoHits_local[i].reserve(nHits);
fTrackCandidates[i].clear();
fTrackCandidates[i].reserve(nHits / 10);
for (unsigned int j = 0; j < fkMaxNstations; j++) {
for (unsigned int j = 0; j < L1Parameters::kMaxNstations; j++) {
fTriplets[j][i].clear();
fTriplets[j][i].reserve(2 * nHits);
}
......
......@@ -95,62 +95,68 @@ public:
float GetDefaultParticleMass2() const { return fDefaultMass * fDefaultMass; }
float fDefaultMass = 0.10565800; // muon mass
// NOTE: technically it is a default value, so it can be modified
// with a setter. But on other hand it is a phys constant, so we must
// think again whether to handle the numerical literal as constexpr or not
//float fDefaultMass = L1Parameters::kMuonMass; // muon mass
static constexpr unsigned int fkStationBits = 6;
static constexpr unsigned int fkThreadBits = 6;
static constexpr unsigned int fkTripletBits = 32 - fkStationBits - fkThreadBits;
/////--> moved to L1Parameters
/////static constexpr unsigned int fkStationBits = 6;
/////static constexpr unsigned int fkThreadBits = 6;
/////static constexpr unsigned int fkTripletBits = 32 - fkStationBits - fkThreadBits;
static constexpr unsigned int fkMaxNstations = (1 << fkStationBits); // 2^6 =64
static constexpr unsigned int fkMaxNthreads = (1 << fkThreadBits); // 2^6 = 64
static constexpr unsigned int fkMaxNtriplets = (1 << fkTripletBits); // 2^20 = 262,144
/////static constexpr unsigned int fkMaxNstations = (1 << fkStationBits); // 2^6 =64
/////static constexpr unsigned int fkMaxNthreads = (1 << fkThreadBits); // 2^6 = 64
/////static constexpr unsigned int fkMaxNtriplets = (1 << fkTripletBits); // 2^20 = 262,144
unsigned int fMaxDoubletsPerSinglet = 150;
unsigned int fMaxTripletPerDoublets = 15;
/////--> moved to L1Parameters
/////unsigned int fMaxDoubletsPerSinglet = 150;
/////unsigned int fMaxTripletPerDoublets = 15;
/// pack station, thread and triplet indices to an unique triplet ID
static unsigned int PackTripletId(unsigned int Station, unsigned int Thread, unsigned int Triplet)
{
#ifndef FAST_CODE
assert(Station < fkMaxNstations);
assert(Thread < fkMaxNthreads);
assert(Triplet < fkMaxNtriplets);
assert(Station < L1Parameters::kMaxNstations);
assert(Thread < L1Parameters::kMaxNthreads);
assert(Triplet < L1Parameters::kMaxNtriplets);
#endif
constexpr unsigned int kMoveThread = fkTripletBits;
constexpr unsigned int kMoveStation = fkTripletBits + fkThreadBits;
constexpr unsigned int kMoveThread = L1Parameters::kTripletBits;
constexpr unsigned int kMoveStation = L1Parameters::kTripletBits + L1Parameters::kThreadBits;
return (Station << kMoveStation) + (Thread << kMoveThread) + Triplet;
}
/// unpack the triplet ID to its station index
static unsigned int TripletId2Station(unsigned int ID)
{
constexpr unsigned int kMoveStation = fkTripletBits + fkThreadBits;
constexpr unsigned int kMoveStation = L1Parameters::kTripletBits + L1Parameters::kThreadBits;
return ID >> kMoveStation;
}
/// unpack the triplet ID to its thread index
static unsigned int TripletId2Thread(unsigned int ID)
{
constexpr unsigned int kMoveThread = fkTripletBits;
constexpr unsigned int kThreadMask = (1 << fkThreadBits) - 1;
constexpr unsigned int kMoveThread = L1Parameters::kTripletBits;
constexpr unsigned int kThreadMask = (1 << L1Parameters::kThreadBits) - 1;
return (ID >> kMoveThread) & kThreadMask;
}
/// unpack the triplet ID to its triplet index
static unsigned int TripletId2Triplet(unsigned int ID)
{
constexpr unsigned int kTripletMask = (1 << fkTripletBits) - 1;
constexpr unsigned int kTripletMask = (1 << L1Parameters::kTripletBits) - 1;
return ID & kTripletMask;
}
L1Vector<L1Triplet> fTriplets[fkMaxNstations][fkMaxNthreads] {
L1Vector<L1Triplet> fTriplets[L1Parameters::kMaxNstations][L1Parameters::kMaxNthreads] { //<--------
{"L1Algo::fTriplets"}}; // created triplets at station + thread
// Track candidates created out of adjacent triplets before the final track selection.
// The candidates may share any amount of hits.
L1Vector<L1Branch> fTrackCandidates[fkMaxNthreads] {"L1Algo::fTrackCandidates"};
L1Vector<L1Branch> fTrackCandidates[L1Parameters::kMaxNthreads] {"L1Algo::fTrackCandidates"};
Tindex fDupletPortionStopIndex[fkMaxNstations] {0}; // end of the duplet portions for the station
Tindex fDupletPortionStopIndex[L1Parameters::kMaxNstations] {0}; // end of the duplet portions for the station
L1Vector<Tindex> fDupletPortionSize {"L1Algo::fDupletPortionSize"}; // N duplets in a portion
//
......@@ -207,18 +213,18 @@ public:
void SetNThreads(unsigned int n);
int NStations {0}; // number of all detector stations
int NMvdStations {0}; // number of mvd stations
int NStsStations {0}; // number of sts stations
int fNfieldStations {0}; // number of stations in the field region
int NStations {0}; ///< number of all detector stations
int NMvdStations {0}; ///< number of mvd stations
int NStsStations {0}; ///< number of sts stations
int fNfieldStations {0}; ///< number of stations in the field region
L1Station vStations[fkMaxNstations] _fvecalignment; // station info
L1Station vStations[L1Parameters::kMaxNstations] _fvecalignment; // station info
L1Vector<L1Material> fRadThick {"fRadThick"}; // material for each station
int NStsStrips {0}; // number of strips
L1Vector<L1Hit>* vStsHits {nullptr}; // hits as a combination of front-, backstrips and z-position
L1Grid vGrid[fkMaxNstations]; // hits as a combination of front-, backstrips and z-position
L1Grid vGridTime[fkMaxNstations];
L1Grid vGrid[L1Parameters::kMaxNstations]; // hits as a combination of front-, backstrips and z-position
L1Grid vGridTime[L1Parameters::kMaxNstations];
L1Vector<unsigned char>* fStripFlag {nullptr}; // information of hits station & using hits in tracks;
......@@ -240,8 +246,8 @@ public:
L1Vector<L1HitPoint> vStsDontUsedHitsxy_A {"L1Algo::vStsDontUsedHitsxy_A"};
L1Vector<L1HitPoint> vStsDontUsedHitsxy_buf {"L1Algo::vStsDontUsedHitsxy_buf"};
L1Vector<L1HitPoint> vStsDontUsedHitsxy_B {"L1Algo::vStsDontUsedHitsxy_B"};
L1Vector<L1Track> fTracks_local[fkMaxNthreads] {"L1Algo::fTracks_local"};
L1Vector<THitI> fRecoHits_local[fkMaxNthreads] {"L1Algo::fRecoHits_local"};
L1Vector<L1Track> fTracks_local[L1Parameters::kMaxNthreads] {"L1Algo::fTracks_local"};
L1Vector<THitI> fRecoHits_local[L1Parameters::kMaxNthreads] {"L1Algo::fRecoHits_local"};
L1Vector<THitI> RealIHit_v {"L1Algo::RealIHit_v"};
L1Vector<THitI> RealIHit_v_buf {"L1Algo::RealIHit_v_buf"};
......@@ -260,8 +266,8 @@ public:
bool fMissingHits {0};
TrackingMode fTrackingMode {kSts};
fvec EventTime[fkMaxNthreads][fkMaxNthreads] {{0}};
fvec Err[fkMaxNthreads][fkMaxNthreads] {{0}};
fvec EventTime[L1Parameters::kMaxNthreads][L1Parameters::kMaxNthreads] {{0}};
fvec Err[L1Parameters::kMaxNthreads][L1Parameters::kMaxNthreads] {{0}};
/// standard sizes of the arrays
......@@ -280,8 +286,7 @@ public:
MaxArrSize =
MaxNPortion * MaxPortionDoublets
/ fkMaxNstations //200000, // standart size of big arrays // mas be 40000 for normal work in cbmroot!
MaxNPortion * MaxPortionDoublets / L1Parameters::kMaxNstations //200000, // standart size of big arrays // mas be 40000 for normal work in cbmroot!
};
......@@ -294,38 +299,38 @@ public:
L1Vector<L1HitPoint>* vStsHitPointsUnused {nullptr};
THitI* RealIHit {nullptr}; // index in vStsHits indexed by index in vStsHitsUnused
THitI StsHitsUnusedStartIndex[fkMaxNstations + 1] {0};
THitI StsHitsUnusedStopIndex[fkMaxNstations + 1] {0};
THitI StsHitsUnusedStartIndexEnd[fkMaxNstations + 1] {0};
THitI StsHitsUnusedStopIndexEnd[fkMaxNstations + 1] {0};
THitI StsHitsUnusedStartIndex[L1Parameters::kMaxNstations + 1] {0};
THitI StsHitsUnusedStopIndex[L1Parameters::kMaxNstations + 1] {0};
THitI StsHitsUnusedStartIndexEnd[L1Parameters::kMaxNstations + 1] {0};
THitI StsHitsUnusedStopIndexEnd[L1Parameters::kMaxNstations + 1] {0};
L1Vector<int> TripForHit[2] {"L1Algo::TripForHit"};
L1Vector<int> TripForHit[2] {"L1Algo::TripForHit"}; // TODO: what does '2' stand for?
// fvec u_front[Portion/fvecLen], u_back[Portion/fvecLen];
// fvec zPos[Portion/fvecLen];
// fvec fHitTime[Portion/fvecLen];
nsL1::vector<L1TrackPar>::TSimd fT_3[fkMaxNthreads];
nsL1::vector<L1TrackPar>::TSimd fT_3[L1Parameters::kMaxNthreads];
L1Vector<THitI> fhitsl_3[fkMaxNthreads] {"L1Algo::fhitsl_3"};
L1Vector<THitI> fhitsm_3[fkMaxNthreads] {"L1Algo::fhitsm_3"};
L1Vector<THitI> fhitsr_3[fkMaxNthreads] {"L1Algo::fhitsr_3"};
L1Vector<THitI> fhitsl_3[L1Parameters::kMaxNthreads] {"L1Algo::fhitsl_3"};
L1Vector<THitI> fhitsm_3[L1Parameters::kMaxNthreads] {"L1Algo::fhitsm_3"};
L1Vector<THitI> fhitsr_3[L1Parameters::kMaxNthreads] {"L1Algo::fhitsr_3"};
nsL1::vector<fvec>::TSimd fu_front3[fkMaxNthreads];
nsL1::vector<fvec>::TSimd fu_back3[fkMaxNthreads];
nsL1::vector<fvec>::TSimd fz_pos3[fkMaxNthreads];
nsL1::vector<fvec>::TSimd fTimeR[fkMaxNthreads];
nsL1::vector<fvec>::TSimd fTimeER[fkMaxNthreads];
nsL1::vector<fvec>::TSimd dx[fkMaxNthreads];
nsL1::vector<fvec>::TSimd dy[fkMaxNthreads];
nsL1::vector<fvec>::TSimd du[fkMaxNthreads];
nsL1::vector<fvec>::TSimd dv[fkMaxNthreads];
nsL1::vector<fvec>::TSimd fu_front3[L1Parameters::kMaxNthreads];
nsL1::vector<fvec>::TSimd fu_back3[L1Parameters::kMaxNthreads];
nsL1::vector<fvec>::TSimd fz_pos3[L1Parameters::kMaxNthreads];
nsL1::vector<fvec>::TSimd fTimeR[L1Parameters::kMaxNthreads];
nsL1::vector<fvec>::TSimd fTimeER[L1Parameters::kMaxNthreads];
nsL1::vector<fvec>::TSimd dx[L1Parameters::kMaxNthreads];
nsL1::vector<fvec>::TSimd dy[L1Parameters::kMaxNthreads];
nsL1::vector<fvec>::TSimd du[L1Parameters::kMaxNthreads];
nsL1::vector<fvec>::TSimd dv[L1Parameters::kMaxNthreads];
// Tindex NHits_l[fkMaxNstations];
// Tindex NHits_l_P[fkMaxNstations];
// Tindex NHits_l[L1Parameters::kMaxNstations];
// Tindex NHits_l_P[L1Parameters::kMaxNstations];
/// ----- Output data -----
friend class CbmL1;
......@@ -359,7 +364,19 @@ public:
inline __attribute__((always_inline)) static bool GetFUsed(unsigned char flag) { return (flag & 0x02) != 0; }
// bool GetFUsedD ( unsigned char flag ){ return (flag&0x01)!=0; }
private:
/// Sets L1Algo parameters object
void SetL1Parameters(const L1Parameters& other) { fL1Parameters = other; }
/// Gets a constant reference to the L1Algo parameters object
const L1Parameters& GetL1Parameters() const { return fL1Parameters; }
// TODO: We should think about, where non-constexpr L1Alog parameters can be modified. At the moment we can create a
// L1Parameters object somewhere outside the L1Algo, fill its fields there and then pass it directly to
// the L1Algo instance.
private:
/// Object containing L1Parameters. Default consturctor is used
L1Parameters fL1Parameters;
/// ================================= FUNCTIONAL PART =================================
/// ----- Subroutines used by L1Algo::CATrackFinder() ------
......
......@@ -27,11 +27,13 @@
#include <iomanip>
//#include <cmath>
/// A base class which provides interface to L1Algo station geometry
class L1BaseStationInfo {
private:
private:
enum { // Here we list all the fields, which must be initialized by user
/// v Basic fields initialization
/// v L1Station initialization
// Basic fields initialization
// L1Station initialization
kEtype,
kEtimeInfo,
kEz,
......@@ -44,18 +46,10 @@ private:
kEstripsFrontSigma,
kEstripsBackPhi,
kEstripsBackSigma,
/// v The last item is equal to the number of bits in fInitFlags
// The last item is equal to the number of bits in fInitFlags
kEND
};
std::bitset<L1BaseStationInfo::kEND> fInitFlags; /// Set of
std::string fTypeName {"BASE"};
L1Station fL1Station {};
// TODO (!!!!) MUST THINK ABOUT THIS OBJECT LIFE TIME: will it be better to copy
// or to move it to the core? If the second, what should we do with
// getters? Do we need to lock them, when the fL1Station object will
// be transfered?
public:
public:
L1BaseStationInfo() {
std::cout << ">>>>>> L1BaseStationInfo: Constructor called\n"; // Temporary
}
......@@ -63,35 +57,41 @@ public:
std::cout << ">>>>>> L1BaseStationInfo: Destructor called\n"; // Temporary
}
///-----------------------------------------------------------------------------------------------------///
/// Basic methods ///
///-----------------------------------------------------------------------------------------------------///
//-------------------------------------------------------------------------------------------------------//
// Basic methods //
//-------------------------------------------------------------------------------------------------------//
std::string GetTypeName() const { return fTypeName; }
// Checks if all the necessary fields are initialized by user
bool IsInitialized() const { return fInitFlags.size() == fInitFlags.count(); };
// Transfers all gathered data to L1Algo
/// Returns the name of the station (TODO: connect official naming)
std::string GetTypeName() const { return fTypeName; }
/// Checks if all the necessary fields are initialized by user
bool IsInitialized() const { return fInitFlags.size() == fInitFlags.count(); }
/// Transfers all gathered data to L1Algo (TODO)
void TransferL1Station() {
/**********/
}
void TransferData() { /*********/ }
///-----------------------------------------------------------------------------------------------------///
/// Interface for L1Station object initialization ///
///-----------------------------------------------------------------------------------------------------///
/// Setters
//-------------------------------------------------------------------------------------------------------//
// Interface for L1Station object initialization //
//-------------------------------------------------------------------------------------------------------//
// Sets type of station // TODO: Temporary method, must be selected automatically in the derived class
//
// Setters
//
/// Sets type of station
void SetStationType(int inType) { fL1Station.type = inType; fInitFlags[kEtype] = true;}
// TODO: Temporary method, a type must be selected automatically in the derived classes
void SetTimeInfo(int inTimeInfo) { fL1Station.timeInfo = inTimeInfo; fInitFlags[kEtimeInfo] = true;}
// ???
/// Sets nominal z position of the station
void SetZ(double inZ) { fL1Station.z = inZ; fInitFlags[kEz] = true; }
/// Sets min transverse size of the station
void SetRmin(double inRmin) { fL1Station.Rmin = inRmin; fInitFlags[kERmin] = true; }
/// Sets max transverse size of the station
void SetRmax(double inRmax) { fL1Station.Rmax = inRmax; fInitFlags[kERmax] = true; }
// Sets material thickness and radiational length, calculates their ratio ("RadThick")
// and its logarithm ("logRadThick")
/// Sets station thickness and radiational length
void SetMaterial(double inThickness, double inRL) {
#ifndef L1_NO_ASSERT // check for zero denominator
L1_ASSERT(inRL, "Attempt of entering zero inRL (radiational length) value");
......@@ -104,9 +104,9 @@ public:
fInitFlags[kEmaterialInfoRL] = true;
}
// Sets coefficients of the magnetic field approximation
void SetFieldSlice(const double * Cx, const double * Cy, const double * Cz) {
for (int idx = 0; idx < L1Parameters::kN_FS_COEFFS; ++idx) {
/// Sets arrays of the approximation coefficients for the field x, y and z-components, respectively
void SetFieldSlice(const double* Cx, const double* Cy, const double* Cz) {
for (int idx = 0; idx < L1Parameters::kMaxNFieldApproxCoefficients; ++idx) {
fL1Station.fieldSlice.cx[idx] = Cx[idx];
fL1Station.fieldSlice.cy[idx] = Cy[idx];
fL1Station.fieldSlice.cz[idx] = Cz[idx];
......@@ -114,11 +114,12 @@ public:
}
}
// Sets stereo angles and sigmas for front and back strips, automatically set frontInfo, backInfo,
// XYInfo, xInfo and yInfo
void SetFBStripsGeometry(double f_phi, double f_sigma, double b_phi, double b_sigma) {
/// Sets stereo angles and sigmas for front and back strips, automatically set frontInfo, backInfo,
/// XYInfo, xInfo and yInfo
void SetFrontBackStripsGeometry(double f_phi, double f_sigma, double b_phi, double b_sigma) {
// TODO: may be is it better to define separate setters for these values and then calculate the
// rest somewhere below?
// TODO: move into .cxx file
//----- Original code from L1Algo ---------------------------------------------------------------------//
double c_f = cos(f_phi);
......@@ -176,34 +177,48 @@ public:
fInitFlags[kEstripsBackSigma] = true;
}
/// Getters
//
// Getters
//
/// Gets nominal z position of the station
fvec GetZ() const { return fL1Station.z; }
/// Gets min transverse size of the station
fvec GetRmin() const { return fL1Station.Rmin; }
/// Gets max transverse size of the station
fvec GetRmax() const { return fL1Station.Rmax; }
/// Gets material thickness
fvec GetMaterialThick() const { return fL1Station.materialInfo.thick; }
// TODO: investigate if thick, RL and RadThick are useful, may be we should have only
// GetMateralLogRadThick?
/// Gets the radiation length of the station material
fvec GetMaterialRL() const { return fL1Station.materialInfo.RL; } // TODO: -//-
fvec GetMaterialRadThick() const { return fL1Station.materialInfo.RadThick; } // TODO: -//-
/// Gets the relative material thickness in units of the radiational length
fvec GetMaterialRadThick() const { return fL1Station.materialInfo.RadThick; } // TODO: Rename?
/// Gets log of the relative material thickness in units of the radiational length
fvec GetMaterialLogRadThick() const { return fL1Station.materialInfo.logRadThick; }
// Methods to get particular element of Cx, Cy or Cz by its index
/// Gets a coefficient with idx for the field x-component approximation
fvec GetFieldSliceCx(int idx) const { return fL1Station.fieldSlice.cx[idx]; }
/// Gets a coefficient with idx for the field y-component approximation
fvec GetFieldSliceCy(int idx) const { return fL1Station.fieldSlice.cy[idx]; }
/// Gets a coefficient with idx for the field z-component approximation
fvec GetFieldSliceCz(int idx) const { return fL1Station.fieldSlice.cz[idx]; }
// Methods to get ptr to array of Cx, Cy or Cz
/// Gets array of the coefficients for the field x-component approximation
const fvec * GetFieldSliceCx() const { return fL1Station.fieldSlice.cx; }
/// Gets array of the coefficients for the field y-component approximation
const fvec * GetFieldSliceCy() const { return fL1Station.fieldSlice.cy; }
/// Gets array of the coefficients for the field z-component approximation
const fvec * GetFieldSliceCz() const { return fL1Station.fieldSlice.cz; }
// Methods to get strip layers geometry
///-----------------------------------------------------------------------------------------------------///
/// Other methods ///
///-----------------------------------------------------------------------------------------------------///
//-------------------------------------------------------------------------------------------------------//
// Other methods //
//-------------------------------------------------------------------------------------------------------//
/// Prints registered fields (TODO: tmp, may be one needs to wrap it into debug directives)
void Print() {
LOG(INFO) << "== L1Algo: station info ===========================================================";
LOG(INFO) << "";
......@@ -217,7 +232,7 @@ public:
LOG(INFO) << " log(X / X0): " << fL1Station.materialInfo.logRadThick[0] ;
LOG(INFO) << " Field approximation coefficients:";
LOG(INFO) << " idx CX CY CZ";
for (int idx = 0; idx < L1Parameters::kN_FS_COEFFS; ++idx) {
for (int idx = 0; idx < L1Parameters::kMaxNFieldApproxCoefficients; ++idx) {
LOG(INFO) << std::setw(9) << std::setfill(' ') << idx << ' '
<< std::setw(10) << std::setfill(' ') << fL1Station.fieldSlice.cx[idx][0] << ' '
<< std::setw(10) << std::setfill(' ') << fL1Station.fieldSlice.cy[idx][0] << ' '
......@@ -247,8 +262,20 @@ public:
LOG(INFO) << "";
LOG(INFO) << "===================================================================================";
}
private:
/// Flags set. A particular flag is up if the corresponding setter was called (experimental)
std::bitset<L1BaseStationInfo::kEND> fInitFlags;
std::string fTypeName {"BASE"};
L1Station fL1Station {};
// TODO (!!!!) MUST THINK ABOUT THIS OBJECT LIFE TIME: will it be better to copy
// or to move it to the core? If the second, what should we do with
// getters? Do we need to lock them, when the fL1Station object will
// be transfered?
};
#endif // L1BaseStationInfo_h
......@@ -540,10 +540,10 @@ inline void L1Algo::f20(
#ifndef FAST_CODE
//TODO: optimise triplet portion limit and put a warning
// assert(Ndoublets < fMaxDoubletsPerSinglet);
// assert(Ndoublets < fL1Parameters.GetMaxDoubletsPerSinglet());
#endif