Skip to content
Snippets Groups Projects
Commit 339d3535 authored by Stephen A. Wood's avatar Stephen A. Wood
Browse files

Add code and example of interpreting ENGINE style database files which

use the run number to determine which parameter and map files to use.
parent 5e2bf202
No related branches found
No related tags found
No related merge requests found
# ENGINE style parameter vs. run number database
50017
g_ctp_parm_filename="PARAM/general.param"
g_decode_map_filename="jan03.map"
47000-48000
g_ctp_parm_filename="PARAM/general.param"
g_decode_map_filename="jan03.map"
{
// Load the Hall C style detector map
gHcDetectorMap=new THcDetectorMap();
// gHcDetectorMap->Load("july04.map");
gHcDetectorMap->Load("jan03.map");
//gHcDetectorMap->Load("MAPS/jan03_dg_update.map");
gHcParms->Load("PARAM/general.param");
//
// Steering script to test hodoscope decoding
//
Int_t RunNumber=50017;
char* RunFileNamePattern="daq04_%d.log.0";
gHcParms->Define("gen_run_number", "Run Number", RunNumber);
gHcParms->AddString("g_ctp_database_filename", "DBASE/test.database");
gHcParms->Load(gHcParms->GetString("g_ctp_database_filename"), RunNumber);
// g_ctp_parm_filename and g_decode_map_filename should now be defined
gHcParms->Load(gHcParms->GetString("g_ctp_parm_filename"));
// Load the Hall C style detector map
gHcDetectorMap=new THcDetectorMap();
gHcDetectorMap->Load(gHcParms->GetString("g_decode_map_filename"));
// Set up the equipment to be analyzed.
THaApparatus* HMS = new THcHallCSpectrometer("H","HMS");
......@@ -37,8 +47,12 @@ gHcDetectorMap->Load("jan03.map");
// Define the run(s) that we want to analyze.
// We just set up one, but this could be many.
THaRun* run = new THaRun( "daq04_50017.log.0" );
//THaRun* run = new THaRun( "daq03_47851.log.0" );
char RunFileName[100];
sprintf(RunFileName,RunFileNamePattern,RunNumber);
THaRun* run = new THaRun(RunFileName);
// Eventually need to learn to skip over, or properly analyze
// the pedestal events
run->SetEventRange(1054,100000);
// Define the analysis parameters
......
......@@ -37,7 +37,7 @@ inline static bool IsComment( const string& s, string::size_type pos )
(s[pos] == '#' || s[pos] == ';' || s.substr(pos,2) == "//") );
}
void THcParmList::Load( const char* fname )
void THcParmList::Load( const char* fname, Int_t RunNumber )
{
static const char* const here = "THcParmList::LoadFromFile";
......@@ -60,9 +60,17 @@ void THcParmList::Load( const char* fname )
string line;
Int_t nlines_read = 0, nparameters_read = 0;
char varname[100];
Int_t InRunRange;
varname[0] = '\0';
if(RunNumber > 0) {
InRunRange = 0; // Wait until run number range matching RunNumber is found
cout << "Reading Parameters for run " << RunNumber << endl;
} else {
InRunRange = 1; // Interpret all lines
}
while(nfiles) {
string current_comment("");
string existing_comment("");
......@@ -98,7 +106,6 @@ void THcParmList::Load( const char* fname )
continue;
}
// Blank line or comment?
if( line.empty()
|| (start = line.find_first_not_of( whtspc )) == string::npos
......@@ -170,6 +177,29 @@ void THcParmList::Load( const char* fname )
// Need to do something to bug out if line is empty
// If in Engine database mode, check if line is a number range AAAA-BBBB
if(RunNumber>0) {
if(line.find_first_not_of("0123456789-")==string::npos) { // Interpret as runnum range
if( (pos=line.find_first_of("-")) != string::npos) {
Int_t RangeStart=atoi(line.substr(0,pos).c_str());
Int_t RangeEnd=atoi(line.substr(pos+1,string::npos).c_str());
if(RunNumber >= RangeStart && RunNumber <= RangeEnd) {
InRunRange = 1;
} else {
InRunRange = 0;
}
} else { // A single number. Run
if(atoi(line.c_str()) == RunNumber) {
InRunRange = 1;
} else {
InRunRange = 0;
}
}
}
}
if(!InRunRange) continue;
// Interpret left of = as var name
Int_t valuestartpos=0; // Stays zero if no = found
Int_t existinglength=0;
......
......@@ -19,7 +19,7 @@ public:
THcParmList();
virtual ~THcParmList() { Clear(); delete TextList; }
virtual void Load( const char *fname);
virtual void Load( const char *fname, Int_t RunNumber=0);
virtual void PrintFull(Option_t *opt="") const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment