Changeset 12513
- Timestamp:
- 11/14/11 19:14:31 (13 years ago)
- Location:
- fact/tools/rootmacros
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/DrsCalibration.C
r12511 r12513 31 31 } 32 32 33 34 35 // FACT raw data is stored in fits files in large vector<int16_t>. these 36 // containt the data of the full camera for a single event. 37 // in order to work with this data, one needs to extract the part, which 38 // belongs to the current pixel and apply a DRS calibration, based on a dedicated 39 // DRS calibration file. 40 // 41 // TODO: The calibration Data as well as the Data and StartCell vectors are a bit 42 // massive to give this function as parameters. 43 // better to have these vectors somehow bundled in classes like: 44 // RawData - class and 45 // DrsCalibration - class 46 // those classes would be the result of 47 // openDataFits() and 48 // openCalibFits() 49 // 33 50 size_t applyDrsCalibration( vector<float> &destination, 34 51 int pixel, … … 40 57 UInt_t RegionOfInterest, 41 58 vector<int16_t> AllPixelDataVector, 42 vector<int16_t> StartCellVector 59 vector<int16_t> StartCellVector, 60 int verbosityLevel 43 61 ){ 44 62 // In order to minimize mem free and alloc actions … … 48 66 if ( destination.size() < DestinationLength || destination.size() > 2 * DestinationLength ){ 49 67 destination.resize( DestinationLength ); 50 }51 52 // the vector drs_triggeroffsetmean is not 1440 * 1024 entries long53 // but has hopefully the length 1440 * RegionOfInterest (or longer)54 if ( drs_triggeroffsetmean.size() < 1440*RegionOfInterest ){55 return 0;56 68 } 57 69 … … 103 115 // TrueValue[c][s] = ( RawValue[c][s] - Offset[c][ (c+t)%1024 ] ) / Gain[c][ (c+t)%1024 ] * 1907.35 - TriggerOffset[c][s] 104 116 105 106 107 108 117 const float dconv = 2000/4096.0; 109 118 float vraw; 110 // float vcal;111 // unsigned int pixel_pt;112 // unsigned int slice_pt;113 // unsigned int cal_pt;114 // unsigned int drs_cal_offset;115 119 116 120 if ( RegionOfInterest != AllPixelDataVector.size()/1440 ){ 117 cout << "RegionOfInterest != AllPixelDataVector.size()/1440 .. this makes no sense ... I guess ... aborting" << endl; 121 if (verbosityLevel > 0){ 122 cout << "RegionOfInterest != AllPixelDataVector.size()/1440" << endl; 123 cout << "RegionOfInterest: " << RegionOfInterest << endl; 124 cout << "AllPixelDataVector.size(): " << AllPixelDataVector.size() << endl; 125 cout << "aborting" << endl; 126 } 118 127 return 0; 119 128 } 120 129 121 int Offset_offset = pixel * drs_basemean.size()/1440; 122 int Gain_offset = pixel * drs_gainmean.size()/1440; 123 int TriggerOffset_offset = pixel * drs_triggeroffsetmean.size()/1440; 124 int Data_offset = pixel * RegionOfInterest; 130 // the vector drs_triggeroffsetmean is not 1440 * 1024 entries long 131 // but has hopefully the length 1440 * RegionOfInterest (or longer) 132 if ( drs_triggeroffsetmean.size() < 1440*RegionOfInterest ){ 133 if (verbosityLevel > 0){ 134 cout << "Error: drs_triggeroffsetmean.size() < 1440*RegionOfInterest" << endl; 135 cout << "drs_triggeroffsetmean.size():" << drs_triggeroffsetmean.size() << endl; 136 cout << "RegionOfInterest" << RegionOfInterest << endl; 137 cout << "aborting" << endl; 138 } 139 return 0; 140 } 141 142 int DataPos, OffsetPos, TriggerOffsetPos; 125 143 126 144 for ( unsigned int sl = LeaveOutLeft; sl < RegionOfInterest-LeaveOutRight ; sl++){ 127 vraw = AllPixelDataVector[ Data_offset + sl ] * dconv; 128 vraw -= drs_basemean[ Offset_offset + (sl + StartCellVector[pixel])%1024 ]; 129 vraw /= drs_gainmean[ Gain_offset + (sl + StartCellVector[pixel])%1024 ]; 145 146 DataPos = pixel * RegionOfInterest + sl; 147 // Offset and Gain vector *should look the same 148 OffsetPos = pixel * drs_basemean.size()/1440 + (sl + StartCellVector[pixel])%(drs_basemean.size()/1440); 149 150 TriggerOffsetPos = pixel * drs_triggeroffsetmean.size()/1440 + sl 151 152 vraw = AllPixelDataVector[ DataPos ] * dconv; 153 vraw -= drs_basemean[ OffsetPos ]; 154 vraw /= drs_gainmean[ OffsetPos ]; 130 155 vraw *= 1907.35; 131 vraw -= drs_triggeroffsetmean[ TriggerOffset _offset + sl];156 vraw -= drs_triggeroffsetmean[ TriggerOffsetPos ]; 132 157 133 158 // slice_pt = pixel_pt + sl; -
fact/tools/rootmacros/DrsCalibration.h
r12383 r12513 20 20 UInt_t RegionOfInterest, 21 21 vector<int16_t> AllPixelDataVector, 22 vector<int16_t> StartCellVector 22 vector<int16_t> StartCellVector, 23 int verbosityLevel = 1 23 24 ); 24 25
Note:
See TracChangeset
for help on using the changeset viewer.