Skip to content

Commit bdd8bbe

Browse files
authored
ctpdev: ctp readout checking macros (#10216)
* dev:ctp readout checking macros added + time added to scalers rate output * clang
1 parent 0495274 commit bdd8bbe

5 files changed

Lines changed: 226 additions & 4 deletions

File tree

DataFormats/Detectors/CTP/src/Scalers.cxx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,14 @@ int CTPRunScalers::printRates()
418418
}
419419
LOG(info) << "Scaler rates for run:" << mRunNumber;
420420
CTPScalerRecordO2* scalrec0 = &mScalerRecordO2[0];
421+
uint32_t orbit0 = scalrec0->intRecord.orbit;
421422
for (int i = 1; i < mScalerRecordO2.size(); i++) {
422423
CTPScalerRecordO2* scalrec1 = &mScalerRecordO2[i];
423424
double_t tt = (double_t)(scalrec1->intRecord.orbit - scalrec0->intRecord.orbit);
425+
double_t tinrun = (double_t)(scalrec1->intRecord.orbit - orbit0);
424426
tt = tt * 88e-6;
427+
tinrun = tinrun * 88e-6;
428+
std::cout << "==> Time wrt to SOR [s]:" << tinrun << " time intervale[s]:" << tt << std::endl;
425429
for (int j = 0; j < scalrec1->scalers.size(); j++) {
426430
CTPScalerO2* s0 = &(scalrec0->scalers[j]);
427431
CTPScalerO2* s1 = &(scalrec1->scalers[j]);

Detectors/CTP/macro/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,11 @@ o2_add_test_root_macro(SaveInputsConfig.C
2525
PUBLIC_LINK_LIBRARIES O2::DataFormatsCTP
2626
O2::CCDB
2727
LABELS ctp)
28+
o2_add_test_root_macro(CheckCTPDigits.C
29+
PUBLIC_LINK_LIBRARIES O2::DataFormatsCTP
30+
O2::CCDB
31+
LABELS ctp)
32+
o2_add_test_root_macro(CheckAOD2CTPDigits.C
33+
PUBLIC_LINK_LIBRARIES O2::DataFormatsCTP
34+
O2::CCDB
35+
LABELS ctp)
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file checkAOD2CTPDigits.C
13+
/// \brief create CTP config, test it and add to database
14+
/// \author Roman Lietava
15+
16+
#if !defined(__CLING__) || defined(__ROOTCLING__)
17+
18+
#include <fairlogger/Logger.h>
19+
#include "TFile.h"
20+
#include "TTree.h"
21+
#include <string>
22+
#include <iostream>
23+
#include <vector>
24+
#include "TKey.h"
25+
#include "TTreeReader.h"
26+
#include "TTreeReaderValue.h"
27+
#endif
28+
// To produce CTP digits:
29+
// o2-raw-tf-reader-workflow -b --onlyDet CTP,FT0 --input-data list.txt | o2-ctp-reco-workflow -b --use-verbose-mode
30+
// To produce AOD:
31+
// WORKFLOW_PARAMETERS="AOD" WORKFLOW_DETECTORS="CTP,FT0,FV0" IGNORE_EXISTING_SHMFILES=1 $O2_ROOT/prodtests/full-system-test/run-workflow-on-inputlist.sh TF list.txt
32+
using namespace o2::ctp;
33+
int CheckAOD2CTPDigits(bool files = 0)
34+
{
35+
if (files == 0) {
36+
return 0;
37+
}
38+
int fRunNumber;
39+
ULong64_t fGlobalBC;
40+
ULong64_t fTriggerMask;
41+
std::unique_ptr<TFile> file(TFile::Open("AO2D.root"));
42+
file->ls();
43+
TIter keyList(file->GetListOfKeys());
44+
TKey* key;
45+
TTree* tree;
46+
;
47+
std::map<ULong64_t, ULong64_t> bc2classmask;
48+
// Find aod trigger info
49+
while ((key = (TKey*)keyList())) {
50+
std::cout << key->GetName() << std::endl;
51+
tree = (TTree*)file->Get(Form("%s/O2bc", key->GetName()));
52+
if (tree != 0) {
53+
std::cout << "found O2bc" << std::endl;
54+
tree->SetBranchAddress("fRunNumber", &fRunNumber);
55+
tree->SetBranchAddress("fGlobalBC", &fGlobalBC);
56+
tree->SetBranchAddress("fTriggerMask", &fTriggerMask);
57+
std::cout << "# of entries:" << tree->GetEntries() << std::endl;
58+
int NN = tree->GetEntries();
59+
int Nloop = NN;
60+
for (int n{0}; n < Nloop; ++n) {
61+
tree->GetEvent(n);
62+
if (fTriggerMask) {
63+
bc2classmask[fGlobalBC] = fTriggerMask;
64+
// std::cout << std::dec << n << " Run:" << fRunNumber << " GBC:" << std::hex << fGlobalBC << " TM:0x" << std::hex << fTriggerMask << " count:" << bc2classmask.count(fGlobalBC) << std::endl;
65+
}
66+
}
67+
} else {
68+
return 1;
69+
}
70+
}
71+
// Read CTP digits and check if every class mask in digits is in AOD
72+
// CTP digits
73+
TFile* fileDigits = TFile::Open("ctpdigits.root");
74+
//
75+
fileDigits->ls();
76+
o2::ctp::CTPDigit* dig = new o2::ctp::CTPDigit;
77+
//
78+
// tree->Print();
79+
TTreeReader reader("o2sim", fileDigits);
80+
TTreeReaderValue<std::vector<o2::ctp::CTPDigit>> ctpdigs(reader, "CTPDigits");
81+
// TTreeReaderArray<o2::ctp::CTPDigit> ctpdigs(reader,"CTPDigits");
82+
bool firstE = true;
83+
//
84+
std::bitset<48> tvxmask;
85+
tvxmask.set(2);
86+
int ncls = 0;
87+
int nnotf = 0;
88+
while (reader.Next()) {
89+
if (ctpdigs.GetSetupStatus() < 0) {
90+
std::cout << "Error:" << std::dec << ctpdigs.GetSetupStatus() << " for:" << ctpdigs.GetBranchName() << std::endl;
91+
return 1;
92+
}
93+
// std::cout << "size:" << std::dec << ctpdigs.GetSize() << std::endl;
94+
std::cout << "size:" << std::dec << ctpdigs->size() << std::endl;
95+
for (auto const& dig : *ctpdigs) {
96+
if (dig.CTPClassMask.count()) {
97+
ULong64_t gbc = dig.intRecord.toLong();
98+
// int del = 280+17;
99+
if (bc2classmask.count(gbc)) {
100+
// std::cout << std::hex << gbc << "aod clsmask:" << bc2classmask[gbc] << " " << dig.CTPClassMask.to_ullong() << " inps:" << dig.CTPInputMask.to_ullong() << std::endl;
101+
// dig.printStream(std::cout);
102+
} else {
103+
std::cout << std::dec << dig.intRecord.orbit << " " << dig.intRecord.bc << " " << std::hex << dig.intRecord.toLong() << " not found " << bc2classmask.count(gbc) << std::endl;
104+
}
105+
}
106+
}
107+
}
108+
return 0;
109+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file checkCTPDigits.C
13+
/// \brief create CTP config, test it and add to database
14+
/// \author Roman Lietava
15+
16+
#if !defined(__CLING__) || defined(__ROOTCLING__)
17+
18+
#include <fairlogger/Logger.h>
19+
#include "TFile.h"
20+
#include "TTree.h"
21+
#include <string>
22+
#include <iostream>
23+
#include <vector>
24+
#include "TKey.h"
25+
#include "TTreeReader.h"
26+
#include "TTreeReaderValue.h"
27+
#endif
28+
// Check if trigger class mask has corresponding input class mask
29+
// Tp be generalised to use CTP config
30+
using namespace o2::ctp;
31+
int CheckCTPDigits(bool files = 0)
32+
{
33+
if (files == 0) {
34+
return 0;
35+
}
36+
// CTP digits
37+
TFile* fileDigits = TFile::Open("ctpdigits.root");
38+
//
39+
fileDigits->ls();
40+
o2::ctp::CTPDigit* dig = new o2::ctp::CTPDigit;
41+
//
42+
// tree->Print();
43+
TTreeReader reader("o2sim", fileDigits);
44+
// TTreeReaderValue<std::vector<o2::ctp::CTPDigit>> ctpdigs(reader,"CTPDigits");
45+
TTreeReaderArray<o2::ctp::CTPDigit> ctpdigs(reader, "CTPDigits");
46+
bool firstE = true;
47+
//
48+
std::bitset<48> tvxmask;
49+
tvxmask.set(2);
50+
int ncls = 0;
51+
int nnotf = 0;
52+
while (reader.Next()) {
53+
if (ctpdigs.GetSetupStatus() < 0) {
54+
std::cout << "Error:" << std::dec << ctpdigs.GetSetupStatus() << " for:" << ctpdigs.GetBranchName() << std::endl;
55+
return 1;
56+
}
57+
std::cout << "size:" << std::dec << ctpdigs.GetSize() << std::endl;
58+
int del = 280 + 14;
59+
int i, j, bc;
60+
for (i = del; i < ctpdigs.GetSize(); i++) {
61+
o2::ctp::CTPDigit* dig = &ctpdigs[i];
62+
if (dig->CTPClassMask.count() > 0) {
63+
std::cout << std::dec << "=======> BC tm:" << dig->intRecord.bc << " O:" << dig->intRecord.orbit << std::hex << " 0b" << dig->CTPClassMask << " gbc:" << dig->intRecord.toLong() << std::endl;
64+
int found = 0;
65+
ncls++;
66+
std::stringstream ss;
67+
for (j = 0; j < del; j++) {
68+
ss << std::dec << ctpdigs[i - j].intRecord.bc << " O:" << ctpdigs[i - j].intRecord.orbit << " " << std::hex << ctpdigs[i - j].CTPInputMask.to_ullong() << std::endl;
69+
bc = (dig->intRecord.bc - del) % 3564;
70+
if (bc < 0)
71+
bc += 3564;
72+
if (bc == ctpdigs[i - j].intRecord.bc) {
73+
std::cout << " found:" << std::dec << j << " 0b" << ctpdigs[i - j].CTPInputMask << std::endl;
74+
found = 1;
75+
auto istvx = ctpdigs[i - j].CTPInputMask & tvxmask;
76+
if (istvx.count() == 0)
77+
std::cout << "error: tcx missing " << std::endl;
78+
break;
79+
}
80+
}
81+
// std::cout << std::endl;
82+
if (0) {
83+
if (found == 0) {
84+
std::cout << " NOT FOUND:" << std::dec << bc;
85+
std::cout << std::dec << " =======> BC tm:" << dig->intRecord.bc << ""
86+
<< " O:" << dig->intRecord.orbit << std::hex << " 0b" << dig->CTPClassMask << std::endl;
87+
std::cout << ss.str() << std::endl;
88+
nnotf++;
89+
} else {
90+
std::cout << " FOUND:" << std::dec << bc << " " << ctpdigs[i - j].intRecord.bc;
91+
std::cout << std::dec << " =======> BC tm:" << dig->intRecord.bc << ""
92+
<< " O:" << dig->intRecord.orbit << std::hex << " 0b" << dig->CTPClassMask << std::endl;
93+
}
94+
}
95+
}
96+
}
97+
}
98+
std::cout << "# of cls masks:" << std::dec << ncls++ << " NOT found:" << nnotf << std::endl;
99+
return 0;
100+
}

Detectors/CTP/macro/GetScalers.C

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ void GetScalers(std::string srun, long time, std::string ccdbHost = "http://ccdb
4444
// scl.printRates();
4545
scl.printIntegrals();
4646
ctpcfg = mng.getConfigFromCCDB(time, srun);
47-
// std::vector<int> clsses;
48-
// clsses = ctpcfg.getTriggerClassList();
49-
// std::cout << clsses.size() << std::endl;
50-
// for(auto const& i : clsses) std::cout << i << std::endl;
47+
// scl.printRates();
48+
// std::vector<int> clsses;
49+
// clsses = ctpcfg.getTriggerClassList();
50+
// std::cout << clsses.size() << std::endl;
51+
// for(auto const& i : clsses) std::cout << i << std::endl;
5152
} else {
5253
std::cout << "Can not find run, please, check parameters" << std::endl;
5354
}

0 commit comments

Comments
 (0)