Skip to content

Commit 9f2b159

Browse files
AllaMaevskayasawenzel
authored andcommitted
FIT: Initial MCtruth treatment for charged particles / QED background
* initial impl for mctruth in DigitizerTask; Still needs to ported to DPL * initial QED background
1 parent 92b135a commit 9f2b159

File tree

10 files changed

+242
-24
lines changed

10 files changed

+242
-24
lines changed

Detectors/FIT/simulation/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ set(SRCS
66
src/Detector.cxx
77
src/Digitizer.cxx
88
src/DigitizerTask.cxx
9-
10-
)
9+
)
1110
set(HEADERS
1211
include/${MODULE_NAME}/Detector.h
1312
include/${MODULE_NAME}/Digitizer.h
1413
include/${MODULE_NAME}/DigitizerTask.h
14+
include/${MODULE_NAME}/MCLabel.h
1515
)
1616

1717
Set(LINKDEF src/FITSimulationLinkDef.h)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
/// \file DigitizerTask.h
12+
/// \brief Definition of the TOF digitizer task
13+
14+
#ifndef ALICEO2_FIT_DIGITIZERTASK_H
15+
#define ALICEO2_FIT_DIGITIZERTASK_H
16+
17+
#include "FairTask.h" // for FairTask, InitStatus
18+
#include "Rtypes.h" // for DigitizerTask::Class, ClassDef, etc
19+
20+
#include "FITBase/Digit.h"
21+
#include "FITSimulation/Detector.h" // for HitType
22+
#include "FITSimulation/Digitizer.h"
23+
#include "SimulationDataFormat/MCTruthContainer.h"
24+
#include "SimulationDataFormat/MCCompLabel.h"
25+
#include "FITSimulation/MCLabel.h"
26+
27+
namespace o2
28+
{
29+
namespace fit
30+
{
31+
32+
class DigitizerTask : public FairTask
33+
{
34+
using Digitizer = o2::fit::Digitizer;
35+
36+
public:
37+
DigitizerTask();
38+
~DigitizerTask() override;
39+
40+
InitStatus Init() override;
41+
42+
void Exec(Option_t* option) override;
43+
void FinishTask() override;
44+
45+
Digitizer& getDigitizer() { return mDigitizer; }
46+
void setContinuous(bool v) { mContinuous = v; }
47+
bool isContinuous() const { return mContinuous; }
48+
49+
void setQEDInput(TBranch* qed, float timebin, UChar_t srcID);
50+
51+
void setQEDInput(TBranch* qed, float timebin, UChar_t srcID);
52+
53+
private:
54+
void processQEDBackground(double tMax);
55+
56+
Bool_t mContinuous = kFALSE; ///< flag to do continuous simulation
57+
double mFairTimeUnitInNS = 1; ///< Fair time unit in ns
58+
59+
Int_t mSourceID = 0; ///< current source
60+
Int_t mEventID = 0; ///< current event id from the source
61+
Digitizer mDigitizer; ///< Digitizer
62+
const std::vector<o2::fit::HitType>* mHitsArray = nullptr; ///< Array of MC hits
63+
64+
TBranch* mQEDBranch = nullptr; //! optional special branch of hits from QED collitions
65+
const std::vector<o2::fit::HitType>* mHitsArrayQED = nullptr; //! array of MC hits from ED
66+
float mQEDEntryTimeBinNS = 0.f; ///< every entry in the QED branch integrates QED for so many nanosec.
67+
double mLastQEDTimeNS = 0.; ///< center of the time-bin of last added QED bg slot (entry of mQEDBranch)
68+
int mLastQEDEntry = -1; ///< last used QED entry
69+
UChar_t mQEDSourceID = 0; ///< MC ID source of the QED (stored in the labels)
70+
71+
Digit* mEventDigit = nullptr; ///< one digit for one event
72+
o2::dataformats::MCTruthContainer<o2::fit::MCLabel> mMCTruthArray ; //! Labels containter
73+
o2::dataformats::MCTruthContainer<o2::fit::MCLabel>* mMCTruthArrayPtr = &mMCTruthArray; //! Labels containter pointer
74+
75+
ClassDefOverride(DigitizerTask, 1);
76+
};
77+
} // namespace fit
78+
} // namespace o2
79+
80+
#endif /* ALICEO2_TOF_DIGITIZERTASK_H */

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
#include "FITBase/Digit.h"
1515
#include "FITSimulation/Detector.h"
16+
#include "SimulationDataFormat/MCTruthContainer.h"
17+
#include "SimulationDataFormat/MCCompLabel.h"
18+
#include "FITSimulation/MCLabel.h"
1619

