CbmRoot
CbmModelsQA.cxx
Go to the documentation of this file.
1 /*
2  *====================================================================
3  *
4  * CBM Models
5  *
6  * Authors: V.Vovchenko
7  *
8  * e-mail :
9  *
10  *====================================================================
11  *
12  *
13  *====================================================================
14  */
15 #include "CbmModelsQA.h"
16 
17 #include "CbmKF.h"
18 /*#include "CbmKFParticle.h"*/
19 #include "CbmKFVertex.h"
20 
21 #include "CbmStsCluster.h"
22 #include "CbmStsDigi.h"
23 #include "CbmStsHit.h"
24 #include "CbmStsTrack.h"
25 #include "CbmTrackMatch.h"
26 
27 #include "CbmMatch.h"
28 
29 #include "CbmMCTrack.h"
30 #include "CbmMvdPoint.h"
31 #include "CbmVertex.h"
32 //#include "CbmMvdHitMatch.h"
33 #include "CbmStsPoint.h"
34 
35 #include "TAxis.h"
36 #include "TClonesArray.h"
37 #include "TDirectory.h"
38 #include "TFile.h"
39 #include "TH1F.h"
40 #include "TH2F.h"
41 
42 #include "CbmL1PFFitter.h"
43 #include "L1Field.h"
44 
45 #include "FairRunAna.h"
46 
47 // Models
48 //#include "CbmThermalModelNoFlow.h"
51 #include "HRGModel/CbmHRGModel.h"
55 
56 #include <algorithm>
57 #include <cmath>
58 #include <fstream>
59 #include <iostream>
60 #include <map>
61 using namespace std;
62 using std::vector;
63 
65 
66  CbmModelsQA::CbmModelsQA(Int_t iVerbose,
67  int /*findParticlesMode*/,
68  int /*perf*/,
69  KFParticleTopoReconstructor* tr,
70  const char* name,
71  const char* /*title*/,
72  float ekin_)
73  : FairTask(name, iVerbose)
74  , fPrimVtx(NULL)
75  , outfileName("CbmModelsQA.root")
76  , histodir(0)
77  , vStsHitMatch()
78  , vStsPointMatch()
79  , vMvdPointMatch()
80  , vMCTrackMatch()
81  , fNEvents(0)
82  , fTopoReconstructor(tr)
83  , ekin(ekin_)
84  , Models()
85  , histodirmod(NULL) {
86  TDirectory* currentDir = gDirectory;
87 
88  gDirectory->mkdir("Models");
89  gDirectory->cd("Models");
90 
91  histodirmod = gDirectory;
92 
93  gDirectory = currentDir;
94 }
95 
97  for (unsigned int i = 0; i < Models.size(); ++i) {
98  if (Models[i] != NULL) delete Models[i];
99  }
100 }
101 
102 InitStatus CbmModelsQA::ReInit() { return Init(); }
103 
104 InitStatus CbmModelsQA::Init() {
105  FairRootManager* fManger = FairRootManager::Instance();
106 
107  for (unsigned int i = 0; i < Models.size(); ++i) {
108  if (Models[i] != NULL) Models[i]->ReInit(fManger);
109  }
110  //if (ThermalNoFlow!=NULL) ThermalNoFlow->ReInit(fManger);
111  //if (HRGModel!=NULL) HRGModel->ReInit(fManger);
112  //if (MSSModel!=NULL) MSSModel->ReInit(fManger);
113 
114  return kSUCCESS;
115 }
116 
117 void CbmModelsQA::Exec(Option_t* /*option*/) {
118  for (unsigned int i = 0; i < Models.size(); ++i) {
119  if (Models[i] != NULL) Models[i]->Exec();
120  }
121  //if (ThermalNoFlow!=NULL) ThermalNoFlow->Exec();
122  //if (HRGModel!=NULL) HRGModel->Exec();
123  //if (MSSModel!=NULL) MSSModel->Exec();
124 }
125 
127  for (unsigned int i = 0; i < Models.size(); ++i) {
128  if (Models[i] != NULL) Models[i]->Finish();
129  }
130  if (!(outfileName == "")) {
131  TDirectory* curr = gDirectory;
132  TFile* currentFile = gFile;
133  // Open output file and write histograms
134  TFile* outfile;
135 
136  outfile = new TFile(outfileName.Data(), "RECREATE");
137  outfile->cd();
138  if (histodirmod != NULL) WriteHistos(histodirmod);
139  outfile->Close();
140  outfile->Delete();
141  gFile = currentFile;
142  gDirectory = curr;
143  } else {
145  }
146 }
147 
148 void CbmModelsQA::WriteHistos(TObject* obj) {
149  if (!obj->IsFolder())
150  obj->Write();
151  else {
152  TDirectory* cur = gDirectory;
153  TDirectory* sub = cur->mkdir(obj->GetName());
154  sub->cd();
155  TList* listSub = (static_cast<TDirectory*>(obj))->GetList();
156  TIter it(listSub);
157  while (TObject* obj1 = it())
158  WriteHistos(obj1);
159  cur->cd();
160  }
161 }
162 
164  if (!obj->IsFolder())
165  obj->Write();
166  else {
167  TDirectory* cur = gDirectory;
168  TDirectory* sub = cur->GetDirectory(obj->GetName());
169  sub->cd();
170  TList* listSub = (static_cast<TDirectory*>(obj))->GetList();
171  TIter it(listSub);
172  while (TObject* obj1 = it())
173  WriteHistosCurFile(obj1);
174  cur->cd();
175  }
176 }
177 
178 void CbmModelsQA::AddHRGAnalysis(int TracksType,
179  double SystError,
180  TString name,
181  int EventStats,
182  Bool_t UseWidth,
183  Bool_t UseStatistics,
184  double rad) {
185  CbmHRGModel* HRGModel = new CbmHRGModel(TracksType,
186  1,
187  name,
188  EventStats,
190  UseWidth,
191  UseStatistics,
192  rad);
193 
194  // Default set of ratios
195  HRGModel->AddRatio(-211, 211, SystError); //pi-/pi+
196  HRGModel->AddRatio(-321, 321, SystError); //K-/K+
197  HRGModel->AddRatio(321, 211, SystError); //K+/pi+
198  HRGModel->AddRatio(2212, -211, SystError); //p/pi-
199  //HRGModel->AddRatio(-2212, 2212, SystError); //pbar/p
200  //HRGModel->AddRatio(-3122, 3122, SystError); //Lambdabar/Lambda
201  //HRGModel->AddRatio(-3312, 3312, SystError); //Xi-bar/Xi-
202 
203 
204  // HRGModel->AddRatio(211, -211, SystError); //pi+/pi-
205  // HRGModel->AddRatio(-321, -211, SystError); //K-/pi-
206  // HRGModel->AddRatio(321, -211, SystError); //K+/pi-
207  // HRGModel->AddRatio(2212, -211, SystError); //p/pi-
208  //HRGModel->AddRatio(310, -211, SystError); //K0S/pi-
209  //HRGModel->AddRatio(3122, -211, SystError); //Lambda/pi-
210 
211 
212  //Models.push_back((CbmModelBase*)HRGModel);
213  Models.push_back(static_cast<CbmModelBase*>(HRGModel));
214 }
215 
217  double /*SystError*/,
218  TString name,
219  int EventStats) {
220 
222  TracksType, 1, name, EventStats, fTopoReconstructor, ekin);
223 
224  // Models.push_back((CbmMultiscatteringModel*)MultiscatteringModel);
225  Models.push_back(static_cast<CbmMultiscatteringModel*>(MultiscatteringModel));
226 }
227 
229  const char* pname,
230  int TracksType,
231  double /*SystError*/,
232  TString name,
233  int EventStats) {
234  //int trackNumber = 1;
235 
236  CbmInverseSlope* InverseSlope = new CbmInverseSlope(TracksType,
237  1,
238  name,
239  PDGID,
240  TString(pname),
241  EventStats,
243  ekin);
244  //InverseSlope->AddRapidityInterval(-2.0, -1.8);
245  //InverseSlope->AddRapidityInterval(-1.8, -1.6);
246  //InverseSlope->AddRapidityInterval(-1.6, -1.4);
247  //InverseSlope->AddRapidityInterval(-1.4, -1.2);
248  //InverseSlope->AddRapidityInterval(-1.2, -1.0);
249  //InverseSlope->AddRapidityInterval(-1.0, -0.8);
250  //InverseSlope->AddRapidityInterval(-0.8, -0.6);
251  InverseSlope->AddRapidityInterval(-0.6, -0.4);
252  InverseSlope->AddRapidityInterval(-0.4, -0.2);
253  InverseSlope->AddRapidityInterval(-0.2, 0.0);
254  InverseSlope->AddRapidityInterval(0.0, 0.2);
255  InverseSlope->AddRapidityInterval(0.2, 0.4);
256  InverseSlope->AddRapidityInterval(0.4, 0.6);
257  InverseSlope->AddRapidityInterval(0.6, 0.8);
258  InverseSlope->AddRapidityInterval(0.8, 1.0);
259  InverseSlope->AddRapidityInterval(1.0, 1.2);
260  InverseSlope->AddRapidityInterval(1.2, 1.4);
261  //InverseSlope->AddRapidityInterval(1.4, 1.6);
262  //InverseSlope->AddRapidityInterval(1.6, 1.8);
263  //InverseSlope->AddRapidityInterval(1.8, 2.0);
264  InverseSlope->AddHistos();
265 
266  // Models.push_back((CbmInverseSlope*)InverseSlope);
267  Models.push_back(static_cast<CbmInverseSlope*>(InverseSlope));
268 }
269 
271  const char* pname,
272  int TracksType,
273  double /*SystError*/,
274  TString name,
275  int EventStats) {
277  new CbmBoltzmannDistribution(TracksType,
278  1,
279  name,
280  PDGID,
281  TString(pname),
282  EventStats,
284  ekin);
285 
286  // Models.push_back((CbmBoltzmannDistribution*)BoltzmannDistribution);
287  Models.push_back(
289 }
290 
292  const char* pname,
293  int TracksType,
294  double /*SystError*/,
295  TString name,
296  int EventStats,
297  double Tlong) {
298 
299  CbmBlastWave* BlastWave = new CbmBlastWave(TracksType,
300  1,
301  name,
302  PDGID,
303  TString(pname),
304  EventStats,
306  ekin,
307  Tlong);
308 
309  // BlastWave->AddRapidityInterval(-0.6, -0.4);
310  // BlastWave->AddRapidityInterval(-0.4, -0.2);
311  // BlastWave->AddRapidityInterval(-0.2, 0.0);
312  // BlastWave->AddRapidityInterval(0.0, 0.2);
313  // BlastWave->AddRapidityInterval(0.2, 0.4);
314  // BlastWave->AddRapidityInterval(0.4, 0.6);
315  // BlastWave->AddRapidityInterval(0.6, 0.8);
316  // BlastWave->AddRapidityInterval(0.8, 1.0);
317  // BlastWave->AddRapidityInterval(1.0, 1.2);
318  // BlastWave->AddRapidityInterval(1.2, 1.4);
319  // BlastWave->AddHistos();
320 
321  // Models.push_back((CbmBlastWave*)BlastWave);
322  Models.push_back(static_cast<CbmBlastWave*>(BlastWave));
323 }
324 
326  double /*SystError*/,
327  TString name,
328  TString InputTable) {
329 
331  TracksType, 1, name, fTopoReconstructor, ekin, InputTable);
332 
333  // Models.push_back((CbmImpactParameterModel*)ImpactParameterModel);
334  Models.push_back(static_cast<CbmImpactParameterModel*>(ImpactParameterModel));
335 }
CbmModelsQA::Init
virtual InitStatus Init()
Definition: CbmModelsQA.cxx:104
CbmModelsQA::~CbmModelsQA
~CbmModelsQA()
Definition: CbmModelsQA.cxx:96
CbmModelsQA::AddInverseSlopeAnalysis
void AddInverseSlopeAnalysis(int PDGID=-211, const char *pname="pi-", int TracksType=-1, double SystError=0., TString name="MC", int EventStats=1)
Definition: CbmModelsQA.cxx:228
CbmVertex.h
CbmModelsQA::histodirmod
TDirectory * histodirmod
Definition: CbmModelsQA.h:124
CbmModelsQA::Models
std::vector< CbmModelBase * > Models
Definition: CbmModelsQA.h:123
CbmBlastWave
Definition: CbmBlastWave.h:39
CbmKF.h
CbmModelsQA::AddImpactParameterAnalysis
void AddImpactParameterAnalysis(int TracksType=-1, double SystError=0., TString name="MC", TString InputTable="")
Definition: CbmModelsQA.cxx:325
L1Field.h
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmModelsQA::ekin
float ekin
Definition: CbmModelsQA.h:116
CbmMultiscatteringModel
Definition: CbmMultiscatteringModel.h:38
CbmModelsQA::AddMultiscatteringAnalysis
void AddMultiscatteringAnalysis(int TracksType=-1, double SystError=0., TString name="MC", int EventStats=1)
Definition: CbmModelsQA.cxx:216
CbmMatch.h
CbmTrackMatch.h
ImpactParameterModel
Definition: ImpactParameterModel.h:11
CbmModelsQA::AddHRGAnalysis
void AddHRGAnalysis(int TracksType=-1, double SystError=0., TString name="MC", int EventStats=1, Bool_t UseWidth=false, Bool_t UseStatistics=false, double rad=0.)
Definition: CbmModelsQA.cxx:178
CbmInverseSlope
Definition: CbmInverseSlope.h:38
CbmModelsQA::outfileName
TString outfileName
Definition: CbmModelsQA.h:103
CbmBlastWave.h
CbmMvdPoint.h
CbmStsDigi.h
CbmMultiscatteringModel.h
CbmStsTrack.h
Data class for STS tracks.
CbmModelsQA::AddBlastWaveAnalysis
void AddBlastWaveAnalysis(int PDGID=-211, const char *pname="pi-", int TracksType=-1, double SystError=0., TString name="MC", int EventStats=1, double Tlong=0.132)
Definition: CbmModelsQA.cxx:291
CbmModelsQA::fTopoReconstructor
KFParticleTopoReconstructor * fTopoReconstructor
Definition: CbmModelsQA.h:114
CbmModelsQA
Definition: CbmModelsQA.h:37
CbmModelsQA::Finish
void Finish()
Definition: CbmModelsQA.cxx:126
CbmModelsQA::WriteHistos
void WriteHistos(TObject *obj)
Definition: CbmModelsQA.cxx:148
ClassImp
ClassImp(CbmModelsQA) CbmModelsQA
Definition: CbmModelsQA.cxx:64
CbmModelsQA::WriteHistosCurFile
void WriteHistosCurFile(TObject *obj)
Definition: CbmModelsQA.cxx:163
CbmHRGModel.h
CbmInverseSlope.h
CbmL1PFFitter.h
CbmHRGModel::AddRatio
void AddRatio(int pdgid1, int pdgid2, double SystError=0.)
Definition: CbmHRGModel.cxx:642
CbmModelBase
Definition: CbmModelBase.h:25
CbmImpactParameterModel.h
CbmImpactParameterModel
Definition: CbmImpactParameterModel.h:39
CbmHRGModel
Definition: CbmHRGModel.h:63
CbmModelsQA::Exec
void Exec(Option_t *option)
Definition: CbmModelsQA.cxx:117
CbmStsPoint.h
CbmMCTrack.h
CbmModelsQA.h
BoltzmannDistribution
Definition: BoltzmannDistribution.h:12
CbmModelsQA::AddBoltzmannAnalysis
void AddBoltzmannAnalysis(int PDGID=-211, const char *pname="pi-", int TracksType=-1, double SystError=0., TString name="MC", int EventStats=1)
Definition: CbmModelsQA.cxx:270
CbmModelsQA::ReInit
virtual InitStatus ReInit()
Definition: CbmModelsQA.cxx:102
CbmBoltzmannDistribution.h
CbmBoltzmannDistribution
Definition: CbmBoltzmannDistribution.h:38
CbmStsCluster.h
Data class for STS clusters.
InverseSlope
Definition: InverseSlope.h:12
BlastWave
Definition: BlastWave.h:12
CbmKFVertex.h
MultiscatteringModel
Definition: MultiscatteringModel.h:10
CbmStsHit.h
Data class for a reconstructed hit in the STS.
CbmModelsQA::CbmModelsQA
CbmModelsQA(Int_t iVerbose=1, int findParticlesMode=1, int perf=3, KFParticleTopoReconstructor *tr=0, const char *name="CbmModelsQA", const char *title="Cbm Models QA", float ekin_=24.08)