Skip to content

Commit d23a490

Browse files
wiechulasawenzel
authored andcommitted
Add possibility to process several directories with raw data
1 parent b9bd4cd commit d23a490

7 files changed

Lines changed: 79 additions & 52 deletions

File tree

Detectors/TPC/calibration/macro/drawPulser.C

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ void drawPulser(TString pulserFile)
6767
const float maxWidth = medianWidth + rangeWidth;
6868

6969
const float rangeQtot = 150;
70-
const float minQtot = medianQtot - rangeQtot;
70+
const float minQtot = medianQtot - 50;
7171
const float maxQtot = medianQtot + rangeQtot;
7272

7373
// ===| histograms for t0, width and qtot |===
74-
auto hT0 = new TH1F(Form("hT0%02d", iroc), Form("T0 distribution ROC %02d;ADC value", iroc), 100, minT0, maxT0);
75-
auto hWidth = new TH1F(Form("hWidth%02d", iroc), Form("Width distribution ROC %02d;ADC value", iroc), 100, minWidth, maxWidth);
76-
auto hQtot = new TH1F(Form("hQtot%02d", iroc), Form("Qtot distribution ROC %02d;ADC value", iroc), 100, minQtot, maxQtot);
74+
auto hT0 = new TH1F(Form("hT0%02d", iroc), Form("T0 distribution ROC %02d;time bins (0.2 #mus)", iroc), 100, minT0, maxT0);
75+
auto hWidth = new TH1F(Form("hWidth%02d", iroc), Form("Width distribution ROC %02d;time bins (0.2 #mus)", iroc), 100, minWidth, maxWidth);
76+
auto hQtot = new TH1F(Form("hQtot%02d", iroc), Form("Qtot distribution ROC %02d;ADC counts", iroc), 100, minQtot, maxQtot);
7777

7878
auto hT02D = painter::getHistogram2D(rocT0);
7979
hT02D->SetStats(0);

Detectors/TPC/calibration/macro/runPedestal.C

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,45 @@
1010

1111
#if !defined(__CLING__) || defined(__ROOTCLING__)
1212
#include <iostream>
13+
#include <vector>
14+
#include <string_view>
15+
#include "TFile.h"
1316
#include "TPCCalibration/CalibPedestal.h"
1417
#include "TPCCalibration/CalibRawBase.h"
1518
#endif
1619