1720
namespace o2
1821
{
@@ -31,11 +34,14 @@ class Digitizer
3134
// void printParameters();
3235
void setEventTime(double value) { mEventTime = value; }
3336
void setEventID(Int_t id) { mEventID = id; }
37+
void setSrcID(Int_t id) { mSrcID = id; }
3438
Int_t getCurrentTimeFrame() const { return mTimeFrameCurrent; }
3539
void setCurrentTimeFrame(Double_t value) { mTimeFrameCurrent = value; }
3640

3741
void init();
3842
void finish();
43+
// void setMCLabels(o2::dataformats::MCTruthContainer<o2::MCCompLabel>* mclb) { mMCLabels = mclb; }
44+
void setMCLabels(o2::dataformats::MCTruthContainer<o2::fit::MCLabel>* mclb) { mMCLabels = mclb; }
3945

4046
private:
4147
// digit info
@@ -46,12 +52,15 @@ class Digitizer
4652
Int_t mMode;
4753
Int_t mTimeFrameCurrent;
4854
Double_t mEventTime; // Initialized in initParameters
49-
Int_t mEventID = 0;
50-
Int_t mSrcID = 0;
55+
Int_t mEventID;
56+
Int_t mSrcID;
5157
Int_t mAmpThreshold; // Initialized in initParameters
5258
Double_t mLowTime; // Initialized in initParameters
5359
Double_t mHighTime; // Initialized in initParameters
5460
Double_t mTimeDiffAC = (Geometry::ZdetA - Geometry::ZdetC) * TMath::C();
61+
62+
o2::dataformats::MCTruthContainer<o2::fit::MCLabel>* mMCLabels = nullptr;
63+
5564
ClassDefNV(Digitizer, 1);
5665
};
5766
} // namespace fit

Detectors/FIT/simulation/include/FITSimulation/DigitizerTask.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
#include "FITBase/Digit.h"
2121
#include "FITSimulation/Detector.h" // for HitType
2222
#include "FITSimulation/Digitizer.h"
23+
#include "SimulationDataFormat/MCTruthContainer.h"
24+
#include "SimulationDataFormat/MCCompLabel.h"
25+
#include "FITSimulation/MCLabel.h"
2326

2427
namespace o2
2528
{
@@ -43,7 +46,11 @@ class DigitizerTask : public FairTask
4346
void setContinuous(bool v) { mContinuous = v; }
4447
bool isContinuous() const { return mContinuous; }
4548

49+
void setQEDInput(TBranch* qed, float timebin, UChar_t srcID);
50+
4651
private:
52+
void processQEDBackground(double tMax);
53+
4754
Bool_t mContinuous = kFALSE; ///< flag to do continuous simulation
4855
double mFairTimeUnitInNS = 1; ///< Fair time unit in ns
4956

@@ -52,8 +59,20 @@ class DigitizerTask : public FairTask
5259
Digitizer mDigitizer; ///< Digitizer
5360
const std::vector<o2::fit::HitType>* mHitsArray = nullptr; ///< Array of MC hits
5461

55-
Digit* mEventDigit = nullptr; ///< one digit for one event
56-
//std::vector<o2::fit::Digit>* mDigitsArray = nullptr; ///< Array of digits
62+
TBranch* mQEDBranch = nullptr; //! optional special branch of hits from QED collitions
63+
const std::vector<o2::fit::HitType>* mHitsArrayQED = nullptr; //! array of MC hits from ED
64+
float mQEDEntryTimeBinNS = 0.f; ///< every entry in the QED branch integrates QED for so many nanosec.
65+
double mLastQEDTimeNS = 0.; ///< center of the time-bin of last added QED bg slot (entry of mQEDBranch)
66+
int mLastQEDEntry = -1; ///< last used QED entry
67+
UChar_t mQEDSourceID = 0; ///< MC ID source of the QED (stored in the labels)
68+
69+
Digit* mEventDigit = nullptr; ///< one digit for one event
70+
//std::vector<o2::fit::Digit>* mDigitsArray = nullptr; ///< Array of digits
71+
// o2::dataformats::MCTruthContainer<o2::MCCompLabel> *mMCTruthArray = nullptr;
72+
// o2::dataformats::MCTruthContainer<o2::MCCompLabel> mMCTruthArray; //! Labels containter
73+
// o2::dataformats::MCTruthContainer<o2::MCCompLabel>* mMCTruthArrayPtr = &mMCTruthArray; //! Labels containter pointer
74+
o2::dataformats::MCTruthContainer<o2::fit::MCLabel> mMCTruthArray; //! Labels containter
75+
o2::dataformats::MCTruthContainer<o2::fit::MCLabel>* mMCTruthArrayPtr = &mMCTruthArray; //! Labels containter pointer
5776

5877
ClassDefOverride(DigitizerTask, 1);
5978
};
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
11+
// Declaration of a transient MC label class for FIT
12+
13+
#ifndef ALICEO2_FIT_MCLABEL_H_
14+
#define ALICEO2_FIT_MCLABEL_H_
15+
16+
#include "SimulationDataFormat/MCCompLabel.h"
17+
18+
namespace o2
19+
{
20+
namespace fit
21+
{
22+
class MCLabel : public o2::MCCompLabel
23+
{
24+
private:
25+
Int_t mDetID = -1;
26+
27+
public:
28+
MCLabel() = default;
29+
MCLabel(Int_t trackID, Int_t eventID, Int_t srcID, Int_t qID)
30+
: o2::MCCompLabel(trackID, eventID, srcID), mDetID(qID) {}
31+
Int_t getDetID() const { return mDetID; }
32+
33+
ClassDefNV(MCLabel, 1);
34+
};
35+
} // namespace fit
36+
} // namespace o2
37+
38+
#endif

