Skip to content

Commit

Permalink
FIT: Base TOF for sim hits on hit pos instead of fixed detector pos
Browse files Browse the repository at this point in the history
- Estimate time-of-flight for MC hits based on location of the hits, instead of hard coded detector locations. This way the TOF is compensated for, when detector geometries are misaligned.
- Add additional config parameters for hit time offset (should it be needed).
  • Loading branch information
andreasmolander committed Nov 29, 2023
1 parent f2fdcac commit 22b0e9a
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 47 deletions.
15 changes: 0 additions & 15 deletions Detectors/FIT/FDD/base/include/FDDBase/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,6 @@ constexpr float PMNbOfSecElec = 6.0; // Number of secondary electrons e

constexpr int NTimeBinsPerBC = 256; // number of samples per BC

// Detector TOF correction in ns
constexpr float FDAdist = 1696.67;
constexpr float FDCdist = 1954.4;
constexpr float LayerWidth = 1.27;

constexpr float getTOFCorrection(int det)
{
constexpr float TOFCorr[4] = {
(FDCdist + LayerWidth) / o2::constants::physics::LightSpeedCm2NS,
(FDCdist - LayerWidth) / o2::constants::physics::LightSpeedCm2NS,
(FDAdist - LayerWidth) / o2::constants::physics::LightSpeedCm2NS,
(FDAdist + LayerWidth) / o2::constants::physics::LightSpeedCm2NS};
return TOFCorr[det];
}

} // namespace fdd
} // namespace o2

Expand Down
21 changes: 12 additions & 9 deletions Detectors/FIT/FDD/simulation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,25 @@

o2_add_library(FDDSimulation
SOURCES src/Detector.cxx
src/Digitizer.cxx
PUBLIC_LINK_LIBRARIES O2::SimulationDataFormat
O2::FDDBase
O2::DataFormatsFDD
O2::DetectorsRaw
O2::DetectorsBase
ROOT::Physics)
src/Digitizer.cxx
PUBLIC_LINK_LIBRARIES O2::CommonUtils
O2::SimulationDataFormat
O2::FDDBase
O2::DataFormatsFDD
O2::DetectorsRaw
O2::DetectorsBase
ROOT::Physics)

o2_target_root_dictionary(FDDSimulation
HEADERS include/FDDSimulation/Detector.h
include/FDDSimulation/Digitizer.h
include/FDDSimulation/DigitizationParameters.h)
include/FDDSimulation/Digitizer.h
include/FDDSimulation/DigitizationParameters.h
include/FDDSimulation/FDDDigParam.h)

o2_add_executable(digit2raw
COMPONENT_NAME fdd
SOURCES src/digit2raw.cxx
PUBLIC_LINK_LIBRARIES O2::FDDRaw
Boost::program_options)

o2_data_file(COPY data DESTINATION Detectors/FDD/simulation)
32 changes: 32 additions & 0 deletions Detectors/FIT/FDD/simulation/include/FDDSimulation/FDDDigParam.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// \file FDDDigParam.h
/// \brief Configurable digitization parameters
///
/// \author Andreas Molander <andreas.molander@cern.ch>

#ifndef ALICEO2_FDD_DIG_PARAM
#define ALICEO2_FDD_DIG_PARAM

#include "CommonUtils/ConfigurableParamHelper.h"

namespace o2::fdd
{
struct FDDDigParam : o2::conf::ConfigurableParamHelper<FDDDigParam> {
float hitTimeOffsetA = 0; ///< Hit time offset on the A side [ns]
float hitTimeOffsetC = 0; ///< Hit time offset on the C side [ns]

O2ParamDef(FDDDigParam, "FDDDigParam");
};
} // namespace o2::fdd

#endif // ALICEO2_FDD_DIG_PARAM
12 changes: 10 additions & 2 deletions Detectors/FIT/FDD/simulation/src/Digitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
// or submit itself to any jurisdiction.

#include "FDDSimulation/Digitizer.h"

#include "CommonDataFormat/InteractionRecord.h"
#include "FDDSimulation/FDDDigParam.h"
#include "SimulationDataFormat/MCTruthContainer.h"
#include <CommonDataFormat/InteractionRecord.h>

#include "TMath.h"
#include "TRandom.h"
Expand Down Expand Up @@ -66,7 +68,11 @@ void Digitizer::process(const std::vector<o2::fdd::Hit>& hits,
double delayScintillator = mRndScintDelay.getNextValue();
double timeHit = delayScintillator + hit.GetTime();

timeHit -= getTOFCorrection(int(iChannel / 4)); // account for TOF to detector
// Subtract time-of-flight from hit time
const float timeOfFlight = hit.GetPos().R() / o2::constants::physics::LightSpeedCm2NS;
const float timeOffset = iChannel < 8 ? FDDDigParam::Instance().hitTimeOffsetC : FDDDigParam::Instance().hitTimeOffsetA;

timeHit += -timeOfFlight + timeOffset;
timeHit += mIntRecord.getTimeNS();
o2::InteractionRecord irHit(timeHit); // BC in which the hit appears (might be different from interaction BC for slow particles)

Expand Down Expand Up @@ -420,3 +426,5 @@ void Digitizer::BCCache::print() const
printf("\n");
}
}

