00001 #ifndef CALIB_BARREL_RIGHT_OFFSET2_BUNCH3_4_H 00002 #define CALIB_BARREL_RIGHT_OFFSET2_BUNCH3_4_H 00003 00004 #include "tofcalgsec/TofCalib.h" 00005 00006 const int nBarrelRight_Offset2_bunch3_4 = 7; 00007 00008 class calib_barrel_right_offset2_bunch3_4:public TofCalib { 00009 public: 00010 calib_barrel_right_offset2_bunch3_4():TofCalib( nBarrelRight_Offset2_bunch3_4 ) { 00011 m_name = string("calib_barrel_right_offset2_bunch3"); 00012 } 00013 00014 void calculate_funcs( const Record* r ) { 00015 double z = r->zrhit(); 00016 double t = r->tright(); 00017 double t0 = r->phi(); 00018 if( r->run()<0 || ( (static_cast<int>(t0/(8.0*12000./499.8/8./4. )+0.1))%4==3 ) ) { 00019 if( z<5.0 && abs(t)<10.0 ) { 00020 funcs[0] = 1.0; 00021 funcs[1] = z; 00022 funcs[2] = z*z; 00023 funcs[3] = z*z*z; 00024 funcs[4] = z*z*z*z; 00025 funcs[5] = z*z*z*z*z; 00026 funcs[6] = z*z*z*z*z*z; 00027 } 00028 else { 00029 funcs[0] = 0.0; 00030 funcs[1] = 0.0; 00031 funcs[2] = 0.0; 00032 funcs[3] = 0.0; 00033 funcs[4] = 0.0; 00034 funcs[5] = 0.0; 00035 funcs[6] = 0.0; 00036 } 00037 } 00038 return; 00039 } 00040 00041 void calculate_y(const Record* r) { 00042 if( r->run()<0 || ( (static_cast<int>((r->phi())/(8.0*12000./499.8/8./4. )+0.1))%4==3 ) ) { 00043 if( r->zrhit() < 5.0 ) { 00044 y = r->tright(); 00045 } 00046 else { 00047 y = 0.0; 00048 } 00049 } 00050 return; 00051 } 00052 00053 void updateData( RecordSet*& data ) { 00054 if( data->size() > 0 ) { 00055 std::vector<Record*>::iterator iter = data->begin(); 00056 for( ; iter!=data->end(); iter++ ) { 00057 if( (*iter)->run() < 0 ) return; 00058 if ((static_cast<int>(((*iter)->phi())/(8.0*12000./499.8/8./4. )+0.1))%4==3){ 00059 if( (*iter)->zrhit() >= 0.0 ) continue; 00060 calculate_funcs( (*iter) ); 00061 double tcorr = 0.0; 00062 for( int i=0; i<X.num_row(); i++ ) { 00063 tcorr += X[i]*funcs[i]; 00064 } 00065 (*iter)->settright( (*iter)->tright() - tcorr ); 00066 } 00067 } 00068 } 00069 return; 00070 } 00071 00072 }; 00073 00074 #endif