Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Detectors/GlobalTrackingWorkflow/tofworkflow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ o2_add_library(TOFWorkflow
src/TOFMatchedWriterSpec.cxx
src/TOFCalibWriterSpec.cxx
src/TOFMatchedReaderSpec.cxx
src/CalibInfoReaderSpec.cxx
PUBLIC_LINK_LIBRARIES O2::Framework O2::TOFBase O2::DataFormatsTOF O2::TOFReconstruction
O2::GlobalTracking O2::GlobalTrackingWorkflow O2::TOFWorkflowUtils
O2::TOFCalibration O2::DataFormatsFT0 O2::FT0Reconstruction O2::FT0Workflow)
Expand All @@ -21,3 +22,8 @@ o2_add_executable(reco-workflow
COMPONENT_NAME tof
SOURCES src/tof-reco-workflow.cxx
PUBLIC_LINK_LIBRARIES O2::TOFWorkflow)

o2_add_executable(calib-reader
COMPONENT_NAME tof
SOURCES src/tof-calibinfo-reader.cxx
PUBLIC_LINK_LIBRARIES O2::TOFWorkflow)
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// @file CalibInfoReaderSpec.h

#ifndef O2_TOF_CALIBINFOREADER
#define O2_TOF_CALIBINFOREADER

#include "TFile.h"

#include "Framework/DataProcessorSpec.h"
#include "Framework/Task.h"
#include "DataFormatsTOF/CalibInfoTOF.h"

using namespace o2::framework;

namespace o2
{
namespace tof
{

class CalibInfoReader : public Task
{
public:
CalibInfoReader(int instance, int ninstances, const char* filename) : mInstance(instance), mNinstances(ninstances), mFileName(filename) {}
~CalibInfoReader() override = default;
void init(InitContext& ic) final;
void run(ProcessingContext& pc) final;

private:
int mState = 0;
int mInstance;
int mNinstances;
const char* mFileName = nullptr;
FILE* mFile = nullptr;
int mCurrentEntry = 0;
int mGlobalEntry = 0;
std::vector<o2::dataformats::CalibInfoTOF> mVect, *mPvect = &mVect;
};

/// create a processor spec
/// read simulated TOF digits from a root file
framework::DataProcessorSpec getCalibInfoReaderSpec(int instance, int ninstances, const char* filename);

} // namespace tof
} // namespace o2

#endif /* O2_TOF_CALIBINFOREADER */
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// @file DigitReaderSpec.cxx

#include <vector>

#include "TChain.h"
#include "TTree.h"

#include "Framework/ControlService.h"
#include "Framework/ConfigParamRegistry.h"
#include "TOFWorkflow/CalibInfoReaderSpec.h"

using namespace o2::framework;
using namespace o2::tof;

namespace o2
{
namespace tof
{

void CalibInfoReader::init(InitContext& ic)
{
LOG(INFO) << "Init CalibInfo reader!";
mFile = fopen(mFileName, "r");
if (!mFile) {
LOG(ERROR) << "Cannot open the " << mFileName << " file !";
mState = 0;
return;
}
mState = 1;
}

void CalibInfoReader::run(ProcessingContext& pc)
{
if (mState != 1) {
return;
}

char filename[100];
int ientry = 0;
while (fscanf(mFile, "%s", filename) == 1) {
TFile* fin = TFile::Open(filename);
TTree* tin = (TTree*)fin->Get("calibTOF");
tin->SetBranchAddress("TOFCalibInfo", &mPvect);
for (int i = 0; i < tin->GetEntries(); i += mNinstances) {
if ((ientry % mNinstances) == mInstance) {
tin->GetEvent(i);
LOG(INFO) << "Send " << mVect.size() << " calib infos";
pc.outputs().snapshot(Output{o2::header::gDataOriginTOF, "CALIBINFOS", 0, Lifetime::Timeframe}, mVect);
}
ientry++;
}
}

mState = 2;
pc.services().get<ControlService>().endOfStream();
return;
}

DataProcessorSpec getCalibInfoReaderSpec(int instance, int ninstances, const char* filename)
{
std::vector<OutputSpec> outputs;
outputs.emplace_back(o2::header::gDataOriginTOF, "CALIBINFOS", 0, Lifetime::Timeframe);

const char* nameSpec;
if (ninstances == 1)
nameSpec = "tof-calibinfo-reader";
else
nameSpec = Form("tof-calibinfo-reader-%d", instance);

return DataProcessorSpec{
nameSpec,
Inputs{},
outputs,
AlgorithmSpec{adaptFromTask<CalibInfoReader>(instance, ninstances, filename)},
Options{/* for the moment no options */}};
}
} // namespace tof
} // namespace o2
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// @file tof-reco-workflow.cxx
/// @author Francesco Noferini
/// @since 2019-05-22
/// @brief Basic DPL workflow for TOF reconstruction starting from digits

