BmnRoot
Loading...
Searching...
No Matches
BmnMassSpectrumAnal.h
Go to the documentation of this file.
1#include <TNamed.h>
2#include <TChain.h>
3#include <TSystemDirectory.h>
4#include <TCollection.h>
5#include <TClonesArray.h>
6#include <TFile.h>
7#include <TH1F.h>
8#include <TF1.h>
9#include <TFitResult.h>
10#include <TLegend.h>
11#include <TCanvas.h>
12#include <TStyle.h>
13#include <TLatex.h>
14
15#include <BmnParticlePair.h>
16#include <BmnParticlePairCut.h>
17#include <UniDetectorParameter.h>
18#include <UniRun.h>
19
20#include <iostream>
21#include <vector>
22
23using namespace std;
24
25#ifndef BMNMASSSPECTRUMANAL_H
26#define BMNMASSSPECTRUMANAL_H 1
27
28class BmnMassSpectrumAnal : public TNamed {
29public:
30
32
33 BmnMassSpectrumAnal(TString);
34
35 vector <TString> createFilelist();
36
37 void SetTarget(TString t) {
38 fTarget.push_back(t);
39 }
40
41 void SetSpectrumRange(Double_t min, Double_t max) {
42 xLow = min;
43 xUp = max;
44 }
45
46 void SetSignalCut(Double_t s) {
47 fSignal = s;
48 }
49
50 void SetBackgroungCut(Double_t b) {
51 fBackground = b;
52 }
53
54 // Cuts to check optimal ones ...
55
56 void SetCuts(vector <Double_t> DCA0,
57 vector <Double_t> DCA1, vector <Double_t> DCA2, vector <Double_t> DCA12, vector <Double_t> PATH,
58 vector <Int_t> nHitsPos, vector <Int_t> nHitsNeg) {
59
60 // Looping over cut vectors ...
61 for (auto dca0 : DCA0)
62 for (auto dca1 : DCA1)
63 for (auto dca2 : DCA2)
64 for (auto dca12 : DCA12)
65 for (auto path : PATH)
66 for (auto nPos : nHitsPos)
67 for (auto nNeg : nHitsNeg) {
68 BmnParticlePairCut* pCut = new ((*fParticlePairCuts) [fParticlePairCuts->GetEntriesFast()]) BmnParticlePairCut();
69 pCut->SetDca0(dca0);
70 pCut->SetDca1(dca1);
71 pCut->SetDca2(dca2);
72 pCut->SetDca12(dca12);
73 pCut->SetPath(path);
74 pCut->SetNHitsGemPos(nPos);
75 pCut->SetNHitsGemNeg(nNeg);
76 }
77
78 if (fParticlePairCuts->GetEntriesFast())
79 DoOptimization();
80 }
81
82 void SetNFiles(Int_t n) {
83 fNFiles = n;
84 }
85
87
88 }
89
90 void SetStartRun(Int_t start) {
91 fStartRun = start;
92 }
93
94 void SetFinishRun(Int_t finish) {
95 fFinishRun = finish;
96 }
97
98 vector <TString> GetFileList() {
99 return fInFiles;
100 }
101
102private:
103 void DoOptimization();
104 Double_t ImproveCutValue(vector <TString>, BmnParticlePairCut*, TString);
105
106 Int_t FinBin(map <Int_t, pair <Double_t, Double_t>> binMap, Double_t value) {
107 for (auto it : binMap) {
108 Int_t bin = it.first;
109 Double_t min = it.second.first;
110 Double_t max = it.second.second;
111
112 if (value > min && value < max)
113 return bin;
114 }
115 // If multBin not found ...
116 return -1;
117 }
118
119 Bool_t isVectorOk(vector <Double_t> vector) {
120
121 for (auto value : vector)
122 if (TMath::Abs(value) > 100. || TMath::IsNaN(value))
123 return kFALSE;
124
125 return kTRUE;
126 }
127
128protected:
129 void ReadFile(TString, BmnParticlePairCut* cut0 = nullptr, TClonesArray* triggEffInfo = nullptr, Double_t pathMin = 0., Double_t pathMax = 0.);
130
131 TFitResultPtr fitSpectrum(TH1F*);
132 void fitSpectrum(TH1F*, Double_t&, Double_t&, pair <Double_t, Double_t>&, pair <Double_t, Double_t>&);
134 static Double_t background(Double_t*, Double_t*);
135 static Double_t signal(Double_t*, Double_t*);
136 static Double_t fitFunction(Double_t*, Double_t*);
137
138 void GetPtY(vector <Double_t>, vector <Double_t>, Double_t&, Double_t&);
139
140 Double_t deltaB(TF1* f, TFitResultPtr fitRes) {
141 TH1F* h = new TH1F("h", "h", 75., xLow, xUp);
142
143 Double_t min = h->GetBinCenter(fSignalBinMin);
144 Double_t max = h->GetBinCenter(fSignalBinMax);
145
146 if (fitRes.Get()) {
147 Double_t err = f->IntegralError(min - .5 * h->GetBinWidth(1), max + .5 * h->GetBinWidth(1),
148 fitRes->GetParams(), fitRes->GetCovarianceMatrix().GetMatrixArray()) / h->GetBinWidth(1);
149 delete h;
150 return err;
151 } else {
152 delete h;
153 return 0.;
154 }
155 }
156
157protected:
158 // Run info ...
159 Int_t fPeriod;
162
163 vector <TString> fInFiles;
164
165 // Beam, target info ...
166 TString fBeam;
167
168private:
169 TClonesArray* fParticlePairCuts;
170
171 // Spectrum histos ...
172 TH1F** hSpectra;
173
174 // S and B cuts if needed ...
175 Double_t fSignal;
176 Double_t fBackground;
177
178protected:
179 Double_t xLow;
180 Double_t xUp;
181
184
185 vector <TString> fTarget;
186 Int_t fNFiles;
187
188 // Spectrum for improved cut values ...
190
191 // Spectra in Pt-Y space ...
192 Bool_t isPtY;
194 TH1F** hSpectraY;
195
196 Int_t nPtBins;
197 map <Int_t, pair <Double_t, Double_t>> fPtBinMap;
198
199 Int_t nYBins;
200 map <Int_t, pair <Double_t, Double_t>> fYBinMap;
201
203 map <Int_t, pair <Double_t, Double_t>> fPathBins;
204
205 Bool_t isMc;
206
207 ClassDef(BmnMassSpectrumAnal, 0)
208};
209
210
211#endif
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition P4_F32vec4.h:30
float f
Definition P4_F32vec4.h:21
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition P4_F32vec4.h:31
map< Int_t, pair< Double_t, Double_t > > fPtBinMap
void SetCuts(vector< Double_t > DCA0, vector< Double_t > DCA1, vector< Double_t > DCA2, vector< Double_t > DCA12, vector< Double_t > PATH, vector< Int_t > nHitsPos, vector< Int_t > nHitsNeg)
void SetBackgroungCut(Double_t b)
vector< TString > createFilelist()
static Double_t fitFunction(Double_t *, Double_t *)
map< Int_t, pair< Double_t, Double_t > > fYBinMap
Double_t deltaB(TF1 *f, TFitResultPtr fitRes)
void SetStartRun(Int_t start)
void SetSignalCut(Double_t s)
vector< TString > fInFiles
void ReadFile(TString, BmnParticlePairCut *cut0=nullptr, TClonesArray *triggEffInfo=nullptr, Double_t pathMin=0., Double_t pathMax=0.)
Bool_t checkFit(BmnParticlePairCut *)
void SetFinishRun(Int_t finish)
map< Int_t, pair< Double_t, Double_t > > fPathBins
TFitResultPtr fitSpectrum(TH1F *)
static Double_t signal(Double_t *, Double_t *)
void SetTarget(TString t)
vector< TString > fTarget
static Double_t background(Double_t *, Double_t *)
void GetPtY(vector< Double_t >, vector< Double_t >, Double_t &, Double_t &)
vector< TString > GetFileList()
void SetSpectrumRange(Double_t min, Double_t max)
void SetNHitsGemNeg(Int_t nHits)
void SetNHitsGemPos(Int_t nHits)
void SetDca1(Double_t v)
void SetDca0(Double_t v)
void SetPath(Double_t v)
void SetDca12(Double_t v)
void SetDca2(Double_t v)
STL namespace.