Skip to content

Commit 0057a62

Browse files
authored
TOF CalibInfo reader in (AliceO2Group#4087)
* TOF CalibInfo reader in * cleanup of printf
1 parent ae2a58f commit 0057a62

8 files changed

Lines changed: 236 additions & 9 deletions

File tree

Detectors/GlobalTrackingWorkflow/tofworkflow/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ o2_add_library(TOFWorkflow
1313
src/TOFMatchedWriterSpec.cxx
1414
src/TOFCalibWriterSpec.cxx
1515
src/TOFMatchedReaderSpec.cxx
16+
src/CalibInfoReaderSpec.cxx
1617
PUBLIC_LINK_LIBRARIES O2::Framework O2::TOFBase O2::DataFormatsTOF O2::TOFReconstruction
1718
O2::GlobalTracking O2::GlobalTrackingWorkflow O2::TOFWorkflowUtils
1819
O2::TOFCalibration O2::DataFormatsFT0 O2::FT0Reconstruction O2::FT0Workflow)
@@ -21,3 +22,8 @@ o2_add_executable(reco-workflow
2122
COMPONENT_NAME tof
2223
SOURCES src/tof-reco-workflow.cxx
2324
PUBLIC_LINK_LIBRARIES O2::TOFWorkflow)
25+
26+
o2_add_executable(calib-reader
27+
COMPONENT_NAME tof
28+
SOURCES src/tof-calibinfo-reader.cxx
29+
PUBLIC_LINK_LIBRARIES O2::TOFWorkflow)
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// @file CalibInfoReaderSpec.h
12+
13+
#ifndef O2_TOF_CALIBINFOREADER
14+
#define O2_TOF_CALIBINFOREADER
15+
16+
#include "TFile.h"
17+
18+
#include "Framework/DataProcessorSpec.h"
19+
#include "Framework/Task.h"
20+
#include "DataFormatsTOF/CalibInfoTOF.h"
21+
22+
using namespace o2::framework;
23+
24+
namespace o2
25+
{
26+
namespace tof
27+
{
28+
29+
class CalibInfoReader : public Task
30+
{
31+
public:
32+
CalibInfoReader(int instance, int ninstances, const char* filename) : mInstance(instance), mNinstances(ninstances), mFileName(filename) {}
33+
~CalibInfoReader() override = default;
34+
void init(InitContext& ic) final;
35+
void run(ProcessingContext& pc) final;
36+
37+
private:
38+
int mState = 0;
39+
int mInstance;
40+
int mNinstances;
41+
const char* mFileName = nullptr;
42+
FILE* mFile = nullptr;
43+
int mCurrentEntry = 0;
44+
int mGlobalEntry = 0;
45+
std::vector<o2::dataformats::CalibInfoTOF> mVect, *mPvect = &mVect;
46+
};
47+
48+
/// create a processor spec
49+
/// read simulated TOF digits from a root file
50+
framework::DataProcessorSpec getCalibInfoReaderSpec(int instance, int ninstances, const char* filename);
51+
52+
} // namespace tof
53+
} // namespace o2
54+
55+
#endif /* O2_TOF_CALIBINFOREADER */
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// @file DigitReaderSpec.cxx
12+
13+
#include <vector>
14+
15+
#include "TChain.h"
16+
#include "TTree.h"
17+
18+
#include "Framework/ControlService.h"
19+
#include "Framework/ConfigParamRegistry.h"
20+
#include "TOFWorkflow/CalibInfoReaderSpec.h"
21+
22+
using namespace o2::framework;
23+
using namespace o2::tof;
24+
25+
namespace o2
26+
{
27+
namespace tof
28+
{
29+
30+
void CalibInfoReader::init(InitContext& ic)
31+
{
32+
LOG(INFO) << "Init CalibInfo reader!";
33+
mFile = fopen(mFileName, "r");
34+
if (!mFile) {
35+
LOG(ERROR) << "Cannot open the " << mFileName << " file !";
36+
mState = 0;
37+
return;
38+
}
39+
mState = 1;
40+
}
41+
42+
void CalibInfoReader::run(ProcessingContext& pc)
43+
{
44+
if (mState != 1) {
45+
return;
46+
}
47+
48+
char filename[100];
49+
int ientry = 0;
50+
while (fscanf(mFile, "%s", filename) == 1) {
51+
TFile* fin = TFile::Open(filename);
52+
TTree* tin = (TTree*)fin->Get("calibTOF");
53+
tin->SetBranchAddress("TOFCalibInfo", &mPvect);
54+
for (int i = 0; i < tin->GetEntries(); i += mNinstances) {
55+
if ((ientry % mNinstances) == mInstance) {
56+
tin->GetEvent(i);
57+
LOG(INFO) << "Send " << mVect.size() << " calib infos";
58+
pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "CALIBINFOS", 0, Lifetime::Timeframe}, mVect);
59+
}
60+
ientry++;
61+
}
62+
}
63+
64+
mState = 2;
65+
pc.services().get<ControlService>().endOfStream();
66+
return;
67+
}
68+
69+
DataProcessorSpec getCalibInfoReaderSpec(int instance, int ninstances, const char* filename)
70+
{
71+
std::vector<OutputSpec> outputs;
72+
outputs.emplace_back(o2::header::gDataOriginTOF, "CALIBINFOS", 0, Lifetime::Timeframe);
73+
74+
const char* nameSpec;
75+
if (ninstances == 1)
76+
nameSpec = "tof-calibinfo-reader";
77+
else
78+
nameSpec = Form("tof-calibinfo-reader-%d", instance);
79+
80+
return DataProcessorSpec{
81+
nameSpec,
82+
Inputs{},
83+
outputs,
84+
AlgorithmSpec{adaptFromTask<CalibInfoReader>(instance, ninstances, filename)},
85+
Options{/* for the moment no options */}};
86+
}
87+
} // namespace tof
88+
} // namespace o2
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// @file tof-reco-workflow.cxx
12+
/// @author Francesco Noferini
13+
/// @since 2019-05-22
14+
/// @brief Basic DPL workflow for TOF reconstruction starting from digits
15+
16+
#include "DetectorsBase/Propagator.h"
17+
#include "GlobalTrackingWorkflow/TrackTPCITSReaderSpec.h"
18+
#include "TOFWorkflow/CalibInfoReaderSpec.h"
19+
#include "Framework/WorkflowSpec.h"
20+
#include "Framework/ConfigParamSpec.h"
21+
#include "TOFWorkflow/RecoWorkflowSpec.h"
22+
#include "Algorithm/RangeTokenizer.h"
23+
#include "FairLogger.h"
24+
#include "CommonUtils/ConfigurableParam.h"
25+
#include "DetectorsCommonDataFormats/NameConf.h"
26+
27+
#include <string>
28+
#include <stdexcept>
29+
#include <unordered_map>
30+
31+
// add workflow options, note that customization needs to be declared before
32+
// including Framework/runDataProcessing
33+
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
34+
{
35+
workflowOptions.push_back(ConfigParamSpec{"collection-infile", o2::framework::VariantType::String, "list-calibfile", {"Name of the collection input file"}});
36+
workflowOptions.push_back(ConfigParamSpec{"ninstances", o2::framework::VariantType::Int, 1, {"Number of reader instances"}});
37+
workflowOptions.push_back(ConfigParamSpec{"configKeyValues", o2::framework::VariantType::String, "", {"Semicolon separated key=value strings ..."}});
38+
}
39+
40+
#include "Framework/runDataProcessing.h" // the main driver
41+
42+
using namespace o2::framework;
43+
44+
/// The workflow executable for the stand alone TOF reconstruction workflow
45+
/// The basic workflow for TOF reconstruction is defined in RecoWorkflow.cxx
46+
/// and contains the following default processors
47+
/// - digit reader
48+
/// - clusterer
49+
/// - cluster raw decoder
50+
/// - track-TOF matcher
51+
///
52+
/// The default workflow can be customized by specifying input and output types
53+
/// e.g. digits, raw, clusters.
54+
///
55+
/// MC info is processed by default, disabled by using command line option `--disable-mc`
56+
///
57+
/// This function hooks up the the workflow specifications into the DPL driver.
58+
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
59+
{
60+
WorkflowSpec specs;
61+
62+
if (!cfgc.helpOnCommandLine()) {
63+
o2::conf::ConfigurableParam::updateFromString(cfgc.options().get<std::string>("configKeyValues"));
64+
}
65+
66+
int ninstances = cfgc.options().get<int>("ninstances");
67+
auto listname = cfgc.options().get<std::string>("collection-infile");
68+
69+
char* stringTBP = new char[listname.size()];
70+
sprintf(stringTBP, "%s", listname.c_str());
71+
72+
// the lane configuration defines the subspecification ids to be distributed among the lanes.
73+
// auto tofSectors = o2::RangeTokenizer::tokenize<int>(cfgc.options().get<std::string>("tof-sectors"));
74+
// std::vector<int> laneConfiguration = tofSectors;
75+
76+
for (int i = 0; i < ninstances; i++)
77+
specs.emplace_back(o2::tof::getCalibInfoReaderSpec(i, ninstances, stringTBP));
78+
79+
LOG(INFO) << "Number of active devices = " << specs.size();
80+
81+
return std::move(specs);
82+
}