Detectors/FIT/simulation/src/Detector.cxx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ void Detector::InitializeO2Detector()
5151
// FIXME: we need to register the sensitive volumes with FairRoot
5252
TGeoVolume* v = gGeoManager->GetVolume("0REG");
5353
if (v == nullptr)
54-
LOG(WARN) << "@@@@ Sensitive volume 0REG not found!!!!!!!!";
54+
printf("@@@@ Sensitive volume 0REG not found!!!!!!!!");
5555
else {
5656
AddSensitiveVolume(v);
5757
}
5858
}
5959

6060
void Detector::ConstructGeometry()
6161
{
62-
LOG(DEBUG) << "Creating FIT geometry";
62+
LOG(DEBUG) << "Creating FIT geometry\n";
6363
CreateMaterials();
6464

6565
Float_t zdetA = 333;
@@ -74,11 +74,10 @@ void Detector::ConstructGeometry()
7474

7575
int nCellsA = Geometry::NCellsA;
7676
int nCellsC = Geometry::NCellsC;
77-
77+
7878
Geometry geometry;
7979
TVector3 centerMCP = geometry.centerMCP(2);
80-
LOG(DEBUG) << "@@@@ mGeometry->centerMCP " << nCellsA << " " << nCellsC << centerMCP.X();
81-
80+
8281
Matrix(idrotm[901], 90., 0., 90., 90., 180., 0.);
8382

8483
// C side Concave Geometry
@@ -163,7 +162,6 @@ void Detector::ConstructGeometry()
163162
nameTr = Form("0TR%i", itr + 1);
164163
z = -pstartA[2] + pinstart[2];
165164
tr[itr] = new TGeoTranslation(nameTr.Data(), xa[itr], ya[itr], z);
166-
LOG(DEBUG) << Form(" FIT: itr %i A %f %f %f \n", itr, xa[itr], ya[itr], z + zdetA);
167165
tr[itr]->RegisterYourself();
168166
stlinA->AddNode(ins, itr, tr[itr]);
169167
}
@@ -247,13 +245,10 @@ void Detector::SetOneMCP(TGeoVolume* ins)
247245
topref->AddNode(top, 1, new TGeoTranslation(0, 0, 0));
248246
xinv = -ptop[0] - prfv[0];
249247
topref->AddNode(rfv, 1, new TGeoTranslation(xinv, 0, 0));
250-
LOG(DEBUG) << Form(" GEOGEO refv %f , 0,0 \n", xinv);
251248
xinv = ptop[0] + prfv[0];
252249
topref->AddNode(rfv, 2, new TGeoTranslation(xinv, 0, 0));
253-
LOG(DEBUG) << Form(" GEOGEO refv %f , 0,0 \n", xinv);
254-
yinv = -ptop[1] - prfh[1];
250+
yinv = -ptop[1] - prfh[1];
255251
topref->AddNode(rfh, 1, new TGeoTranslation(0, yinv, 0));
256-
LOG(DEBUG) << Form(" GEOGEO refh , 0, %f, 0 \n", yinv);
257252
yinv = ptop[1] + prfh[1];
258253
topref->AddNode(rfh, 2, new TGeoTranslation(0, yinv, 0));
259254

