Changeset 5233 for trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
- Timestamp:
- 10/12/04 11:11:50 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
r5161 r5233 88 88 // Default constructor. 89 89 // 90 // Sets fRuns to 0, fExtractor to NULL, fDataCheck to kFALSE 90 // Sets: 91 // - fRuns to 0, 92 // - fExtractor to NULL, 93 // - fDataCheck to kFALSE, 94 // - fUseData to kFALSE 95 // - fStorage to kNormalStorage 91 96 // 92 97 MJPedestal::MJPedestal(const char *name, const char *title) … … 94 99 fDataCheck(kFALSE), fUseData(kFALSE) 95 100 { 96 fName = name ? name : "MJPedestal"; 97 fTitle = title ? title : "Tool to create a pedestal file (MPedestalCam)"; 101 102 fName = name ? name : "MJPedestal"; 103 fTitle = title ? title : "Tool to create a pedestal file (MPedestalCam)"; 104 105 SetNormalStorage(); 98 106 } 99 107 … … 109 117 } 110 118 119 //--------------------------------------------------------------------------------- 120 // 121 // Try to read an existing MPedestalCam from a previously created output file. 122 // If found, also an MBadPixelsCam and the corresponding display is read. 123 // 124 // In case of Storage type "kNoStorage" or if the file is not found or the 125 // MPedestalCam cannot be read, return kFALSE, otherwise kTRUE. 126 // 111 127 Bool_t MJPedestal::ReadPedestalCam() 112 128 { 113 const TString fname = GetOutputFile(); 114 115 if (gSystem->AccessPathName(fname, kFileExists)) 116 { 117 *fLog << warn << "Input file " << fname << " doesn't exist, will create it." << endl; 118 return kFALSE; 119 } 120 121 *fLog << inf << "Reading from file: " << fname << endl; 122 123 TFile file(fname, "READ"); 124 if (fPedestalCam.Read()<=0) 125 { 126 *fLog << err << "Unable to read MPedestalCam from " << fname << endl; 127 return kFALSE; 128 } 129 130 if (file.FindKey("MBadPixelsCam")) 131 { 132 MBadPixelsCam bad; 129 130 if (IsNoStorage()) 131 return kFALSE; 132 133 const TString fname = GetOutputFile(); 134 135 if (gSystem->AccessPathName(fname, kFileExists)) 136 { 137 *fLog << warn << "Input file " << fname << " doesn't exist, will create it." << endl; 138 return kFALSE; 139 } 140 141 *fLog << inf << "Reading from file: " << fname << endl; 142 143 TFile file(fname, "READ"); 144 if (fPedestalCam.Read()<=0) 145 { 146 *fLog << err << "Unable to read MPedestalCam from " << fname << endl; 147 return kFALSE; 148 } 149 150 if (file.FindKey("MBadPixelsCam")) 151 { 152 MBadPixelsCam bad; 133 153 if (bad.Read()<=0) 134 {154 { 135 155 *fLog << err << "Unable to read MBadPixelsCam from " << fname << endl; 136 156 return kFALSE; 137 }157 } 138 158 fBadPixels.Merge(bad); 139 159 } 140 160 141 if (fDisplay && !fDisplay->GetCanvas("Pedestals")) 142 fDisplay->Read(); 143 144 return kTRUE; 145 } 146 161 if (fDisplay && !fDisplay->GetCanvas("Pedestals")) 162 fDisplay->Read(); 163 164 return kTRUE; 165 } 166 167 //--------------------------------------------------------------------------------- 168 // 169 // Display the results. 170 // If Display type "kDataCheck" was chosen, also the reference lines are displayed. 171 // 147 172 void MJPedestal::DisplayResult(MParList &plist) 148 173 { … … 480 505 } 481 506 507 //--------------------------------------------------------------------------------- 508 // 509 // Try to write the created MPedestalCam in the output file. 510 // If possible, also an MBadPixelsCam and the corresponding display is written. 511 // 512 // In case of Storage type "kNoStorage" or if any of the containers 513 // cannot be written, return kFALSE, otherwise kTRUE. 514 // 482 515 Bool_t MJPedestal::WriteResult() 483 516 { 484 if (fPathOut.IsNull()) 485 return kTRUE; 486 487 const TString oname(GetOutputFile()); 488 489 *fLog << inf << "Writing to file: " << oname << endl; 490 491 TFile file(oname, "UPDATE", "File created by MJPedestal", 9); 492 if (!file.IsOpen()) 493 { 494 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl; 495 return kFALSE; 496 } 497 498 if (fDisplay && fDisplay->Write()<=0) 499 { 500 *fLog << err << "Unable to write MStatusDisplay to " << oname << endl; 501 return kFALSE; 502 } 503 504 if (fPedestalCam.Write()<=0) 505 { 506 *fLog << err << "Unable to write MPedestalCam to " << oname << endl; 507 return kFALSE; 508 } 509 510 if (fBadPixels.Write()<=0) 511 { 512 *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl; 513 return kFALSE; 514 } 515 517 518 if (IsNoStorage()) 516 519 return kTRUE; 520 521 if (fPathOut.IsNull()) 522 return kTRUE; 523 524 const TString oname(GetOutputFile()); 525 526 *fLog << inf << "Writing to file: " << oname << endl; 527 528 TFile file(oname, "UPDATE", "File created by MJPedestal", 9); 529 if (!file.IsOpen()) 530 { 531 *fLog << err << "ERROR - Couldn't open file " << oname << " for writing..." << endl; 532 return kFALSE; 533 } 534 535 if (fDisplay && fDisplay->Write()<=0) 536 { 537 *fLog << err << "Unable to write MStatusDisplay to " << oname << endl; 538 return kFALSE; 539 } 540 541 if (fPedestalCam.Write()<=0) 542 { 543 *fLog << err << "Unable to write MPedestalCam to " << oname << endl; 544 return kFALSE; 545 } 546 547 if (fBadPixels.Write()<=0) 548 { 549 *fLog << err << "Unable to write MBadPixelsCam to " << oname << endl; 550 return kFALSE; 551 } 552 553 return kTRUE; 517 554 } 518 555
Note:
See TracChangeset
for help on using the changeset viewer.