Skip to content

Commit bbbd46f

Browse files
committed
Let digitization context provide GRP
1 parent 73a31f3 commit bbbd46f

File tree

6 files changed

+25
-38
lines changed

6 files changed

+25
-38
lines changed

DataFormats/simulation/include/SimulationDataFormat/RunContext.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "CommonDataFormat/InteractionRecord.h"
1818
#include "CommonDataFormat/BunchFilling.h"
1919
#include "DetectorsCommonDataFormats/DetID.h"
20+
#include "DataFormatsParameters/GRPObject.h"
2021
#include <FairLogger.h>
2122

2223
namespace o2
@@ -81,6 +82,9 @@ class RunContext
8182
int entryID,
8283
std::vector<T>* hits) const;
8384

85+
/// returns the GRP object associated to this context
86+
o2::parameters::GRPObject const& getGRP() const;
87+
8488
private:
8589
int mNofEntries = 0;
8690
int mMaxPartNumber = 0; // max number of parts in any given collision
@@ -92,7 +96,8 @@ class RunContext
9296

9397
o2::BunchFilling mBCFilling; // patter of active BCs
9498

95-
std::vector<std::string> mSimPrefixes; // identifiers to the hit sim products; the index corresponds to the source ID of event record
99+
std::vector<std::string> mSimPrefixes; // identifiers to the hit sim products; the index corresponds to the source ID of event record
100+
mutable o2::parameters::GRPObject* mGRP = nullptr; //!
96101

97102
ClassDefNV(RunContext, 2);
98103
};

DataFormats/simulation/src/RunContext.cxx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// or submit itself to any jurisdiction.
1010

1111
#include "SimulationDataFormat/RunContext.h"
12-
#include "DetectorsCommonDataFormats/FileNameGenerator.h"
12+
#include "DetectorsCommonDataFormats/NameConf.h"
1313
#include <TChain.h>
1414
#include <iostream>
1515

@@ -51,12 +51,22 @@ bool RunContext::initSimChains(o2::detectors::DetID detid, std::vector<TChain*>&
5151

5252
simchains.emplace_back(new TChain("o2sim"));
5353
// add the main (background) file
54-
simchains.back()->AddFile(o2::filenames::SimFileNameGenerator::getHitFileName(detid, mSimPrefixes[0].data()).c_str());
54+
simchains.back()->AddFile(o2::base::NameConf::getHitsFileName(detid, mSimPrefixes[0].data()).c_str());
5555

5656
for (int source = 1; source < mSimPrefixes.size(); ++source) {
5757
simchains.emplace_back(new TChain("o2sim"));
5858
// add signal files
59-
simchains.back()->AddFile(o2::filenames::SimFileNameGenerator::getHitFileName(detid, mSimPrefixes[source].data()).c_str());
59+
simchains.back()->AddFile(o2::base::NameConf::getHitsFileName(detid, mSimPrefixes[source].data()).c_str());
6060
}
6161
return true;
6262
}
63+
64+
o2::parameters::GRPObject const& RunContext::getGRP() const
65+
{
66+
if (!mGRP) {
67+
// we take the GRP from the background file
68+
// maybe we should add a check that all GRPs are consistent ..
69+
mGRP = o2::parameters::GRPObject::loadFrom(o2::base::NameConf::getGRPFileName(mSimPrefixes[0].data()).c_str());
70+
}
71+
return *mGRP;
72+
}