17-
void runPedestal(TString fileInfo, TString outputFileName = "", Int_t nevents = 100, Int_t adcMin = 0, Int_t adcMax = 1100, Int_t firstTimeBin = 0, Int_t lastTimeBin = 450, Int_t statisticsType = 0, uint32_t verbosity = 0, uint32_t debugLevel = 0, Int_t firstEvent = 0)
20+
void runPedestal(std::vector<std::string_view> fileInfos, TString outputFileName = "", Int_t nevents = 100, Int_t adcMin = 0, Int_t adcMax = 1100, Int_t firstTimeBin = 0, Int_t lastTimeBin = 450, Int_t statisticsType = 0, uint32_t verbosity = 0, uint32_t debugLevel = 0, Int_t firstEvent = 0)
1821
{
1922
using namespace o2::tpc;
2023
CalibPedestal ped; //(PadSubset::Region);
2124
ped.setADCRange(adcMin, adcMax);
22-
ped.setupContainers(fileInfo, verbosity, debugLevel);
23-
ped.setStatisticsType(CalibPedestal::StatisticsType(statisticsType));
25+
ped.setStatisticsType(StatisticsType(statisticsType));
2426
ped.setTimeBinRange(firstTimeBin, lastTimeBin);
2527

2628
//ped.processEvent();
2729
//ped.resetData();
2830

2931
CalibRawBase::ProcessStatus status = CalibRawBase::ProcessStatus::Ok;
30-
//while (ped.processEvent());
31-
for (Int_t i = firstEvent; i < firstEvent + nevents; ++i) {
32-
status = ped.processEvent(i);
33-
cout << "Processing event " << i << " with status " << int(status) << '\n';
34-
if (status != CalibRawBase::ProcessStatus::Ok) {
35-
break;
32+
33+
for (const auto& fileInfo : fileInfos) {
34+
ped.setupContainers(fileInfo.data(), verbosity, debugLevel);
35+
36+
for (Int_t i = firstEvent; i < firstEvent + nevents; ++i) {
37+
status = ped.processEvent(i);
38+
cout << "Processing event " << i << " with status " << int(status) << '\n';
39+
if (status != CalibRawBase::ProcessStatus::Ok) {
40+
break;
41+
}
3642
}
3743
}
3844
ped.analyse();
3945

40-
cout << "Number of processed events: " << ped.getNumberOfProcessedEvents() << '\n';
41-
cout << "Status: " << int(status) << '\n';
42-
if (outputFileName.IsNull())
46+
std::cout << "Number of processed events: " << ped.getNumberOfProcessedEvents() << '\n';
47+
std::cout << "Status: " << int(status) << '\n';
48+
if (outputFileName.IsNull()) {
4349
outputFileName = "Pedestals.root";
50+
}
4451
ped.dumpToFile(outputFileName.Data());
4552

46-
//const CalDet<float>& calPedestal = ped.getPedestal();
47-
//const CalDet<float>& calNoise = ped.getNoise();
48-
49-
//painter::Draw(calPedestal);
50-
//painter::Draw(calNoise);
51-
52-
//TCanvas *cPedestal = new TCanvas("cPedestal","Pedestal");
53-
//auto hPedestal = painter::getHistogram2D(calPedestal.getCalArray(0));
54-
//hPedestal->SetTitle("Pedestals");
55-
//hPedestal->Draw("colz");
56-
57-
//TCanvas *cNoise = new TCanvas("cNoise","Noise");
58-
//auto hNoise = painter::getHistogram2D(calNoise.getCalArray(0));
59-
//hNoise->SetTitle("Noise");
60-
//hNoise->Draw("colz");
61-
62-
cout << "To display the pedestals run: root.exe $calibMacroDir/drawNoiseAndPedestal.C'(\"" << outputFileName << "\")'\n";
53+
std::cout << "To display the pedestals run: root.exe $calibMacroDir/drawNoiseAndPedestal.C'(\"" << outputFileName << "\")'\n";
6354
}

Detectors/TPC/calibration/macro/runPedestal.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ adcMin=0
4747
adcMax=1100
4848

4949
# ===| parse command line options |=============================================
50-
OPTIONS=$(getopt -l "fileInfo:,outputFile:,firstTimeBin:,lastTimeBin:,nevents:,adcMin:,adcMax:,statType:,verbosity:,debugLevel:,help" -o "i:o:t:f:l:m:x:s:v:d:h" -n "runPedestal.sh" -- "$@")
50+
OPTIONS=$(getopt -l "fileInfo:,outputFile:,firstTimeBin:,lastTimeBin:,nevents:,adcMin:,adcMax:,statType:,verbosity:,debugLevel:,help" -o "i:o:t:f:l:n:m:x:s:v:d:h" -n "runPedestal.sh" -- "$@")
5151

5252
if [ $? != 0 ] ; then
5353
usageAndExit
@@ -80,13 +80,18 @@ fi
8080

8181
# ===| check time bin info |====================================================
8282
if [[ $fileInfo =~ : ]]; then
83-
timeBins=${fileInfo#*:}
84-
timeBins=${timeBins%%:*}
83+
lastTimeBin=${fileInfo#*:}
84+
lastTimeBin=${lastTimeBin%%:*}
8585
else
86-
fileInfo=${fileInfo}:${timeBins}
86+
fileInfo=${fileInfo}:${lastTimeBin}
8787
fi
8888

89+
# ===| properly format fileInfo |===============================================
90+
fileInfo=$(echo $fileInfo | sed "s|^|{\"|;s|,|:$lastTimeBin\",\"|g;s|$|\"}|")
91+
8992
# ===| command building and execution |=========================================
90-
cmd="root.exe -b -q -l -n -x $O2_SRC/Detectors/TPC/calibration/macro/runPedestal.C'(\"$fileInfo\",\"$outputFile\", $nevents, $adcMin, $adcMax, $firstTimeBin, $lastTimeBin, $statisticsType, $verbosity, $debugLevel)'"
93+
cmd="root.exe -b -q -l -n -x $O2_SRC/Detectors/TPC/calibration/macro/runPedestal.C'($fileInfo,\"$outputFile\", $nevents, $adcMin, $adcMax, $firstTimeBin, $lastTimeBin, $statisticsType, $verbosity, $debugLevel)'"
94+
#cmd="perf record -g -o perf.log root.exe -b -q -l -n -x $O2_SRC/Detectors/TPC/calibration/macro/runPedestal.C'($fileInfo,\"$outputFile\", $nevents, $adcMin, $adcMax, $firstTimeBin, $lastTimeBin, $statisticsType, $verbosity, $debugLevel)'"
95+
#cmd="valgrind --tool=callgrind --dump-instr=yes --dump-instr=yes root.exe -b -q -l -n -x $O2_SRC/Detectors/TPC/calibration/macro/runPedestal.C'($fileInfo,\"$outputFile\", $nevents, $adcMin, $adcMax, $firstTimeBin, $lastTimeBin, $statisticsType, $verbosity, $debugLevel)'"
9196
echo "running: $cmd"
9297
eval $cmd

Detectors/TPC/calibration/macro/runPulser.C

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010

1111
#if !defined(__CLING__) || defined(__ROOTCLING__)
1212
#include <iostream>
13+
#include <vector>
14+
#include <string_view>
1315
#include "TFile.h"
1416
#include "TPCCalibration/CalibPulser.h"
1517
#include "TPCCalibration/CalibRawBase.h"
1618
#endif
1719

18-
void runPulser(TString fileInfo, TString outputFileName = "", Int_t nevents = 100,
20+
void runPulser(std::vector<std::string_view> fileInfos, TString outputFileName = "", Int_t nevents = 100,
1921
Int_t adcMin = 0, Int_t adcMax = 1100,
2022
Int_t firstTimeBin = 0, Int_t lastTimeBin = 500,
2123
TString pedestalAndNoiseFile = "",
@@ -25,7 +27,6 @@ void runPulser(TString fileInfo, TString outputFileName = "", Int_t nevents = 10
2527
// ===| set up calibration class |============================================
2628
CalibPulser calib;
2729
calib.setADCRange(adcMin, adcMax);
28-
calib.setupContainers(fileInfo, verbosity, debugLevel);
2930
calib.setTimeBinRange(firstTimeBin, lastTimeBin);
3031
calib.setDebugLevel();
3132
//calib.setDebugLevel(debugLevel);
@@ -52,22 +53,26 @@ void runPulser(TString fileInfo, TString outputFileName = "", Int_t nevents = 10
5253

5354
CalibRawBase::ProcessStatus status = CalibRawBase::ProcessStatus::Ok;
5455

55-
for (Int_t i = 0; i < nevents; ++i) {
56-
status = calib.processEvent(i);
57-
cout << "Processing event " << i << " with status " << int(status) << '\n';
58-
if (status != CalibRawBase::ProcessStatus::Ok) {
59-
break;
56+
for (const auto& fileInfo : fileInfos) {
57+
calib.setupContainers(fileInfo.data(), verbosity, debugLevel);
58+
59+
for (Int_t i = 0; i < nevents; ++i) {
60+
status = calib.processEvent(i);
61+
cout << "Processing event " << i << " with status " << int(status) << '\n';
62+
if (status != CalibRawBase::ProcessStatus::Ok) {
63+
break;
64+
}
6065
}
6166
}
6267
calib.analyse();
6368

64-
cout << "Number of processed events: " << calib.getNumberOfProcessedEvents() << '\n';
65-
cout << "Status: " << int(status) << '\n';
69+
std::cout << "Number of processed events: " << calib.getNumberOfProcessedEvents() << '\n';
70+
std::cout << "Status: " << int(status) << '\n';
6671
if (outputFileName.IsNull()) {
6772
outputFileName = "Pulser.root";
6873
}
6974

7075
calib.dumpToFile(outputFileName.Data());
7176

72-
cout << "To display the Pulsers run: root.exe $calibMacroDir/drawPulser.C'(\"" << outputFileName << "\")'\n";
77+
std::cout << "To display the Pulsers run: root.exe $calibMacroDir/drawPulser.C'(\"" << outputFileName << "\")'\n";
7378
}

Detectors/TPC/calibration/macro/runPulser.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,16 @@ fi
7979

8080
# ===| check time bin info |====================================================
8181
if [[ $fileInfo =~ : ]]; then
82-
timeBins=${fileInfo#*:}
83-
timeBins=${timeBins%%:*}
82+
lastTimeBin=${fileInfo#*:}
83+
lastTimeBin=${lastTimeBin%%:*}
8484
else
85-
fileInfo=${fileInfo}:${timeBins}
85+
fileInfo=${fileInfo}:${lastTimeBin}
8686
fi
8787

88+
# ===| properly format fileInfo |===============================================
89+
fileInfo=$(echo $fileInfo | sed "s|^|{\"|;s|,|:$lastTimeBin\",\"|g;s|$|\"}|")
90+
8891
# ===| command building and execution |=========================================
89-
cmd="root.exe -b -q -l -n -x $O2_SRC/Detectors/TPC/calibration/macro/runPulser.C'(\"$fileInfo\",\"$outputFile\", $nevents, $adcMin, $adcMax, $firstTimeBin, $lastTimeBin, \"$pedestalFile\", $verbosity, $debugLevel)'"
92+
cmd="root.exe -b -q -l -n -x $O2_SRC/Detectors/TPC/calibration/macro/runPulser.C'($fileInfo,\"$outputFile\", $nevents, $adcMin, $adcMax, $firstTimeBin, $lastTimeBin, \"$pedestalFile\", $verbosity, $debugLevel)'"
9093
echo "running: $cmd"
9194
eval $cmd

Detectors/TPC/calibration/src/CalibRawBase.cxx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ void CalibRawBase::setupContainers(TString fileInfo, uint32_t verbosity, uint32_
6060
TString files = gSystem->GetFromPipe(TString::Format("ls %s", arrDataInfo->At(0)->GetName()));
6161
const int timeBins = static_cast<TObjString*>(arrDataInfo->At(1))->String().Atoi();
6262
std::unique_ptr<TObjArray> arr(files.Tokenize("\n"));
63+
mRawReaderCRUManager.reset();
64+
mPresentEventNumber = 0; // reset event number for readers
6365
mRawReaderCRUManager.setDebugLevel(debugLevel);
6466
for (auto file : *arr) {
6567
// fix the number of time bins

Detectors/TPC/reconstruction/include/TPCReconstruction/RawReaderCRU.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,13 @@ class RawReaderCRUEventSync
409409
/// set a cru as seen
410410
void setCRUSeen(const CRU cru) { mCRUSeen[cru] = true; }
411411

412+
/// reset all information
413+
void reset()
414+
{
415+
mEventInformation.clear();
416+
mCRUSeen.reset();
417+
}
418+
412419
/// overloading output stream operator
413420
friend std::ostream& operator<<(std::ostream& output, const RawReaderCRUEventSync& eventSync)
414421
{
@@ -824,6 +831,20 @@ class RawReaderCRUManager
824831
/// return last reader
825832
const RawReaderCRU& getLastReader() const { return *mRawReadersCRU.back().get(); }
826833

834+
/// reset readers
835+
void resetReaders() { mRawReadersCRU.clear(); }
836+
837+
/// reset event synchronisation info
838+
void resetEventSync() { mEventSync.reset(); }
839+
840+
/// reset all
841+
void reset()
842+
{
843+
resetReaders();
844+
resetEventSync();
845+
mIsInitialized = false;
846+
}
847+
827848
/// set event number to all sub-readers
828849
void setEventNumber(uint32_t eventNumber)
829850
{

0 commit comments

Comments
 (0)