source: trunk/Mars/fact/analysis/merpp.C@ 19819

Last change on this file since 19819 was 19266, checked in by tbretz, 6 years ago
Fixed some minor issues with the cling based interpreter - this should not have any effect at runtime maybe except stability
File size: 3.3 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 = (TTree*)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(const char *seqfile="sequences/20111205_013.seq", const char *path = "output")
78{
79 // The sequence file which defines the files for the analysis
80 MSequence seq(seqfile);
81 if (!seq.IsValid())
82 {
83 gLog << err << "ERROR - Sequence invalid!" << endl;
84 return 1;
85 }
86
87 // ------------------------------------------------------
88
89 gLog.Separator("Merpp");
90 gLog << all;
91 gLog << "Merge slow control data of sequence ";
92 gLog << seq.GetFileName() << endl;
93 gLog << endl;
94 gLog << "Path: " << path << endl;
95
96 MDirIter iter;
97 if (seq.GetRuns(iter, MSequence::kFactImg, path)<=0)
98 {
99 gLog << err << "ERROR - Sequence valid but without files." << endl;
100 return 2;
101 }
102
103 iter.Print();
104
105 while (1)
106 {
107 TString fname = iter.Next();
108 if (fname.IsNull())
109 break;
110
111 merpp(fname, "Weather", "MAGIC_WEATHER_DATA");
112 merpp(fname, "Drive", "DRIVE_CONTROL_TRACKING_POSITION");
113 merpp(fname, "Rates", "FTM_CONTROL_TRIGGER_RATES");
114 merpp(fname, "Temperatures", "FSC_CONTROL_TEMPERATURE");
115 merpp(fname, "Humidity", "FSC_CONTROL_HUMIDITY");
116 }
117
118 return 0;
119}
120
121int merpp(const ULong64_t seqnum, const char *path="output")
122{
123 UInt_t night = seqnum/1000;
124 UInt_t num = seqnum%1000;
125
126 TString file = Form("/scratch/fact/sequences/%04d/%02d/%02d/%06d_%03d.seq",
127 night/10000, (night/100)%100, night%100, night, num);
128
129 return merpp(file.Data(), path);
130}
Note: See TracBrowser for help on using the repository browser.