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