O2ParamImpl(FDDDigParam);
1 change: 1 addition & 0 deletions Detectors/FIT/FDD/simulation/src/FDDSimulationLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#pragma link C++ class o2::base::DetImpl < o2::fdd::Detector> + ;
#pragma link C++ class o2::fdd::Digitizer + ;
#pragma link C++ class o2::fdd::DigitizationParameters + ;
#pragma link C++ class o2::fdd::FDDDigParam + ;
#pragma link C++ class o2::dataformats::MCTruthContainer < o2::fdd::MCLabel> + ;

#endif
6 changes: 3 additions & 3 deletions Detectors/FIT/FT0/base/include/FT0Base/FT0DigParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// \file FT0DigParam.h
/// \file FT0DigParam.h
/// \brief Configurable digitization parameters

#ifndef ALICEO2_FT0_DIG_PARAM
Expand All @@ -29,8 +29,8 @@ struct FT0DigParam : o2::conf::ConfigurableParamHelper<FT0DigParam> {
float mAmp_trsh = 100; // [ph.e]
float mAmpRecordLow = -4; // integrate charge from
float mAmpRecordUp = 15; // to [ns]
float mC_side_cable_cmps = 2.86; // ns
float mA_side_cable_cmps = 11.110; // ns
float hitTimeOffsetA = 0; ///< hit time offset on the A side [ns]
float hitTimeOffsetC = 0; ///< hit time offset on the C side [ns]
int mtrg_central_trh = 600.; // channels
int mtrg_semicentral_trh = 300.; // channels

Expand Down
12 changes: 9 additions & 3 deletions Detectors/FIT/FT0/simulation/src/Digitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
#include "FT0Simulation/DigitizationConstants.h"
#include "FT0Base/FT0DigParam.h"
#include "SimulationDataFormat/MCTruthContainer.h"
#include <CommonDataFormat/InteractionRecord.h>
#include "CommonConstants/PhysicsConstants.h"
#include "CommonDataFormat/InteractionRecord.h"

#include "TMath.h"
#include "TRandom.h"
Expand Down Expand Up @@ -207,11 +208,16 @@ void Digitizer::process(const std::vector<o2::ft0::HitType>* hits,
const auto& params = FT0DigParam::Instance();
Int_t hit_ch = hit.GetDetectorID();
Bool_t is_A_side = (hit_ch < 4 * mGeometry.NCellsA);
Float_t time_compensate = is_A_side ? params.mA_side_cable_cmps : params.mC_side_cable_cmps;
Double_t hit_time = hit.GetTime() - time_compensate;

// Subtract time-of-flight from hit time
const Float_t timeOfFlight = hit.GetPos().R() / o2::constants::physics::LightSpeedCm2NS;
const Float_t timeOffset = is_A_side ? params.hitTimeOffsetA : params.hitTimeOffsetC;
Double_t hit_time = hit.GetTime() - timeOfFlight + timeOffset;

if (hit_time > 150) {
continue; // not collect very slow particles
}

auto relBC = o2::InteractionRecord{hit_time};
if (mCache.size() <= relBC.bc) {
mCache.resize(relBC.bc + 1);
Expand Down
12 changes: 10 additions & 2 deletions Detectors/FIT/FV0/simulation/include/FV0Simulation/Digitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,16 @@ class Digitizer

private:
static constexpr int BCCacheMin = 0, BCCacheMax = 7, NBC2Cache = 1 + BCCacheMax - BCCacheMin;
void createPulse(float mipFraction, int parID, const double hitTime, std::array<o2::InteractionRecord, NBC2Cache> const& cachedIR,
int nCachedIR, const int detID);
/// Create signal pulse based on MC hit
/// \param mipFraction Fraction of the MIP energy deposited in the cell
/// \param parID Particle ID
/// \param hitTime Time of the hit
/// \param hitR Length to IP from the position of the hit
/// \param cachedIR Cached interaction records
/// \param nCachedIR Number of cached interaction records
/// \param detID Detector cell ID
void createPulse(float mipFraction, int parID, const double hitTime, const float hitR,
std::array<o2::InteractionRecord, NBC2Cache> const& cachedIR, int nCachedIR, const int detID);

long mTimeStamp; // TF (run) timestamp
InteractionTimeRecord mIntRecord; // Interaction record (orbit, bc) -> InteractionTimeRecord
Expand Down
11 changes: 6 additions & 5 deletions Detectors/FIT/FV0/simulation/include/FV0Simulation/FV0DigParam.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// \file FV0DigParam.h
/// \file FV0DigParam.h
/// \brief Configurable digitization parameters

#ifndef ALICEO2_FV0_DIG_PARAM
Expand All @@ -22,9 +22,11 @@ namespace o2::fv0
{
// parameters of FV0 digitization / transport simulation
struct FV0DigParam : o2::conf::ConfigurableParamHelper<FV0DigParam> {
float photoCathodeEfficiency = 0.23; // quantum efficiency = nOfPhotoE_emitted_by_photocathode / nIncidentPhotons
float lightYield = 0.01; // light collection efficiency to be tuned using collision data [1%]
float adcChannelsPerMip = 16; // Default: 16 for pp and 8 for PbPb
float hitTimeOffset = 0.0; ///< Hit time offset [ns]

float photoCathodeEfficiency = 0.23; // quantum efficiency = nOfPhotoE_emitted_by_photocathode / nIncidentPhotons
float lightYield = 0.01; // light collection efficiency to be tuned using collision data [1%]
float adcChannelsPerMip = 16; // Default: 16 for pp and 8 for PbPb
float getChannelsPerMilivolt() const { return adcChannelsPerMip / 7.5; } // Non-trivial conversion depending on the pulseshape: amplitude to charge
float chargeThrForMeanTime = 5; // Charge threshold, only above which the time is taken into account in calculating the mean time of all qualifying channels

Expand Down Expand Up @@ -55,7 +57,6 @@ struct FV0DigParam : o2::conf::ConfigurableParamHelper<FV0DigParam> {
bool isIntegrateFull = false; // Full charge integration widow in 25 ns
float cfdCheckWindow = 2.5; // time window for the cfd in ns to trigger the charge integration
int avgNumberPhElectronPerMip = 201; // avg number of photo-electrons per MIP
float globalTimeOfFlight = 315.0 / o2::constants::physics::LightSpeedCm2NS; // TODO [check the correct value for distance of FV0 to IP]
float mCfdDeadTime = 15.6; // [ns]
float mCFD_trsh = 3.; // [mV]
float getCFDTrshInAdc() const { return mCFD_trsh * getChannelsPerMilivolt(); } // [ADC channels]
Expand Down
19 changes: 11 additions & 8 deletions Detectors/FIT/FV0/simulation/src/Digitizer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ void Digitizer::process(const std::vector<o2::fv0::Hit>& hits,
for (auto ids : hitIdx) {
const auto& hit = hits[ids];
Int_t detId = hit.GetDetectorID();
Double_t hitEdep = hit.GetHitValue() * 1e3; //convert to MeV
Float_t const hitTime = hit.GetTime() * 1e9;
Double_t hitEdep = hit.GetHitValue() * 1e3; // convert to MeV
Float_t const hitTime = hit.GetTime() * 1e9; // convert to ns
// TODO: check how big is inaccuracy if more than 1 'below-threshold' particles hit the same detector cell
if (hitEdep < FV0DigParam::Instance().singleMipThreshold || hitTime > FV0DigParam::Instance().singleHitTimeThreshold) {
continue;
Expand Down Expand Up @@ -138,15 +138,17 @@ void Digitizer::process(const std::vector<o2::fv0::Hit>& hits,
if (tNS < 0 && cachedIR[nCachedIR] > irHit) {
continue; // don't go to negative BC/orbit (it will wrap)
}
setBCCache(cachedIR[nCachedIR++]); // ensure existence of cached container
} //BCCache loop
createPulse(mipFraction, hit.GetTrackID(), hitTime, cachedIR, nCachedIR, detId);
// ensure existence of cached container
setBCCache(cachedIR[nCachedIR++]);
} // BCCache loop

createPulse(mipFraction, hit.GetTrackID(), hitTime, hit.GetPos().R(), cachedIR, nCachedIR, detId);

} //while loop
} //hitloop
}

void Digitizer::createPulse(float mipFraction, int parID, const double hitTime,
void Digitizer::createPulse(float mipFraction, int parID, const double hitTime, const float hitR,
std::array<o2::InteractionRecord, NBC2Cache> const& cachedIR, int nCachedIR, const int detId)
{

Expand All @@ -160,8 +162,9 @@ void Digitizer::createPulse(float mipFraction, int parID, const double hitTime,
}
}

///Time of flight subtracted from Hit time //TODO have different TOF according to thr ring number
Int_t const NBinShift = std::lround((hitTime - FV0DigParam::Instance().globalTimeOfFlight) / FV0DigParam::Instance().waveformBinWidth);
// Subtract time-of-flight from hit time
const float timeOfFlight = hitR / o2::constants::physics::LightSpeedCm2NS;
Int_t const NBinShift = std::lround((hitTime - timeOfFlight + FV0DigParam::Instance().hitTimeOffset) / FV0DigParam::Instance().waveformBinWidth);

if (NBinShift >= 0 && NBinShift < FV0DigParam::Instance().waveformNbins) {
mPmtResponseTemp.resize(FV0DigParam::Instance().waveformNbins, 0.);
Expand Down

0 comments on commit 22b0e9a

Please sign in to comment.