Skip to content
Snippets Groups Projects
Commit 3cd7b04f authored by Dominik Smith's avatar Dominik Smith Committed by Florian Uhlig
Browse files

Removed digi indices from cbm::algo::tof::Hit. Stored indices in separate...

Removed digi indices from cbm::algo::tof::Hit. Stored indices in separate vector in cbm::algo::tof::Clusterizer.
parent 9a6fa5c0
No related branches found
No related tags found
1 merge request!1475Channel-partitioned TOF hits for tracking. Separate digi index output for cbm::tof::Hitfind.
...@@ -52,9 +52,10 @@ namespace cbm::algo::tof ...@@ -52,9 +52,10 @@ namespace cbm::algo::tof
// Output variables // Output variables
resultType result; resultType result;
std::vector<Hit>& clustersOut = std::get<0>(result); // Hits std::vector<Hit>& clustersOut = std::get<0>(result); // Hits
std::vector<size_t>& chanSizes = std::get<1>(result); // nClusters per channel std::vector<size_t>& chanSizes = std::get<1>(result); // nClusters per channel
std::vector<u32>& chanAddresses = std::get<2>(result); // channel addresses std::vector<u32>& chanAddresses = std::get<2>(result); // channel addresses
std::vector<int32_t>& digiIndRef = std::get<3>(result); // digi indices of clusters
// Reference cell of a cluster // Reference cell of a cluster
TofCell* cell = nullptr; TofCell* cell = nullptr;
...@@ -85,7 +86,7 @@ namespace cbm::algo::tof ...@@ -85,7 +86,7 @@ namespace cbm::algo::tof
while (1 < std::distance(digiIt, storDigi.end())) { while (1 < std::distance(digiIt, storDigi.end())) {
while (digiIt->first->GetSide() == std::next(digiIt, 1)->first->GetSide()) { // Not one Digi of each end! while (digiIt->first->GetSide() == std::next(digiIt)->first->GetSide()) { // Not one Digi of each end!
digiIt++; digiIt++;
if (2 > std::distance(digiIt, storDigi.end())) { break; } if (2 > std::distance(digiIt, storDigi.end())) { break; }
} }
...@@ -94,7 +95,7 @@ namespace cbm::algo::tof ...@@ -94,7 +95,7 @@ namespace cbm::algo::tof
// 2 Digis = both sides present // 2 Digis = both sides present
cell = &fParams.fChanPar[chan].cell; cell = &fParams.fChanPar[chan].cell;
CbmTofDigi* xDigiA = digiIt->first; CbmTofDigi* xDigiA = digiIt->first;
CbmTofDigi* xDigiB = std::next(digiIt, 1)->first; CbmTofDigi* xDigiB = std::next(digiIt)->first;
// use local coordinates, (0,0,0) is in the center of counter ? // use local coordinates, (0,0,0) is in the center of counter ?
ROOT::Math::XYZVector pos(((-(double) numChan / 2. + (double) chan) + 0.5) * cell->sizeX, 0., 0.); ROOT::Math::XYZVector pos(((-(double) numChan / 2. + (double) chan) + 0.5) * cell->sizeX, 0., 0.);
...@@ -148,13 +149,16 @@ namespace cbm::algo::tof ...@@ -148,13 +149,16 @@ namespace cbm::algo::tof
cluster.reset(); cluster.reset();
} }
} }
cluster.add(pos, time, totSum, totSum, digiIt->second, std::next(digiIt, 1)->second); cluster.add(pos, time, totSum, totSum);
digiIndRef.push_back(digiIt->second);
digiIndRef.push_back(std::next(digiIt)->second);
digiIt += 2; digiIt += 2;
lastChan = chan; lastChan = chan;
lastPosY = pos.Y(); lastPosY = pos.Y();
lastTime = time; lastTime = time;
AddNextChan(input, lastChan, cluster, clustersOut, &lastChanPos); AddNextChan(input, lastChan, cluster, clustersOut, digiIndRef, &lastChanPos);
} // while( 1 < storDigi.size() ) } // while( 1 < storDigi.size() )
// Apply subtraction such that chanSize constains hit count per channel // Apply subtraction such that chanSize constains hit count per channel
...@@ -177,7 +181,8 @@ namespace cbm::algo::tof ...@@ -177,7 +181,8 @@ namespace cbm::algo::tof
} }
bool Clusterizer::AddNextChan(std::vector<inputType>& input, int32_t lastChan, Hit& cluster, bool Clusterizer::AddNextChan(std::vector<inputType>& input, int32_t lastChan, Hit& cluster,
std::vector<Hit>& clustersOut, std::vector<inputType::iterator>* lastChanPos) std::vector<Hit>& clustersOut, std::vector<int32_t>& digiIndRef,
std::vector<inputType::iterator>* lastChanPos)
{ {
//D.Smith 25.8.23: Why are "C" digis (position "2") not considered here? //D.Smith 25.8.23: Why are "C" digis (position "2") not considered here?
...@@ -246,14 +251,16 @@ namespace cbm::algo::tof ...@@ -246,14 +251,16 @@ namespace cbm::algo::tof
const double totSum = xDigiA->GetTot() + xDigiB->GetTot(); const double totSum = xDigiA->GetTot() + xDigiB->GetTot();
ROOT::Math::XYZVector pos(posX, posY, 0.); ROOT::Math::XYZVector pos(posX, posY, 0.);
cluster.add(pos, time, totSum, totSum, i1->second, i2->second); cluster.add(pos, time, totSum, totSum);
digiIndRef.push_back(i1->second);
digiIndRef.push_back(i2->second);
// remove digis at positions i1 and i2 from pool in efficient way (replaces two vector::erase calls). // remove digis at positions i1 and i2 from pool in efficient way (replaces two vector::erase calls).
std::copy(i1 + 1, i2, i1); std::copy(i1 + 1, i2, i1);
std::copy(i2 + 1, storDigi.end(), i2 - 1); std::copy(i2 + 1, storDigi.end(), i2 - 1);
storDigi.resize(storDigi.size() - 2); storDigi.resize(storDigi.size() - 2);
if (AddNextChan(input, chan, cluster, clustersOut)) { if (AddNextChan(input, chan, cluster, clustersOut, digiIndRef)) {
return true; // signal hit was already added return true; // signal hit was already added
} }
i1 = storDigi.end(); // jump to end of outer loop i1 = storDigi.end(); // jump to end of outer loop
......
...@@ -27,7 +27,7 @@ namespace cbm::algo::tof ...@@ -27,7 +27,7 @@ namespace cbm::algo::tof
{ {
class Clusterizer { class Clusterizer {
public: public:
typedef std::tuple<std::vector<Hit>, std::vector<size_t>, std::vector<u32>> resultType; typedef std::tuple<std::vector<Hit>, std::vector<size_t>, std::vector<u32>, std::vector<int32_t>> resultType;
typedef std::vector<std::pair<CbmTofDigi*, int32_t>> inputType; typedef std::vector<std::pair<CbmTofDigi*, int32_t>> inputType;
/** /**
...@@ -58,7 +58,7 @@ namespace cbm::algo::tof ...@@ -58,7 +58,7 @@ namespace cbm::algo::tof
resultType buildClusters(std::vector<inputType>& input); resultType buildClusters(std::vector<inputType>& input);
bool AddNextChan(std::vector<inputType>& input, int32_t iLastChan, Hit& cluster, std::vector<Hit>& clustersOut, bool AddNextChan(std::vector<inputType>& input, int32_t iLastChan, Hit& cluster, std::vector<Hit>& clustersOut,
std::vector<inputType::iterator>* lastChanPos = nullptr); std::vector<int32_t>& digiIndRef, std::vector<inputType::iterator>* lastChanPos = nullptr);
}; };
} // namespace cbm::algo::tof } // namespace cbm::algo::tof
......
...@@ -48,9 +48,8 @@ namespace cbm::algo::tof ...@@ -48,9 +48,8 @@ namespace cbm::algo::tof
double hitTime = 0.0; double hitTime = 0.0;
double hitTimeErr = 0.0; double hitTimeErr = 0.0;
int32_t address = 0; int32_t address = 0;
size_t numchan = 0;
std::vector<int32_t> vDigiIndRef; double weightsSum = 0.0;
double weightsSum = 0.0;
// Interface for tracker // Interface for tracker
...@@ -65,27 +64,26 @@ namespace cbm::algo::tof ...@@ -65,27 +64,26 @@ namespace cbm::algo::tof
// Interface end // Interface end
int32_t numChan() { return vDigiIndRef.size() / 2; } int32_t numChan() const { return numchan; }
void reset() void reset()
{ {
vDigiIndRef.clear();
hitPos = ROOT::Math::XYZVector(0.0, 0.0, 0.0); hitPos = ROOT::Math::XYZVector(0.0, 0.0, 0.0);
hitPosErr = ROOT::Math::XYZVector(0.5, 0.5, 0.5); //D.Smith 15.8.23: Set this back to zero eventually. hitPosErr = ROOT::Math::XYZVector(0.0, 0.0, 0.0);
hitTime = 0.0; hitTime = 0.0;
hitTimeErr = 0.0; hitTimeErr = 0.0;
weightsSum = 0.0; weightsSum = 0.0;
address = 0; address = 0;
numchan = 0;
} }
void add(ROOT::Math::XYZVector pos, double time, double timeErr, double weight, int32_t digiIndA, int32_t digiIndB) void add(ROOT::Math::XYZVector pos, double time, double timeErr, double weight)
{ {
vDigiIndRef.push_back(digiIndA);
vDigiIndRef.push_back(digiIndB);
hitPos += pos * weight; hitPos += pos * weight;
hitTime += time * weight; hitTime += time * weight;
hitTimeErr += timeErr * weight; hitTimeErr += timeErr * weight;
weightsSum += weight; weightsSum += weight;
numchan++;
} }
void normalize(double timeErr) void normalize(double timeErr)
...@@ -137,7 +135,7 @@ namespace cbm::algo::tof ...@@ -137,7 +135,7 @@ namespace cbm::algo::tof
ar& hitTime; ar& hitTime;
ar& hitTimeErr; ar& hitTimeErr;
ar& address; ar& address;
ar& vDigiIndRef; ar& numchan;
ar& weightsSum; ar& weightsSum;
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment