1414
1515#include " ITSMFTBase/SegmentationAlpide.h"
1616#include " ITS3Simulation/Digitizer.h"
17+ #include " ITS3Base/ITS3Params.h"
1718#include " MathUtils/Cartesian.h"
1819#include " SimulationDataFormat/MCTruthContainer.h"
1920#include " DetectorsRaw/HBFUtils.h"
@@ -43,12 +44,39 @@ void Digitizer::init()
4344 }
4445 }
4546
46- if (mParams .getAlpSimResponse () == nullptr ) {
47- std::string responseFile = " $(O2_ROOT)/share/Detectors/ITSMFT/data/AlpideResponseData/AlpideResponseData.root" ;
48- LOGP (info, " Loading AlpideSimRespnse from file: {}" , responseFile);
49- auto file = TFile::Open (responseFile.data ());
50- mAlpSimResp = (o2::itsmft::AlpideSimResponse*)file->Get (" response0" ); // We use by default the alpide response for Vbb=0V
51- mParams .setAlpSimResponse (mAlpSimResp );
47+ if (!mParams .hasResponseFunctions ()) {
48+ auto loadSetResponseFunc = [&](const char * fileIB, const char * fileOB, const char * name) {
49+ const auto & nameIB = ITS3Params::Instance ().responseFunctionIB ;
50+ const auto & nameOB = ITS3Params::Instance ().responseFunctionOB ;
51+ LOGP (info, " Loading response function for {}: IB={}:{} / OB={}:{}" , name, nameIB, fileIB, nameOB, fileOB);
52+ auto fIB = TFile::Open (fileIB);
53+ if (fIB ->IsZombie () || !fIB ->IsOpen ()) {
54+ LOGP (fatal, " Cannot open file {}" , fileIB);
55+ }
56+ auto fOB = TFile::Open (fileIB);
57+ if (fOB ->IsZombie () || !fOB ->IsOpen ()) {
58+ LOGP (fatal, " Cannot open file {}" , fileOB);
59+ }
60+ mParams .setIBSimResponse (mSimRespIB = fIB ->Get <o2::itsmft::AlpideSimResponse>(nameIB.c_str ()));
61+ mParams .setOBSimResponse (mSimRespOB = fOB ->Get <o2::itsmft::AlpideSimResponse>(nameOB.c_str ()));
62+ fIB ->Close ();
63+ fOB ->Close ();
64+ };
65+
66+ if (const auto & func = ITS3Params::Instance ().chipResponseFunction ; func == " Alpide" ) {
67+ constexpr const char * responseFile = " $(O2_ROOT)/share/Detectors/ITSMFT/data/AlpideResponseData/AlpideResponseData.root" ;
68+ loadSetResponseFunc (responseFile, responseFile, " Alpide" );
69+ mSimRespIBShift = mSimRespIB ->getDepthMax () - SegmentationSuperAlpide::mSensorLayerThickness / 2 .f ;
70+ mSimRespOBShift = mSimRespOB ->getDepthMax () - Segmentation::SensorLayerThickness / 2 .f ;
71+ } else if (func == " APTS" ) {
72+ constexpr const char * responseFileIB = " $(O2_ROOT)/share/Detectors/Upgrades/ITS3/data/ITS3ChipResponseData/APTSResponseData.root" ;
73+ constexpr const char * responseFileOB = " $(O2_ROOT)/share/Detectors/ITSMFT/data/AlpideResponseData/AlpideResponseData.root" ;
74+ loadSetResponseFunc (responseFileIB, responseFileOB, " APTS" );
75+ mSimRespIBShift = mSimRespIB ->getDepthMax () - 10 .e -4f ;
76+ mSimRespOBShift = mSimRespOB ->getDepthMax () - Segmentation::SensorLayerThickness / 2 .f ;
77+ } else {
78+ LOGP (fatal, " ResponseFunction '{}' not implemented!" , func);
79+ }
5280 }
5381 mParams .print ();
5482 mIRFirstSampledTF = o2::raw::HBFUtils::Instance ().getFirstSampledTFIR ();
@@ -326,8 +354,8 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, uint32_t& maxFr, int evID
326354 // take into account that the AlpideSimResponse depth defintion has different min/max boundaries
327355 // although the max should coincide with the surface of the epitaxial layer, which in the chip
328356 // local coordinates has Y = +SensorLayerThickness/2
329- float thickness = innerBarrel ? SegmentationSuperAlpide:: mSensorLayerThickness : Segmentation::SensorLayerThickness ;
330- xyzLocS. SetY (xyzLocS. Y () + mAlpSimResp -> getDepthMax () - thickness / 2 .);
357+ xyzLocS. SetY (xyzLocS. Y () + (( innerBarrel) ? mSimRespIBShift : mSimRespOBShift )) ;
358+
331359 // collect charge in evey pixel which might be affected by the hit
332360 for (int iStep = nSteps; iStep--;) {
333361 // Get the pixel ID
@@ -349,9 +377,9 @@ void Digitizer::processHit(const o2::itsmft::Hit& hit, uint32_t& maxFr, int evID
349377 }
350378 bool flipCol = false , flipRow = false ;
351379 // note that response needs coordinates along column row (locX) (locZ) then depth (locY)
352- double rowMax{0 .5f * (innerBarrel ? SegmentationSuperAlpide::mPitchRow : Segmentation::PitchRow)};
353- double colMax{0 .5f * (innerBarrel ? SegmentationSuperAlpide::mPitchCol : Segmentation::PitchCol)};
354- auto rspmat = mAlpSimResp ->getResponse (xyzLocS.X () - cRowPix, xyzLocS.Z () - cColPix, xyzLocS.Y (), flipRow, flipCol, rowMax, colMax);
380+ float rowMax{0 .5f * (innerBarrel ? SegmentationSuperAlpide::mPitchRow : Segmentation::PitchRow)};
381+ float colMax{0 .5f * (innerBarrel ? SegmentationSuperAlpide::mPitchCol : Segmentation::PitchCol)};
382+ auto rspmat = ((innerBarrel) ? mSimRespIB : mSimRespOB ) ->getResponse (xyzLocS.X () - cRowPix, xyzLocS.Z () - cColPix, xyzLocS.Y (), flipRow, flipCol, rowMax, colMax);
355383
356384 xyzLocS += step;
357385 if (rspmat == nullptr ) {
0 commit comments