Skip to content

Commit ee43cbe

Browse files
AllaMaevskayashahor02
authored andcommitted
Realistic time smearing
1 parent d99d439 commit ee43cbe

5 files changed

Lines changed: 45 additions & 20 deletions

File tree

Detectors/FIT/T0/simulation/include/T0Simulation/DigitizationParameters.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ inline o2::fit::DigitizationParameters T0DigitizationParameters()
3030
result.mAmpThreshold = 100; // number of photoelectrons
3131
result.mTimeDiffAC = (Geometry::ZdetA - Geometry::ZdetC) * TMath::C();
3232
result.mIsT0 = true;
33+
result.mSignalWidth = 5;
3334

3435
return result;
3536
}

Detectors/FIT/common/simulation/include/FITSimulation/DigitizationParameters.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct DigitizationParameters {
2727
Int_t mAmpThreshold; // number of photoelectrons
2828
Float_t mTimeDiffAC;
2929
bool mIsT0; //amplitude T0(true) or V0 (false)
30+
Float_t mSignalWidth; // Gate in ns
3031
};
3132
} // namespace o2::fit
3233
#endif

Detectors/FIT/common/simulation/include/FITSimulation/Digitizer.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Digitizer
3030
~Digitizer() = default;
3131

3232
//void process(const std::vector<HitType>* hits, std::vector<Digit>* digits);
33-
void process(const std::vector<o2::t0::HitType>* hits, o2::t0::Digit* digit);
33+
void process(const std::vector<o2::t0::HitType>* hits, o2::t0::Digit* digit, std::vector<std::vector<double>>& channel_times);
3434
void computeAverage(o2::t0::Digit& digit);
3535

3636
void initParameters();
@@ -50,7 +50,7 @@ class Digitizer
5050
uint16_t getBC() const { return mIntRecord.bc; }
5151

5252
void setTriggers(o2::t0::Digit* digit);
53-
void smearCFDtime(o2::t0::Digit* digit);
53+
void smearCFDtime(o2::t0::Digit* digit, std::vector<std::vector<double>> const& channel_times);
5454

5555
void init();
5656
void finish();
@@ -70,6 +70,12 @@ class Digitizer
7070

7171
o2::dataformats::MCTruthContainer<o2::t0::MCLabel>* mMCLabels = nullptr;
7272

73+
static constexpr Float_t C_side_cable_cmps = 2.877; //ns
74+
static constexpr Float_t A_side_cable_cmps = 11.08; //ns
75+
//static constexpr Float_t signal_width = 5.; // time gate for signal, ns
76+
77+
//static std::vector<double> aggregate_channels(const std::vector<o2::fit::HitType>& hits, DigitizationParameters const& parameters);
78+
7379
ClassDefNV(Digitizer, 1);
7480
};
7581
} // namespace fit

Detectors/FIT/common/simulation/src/Digitizer.cxx

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "TMath.h"
1616
#include "TRandom.h"
17+
#include <TH1F.h>
1718
#include <algorithm>
1819
#include <cassert>
1920
#include <iostream>
@@ -23,15 +24,25 @@ using namespace o2::fit;
2324

2425
ClassImp(Digitizer);
2526

26-
void Digitizer::process(const std::vector<o2::t0::HitType>* hits, o2::t0::Digit* digit)
27-
27+
double get_time(const std::vector<double>& times, double signal_width)
2828
{
29-
//parameters constants TO DO: move to class
29+
TH1F hist("time_histogram", "", 1000, -0.5 * signal_width, 0.5 * signal_width);
30+
auto signalForm = [](double x) {
31+
return -(exp(-0.83344945 * x) - exp(-0.45458 * x));
32+
};
33+
for (auto time : times)
34+
for (int bin = hist.FindBin(time); bin < hist.GetSize(); ++bin)
35+
if (hist.GetBinCenter(bin) > time)
36+
hist.AddBinContent(bin, signalForm(hist.GetBinCenter(bin) - time));
37+
double maximum{ hist.GetMaximum() };
38+
int binfound{ hist.FindFirstBinAbove(maximum * 0.4) };
39+
// std::cout<<"@@@@@!!! max "<<maximum<<" binfound "<<binfound<<" return "<<hist.GetBinCenter(binfound)<<std::endl;
40+
return hist.GetBinCenter(binfound);
41+
}
3042

31-
constexpr Float_t C_side_cable_cmps = 2.877; //ns
32-
constexpr Float_t A_side_cable_cmps = 11.08; //ns
33-
constexpr Float_t signal_width = 5.; // time gate for signal, ns
43+
void Digitizer::process(const std::vector<o2::t0::HitType>* hits, o2::t0::Digit* digit, std::vector<std::vector<double>>& channel_times)
3444

