Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
195f1c2
first separation T0 V0
AllaMaevskaya Jan 18, 2019
4b6daad
T0 simulation works with this
AllaMaevskaya Jan 22, 2019
2e5709a
move Hit to common
AllaMaevskaya Jan 23, 2019
9abcec9
T0 digitzation as a part of FIT
AllaMaevskaya Jan 26, 2019
15dc66a
add run_reco_t0
AllaMaevskaya Feb 6, 2019
cb8dc52
Added V0: Detector and Geometry classes; no proper hits yet
mslupeck Mar 19, 2019
0acd64a
first separation T0 V0
AllaMaevskaya Jan 18, 2019
83f3b13
T0 simulation works with this
AllaMaevskaya Jan 22, 2019
f1b2bfa
move Hit to common
AllaMaevskaya Jan 23, 2019
a8f333c
T0 digitzation as a part of FIT
AllaMaevskaya Jan 26, 2019
8553ebd
add run_reco_t0
AllaMaevskaya Feb 6, 2019
8100ae2
first separation T0 V0
AllaMaevskaya Jan 18, 2019
d748e72
T0 simulation works with this
AllaMaevskaya Jan 22, 2019
9d0e919
move Hit to common
AllaMaevskaya Jan 23, 2019
a75c6e1
T0 digitzation as a part of FIT
AllaMaevskaya Jan 26, 2019
419cfdc
add run_reco_t0
AllaMaevskaya Feb 6, 2019
297b9f7
remove <<<< after mergeing
AllaMaevskaya Mar 28, 2019
314bd43
fix conflict
AllaMaevskaya Mar 29, 2019
a04fde0
merge with V0
AllaMaevskaya Mar 29, 2019
dcb3915
Fixed material definition in FIT-V0+
mslupeck Mar 30, 2019
ffa30ca
Merge pull request #6 from mslupeck/dev
AllaMaevskaya Mar 30, 2019
a705103
clang fixed
AllaMaevskaya Mar 30, 2019
0290ee5
explicit added
AllaMaevskaya Mar 31, 2019
ab36798
remove empty line in HitMerger.h: clang complains
AllaMaevskaya Mar 31, 2019
1ead442
remove unused macros
AllaMaevskaya Mar 31, 2019
939e2a2
fix T0 part
AllaMaevskaya Mar 31, 2019
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
Prev Previous commit
Next Next commit
T0 simulation works with this
  • Loading branch information
AllaMaevskaya committed Mar 29, 2019
commit 4b6daad3402f5be78cf89ff8d2ff58898fa1fcdb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class DetID
static constexpr ID MCH = 9;
static constexpr ID MID = 10;
static constexpr ID ZDC = 11;
static constexpr ID FIT = 12;
static constexpr ID T0 = 12;
static constexpr ID ACO = 13;
static constexpr ID First = ITS;
static constexpr ID Last = ACO; ///< if extra detectors added, update this !!!
Expand Down Expand Up @@ -105,13 +105,13 @@ class DetID
ID mID = First; ///< detector ID

static constexpr const char* sDetNames[nDetectors + 1] = ///< defined detector names
{ "ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "FIT", "ACO", nullptr };
{ "ITS", "TPC", "TRD", "TOF", "PHS", "CPV", "EMC", "HMP", "MFT", "MCH", "MID", "ZDC", "T0", "ACO", nullptr };

// detector names, will be defined in DataSources
static constexpr std::array<mask_t, nDetectors> sMasks = ///< detectot masks
{ utils::bit2Mask(ITS), utils::bit2Mask(TPC), utils::bit2Mask(TRD), utils::bit2Mask(TOF), utils::bit2Mask(PHS),
utils::bit2Mask(CPV), utils::bit2Mask(EMC), utils::bit2Mask(HMP), utils::bit2Mask(MFT), utils::bit2Mask(MCH),
utils::bit2Mask(MID), utils::bit2Mask(ZDC), utils::bit2Mask(FIT), utils::bit2Mask(ACO) };
utils::bit2Mask(MID), utils::bit2Mask(ZDC), utils::bit2Mask(T0), utils::bit2Mask(ACO) };

ClassDefNV(DetID, 1);
};
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/Detectors/Common/src/DetID.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ constexpr std::array<DetID::mask_t, DetID::nDetectors> DetID::sMasks;

