Project
Loading...
Searching...
No Matches
CalibRawBase.cxx
Go to the documentation of this file.
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
14
15#include "TSystem.h"
16#include "TGrid.h"
17#include "TObjString.h"
18#include "TObjArray.h"
19#include "TPCBase/RDHUtils.h"
20
22
23using namespace o2::tpc;
24
25void CalibRawBase::setupContainers(TString fileInfo, uint32_t verbosity, uint32_t debugLevel)
26{
27 int iSize = 4000000;
28 int iCRU = 0;
29 int iLink = 0;
30 int iSampaVersion = -1;
31
32 // auto contPtr = std::unique_ptr<GBTFrameContainer>(new GBTFrameContainer(iSize,iCRU,iLink));
33 // input data
34 TString rorcType = "cru";
35 auto arrData = fileInfo.Tokenize("; ");
36
37 std::shared_ptr<RawReaderEventSync> eventSync = std::make_shared<RawReaderEventSync>();
38
39 for (auto o : *arrData) {
40 const TString& data = static_cast<TObjString*>(o)->String();
41
42 std::cout << " data: " << data << "\n";
43 if (data.Contains(".root")) {
44 rorcType = "digits";
45 std::cout << "Setting digits\n";
46 }
47
48 // get file info: file name, cru, link
49 auto arrDataInfo = data.Tokenize(":");
50 if (arrDataInfo->GetEntriesFast() == 1) {
51 TString& rorcTypeTmp = static_cast<TObjString*>(arrDataInfo->At(0))->String();
52 if (rorcTypeTmp == "grorc") {
53 rorcType = rorcTypeTmp;
54 } else if (rorcTypeTmp == "trorc") {
55 rorcType = rorcTypeTmp;
56 } else if (rorcTypeTmp == "trorc2") {
57 rorcType = rorcTypeTmp;
58 } else if (rorcTypeTmp == "raw") {
59 rorcType = rorcTypeTmp;
60 } else if (rorcTypeTmp == "cru") {
61 rorcType = rorcTypeTmp;
62 } else {
63 printf("Error, unrecognized option: %s\n", rorcTypeTmp.Data());
64 }
65 std::cout << "Found decoder type: " << rorcType << "\n";
66 delete arrDataInfo;
67 continue;
68 } else if (rorcType == "cru") {
69 TString files = gSystem->GetFromPipe(TString::Format("ls %s", arrDataInfo->At(0)->GetName()));
70 const int timeBins = static_cast<TObjString*>(arrDataInfo->At(1))->String().Atoi();
71 std::unique_ptr<TObjArray> arr(files.Tokenize("\n"));
72 mRawReaderCRUManager.reset();
73 mPresentEventNumber = 0; // reset event number for readers
74 mRawReaderCRUManager.setDebugLevel(debugLevel);
75 mRawReaderCRUManager.setADCDataCallback([this](const PadROCPos& padROCPos, const CRU& cru, const gsl::span<const uint32_t> data) -> Int_t {
76 Int_t timeBins = update(padROCPos, cru, data);
77 mProcessedTimeBins = std::max(mProcessedTimeBins, size_t(timeBins));
78 return timeBins;
79 });
80 mRawReaderCRUManager.setLinkZSCallback([this](int cru, int rowInSector, int padInRow, int timeBin, float adcValue) -> bool {
81 CRU cruID(cru);
82 updateROC(cruID.roc(), rowInSector - (rowInSector > 62) * 63, padInRow, timeBin, adcValue);
83 const PadRegionInfo& regionInfo = mMapper.getPadRegionInfo(cruID.region());
84 updateCRU(cruID, rowInSector - regionInfo.getGlobalRowOffset(), padInRow, timeBin, adcValue);
85 return true;
86 });
87
88 for (auto file : *arr) {
89 // fix the number of time bins
90 auto& reader = mRawReaderCRUManager.createReader(file->GetName(), timeBins);
91 reader.setVerbosity(verbosity);
92 reader.setDebugLevel(debugLevel);
93 reader.setFillADCdataMap(false); // switch off filling and use callback above
94 printf("Adding file: %s\n", file->GetName());
95 if (arrDataInfo->GetEntriesFast() == 3) {
96 const int cru = static_cast<TObjString*>(arrDataInfo->At(2))->String().Atoi();
97 reader.forceCRU(cru);
98 printf("Forcing CRU %03d\n", cru);
99 }
100 }
101 mRawReaderCRUManager.init();
102 } else if (rorcType == "digits") {
103 const TString name = arrDataInfo->At(0)->GetName();
104 TString cmd = "ls";
105 if (name.EndsWith(".list")) {
106 cmd = "cat";
107 }
108 TString files = gSystem->GetFromPipe(TString::Format("%s %s", cmd.Data(), name.Data()));
109 // const int timeBins = static_cast<TObjString*>(arrDataInfo->At(1))->String().Atoi();
110 std::unique_ptr<TObjArray> arr(files.Tokenize("\n"));
111 mDigitTree = std::make_unique<TChain>("o2sim", "Digit chain");
112 // mDigitTree = new TChain("Digits","Digit chain");
113 for (auto file : *arr) {
114 if (TString(file->GetName()).BeginsWith("alien://") && !gGrid) {
115 TGrid::Connect("alien");
116 }
117 mDigitTree->AddFile(file->GetName());
118 LOGP(info, "Adding file {}", file->GetName());
119 }
120 } else if (arrDataInfo->GetEntriesFast() < 3) {
121 printf("Error, badly formatte input data string: %s, expected format is <filename:cru:link[:sampaVersion]>\n",
122 data.Data());
123 delete arrDataInfo;
124 continue;
125 }
126
127 if (rorcType == "raw") {
128 auto rawReader = new RawReader;
129 rawReader->addEventSynchronizer(eventSync);
130 rawReader->addInputFile(data.Data());
131
132 addRawReader(rawReader);
133 } else if ((rorcType != "cru") && (rorcType != "digits")) {
134 TString& filename = static_cast<TObjString*>(arrDataInfo->At(0))->String();
135 iCRU = static_cast<TObjString*>(arrDataInfo->At(1))->String().Atoi();
136 iLink = static_cast<TObjString*>(arrDataInfo->At(2))->String().Atoi();
137 if (arrDataInfo->GetEntriesFast() > 3) {
138 iSampaVersion = static_cast<TObjString*>(arrDataInfo->At(3))->String().Atoi();
139 }
140
141 auto cont = new GBTFrameContainer(iSize, iCRU, iLink, iSampaVersion);
142
143 cont->setEnableAdcClockWarning(false);
144 cont->setEnableSyncPatternWarning(false);
145 cont->setEnableStoreGBTFrames(false);
146 cont->setEnableCompileAdcValues(true);
147
148 std::cout << "Read digits from file " << filename << " with cru " << iCRU << ", link " << iLink << ", rorc type "
149 << rorcType << ", SAMPA Version " << iSampaVersion << "...\n";
150 cont->addGBTFramesFromBinaryFile(filename.Data(), rorcType.Data(), -1);
151 std::cout << " ... done. Read " << cont->getSize() << "\n";
152
154 }
155 }
156
157 delete arrData;
158}
159
161{
162 for (auto& c : mGBTFrameContainers) {
163 c.get()->reProcessAllFrames();
164 }
165}
#define verbosity
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual Show related Highlight grid Show only individual collision Color clusters belonging to track objects Set line Enable drawing TPC data Enable drawing TOF data Enable drawing magnetic field Set field line step count Invert colors configStandalone Heavy OpenGL display display_heavy Show tracks with ITS contribution Show tracks with TOF contribution Enable propagation of loopers Show clusters at nominal x of pad row for early transformed data Split CE tracks when they cross the central Mark clusters Mark adjacent clusters Hide rejected tracks Apply filter on tracks to be displayed Separate increase X h configStandalone Camera window renderer OpenGL display display_camera Orient the camera such that the y axis is always upwards Full Screen MultiSample Anti Downsampling Anti Enable Vertical Sync Target frame or if the backend cannot limit to the refresh Use OpenGL indirect draws to reduce number of draw calls Display h configStandalone Vulkan display display_vulkan Have uniform buffers in host accessible device memory h configStandalone Internal display display_internal Number of updates the Qt GUI may send ahead of the last one the display has before it waits for the display Opacity of the console background Number of console lines the history is shortened to this when it reaches twice the size Time in seconds an info message fades out after setInfoTime h OpenGL display display Font size Do not use Freetype for font Renderer for event Frontend to use for event ROOT macros used as track filter Console script file
uint32_t c
Definition RawData.h:2
unsigned char region() const
Definition CRU.h:64
const ROC roc() const
Definition CRU.h:61
Int_t update(const PadROCPos &padROCPos, const CRU &cru, const gsl::span< const uint32_t > data)
virtual Int_t updateROC(const Int_t roc, const Int_t row, const Int_t pad, const Int_t timeBin, const Float_t signal)=0
void addGBTFrameContainer(GBTFrameContainer *cont)
add GBT frame container to process
void setupContainers(TString fileInfo, uint32_t verbosity=0, uint32_t debugLevel=0)
void rewindEvents()
Rewind the events.
const Mapper & mMapper
TPC mapper.
void addRawReader(RawReader *reader)
add RawReader
virtual Int_t updateCRU(const CRU &cru, const Int_t row, const Int_t pad, const Int_t timeBin, const Float_t signal)=0
GBT Frame container class.
const PadRegionInfo & getPadRegionInfo(const unsigned char region) const
Definition Mapper.h:385
Pad and row inside a ROC.
Definition PadROCPos.h:37
unsigned char getGlobalRowOffset() const
Reader for RAW TPC data.
Definition RawReader.h:38
void addEventSynchronizer(std::shared_ptr< RawReaderEventSync > eventSync)
Definition RawReader.h:199
void init()
initialize all readers
RawReaderCRU & createReader(const std::string_view inputFileName, uint32_t numTimeBins=0, uint32_t link=0, uint32_t stream=0, uint32_t debugLevel=0, uint32_t verbosity=0, const std::string_view outputFilePrefix="")
create a new raw reader
void setDebugLevel(uint32_t debugLevel)
set debug level
void setLinkZSCallback(LinkZSCallback function)
set a callback function for decoded LinkZS data
void setADCDataCallback(ADCDataCallback function)
set a callback function
void setVerbosity(uint32_t verbosity=1)
set verbosity level
GLuint const GLchar * name
Definition glcorearb.h:781
Global TPC definitions and constants.
std::string filename()