45+
{
3546
auto sorted_hits{ *hits };
3647
std::sort(sorted_hits.begin(), sorted_hits.end(), [](o2::t0::HitType const& a, o2::t0::HitType const& b) {
3748
return a.GetTrackID() < b.GetTrackID();
@@ -46,23 +57,24 @@ void Digitizer::process(const std::vector<o2::t0::HitType>* hits, o2::t0::Digit*
4657
for (int i = 0; i < parameters.mMCPs; ++i)
4758
channel_data.emplace_back(o2::t0::ChannelData{ i, 0, 0, 0 });
4859
}
60+
if (channel_times.size() == 0)
61+
channel_times.resize(parameters.mMCPs);
4962
Int_t parent = -10;
5063
assert(digit->getChDgData().size() == parameters.mMCPs);
5164
for (auto& hit : sorted_hits) {
65+
if (hit.GetEnergyLoss() > 0)
66+
continue;
5267
Int_t hit_ch = hit.GetDetectorID();
53-
Double_t hit_time = hit.GetTime();
54-
Bool_t is_A_side = (hit_ch <= 4 * parameters.NCellsA);
68+
Bool_t is_A_side = (hit_ch < 4 * parameters.NCellsA);
5569
Float_t time_compensate = is_A_side ? A_side_cable_cmps : C_side_cable_cmps;
70+
Double_t hit_time = hit.GetTime() - time_compensate;
5671

57-
Bool_t is_hit_in_signal_gate = (hit_time > time_compensate - signal_width * .5) &&
58-
(hit_time < time_compensate + signal_width * .5);
59-
60-
Double_t hit_time_corr = hit_time - time_compensate /* + mBC_clk_center + mEventTime*/;
72+
Bool_t is_hit_in_signal_gate = (abs(hit_time) < parameters.mSignalWidth * .5);
6173

6274
if (is_hit_in_signal_gate) {
6375
channel_data[hit_ch].numberOfParticles++;
64-
channel_data[hit_ch].QTCAmpl += hit.GetEnergyLoss();
65-
channel_data[hit_ch].CFDTime += hit_time_corr;
76+
channel_data[hit_ch].QTCAmpl += hit.GetEnergyLoss(); //for FV0
77+
channel_times[hit_ch].push_back(hit_time);
6678
}
6779

6880
//charge particles in MCLabel
@@ -98,7 +110,7 @@ void Digitizer::computeAverage(o2::t0::Digit& digit)
98110
}
99111

100112
//------------------------------------------------------------------------
101-
void Digitizer::smearCFDtime(o2::t0::Digit* digit)
113+
void Digitizer::smearCFDtime(o2::t0::Digit* digit, std::vector<std::vector<double>> const& channel_times)
102114
{
103115
//smeared CFD time for 50ps
104116
std::vector<o2::t0::ChannelData> mChDgDataArr;
@@ -108,7 +120,8 @@ void Digitizer::smearCFDtime(o2::t0::Digit* digit)
108120
Float_t amp = d.QTCAmpl;
109121
int numpart = d.numberOfParticles;
110122
if (amp > parameters.mCFD_trsh_mip) {
111-
Double_t smeared_time = gRandom->Gaus(cfd, 0.050) + parameters.mBC_clk_center + mEventTime;
123+
//Double_t smeared_time = gRandom->Gaus(cfd, 0.050) + parameters.mBC_clk_center + mEventTime;
124+
double smeared_time = get_time(channel_times[mcp], parameters.mSignalWidth) + parameters.mBC_clk_center + mEventTime;
112125
mChDgDataArr.emplace_back(o2::t0::ChannelData{ mcp, smeared_time, amp, numpart });
113126
}
114127
}

Steer/DigitizerWorkflow/src/FITDigitizerSpec.cxx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ class FITDPLDigitizerTask
101101
mDigitizer.setEventTime(timesview[collID].timeNS);
102102
mDigitizer.setInteractionRecord(timesview[collID]);
103103
digit.cleardigits();
104+
std::vector<std::vector<double>> channel_times;
104105
// for each collision, loop over the constituents event and source IDs
105106
// (background signal merging is basically taking place here)
107+
std::cout << " @@@@ mOrigin " << mOrigin << " mID " << mID.getName() << std::endl;
106108
for (auto& part : eventParts[collID]) {
107109
// get the hits for this event and this source
108110
hits.clear();
@@ -112,15 +114,15 @@ class FITDPLDigitizerTask
112114
// call actual digitization procedure
113115
labels.clear();
114116
// digits.clear();
115-
mDigitizer.process(&hits, &digit);
117+
mDigitizer.process(&hits, &digit, channel_times);
116118
const auto& data = digit.getChDgData();
117119
LOG(INFO) << "Have " << data.size() << " fired channels ";
118120
// copy digits into accumulator
119121
labelAccum.mergeAtBack(labels);
120122
}
121123
mDigitizer.computeAverage(digit);
124+
mDigitizer.smearCFDtime(&digit, channel_times);
122125
mDigitizer.setTriggers(&digit);
123-
mDigitizer.smearCFDtime(&digit);
124126
digitAccum.push_back(digit); // we should move it there actually
125127
LOG(INFO) << "Have " << digitAccum.back().getChDgData().size() << " fired channels ";
126128
digit.printStream(std::cout);
@@ -161,6 +163,7 @@ class FITDPLDigitizerTask
161163
{
162164
std::string detStr = mID.getName();
163165
auto br = mSimChains[sourceID]->GetBranch((detStr + "Hit").c_str());
166+
// auto br = chains[sourceID]->GetBranch(brname);
164167
if (!br) {
165168
LOG(ERROR) << "No branch found";
166169
return;
@@ -207,6 +210,7 @@ o2::framework::DataProcessorSpec getFITT0DigitizerSpec(int channel)
207210
{ "simFileS", VariantType::String, "", { "Sim (signal) input filename" } },
208211
{ "pileup", VariantType::Int, 1, { "whether to run in continuous time mode" } } }
209212

213+
// I can't use VariantType::Bool as it seems to have a problem
210214
};
211215
}
212216

0 commit comments

Comments
 (0)