// redundant declarations
constexpr DetID::ID DetID::ITS, DetID::TPC, DetID::TRD, DetID::TOF, DetID::PHS, DetID::CPV, DetID::EMC,
DetID::HMP, DetID::MFT, DetID::MCH, DetID::MID, DetID::ZDC, DetID::FIT, DetID::ACO, DetID::First, DetID::Last;
DetID::HMP, DetID::MFT, DetID::MCH, DetID::MID, DetID::ZDC, DetID::T0, DetID::ACO, DetID::First, DetID::Last;

constexpr int DetID::nDetectors;

Expand Down
2 changes: 1 addition & 1 deletion DataFormats/Headers/include/Headers/DataHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ constexpr o2::header::DataOrigin gDataOriginACO{ "ACO" };
constexpr o2::header::DataOrigin gDataOriginCPV{ "CPV" };
constexpr o2::header::DataOrigin gDataOriginCTP{ "CTP" };
constexpr o2::header::DataOrigin gDataOriginEMC{ "EMC" };
constexpr o2::header::DataOrigin gDataOriginFIT{ "FIT" };
constexpr o2::header::DataOrigin gDataOriginT0{ "T0" };
constexpr o2::header::DataOrigin gDataOriginHMP{ "HMP" };
constexpr o2::header::DataOrigin gDataOriginITS{ "ITS" };
constexpr o2::header::DataOrigin gDataOriginMCH{ "MCH" };
Expand Down
4 changes: 2 additions & 2 deletions Detectors/FIT/T0/simulation/src/Detector.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using o2::t0::Geometry;
ClassImp(Detector);

Detector::Detector(Bool_t Active)
: o2::Base::DetImpl<Detector>("FIT", Active), mIdSens1(0), mPMTeff(nullptr), mHits(o2::utils::createSimVector<HitType>())
: o2::Base::DetImpl<Detector>("T0", Active), mIdSens1(0), mPMTeff(nullptr), mHits(o2::utils::createSimVector<HitType>())

