@@ -54,6 +54,10 @@ class IOTOFDPLDigitizerTask : o2::base::BaseDPLDigitizer
5454 void initDigitizerTask (framework::InitContext& ic) override
5555 {
5656 mDisableQED = ic.options ().get <bool >(" disable-qed" );
57+ mEnableResponseFiles = ic.options ().get <bool >(" enable-response-files" );
58+ mLocalEfficiencyFile = ic.options ().get <std::string>(" local-efficiency-file" );
59+ mLocalTimeResoFile = ic.options ().get <std::string>(" local-timereso-file" );
60+ mLocalToAFile = ic.options ().get <std::string>(" local-toa-file" );
5761
5862 auto geom = GeometryTGeo::Instance ();
5963 geom->fillMatrixCache (o2::math_utils::bit2Mask (o2::math_utils::TransformType::L2G )); // make sure L2G matrices are loaded
@@ -69,6 +73,13 @@ class IOTOFDPLDigitizerTask : o2::base::BaseDPLDigitizer
6973 if (mFinished ) {
7074 return ;
7175 }
76+
77+ if (mEnableResponseFiles ) {
78+ pc.inputs ().get <TH2D *>(" madpixeff" );
79+ pc.inputs ().get <TH2D *>(" madpixreso" );
80+ pc.inputs ().get <TH2D *>(" madpixtoa" );
81+ }
82+
7283 mFirstOrbitTF = pc.services ().get <o2::framework::TimingInfo>().firstTForbit ;
7384 const o2::InteractionRecord firstIR (0 , mFirstOrbitTF );
7485
@@ -163,10 +174,59 @@ class IOTOFDPLDigitizerTask : o2::base::BaseDPLDigitizer
163174 mFinished = true ;
164175 }
165176
177+ void finaliseCCDB (ConcreteDataMatcher& matcher, void * obj)
178+ {
179+ if (matcher == ConcreteDataMatcher (mOrigin , " MADPIXEFF" , 0 )) {
180+ if (mLocalEfficiencyFile .empty ()) {
181+ LOG (info) << " Using CCDB/MADPIX efficiency file" ;
182+ mDigitizer .loadEfficiencyMap ((TH2D *)obj);
183+ } else {
184+ LOG (info) << " Response function will be loaded from local file: " << mLocalEfficiencyFile ;
185+ std::unique_ptr<TFile> file (TFile::Open (mLocalEfficiencyFile .data (), " READ" ));
186+ if (!file) {
187+ LOG (fatal) << " Cannot open response file " << mLocalEfficiencyFile .data ();
188+ }
189+ mDigitizer .loadEfficiencyMap ((TH2D *)file->Get (" efficiency_pixel" ));
190+ }
191+ return ;
192+ }
193+ if (matcher == ConcreteDataMatcher (mOrigin , " MADPIXRESO" , 0 )) {
194+ if (mLocalTimeResoFile .empty ()) {
195+ LOG (info) << " Using CCDB/MADPIX time resolution file" ;
196+ mDigitizer .loadResolutionMap ((TH2D *)obj);
197+ } else {
198+ LOG (info) << " Response function will be loaded from local file: " << mLocalTimeResoFile ;
199+ std::unique_ptr<TFile> file (TFile::Open (mLocalTimeResoFile .data (), " READ" ));
200+ if (!file) {
201+ LOG (fatal) << " Cannot open response file " << mLocalTimeResoFile .data ();
202+ }
203+ mDigitizer .loadResolutionMap ((TH2D *)file->Get (" sigma_pixel" ));
204+ }
205+ return ;
206+ }
207+ if (matcher == ConcreteDataMatcher (mOrigin , " MADPIXTOA" , 0 )) {
208+ if (mLocalToAFile .empty ()) {
209+ LOG (info) << " Using CCDB/MADPIX time-of-arrival file" ;
210+ mDigitizer .loadTimeOfArrivalMap ((TH2D *)obj);
211+ } else {
212+ LOG (info) << " Response function will be loaded from local file: " << mLocalToAFile ;
213+ std::unique_ptr<TFile> file (TFile::Open (mLocalToAFile .data (), " READ" ));
214+ if (!file) {
215+ LOG (fatal) << " Cannot open response file " << mLocalToAFile .data ();
216+ }
217+ mDigitizer .loadTimeOfArrivalMap ((TH2D *)file->Get (" toa_pixel" ));
218+ }
219+ }
220+ }
221+
166222 private:
167223 bool mDisableQED = false ;
224+ bool mEnableResponseFiles = false ;
168225 bool mWithMCTruth {true };
169226 bool mFinished {false };
227+ std::string mLocalEfficiencyFile {" " };
228+ std::string mLocalTimeResoFile {" " };
229+ std::string mLocalToAFile {" " };
170230 unsigned long mFirstOrbitTF = 0x0 ;
171231 const o2::detectors::DetID mID {o2::detectors::DetID::TF3 };
172232 const o2::header::DataOrigin mOrigin {o2::header::gDataOriginTF3 };
@@ -197,7 +257,9 @@ o2::framework::DataProcessorSpec getIOTOFDigitizerSpec(int channel, bool mctruth
197257{
198258 std::vector<o2::framework::InputSpec> inputs;
199259 inputs.emplace_back (" collisioncontext" , " SIM" , " COLLISIONCONTEXT" , static_cast <o2::header::DataHeader::SubSpecificationType>(channel), o2::framework::Lifetime::Timeframe);
200- inputs.emplace_back (" IOTOF_aptsresp" , " TF3" , " APTSRESP" , 0 , o2::framework::Lifetime::Condition, o2::framework::ccdbParamSpec (" IT3/Calib/APTSResponse" ));
260+ inputs.emplace_back (" madpixeff" , " TF3" , " MADPIXEFF" , 0 , o2::framework::Lifetime::Condition, o2::framework::ccdbParamSpec (" Users/g/glucia/tmp/ALICE3/IOTOF/pixelEfficiency" ));
261+ inputs.emplace_back (" madpixreso" , " TF3" , " MADPIXRESO" , 0 , o2::framework::Lifetime::Condition, o2::framework::ccdbParamSpec (" Users/g/glucia/tmp/ALICE3/IOTOF/pixelResolution" ));
262+ inputs.emplace_back (" madpixtoa" , " TF3" , " MADPIXTOA" , 0 , o2::framework::Lifetime::Condition, o2::framework::ccdbParamSpec (" Users/g/glucia/tmp/ALICE3/IOTOF/pixelTimeOfArrival" ));
201263
202264 const std::string detStr = o2::detectors::DetID::getName (o2::detectors::DetID::TF3 );
203265 return o2::framework::DataProcessorSpec{detStr + " Digitizer" ,
@@ -206,7 +268,10 @@ o2::framework::DataProcessorSpec getIOTOFDigitizerSpec(int channel, bool mctruth
206268 o2::framework::AlgorithmSpec{o2::framework::adaptFromTask<IOTOFDPLDigitizerTask>(mctruth)},
207269 o2::framework::Options{
208270 {" disable-qed" , o2::framework::VariantType::Bool, false , {" disable QED handling" }},
209- {" local-response-file" , o2::framework::VariantType::String, " " , {" use response file saved locally at this path/filename" }}}};
271+ {" enable-response-files" , o2::framework::VariantType::Bool, false , {" enable in-pixel response maps from data" }},
272+ {" local-efficiency-file" , o2::framework::VariantType::String, " " , {" use efficiency map saved locally at this path/filename" }},
273+ {" local-timereso-file" , o2::framework::VariantType::String, " " , {" use time resolution map saved locally at this path/filename" }},
274+ {" local-toa-file" , o2::framework::VariantType::String, " " , {" use ToA map saved locally at this path/filename" }}}};
210275}
211276
212277} // namespace o2::iotof
0 commit comments