@@ -265,11 +260,9 @@ void Detector::SetOneMCP(TGeoVolume* ins)
265260
yin = -pinstart[1] + 0.3 + (iy + 0.5) * 2 * ptopref[1];
266261
ntops++;
267262
ins->AddNode(topref, ntops, new TGeoTranslation(xin, yin, z));
268-
LOG(DEBUG) << Form(" 0TOP full %i x %f y %f z %f \n", ntops, xin, yin, z);
269-
z = -pinstart[2] + 2 * pal[2] + 2 * ptopref[2] + preg[2];
263+
z = -pinstart[2] + 2 * pal[2] + 2 * ptopref[2] + preg[2];
270264
ins->AddNode(cat, ntops, new TGeoTranslation(xin, yin, z));
271265
// cat->Print();
272-
LOG(DEBUG) << Form(" GEOGEO CATHOD x=%f , y= %f z= %f num %i\n", xin, yin, z, ntops);
273266
}
274267
}
275268
// Al top
@@ -296,12 +289,16 @@ Bool_t Detector::ProcessHits(FairVolume* v)
296289
float etot = fMC->Etot();
297290
int iPart = fMC->TrackPid();
298291
float enDep = fMC->Edep();
292+
if (fMC->TrackCharge()) { //charge particles for MCtrue
293+
AddHit(x, y, z, time, 10, trackID, detID);
294+
}
299295
if (iPart == 50000050) // If particles is photon then ...
300296
{
301297
if (RegisterPhotoE(etot)) {
302298
AddHit(x, y, z, time, enDep, trackID, detID);
303299
}
304300
}
301+
305302
return kTRUE;
306303
}
307304
return kFALSE;

Detectors/FIT/simulation/src/Digitizer.cxx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
// or submit itself to any jurisdiction.
1010

1111
#include "FITSimulation/Digitizer.h"
12+
#include "FITSimulation/MCLabel.h"
13+
#include "SimulationDataFormat/MCTruthContainer.h"
1214

1315
#include "TFile.h"
1416
#include "TH1F.h"
@@ -48,6 +50,7 @@ void Digitizer::process(const std::vector<HitType>* hits, Digit* digit)
4850

4951
//mDigits = digits;
5052

53+
Int_t nlbl = 0; //number of MCtrues
5154
Double_t digit_timeframe = mEventTime;
5255
Double_t digit_bc = mEventID;
5356
Int_t nClk = floor(mEventTime / BC_clk);
@@ -65,6 +68,18 @@ void Digitizer::process(const std::vector<HitType>* hits, Digit* digit)
6568
ch_hit_nPe[hit_ch]++;
6669
ch_hit_mean_time[hit_ch] += hit_time;
6770
}
71+
if (hit.GetEnergyLoss() > 0) {
72+
o2::fit::MCLabel label(hit.GetTrackID(), mEventID, mSrcID, hit_ch);
73+
// o2::MCCompLabel label(hit.GetTrackID(), mEventID, mSrcID);
74+
int tr, ev, sr;
75+
label.get(tr, ev, sr);
76+
int lblCurrent;
77+
if (mMCLabels) {
78+
lblCurrent = mMCLabels->getIndexedSize(); // this is the size of mHeaderArray;
79+
mMCLabels->addElement(lblCurrent, label);
80+
nlbl++;
81+
}
82+
}
6883
}
6984

7085
for (Int_t ch_iter = 0; ch_iter < nMCPs; ch_iter++) {
@@ -157,7 +172,7 @@ void Digitizer::process(const std::vector<HitType>* hits, Digit* digit)
157172
is_Vertex = (vertex_time > trg_vertex_min) && (vertex_time < trg_vertex_max);
158173
// --------------------------------------------------------------------------
159174

160-
//fillig digit
175+
//filling digit
161176
digit->setTime(digit_timeframe);
162177
digit->setBC(mEventID);
163178
digit->setTriggers(is_A, is_C, is_Central, is_SemiCentral, is_Vertex);
@@ -189,10 +204,6 @@ void Digitizer::process(const std::vector<HitType>* hits, Digit* digit)
189204
LOG(DEBUG) << "IS A " << is_A << " IS C " << is_C << " is Central " << is_Central
190205
<< " is SemiCentral " << is_SemiCentral << " is Vertex " << is_Vertex << FairLogger::endl;
191206

192-
//LOG(DEBUG) << *digit << FairLogger::endl;
193-
//std::cout << *digit << FairLogger::endl;
194-
// digit->printStream( std::cout );
195-
196207
LOG(DEBUG) << "======================================\n\n"
197208
<< FairLogger::endl;
198209
// --------------------------------------------------------------------------

0 commit comments

Comments
 (0)