Changeset 13551 for fact/tools/pyscripts
- Timestamp:
- 05/03/12 22:36:20 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/pyscripts/pyfact/calfactfits.h
r13514 r13551 70 70 float* calib_gainmean; 71 71 float* calib_triggeroffsetmean; 72 // The same variables as above, but this time 73 // they are doubled in memory, so the modulo operation is not necessary. 74 // idea by TPK again 75 // since we like to work with doubles for some reason, I don't know yet 76 // I cast the float to double already in this stage. 77 78 double* baseline; 79 double* gain; 80 double* trigger_offset; 72 81 //Using <vector> instead of arrays makes no visible difference 73 82 //ToDo: use arrays of size 1440x1024 (x2 for wrap-arounds) and read all variables into those … … 86 95 npcaldata(NULL) 87 96 { 97 //cout << "Constructor called" << endl; 88 98 //Read basic parameters of the two files 89 99 // std::cout << "...Reading basic file parameters..." << std::endl; … … 120 130 // std::cout << "...Reading calibration data..." << std::endl; 121 131 calib_baselinemean = new float[calibfile.GetN("BaselineMean")]; 122 calibfile.SetPtrAddress("BaselineMean", calib_baselinemean, calibfile.GetN("BaselineMean")); 132 calibfile.SetPtrAddress("BaselineMean", calib_baselinemean, calibfile.GetN("BaselineMean")); 133 baseline = new double[calibfile.GetN("BaselineMean")*2]; 134 123 135 calib_gainmean = new float[calibfile.GetN("GainMean")]; 124 136 calibfile.SetPtrAddress("GainMean", calib_gainmean, calibfile.GetN("GainMean")); 137 gain = new double[calibfile.GetN("GainMean")*2]; 138 125 139 calib_triggeroffsetmean = new float[calibfile.GetN("TriggerOffsetMean")]; 126 140 calibfile.SetPtrAddress("TriggerOffsetMean", calib_triggeroffsetmean, calibfile.GetN("TriggerOffsetMean")); 127 calibfile.GetRow(0); 141 trigger_offset = new double[calibfile.GetN("TriggerOffsetMean")]; 142 143 calibfile.GetRow(0); 144 145 for (int i = 0; i < (int)calibfile.GetN("BaselineMean"); ++i) 146 { 147 baseline[i] = double(calib_baselinemean[i]) *4096./2000.; 148 baseline[i+(int)calibfile.GetN("BaselineMean")] = double(calib_baselinemean[i]) *4096./2000.; 149 } 150 151 for (int i = 0; i < (int)calibfile.GetN("GainMean"); ++i) 152 { 153 gain[i] = double(calib_gainmean[i]) * 1907.35; 154 gain[i+(int)calibfile.GetN("GainMean")] = double(calib_gainmean[i]) * 1907.35 *4096. /2000.; 155 } 156 157 for (int i = 0; i < (int)calibfile.GetN("TriggerOffsetMean"); ++i) 158 { 159 trigger_offset[i] = double(calib_triggeroffsetmean[i])*4096./2000.; 160 trigger_offset[i+(int)calibfile.GetN("TriggerOffsetMean")] = double(calib_triggeroffsetmean[i])*4096./2000.; 161 } 162 163 128 164 129 165 //Set the event pointers … … 144 180 ~CalFactFits() //Standard destructor 145 181 { 182 //cout << "Destructor called " << endl; 183 //cout << "calib_baselinemean " << calib_baselinemean << endl; 184 //cout << "calib_gainmean " << calib_gainmean << endl; 185 //cout << "calib_triggeroffsetmean " << calib_triggeroffsetmean << endl; 186 //cout << "event_data " << event_data << endl; 187 //cout << "event_offset " << event_offset << endl; 188 //cout << "event_boardtimes " << event_boardtimes << endl; 189 //cout << "baseline " << baseline << endl; 190 //cout << "gain " << gain << endl; 191 //cout << "trigger_offset " << trigger_offset << endl; 192 146 193 delete[] calib_baselinemean; 147 194 delete[] calib_gainmean; 148 delete[] calib_triggeroffsetmean;195 //delete[] calib_triggeroffsetmean; 149 196 delete[] event_data; 150 197 delete[] event_offset; 151 198 delete[] event_boardtimes; 199 delete[] baseline; 200 //delete[] gain; 201 delete[] trigger_offset; 152 202 } 153 203 … … 170 220 else { 171 221 UInt_t drs_calib_offset; 172 for(UInt_t pixel=0;pixel<data_npix;pixel++) { 173 for(UInt_t slice=0;slice<data_nroi;slice++) { 174 drs_calib_offset = (slice+event_offset[pixel])%calib_blm_size; 175 npcaldata[pixel*data_nroi+slice] = double((event_data[pixel*data_nroi+slice]*2000./4096.-calib_baselinemean[pixel*calib_blm_size+drs_calib_offset]-calib_triggeroffsetmean[pixel*data_nroi+slice])/calib_gainmean[pixel*calib_blm_size+drs_calib_offset]*1907.35); 222 double raw, raw_bsl, shifted; 223 for(UInt_t pixel = 0; pixel < data_npix; pixel++) 224 { 225 for(UInt_t slice = 0; slice < data_nroi; slice++) 226 { 227 drs_calib_offset = slice + event_offset[pixel]; 228 raw = (double)event_data[pixel*data_nroi+slice]; 229 raw_bsl = raw - baseline[pixel*calib_blm_size+drs_calib_offset]; 230 shifted = raw_bsl - trigger_offset[pixel*data_nroi+slice]; 231 npcaldata[pixel*data_nroi+slice] = shifted / gain[pixel*calib_blm_size+drs_calib_offset]; 232 //npcaldata[pixel*data_nroi+slice] = double((event_data[pixel*data_nroi+slice]*2000./4096.-calib_baselinemean[pixel*calib_blm_size+drs_calib_offset]-calib_triggeroffsetmean[pixel*data_nroi+slice])/calib_gainmean[pixel*calib_blm_size+drs_calib_offset]*1907.35); 176 233 //Note: data_nroi=calib_nroi, calib_blm_size=calib_gm_size 177 234 }
Note:
See TracChangeset
for help on using the changeset viewer.