35 map<string, gBank> banks;
44 abank.
load_variable(
"evn_type", 4,
"Ni",
"Event Type. 1 for physics events, 10 for scaler. Negative sign for MC.");
46 abank.
load_variable(
"var1", 6,
"Nd",
"User defined. In LUND this was: Target Polarization");
47 abank.
load_variable(
"var2", 7,
"Nd",
"User defined. In LUND this was: Number of nucleons in the target");
48 abank.
load_variable(
"var3", 8,
"Nd",
"User defined. In LUND this was: Number of protons in the target");
49 abank.
load_variable(
"var4", 9,
"Nd",
"User defined. In LUND this was: Bjorken x");
50 abank.
load_variable(
"var5", 10,
"Nd",
"User defined. In LUND this was: Fraction of energy loss");
51 abank.
load_variable(
"var6", 11,
"Nd",
"User defined. In LUND this was: W square");
52 abank.
load_variable(
"var7", 12,
"Nd",
"User defined. In LUND this was: Q square");
53 abank.
load_variable(
"var8", 13,
"Nd",
"User defined. In LUND this was: Energy loss");
55 banks[
"header"] = abank;
60 abank.
load_variable(
"px", 2,
"Nd",
"x component of momentum");
61 abank.
load_variable(
"py", 3,
"Nd",
"y component of momentum");
62 abank.
load_variable(
"pz", 4,
"Nd",
"z component of momentum");
67 banks[
"generated"] = abank;
73 abank.
load_variable(
"stat", 2,
"Ni",
"Number of Hits in the detector");
74 abank.
load_variable(
"etot", 3,
"Nd",
"Total Energy Deposited");
75 abank.
load_variable(
"t", 4,
"Nd",
"Fastest Time on Detector");
76 abank.
load_variable(
"nphe", 5,
"Ni",
"Number of Photoelectrons");
78 banks[
"psummary"] = abank;
85 abank =
gBank(
RAWINT_ID,
"raws",
"Geant4 true information integrated over the hit");
86 abank.
load_variable(
"pid", 1,
"Ri",
"ID of the first particle entering the sensitive volume");
87 abank.
load_variable(
"mpid", 2,
"Ri",
"ID of the mother of the first particle entering the sensitive volume");
88 abank.
load_variable(
"tid", 3,
"Ri",
"Track ID of the first particle entering the sensitive volume");
89 abank.
load_variable(
"mtid", 4,
"Ri",
"Track ID of the mother of the first particle entering the sensitive volume");
90 abank.
load_variable(
"otid", 5,
"Ri",
"Track ID of the original track that generated the first particle entering the sensitive volume");
91 abank.
load_variable(
"trackE", 6,
"Rd",
"Energy of the track");
92 abank.
load_variable(
"totEdep", 7,
"Rd",
"Total Energy Deposited (in MeV");
93 abank.
load_variable(
"avg_x", 8,
"Rd",
"Average X position in the global reference system (in mm)");
94 abank.
load_variable(
"avg_y", 9,
"Rd",
"Average Y position in the global reference system (in mm)");
95 abank.
load_variable(
"avg_z", 10,
"Rd",
"Average Z position in the global reference system (in mm)");
96 abank.
load_variable(
"avg_lx", 11,
"Rd",
"Average X position in the local reference system (in mm)");
97 abank.
load_variable(
"avg_ly", 12,
"Rd",
"Average Y position in the local reference system (in mm)");
98 abank.
load_variable(
"avg_lz", 13,
"Rd",
"Average Z position in the local reference system (in mm)");
99 abank.
load_variable(
"px", 14,
"Rd",
"x component of momentum of the particle entering the sensitive volume");
100 abank.
load_variable(
"py", 15,
"Rd",
"y component of momentum of the particle entering the sensitive volume");
101 abank.
load_variable(
"pz", 16,
"Rd",
"z component of momentum of the particle entering the sensitive volume");
102 abank.
load_variable(
"vx", 17,
"Rd",
"x component of point of origin of the particle entering the sensitive volume");
103 abank.
load_variable(
"vy", 18,
"Rd",
"y component of point of origin of the particle entering the sensitive volume");
104 abank.
load_variable(
"vz", 19,
"Rd",
"z component of point of origin of the particle entering the sensitive volume");
105 abank.
load_variable(
"mvx", 20,
"Rd",
"x component of point of origin the mother of the particle entering the sensitive volume");
106 abank.
load_variable(
"mvy", 21,
"Rd",
"y component of point of origin of the mother of the particle entering the sensitive volume");
107 abank.
load_variable(
"mvz", 22,
"Rd",
"z component of point of origin of the mother of the particle entering the sensitive volume");
109 abank.
load_variable(
"nsteps", 24,
"Ri",
"Number of geant4 steps");
110 abank.
load_variable(
"procID", 25,
"Ri",
"Process that created the particle. It's an integer described at gemc.jlab.org");
113 banks[
"raws"] = abank;
118 abank =
gBank(
RAWSTEP_ID,
"allraws",
"Geant4 true information step by step");
119 abank.
load_variable(
"pid", 1,
"Si",
"ID of the particle in the sensitive volume");
120 abank.
load_variable(
"mpid", 2,
"Si",
"ID of the mother in the sensitive volume");
121 abank.
load_variable(
"tid", 3,
"Si",
"Track ID of the particle in the sensitive volume");
122 abank.
load_variable(
"mtid", 4,
"Si",
"Track ID of the mother of the particle in the sensitive volume");
123 abank.
load_variable(
"otid", 5,
"Si",
"Track ID of the original track that generated the particle in the sensitive volume");
124 abank.
load_variable(
"trackE", 6,
"Sd",
"Energy of the track");
126 abank.
load_variable(
"x", 8,
"Sd",
"X position in global reference system");
127 abank.
load_variable(
"y", 9,
"Sd",
"Y position in global reference system");
128 abank.
load_variable(
"z", 10,
"Sd",
"Z position in global reference system");
129 abank.
load_variable(
"lx", 11,
"Sd",
"X position in local reference system");
130 abank.
load_variable(
"ly", 12,
"Sd",
"Y position in local reference system");
131 abank.
load_variable(
"lz", 13,
"Sd",
"Z position in local reference system");
132 abank.
load_variable(
"px", 14,
"Sd",
"x component of momentum of the particle in the sensitive volume");
133 abank.
load_variable(
"py", 15,
"Sd",
"y component of momentum of the particle in the sensitive volume");
134 abank.
load_variable(
"pz", 16,
"Sd",
"z component of momentum of the particle in the sensitive volume");
135 abank.
load_variable(
"vx", 17,
"Sd",
"x component of primary vertex of the particle in the sensitive volume");
136 abank.
load_variable(
"vy", 18,
"Sd",
"y component of primary vertex of the particle in the sensitive volume");
137 abank.
load_variable(
"vz", 19,
"Sd",
"z component of primary vertex of the particle in the sensitive volume");
138 abank.
load_variable(
"mvx", 20,
"Sd",
"x component of primary vertex of the mother of the particle in the sensitive volume");
139 abank.
load_variable(
"mvy", 21,
"Sd",
"y component of primary vertex of the mother of the particle in the sensitive volume");
140 abank.
load_variable(
"mvz", 22,
"Sd",
"z component of primary vertex of the mother of the particle in the sensitive volume");
145 banks[
"allraws"] = abank;
151 abank =
gBank(
FLUX_BANK_TAG,
"flux",
"Geant4 flux digitized information integrated over the hit");
155 banks[
"flux"] = abank;
160 for(map<string, string>::iterator sit = allSystems.begin(); sit != allSystems.end(); sit++)
162 string systemName = sit->first;
163 string systemFactory = sit->second;
165 if(systemName ==
"flux")
continue;
168 if(systemFactory ==
"TEXT")
171 string fname = systemName +
"__bank.txt";
172 ifstream IN(fname.c_str());
176 if(getenv(
"GEMC_DATA_DIR") != NULL)
178 fname = (string) getenv(
"GEMC_DATA_DIR") +
"/" + fname;
179 IN.open(fname.c_str());
187 cout <<
" > Loading bank TEXT definitions for <" << systemName <<
">." << endl;
191 vector<string> banksForSystem;
197 if(!dbline.size())
continue;
202 if(gt.
data[1] ==
"bankid")
203 banksForSystem.push_back(gt.
data[0]);
210 for(
unsigned b=0; b<banksForSystem.size(); b++)
217 if(!dbline.size())
continue;
223 if(gt.
data[0] == banksForSystem[b])
225 string bname = gt.
data[0];
226 string vname = gt.
data[1];
227 string desc = gt.
data[2];
229 string type = gt.
data[4];
231 if(vname ==
"bankid")
233 abank =
gBank(num, bname, desc);
243 banks[banksForSystem[b]] = abank;
253 cout <<
" !!! Error: Failed to open system bank file " << fname
254 <<
". Maybe the filename doesn't exist? Exiting." << endl;
258 if(systemFactory ==
"MYSQL")
261 QSqlDatabase db =
openGdb(gemcOpt);
262 string tname = systemName +
"__bank";
264 string variation =
"original";
266 if(verbosity > 1) cout <<
" > Loading MYSQL definitions for <" << systemName <<
">." << endl;
269 string dbexecute =
"select bankname, name from " + tname ;
270 dbexecute +=
" where variation ='" + variation +
"'";
273 if(!q.exec(dbexecute.c_str()))
275 cout <<
" !!! Failed to execute MYSQL query " << dbexecute <<
". This is a fatal error. Exiting." << endl;
276 qDebug() << q.lastError();
283 cout <<
" ** WARNING: system \"" << systemName <<
"\" not found in MYSQL database " 284 <<
" for variation " << variation << endl << endl;
287 vector<string> banksForSystem;
301 for(
unsigned b=0; b<banksForSystem.size(); b++)
304 dbexecute =
"select bankname, name, num, type, description from " + tname ;
305 dbexecute +=
" where variation ='" + variation +
"'";
306 dbexecute +=
" and bankname = '" + banksForSystem[b] +
"'";
307 q.exec(dbexecute.c_str());
318 if(vname ==
"bankid")
320 abank =
gBank(num, bname, desc);
328 banks[banksForSystem[b]] = abank;
340 for(map<string, gBank>::iterator it = banks.begin(); it != banks.end(); it++)
360 for(
unsigned int i=0; i<
name.size(); i++)
362 if(
name[i].find(bank) == 0)
return id[i];
371 for(
unsigned int i=0; i<
name.size(); i++)
372 if(
name[i] == var &&
type[i].length() == 2)
374 if(
type[i].find(
"i") == 1)
return "i";
375 if(
type[i].find(
"d") == 1)
return "d";
383 for(
unsigned int i=0; i<
name.size(); i++)
385 if(
name[i] == var &&
type[i].length() == 2)
404 for(
unsigned i=0; i<
id.size(); i++)
406 if(
id[i] < minId) minId =
id[i];
407 if(
id[i] > maxId) maxId =
id[i];
411 for(
int i=minId; i<=maxId; i++)
413 for(
unsigned k=0; k<
id.size(); k++)
426 if(banksMap->find(name) == banksMap->end())
428 cout <<
" !!! Error: >" << name <<
"< bank definitions not found. Exiting." << endl;
432 return (*banksMap)[
name];
440 gBank thisBank, dgtBank;
441 if(banksMap->find(name) == banksMap->end())
443 cout <<
" !!! Error: >" << name <<
"< bank definitions not found. Exiting." << endl;
450 thisBank = (*banksMap)[
name];
453 for(
unsigned int i=0; i<thisBank.
name.size(); i++)
471 for(
unsigned i = 0; i<bank.
name.size(); i++)
473 cout <<
" > Variable : " << bank.
name[i] <<
"\t id: " << bank.
id[i] <<
"\t type: " << bank.
type[i] <<
" : " << bank.
description[i] << endl;
void load_variable(string, int, string, string)
vector< string > get_strings(string input)
returns a vector of strings from a stringstream, space is delimiter
string getVarType(string)
void closeGdb(QSqlDatabase db)
QSqlDatabase openGdb(goptions gemcOpt)
gBank getDgtBankFromMap(string name, map< string, gBank > *banksMap)
int idtag
unique id for the bank
int getVarBankType(string)
friend ostream & operator<<(ostream &stream, gBank)
Overloaded "<<" for the class 'bank'.
#define GENERATED_PARTICLES_BANK_TAG
string qv_tostring(QVariant input)
vector< string > type
Variable type.
double get_number(string v, int warn_no_unit)
Returns number with dimension from string, i.e. 100*cm.
gBank getBankFromMap(string name, map< string, gBank > *banksMap)
map< string, aopt > optMap
Options map.
string bankName
name of the bank, it's also key in the map but we store it here as well
map< int, string > orderedNames
#define GENERATED_SUMMARY_BANK_TAG
vector< string > name
Variable name.
map< string, gBank > read_banks(goptions gemcOpt, map< string, string > allSystems)
vector< int > id
Output variable identifier.
vector< string > description
Variable description.
string bdescription
bank description