Changeset 12368 for fact/tools/rootmacros/FOpenDataFile.c
- Timestamp:
- 11/04/11 12:44:27 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fact/tools/rootmacros/FOpenDataFile.c
r12166 r12368 1 #include <cstdio> 2 int FOpenDataFile(fits &datafile, vector<int16_t> &data, vector<int16_t> &data_offset, unsigned int &data_num, size_t &data_n, UInt_t &data_roi, UInt_t &data_px) 3 { 1 2 3 4 //#include "FOpenDataFile.h" 5 6 int FOpenDataFile( 7 fits &datafile, 8 vector<int16_t> &data, 9 vector<int16_t> &data_offset, 10 unsigned int &data_num, 11 size_t &data_n, 12 UInt_t &data_roi, 13 UInt_t &data_px 14 ){ 4 15 //------------------------------------------- 5 16 //Print the header … … 34 45 return 0; 35 46 } 47 48 size_t OpenDataFile( 49 const char *datafilename, // path to fits file containing FACT raw data 50 fits * * datafile, // ptr to pointer, where to return the fits object 51 vector<int16_t> &Data, // vector, which will be filled with raw data 52 vector<int16_t> &StartCells, // vector, which will be filled with DRS start positions 53 unsigned int &EventID, // index of the current event 54 UInt_t &RegionOfInterest, // Width of the Region, read out of the DRS 55 UInt_t &NumberOfPixels, // Total number of pixel, read out of the camera 56 size_t &PXLxROI, // Size of column "Data" = #Pixel x ROI 57 // this can be used, to x-check RegionOfInterest and NumberOfPixels 58 int VerbosityLevel // 59 ) { 60 size_t NumberOfEvents; 61 *datafile = new fits(datafilename); 62 if (!(*(*datafile))) { 63 if (VerbosityLevel > 0) 64 cout << "Couldn't properly open the datafile: " << datafilename << endl; 65 return 0; 66 } 67 68 NumberOfEvents = (*datafile)->GetNumRows(); 69 if (NumberOfEvents < 1){ 70 if (VerbosityLevel > 0){ 71 cout << "Warning in FOpenDataFile of file: " << datafilename << endl; 72 cout << "the file contains no events." << endl; 73 } 74 } 75 76 RegionOfInterest = (*datafile)->GetUInt("NROI"); 77 NumberOfPixels = (*datafile)->GetUInt("NPIX"); 78 PXLxROI = (*datafile)->GetN("Data"); 79 80 if ( RegionOfInterest * NumberOfPixels != PXLxROI) // something in the file went wrong 81 { 82 if (VerbosityLevel > 0){ 83 cout << "Warning in FOpenDataFile of file: " << datafilename << endl; 84 cout << "RegionOfInterest * NumberOfPixels != PXLxROI" << endl; 85 cout << "--> " << RegionOfInterest; 86 cout << " * " << NumberOfPixels; 87 cout << " = " << RegionOfInterest * NumberOfPixels; 88 cout << ", but PXLxROI =" << PXLxROI << endl; 89 } 90 return 0; 91 } 92 93 //Set the sizes of the data vectors 94 Data.resize(PXLxROI, 0); 95 StartCells.resize(NumberOfPixels, 0); 96 97 //Link the data to variables 98 (*datafile)->SetRefAddress("EventNum", EventID); 99 (*datafile)->SetVecAddress("Data", Data); 100 (*datafile)->SetVecAddress("StartCellData", StartCells); 101 102 return NumberOfEvents; 103 } 104
Note:
See TracChangeset
for help on using the changeset viewer.