1616// / @brief Device to write to tree the information for TOF time slewing calibration.
1717
1818#include " Framework/ControlService.h"
19+ #include " Framework/DeviceSpec.h"
1920#include " Framework/ConfigParamRegistry.h"
2021#include " Framework/DataProcessorSpec.h"
2122#include " Framework/Task.h"
@@ -44,9 +45,9 @@ class TOFDigitWriterSplitter : public Task
4445 public:
4546 TOFDigitWriterSplitter (int nTF, bool storeErr = false ) : mTFthr (nTF), mStoreErrors (storeErr) {}
4647
47- void createAndOpenFileAndTree ()
48+ void createAndOpenFileAndTree (int ithread = 0 )
4849 {
49- TString filename = TString::Format (" %s_%06d.root" , mBaseName .c_str (), mCount );
50+ TString filename = TString::Format (" %s_%02d_% 06d.root" , mBaseName .c_str (), ithread , mCount );
5051 LOG (DEBUG ) << " opening file " << filename.Data ();
5152 mfileOut.reset (TFile::Open (TString::Format (" %s" , filename.Data ()), " RECREATE" ));
5253 mOutputTree = std::make_unique<TTree>(" o2sim" , " Tree with TOF digits" );
@@ -66,11 +67,17 @@ class TOFDigitWriterSplitter : public Task
6667 mBaseName = ic.options ().get <std::string>(" output-base-name" );
6768
6869 mCount = 0 ;
69- createAndOpenFileAndTree ();
70+
71+ auto instance = ic.services ().get <const o2::framework::DeviceSpec>().inputTimesliceId ;
72+
73+ createAndOpenFileAndTree (instance);
7074 }
7175
7276 void run (o2::framework::ProcessingContext& pc) final
7377 {
78+ auto instance = pc.services ().get <const o2::framework::DeviceSpec>().inputTimesliceId ;
79+ // pc.services().get<const o2::framework::DeviceSpec>().maxInputTimeslices;
80+
7481 auto digits = pc.inputs ().get <OutputType>(" digits" );
7582 mPDigits = &digits;
7683 auto header = pc.inputs ().get <HeaderType>(" header" );
@@ -90,14 +97,16 @@ class TOFDigitWriterSplitter : public Task
9097 mNTF ++;
9198
9299 if (mNTF >= mTFthr ) {
93- sendOutput ();
100+ sendOutput (instance );
94101 }
95102 }
96103
97104 void endOfStream (o2::framework::EndOfStreamContext& ec) final
98105 {
99106 mIsEndOfStream = true ;
100- sendOutput ();
107+ auto instance = ec.services ().get <const o2::framework::DeviceSpec>().inputTimesliceId ;
108+
109+ sendOutput (instance);
101110 }
102111
103112 private:
@@ -120,7 +129,7 @@ class TOFDigitWriterSplitter : public Task
120129 std::unique_ptr<TFile> mfileOut = nullptr ; // file in which to write the output
121130
122131 // ________________________________________________________________
123- void sendOutput ()
132+ void sendOutput (int instance )
124133 {
125134 // This is to fill the tree.
126135 // One file with an empty tree will be created at the end, because we have to have a
@@ -133,7 +142,7 @@ class TOFDigitWriterSplitter : public Task
133142 mfileOut.reset ();
134143 mCount ++;
135144 if (!mIsEndOfStream ) {
136- createAndOpenFileAndTree ();
145+ createAndOpenFileAndTree (instance );
137146 }
138147 }
139148};
0 commit comments