Changeset 1031 for trunk/MagicSoft/Mars/mraw
- Timestamp:
- 11/06/01 10:33:21 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/mraw
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mraw/MRawCrateArray.cc
r1004 r1031 41 41 42 42 #include "MLog.h" 43 #include "MRawCrateData.h" 43 44 44 45 ClassImp(MRawCrateArray); … … 80 81 } 81 82 82 // -------------------------------------------------------------------------- 83 // 84 // Return a pointer the i-th entry in the array 85 // 86 MRawCrateData *MRawCrateArray::GetEntry(Int_t i) 83 void MRawCrateArray::SetSize(Int_t i) 87 84 { 88 return (MRawCrateData*)fArray->AddrAt(i); 85 if (fArray->GetEntriesFast() == i) 86 return; 87 88 fArray->ExpandCreateFast(i); 89 89 } 90 90 91 91 // -------------------------------------------------------------------------- 92 92 // 93 // Return the i-th entry in the array 93 // Return a pointer the i-th entry in the array, without range check 94 // 95 MRawCrateData *MRawCrateArray::GetEntry(Int_t i) 96 { 97 return (MRawCrateData*)fArray->UncheckedAt(i); // AddrAt would be with rcheck 98 } 99 100 // -------------------------------------------------------------------------- 101 // 102 // Return the i-th entry in the array, with range check 94 103 // 95 104 MRawCrateData* &MRawCrateArray::operator[](Int_t i) -
trunk/MagicSoft/Mars/mraw/MRawCrateArray.h
r1018 r1031 25 25 void Clear(Option_t *opt=NULL); 26 26 27 void SetSize(Int_t i); 27 28 MRawCrateData *GetEntry(Int_t i); 28 29 -
trunk/MagicSoft/Mars/mraw/MRawCrateData.h
r1018 r1031 2 2 #define MARS_MRawCrateData 3 3 4 #ifndef MARS_M AGIC5 #include "M AGIC.h"4 #ifndef MARS_MParContainer 5 #include "MParContainer.h" 6 6 #endif 7 7 8 8 class ifstream; 9 9 10 class MRawCrateData : public TObject10 class MRawCrateData : public MParContainer 11 11 { 12 12 private: -
trunk/MagicSoft/Mars/mraw/MRawEvtData.cc
r1030 r1031 138 138 // "dec" Prints the time slices decimal 139 139 // 140 void MRawEvtData::Print(Option_t *opt) 140 void MRawEvtData::Print(Option_t *opt) const 141 141 { 142 142 // … … 296 296 void MRawEvtData::DeletePixels(Bool_t flag) 297 297 { 298 const int npix = fRunHeader->GetNumCrates()*fRunHeader->GetNumPixInCrate(); 299 300 if (fArraySize == npix && flag) 301 { 302 fPosInArray = 0; 303 return; 304 } 305 298 306 DeleteArrays(); 299 307 InitArrays(flag); … … 319 327 void MRawEvtData::InitArrays(Bool_t flag) 320 328 { 321 // const int npix = !flag ? 0 : fRunHeader->GetNumCrates()*fRunHeader->GetNumPixInCrate(); 322 323 fHiGainPixId = new MArrayS(0);//npix); 324 fLoGainPixId = new MArrayS(0);//npix); 325 fHiGainFadcSamples = new MArrayB(0);//npix*fRunHeader->GetNumSamplesHiGain()); 326 fLoGainFadcSamples = new MArrayB(0);//npix*fRunHeader->GetNumSamplesLoGain()); 329 if (flag) 330 { 331 const int npix = fRunHeader->GetNumCrates()*fRunHeader->GetNumPixInCrate(); 332 333 fHiGainPixId = new MArrayS(npix); 334 fLoGainPixId = new MArrayS(npix); 335 fHiGainFadcSamples = new MArrayB(npix*fRunHeader->GetNumSamplesHiGain()); 336 fLoGainFadcSamples = new MArrayB(npix*fRunHeader->GetNumSamplesLoGain()); 337 338 fArraySize = npix; 339 } 340 else 341 { 342 fHiGainPixId = new MArrayS(0); 343 fLoGainPixId = new MArrayS(0); 344 fHiGainFadcSamples = new MArrayB(0); 345 fLoGainFadcSamples = new MArrayB(0); 346 347 fArraySize = 0; 348 } 349 350 fPosInArray = 0; 327 351 } 328 352 … … 384 408 const UShort_t npic = fRunHeader->GetNumPixInCrate(); 385 409 386 // 387 // Enhance array by the size which we'll read now 388 // 389 const int npixhi = fHiGainPixId->GetSize(); 390 const int npixlo = fLoGainPixId->GetSize(); 391 392 fHiGainPixId->Set(npixhi+npic); 393 fLoGainPixId->Set(npixlo+npic); 394 395 const int nsamhi = fHiGainFadcSamples->GetSize(); 396 const int nsamlo = fLoGainFadcSamples->GetSize(); 397 398 fHiGainFadcSamples->Set(nsamhi+nhi*npic); 399 fLoGainFadcSamples->Set(nsamlo+nlo*npic); 400 401 Byte_t *higainsam = fHiGainFadcSamples->GetArray()+nsamhi; 402 Byte_t *logainsam = fLoGainFadcSamples->GetArray()+nsamlo; 410 const UShort_t npos = npic*fPosInArray; 411 412 Byte_t *higainsam = fHiGainFadcSamples->GetArray()+nhi*npos; 413 Byte_t *logainsam = fLoGainFadcSamples->GetArray()+nlo*npos; 414 415 // UShort_t *hipixid = (UShort_t*)fHiGainPixId->GetArray()+npos; 416 // UShort_t *lopixid = (UShort_t*)fLoGainPixId->GetArray()+npos; 403 417 404 418 for (int i=0; i<npic; i++) … … 409 423 const UShort_t npix = fRunHeader->GetPixAssignment(i); 410 424 425 const UShort_t ipos = npos+i; 411 426 // 412 427 // This is to fill the data of one pixel to the MRawEvtHeader Class. … … 414 429 // Add to lo gains if lflag = 1 415 430 // 416 fHiGainPixId->AddAt(npix, npixhi+i);431 fHiGainPixId->AddAt(npix, ipos); 417 432 fin.read(higainsam, nhi); 418 433 higainsam += nhi; … … 421 436 //if (IsLoGainOn(i, j)) 422 437 //{ 423 fLoGainPixId->AddAt(npix, npixlo+i);438 fLoGainPixId->AddAt(npix, ipos); 424 439 fin.read(logainsam, nlo); 425 440 logainsam += nlo; -
trunk/MagicSoft/Mars/mraw/MRawEvtData.h
r1018 r1031 27 27 MArrayB *fLoGainFadcSamples; // list of lo gain samples of all pixels (ordering: see fLoGainPixId) 28 28 29 Int_t fPosInArray; //! 30 Int_t fArraySize; //! 31 29 32 void InitArrays(Bool_t flag=kFALSE); 30 33 void DeleteArrays(); … … 44 47 45 48 void Clear(Option_t * = NULL); 46 void Print(Option_t * = NULL) ;49 void Print(Option_t * = NULL) const; 47 50 void Draw (Option_t * = NULL); 48 51 49 52 void DeletePixels(Bool_t flag=kFALSE); 53 void ResetPixels() { DeletePixels(kTRUE); } 50 54 void AddPixel(UShort_t nOfPixel, TArrayC *data, Bool_t lflag=kFALSE); 51 55 52 Byte_t GetNumHiGainSamples() const;53 Byte_t GetNumLoGainSamples() const;56 Byte_t GetNumHiGainSamples() const; 57 Byte_t GetNumLoGainSamples() const; 54 58 UShort_t GetNumPixels() const; 55 59 -
trunk/MagicSoft/Mars/mraw/MRawFileRead.cc
r1004 r1031 25 25 ////////////////////////////////////////////////////////////////////////////// 26 26 // // 27 // MRawFile 27 // MRawFileRead // 28 28 // // 29 29 // This tasks reads the raw binary file like specified in the TDAS??? // … … 35 35 // // 36 36 // Output Containers: // 37 // MRawRunHeader, MRawEvtHeader, MRawEvtData, MRawCrateArray, M Time//37 // MRawRunHeader, MRawEvtHeader, MRawEvtData, MRawCrateArray, MRawEvtTime // 38 38 // // 39 39 ////////////////////////////////////////////////////////////////////////////// … … 55 55 56 56 57 /* /----------- please don't delete and don't care about (Thomas) ------------58 #define kBUFSZ 102459 57 /* ----------- please don't delete and don't care about (Thomas) ------------ 58 #define kBUFSZ 64 //1024*1024*64 59 #include <iomanip.h> 60 60 class bifstream : public istream, public streambuf 61 61 { … … 72 72 { 73 73 int sz=fread(fBuffer, kBUFSZ, 1, fd); 74 //int sz=fread(fBuffer, 1, kBUFSZ, fd); 74 75 setg(fBuffer, fBuffer, fBuffer+kBUFSZ); 75 76 76 return sz==kBUFSZ ? *(unsigned char*)fBuffer : EOF;//EOF; 77 return sz==1 ? *(unsigned char*)fBuffer : EOF;//EOF; 78 //return sz==kBUFSZ ? *(unsigned char*)fBuffer : EOF;//EOF; 77 79 } 78 80 public: … … 90 92 // 91 93 MRawFileRead::MRawFileRead(const char *fname, const char *name, const char *title) 94 : fFileName(fname) 92 95 { 93 96 fName = name ? name : "MRawFileRead"; … … 198 201 199 202 // 203 // Get number of crates from the run header 204 // 205 const UShort_t nc = fRawRunHeader->GetNumCrates(); 206 207 // 200 208 // Delete arrays which stores the pixel information (time slices) 201 209 // 202 fRawEvtData-> DeletePixels();210 fRawEvtData->ResetPixels(); 203 211 204 212 // 205 213 // clear the TClonesArray which stores the Crate Information 206 // 207 fRawCrateArray->Clear(); 208 209 // 210 // Get number of crates from the run header 211 // 212 const UShort_t nc = fRawRunHeader->GetNumCrates(); 214 // and create a new array of the correct size 215 // 216 fRawCrateArray->SetSize(nc); 213 217 214 218 // … … 225 229 } 226 230 231 // -------------------------------------------------------------------------- 232 // 233 // Checks whether the number of read events differs from the number the 234 // file should containe (MRawRunHeader). Prints a warning if it doesn't 235 // match. 236 // 237 Bool_t MRawFileRead::PostProcess() 238 { 239 if (fRawRunHeader->GetNumEvents() != GetNumExecutions()-1) 240 *fLog << "WARNING - number of read events doesn't match number in run header." << endl; 241 242 return kTRUE; 243 } -
trunk/MagicSoft/Mars/mraw/MRawFileRead.h
r1018 r1031 2 2 #define MARS_MRawFileRead 3 3 4 #ifndef MARS_MT ASK4 #ifndef MARS_MTask 5 5 #include "MTask.h" 6 6 #endif … … 33 33 Bool_t PreProcess(MParList *pList); 34 34 Bool_t Process(); 35 Bool_t PostProcess(); 35 36 36 37 ClassDef(MRawFileRead, 0) // Task to read the raw data binary file -
trunk/MagicSoft/Mars/mraw/MRawFileWrite.cc
r1004 r1031 83 83 84 84 delete fOut; 85 86 // 87 // Remark: 88 // - Trees are automatically deleted by the the file 89 // (unless file.SetDirectory(0) was called) 90 // - Branches are automatically deleted by the tree destructor 91 // 85 92 } 86 93 … … 156 163 157 164 // 165 // Remark: 166 // - Trees are automatically deleted by the the file 167 // (unless file.SetDirectory(0) was called) 168 // - Branches are automatically deleted by the tree destructor 169 // 170 171 // 158 172 // Write the run header information to the file 159 173 // 160 TTree 161 TBranch *tb =rh->Branch("MRawRunHeader", "MRawRunHeader", &fRawRunHeader, 32000);174 TTree *rh = new TTree("RunHeaders", "Run headers of all runs in this file"); 175 rh->Branch("MRawRunHeader", "MRawRunHeader", &fRawRunHeader, 32000); 162 176 rh->Fill(); 163 rh->Write(); 164 delete tb; 165 delete rh; 177 //rh->Write(); 166 178 167 179 // … … 173 185 174 186 // 187 // From the root dicumentation: 188 // 189 // Note that calling TTree::AutoSave too frequently (or similarly calling 190 // TTree::SetAutoSave with a small value) is an expensive operation. 191 // You should make tests for your own application to find a compromize 192 // between speed and the quantity of information you may loose in case of 193 // a job crash. 194 // 195 // In case your program crashes before closing the file holding this tree, 196 // the file will be automatically recovered when you will connect the file 197 // in UPDATE mode. 198 // The Tree will be recovered at the status corresponding to the last AutoSave. 199 // 200 fTData ->SetAutoSave(2000000000); // 2GB 201 fTPedestal ->SetAutoSave(2000000000); // 2GB 202 fTCalibration->SetAutoSave(2000000000); // 2GB 203 204 // 175 205 // create all branches which are necessary 176 206 // 177 fTData ->Branch("MTime.", "MTime", &fRawEvtTime, 32000); 178 fTPedestal ->Branch("MTime.", "MTime", &fRawEvtTime, 32000); 179 fTCalibration->Branch("MTime.", "MTime", &fRawEvtTime, 32000); 180 fTData ->Branch("MRawEvtHeader.", "MRawEvtHeader", &fRawEvtHeader, 32000); 181 fTPedestal ->Branch("MRawEvtHeader.", "MRawEvtHeader", &fRawEvtHeader, 32000); 182 fTCalibration->Branch("MRawEvtHeader.", "MRawEvtHeader", &fRawEvtHeader, 32000); 183 fTData ->Branch("MRawEvtData.", "MRawEvtData", &fRawEvtData, 32000); 184 fTPedestal ->Branch("MRawEvtData.", "MRawEvtData", &fRawEvtData, 320000); 185 fTCalibration->Branch("MRawEvtData.", "MRawEvtData", &fRawEvtData, 320000); 207 // FIXME: Can we calculate a good buffer size out of the event size? 208 // using splitlevel=0 sppeds up writing by a factor of 5-10% 209 fTData ->Branch("MTime", "MTime", &fRawEvtTime, 32000); 210 fTPedestal ->Branch("MTime", "MTime", &fRawEvtTime, 32000); 211 fTCalibration->Branch("MTime", "MTime", &fRawEvtTime, 32000); 212 fTData ->Branch("MRawEvtHeader", "MRawEvtHeader", &fRawEvtHeader, 32000); 213 fTPedestal ->Branch("MRawEvtHeader", "MRawEvtHeader", &fRawEvtHeader, 32000); 214 fTCalibration->Branch("MRawEvtHeader", "MRawEvtHeader", &fRawEvtHeader, 32000); 215 fTData ->Branch("MRawEvtData", "MRawEvtData", &fRawEvtData, 320000); 216 fTPedestal ->Branch("MRawEvtData", "MRawEvtData", &fRawEvtData, 320000); 217 fTCalibration->Branch("MRawEvtData", "MRawEvtData", &fRawEvtData, 320000); 186 218 //fTree->Branch("MRawCrateArray", fRawCrateArray->GetArray(), 32000, 1); 187 fTData ->Branch("MRawCrateArray .", "MRawCrateArray", &fRawCrateArray, 32000);188 fTPedestal ->Branch("MRawCrateArray .", "MRawCrateArray", &fRawCrateArray, 32000);189 fTCalibration->Branch("MRawCrateArray .", "MRawCrateArray", &fRawCrateArray, 32000);219 fTData ->Branch("MRawCrateArray", "MRawCrateArray", &fRawCrateArray, 32000); 220 fTPedestal ->Branch("MRawCrateArray", "MRawCrateArray", &fRawCrateArray, 32000); 221 fTCalibration->Branch("MRawCrateArray", "MRawCrateArray", &fRawCrateArray, 32000); 190 222 191 223 return kTRUE;
Note:
See TracChangeset
for help on using the changeset viewer.