Ignore:
Timestamp:
11/14/11 19:14:31 (13 years ago)
Author:
neise
Message:
next try
Location:
fact/tools/rootmacros
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fact/tools/rootmacros/DrsCalibration.C

    r12511 r12513  
    3131}
    3232
     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//
    3350size_t applyDrsCalibration( vector<float> &destination,
    3451        int pixel,
     
    4057        UInt_t RegionOfInterest,
    4158        vector<int16_t> AllPixelDataVector,
    42         vector<int16_t> StartCellVector
     59        vector<int16_t> StartCellVector,
     60        int verbosityLevel
    4361){
    4462        // In order to minimize mem free and alloc actions
     
    4866        if ( destination.size() < DestinationLength || destination.size() > 2 * DestinationLength ){
    4967                destination.resize( DestinationLength );
    50         }
    51 
    52         // the vector drs_triggeroffsetmean is not 1440 * 1024 entries long
    53         // but has hopefully the length 1440 * RegionOfInterest (or longer)
    54         if ( drs_triggeroffsetmean.size() < 1440*RegionOfInterest ){
    55                 return 0;
    5668        }
    5769
     
    103115        // TrueValue[c][s] = ( RawValue[c][s] - Offset[c][ (c+t)%1024 ] ) / Gain[c][ (c+t)%1024 ] * 1907.35 - TriggerOffset[c][s]
    104116       
    105        
    106        
    107 
    108117        const float dconv = 2000/4096.0;
    109118        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;
    115119
    116120        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                }
    118127                return 0;
    119128        }
    120129
    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;
    125143       
    126144        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 ];
    130155                vraw *= 1907.35;
    131                 vraw -= drs_triggeroffsetmean[ TriggerOffset_offset + sl ];
     156                vraw -= drs_triggeroffsetmean[ TriggerOffsetPos ];
    132157
    133158//              slice_pt = pixel_pt + sl;
  • fact/tools/rootmacros/DrsCalibration.h

    r12383 r12513  
    2020        UInt_t RegionOfInterest,
    2121        vector<int16_t> AllPixelDataVector,
    22         vector<int16_t> StartCellVector
     22        vector<int16_t> StartCellVector,
     23        int verbosityLevel  = 1
    2324);
    2425
Note: See TracChangeset for help on using the changeset viewer.