source: trunk/MagicSoft/Mars/macros/threshold.C@ 4093

Last change on this file since 4093 was 2377, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 3.3 KB
Line 
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!
18! Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2003
21!
22!
23\* ======================================================================== */
24
25
26void threshold(TString filename="data/camera.root", TString outname="")
27{
28 //
29 // This macro fill the container MHMcEnergies using the task
30 // MMcThresholdCalc and shows the results.
31 //
32 MParList parlist;
33
34 MTaskList tasklist;
35 parlist.AddToList(&tasklist);
36
37 //
38 // Setup the parameter list
39 // - You need create the container MHMcEnergies.
40 // + You need to put the number of trigger conditions when
41 // you declarete the MHMcEnergies
42 // + If you don't put any dimension to MHMcEnergies it works
43 // taking only the trigger information from MMcTrig
44 //
45 const UInt_t numtrigcond = 0;
46
47 UInt_t from = numtrigcond>0 ? 1 : -numtrigcond;
48 UInt_t to = numtrigcond>0 ? numtrigcond : -numtrigcond;
49
50 Int_t dim = to-from+1;
51
52 //
53 // Create numtriggerconditions histograms of type MHMcEnergy
54 // and store the histograms in an TObjArray
55 //
56 TObjArray hists(MParList::CreateObjList("MHMcEnergy", from, to));
57 hists.SetOwner();
58
59 //
60 // Check if the list really contains the right number of histograms
61 //
62 if (hists.GetEntriesFast() != dim)
63 return;
64
65 //
66 // Add the histograms to the paramater list.
67 //
68 parlist.AddToList(&hists);
69
70 //
71 // Setup the task list
72 // - You need the read and the MMcThresholdCalc tasks
73 // - You have to fill the histograms for the Energy threshold
74 // + You need to put the number of trigger conditions when
75 // you declarete the MMcThresholdCalc
76 // + If you don't put any dimension to MMcThresholdCalc it works
77 // like one dimension MMcThresholdCalc
78 //
79 MReadTree read("Events", filename);
80 MMcThresholdCalc calc(numtrigcond);
81
82 tasklist.AddToList(&read);
83 tasklist.AddToList(&calc);
84
85 MEvtLoop evtloop;
86 evtloop.SetParList(&parlist);
87
88 //
89 // Begin the loop (if the loop wasn't succesfull
90 // don't try to draw the results
91 //
92 MProgressBar bar;
93 evtloop.SetProgressBar(&bar);
94 if (!evtloop.Eventloop())
95 return;
96
97 //
98 // Now you can display the results
99 //
100 hists.Print();
101
102 TIter Next(&hists);
103 TObject *obj;
104 while ((obj=Next()))
105 obj->DrawClone();
106
107 // Write histogram to a file in case an output filename has been supplied:
108 if (outname.IsNull())
109 return;
110
111 TFile f(outname, "recreate");
112 if (!f)
113 return;
114
115 parlist.FindObject("MHMcEnergy")->Write();
116}
Note: See TracBrowser for help on using the repository browser.