#include "DetectorsBase/Propagator.h"
#include "GlobalTrackingWorkflow/TrackTPCITSReaderSpec.h"
#include "TOFWorkflow/CalibInfoReaderSpec.h"
#include "Framework/WorkflowSpec.h"
#include "Framework/ConfigParamSpec.h"
#include "TOFWorkflow/RecoWorkflowSpec.h"
#include "Algorithm/RangeTokenizer.h"
#include "FairLogger.h"
#include "CommonUtils/ConfigurableParam.h"
#include "DetectorsCommonDataFormats/NameConf.h"

#include <string>
#include <stdexcept>
#include <unordered_map>

// add workflow options, note that customization needs to be declared before
// including Framework/runDataProcessing
void customize(std::vector<o2::framework::ConfigParamSpec>& workflowOptions)
{
workflowOptions.push_back(ConfigParamSpec{"collection-infile", o2::framework::VariantType::String, "list-calibfile", {"Name of the collection input file"}});
workflowOptions.push_back(ConfigParamSpec{"ninstances", o2::framework::VariantType::Int, 1, {"Number of reader instances"}});
workflowOptions.push_back(ConfigParamSpec{"configKeyValues", o2::framework::VariantType::String, "", {"Semicolon separated key=value strings ..."}});
}

#include "Framework/runDataProcessing.h" // the main driver

using namespace o2::framework;

/// The workflow executable for the stand alone TOF reconstruction workflow
/// The basic workflow for TOF reconstruction is defined in RecoWorkflow.cxx
/// and contains the following default processors
/// - digit reader
/// - clusterer
/// - cluster raw decoder
/// - track-TOF matcher
///
/// The default workflow can be customized by specifying input and output types
/// e.g. digits, raw, clusters.
///
/// MC info is processed by default, disabled by using command line option `--disable-mc`
///
/// This function hooks up the the workflow specifications into the DPL driver.
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
WorkflowSpec specs;

if (!cfgc.helpOnCommandLine()) {
o2::conf::ConfigurableParam::updateFromString(cfgc.options().get<std::string>("configKeyValues"));
}

int ninstances = cfgc.options().get<int>("ninstances");
auto listname = cfgc.options().get<std::string>("collection-infile");

char* stringTBP = new char[listname.size()];
sprintf(stringTBP, "%s", listname.c_str());

// the lane configuration defines the subspecification ids to be distributed among the lanes.
// auto tofSectors = o2::RangeTokenizer::tokenize<int>(cfgc.options().get<std::string>("tof-sectors"));
// std::vector<int> laneConfiguration = tofSectors;

for (int i = 0; i < ninstances; i++)
specs.emplace_back(o2::tof::getCalibInfoReaderSpec(i, ninstances, stringTBP));

LOG(INFO) << "Number of active devices = " << specs.size();

return std::move(specs);
}
5 changes: 0 additions & 5 deletions Detectors/TOF/base/src/WindowFiller.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,12 @@ void WindowFiller::flushOutputContainer(std::vector<Digit>& digits)
{ // flush all residual buffered data
// TO be implemented

printf("flushOutputContainer\n");
for (Int_t i = 0; i < MAXWINDOWS; i++) {
int n = 0;
for (int j = 0; j < mStrips[i].size(); j++)
n += ((mStrips[i])[j]).getNumberOfDigits();

printf("ro #%d: digits = %d\n", i, n);
}

printf("Future digits = %lu\n", mFutureDigits.size());

checkIfReuseFutureDigitsRO();

if (!mContinuous)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class Clusterer
void setCalibApi(CalibApi* calibApi)
{
mCalibApi = calibApi;
Printf("mCalibApi = %p", mCalibApi);
}

void setFirstOrbit(uint32_t orb);
Expand Down
1 change: 0 additions & 1 deletion Detectors/TOF/reconstruction/src/Decoder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ void Decoder::FillWindows()
{
std::vector<Digit> digTemp;
flushOutputContainer(digTemp);
printf("hit decoded = %d (digits not filled = %lu)\n", mHitDecoded, mFutureDigits.size());
}

void Decoder::printCrateInfo(int icru) const
Expand Down
7 changes: 5 additions & 2 deletions Detectors/TOF/simulation/src/Digitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,11 @@ void Digitizer::addDigit(Int_t channel, UInt_t istrip, Double_t time, Float_t x,
time = getDigitTimeSmeared(time, x, z, charge); // add time smearing

charge *= getFractionOfCharge(x, z);
Float_t tot = 12; // time-over-threshold

// tot tuned to reproduce 0.8% of orphans tot(=0)
Float_t tot = gRandom->Gaus(12., 1.5); // time-over-threshold
if (tot < 8.4)
tot = 0;

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