Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:18:02

0001 /*!
0002  * \file TpcClusterZCrossingCorrection.cc
0003  * \brief applies correction to TPC cluster Z for bunch crossing time offset
0004  * \author Tony Frawley, March 2022
0005  */
0006 
0007 #include "TpcClusterZCrossingCorrection.h"
0008 
0009 #include <phool/sphenix_constants.h>
0010 
0011 #include <cmath>
0012 #include <iostream>
0013 #include <limits>
0014 
0015 // default value, override from macro (cm/ns)
0016 float TpcClusterZCrossingCorrection::_vdrift = 8.0e-03;
0017 
0018 // ns, same value as in pileup generator
0019 float TpcClusterZCrossingCorrection::_time_between_crossings = sphenix_constants::time_between_crossings;
0020 
0021 //______________________________________________________________________________________________
0022 float TpcClusterZCrossingCorrection::correctZ(float zinit, unsigned int side, short int crossing)
0023 {
0024   if (crossing == std::numeric_limits<short>::max())
0025   {
0026     return std::numeric_limits<float>::quiet_NaN();
0027   }
0028 
0029   float z_bunch_separation = _time_between_crossings * _vdrift;
0030 
0031   //    +ve crossing occurs in the future relative to time zero
0032   //        -ve z side (south, side 0), cluster arrives late, so z seems more positive
0033   //        +ve z side (north, side 1), cluster arrives late, so z seems more negative
0034   float corrected_z;
0035   if (side == 0)
0036   {
0037     corrected_z = zinit - (float) crossing * z_bunch_separation;
0038   }
0039   else
0040   {
0041     corrected_z = zinit + (float) crossing * z_bunch_separation;
0042   }
0043 
0044   //  std::cout << "         crossing " << crossing << " _vdrift " << _vdrift << " zinit " << zinit << " side " << side << " corrected_z " << corrected_z << std::endl;
0045 
0046   return corrected_z;
0047 }