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

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