Skip to content

Commit a1b5392

Browse files
committed
ITS3: macro fixes
Signed-off-by: Felix Schlepper <[email protected]>
1 parent 405a531 commit a1b5392

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

Detectors/Upgrades/ITS3/macros/test/CheckClusterSize.C

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "SimulationDataFormat/MCCompLabel.h"
4444
#include "SimulationDataFormat/MCEventHeader.h"
4545
#include "SimulationDataFormat/MCTrack.h"
46+
#include "ITS3Base/SpecsV2.h"
4647
#endif
4748
#define ENABLE_UPGRADES
4849
#include "SimulationDataFormat/MCTruthContainer.h"
@@ -65,7 +66,11 @@ void checkFile(const std::unique_ptr<TFile>& file);
6566

6667
inline auto hist_map(unsigned short id)
6768
{
68-
return std::clamp(id, static_cast<unsigned short>(0), static_cast<unsigned short>(6)) / 2;
69+
int lay = o2::its3::constants::detID::getDetID2Layer<int>(id);
70+
if (lay == -1) {
71+
return nLayers - 1;
72+
}
73+
return lay;
6974
}
7075

7176
void CheckClusterSize(std::string clusFileName = "o2clus_its.root",
@@ -133,7 +138,7 @@ void CheckClusterSize(std::string clusFileName = "o2clus_its.root",
133138
std::vector<TH2D> hOtherSecondaryEta;
134139
std::vector<TH2D> hOtherSecondaryPt;
135140
std::vector<TH2D> hOtherSecondaryPhi;
136-
for (int i = 0; i < 4; ++i) {
141+
for (int i = 0; i < nLayers; ++i) {
137142
hPrimary.emplace_back(Form("primary/L%d", i), Form("L%d Primary Cluster Size", i), maxClusterSize, 0, maxClusterSize);
138143
hPrimaryEta.emplace_back(Form("primary/EtaL%d", i), Form("L%d Primary Cluster Size vs Eta", i), maxClusterSize, 0, maxClusterSize, 100, -3.0, 3.0);
139144
hPrimaryPt.emplace_back(Form("primary/Pt%d", i), Form("L%d Primary Cluster Size vs Pt", i), maxClusterSize, 0, maxClusterSize, 100, 0.0, 10.0);
@@ -238,14 +243,15 @@ void CheckClusterSize(std::string clusFileName = "o2clus_its.root",
238243
int nROFRec = (int)rofRecVec.size();
239244
auto pattIt = patternsPtr->cbegin();
240245

246+
int cInvalid{0}, cGood{0};
241247
for (int irof = 0; irof < nROFRec; irof++) {
242248
const auto& rofRec = rofRecVec[irof];
243-
// rofRec.print();
249+
/*rofRec.print();*/
244250

245251
for (int icl = 0; icl < rofRec.getNEntries(); icl++) {
246252
int clEntry = rofRec.getFirstEntry() + icl;
247253
const auto& cluster = clusArr[clEntry];
248-
// cluster.print();
254+
/*cluster.print();*/
249255

250256
auto pattId = cluster.getPatternID();
251257
auto id = cluster.getSensorID();
@@ -260,13 +266,15 @@ void CheckClusterSize(std::string clusFileName = "o2clus_its.root",
260266

261267
const auto& label = (clusLabArr->getLabels(clEntry))[0];
262268
if (!label.isValid() || label.getSourceID() != 0 || !label.isCorrect()) {
269+
++cInvalid;
263270
continue;
264271
}
272+
++cGood;
265273

266274
const int trackID = label.getTrackID();
267275
int evID = label.getEventID();
268276
const auto& pInfo = info[evID][trackID];
269-
if (id > 6) {
277+
if (!o2::its3::constants::detID::isDetITS3(id)) {
270278
hOuterBarrel.Fill(clusterSize);
271279
}
272280

@@ -332,6 +340,7 @@ void CheckClusterSize(std::string clusFileName = "o2clus_its.root",
332340
}
333341
}
334342
}
343+
std::cout << "Good labels: " << cGood << "; invalid: " << cInvalid << '\n';
335344
std::cout << "Done measuring cluster sizes:" << std::endl;
336345
for (int i = 0; i < nLayers; ++i) {
337346
std::cout << "* Layer " << i << ":\n";

Detectors/Upgrades/ITS3/macros/test/CheckClustersITS3.C

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ void CheckClustersITS3(const std::string& clusfile = "o2clus_its.root",
5757
using ROFRec = o2::itsmft::ROFRecord;
5858
using MC2ROF = o2::itsmft::MC2ROFRecord;
5959
using HitVec = std::vector<Hit>;
60-
using MC2HITS_map = std::unordered_map<uint64_t, int>; // maps (track_ID<<16 + chip_ID) to entry in the hit vector
60+
using MC2HITS_map = std::unordered_map<uint64_t, int>; // maps (track_ID<<32 + chip_ID) to entry in the hit vector
61+
std::array<SuperSegmentation, 3> mSuperSegmentations{0, 1, 2};
6162

6263
std::vector<HitVec*> hitVecPool;
6364
std::vector<MC2HITS_map> mc2hitVec;
@@ -234,10 +235,10 @@ void CheckClustersITS3(const std::string& clusfile = "o2clus_its.root",
234235
} else {
235236
// compare in local flat coordinates
236237
float xFlatEnd{0.}, yFlatEnd{0.};
237-
o2::its3::SuperSegmentations[layer].curvedToFlat(locH.X(), locH.Y(), xFlatEnd, yFlatEnd);
238+
mSuperSegmentations[layer].curvedToFlat(locH.X(), locH.Y(), xFlatEnd, yFlatEnd);
238239
locH.SetXYZ(xFlatEnd, yFlatEnd, locH.Z());
239240
float xFlatSta{0.}, yFlatSta{0.};
240-
o2::its3::SuperSegmentations[layer].curvedToFlat(locHsta.X(), locHsta.Y(), xFlatSta, yFlatSta);
241+
mSuperSegmentations[layer].curvedToFlat(locHsta.X(), locHsta.Y(), xFlatSta, yFlatSta);
241242
locHsta.SetXYZ(xFlatSta, yFlatSta, locHsta.Z());
242243
// recalculate x/y in flat
243244
// x0 = xFlatSta, dltx = xFlatEnd - x0;
@@ -248,7 +249,7 @@ void CheckClustersITS3(const std::string& clusfile = "o2clus_its.root",
248249
// not really precise, but okish
249250
locH.SetXYZ(0.5f * (locH.X() + locHsta.X()), 0.5f * (locH.Y() + locHsta.Y()), 0.5f * (locH.Z() + locHsta.Z()));
250251

251-
o2::its3::SuperSegmentations[layer].curvedToFlat(locC.X(), locC.Y(), xFlatSta, yFlatSta);
252+
mSuperSegmentations[layer].curvedToFlat(locC.X(), locC.Y(), xFlatSta, yFlatSta);
252253
locC.SetXYZ(xFlatSta, yFlatSta, locC.Z());
253254
}
254255

Detectors/Upgrades/ITS3/macros/test/CompareClustersAndDigits.C

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,9 @@ void CompareClustersAndDigits(std::string clusfile = "o2clus_it3.root",
126126
TFile fileC(clusfile.data());
127127
auto* clusTree = dynamic_cast<TTree*>(fileC.Get("o2sim"));
128128
std::vector<CompClusterExt>* clusArr = nullptr;
129-
clusTree->SetBranchAddress("IT3ClusterComp", &clusArr);
129+
clusTree->SetBranchAddress("ITSClusterComp", &clusArr);
130130
std::vector<unsigned char>* patternsPtr = nullptr;
131-
auto pattBranch = clusTree->GetBranch("IT3ClusterPatt");
131+
auto pattBranch = clusTree->GetBranch("ITSClusterPatt");
132132
if (pattBranch != nullptr) {
133133
pattBranch->SetAddress(&patternsPtr);
134134
}
@@ -146,14 +146,14 @@ void CompareClustersAndDigits(std::string clusfile = "o2clus_it3.root",
146146

147147
// ROFrecords
148148
std::vector<ROFRec> rofRecVec, *rofRecVecP = &rofRecVec;
149-
clusTree->SetBranchAddress("IT3ClustersROF", &rofRecVecP);
149+
clusTree->SetBranchAddress("ITSClustersROF", &rofRecVecP);
150150

151151
// Cluster MC labels
152152
o2::dataformats::MCTruthContainer<o2::MCCompLabel>* clusLabArr = nullptr;
153153
std::vector<MC2ROF> mc2rofVec, *mc2rofVecP = &mc2rofVec;
154-
if ((hitTree != nullptr) && (clusTree->GetBranch("IT3ClusterMCTruth") != nullptr)) {
155-
clusTree->SetBranchAddress("IT3ClusterMCTruth", &clusLabArr);
156-
clusTree->SetBranchAddress("IT3ClustersMC2ROF", &mc2rofVecP);
154+
if ((hitTree != nullptr) && (clusTree->GetBranch("ITSClusterMCTruth") != nullptr)) {
155+
clusTree->SetBranchAddress("ITSClusterMCTruth", &clusLabArr);
156+
clusTree->SetBranchAddress("ITSClustersMC2ROF", &mc2rofVecP);
157157
}
158158

159159
clusTree->GetEntry(0);
@@ -340,8 +340,8 @@ void CompareClustersAndDigits(std::string clusfile = "o2clus_it3.root",
340340
}
341341
auto& dat = data[iChip];
342342
gFile->cd();
343-
/* auto path = gman->getMatrixPath(iChip); */
344-
TString path; // TODO wrong use above
343+
auto path = gman->getMatrixPath(iChip);
344+
/*TString path; // TODO wrong use above*/
345345
const std::string cpath{path.Data() + 39, path.Data() + path.Length()};
346346
const std::filesystem::path p{cpath};
347347
if (oFile->mkdir(p.parent_path().c_str(), "", true) == nullptr) {

0 commit comments

Comments
 (0)