1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | ! Author(s): Abelardo Moralejo 1/2005 <mailto:moralejo@pd.infn.it>!
|
---|
18 | !
|
---|
19 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
20 | !
|
---|
21 | !
|
---|
22 | \* ======================================================================== */
|
---|
23 |
|
---|
24 | ///////////////////////////////////////////////////////////////////////////////////////
|
---|
25 | //
|
---|
26 | // Macro trainsubsample.C
|
---|
27 | //
|
---|
28 | // Reads a star file from real data, and makes a subsample of it, adding a "fake"
|
---|
29 | // MMcEvt container with MMcEvt.fPartId=14. This intended to produce, from real data,
|
---|
30 | // a "hadron training file" to be used in random forest (or other) g/h separation. The
|
---|
31 | // MMcEvt container is added so that whatever the method will consider these (real)
|
---|
32 | // showers to be all protons (before cuts, most will be, even in the case of strong
|
---|
33 | // source as Crab).
|
---|
34 | //
|
---|
35 | /////////////////////////////////////////////////////////////////////////////////////
|
---|
36 |
|
---|
37 | void trainsubsample()
|
---|
38 | {
|
---|
39 | MParList plist;
|
---|
40 | MTaskList tlist;
|
---|
41 |
|
---|
42 | plist.AddToList(&tlist);
|
---|
43 |
|
---|
44 | MReadMarsFile read("Events", "star_20040915_CrabNebulaW1.root");
|
---|
45 |
|
---|
46 | MFEventSelector evsel;
|
---|
47 | evsel.SetSelectionRatio(0.05); // Fraction of events in output
|
---|
48 |
|
---|
49 | read.DisableAutoScheme();
|
---|
50 | tlist.AddToList(&read);
|
---|
51 |
|
---|
52 | MMcEvt* mcevt = new MMcEvt;
|
---|
53 | mcevt->SetPartId(14);
|
---|
54 | plist.AddToList(mcevt);
|
---|
55 |
|
---|
56 | MWriteRootFile write("star_train_20040915_CrabNebulaW1.root", "recreate");
|
---|
57 |
|
---|
58 | write.AddContainer("MMcEvt", "Events", kFALSE);
|
---|
59 | write.AddContainer("MHillas", "Events");
|
---|
60 | write.AddContainer("MHillasExt", "Events");
|
---|
61 | write.AddContainer("MImagePar", "Events");
|
---|
62 | write.AddContainer("MNewImagePar", "Events");
|
---|
63 | write.AddContainer("MHillasSrc", "Events");
|
---|
64 | write.AddContainer("MConcentration", "Events", kFALSE);
|
---|
65 | write.AddContainer("MPointingPos", "Events", kFALSE);
|
---|
66 |
|
---|
67 |
|
---|
68 | write.AddContainer("MGeomCam", "RunHeaders", kFALSE);
|
---|
69 | write.AddContainer("MMcConfigRunHeader", "RunHeaders", kFALSE);
|
---|
70 | write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
|
---|
71 | write.AddContainer("MMcFadcHeader", "RunHeaders", kFALSE);
|
---|
72 | write.AddContainer("MMcTrigHeader", "RunHeaders", kFALSE);
|
---|
73 |
|
---|
74 | write.AddContainer("MRawRunHeader", "RunHeaders");
|
---|
75 | write.AddContainer("MSrcPosCam", "RunHeaders");
|
---|
76 | write.AddContainer("MMcRunHeader", "RunHeaders", kFALSE);
|
---|
77 |
|
---|
78 | write.SetFilter(&evsel);
|
---|
79 |
|
---|
80 | tlist.AddToList(&evsel);
|
---|
81 | tlist.AddToList(&write);
|
---|
82 |
|
---|
83 | MEvtLoop evtloop;
|
---|
84 | evtloop.SetParList(&plist);
|
---|
85 |
|
---|
86 | MProgressBar *bar = new MProgressBar;
|
---|
87 | evtloop.SetProgressBar(bar);
|
---|
88 |
|
---|
89 | //
|
---|
90 | // Execute your analysis
|
---|
91 | //
|
---|
92 | if (!evtloop.Eventloop())
|
---|
93 | return;
|
---|
94 |
|
---|
95 | tlist.PrintStatistics();
|
---|
96 |
|
---|
97 | bar->DestroyWindow();
|
---|
98 |
|
---|
99 | return;
|
---|
100 | }
|
---|