source: trunk/Mars/fact/analysis/merpp_file.C@ 18274

Last change on this file since 18274 was 18077, checked in by Daniela Dorner, 10 years ago
version of merpp.C to process one file (used for QLA)
File size: 2.4 KB
Line 
1#include "MLogManip.h"
2
3void merpp(TString &froot, const char *id, const char *faux)
4{
5 gLog.Separator(froot+" - "+TString(id));
6
7 TFile file(froot);
8 if (file.IsZombie())
9 {
10 gLog << err << "merpp: Invalid file '" << froot << "'" << endl;
11 return;
12 }
13
14 MRawRunHeader *h = NULL;
15 TTree *tree = file.Get("RunHeaders");
16 if (!tree)
17 {
18 gLog << err << "merpp: Tree 'RunHeaders' not found... skipped." << endl;
19 return;
20 }
21
22 if (tree->GetEntries()!=1)
23 {
24 gLog << err << "merpp: Number of RunHeaders do not match 1... skipped." << endl;
25 return;
26 }
27
28 tree->SetBranchAddress("MRawRunHeader.", &h);
29 tree->GetEntry(0);
30
31 if (file.Get(id))
32 {
33 gLog << warn << "WARNING - Tree '" << id << "' already existing... skipped." << endl;
34 return;
35 }
36
37 file.Close();
38
39 UInt_t night = h->GetRunNumber();
40
41 TString ffits = Form("/fact/aux/%4d/%02d/%02d/%6d.%s.fits",
42 night/10000, (night/100)%100, night%100, night, faux);
43
44 TString report = Form("MReport%s", id);
45 TString time = Form("MTime%s", id);
46
47 gLog << all;
48 gLog << " --- Fits file: " << ffits << endl;
49 gLog << " --- Root file: " << froot << endl;
50 gLog << " --- Tree: " << id << " (" << faux << ")" << endl;
51
52 MReportFitsRead read(ffits);
53 read.SetReportName(report);
54 read.SetTimeStart(h->GetRunStart());
55 read.SetTimeStop(h->GetRunEnd());
56
57 // FIXME: Write also last event BEFORE start of run
58
59 MWriteRootFile write(froot, "UPDATE");
60 write.AddContainer(report, id);
61 write.AddContainer(time, id);
62
63 MParList plist;
64 MTaskList tlist;
65 plist.AddToList(&tlist);
66
67 tlist.AddToList(&read);
68 tlist.AddToList(&write);
69
70 MEvtLoop loop;
71 loop.SetParList(&plist);
72
73 if (!loop.Eventloop())
74 return;
75}
76
77int merpp_file(const char *datafile)
78{
79 // ------------------------------------------------------
80
81 gLog.Separator("Merpp");
82 gLog << all;
83 gLog << "Merge slow control data of ";
84 gLog << datafile << endl;
85 gLog << endl;
86
87 merpp(datafile, "Weather", "MAGIC_WEATHER_DATA");
88 merpp(datafile, "Drive", "DRIVE_CONTROL_TRACKING_POSITION");
89 merpp(datafile, "Rates", "FTM_CONTROL_TRIGGER_RATES");
90 merpp(datafile, "Temperatures", "FSC_CONTROL_TEMPERATURE");
91 merpp(datafile, "Humidity", "FSC_CONTROL_HUMIDITY");
92
93 return 0;
94}
Note: See TracBrowser for help on using the repository browser.