Detectors/TOF/base/src/WindowFiller.cxx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,12 @@ void WindowFiller::flushOutputContainer(std::vector<Digit>& digits)
149149
{ // flush all residual buffered data
150150
// TO be implemented
151151

152-
printf("flushOutputContainer\n");
153152
for (Int_t i = 0; i < MAXWINDOWS; i++) {
154153
int n = 0;
155154
for (int j = 0; j < mStrips[i].size(); j++)
156155
n += ((mStrips[i])[j]).getNumberOfDigits();
157-
158-
printf("ro #%d: digits = %d\n", i, n);
159156
}
160157

161-
printf("Future digits = %lu\n", mFutureDigits.size());
162-
163158
checkIfReuseFutureDigitsRO();
164159

165160
if (!mContinuous)

Detectors/TOF/reconstruction/include/TOFReconstruction/Clusterer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class Clusterer
4949
void setCalibApi(CalibApi* calibApi)
5050
{
5151
mCalibApi = calibApi;
52-
Printf("mCalibApi = %p", mCalibApi);
5352
}
5453

5554
void setFirstOrbit(uint32_t orb);

Detectors/TOF/reconstruction/src/Decoder.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,6 @@ void Decoder::FillWindows()
305305
{
306306
std::vector<Digit> digTemp;
307307
flushOutputContainer(digTemp);
308-
printf("hit decoded = %d (digits not filled = %lu)\n", mHitDecoded, mFutureDigits.size());
309308
}
310309

311310
void Decoder::printCrateInfo(int icru) const

Detectors/TOF/simulation/src/Digitizer.cxx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,11 @@ void Digitizer::addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x,
245245
time = getDigitTimeSmeared(time, x, z, charge); // add time smearing
246246

247247
charge *= getFractionOfCharge(x, z);
248-
Float_t tot = 12; // time-over-threshold
248+
249+
// tot tuned to reproduce 0.8% of orphans tot(=0)
250+
Float_t tot = gRandom->Gaus(12., 1.5); // time-over-threshold
251+
if (tot < 8.4)
252+
tot = 0;
249253

250254
Float_t xborder = Geo::XPAD * 0.5 - TMath::Abs(x);
251255
Float_t zborder = Geo::ZPAD * 0.5 - TMath::Abs(z);
@@ -826,7 +830,6 @@ void Digitizer::fillOutputContainer(std::vector<Digit>& digits)
826830
void Digitizer::flushOutputContainer(std::vector<Digit>& digits)
827831
{ // flush all residual buffered data
828832
// TO be implemented
829-
printf("flushOutputContainer\n");
830833
if (!mContinuous)
831834
fillOutputContainer(digits);
832835
else {

0 commit comments

Comments
 (0)