source: branches/Mars_MC/fact/analysis/merpp.C@ 17877

Last change on this file since 17877 was 15232, checked in by Daniela Dorner, 12 years ago
updated name
File size: 2.9 KB
Line 
1void merpp(TString &froot, const char *id, const char *faux)
2{
3 gLog.Separator(froot+" - "+TString(id));
4
5 TFile file(froot);
6 if (file.IsZombie())
7 {
8 gLog << "merpp: Invalid file '" << froot << "'" << endl;
9 return;
10 }
11
12 MRawRunHeader *h = NULL;
13 TTree *tree = file.Get("RunHeaders");
14 if (!tree)
15 {
16 gLog << "merpp: Tree 'RunHeaders' not found... skipped." << endl;
17 return;
18 }
19
20 if (tree->GetEntries()!=1)
21 {
22 gLog << "merpp: Number of RunHeaders do not match 1... skipped." << endl;
23 return;
24 }
25
26 tree->SetBranchAddress("MRawRunHeader.", &h);
27 tree->GetEntry(0);
28
29 if (file.Get(id))
30 {
31 gLog << "WARNING - Tree '" << id << "' already existing... skipped." << endl;
32 return;
33 }
34
35 file.Close();
36
37 UInt_t night = h->GetRunNumber();
38
39 TString ffits = Form("/fact/aux/%4d/%02d/%02d/%6d.%s.fits",
40 night/10000, (night/100)%100, night%100, night, faux);
41
42 TString report = Form("MReport%s", id);
43 TString time = Form("MTime%s", id);
44
45 gLog << " --- Fits file: " << ffits << endl;
46 gLog << " --- Root file: " << froot << endl;
47 gLog << " --- Tree: " << id << " (" << faux << ")" << endl;
48
49 MReportFitsRead read(ffits);
50 read.SetReportName(report);
51 read.SetTimeStart(h->GetRunStart());
52 read.SetTimeStop(h->GetRunEnd());
53
54 // FIXME: Write also last event BEFORE start of run
55
56 MWriteRootFile write(froot, "UPDATE");
57 write.AddContainer(report, id);
58 write.AddContainer(time, id);
59
60 MParList plist;
61 MTaskList tlist;
62 plist.AddToList(&tlist);
63
64 tlist.AddToList(&read);
65 tlist.AddToList(&write);
66
67 MEvtLoop loop;
68 loop.SetParList(&plist);
69
70 if (!loop.Eventloop())
71 return;
72}
73
74int merpp(const char *seqfile="sequences/20111205_013.seq", const char *path = "output")
75{
76 // The sequence file which defines the files for the analysis
77 MSequence seq(seqfile);
78 if (!seq.IsValid())
79 {
80 gLog << "ERROR - Sequence invalid!" << endl;
81 return 1;
82 }
83
84 // ------------------------------------------------------
85
86 gLog.Separator("Merpp");
87 gLog << "Merge slow control data of sequence ";
88 gLog << seq.GetFileName() << endl;
89 gLog << endl;
90 gLog << "Path: " << path << endl;
91
92 MDirIter iter;
93 if (seq.GetRuns(iter, MSequence::kFactImg, path)<=0)
94 {
95 gLog << "ERROR - Sequence valid but without files." << endl;
96 return 2;
97 }
98
99 iter.Print();
100
101 while (1)
102 {
103 TString fname = iter.Next();
104 if (fname.IsNull())
105 break;
106
107 merpp(fname, "Weather", "MAGIC_WEATHER_DATA");
108 merpp(fname, "Drive", "DRIVE_CONTROL_TRACKING_POSITION");
109 merpp(fname, "Rates", "FTM_CONTROL_TRIGGER_RATES");
110 merpp(fname, "Temperatures", "FSC_CONTROL_TEMPERATURE");
111 merpp(fname, "Humidity", "FSC_CONTROL_HUMIDITY");
112 }
113
114 return 0;
115}
Note: See TracBrowser for help on using the repository browser.