diff --git a/StRoot/StBTofCalibMaker/StBTofCalibMaker.cxx b/StRoot/StBTofCalibMaker/StBTofCalibMaker.cxx index afc052abba5..c82328a3523 100644 --- a/StRoot/StBTofCalibMaker/StBTofCalibMaker.cxx +++ b/StRoot/StBTofCalibMaker/StBTofCalibMaker.cxx @@ -2835,36 +2835,20 @@ void StBTofCalibMaker::writePPPAHistograms() //_____________________________________________________________________________ float StBTofCalibMaker::tofCellResolution(const Int_t itray, const Int_t iModuleChan) { + float resolution(0.013); // 0.013 by default - 1/beta resolution + if (itray<0){return resolution;} - float resolution(0.013); // 0.013 by default - 1/beta resolution - if (itray<0){return resolution;} - - int module = iModuleChan/6 + 1; - int cell = iModuleChan%6 + 1; - // mBTofRes::timeres_tof() reports in picoseconds - float stop_resolution = mBTofRes->timeres_tof(itray, module, cell)/1000.; - -float start_resolution(0); - if (mUseVpdStart){ - - // For VPD timing determine the VPD starttime by combing the resolutions of - // tray == 122 (east) - // mSimParams[singleHit.tubeId-1+19].singleTubeRes - // tray 121 (west) - // mSimParams[singleHit.tubeId-1].singleTubeRes - // - // needs to be implemented - - } - else { - // combine an average BTOF resolution based on NT0 - // more sophisticated: figure out what BTOF cells actually went into the NT0 count. - - // mBTofRes::timeres_tof() reports in picoseconds - start_resolution = mBTofRes->average_timeres_tof()/sqrt(mNTzero)/1000.; - } + int module = iModuleChan/6 + 1; + int cell = iModuleChan%6 + 1; + // mBTofRes::timeres_tof() reports in picoseconds + float stop_resolution = mBTofRes->timeres_tof(itray, module, cell)/1000.; - resolution = sqrt(stop_resolution*stop_resolution + start_resolution*start_resolution); + float start_resolution = 0.0; + if (mUseVpdStart) + start_resolution = mVpdResConfig->singleTubeRes(mVPDHitPatternEast, mVPDHitPatternWest)/1000.; + else + start_resolution = mBTofRes->average_timeres_tof()/sqrt(mNTzero)/1000.; + resolution = sqrt(stop_resolution*stop_resolution + start_resolution*start_resolution); -return resolution; + return resolution; } diff --git a/StRoot/StBTofUtil/StVpdSimConfig.h b/StRoot/StBTofUtil/StVpdSimConfig.h index 26176a355bd..69d6ee0be95 100644 --- a/StRoot/StBTofUtil/StVpdSimConfig.h +++ b/StRoot/StBTofUtil/StVpdSimConfig.h @@ -29,21 +29,35 @@ class StVpdSimConfig : public StMaker { //! structure containing tube parameters struct SingleTubeParams{ float singleTubeRes; //!< Resolution of a particular Vpd tube in ps - int tubeId; //!< Tube Id (number) [0,37] with west Vpd [0,18] and east Vpd [19,37] - int tubeStatusFlag; //!< Status flag for whether tube was active (1) or inactive (0) - int tubeTriggerFlag; //!< Status flag for whether tube was triggered on (1) or not (0) + int tubeId, //!< Tube Id (number) [0,37] with west Vpd [0,18] and east Vpd [19,37] + tubeStatusFlag, //!< Status flag for whether tube was active (1) or inactive (0) + tubeTriggerFlag; //!< Status flag for whether tube was triggered on (1) or not (0) }; -/// calculate correct resolution based on those tubes that were used -double singleTubeRes(UInt_t mVPDHitPatternEast, UInt_t mVPDHitPatternWest){ - double vpdResSumSqr(0.), vpdresolution(0.); - for (int i=0; i<19; i++){ - if (1 << i && mVPDHitPatternEast) vpdResSumSqr += (mSimParams[i].singleTubeRes)*(mSimParams[i].singleTubeRes); - if (1 << i && mVPDHitPatternWest) vpdResSumSqr += (mSimParams[i+19].singleTubeRes)*(mSimParams[i+19].singleTubeRes); + /** + * @brief Calculate correct resolution based on those tubes that were used. + * + * @param mVPDHitPatternEast 9 digit binary number specifying hit pattern of east VPD tubes. + * @param mVPDHitPatternWest 9 digit binary number specifying hit pattern of west VPD tubes. + * @return double vpd resolution. + */ + double singleTubeRes(UInt_t mVPDHitPatternEast, UInt_t mVPDHitPatternWest){ + double vpdResSumSqr(0.), + vpdresolution(0.); + int total_vpd_hits = 0; //Total number of vpd tubes used. + for (int i=0; i<19; i++){ + if (1 << i & mVPDHitPatternEast) { + vpdResSumSqr += (mSimParams[i].singleTubeRes)*(mSimParams[i].singleTubeRes); + total_vpd_hits += 1; + } + if (1 << i & mVPDHitPatternWest) { + vpdResSumSqr += (mSimParams[i+19].singleTubeRes)*(mSimParams[i+19].singleTubeRes); + total_vpd_hits += 1; + } } - vpdresolution = sqrt(vpdResSumSqr); - return vpdresolution; -} + vpdresolution = sqrt(vpdResSumSqr)/total_vpd_hits; + return vpdresolution; + } /** * Calculates the average resolution across all 38 tubes (discounts inactive tubes)