Changeset 17075 for trunk/Mars/fact
- Timestamp:
- 09/05/13 11:34:42 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/fact/analysis/gain/fit_spectra.C
r17053 r17075 9 9 #include <TStyle.h> 10 10 11 #include "MLog.h" 12 #include "MLogManip.h" 11 13 #include "MStatusArray.h" 12 14 #include "MStatusDisplay.h" … … 15 17 #include "MParameters.h" 16 18 #include "MArrayI.h" 19 #include "MRawRunHeader.h" 17 20 18 21 using namespace std; … … 140 143 if (file.IsZombie()) 141 144 { 142 cout<< "Opening file '" << filename << "' failed." << endl;145 gLog << err << "Opening file '" << filename << "' failed." << endl; 143 146 return 1; 144 147 } … … 147 150 if (arr.Read()<=0) 148 151 { 149 cout<< "Reading of MStatusArray from '" << filename << "' failed." << endl;152 gLog << err << "Reading of MStatusArray from '" << filename << "' failed." << endl; 150 153 return 2; 151 154 } … … 154 157 if (!hsignal) 155 158 { 156 cout<< "Histogram Signal not found in '" << filename << "'." << endl;159 gLog << err << "Histogram Signal not found in '" << filename << "'." << endl; 157 160 return 3; 158 161 } … … 160 163 if (!htime) 161 164 { 162 cout<< "Histogram Time not found in '" << filename << "'." << endl;163 return 3;165 gLog << err << "Histogram Time not found in '" << filename << "'." << endl; 166 return 4; 164 167 } 165 168 TProfile2D *hpulse = (TProfile2D*)arr.FindObjectInCanvas("Pulse", "TProfile2D", "MHSingles"); 166 169 if (!hpulse) 167 170 { 168 cout<< "Histogram Pulse not found in '" << filename << "'." << endl;169 return 3;171 gLog << err << "Histogram Pulse not found in '" << filename << "'." << endl; 172 return 5; 170 173 } 171 174 TH2F *hbase = (TH2F*)arr.FindObjectInCanvas("Baseline", "TH2F", "MHBaseline"); 172 175 if (!hbase) 173 176 { 174 cout << "Histogram Baseline not found in '" << filename << "'." << endl; 175 return 3; 177 gLog << err << "Histogram Baseline not found in '" << filename << "'." << endl; 178 return 6; 179 } 180 181 MRawRunHeader header; 182 if (header.Read()<=0) 183 { 184 gLog << err << "MRawRunheader not found in '" << filename << "'." << endl; 185 return 7; 176 186 } 177 187 … … 179 189 if (par.Read()<=0) 180 190 { 181 cout<< "NumEvents not found in '" << filename << "'." << endl;182 return 4;191 gLog << err << "NumEvents not found in '" << filename << "'." << endl; 192 return 8; 183 193 } 184 194 … … 186 196 if (ext.Read("ExtractionRange")<=0) 187 197 { 188 cout<< "ExtractionRange not found in '" << filename << "'." << endl;189 return 5;198 gLog << err << "ExtractionRange not found in '" << filename << "'." << endl; 199 return 9; 190 200 191 201 } … … 226 236 227 237 // Instantiate 1D histograms for the distributions 228 TH1F hRate ("Rate", "Dark count rate", 1 00, 0, 10);238 TH1F hRate ("Rate", "Dark count rate", 150, 0, 15); 229 239 TH1F hGain ("Gain", "Gain distribution", 100, 0, 400); 230 240 TH1F hRelSigma ("RelSigma", "Rel. Sigma", 160, 0, 0.40); … … 317 327 if (fwhmSum==0) 318 328 { 319 cout<< "Could not determine start value for sigma." << endl;329 gLog << warn << "Could not determine start value for sigma." << endl; 320 330 } 321 331 … … 393 403 if (hist->GetEntries()<100) 394 404 { 395 cout<< pixel << " ...histogram empty." << endl;405 gLog << warn << pixel << " ...histogram empty." << endl; 396 406 usePixel[pixel] = 0; 397 407 delete hist; … … 488 498 // mark pixels suspicious with failed fit 489 499 if (!ok) 490 cout<< pixel << " ...fit failed!" << endl;500 gLog << warn << pixel << " ...fit failed!" << endl; 491 501 492 502 // mark pixels suspicious with negative GainRMS 493 503 if (fabs(fGain/gain-1)>0.3) 494 504 { 495 cout<< pixel << " ...gain deviates more than 30% from sum-gain." << endl;505 gLog << warn << pixel << " ...gain deviates more than 30% from sum-gain." << endl; 496 506 ok = 0; 497 507 } … … 499 509 if (fabs(fOffset/integration_window)>3) 500 510 { 501 cout<< pixel << " ...baseline deviates." << endl;511 gLog << warn << pixel << " ...baseline deviates." << endl; 502 512 ok = 0; 503 513 } … … 548 558 hNormGain.Fill( fGain/gain); 549 559 hFitProb.Fill( fit_prob); 560 hCrosstalkP.Fill(fCrosstalkP); 561 hCoeffR.Fill( fCoeffR); 550 562 551 563 // Fill sum spectrum … … 771 783 // ================================================================ 772 784 773 cout << " saving results to rootfile" << endl;785 cout << "Saving results to '" << outfile << "'" << endl; 774 786 d->SaveAs(outfile); 775 787 cout << "..success!" << endl; … … 778 790 par.Write(); 779 791 ext.Write("ExtractionRange"); 792 header.Write(); 780 793 781 794 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.