9 #ifndef StVpdSimConfig_h
10 #define StVpdSimConfig_h
15 #include "St_db_Maker/St_db_Maker.h"
16 #include "tables/St_vpdSimParams_Table.h"
17 #include "phys_constants.h"
21 class vpdSimParams_st;
44 double singleTubeRes(UInt_t mVPDHitPatternEast, UInt_t mVPDHitPatternWest){
45 double vpdResSumSqr(0.),
47 int total_vpd_hits = 0;
48 for (
int i=0; i<19; i++){
49 if (1 << i & mVPDHitPatternEast) {
53 if (1 << i & mVPDHitPatternWest) {
58 vpdresolution = sqrt(vpdResSumSqr)/total_vpd_hits;
73 TRandom3 randEngine(0);
77 for (
int i=0; i<MAX_ARRAY_INDEX; i++) {
85 vpdRes = vpdRes/counter;
88 LOG_WARN <<
"No resolutions found in DB! Using DEFAULT avg of 120 ps single tube res- maybe a terrible guess for your dataset!" << endm;
92 if ( 0 == nWest && 0 == nEast ){
93 LOG_WARN <<
"No VPD tubes hit, resolution = 999" << endm;
97 for (
int j=0;j< (nWest + nEast); j++) {
98 randNum = randEngine.Gaus(0, vpdRes);
102 float result = tSum / ((float)(nWest + nEast));
103 LOG_INFO <<
"tof blur from vpd resolution (nEast + nWest = " << (nEast+nWest) <<
": " << result << endm;
109 void loadVpdSimParams(
const int date = 20160913,
const int time = 175725,
const char* Default_time =
"2016-09-13 17:57:25")
114 TDataSet *DB = GetDataBase(
"Calibrations/tof/vpdSimParams");
117 LOG_WARN <<
"No data set found, creating new St_db_Maker... with date/time" << date <<
"/" << time << endm;
118 dbMk =
new St_db_Maker(
"db",
"MySQL:StarDb",
"$STAR/StarDb");
120 dbMk->SetDateTime(date,time);
121 dbMk->SetFlavor(
"ofl");
127 LOG_WARN <<
"Failed to connect to Database!" << endm;
131 St_vpdSimParams *dataset = 0;
132 dataset = (St_vpdSimParams*) DB->
Find(
"vpdSimParams");
136 dbMk->GetValidity((
TTable*)dataset,val);
137 vpdSimParams_st* table =
static_cast<vpdSimParams_st*
>(dataset->GetTable());
141 for (
int i = 0; i < MAX_ARRAY_INDEX; i++) {
142 params.
tubeId = table->tubeID[i];
152 LOG_WARN <<
"ERROR: dataset does not contain requested table" << endm;
162 int MAX_DB_INDEX = 38;
166 int vpdTubeStatusFlag;
167 int vpdTubeTriggerFlag;
171 std::ifstream inData;
172 inData.open( params_filename.c_str() );
174 for (
int i = 0; i < MAX_DB_INDEX; i++) {
175 inData >> vpdTubeId >> vpdTubeRes >> vpdTubeStatusFlag >> vpdTubeTriggerFlag;
176 params.
tubeId = vpdTubeId;
187 std::map<int, SingleTubeParams> getParams(){
191 float getThreshold()
const {
return mThreshold; }
192 float getVpdDistance()
const {
return VPDDISTANCE; }
193 float getTDiffCut()
const {
return TDIFFCUT; }
194 float getMcClock()
const {
return kMcClock; }
202 const int MAX_ARRAY_INDEX = 38;
double getVpdResolution(int nWest, int nEast)
int tubeTriggerFlag
Status flag for whether tube was triggered on (1) or not (0)
int tubeStatusFlag
Status flag for whether tube was active (1) or inactive (0)
std::map< int, SingleTubeParams > mSimParams
stores a map of the single tube params indexed on tubeId
int mThreshold
Threshold value for a tube to recognize it as a true hit.
const float kMcClock
Standard clock for pure simulation in ns. This is present to match the clock of BTof hits...
int tubeId
Tube Id (number) [0,37] with west Vpd [0,18] and east Vpd [19,37].
const float VPDDISTANCE
Distance (in cm) of each Vpd from the zero point.
const float TDIFFCUT
Cut value for eliminating times with a significant deviation from avg.
void loadVpdSimParams(string params_filename)
float singleTubeRes
Resolution of a particular Vpd tube in ps.
void loadVpdSimParams(const int date=20160913, const int time=175725, const char *Default_time="2016-09-13 17:57:25")
Loads Vpd Sim Params from database.
double singleTubeRes(UInt_t mVPDHitPatternEast, UInt_t mVPDHitPatternWest)
Calculate correct resolution based on those tubes that were used.
virtual TDataSet * Find(const char *path) const
structure containing tube parameters