Skip to content

Commit fe19461

Browse files
authored
dev: creating decoding method which can be used also in QC ctp (#11271)
* dev: creating decoding method which can be used also in QC ctp * dev: decoding moved to separate class * clang * fix: Ruben's fixes
1 parent 513fa30 commit fe19461

File tree

9 files changed

+488
-278
lines changed

9 files changed

+488
-278
lines changed

Detectors/CTP/macro/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,11 @@ o2_add_test_root_macro(dumpCTPRO.C
4141
PUBLIC_LINK_LIBRARIES O2::DataFormatsCTP
4242
O2::CCDB
4343
LABELS ctp)
44+
o2_add_test_root_macro(GetAndSave.C
45+
PUBLIC_LINK_LIBRARIES O2::DataFormatsCTP
46+
O2::CCDB
47+
LABELS ctp)
48+
o2_add_test_root_macro(ReadCTPRunScalersFromFile.C
49+
PUBLIC_LINK_LIBRARIES O2::DataFormatsCTP
50+
O2::CCDB
51+
LABELS ctp)

Detectors/CTP/macro/GetAndSave.C

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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 TestCTPScalers.C
13+
/// \brief create CTP scalers, test it and add to database
14+
/// \author Roman Lietava
15+
#if !defined(__CLING__) || defined(__ROOTCLING__)
16+
17+
#include <fairlogger/Logger.h>
18+
#include "CCDB/CcdbApi.h"
19+
#include "CCDB/BasicCCDBManager.h"
20+
#include "DataFormatsCTP/Scalers.h"
21+
#include "DataFormatsCTP/Configuration.h"
22+
#include "TFile.h"
23+
#include "TString.h"
24+
#include <string>
25+
#include <map>
26+
#include <iostream>
27+
#endif
28+
using namespace o2::ctp;
29+
void GetAndSave(std::string ccdbHost = "http://ccdb-test.cern.ch:8080")
30+
{
31+
std::string CCDBPathCTPScalers = "CTP/Calib/Scalers";
32+
// std::vector<string> runs = {"518541","518543","518546","518547"};
33+
// std::vector<long> timestamps = {1655116302316,1655118513690,1655121997478,1655123792911};
34+
std::vector<string> runs = {"519903", "519904", "519905", "519906"};
35+
std::vector<long> timestamps = {1656658674161, 1656660737184, 1656667772462, 1656669421115};
36+
// std::vector<string> runs = {"518543"};
37+
// std::vector<long> timestamps = {1655118513690};
38+
int i = 0;
39+
CTPRunManager mng;
40+
// mng.setCCDBHost(ccdbHost);
41+
auto& mgr = o2::ccdb::BasicCCDBManager::instance();
42+
mgr.setURL(ccdbHost);
43+
for (auto const& run : runs) {
44+
CTPConfiguration ctpcfg;
45+
CTPRunScalers scl;
46+
map<string, string> metadata; // can be empty
47+
metadata["runNumber"] = run;
48+
CTPRunScalers* ctpscalers = mgr.getSpecific<CTPRunScalers>(CCDBPathCTPScalers, timestamps[i], metadata);
49+
if (ctpscalers == nullptr) {
50+
std::cout << run << " CTPRunScalers not in database, timestamp:" << timestamps[i] << std::endl;
51+
} else {
52+
// ctpscalers->printStream(std::cout);
53+
std::string name = run + ".root";
54+
TFile* myFile = TFile::Open(name.c_str(), "RECREATE");
55+
myFile->WriteObject(ctpscalers, "CTPRunScalers");
56+
// myFile->Write();
57+
std::cout << run << " ok" << std::endl;
58+
}
59+
i++;
60+
}
61+
}

Detectors/CTP/macro/GetScalers.C

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
/// \file TestCTPScalers.C
1313
/// \brief create CTP scalers, test it and add to database
1414
/// \author Roman Lietava
15+
// root -b -q "GetScalers.C(\"519499\", 1656286373953)"
1516
#if !defined(__CLING__) || defined(__ROOTCLING__)
1617

1718
#include <fairlogger/Logger.h>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 TestCTPScalers.C
13+
/// \brief create CTP scalers, test it and add to database
14+
/// \author Roman Lietava
15+
#if !defined(__CLING__) || defined(__ROOTCLING__)
16+
17+
#include <fairlogger/Logger.h>
18+
#include "CCDB/CcdbApi.h"
19+
#include "CCDB/BasicCCDBManager.h"
20+
#include "DataFormatsCTP/Scalers.h"
21+
#include "DataFormatsCTP/Configuration.h"
22+
#include "TFile.h"
23+
#include "TString.h"
24+
#include <string>
25+
#include <map>
26+
#include <iostream>
27+
#endif
28+
using namespace o2::ctp;
29+
void ReadCTPRunScalersFromFile(std::string name = "519903.root")
30+
{
31+
std::cout << "Reading file:" << name << std::endl;
32+
TFile* myFile = TFile::Open(name.c_str());
33+
CTPRunScalers* ctpscalers = myFile->Get<CTPRunScalers>("CTPRunScalers");
34+
ctpscalers->printStream(std::cout);
35+
}

Detectors/CTP/reconstruction/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111

1212
o2_add_library(CTPReconstruction
1313
SOURCES src/CTFCoder.cxx src/CTFHelper.cxx
14+
src/RawDataDecoder.cxx
1415
PUBLIC_LINK_LIBRARIES O2::DataFormatsCTP
16+
O2::DPLUtils
17+
O2::DetectorsRaw
1518
O2::DetectorsBase
1619
O2::CommonDataFormat
1720
O2::DetectorsCommonDataFormats
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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 RawDataDecoder.h
13+
/// \brief Digits tw Raw translation
14+
/// \author Roman Lietava
15+
16+
#ifndef ALICEO2_CTP_RAWDATADECODER_H_
17+
#define ALICEO2_CTP_RAWDATADECODER_H_
18+
19+
#include <vector>
20+
#include <map>
21+
#include <deque>
22+
#include "DPLUtils/DPLRawParser.h"
23+
#include "Framework/InputRecord.h"
24+
#include "Framework/InputRecord.h"
25+
#include "DataFormatsCTP/Digits.h"
26+
#include "DataFormatsCTP/LumiInfo.h"
27+
#include "DataFormatsCTP/TriggerOffsetsParam.h"
28+
29+
namespace o2
30+
{
31+
namespace ctp
32+
{
33+
class RawDataDecoder
34+
{
35+
public:
36+
RawDataDecoder() = default;
37+
~RawDataDecoder() = default;
38+
static void makeGBTWordInverse(std::vector<gbtword80_t>& diglets, gbtword80_t& GBTWord, gbtword80_t& remnant, uint32_t& size_gbt, uint32_t Npld);
39+
int addCTPDigit(uint32_t linkCRU, uint32_t triggerOrbit, gbtword80_t& diglet, gbtword80_t& pldmask, std::map<o2::InteractionRecord, CTPDigit>& digits);
40+
int decodeRaw(o2::framework::InputRecord& inputs, std::map<o2::InteractionRecord, CTPDigit>& digits, std::vector<LumiInfo>& lumiPointsHBF1);
41+
void setDoLumi(bool lumi) { mDoLumi = lumi; }
42+
void setDoDigits(bool digi) { mDoDigits = digi; }
43+
void setVerbose(bool v) { mVerbose = v; }
44+
uint32_t getIRRejected() const { return mIRRejected; }
45+
uint32_t getTCRRejected() const { return mTCRRejected; }
46+
std::vector<uint32_t>& getTFOrbits() { return mTFOrbits; }
47+
int init();
48+
49+
private:
50+
static constexpr uint32_t TF_TRIGGERTYPE_MASK = 0x800;
51+
static constexpr uint32_t HB_TRIGGERTYPE_MASK = 0x2;
52+
// for digits
53+
bool mDoDigits = true;
54+
std::vector<CTPDigit> mOutputDigits;
55+
// for lumi
56+
bool mDoLumi = true;
57+
//
58+
gbtword80_t mTVXMask = 0x4; // TVX is 3rd input
59+
gbtword80_t mVBAMask = 0x20; // VBA is 6 th input
60+
LumiInfo mOutputLumiInfo;
61+
bool mVerbose = false;
62+
uint32_t mIRRejected = 0;
63+
uint32_t mTCRRejected = 0;
64+
bool mPadding = true;
65+
uint32_t mTFOrbit = 0;
66+
std::vector<uint32_t> mTFOrbits;
67+
};
68+
} // namespace ctp
69+
} // namespace o2
70+
#endif

0 commit comments

Comments
 (0)