-
Notifications
You must be signed in to change notification settings - Fork 0
/
StrangeTrackTableProducer.C
105 lines (89 loc) · 3.67 KB
/
StrangeTrackTableProducer.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/// ROOT
#include "iostream"
#include "ostream"
#include "TStyle.h"
#include "TCanvas.h"
#include "TChain.h"
#include "TFile.h"
#include "TList.h"
#include "TLine.h"
#include "TGeoGlobalMagField.h"
#include "TH1.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TStopwatch.h"
#include "TTree.h"
#include "TSystemDirectory.h"
#include "TMath.h"
#include "TString.h"
#include "TLatex.h"
#include "TLegend.h"
#include "TLorentzVector.h"
/// O2
#include "CommonDataFormat/RangeReference.h"
#include "DataFormatsITS/TrackITS.h"
#include "DataFormatsITSMFT/CompCluster.h"
#include "DataFormatsITSMFT/ROFRecord.h"
#include "DataFormatsParameters/GRPObject.h"
#include "DetectorsBase/Propagator.h"
#include "ITSBase/GeometryTGeo.h"
#include "ITStracking/IOUtils.h"
#include "ReconstructionDataFormats/Cascade.h"
#include "ReconstructionDataFormats/PrimaryVertex.h"
#include "ReconstructionDataFormats/TrackTPCITS.h"
#include "ReconstructionDataFormats/V0.h"
#include "ReconstructionDataFormats/VtxTrackIndex.h"
#include "ReconstructionDataFormats/PID.h"
#include "SimulationDataFormat/MCCompLabel.h"
#include "SimulationDataFormat/MCEventLabel.h"
#include "SimulationDataFormat/MCTrack.h"
#include "SimulationDataFormat/MCTruthContainer.h"
#include "ITSMFTSimulation/Hit.h"
#include "GPUCommonArray.h"
#include "DataFormatsITSMFT/TopologyDictionary.h"
#include "DetectorsCommonDataFormats/DetectorNameConf.h"
#include "StrangenessTracking/StrangenessTracker.h"
using namespace o2;
using namespace o2::framework;
using StrangeTrack = o2::dataformats::StrangeTrack;
using ClusAttachments = o2::strangeness_tracking::ClusAttachments;
void StrangeTrackTableProducer() {
TFile OutputFile = TFile("StrangeTracks.root", "recreate");
TTree *Tree = new TTree("StrTTree", "StrTTree");
float Pt, XKF, YKF, ZKF, PtKF, MassKF, TopoChi2KF, GeoChi2KF;
Tree->Branch("Pt", &Pt);
Tree->Branch("XKF", &XKF);
Tree->Branch("YKF", &YKF);
Tree->Branch("ZKF", &ZKF);
Tree->Branch("PtKF", &PtKF);
Tree->Branch("MassKF", &MassKF);
Tree->Branch("TopoChi2KF", &TopoChi2KF);
Tree->Branch("GeoChi2KF", &GeoChi2KF);
auto fStrangeTracks = TFile::Open("/home/ceres/reetz/sim/StrangenessTracking/GeneratorPYTHIAbottle/sims/000/tf1/o2_strange_tracks.root");
auto treeStrangeTracks = (TTree*)fStrangeTracks->Get("o2sim");
std::vector<StrangeTrack> *strangeTrackVec = nullptr;
std::vector<ClusAttachments> *nAttachments = nullptr;
treeStrangeTracks->SetBranchAddress("StrangeTracks", &strangeTrackVec);
treeStrangeTracks->SetBranchAddress("ClusUpdates", &nAttachments);
// default tree values
Pt=-1, XKF=-1, YKF=-1, ZKF=-1, PtKF=-1, MassKF=-1, TopoChi2KF=-1, GeoChi2KF=-1;
cout << "strangeTrackVec->size() = " << strangeTrackVec->size() << endl;
cout << "nAttachments->size() = " << nAttachments->size() << endl;
for (unsigned int iStTr = 0; iStTr < strangeTrackVec->size(); iStTr++) {
auto &strangeTrack = strangeTrackVec->at(iStTr);
auto &itsRef = strangeTrack.mITSRef;
auto &v0Ref = strangeTrack.mDecayRef;
if (!(strangeTrack.mPartType == o2::dataformats::kStrkV0) && !(strangeTrack.mPartType == o2::dataformats::kStrkCascade)) continue; // only fill if track is either V0 or cascade
Pt = sqrt(strangeTrack.mDecayMom[0] * strangeTrack.mDecayMom[0] + strangeTrack.mDecayMom[1] * strangeTrack.mDecayMom[1]);
XKF = strangeTrack.decayVtxXKF;
YKF = strangeTrack.decayVtxYKF;
ZKF = strangeTrack.decayVtxZKF;
MassKF = strangeTrack.mMassKF;
PtKF = strangeTrack.mPtKF;
TopoChi2KF = strangeTrack.mTopoChi2KF;
GeoChi2KF = strangeTrack.mGeoChi2KF;
Tree->Fill();
}
OutputFile.cd();
Tree->Write();
}