{
// Gegeo = GetGeometry() ;
Expand Down Expand Up @@ -384,7 +384,7 @@ void Detector::DefineOpticalProperties()
const char* aliceO2env = std::getenv("O2_ROOT");
if (aliceO2env)
inputDir = aliceO2env;
inputDir += "/share/Detectors/FIT/files/";
inputDir += "/share/Detectors/T0/files/";

TString optPropPath = inputDir + "quartzOptProperties.txt";
optPropPath = gSystem->ExpandPathName(optPropPath.Data()); // Expand $(ALICE_ROOT) into real system path
Expand Down
4 changes: 2 additions & 2 deletions Detectors/FIT/T0/simulation/src/DigitizerTask.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ClassImp(o2::t0::DigitizerTask);
using namespace o2::fit;
using namespace o2::t0;

DigitizerTask::DigitizerTask() : FairTask("FITDigitizerTask"), mDigitizer() {}
DigitizerTask::DigitizerTask() : FairTask("T0DigitizerTask"), mDigitizer() {}
DigitizerTask::~DigitizerTask()
{
if (mEventDigit)
Expand Down Expand Up @@ -50,7 +50,7 @@ InitStatus DigitizerTask::Init()
mDigitizer.setMCLabels(mMCTruthArrayPtr);

// Register output container
mgr->RegisterAny("FITDigit", mEventDigit, kTRUE);
mgr->RegisterAny("FITT0Digit", mEventDigit, kTRUE);
// mMCTruthArray = new typename std::remove_pointer<decltype(mMCTruthArray)>::type;
mgr->RegisterAny("FITDigitMCTruth", mMCTruthArrayPtr, kTRUE);
mDigitizer.init();
Expand Down
191 changes: 116 additions & 75 deletions Steer/DigitizerWorkflow/src/FITDigitWriterSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,24 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// @brief Processor spec for a ROOT file writer for TOF digits
/// @brief Processor spec for a ROOT file writer for FIT T0&V0 digits

#include "FITDigitWriterSpec.h"
#include "Framework/CallbackService.h"
#include "Framework/ControlService.h"
#include <SimulationDataFormat/MCCompLabel.h>
#include <SimulationDataFormat/MCTruthContainer.h>
#include "TTree.h"
#include "TBranch.h"
#include "TFile.h"
#include "Framework/Task.h"
#include "FITBase/Digit.h"
#include "Headers/DataHeader.h"
#include "DetectorsCommonDataFormats/DetID.h"
#include "SimulationDataFormat/MCTruthContainer.h"
#include "SimulationDataFormat/MCCompLabel.h"
#include <TTree.h>
#include <TBranch.h>
#include <TFile.h>
#include <memory> // for make_shared, make_unique, unique_ptr
#include <vector>
#include <string>
#include <algorithm>

using namespace o2::framework;
using SubSpecificationType = o2::framework::DataAllocator::SubSpecificationType;
Expand All @@ -30,88 +35,124 @@ namespace o2
namespace fit
{

template <typename T>
TBranch* getOrMakeBranch(TTree& tree, std::string brname, T* ptr)
class FITDPLDigitWriter
{
if (auto br = tree.GetBranch(brname.c_str())) {
br->SetAddress(static_cast<void*>(&ptr));
return br;

using MCCont = o2::dataformats::MCTruthContainer<o2::MCCompLabel>;

public:
void init(framework::InitContext& ic)
{
std::string detStrL = mID.getName();
std::transform(detStrL.begin(), detStrL.end(), detStrL.begin(), ::tolower);

auto filename = ic.options().get<std::string>((detStrL + "-digit-outfile").c_str());
auto treename = ic.options().get<std::string>("treename");

mOutFile = std::make_unique<TFile>(filename.c_str(), "RECREATE");
if (!mOutFile || mOutFile->IsZombie()) {
LOG(ERROR) << "Failed to open " << filename << " output file";
} else {
LOG(INFO) << "Opened " << filename << " output file";
}
mOutTree = std::make_unique<TTree>(treename.c_str(), treename.c_str());
}
// otherwise make it
return tree.Branch(brname.c_str(), ptr);
}

void run(framework::ProcessingContext& pc)
{
if (mFinished) {
return;
}
std::string detStr = mID.getName();
std::string detStrL = mID.getName();
std::transform(detStrL.begin(), detStrL.end(), detStrL.begin(), ::tolower);

// retrieve the digits from the input
auto inDigits = pc.inputs().get<std::vector<o2::fit::Digit>>((detStr + "digits").c_str());
// auto inROFs = pc.inputs().get<std::vector<o2::ITSMFT::ROFRecord>>((detStr + "digitsROF").c_str());
// auto inMC2ROFs = pc.inputs().get<std::vector<o2::ITSMFT::MC2ROFRecord>>((detStr + "digitsMC2ROF").c_str());
// auto inLabels = pc.inputs().get<MCCont*>((detStr + "digitsMCTR").c_str());
LOG(INFO) << "RECEIVED DIGITS SIZE " << inDigits.size();

auto digitsP = &inDigits;
// auto labelsRaw = inLabels.get();
// connect this to a particular branch

auto brDig = getOrMakeBranch(*mOutTree.get(), (detStr + "Digit").c_str(), &digitsP);
// auto brLbl = getOrMakeBranch(*mOutTree.get(), (detStr + "DigitMCTruth").c_str(), &labelsRaw);
mOutTree->Fill();

mOutFile->cd();
mOutTree->Write();
mOutTree.reset(); // delete the tree before closing the file
mOutFile->Close();
mFinished = true;
pc.services().get<ControlService>().readyToQuit(false);
}

protected:
FITDPLDigitWriter() {}
template <typename T>
TBranch* getOrMakeBranch(TTree& tree, std::string brname, T* ptr)
{
if (auto br = tree.GetBranch(brname.c_str())) {
br->SetAddress(static_cast<void*>(ptr));
return br;
}
// otherwise make it
return tree.Branch(brname.c_str(), ptr);
}

bool mFinished = false;
o2::detectors::DetID mID;
o2::header::DataOrigin mOrigin = o2::header::gDataOriginInvalid;
std::vector<o2::fit::Digit> mDigits; // input digits
std::unique_ptr<TFile> mOutFile;
std::unique_ptr<TTree> mOutTree;
};

//_______________________________________________
class T0DPLDigitWriter : public FITDPLDigitWriter
{
public:
// FIXME: origina should be extractable from the DetID, the problem is 3d party header dependencies
static constexpr o2::detectors::DetID::ID DETID = o2::detectors::DetID::T0;
static constexpr o2::header::DataOrigin DETOR = o2::header::gDataOriginT0;
T0DPLDigitWriter()
{
mID = DETID;
mOrigin = DETOR;
}
};

constexpr o2::detectors::DetID::ID T0DPLDigitWriter::DETID;
constexpr o2::header::DataOrigin T0DPLDigitWriter::DETOR;

//_______________________________________________
/// create the processor spec
/// TODO: replace by generic processor once this is working
DataProcessorSpec getFITDigitWriterSpec()
/// describing a processor receiving digits for ITS/MFT and writing them to file
DataProcessorSpec getT0DigitWriterSpec()
{
auto initFunction = [](InitContext& ic) {
// get the option from the init context
auto filename = ic.options().get<std::string>("fit-digit-outfile");
auto treename = ic.options().get<std::string>("treename");
std::string detStr = o2::detectors::DetID::getName(T0DPLDigitWriter::DETID);
std::string detStrL = detStr;
std::transform(detStrL.begin(), detStrL.end(), detStrL.begin(), ::tolower);
auto detOrig = T0DPLDigitWriter::DETOR;

auto outputfile = std::make_shared<TFile>(filename.c_str(), "RECREATE");
auto outputtree = std::make_shared<TTree>(treename.c_str(), treename.c_str());

// container for incoming digits
auto digits = std::make_shared<std::vector<o2::fit::Digit>>();

// the callback to be set as hook at stop of processing for the framework
auto finishWriting = [outputfile, outputtree]() {
outputtree->SetEntries(1);
outputtree->Write();
outputfile->Close();
};
ic.services().get<CallbackService>().set(CallbackService::Id::Stop, finishWriting);

// setup the processing function
// using by-copy capture of the worker instance shared pointer
// the shared pointer makes sure to clean up the instance when the processing
// function gets out of scope
auto processingFct = [outputfile, outputtree, digits](ProcessingContext& pc) {
static bool finished = false;
if (finished) {
// avoid being executed again when marked as finished;
return;
}

// retrieve the digits from the input
auto indata = pc.inputs().get<std::vector<o2::fit::Digit>>("fitdigits");
LOG(INFO) << "RECEIVED DIGITS SIZE " << indata.size();
*digits.get() = std::move(indata);

// connect this to a particular branch
auto br = getOrMakeBranch(*outputtree.get(), "FITDigit", digits.get());
br->Fill();

// retrieve labels from the input
//auto labeldata = pc.inputs().get<o2::dataformats::MCTruthContainer<o2::MCCompLabel>*>("tofdigitlabels");
//LOG(INFO) << "TOF GOT " << labeldata->getNElements() << " LABELS ";
//auto labeldataraw = labeldata.get();
// connect this to a particular branch
//auto labelbr = getOrMakeBranch(*outputtree.get(), "TOFDigitMCTruth", &labeldataraw);
//labelbr->Fill();

finished = true;
pc.services().get<ControlService>().readyToQuit(false);
};

// return the actual processing function as a lambda function using variables
// of the init function
return processingFct;
};
std::vector<InputSpec> inputs;
inputs.emplace_back(InputSpec{ (detStr + "digits").c_str(), detOrig, "DIGITS", 0, Lifetime::Timeframe });

return DataProcessorSpec{
"FITDigitWriter",
Inputs{ InputSpec{ "fitdigits", "FIT", "DIGITS", 0, Lifetime::Timeframe },
/* InputSpec{ "tofdigitlabels", "TOF", "DIGITSMCTR", 0, Lifetime::Timeframe } */ },
(detStr + "DigitWriter").c_str(),
inputs,
{}, // no output
AlgorithmSpec(initFunction),
AlgorithmSpec(adaptFromTask<T0DPLDigitWriter>()),
Options{
{ "fit-digit-outfile", VariantType::String, "fitdigits.root", { "Name of the input file" } },
{ (detStrL + "-digit-outfile").c_str(), VariantType::String, (detStrL + "digits.root").c_str(), { "Name of the input file" } },
{ "treename", VariantType::String, "o2sim", { "Name of top-level TTree" } },
}
};
}


} // end namespace fit
} // end namespace o2
9 changes: 5 additions & 4 deletions Steer/DigitizerWorkflow/src/FITDigitWriterSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ namespace o2
namespace fit
{

o2::framework::DataProcessorSpec getFITDigitWriterSpec();
o2::framework::DataProcessorSpec getT0DigitWriterSpec();
//o2::framework::DataProcessorSpec getMFTDigitWriterSpec();

} // end namespace tof
} // end namespace itsmft
} // end namespace o2

#endif /* STEER_DIGITIZERWORKFLOW_FITDIGITWRITER_H_ */
#endif /* STEER_DIGITIZERWORKFLOW_ITSMFTDIGITWRITER_H_ */
Loading