Steer/DigitizerWorkflow/src/FDDDigitizerSpec.cxx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ class FDDDPLDigitizerTask
4646
{
4747
LOG(INFO) << "initializing FDD digitization";
4848

49-
const std::string inputGRP = "o2sim_grp.root";
50-
const std::string grpName = "GRP";
51-
TFile flGRP(inputGRP.c_str());
52-
if (flGRP.IsZombie()) {
53-
LOG(FATAL) << "Failed to open " << inputGRP;
54-
}
55-
std::unique_ptr<GRP> grp(static_cast<GRP*>(flGRP.GetObjectChecked(grpName.c_str(), GRP::Class())));
56-
mDigitizer.setEventTime(grp->getTimeStart());
5749
//mDigitizer.setCCDBServer(dopt.ccdb);
5850
mDigitizer.init();
5951
//mROMode = mDigitizer.isContinuous() ? o2::parameters::GRPObject::CONTINUOUS : o2::parameters::GRPObject::PRESENT;
@@ -73,7 +65,7 @@ class FDDDPLDigitizerTask
7365
auto& irecords = context->getEventRecords();
7466

7567
context->initSimChains(o2::detectors::DetID::FDD, mSimChains);
76-
68+
mDigitizer.setEventTime(context->getGRP().getTimeStart());
7769
for (auto& record : irecords) {
7870
LOG(INFO) << "FDD TIME RECEIVED " << record.timeNS;
7971
}

Steer/DigitizerWorkflow/src/FT0DigitizerSpec.cxx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,6 @@ class FT0DPLDigitizerTask
5353

5454
void init(framework::InitContext& ic)
5555
{
56-
const std::string inputGRP = "o2sim_grp.root";
57-
const std::string grpName = "GRP";
58-
TFile flGRP(inputGRP.c_str());
59-
if (flGRP.IsZombie()) {
60-
LOG(FATAL) << "Failed to open " << inputGRP;
61-
}
62-
std::unique_ptr<GRP> grp(static_cast<GRP*>(flGRP.GetObjectChecked(grpName.c_str(), GRP::Class())));
63-
6456
mDigitizer.init();
6557
mROMode = mDigitizer.isContinuous() ? o2::parameters::GRPObject::CONTINUOUS : o2::parameters::GRPObject::PRESENT;
6658
}

Steer/DigitizerWorkflow/src/FV0DigitizerSpec.cxx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,7 @@ class FV0DPLDigitizerTask
4949
void init(framework::InitContext& ic)
5050
{
5151
LOG(INFO) << "FV0DPLDigitizerTask:init";
52-
53-
const std::string inputGRP = "o2sim_grp.root";
54-
const std::string grpName = "GRP";
55-
TFile flGRP(inputGRP.c_str());
56-
if (flGRP.IsZombie()) {
57-
LOG(FATAL) << "Failed to open " << inputGRP;
58-
}
59-
std::unique_ptr<GRP> grp(static_cast<GRP*>(flGRP.GetObjectChecked(grpName.c_str(), GRP::Class())));
6052
mDigitizer.init();
61-
mDigitizer.setTimeStamp(grp->getTimeStart());
6253
}
6354

6455
void run(framework::ProcessingContext& pc)
@@ -72,6 +63,8 @@ class FV0DPLDigitizerTask
7263
auto context = pc.inputs().get<o2::steer::RunContext*>("collisioncontext");
7364
context->initSimChains(o2::detectors::DetID::FV0, mSimChains);
7465

66+
mDigitizer.setTimeStamp(context->getGRP().getTimeStart());
67+
7568
auto& irecords = context->getEventRecords();
7669
auto& eventParts = context->getEventParts();
7770

Steer/DigitizerWorkflow/src/ZDCDigitizerSpec.cxx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ class ZDCDPLDigitizerTask
4848

4949
auto& dopt = o2::conf::DigiParams::Instance();
5050

51-
const std::string inputGRP = "o2sim_grp.root";
52-
const std::string grpName = "GRP";
53-
TFile flGRP(inputGRP.c_str());
54-
if (flGRP.IsZombie()) {
55-
LOG(FATAL) << "Failed to open " << inputGRP;
56-
}
57-
std::unique_ptr<GRP> grp(static_cast<GRP*>(flGRP.GetObjectChecked(grpName.c_str(), GRP::Class())));
58-
mDigitizer.setTimeStamp(grp->getTimeStart());
5951
mDigitizer.setCCDBServer(dopt.ccdb);
6052
mDigitizer.init();
6153
mROMode = mDigitizer.isContinuous() ? o2::parameters::GRPObject::CONTINUOUS : o2::parameters::GRPObject::PRESENT;
@@ -75,6 +67,9 @@ class ZDCDPLDigitizerTask
7567
auto context = pc.inputs().get<o2::steer::RunContext*>("collisioncontext");
7668
context->initSimChains(o2::detectors::DetID::ZDC, mSimChains);
7769

70+
const auto& grp = context->getGRP();
71+
mDigitizer.setTimeStamp(grp.getTimeStart());
72+
7873
auto& irecords = context->getEventRecords();
7974
auto& eventParts = context->getEventParts();
8075

0 commit comments

Comments
 (0)