]>
Commit | Line | Data |
---|---|---|
1ee39b3a | 1 | // This macro splits the file created by the AliTRDpidRefMaker to smaller training |
2 | // samples according to the momentum of the track in order to increase the training | |
3 | // speed for the TMultiLayerPerceptrons. | |
4 | // The procedure is the following: | |
5 | // 1. Create a directory where the training should take place | |
6 | // 2. Copy the TRD.TaskPidRefMakerNN.root and the TRD.TaskPidRefMakerLQ.root in this directory. | |
7 | // 3. Run makeTrainingDataNN(). This creates new directories: 0.6GeV, 0.8GeV, ..., 10.0GeV and | |
8 | // create a subset of the training data according to the momentum. | |
9 | // 4. Run makeDataLQ(). Does the same as make TraiingDataNN for the LQ data without the creation | |
10 | // of the directories. | |
11 | // 5. Run CreateDummy() to create a TRD.TaskPidRefMaker.root file. This is necessary for the | |
12 | // monitoring of the training progress. | |
13 | // 6. Go to the subdirectories and run the training. | |
14 | ||
15 | #ifndef __CINT__ | |
16 | #include "TROOT.h" | |
17 | #include "TSystem.h" | |
18 | #include "TFile.h" | |
19 | #include "TTree.h" | |
20 | #include "TBranch.h" | |
21 | #include "TObjArray.h" | |
22 | #include "TGraphErrors.h" | |
23 | ||
24 | #include "AliPID.h" | |
25 | #include "AliTRDpidUtil.h" | |
26 | #include "Cal/AliTRDCalPID.h" | |
27 | #include "qaRec/AliTRDpidRefMasker.h" | |
28 | #endif | |
29 | ||
30 | Int_t makeTrainingDataNN(){ | |
31 | ||
32 | Int_t fLayer; | |
33 | Float_t fMom, fv0pid[AliPID::kSPECIES], fdEdx[AliTRDpidUtil::kNNslices]; | |
34 | ||
35 | AliTRDpidUtil Util; | |
36 | TFile *fIn = new TFile("../TRD.TaskPidRefMakerNN.root","READ"); | |
37 | TTree *tIn = (TTree*) fIn -> Get("NN"); | |
38 | ||
39 | tIn -> SetBranchAddress("fLayer", &fLayer); | |
40 | tIn -> SetBranchAddress("fMom", &fMom); | |
41 | tIn -> SetBranchAddress("fv0pid", fv0pid); | |
42 | tIn -> SetBranchAddress("fdEdx", fdEdx); | |
43 | ||
44 | for(Int_t iMomBin = 0; iMomBin < AliTRDCalPID::kNMom; iMomBin++){ | |
45 | ||
46 | gSystem->Exec(Form("mkdir -v ./%3.1fGeV",AliTRDCalPID::GetMomentum(iMomBin))); | |
47 | ||
48 | printf("Extracting training set for momentum bin %3.1f GeV/c\n", AliTRDCalPID::GetMomentum(iMomBin)); | |
49 | TFile *fOut = new TFile(Form("./%3.1fGeV/TRD.TaskPidRefMakerNN.root",AliTRDCalPID::GetMomentum(iMomBin)),"RECREATE"); | |
50 | TTree *tOut = new TTree("NN", "Reference data for NN"); | |
51 | tOut -> Branch("fLayer", &fLayer, "fLayer/I"); | |
52 | tOut -> Branch("fMom", &fMom, "fMom/F"); | |
53 | tOut -> Branch("fv0pid", fv0pid, Form("fv0pid[%d]/F",AliPID::kSPECIES)); | |
54 | tOut -> Branch("fdEdx", fdEdx, Form("fdEdx[%d]/F", AliTRDpidUtil::kNNslices)); | |
55 | ||
56 | for(Int_t iEv = 0; iEv < (tIn -> GetEntries()); iEv++){ | |
57 | fLayer = 0; | |
58 | fMom = 0.0; | |
59 | for(Int_t i = 0; i < AliPID::kSPECIES; i++) fv0pid[i] = 0.0; | |
60 | for(Int_t i = 0; i < AliTRDpidUtil::kNNslices; i++) fdEdx[i] = 0.0; | |
61 | tIn -> GetEntry(iEv); | |
62 | if(Util.GetMomentumBin(fMom) == iMomBin){ | |
63 | tOut -> Fill(); | |
64 | } | |
65 | } | |
66 | ||
67 | tOut -> Write(); | |
68 | tOut -> Delete(); | |
69 | fOut -> Close(); | |
70 | ||
71 | } | |
72 | ||
73 | printf("Extraction completed!"); | |
74 | return 1; | |
75 | ||
76 | } | |
77 | ||
78 | ||
79 | Int_t makeDataLQ(){ | |
80 | ||
81 | Int_t fLayer; | |
82 | Float_t fMom, fv0pid[AliPID::kSPECIES], fdEdx[AliTRDpidUtil::kLQslices]; | |
83 | ||
84 | AliTRDpidUtil Util; | |
85 | TFile *fIn = new TFile("../TRD.TaskPidRefMakerLQ.root","READ"); | |
86 | TTree *tIn = (TTree*) fIn -> Get("LQ"); | |
87 | ||
88 | tIn -> SetBranchAddress("fLayer", &fLayer); | |
89 | tIn -> SetBranchAddress("fMom", &fMom); | |
90 | tIn -> SetBranchAddress("fv0pid", fv0pid); | |
91 | tIn -> SetBranchAddress("fdEdx", fdEdx); | |
92 | ||
93 | for(Int_t iMomBin = 0; iMomBin < AliTRDCalPID::kNMom; iMomBin++){ | |
94 | printf("Extracting training set for momentum bin %3.1f GeV/c\n", AliTRDCalPID::GetMomentum(iMomBin)); | |
95 | TFile *fOut = new TFile(Form("./%3.1fGeV/TRD.TaskPidRefMakerLQ.root",AliTRDCalPID::GetMomentum(iMomBin)),"RECREATE"); | |
96 | TTree *tOut = new TTree("LQ", "Reference data for LQ"); | |
97 | tOut -> Branch("fLayer", &fLayer, "fLayer/I"); | |
98 | tOut -> Branch("fMom", &fMom, "fMom/F"); | |
99 | tOut -> Branch("fv0pid", fv0pid, Form("fv0pid[%d]/F",AliPID::kSPECIES)); | |
100 | tOut -> Branch("fdEdx", fdEdx, Form("fdEdx[%d]/F", AliTRDpidUtil::kLQslices)); | |
101 | ||
102 | for(Int_t iEv = 0; iEv < (tIn -> GetEntries()); iEv++){ | |
103 | fLayer = 0; | |
104 | fMom = 0.0; | |
105 | for(Int_t i = 0; i < AliPID::kSPECIES; i++) fv0pid[i] = 0.0; | |
106 | for(Int_t i = 0; i < AliTRDpidUtil::kLQslices; i++) fdEdx[i] = 0.0; | |
107 | tIn -> GetEntry(iEv); | |
108 | if(Util.GetMomentumBin(fMom) == iMomBin){ | |
109 | tOut -> Fill(); | |
110 | } | |
111 | } | |
112 | ||
113 | tOut -> Write(); | |
114 | tOut -> Delete(); | |
115 | fOut -> Close(); | |
116 | ||
117 | } | |
118 | ||
119 | printf("Extraction completed!"); | |
120 | return 1; | |
121 | ||
122 | } | |
123 | ||
124 | ||
125 | Int_t CreateDummy(){ | |
126 | ||
127 | for(Int_t iMomBin = 0; iMomBin < AliTRDCalPID::kNMom; iMomBin++){ | |
128 | printf("Creating dummy for momentum bin %3.1f GeV/c\n", AliTRDCalPID::GetMomentum(iMomBin)); | |
129 | TFile *fOut = new TFile(Form("./%3.1fGeV/TRD.TaskPidRefMaker.root",AliTRDCalPID::GetMomentum(iMomBin)),"RECREATE"); | |
130 | TObjArray *fContainer = new TObjArray(); | |
131 | ||
132 | TGraphErrors *gEffisTrain = new TGraphErrors(50); | |
133 | // TGraphErrors *gEffisTrain = new TGraphErrors(AliTRDpidRefMaker::kMoniTrain); | |
134 | gEffisTrain -> SetLineColor(4); | |
135 | gEffisTrain -> SetMarkerColor(4); | |
136 | gEffisTrain -> SetMarkerStyle(29); | |
137 | gEffisTrain -> SetMarkerSize(1); | |
138 | ||
139 | TGraphErrors *gEffisTest = new TGraphErrors(50); | |
140 | // TGraphErrors *gEffisTest = new TGraphErrors(AliTRDpidRefMaker::kMoniTrain); | |
141 | gEffisTest -> SetLineColor(2); | |
142 | gEffisTest -> SetMarkerColor(2); | |
143 | gEffisTest -> SetMarkerStyle(29); | |
144 | gEffisTest -> SetMarkerSize(1); | |
145 | ||
146 | fContainer -> AddAt(gEffisTrain,0); | |
147 | fContainer -> AddAt(gEffisTest,1); | |
148 | // fContainer -> AddAt(gEffisTrain,AliTRDpidRefMaker::kGraphTrain); | |
149 | // fContainer -> AddAt(gEffisTest,AliTRDpidRefMaker::kGraphTest); | |
150 | ||
151 | } | |
152 | ||
153 | } |