source: branches/Mars_MC/macros/fact/drscal.C@ 17038

Last change on this file since 17038 was 16893, checked in by tbretz, 11 years ago
Fixed a typo, added the missing cast and removed also the MRawEvtData from the list to avoid confusion in MReadFitsFile when the size of the array is dtermined.
File size: 4.2 KB
Line 
1int drscal(const char *drsname="~dorner/mysequences/2012/02/28/20120228_200.drs.seq", const char *outpath = "output")
2{
3 // ======================================================
4
5 const char *map = "/scratch_nfs/FACTmap111030.txt";
6
7 // ======================================================
8
9 if (map && gSystem->AccessPathName(map, kFileExists))
10 {
11 gLog << "ERROR - Cannot access mapping file '" << map << "'" << endl;
12 return 1;
13 }
14
15 // The sequence file which defines the files for the analysis
16 MSequence drs(drsname);
17 if (!drs.IsValid())
18 {
19 gLog << "ERROR - Sequence '" << drsname << "' invalid!" << endl;
20 return 2;
21 }
22
23 // DrsRuns 1
24 // CalRuns 1
25 // DrsFiles 1 [1024], PedRuns 1 [300]
26
27 // --------------------------------------------------------------------------------
28
29 gLog.Separator("DRS Calibration");
30 gLog << "Calculate drs calibration constants of drs sequence:\n" << drs.GetFileName() << endl;
31 gLog << endl;
32
33 // ------------------------------------------------------
34
35 TString drsped = drs.GetFileName(0, MSequence::kFitsDrsRuns);
36 TString drsgain = drs.GetFileName(0, MSequence::kFitsCal);
37 TString drs1024 = drs.GetFileName(1, MSequence::kFitsDrsRuns);
38 TString drs300 = drs.GetFileName(0, MSequence::kFitsPed);
39
40 gLog << "DRS ped 1024: " << drsped << '\n';
41 gLog << "DRS gain 1024: " << drsgain << '\n';
42 gLog << "DRS ped 1024: " << drs1024 << "\n";
43 gLog << "DRS ped 300: " << drs300 << endl;
44
45 // ======================================================
46
47 MStatusDisplay *d = new MStatusDisplay;
48
49 MParList plist;
50
51 MHDrsCalibration hist;
52 plist.AddToList(&hist);
53
54 hist.SetOutputPath(outpath);
55
56 MTaskList tlist;
57 plist.AddToList(&tlist);
58
59 MEvtLoop loop;
60 loop.SetParList(&plist);
61 loop.SetDisplay(d);
62
63 // --------------------------------------------------------
64
65 gLog.Separator("Calculating cell offset");
66
67 MRawFitsRead read1(drsped);
68 read1.LoadMap(map);
69
70 MGeomApply apply;
71
72 tlist.AddToList(&read1);
73 tlist.AddToList(&apply);
74
75 MFillH fill("MHDrsCalibration");
76 fill.SetNameTab("Ped1");
77
78 tlist.AddToList(&fill);
79
80 if (!loop.Eventloop())
81 return 3;
82
83 if (!loop.GetDisplay())
84 return 4;
85
86 // --------------------------------------------------------
87
88 gLog.Separator("Calculating cell gain");
89
90 MRawFitsRead read2(drsgain);
91 read2.LoadMap(map);
92 tlist.Replace(&read2);
93 fill.SetNameTab("Gain");
94
95 if (!loop.Eventloop())
96 return 5;
97
98 if (!loop.GetDisplay())
99 return 6;
100
101 // --------------------------------------------------------
102
103 gLog.Separator("Calculating drs constants for roi=1024");
104
105 fill.SetNameTab("Ped2-1024");
106
107 // I think one HAS to use the same file than for step one
108 // this is the only way to get rid of a systematic shift.
109 MRawFitsRead read3(drs1024);
110 read3.LoadMap(map);
111 tlist.Replace(&read3);
112
113 if (!loop.Eventloop())
114 return 7;
115
116 if (!loop.GetDisplay())
117 return 8;
118
119 // --------------------------------------------------------
120
121 gLog.Separator("Calculating drs constants for roi=300");
122
123 fill.SetNameTab("Ped2-300");
124
125 if (!hist.ResetSecondaryBaseline())
126 {
127 cout << "ERROR - Reset failed." << endl;
128 return 100;
129 }
130
131 // This would just result in a wrong consistency check for the roi
132 plist.Remove((MParContainer*)plist.FindObject("MRawRunHeader"));
133 plist.Remove((MParContainer*)plist.FindObject("MRawEvtData"));
134
135 // I think one HAS to use the same file than for step one
136 // this is the only way to get rid of a systematic shift.
137 MRawFitsRead read4(drs300);
138 read4.LoadMap(map);
139 tlist.Replace(&read4);
140
141 if (!loop.Eventloop())
142 return 9;
143
144 if (!loop.GetDisplay())
145 return 10;
146
147 // --------------------------------------------------------
148
149 TString title = "-- DRS Calibration #";
150 title += drs.GetSequence();
151 title += " (";
152 title += drsname;
153 title += ") --";
154 d->SetTitle(title, kFALSE);
155
156 TString path;
157 path += Form("%s/20%6d_%03d-drs.root", outpath,
158 drs.GetSequence()/1000, drs.GetSequence()%1000);
159
160 d->SaveAs(path);
161
162 return 0;
163
164}
Note: See TracBrowser for help on using the repository browser.