Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <fmt/core.h>
#include <fmt/ostream.h>
#include <vector>
#include "TString.h"
R__LOAD_LIBRARY(libHallC.so)
#include "hcana/HallC_Data.h"
#include "DecData.h"
//R__LOAD_LIBRARY(libScandalizer.so)
//#include "monitor/DetectorDisplay.h"
//#include "monitor/DisplayPlots.h"
//#include "monitor/MonitoringDisplay.h"
//#include "scandalizer/PostProcessors.h"
//#include "scandalizer/ScriptHelpers.h"
//
//#include "THaPostProcess.h"
//#include "monitor/ExperimentMonitor.h"
//#include "scandalizer/PostProcessors.h"
#include "THcAnalyzer.h"
#include "THaCut.h"
#include "THcGlobals.h"
#include "THcHallCSpectrometer.h"
#include "THcDetectorMap.h"
#include "THcCherenkov.h"
#include "THcDC.h"
#include "THcHodoscope.h"
#include "THcParmList.h"
#include "THaGoldenTrack.h"
#include "THcHodoEff.h"
#include "THcScalerEvtHandler.h"
#include "THcShower.h"
#include "THcReactionPoint.h"
#include "THcExtTarCor.h"
#include "THcRasteredBeam.h"
#include "THcRun.h"
#include "THcCoinTime.h"
#include "THcConfigEvtHandler.h"
#include "THcTrigDet.h"
#include "THcTrigApp.h"
#include "THcSecondaryKine.h"
#include "THcAerogel.h"
#include "THcPrimaryKine.h"
#include "THaReactionPoint.h"
void elastic_coin_replay(Int_t RunNumber = 0, Int_t MaxEvent = -1) {
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
// Get RunNumber and MaxEvent if not provided.
if( RunNumber<=0 ) {
std::exit(-1);
}
// Create file name patterns.
const char* RunFileNamePattern = "coin_all_%05d.dat";
vector<TString> pathList;
pathList.push_back(".");
pathList.push_back("./raw");
pathList.push_back("./raw/../raw.copiedtotape");
pathList.push_back("./cache");
//const char* RunFileNamePattern = "raw/coin_all_%05d.dat";
const char* ROOTFileNamePattern = "ROOTfiles/coin_replay_production_%d_%d.root";
// Load global parameters
gHcParms->Define("gen_run_number", "Run Number", RunNumber);
gHcParms->AddString("g_ctp_database_filename", "DBASE/COIN/standard.database");
gHcParms->Load(gHcParms->GetString("g_ctp_database_filename"), RunNumber);
gHcParms->Load(gHcParms->GetString("g_ctp_parm_filename"));
gHcParms->Load(gHcParms->GetString("g_ctp_kinematics_filename"), RunNumber);
// Load params for COIN trigger configuration
gHcParms->Load("PARAM/TRIG/tcoin.param");
// Load fadc debug parameters
gHcParms->Load("PARAM/HMS/GEN/h_fadc_debug.param");
gHcParms->Load("PARAM/SHMS/GEN/p_fadc_debug.param");
// const char* CurrentFileNamePattern = "low_curr_bcm/bcmcurrent_%d.param";
// gHcParms->Load(Form(CurrentFileNamePattern, RunNumber));
// Load the Hall C detector map
gHcDetectorMap = new THcDetectorMap();
gHcDetectorMap->Load("MAPS/COIN/DETEC/coin.map");
// Dec data
gHaApps->Add(new Podd::DecData("D","Decoder raw data"));
//=:=:=:=
// SHMS
//=:=:=:=
// Set up the equipment to be analyzed.
THcHallCSpectrometer* SHMS = new THcHallCSpectrometer("P", "SHMS");
SHMS->SetEvtType(1);
SHMS->AddEvtType(4);
SHMS->AddEvtType(5);
SHMS->AddEvtType(6);
SHMS->AddEvtType(7);
gHaApps->Add(SHMS);
// Add Noble Gas Cherenkov to SHMS apparatus
THcCherenkov* pngcer = new THcCherenkov("ngcer", "Noble Gas Cherenkov");
SHMS->AddDetector(pngcer);
// Add drift chambers to SHMS apparatus
THcDC* pdc = new THcDC("dc", "Drift Chambers");
SHMS->AddDetector(pdc);
// Add hodoscope to SHMS apparatus
THcHodoscope* phod = new THcHodoscope("hod", "Hodoscope");
SHMS->AddDetector(phod);
// Add Heavy Gas Cherenkov to SHMS apparatus
THcCherenkov* phgcer = new THcCherenkov("hgcer", "Heavy Gas Cherenkov");
SHMS->AddDetector(phgcer);
// Add Aerogel Cherenkov to SHMS apparatus
THcAerogel* paero = new THcAerogel("aero", "Aerogel");
SHMS->AddDetector(paero);
// Add calorimeter to SHMS apparatus
THcShower* pcal = new THcShower("cal", "Calorimeter");
SHMS->AddDetector(pcal);
// THcBCMCurrent* hbc = new THcBCMCurrent("H.bcm", "BCM current check");
// gHaPhysics->Add(hbc);
// Add rastered beam apparatus
THaApparatus* pbeam = new THcRasteredBeam("P.rb", "Rastered Beamline");
gHaApps->Add(pbeam);
// Add physics modules
// Calculate reaction point
THcReactionPoint* prp = new THcReactionPoint("P.react", "SHMS reaction point", "P", "P.rb");
gHaPhysics->Add(prp);
// Calculate extended target corrections
THcExtTarCor* pext = new THcExtTarCor("P.extcor", "HMS extended target corrections", "P", "P.react");
gHaPhysics->Add(pext);
// Calculate golden track quantites
THaGoldenTrack* pgtr = new THaGoldenTrack("P.gtr", "SHMS Golden Track", "P");
gHaPhysics->Add(pgtr);
// Calculate the hodoscope efficiencies
THcHodoEff* peff = new THcHodoEff("phodeff", "SHMS hodo efficiency", "P.hod");
gHaPhysics->Add(peff);
// Add event handler for scaler events
THcScalerEvtHandler* pscaler = new THcScalerEvtHandler("P", "Hall C scaler event type 1");
pscaler->AddEvtType(1);
pscaler->AddEvtType(4);
pscaler->AddEvtType(5);
pscaler->AddEvtType(6);
pscaler->AddEvtType(7);
pscaler->AddEvtType(129);
pscaler->SetDelayedType(129);
pscaler->SetUseFirstEvent(kTRUE);
gHaEvtHandlers->Add(pscaler);
//=:=:=
// HMS
//=:=:=
// Set up the equipment to be analyzed.
THcHallCSpectrometer* HMS = new THcHallCSpectrometer("H", "HMS");
HMS->SetEvtType(2);
HMS->AddEvtType(4);
HMS->AddEvtType(5);
HMS->AddEvtType(6);
HMS->AddEvtType(7);
gHaApps->Add(HMS);
// Add drift chambers to HMS apparatus
THcDC* hdc = new THcDC("dc", "Drift Chambers");
HMS->AddDetector(hdc);
// Add hodoscope to HMS apparatus
THcHodoscope* hhod = new THcHodoscope("hod", "Hodoscope");
HMS->AddDetector(hhod);
// Add Cherenkov to HMS apparatus
THcCherenkov* hcer = new THcCherenkov("cer", "Heavy Gas Cherenkov");
HMS->AddDetector(hcer);
// Add Aerogel Cherenkov to HMS apparatus
// THcAerogel* haero = new THcAerogel("aero", "Aerogel");
// HMS->AddDetector(haero);
// Add calorimeter to HMS apparatus
THcShower* hcal = new THcShower("cal", "Calorimeter");
HMS->AddDetector(hcal);
// Add rastered beam apparatus
THaApparatus* hbeam = new THcRasteredBeam("H.rb", "Rastered Beamline");
gHaApps->Add(hbeam);
// Add physics modules
// Calculate reaction point
THcReactionPoint* hrp = new THcReactionPoint("H.react", "HMS reaction point", "H", "H.rb");
gHaPhysics->Add(hrp);
// Calculate extended target corrections
THcExtTarCor* hext = new THcExtTarCor("H.extcor", "HMS extended target corrections", "H", "H.react");
gHaPhysics->Add(hext);
// Calculate golden track quantities
THaGoldenTrack* hgtr = new THaGoldenTrack("H.gtr", "HMS Golden Track", "H");
gHaPhysics->Add(hgtr);
// Calculate the hodoscope efficiencies
THcHodoEff* heff = new THcHodoEff("hhodeff", "HMS hodo efficiency", "H.hod");
gHaPhysics->Add(heff);
// Add event handler for scaler events
THcScalerEvtHandler *hscaler = new THcScalerEvtHandler("H", "Hall C scaler event type 4");
hscaler->AddEvtType(2);
hscaler->AddEvtType(4);
hscaler->AddEvtType(5);
hscaler->AddEvtType(6);
hscaler->AddEvtType(7);
hscaler->AddEvtType(129);
hscaler->SetDelayedType(129);
hscaler->SetUseFirstEvent(kTRUE);
gHaEvtHandlers->Add(hscaler);
//=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
// Kinematics Modules
//=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
// Add Physics Module to calculate primary (scattered electrons) beam kinematics
THcPrimaryKine* hkin_primary = new THcPrimaryKine("H.kin.primary", "HMS Single Arm Kinematics", "H", "H.rb");
gHaPhysics->Add(hkin_primary);
// Add Physics Module to calculate secondary (scattered hadrons) beam kinematics
THcSecondaryKine* pkin_secondary = new THcSecondaryKine("P.kin.secondary", "SHMS Single Arm Kinematics", "P", "H.kin.primary");
gHaPhysics->Add(pkin_secondary);
//=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
// Global Objects & Event Handlers
//=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
// Add trigger apparatus
THaApparatus* TRG = new THcTrigApp("T", "TRG");
gHaApps->Add(TRG);
// Add trigger detector to trigger apparatus
THcTrigDet* coin = new THcTrigDet("coin", "Coincidence Trigger Information");
// Suppress missing reference time warnings for these event types
coin->SetEvtType(1);
coin->AddEvtType(2);
TRG->AddDetector(coin);
//Add coin physics module THcCoinTime::THcCoinTime (const char *name, const char* description, const char* hadArmName,
// const char* elecArmName, const char* coinname) :
THcCoinTime* coinTime = new THcCoinTime("CTime", "Coincidende Time Determination", "P", "H", "T.coin");
gHaPhysics->Add(coinTime);
// Add event handler for prestart event 125.
THcConfigEvtHandler* ev125 = new THcConfigEvtHandler("HC", "Config Event type 125");
gHaEvtHandlers->Add(ev125);
// Add event handler for EPICS events
THaEpicsEvtHandler* hcepics = new THaEpicsEvtHandler("epics", "HC EPICS event type 180");
gHaEvtHandlers->Add(hcepics);
// Set up the analyzer - we use the standard one,
// but this could be an experiment-specific one as well.
// The Analyzer controls the reading of the data, executes
// tests/cuts, loops over Acpparatus's and PhysicsModules,
// and executes the output routines.
THcAnalyzer* analyzer = new THcAnalyzer;
// A simple event class to be output to the resulting tree.
// Creating your own descendant of THaEvent is one way of
// defining and controlling the output.
THaEvent* event = new THaEvent;
// Define the run(s) that we want to analyze.
// We just set up one, but this could be many.
THcRun* run = new THcRun( pathList, Form(RunFileNamePattern, RunNumber) );
// Set to read in Hall C run database parameters
run->SetRunParamClass("THcRunParameters");
// Eventually need to learn to skip over, or properly analyze the pedestal events
run->SetEventRange(1, MaxEvent); // Physics Event number, does not include scaler or control events.
run->SetNscan(1);
run->SetDataRequired(0x7);
run->Print();
// Define the analysis parameters
TString ROOTFileName = Form(ROOTFileNamePattern, RunNumber, MaxEvent);
analyzer->SetCountMode(2); // 0 = counter is # of physics triggers
// 1 = counter is # of all decode reads
// 2 = counter is event number
analyzer->SetEvent(event);
// Set EPICS event type
analyzer->SetEpicsEvtType(180);
// Define crate map
analyzer->SetCrateMapFileName("MAPS/db_cratemap.dat");
// Define output ROOT file
analyzer->SetOutFile(ROOTFileName.Data());
// Define DEF-file+
analyzer->SetOdefFile("DEF-files/COIN/PRODUCTION/coin_production_hElec_pProt.def");
// Define cuts file
analyzer->SetCutFile("DEF-files/COIN/PRODUCTION/CUTS/coin_production_cuts.def"); // optional
// File to record accounting information for cuts
analyzer->SetSummaryFile(Form("REPORT_OUTPUT/COIN/PRODUCTION/summary_production_%d_%d.report", RunNumber, MaxEvent)); // optional
// Start the actual analysis.
analyzer->Process(run);
// Create report file from template
analyzer->PrintReport("TEMPLATES/COIN/PRODUCTION/coin_production.template",
Form("REPORT_OUTPUT/COIN/PRODUCTION/replay_coin_production_%d_%d.report", RunNumber, MaxEvent)); // optional
}