source: trunk/MagicSoft/Mars/mtemp/mmpi/SupercutsONOFFClasses/MFindSupercutsONOFFThetaLoop.h@ 4788

Last change on this file since 4788 was 4411, checked in by paneque, 20 years ago
*** empty log message ***
File size: 14.3 KB
Line 
1#ifndef MARS_MFindSupercutsONOFFThetaLoop
2#define MARS_MFindSupercutsONOFFThetaLoop
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;
28class MFindSupercutsONOFF;
29class MGeomCam;
30class MHMatrix;
31
32
33class MFindSupercutsONOFFThetaLoop : public MParContainer
34{
35private:
36
37 TString fDataONRootFilename;
38 TString fDataOFFRootFilename;
39
40
41 TString fPathForFiles; // Path to directory where files (PsFiles, rootfiles) will be stored
42
43
44 TString* fOptSCParamFilenameVector; // Pointer to vector of TStrings containing name of the root files where optimized supercuts will be stored. To be created and filled once Vector of Costheta ranges is defined
45
46
47
48
49 // Vectors containing the names of the root files where matrices
50 // will be stored for Train/Test ON/OFF samples.
51 // To be defined and filled once vector fCosThetaRangeVector is
52 // defined
53
54 TString* fTrainMatrixONFilenameVector;
55 TString* fTestMatrixONFilenameVector;
56 TString* fTrainMatrixOFFFilenameVector;
57 TString* fTestMatrixOFFFilenameVector;
58
59
60 Double_t fAlphaSig; // Max alpha value were signal is expected
61
62
63 // Background range (in alpha) is defined by the member variables
64 // fAlphaBkgMin and fAlphaBkgMax
65 Double_t fAlphaBkgMin;
66 Double_t fAlphaBkgMax;
67
68
69 // Size range of events used to fill the data matrices
70 // is defined by the following variables
71
72 Double_t fSizeCutLow;
73 Double_t fSizeCutUp;
74
75
76 // Variables for binning of alpha plots
77
78 Int_t fNAlphaBins;
79 Double_t fAlphaBinLow;
80 Double_t fAlphaBinUp;
81
82
83
84 // Boolean variable used to disable the usage ("serious" usage) of the
85 // quantities computed from fits. This will be useful in those cases
86 // where there is too few events to perform a decent fit to the
87 // alpha histograms. In general this variable will be always kTRUE
88
89 Bool_t fUseFittedQuantities;
90
91
92 Double_t fPolyGaussFitAlphaSigma;
93
94
95 Double_t fWhichFractionTrain; // number <= 1; specifying fraction of ON Train events
96 Double_t fWhichFractionTest; // number <= 1; specifying fraction of ON Test events
97
98 Double_t fWhichFractionTrainOFF; // number <= 1; specifying fraction of OFF Train events
99 Double_t fWhichFractionTestOFF; // number <= 1; specifying fraction of OFF Test events
100
101 Double_t fThetaMin; // Cuts in ThetaOrig.fVal (in rad!!!)
102 Double_t fThetaMax; // Cuts in ThetaOrig.fVal (in rad !!!)
103 TArrayD fCosThetaRangeVector; // vector containing the
104 // theta ranges that will be used in the
105 // optimization
106
107 TString* fThetaRangeStringVector; // Pointer to vector of TStrings that contain Cos theta ranges specified in fCosThetaRangeVector. It will be used to identify alpha distributions stored in fAlphaDistributionsRootFilename
108
109 TArrayD fCosThetaBinCenterVector; // vector containing the
110 // theta bin centers of the theta ranges/bins contained in
111 // fCosThetaRangeVector
112
113 Double_t fActualCosThetaBinCenter; // Theta value used to fill
114 // the histograms fNormFactorTrainHist, fNormFactorTestHist,
115 // fSigmaLiMaTrainHist ...
116
117
118
119 Double_t fOverallNexTrain;
120 Double_t fOverallNexTest;
121
122 Double_t fOverallSigmaLiMaTrain;
123 Double_t fOverallSigmaLiMaTest;
124
125
126 TH1F* fSuccessfulThetaBinsHist; // Hist containing theta bins were optimization was successful
127
128 TH1F* fNormFactorTrainHist; // Hist containing norm factors train for all Cos theta ranges
129 TH1F* fNormFactorTestHist; // Hist containing norm factors test for all Cos theta ranges
130 TH1F* fSigmaLiMaTrainHist; // Hist containing SigmaLiMa for Train samples for all Cos theta ranges
131 TH1F* fSigmaLiMaTestHist; // Hist containing SigmaLiMa for Test samples for all Cos theta ranges
132 TH1F* fNexTrainHist; // Hist containing Number os excess events for Train sample for all Cos thetas
133 TH1F* fNexTestHist; // Hist containing Number os excess events for Test sample for all Cos theta
134
135 TH1F* fNEvtsInTrainMatrixONHist; // Hist containing total number of events in Train Matrices of ON data for all Cos theta ranges
136 TH1F* fNEvtsInTestMatrixONHist; // Hist containing total number of events in Test Matrices of ON data for all Cos theta ranges
137 TH1F* fNEvtsInTrainMatrixOFFHist; // Hist containing total number of events in Train Matrices of OFF data for all Cos theta ranges
138 TH1F* fNEvtsInTestMatrixOFFHist; // Hist containing total number of events in Test Matrices of OFF data for all Cos theta ranges
139
140
141
142
143 // Boolean variable that controls wether the optimization of the
144 // parameters (MMinuitInterface::CallMinuit(..) in function FindParams(..))
145 // takes place or not. kTRUE will skip such optimization.
146 // This variable is useful to test the optmized parameters (previously found
147 // and stored in root file) on the TRAIN sample.
148
149 Bool_t fSkipOptimization;
150
151
152
153
154 // Boolean variable that allows the user to write the initial parameters
155 // into the root file that will be used to store the optimum cuts.
156 // If fUseInitialSCParams = kTRUE , parameters are written.
157 // In this way, the initial SC parameters can be applied on the data (train/test)
158
159 // The initial parameters are ONLY written to the root file if
160 // there is NO SC params optimization, i.e., if variable
161 // fSkipOptimization = kTRUE;
162
163 // The default value is obviously kFALSE.
164
165 Bool_t fUseInitialSCParams;
166
167
168 Double_t fGammaEfficiency; // Fraction of gammas that remain after cuts
169 // Quantity that will have to be determined with MC
170
171 Bool_t fTuneNormFactor; // If true, normalization factors are corrected
172 // using the estimated number of gammas and the gamma efficiency
173 // fNormFactor = fNormFactor - Ngammas/EventsInMatrixOFF
174
175
176 // Boolean variable used to determine wether the normalization factor is
177 // computed from method 1) or 2)
178 // 1) Using total number of ON and OFF events before cuts, and tuning the factor
179 // correcting for "contamination" of gamma events in ON sample
180 // 2) Using number of ON and OFF events after cuts in the background
181 // region determined by variables fAlphaBkgMin-fAlphaBkgMax
182
183 Bool_t fNormFactorFromAlphaBkg; // if kTRUE, method 2) is used
184
185
186 // Boolean variable used to control decide wether to use theta information
187 // in the computation of teh dynamical cuts.
188 Bool_t fNotUseTheta;
189
190 // Boolean variable used to decide wether to use dynamical cuts or static cuts
191 // kTRUE means that static cuts are used.
192 Bool_t fUseStaticCuts;
193
194
195 // Names for the Hadronness containers for ON and OFF data
196
197 TString fHadronnessName;
198 TString fHadronnessNameOFF;
199
200 // Vectors where initial SC parameters and steps are stored.
201 // If these vectors are empty, initial SC parameters and steps
202 // are taken from Supercuts container.
203 // They will be intialized to empty vectors in constructor
204
205 TArrayD fInitSCPar;
206 TArrayD fInitSCParSteps;
207
208
209
210 // Name of Postscript file where, for each theta bin, alpha ON and OFF distributions
211 // after cuts (and hence, Nex and SigmaLiMa computations) will be stored
212 // If fAlphaDistributionsPostScriptFilename is not defined, postscript file is not
213 // produced. It is an optional variable...
214
215 // Still not working...
216
217 TPostScript* fPsFilename;
218
219
220 // ********************************************************
221 // Due to the failure of the use of object TPostScript
222 // to make a Ps document with all plots, I decided to use the
223 // standard way (SaveAs(filename.ps)) to store plots related
224 // to alpha distributions
225 // for ON and OFF and BEFORE and AFTER cuts (VERY IMPORTANT
226 // TO COMPUTE EFFICIENCIES IN CUTS)
227
228 // Psfilename is set inside function LoopOverThetaRanges()
229 // and given to the object MFindSupercutsONOFF created
230 // within this loop.
231
232 // This will have to be removed as soon as the TPostScript
233 // solutions works...
234 // ********************************************************
235
236
237 TString fAlphaDistributionsRootFilename;
238 // Root file where histograms containing the ON alpha distribution and the
239 // OFF alpha distribution (non normalized) , AFTER CUTS, are stored.
240 // Histograms containing the normalization factors, Nex and SigmaLiMa for
241 // each theta bin will be also stored there.
242 // This name MUST be defined, since the histograms
243 // stored there will be used by
244 // function XXX to compute an overall Nex and sigmaLiMa
245 // combining all those histograms
246
247 // Boolean variables seting flags for loop over theta ranges
248
249 Bool_t fReadMatricesFromFile;
250 Bool_t fOptimizeParameters;
251 Bool_t fTestParameters;
252
253 //--------------------------------------------
254
255
256public:
257 MFindSupercutsONOFFThetaLoop(const char *name=NULL,
258 const char *title=NULL);
259 ~MFindSupercutsONOFFThetaLoop();
260
261 void SetHadronnessName(const TString &name)
262 {fHadronnessName = name;}
263 void SetHadronnessNameOFF(const TString &name)
264 {fHadronnessNameOFF = name;}
265
266 void SetPathForFiles(const TString &path)
267 {fPathForFiles = path;}
268
269 void SetDataONOFFRootFilenames(const TString &name1, const TString &name2 )
270 {fDataONRootFilename = name1; fDataOFFRootFilename = name2; }
271
272
273
274 // Names of root files containing matrices and optimizedparameters
275 Bool_t SetALLNames();
276
277 // Function to set names manually... in case matrices are
278 // already defined...
279
280 Bool_t SetNamesManually(TString* OptSCParamFilenameVector,
281 TString* ThetaRangeStringVector,
282 TString* TrainMatrixONFilenameVector,
283 TString* TestMatrixONFilenameVector,
284 TString* TrainMatrixOFFFilenameVector,
285 TString* TestMatrixOFFFilenameVector)
286
287 {
288 fOptSCParamFilenameVector = OptSCParamFilenameVector;
289 fThetaRangeStringVector = ThetaRangeStringVector;
290 fTrainMatrixONFilenameVector = TrainMatrixONFilenameVector;
291 fTestMatrixONFilenameVector = TestMatrixONFilenameVector;
292 fTrainMatrixOFFFilenameVector = TrainMatrixOFFFilenameVector;
293 fTestMatrixOFFFilenameVector = TestMatrixOFFFilenameVector;
294
295 return kTRUE;
296 }
297
298 Bool_t SetAlphaDistributionsRootFilename(const TString &name);
299
300
301 Bool_t SetAlphaSig (Double_t alphasig);
302
303 Bool_t SetAlphaBkgMin (Double_t alphabkgmin);
304 Bool_t SetAlphaBkgMax (Double_t alphabkgmax);
305
306 Bool_t CheckAlphaSigBkg();
307
308 void SetPostScriptFile(TPostScript* PsFile);
309
310
311 Bool_t SetCosThetaRangeVector (const TArrayD &d);
312
313 Bool_t SetThetaRange (Int_t thetabin);
314
315
316 void SetAlphaPlotBinining(Int_t nbins, Double_t binlow, Double_t binup)
317 { fNAlphaBins = nbins; fAlphaBinLow = binlow; fAlphaBinUp = binup;}
318
319 Bool_t SetNormFactorTrainHist();
320 Bool_t SetNormFactorTestHist();
321 Bool_t SetSigmaLiMaTrainHist();
322 Bool_t SetSigmaLiMaTestHist();
323 Bool_t SetNexTrainHist();
324 Bool_t SetNexTestHist();
325 Bool_t SetNexSigmaLiMaNormFactorNEvtsTrainTestHist();
326 Bool_t SetSuccessfulThetaBinsHist();
327 void WriteNexSigmaLiMaNormFactorNEvtsTrainTestHistToFile();
328
329 void WriteSuccessfulThetaBinsHistToFile();
330
331
332 Bool_t SetInitSCPar (TArrayD &d);
333 Bool_t SetInitSCParSteps (TArrayD &d);
334
335
336
337 Bool_t ReadSCParamsFromAsciiFile(const char* filename, Int_t Nparams);
338
339
340 void SetFractionTrainTestOnOffEvents(Double_t fontrain,
341 Double_t fontest,
342 Double_t fofftrain,
343 Double_t fofftest);
344
345 void SetTuneNormFactor(Bool_t b) {fTuneNormFactor = b;}
346 Bool_t SetGammaEfficiency (Double_t gammaeff);
347
348
349
350 void SetNormFactorFromAlphaBkg (Bool_t b) {fNormFactorFromAlphaBkg = b;}
351
352 void SetUseFittedQuantities (Bool_t b)
353 {fUseFittedQuantities = b;}
354
355 void SetReadMatricesFromFile(Bool_t b);
356 void SetTrainParameters(Bool_t b) {fOptimizeParameters = b;}
357 void SetTestParameters(Bool_t b) {fTestParameters = b;}
358
359
360 void SetSkipOptimization(Bool_t b) {fSkipOptimization = b;}
361
362 void SetUseInitialSCParams(Bool_t b) {fUseInitialSCParams = b;}
363
364
365 void SetVariableNotUseTheta(Bool_t b) {fNotUseTheta = b;}
366 Bool_t GetVariableNotUseTheta() { return fNotUseTheta;}
367
368
369 void SetVariableUseStaticCuts(Bool_t b) {fUseStaticCuts = b;}
370 Bool_t GetVariableUseStaticCuts() { return fUseStaticCuts;}
371
372
373 void SetSizeRange(Double_t SizeMin, Double_t SizeMax)
374 {fSizeCutLow = SizeMin; fSizeCutUp = SizeMax; }
375
376 // Function that loops over the theta ranges defined by
377 // fCosThetaRangeVector optimizing parameter and/or testing
378 // parameters
379
380 Bool_t LoopOverThetaRanges();
381
382
383 // Function that loops over the alpha distributions (ON-OFF)
384 // stored in root file defined by fAlphaDistributionsRootFilename
385 // and computes the significance and Nex (using MHFindSignificanceONOFF::FindSigma)
386 // for several cuts in alpha (0-fAlphaSig; in bins defined for alpha distributions
387 // by user).
388
389 // It creates the histograms, fills them and store them
390 // in root file defined by fAlphaDistributionsRootFilename. A single histogram
391 // for each theta bin.
392
393 // The function returns kFALSE if it could not accomplish its duty
394
395 Bool_t ComputeNexSignificanceVSAlphaSig();
396
397
398
399
400 // Function that gets the histograms with the alpha distributions
401 // (for all the theta bins specified by fCosThetaRangeVector)
402 // stored in fAlphaDistributionsRootFilename, and combine them
403 // (correcting OFF histograms with the normalization factors stored
404 // in NormFactorTrain or NormFactorTest) to get one single
405 // Alpha distribution for ON and another one for OFF.
406 // Then these histograms are given as arguments to
407 // the function MHFindSignificanceONOFF::FindSigmaONOFF,
408 // (Object of this class is created) to compute the
409 // Overall Excess events and significance, that will be
410 // stored in variables fOverallNexTrain and fOverallSigmaLiMaTrain
411 // and Test.
412
413
414
415 Bool_t ComputeOverallSignificance(Bool_t CombineTrainData,
416 Bool_t CombineTestData);
417
418
419 Double_t GetOverallNexTrain() {return fOverallNexTrain;}
420 Double_t GetOverallNexTest() {return fOverallNexTest;}
421
422 Double_t GetOverallSigmaLiMaTrain() {return fOverallSigmaLiMaTrain;}
423 Double_t GetOverallSigmaLiMaTest() {return fOverallSigmaLiMaTest;}
424
425 Double_t GetGammaEfficiency() {return fGammaEfficiency;}
426
427 Double_t GetAlphaSig() {return fAlphaSig;}
428 Double_t GetAlphaBkgMin () {return fAlphaBkgMin;}
429 Double_t GetAlphaBkgMax () {return fAlphaBkgMax;}
430
431 Bool_t GetSkipOptimization() {return fSkipOptimization;}
432
433 Bool_t GetUseFittedQuantities() {return fUseFittedQuantities;}
434
435 ClassDef(MFindSupercutsONOFFThetaLoop, 1)
436 // Class for optimization of the Supercuts
437};
438
439#endif
440
441
442
443
Note: See TracBrowser for help on using the repository browser.