source: trunk/MagicSoft/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFF.h@ 6724

Last change on this file since 6724 was 6355, checked in by mazin, 20 years ago
*** empty log message ***
File size: 13.3 KB
Line 
1#ifndef MARS_MFindSupercutsONOFF
2#define MARS_MFindSupercutsONOFF
3
4#ifndef MARS_MParContainer
5#include "MParContainer.h"
6#endif
7
8#ifndef ROOT_TArrayD
9#include <TArrayD.h>
10#endif
11#ifndef ROOT_TArrayI
12#include <TArrayI.h>
13#endif
14
15#ifndef ROOT_TH1F
16#include <TH1F.h>
17#endif
18
19#ifndef ROOT_TPostScript
20#include <TPostScript.h>
21#endif
22
23
24class MFilter;
25class MEvtLoop;
26class MH3;
27class MSupercutsCalcONOFF;
28
29class MGeomCam;
30class MHMatrix;
31
32
33class MFindSupercutsONOFF : public MParContainer
34{
35 private:
36
37
38 // TMP
39 // There are quite some problems during the data preprocessing.
40 // For the time being, I will add some cuts to the functions
41 // DefineTrainTestMatrixThetaRange and for OFF, so that I can
42 // make a kind of preprocess on my own. This allows me
43 // to make a very silly preprocess with wolfgangs macro, which
44 // might be free of corrupted data, and then I can do on my own.
45
46
47 // VARIABLES INITIALIZED IN CONSTRUCTOR
48
49 Double_t fSizeCutLow;
50 Double_t fSizeCutUp;
51
52 Double_t fDistCutLow;
53 Double_t fDistCutUp;
54
55 Double_t fLengthCutLow;
56 Double_t fLengthCutUp;
57
58 Double_t fWidthCutLow;
59 Double_t fWidthCutUp;
60
61 Double_t fLeakageMax;
62
63 Double_t fConvMMToDeg;
64
65 // ENDTMP
66
67
68 Int_t fDegreeON;
69 Int_t fDegreeOFF;
70
71
72 TString fFilenameTrain;
73 TString fFilenameTest;
74
75 Int_t fHowManyTrain;
76 Int_t fHowManyTest;
77
78 Int_t fHowManyTrainOFF;
79 Int_t fHowManyTestOFF;
80
81
82
83 Double_t fAlphaSig; // Max alpha value were signal is expected
84
85 // Background range (in alpha) is defined by the member variables
86 // fAlphaBkgMin and fAlphaBkgMax
87 Double_t fAlphaBkgMin;
88 Double_t fAlphaBkgMax;
89
90 Int_t fThetaMin; // Cut in Theta value (in degrees)
91 Int_t fThetaMax; // Cuts in Theta value (in degrees)
92 TString fThetaRangeString;
93
94
95
96 // Variables for binning of alpha plots
97
98 Int_t fNAlphaBins;
99 Double_t fAlphaBinLow;
100 Double_t fAlphaBinUp;
101
102
103 Bool_t fUseOrigDistribution;
104
105
106 Double_t fNormFactorTrain;
107 Double_t fNormFactorTest;
108 Double_t fSigmaLiMaTrain;
109 Double_t fSigmaLiMaTest;
110 Double_t fNexTrain;
111 Double_t fNexTest;
112 Double_t fGammaEfficiency; // Fraction of gammas that remain after cuts
113 // Quantity that will have to be determined with MC
114
115 Bool_t fTuneNormFactor; // If true, normalization factors are corrected using the estimated number of gammas and the gamma efficiency
116 // fNormFactorTrain = fNormFactorTrain - Ngammas/EventsInTrainMatrixOFF
117
118
119 // Boolean variable used to determine wether the normalization factor is
120 // computed from method 1) or 2)
121 // 1) Using total number of ON and OFF events before cuts, and tuning the factor
122 // correcting for "contamination" of gamma events in ON sample
123 // 2) Using number of ON and OFF events after cuts in the background
124 // region determined by variables fAlphaBkgMin-fAlphaBkgMax
125
126 Bool_t fNormFactorFromAlphaBkg; // if kTRUE, method 2) is used
127
128
129
130 // Boolean variable used to disable the usage ("serious" usage) of the
131 // quantities computed from fits. This will be useful in those cases
132 // where there is too few events to perform a decent fit to the
133 // alpha histograms. Default value will be kTRUE.
134
135 Bool_t fUseFittedQuantities;
136
137 // Boolean variable that controls wether the optimization of the
138 // parameters (MMinuitInterface::CallMinuit(..) in function FindParams(..))
139 // takes place or not. kTRUE will skip such optimization.
140 // This variable is useful to test the optmized parameters (previously found
141 // and stored in root file) on the TRAIN sample.
142
143 Bool_t fSkipOptimization;
144
145
146
147 // Boolean variable that allows the user to set some limits to the
148 // some of the Minuit parameters. For the time being, only the limits
149 // for the parameters which do NOT depend in size, dist and theta are set,
150 // i.e. static limits. The value of this boolean variable is set in the
151 // constructor of the class.
152
153 Bool_t fSetLimitsToSomeMinuitParams;
154
155 // Limits for the Minuit parameters. For the time being the values are set in the constructor
156 // of the class. One MUST be very careful to set limits such that the expected final values
157 // (optimized values) are far away from the limits.
158
159
160
161 Double_t fMinuitDistUPUpperLimit;
162 Double_t fMinuitDistUPLowerLimit;
163 Double_t fMinuitLengthUPUpperLimit;
164 Double_t fMinuitLengthUPLowerLimit;
165 Double_t fMinuitWidthUPUpperLimit;
166 Double_t fMinuitWidthUPLowerLimit;
167
168 Double_t fMinuitLeakage1UPUpperLimit;
169 Double_t fMinuitLeakage1UPLowerLimit;
170
171
172
173 Double_t fMinuitDistLOWUpperLimit;
174 Double_t fMinuitDistLOWLowerLimit;
175 Double_t fMinuitLengthLOWUpperLimit;
176 Double_t fMinuitLengthLOWLowerLimit;
177 Double_t fMinuitWidthLOWUpperLimit;
178 Double_t fMinuitWidthLOWLowerLimit;
179
180
181
182 // Boolean variable used to control decide wether to use theta information
183 // in the computation of teh dynamical cuts.
184 Bool_t fNotUseTheta;
185
186
187 // Boolean variable that allows to use/not use the dist info in the cuts parameterization
188 // kTRUE for use it.
189 // For the time being this variable is set in the constructor
190
191 Bool_t fUseDist;
192
193
194
195 // Boolean variable used to decide wether to use dynamical cuts or static cuts
196 // kTRUE means that static cuts are used.
197 Bool_t fUseStaticCuts;
198
199
200 // Boolean variable that allows the user to write the initial parameters
201 // into the root file that will be used to store the optimum cuts.
202 // If fUseInitialSCParams = kTRUE , parameters are written.
203 // In this way, the initial SC parameters can be applied on the data (train/test)
204
205 // The initial parameters are ONLY written to the root file if
206 // there is NO SC params optimization, i.e., if variable
207 // fSkipOptimization = kTRUE;
208
209 // The default value is obviously kFALSE.
210
211 Bool_t fUseInitialSCParams;
212
213
214 TString fFilenameParam;
215
216 TString fHadronnessName;
217 TString fHadronnessNameOFF;
218
219 // name for the containers to store the
220 // supercuts applied to Train (ON/OFF) and Test(ON/OFF) samples
221
222 TString fTrainONSupercutsAppliedName;
223 TString fTrainOFFSupercutsAppliedName;
224
225 TString fTestONSupercutsAppliedName;
226 TString fTestOFFSupercutsAppliedName;
227
228
229
230 // Name of Postscript file where, for each theta bin, alpha ON and OFF distributions
231 // after cuts (and hence, Nex and SigmaLiMa computations) will be stored
232 // If fAlphaDistributionsPostScriptFilename is not defined, postscript file is not
233 // produced. It is an optional variable...
234
235 // NOT WORKING YET !!!!
236 TPostScript* fPsFilename;
237 TPostScript* fPsFilename2;
238
239 TString fPsFilenameString; // Name of the file where plots will be stored while the
240 // TPostScript option is not working
241
242 TString fAlphaDistributionsRootFilename;
243 // Root file where histograms containing the ON alpha distribution and the
244 // OFF alpha distribution (non normalized) , AFTER CUTS, are stored.
245 // Histograms containing the normalization factors, Nex and SigmaLiMa for
246 // each theta bin will be also stored there.
247 // This name MUST be defined, since the histograms stored there will be used by
248 // function XXX to compute an overall Nex and sigmaLiMa combining all those histograms
249
250
251 MSupercutsCalcONOFF *fCalcHadTrain;
252 MSupercutsCalcONOFF *fCalcHadTest;
253 MSupercutsCalcONOFF *fCalcHadTrainOFF;
254 MSupercutsCalcONOFF *fCalcHadTestOFF;
255
256
257 MHMatrix *fMatrixTrain;
258 MHMatrix *fMatrixTest;
259 MHMatrix *fMatrixTrainOFF;
260 MHMatrix *fMatrixTestOFF;
261
262 MGeomCam *fCam;
263
264 MEvtLoop *fObjectFit;
265
266 MFilter *fMatrixFilter;
267
268 // to comunicate with MINUIT -----------------
269 // attention : dimensions must agree with those in
270 // MMinuitInterface::CallMinuit()
271 //char fParName [80][100];
272 TArrayD fVinit;
273 TArrayD fStep;
274 TArrayD fLimlo;
275 TArrayD fLimup;
276 TArrayI fFix;
277
278 UInt_t fNpar;
279
280 TString fMethod;
281
282 Double_t fMin, fEdm, fErrdef;
283 Int_t fNpari, fNparx, fIstat;
284 Int_t fErrMinimize;
285 //--------------------------------------------
286
287
288public:
289 MFindSupercutsONOFF(const char *name=NULL, const char *title=NULL);
290 ~MFindSupercutsONOFF();
291
292 void SetFilenameTraining(const TString &name, const Int_t howmany)
293 {fFilenameTrain = name; fHowManyTrain = howmany; }
294
295 void SetFilenameTest(const TString &name, const Int_t howmany)
296 {fFilenameTest = name; fHowManyTest = howmany; }
297
298 void SetFilenameParam(const TString &name) {fFilenameParam = name;}
299 void SetHadronnessName(const TString &name) {fHadronnessName = name;}
300 void SetHadronnessNameOFF(const TString &name) {fHadronnessNameOFF = name;}
301
302
303 void SetSupercutsAppliedTreeNames();
304
305
306 void SetAlphaDistributionsRootFilename(const TString &name)
307 {fAlphaDistributionsRootFilename = name;}
308
309 Bool_t SetAlphaSig (Double_t alphasig);
310 Bool_t SetAlphaBkgMin (Double_t alphabkgmin);
311 Bool_t SetAlphaBkgMax (Double_t alphabkgmax);
312
313 // Function that checks that the values of the member data
314 // fAlphaSig, fAlphaBkgMin and fAlphaBkgMax make sense
315 // (ie, fAlphaSig < fAlphaBkgMin < fAlphaBkgMax)
316
317 Bool_t CheckAlphaSigBkg();
318
319 void SetDegreeON (Int_t d) {fDegreeON = d;}
320 void SetDegreeOFF (Int_t d) {fDegreeOFF = d;}
321
322
323 void SetUseFittedQuantities (Bool_t b)
324 {fUseFittedQuantities = b;}
325
326
327 void SetPostScriptFile(TPostScript* PsFile);
328 void SetPostScriptFile2(TPostScript &PsFile);
329
330 void SetPsFilenameString (const TString filename);
331
332
333 void SetMatrixFilter(MFilter *filter) {fMatrixFilter = filter;}
334
335
336
337
338 Bool_t DefineTrainMatrix(const TString &name, MH3 &href,
339 const Int_t howmany, const TString &filetrain);
340 Bool_t DefineTestMatrix(const TString &name, MH3 &href,
341 const Int_t howmany, const TString &filetest);
342
343
344
345 Bool_t DefineTrainTestMatrix(const TString &name, MH3 &href,
346 const Int_t howmanytrain, const Int_t howmanytest,
347 const TString &filetrain, const TString &filetest);
348
349
350
351 Bool_t DefineTrainTestMatrixThetaRange(const TString &name,
352 const Double_t whichfractiontrain,
353 const Double_t whichfractiontest,
354 Double_t ThetaMin, Double_t ThetaMax,
355 const TString &filetrain, const TString &filetest);
356
357
358
359
360 Bool_t DefineTrainTestMatrixOFFThetaRange(const TString &name,
361 const Double_t whichfractiontrain,
362 const Double_t whichfractiontest,
363 Double_t ThetaMin, Double_t ThetaMax,
364 const TString &filetrain, const TString &filetest);
365
366
367 MHMatrix *GetMatrixTrain() { return fMatrixTrain; }
368 MHMatrix *GetMatrixTest() { return fMatrixTest; }
369 MHMatrix *GetMatrixTrainOFF() { return fMatrixTrainOFF; }
370 MHMatrix *GetMatrixTestOFF() { return fMatrixTestOFF; }
371
372
373 void SetUseOrigDistribution(Bool_t b);
374
375
376 Bool_t ReadMatrix( const TString &filetrain, const TString &filetest);
377
378 Bool_t ReadMatrixOFF( const TString &filetrainOFF, const TString &filetestOFF);
379
380
381 Bool_t ReadMatrixTrain(const TString &filetrainON, const TString &filetrainOFF);
382 Bool_t ReadMatrixTest(const TString &filetestON, const TString &filetestOFF);
383
384
385
386 Bool_t ComputeNormFactorTrain ();
387 Bool_t ComputeNormFactorTest ();
388
389 Bool_t FindParams(TString parSCinit, TArrayD &params, TArrayD &steps);
390 // Bool_t TestParams();
391
392 // Function used to apply the supercuts on the TEST sample.
393 // Two event loops (one after the other)
394 // are used to fill the 2 alpha distributions (ON and OFF)
395 // applying supercuts to the Test sample
396 Bool_t TestParamsOnTestSample();
397
398
399 // Function used to apply the supercuts on the TRAIN sample.
400 // Two event loops (one after the other)
401 // are used to fill the 2 alpha distributions (ON and OFF)
402 // applying supercuts to the TRAIN sample
403 Bool_t TestParamsOnTrainSample();
404
405
406
407 Bool_t SetThetaRange(Double_t ThetaMin, Double_t ThetaMax);
408
409 Bool_t SetSizeRange(Double_t SizeMin, Double_t SizeMax);
410
411 Bool_t SetFilters(Double_t LeakageMax, Double_t DistMax, Double_t DistMin);
412
413
414
415 void SetAlphaPlotBinining(Int_t nbins, Double_t binlow, Double_t binup)
416 { fNAlphaBins = nbins; fAlphaBinLow = binlow; fAlphaBinUp = binup;}
417
418 Double_t GetNormFactorTrain() {return fNormFactorTrain;}
419 Double_t GetNormFactorTest() {return fNormFactorTest;}
420 Double_t GetSigmaLiMaTrain() {return fSigmaLiMaTrain;}
421 Double_t GetSigmaLiMaTest() {return fSigmaLiMaTest;}
422 Double_t GetNexTrain() {return fNexTrain;}
423 Double_t GetNexTest() {return fNexTest;}
424
425
426 Double_t GetAlphaSig() {return fAlphaSig;}
427 Double_t GetAlphaBkgMin () {return fAlphaBkgMin;}
428 Double_t GetAlphaBkgMax () {return fAlphaBkgMax;}
429
430 Bool_t GetUseFittedQuantities() {return fUseFittedQuantities;}
431 Bool_t GetSkipOptimization() {return fSkipOptimization;}
432 Bool_t GetUseInitialSCParams() {return fUseInitialSCParams;}
433
434 Bool_t SetGammaEfficiency (Double_t gammaeff);
435 Double_t GetGammaEfficiency() {return fGammaEfficiency;}
436
437
438
439 // Double_t ComputeNormFactorFromAlphaBkg(TH1 *histON, TH1 *histOFF);
440
441 void SetTuneNormFactor(Bool_t b) {fTuneNormFactor = b;}
442
443 void SetNormFactorFromAlphaBkg (Bool_t b) {fNormFactorFromAlphaBkg = b;}
444
445 void SetSkipOptimization(Bool_t b);
446
447 void SetUseInitialSCParams(Bool_t b);
448
449 void SetVariableNotUseTheta(Bool_t b) {fNotUseTheta = b;}
450 Bool_t GetVariableNotUseTheta() { return fNotUseTheta;}
451
452 void SetVariableUseStaticCuts(Bool_t b) {fUseStaticCuts = b;}
453 Bool_t GetVariableUseStaticCuts() { return fUseStaticCuts;}
454
455
456
457
458
459
460 ClassDef(MFindSupercutsONOFF, 1) // Class for optimization of the Supercuts
461};
462
463#endif
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
Note: See TracBrowser for help on using the repository browser.