Changeset 4368
- Timestamp:
- 06/30/04 17:55:26 (20 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsMerge.cc
r3734 r4368 53 53 // constructor. To keep track of all bad pixels the instance this pointer 54 54 // is pointing to is used to collect all bad pixels used so far. 55 // 56 // 57 // ToDo: 58 // - Take a setup file (ReadEnv-implementation) as input 55 59 // 56 60 // -
trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
r3666 r4368 72 72 #include <fstream> // ofstream, SavePrimitive 73 73 74 #include <TEnv.h> // TEnv 74 75 #include <TRint.h> // gApplication, TRint::Class() 75 76 #include <TTime.h> // TTime … … 956 957 // -------------------------------------------------------------------------- 957 958 // 959 // Calls 'ReadEnv' with a TEnv initialized with the given file name. 960 // If 'config=0' kTRUE is returned. 961 // 962 Bool_t MEvtLoop::ReadEnv(const char *config) 963 { 964 return config ? ReadEnv(TEnv(config)) : kTRUE; 965 } 966 967 // -------------------------------------------------------------------------- 968 // 958 969 // Write the contents/setup of a parameter container/task to a TEnv 959 970 // instance (steering card/setup file). -
trunk/MagicSoft/Mars/mbase/MEvtLoop.h
r2728 r4368 80 80 Bool_t WriteEnv(TEnv &env, TString prefix="", Bool_t print=kFALSE) const; 81 81 82 Bool_t ReadEnv(const char *config); 83 82 84 void RecursiveRemove(TObject *obj); 83 85 -
trunk/MagicSoft/Mars/mjobs/MJPedestal.cc
r4303 r4368 32 32 33 33 #include <TF1.h> 34 #include <TEnv.h> 34 35 #include <TFile.h> 36 #include <TLine.h> 37 #include <TLatex.h> 35 38 #include <TString.h> 36 39 #include <TCanvas.h> 37 40 #include <TSystem.h> 38 #include <TLine.h>39 41 #include <TLegend.h> 40 #include <TLatex.h>41 42 42 43 #include "MLog.h" … … 70 71 const Double_t MJPedestal::fgPedRmsMin = 0.; 71 72 const Double_t MJPedestal::fgPedRmsMax = 20.; 72 const Float_t MJPedestal::fgRefPedClosedLids = 9.635; 73 const Float_t MJPedestal::fgRefPedExtraGalactic = 9.93; 74 const Float_t MJPedestal::fgRefPedGalactic = 10.03; 75 const Float_t MJPedestal::fgRefPedRmsClosedLids = 1.7; 73 74 const Float_t MJPedestal::fgRefPedClosedLids = 9.635; 75 const Float_t MJPedestal::fgRefPedExtraGalactic = 9.93; 76 const Float_t MJPedestal::fgRefPedGalactic = 10.03; 77 const Float_t MJPedestal::fgRefPedRmsClosedLids = 1.7; 76 78 const Float_t MJPedestal::fgRefPedRmsExtraGalactic = 5.6; 77 79 const Float_t MJPedestal::fgRefPedRmsGalactic = 6.92; 80 78 81 // -------------------------------------------------------------------------- 79 82 // … … 83 86 // 84 87 MJPedestal::MJPedestal(const char *name, const char *title) 85 : f Runs(0), fExtractor(NULL), fDataCheck(kFALSE)88 : fEnv(0), fRuns(0), fExtractor(NULL), fDataCheck(kFALSE) 86 89 { 87 90 fName = name ? name : "MJPedestal"; … … 89 92 } 90 93 94 MJPedestal::~MJPedestal() 95 { 96 if (fEnv) 97 delete fEnv; 98 } 99 91 100 const char* MJPedestal::GetOutputFile() const 92 101 { 93 94 if (!fRuns) 95 return ""; 96 97 return Form("%s/%s-F0.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName()); 98 102 if (!fRuns) 103 return ""; 104 105 return Form("%s/%s-F0.root", (const char*)fOutputPath, (const char*)fRuns->GetRunsAsFileName()); 99 106 } 100 107 101 108 Bool_t MJPedestal::ReadPedestalCam() 102 109 { 103 104 110 const TString fname = GetOutputFile(); 105 111 … … 139 145 void MJPedestal::DisplayResult(MParList &plist) 140 146 { 141 142 147 if (!fDisplay) 143 148 return; … … 148 153 TString title = fDisplay->GetTitle(); 149 154 title += "-- Pedestal "; 150 title += fRuns->GetRunsAsString(); 155 if (fRuns) // FIXME: What to do if an environmentfile was used? 156 title += fRuns->GetRunsAsString(); 151 157 title += " --"; 152 158 fDisplay->SetTitle(title); … … 179 185 c3.Divide(2,3); 180 186 181 if (fDataCheck) 182 { 183 184 c3.cd(1); 185 gPad->SetBorderMode(0); 186 gPad->SetTicks(); 187 MHCamera *obj1=(MHCamera*)disp0.DrawCopy("hist"); 188 obj1->SetDirectory(NULL); 189 // 190 // for the datacheck, fix the ranges!! 191 // 192 obj1->SetMinimum(fgPedestalMin); 193 obj1->SetMaximum(fgPedestalMax); 194 // 195 // set reference lines 196 // 197 DisplayReferenceLines(obj1,0); 198 // 199 // end reference lines 200 // 201 c3.cd(3); 202 gPad->SetBorderMode(0); 203 obj1->SetPrettyPalette(); 204 obj1->Draw(); 205 206 c3.cd(5); 207 gPad->SetBorderMode(0); 208 gPad->SetTicks(); 209 obj1->DrawProjection(7); 210 211 c3.cd(2); 212 gPad->SetBorderMode(0); 213 gPad->SetTicks(); 214 MHCamera *obj2=(MHCamera*)disp1.DrawCopy("hist"); 215 obj2->SetDirectory(NULL); 216 obj2->SetMinimum(fgPedRmsMin); 217 obj2->SetMaximum(fgPedRmsMax); 218 // 219 // set reference lines 220 // 221 DisplayReferenceLines(obj1,1); 222 223 c3.cd(4); 224 gPad->SetBorderMode(0); 225 obj2->SetPrettyPalette(); 226 obj2->Draw(); 227 228 c3.cd(6); 229 gPad->SetBorderMode(0); 230 gPad->SetTicks(); 231 232 TArrayI inner(1); 233 inner[0] = 0; 234 235 TArrayI outer(1); 236 outer[0] = 1; 237 238 if (geomcam.InheritsFrom("MGeomCamMagic")) 239 { 240 TArrayI s0(6); 241 s0[0] = 6; 242 s0[1] = 1; 243 s0[2] = 2; 244 s0[3] = 3; 245 s0[4] = 4; 246 s0[5] = 5; 247 248 TArrayI s1(3); 249 s1[0] = 6; 250 s1[1] = 1; 251 s1[2] = 2; 252 253 TArrayI s2(3); 254 s2[0] = 3; 255 s2[1] = 4; 256 s2[2] = 5; 257 258 gPad->Clear(); 259 TVirtualPad *pad = gPad; 260 pad->Divide(2,1); 261 262 TH1D *inout[2]; 263 inout[0] = disp1.ProjectionS(s0, inner, "Inner"); 264 inout[1] = disp1.ProjectionS(s0, outer, "Outer"); 265 266 inout[0]->SetDirectory(NULL); 267 inout[1]->SetDirectory(NULL); 268 269 for (int i=0; i<2; i++) 270 { 271 TLegend *leg2 = new TLegend(0.6,0.2,0.9,0.55); 272 leg2->SetHeader(inout[i]->GetName()); 273 pad->cd(i+1); 274 inout[i]->SetLineColor(kRed+i); 275 inout[i]->SetBit(kCanDelete); 276 inout[i]->Draw(); 277 inout[i]->Fit("gaus","Q"); 278 leg2->AddEntry(inout[i],inout[i]->GetName(),"l"); 279 280 // 281 // Display the outliers as dead and noisy pixels 282 // 283 DisplayOutliers(inout[i]); 284 285 // 286 // Display the two half of the camera separately 287 // 288 TH1D *half[2]; 289 half[0] = disp1.ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2"); 290 half[1] = disp1.ProjectionS(s2, i==0 ? inner : outer , "Sector 3-4-5"); 291 292 for (int j=0; j<2; j++) 293 { 294 half[j]->SetLineColor(kRed+i+2*j+1); 295 half[j]->SetDirectory(NULL); 296 half[j]->SetBit(kCanDelete); 297 half[j]->Draw("same"); 298 leg2->AddEntry(half[j],half[j]->GetName(),"l"); 299 } 300 leg2->Draw(); 301 } 302 } 303 } 304 else 305 { 187 if (!fDataCheck) 188 { 306 189 disp0.CamDraw(c3, 1, 2, 1); 307 190 disp1.CamDraw(c3, 2, 2, 6); 308 } 191 return; 192 } 193 194 c3.cd(1); 195 gPad->SetBorderMode(0); 196 gPad->SetTicks(); 197 MHCamera *obj1=(MHCamera*)disp0.DrawCopy("hist"); 198 obj1->SetDirectory(NULL); 199 200 // 201 // for the datacheck, fix the ranges!! 202 // 203 obj1->SetMinimum(fgPedestalMin); 204 obj1->SetMaximum(fgPedestalMax); 205 206 // 207 // set reference lines 208 // 209 DisplayReferenceLines(obj1,0); 210 211 // 212 // end reference lines 213 // 214 c3.cd(3); 215 gPad->SetBorderMode(0); 216 obj1->SetPrettyPalette(); 217 obj1->Draw(); 218 219 c3.cd(5); 220 gPad->SetBorderMode(0); 221 gPad->SetTicks(); 222 obj1->DrawProjection(7); 223 224 c3.cd(2); 225 gPad->SetBorderMode(0); 226 gPad->SetTicks(); 227 MHCamera *obj2=(MHCamera*)disp1.DrawCopy("hist"); 228 obj2->SetDirectory(NULL); 229 obj2->SetMinimum(fgPedRmsMin); 230 obj2->SetMaximum(fgPedRmsMax); 231 232 // 233 // set reference lines 234 // 235 DisplayReferenceLines(obj1,1); 236 237 c3.cd(4); 238 gPad->SetBorderMode(0); 239 obj2->SetPrettyPalette(); 240 obj2->Draw(); 241 242 c3.cd(6); 243 gPad->SetBorderMode(0); 244 gPad->SetTicks(); 245 246 TArrayI inner(1); 247 inner[0] = 0; 248 249 TArrayI outer(1); 250 outer[0] = 1; 251 252 if (geomcam.InheritsFrom("MGeomCamMagic")) 253 { 254 TArrayI s0(6); 255 s0[0] = 6; 256 s0[1] = 1; 257 s0[2] = 2; 258 s0[3] = 3; 259 s0[4] = 4; 260 s0[5] = 5; 261 262 TArrayI s1(3); 263 s1[0] = 6; 264 s1[1] = 1; 265 s1[2] = 2; 266 267 TArrayI s2(3); 268 s2[0] = 3; 269 s2[1] = 4; 270 s2[2] = 5; 271 272 gPad->Clear(); 273 TVirtualPad *pad = gPad; 274 pad->Divide(2,1); 275 276 TH1D *inout[2]; 277 inout[0] = disp1.ProjectionS(s0, inner, "Inner"); 278 inout[1] = disp1.ProjectionS(s0, outer, "Outer"); 279 280 inout[0]->SetDirectory(NULL); 281 inout[1]->SetDirectory(NULL); 282 283 for (int i=0; i<2; i++) 284 { 285 TLegend *leg2 = new TLegend(0.6,0.2,0.9,0.55); 286 leg2->SetHeader(inout[i]->GetName()); 287 pad->cd(i+1); 288 inout[i]->SetLineColor(kRed+i); 289 inout[i]->SetBit(kCanDelete); 290 inout[i]->Draw(); 291 inout[i]->Fit("gaus","Q"); 292 leg2->AddEntry(inout[i],inout[i]->GetName(),"l"); 293 294 // 295 // Display the outliers as dead and noisy pixels 296 // 297 DisplayOutliers(inout[i]); 298 299 // 300 // Display the two half of the camera separately 301 // 302 TH1D *half[2]; 303 half[0] = disp1.ProjectionS(s1, i==0 ? inner : outer , "Sector 6-1-2"); 304 half[1] = disp1.ProjectionS(s2, i==0 ? inner : outer , "Sector 3-4-5"); 305 306 for (int j=0; j<2; j++) 307 { 308 half[j]->SetLineColor(kRed+i+2*j+1); 309 half[j]->SetDirectory(NULL); 310 half[j]->SetBit(kCanDelete); 311 half[j]->Draw("same"); 312 leg2->AddEntry(half[j],half[j]->GetName(),"l"); 313 } 314 leg2->Draw(); 315 } 316 } 309 317 } 310 318 311 319 void MJPedestal::DisplayReferenceLines(MHCamera *cam, const Int_t what) const 312 320 { 313 314 TLine *gala = new TLine(0, 315 what ? fgRefPedRmsGalactic : fgRefPedGalactic,cam->GetNbinsX(), 316 what ? fgRefPedRmsGalactic : fgRefPedGalactic); 317 gala->SetBit(kCanDelete); 318 gala->SetLineColor(4); 319 gala->SetLineStyle(2); 320 gala->SetLineWidth(3); 321 gala->Draw(); 322 TLine *extr = new TLine(0, 323 what ? fgRefPedRmsExtraGalactic : fgRefPedExtraGalactic,cam->GetNbinsX(), 324 what ? fgRefPedRmsExtraGalactic : fgRefPedExtraGalactic); 325 extr->SetBit(kCanDelete); 326 extr->SetLineColor(5); 327 extr->SetLineStyle(2); 328 extr->SetLineWidth(3); 329 extr->Draw(); 330 TLine *close = new TLine(0, 331 what ? fgRefPedRmsClosedLids : fgRefPedClosedLids,cam->GetNbinsX(), 332 what ? fgRefPedRmsClosedLids : fgRefPedClosedLids); 333 close->SetBit(kCanDelete); 334 close->SetLineColor(6); 335 close->SetLineStyle(2); 336 close->SetLineWidth(3); 337 close->Draw(); 338 TLegend *leg = new TLegend(0.4,0.75,0.7,0.99); 339 leg->SetBit(kCanDelete); 340 leg->AddEntry(gala,"Galactic Source","l"); 341 leg->AddEntry(extr,"Extra-Galactic Source","l"); 342 leg->AddEntry(close,"Closed Lids","l"); 343 leg->Draw(); 321 const Double_t x = cam->GetNbinsX(); 322 323 TLine line; 324 line.SetLineStyle(kDashed); 325 line.SetLineWidth(3); 326 327 line.SetLineColor(kBlue); 328 TLine *l1 = line.DrawLine(0, what ? fgRefPedRmsGalactic : fgRefPedGalactic, 329 x, what ? fgRefPedRmsGalactic : fgRefPedGalactic); 330 331 line.SetLineColor(kYellow); 332 TLine *l2 = line.DrawLine(0, what ? fgRefPedRmsExtraGalactic : fgRefPedExtraGalactic, 333 x, what ? fgRefPedRmsExtraGalactic : fgRefPedExtraGalactic); 334 335 line.SetLineColor(kMagenta); 336 TLine *l3 = line.DrawLine(0, what ? fgRefPedRmsClosedLids : fgRefPedClosedLids, 337 x, what ? fgRefPedRmsClosedLids : fgRefPedClosedLids); 338 339 340 TLegend *leg = new TLegend(0.4,0.75,0.7,0.99); 341 leg->SetBit(kCanDelete); 342 leg->AddEntry(l1, "Galactic Source","l"); 343 leg->AddEntry(l2, "Extra-Galactic Source","l"); 344 leg->AddEntry(l3, "Closed Lids","l"); 345 leg->Draw(); 344 346 } 345 347 346 348 void MJPedestal::DisplayOutliers(TH1D *hist) const 347 349 { 348 349 const Float_t mean = hist->GetFunction("gaus")->GetParameter(1); 350 const Float_t lolim = mean - 3.5*hist->GetFunction("gaus")->GetParameter(2); 351 const Float_t uplim = mean + 3.5*hist->GetFunction("gaus")->GetParameter(2); 352 const Stat_t dead = hist->Integral(0,hist->FindBin(lolim)-1); 353 const Stat_t noisy = hist->Integral(hist->FindBin(uplim)+1,hist->GetNbinsX()+1); 354 355 TLatex deadtex; 356 deadtex.SetTextSize(0.06); 357 deadtex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.1,Form("%3i dead pixels",(Int_t)dead)); 358 359 TLatex noisytex; 360 noisytex.SetTextSize(0.06); 361 noisytex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.2,Form("%3i noisy pixels",(Int_t)noisy)); 362 350 const Float_t mean = hist->GetFunction("gaus")->GetParameter(1); 351 const Float_t lolim = mean - 3.5*hist->GetFunction("gaus")->GetParameter(2); 352 const Float_t uplim = mean + 3.5*hist->GetFunction("gaus")->GetParameter(2); 353 const Stat_t dead = hist->Integral(0,hist->FindBin(lolim)-1); 354 const Stat_t noisy = hist->Integral(hist->FindBin(uplim)+1,hist->GetNbinsX()+1); 355 356 TLatex deadtex; 357 deadtex.SetTextSize(0.06); 358 deadtex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.1,Form("%3i dead pixels",(Int_t)dead)); 359 360 TLatex noisytex; 361 noisytex.SetTextSize(0.06); 362 noisytex.DrawLatex(0.1,hist->GetBinContent(hist->GetMaximumBin())/1.2,Form("%3i noisy pixels",(Int_t)noisy)); 363 363 } 364 364 … … 402 402 } 403 403 404 void MJPedestal::SetEnv(const char *env) 405 { 406 if (fEnv) 407 delete fEnv; 408 fEnv = new TEnv(env); 409 } 410 404 411 Bool_t MJPedestal::Process() 405 412 { … … 412 419 Bool_t MJPedestal::ProcessFile() 413 420 { 414 if (!fRuns )415 { 416 *fLog << err << "N o Runs choosen... abort." << endl;417 return kFALSE; 418 } 419 if (fRuns ->GetNumRuns() != fRuns->GetNumEntries())421 if (!fRuns && !fEnv) 422 { 423 *fLog << err << "Neither AddRuns was called nor SetEnv was used... abort." << endl; 424 return kFALSE; 425 } 426 if (fRuns && fRuns->GetNumRuns() != fRuns->GetNumEntries()) 420 427 { 421 428 *fLog << err << "Number of files found doesn't match number of runs... abort." << endl; … … 425 432 *fLog << inf; 426 433 fLog->Separator(GetDescriptor()); 427 *fLog << "Calculate MPedestalCam from Runs " << fRuns->GetRunsAsString() << endl; 434 *fLog << "Calculate MPedestalCam from Runs "; 435 if (fRuns) 436 *fLog << fRuns->GetRunsAsString() << endl; 437 else 438 *fLog << "in " << fEnv->GetName() << endl; 428 439 *fLog << endl; 429 440 … … 437 448 if (fDataCheck) 438 449 { 439 rawread.AddFiles(*fRuns); 450 if (fRuns) 451 rawread.AddFiles(*fRuns); 440 452 tlist.AddToList(&rawread); 441 453 } 442 454 else 443 455 { 444 read.DisableAutoScheme(); 445 static_cast<MRead&>(read).AddFiles(*fRuns); 456 read.DisableAutoScheme(); 457 if (fRuns) 458 static_cast<MRead&>(read).AddFiles(*fRuns); 446 459 tlist.AddToList(&read); 447 460 } … … 454 467 455 468 MGeomApply geomapl; 456 //MBadPixelsMerge merge(&fBadPixels);469 MBadPixelsMerge merge(&fBadPixels); 457 470 MPedCalcPedRun pedcalc; 458 471 459 472 if (fExtractor) 460 473 { 461 474 pedcalc.SetWindowSize((Int_t)fExtractor->GetNumHiGainSamples()); 462 475 pedcalc.SetRange(fExtractor->GetHiGainFirst(), fExtractor->GetHiGainLast()); 463 476 } 464 477 else 465 466 *fLog << warn << GetDescriptor() 467 468 478 { 479 *fLog << warn << GetDescriptor(); 480 *fLog << ": No extractor has been chosen, take default number of FADC samples " << endl; 481 } 469 482 470 483 tlist.AddToList(&geomapl); 471 // tlist.AddToList(&merge); 472 //tlist.AddToList(&sigcalc); 484 tlist.AddToList(&merge); 473 485 tlist.AddToList(&pedcalc); 474 486 … … 480 492 evtloop.SetDisplay(fDisplay); 481 493 evtloop.SetLogStream(fLog); 494 if (fEnv) 495 evtloop.ReadEnv(*fEnv); 482 496 483 497 // Execute first analysis -
trunk/MagicSoft/Mars/mjobs/MJPedestal.h
r4303 r4368 9 9 #endif 10 10 11 class TEnv; 11 12 class TCanvas; 12 13 class MParList; … … 15 16 class TH1D; 16 17 class MExtractor; 17 class MJPedestal : public MParContainer 18 19 class MJPedestal : public MParContainer 18 20 { 19 21 private: 22 static const Double_t fgPedestalMin; 23 static const Double_t fgPedestalMax; 24 static const Double_t fgPedRmsMin; 25 static const Double_t fgPedRmsMax; 20 26 21 static const Double_t fgPedestalMin; 22 static const Double_t fgPedestalMax; 23 static const Double_t fgPedRmsMin; 24 static const Double_t fgPedRmsMax; 27 static const Float_t fgRefPedClosedLids; 28 static const Float_t fgRefPedExtraGalactic; 29 static const Float_t fgRefPedGalactic; 25 30 26 static const Float_t fgRefPedClosedLids;27 static const Float_t fgRefPedExtraGalactic;28 static const Float_t fgRefPedGalactic;31 static const Float_t fgRefPedRmsClosedLids; 32 static const Float_t fgRefPedRmsExtraGalactic; 33 static const Float_t fgRefPedRmsGalactic; 29 34 30 static const Float_t fgRefPedRmsClosedLids; 31 static const Float_t fgRefPedRmsExtraGalactic; 32 static const Float_t fgRefPedRmsGalactic; 35 TString fOutputPath; 33 36 34 TString fOutputPath; 35 36 MRunIter *fRuns; 37 MExtractor *fExtractor; // Signal extractor, used to find the nr. of used FADC slices 37 TEnv *fEnv; // Input setup-file 38 38 39 MPedestalCam fPedestalCam; 40 MBadPixelsCam fBadPixels; 41 42 Bool_t fDataCheck; // Flag if the data check is run on raw data 43 44 Bool_t ReadPedestalCam(); 45 Bool_t WriteResult(); 46 47 void DisplayResult(MParList &plist); 48 void DisplayReferenceLines(MHCamera *cam, const Int_t what) const; 49 void DisplayOutliers( TH1D *hist) const; 50 39 MRunIter *fRuns; 40 MExtractor *fExtractor; // Signal extractor, used to find the nr. of used FADC slices 41 42 MPedestalCam fPedestalCam; 43 MBadPixelsCam fBadPixels; 44 45 Bool_t fDataCheck; // Flag if the data check is run on raw data 46 47 Bool_t ReadPedestalCam(); 48 Bool_t WriteResult(); 49 50 void DisplayResult(MParList &plist); 51 void DisplayReferenceLines(MHCamera *cam, const Int_t what) const; 52 void DisplayOutliers(TH1D *hist) const; 53 51 54 public: 55 MJPedestal(const char *name=NULL, const char *title=NULL); 56 ~MJPedestal(); 52 57 53 MJPedestal(const char *name=NULL, const char *title=NULL); 58 MPedestalCam &GetPedestalCam() { return fPedestalCam; } 59 const MBadPixelsCam &GetBadPixels() const { return fBadPixels; } 54 60 55 MPedestalCam &GetPedestalCam() { return fPedestalCam; } 56 const MBadPixelsCam &GetBadPixels() const { return fBadPixels; } 57 58 const char* GetOutputFile() const; 59 const Bool_t IsDataCheck() const { return fDataCheck; } 60 61 Bool_t Process(); 62 Bool_t ProcessFile(); 63 64 void SetBadPixels ( const MBadPixelsCam &bad) { bad.Copy(fBadPixels); } 65 void SetDataCheck ( const Bool_t b=kTRUE ) { fDataCheck = b; } 66 void SetExtractor ( MExtractor* ext ) { fExtractor = ext; } 67 void SetInput ( MRunIter *iter ) { fRuns = iter; } 68 void SetOutputPath( const char *path="." ); 69 70 ClassDef(MJPedestal, 0) // Tool to create a pedestal file (MPedestalCam) 61 const char* GetOutputFile() const; 62 const Bool_t IsDataCheck() const { return fDataCheck; } 63 64 Bool_t Process(); 65 Bool_t ProcessFile(); 66 67 void SetBadPixels(const MBadPixelsCam &bad) { bad.Copy(fBadPixels); } 68 void SetExtractor(MExtractor* ext ) { fExtractor = ext; } 69 void SetInput(MRunIter *iter) { fRuns = iter; } 70 void SetOutputPath(const char *path="."); 71 void SetEnv(const char *env); 72 73 void SetDataCheck(const Bool_t b=kTRUE) { fDataCheck = b; } 74 75 ClassDef(MJPedestal, 0) // Tool to create a pedestal file (MPedestalCam) 71 76 }; 72 77 -
trunk/MagicSoft/Mars/mpedestal/MPedCalcPedRun.cc
r4288 r4368 101 101 // fLoGainWindowSize = fgLoGainWindowSize = 0 102 102 // 103 // 104 // ToDo: 105 // - Take a setup file (ReadEnv-implementation) as input 106 // 107 // 103 108 // Input Containers: 104 109 // MRawEvtData -
trunk/MagicSoft/Mars/msignal/MExtractor.cc
r4340 r4368 25 25 ////////////////////////////////////////////////////////////////////////////// 26 26 // 27 // MExtractor 27 // MExtractor 28 // ========== 28 29 // 29 30 // Base class for the signal extractors, used the functions … … 38 39 // - fSqrtLoGainSamples 39 40 // 41 // The signal extractor classes can be setup from an environmental 42 // setup file. For more information see ReadEnv and MEvtLoop::ReadEnv 43 // 40 44 // Input Containers: 41 45 // MRawEvtData … … 71 75 72 76 const Byte_t MExtractor::fgSaturationLimit = 254; 77 73 78 // -------------------------------------------------------------------------- 74 79 // … … 88 93 fSaturationLimit(fgSaturationLimit) 89 94 { 90 91 95 fName = name ? name : "MExtractor"; 92 96 fTitle = title ? title : "Base class for signal extractors"; … … 99 103 void MExtractor::SetRange(Byte_t hifirst, Byte_t hilast, Byte_t lofirst, Byte_t lolast) 100 104 { 101 102 fHiGainFirst = hifirst; 103 fHiGainLast = hilast; 104 105 fLoGainFirst = lofirst; 106 fLoGainLast = lolast; 107 108 } 109 105 fHiGainFirst = hifirst; 106 fHiGainLast = hilast; 107 108 fLoGainFirst = lofirst; 109 fLoGainLast = lolast; 110 } 110 111 111 112 // -------------------------------------------------------------------------- … … 123 124 Int_t MExtractor::PreProcess(MParList *pList) 124 125 { 125 126 126 fRawEvt = (MRawEvtData*)pList->FindObject(AddSerialNumber("MRawEvtData")); 127 127 if (!fRawEvt) … … 178 178 Bool_t MExtractor::ReInit(MParList *pList) 179 179 { 180 181 Int_t lastdesired = (Int_t)(fLoGainLast); 182 Int_t lastavailable = (Int_t)fRunHeader->GetNumSamplesLoGain()-1; 183 184 if (lastavailable < 0) 185 *fLog << warn << GetDescriptor() 186 << ": WARNING: Number of available Low-Gain Slices is smaller than or equal zero!" << endl; 187 180 Int_t lastdesired = (Int_t)(fLoGainLast); 181 Int_t lastavailable = (Int_t)fRunHeader->GetNumSamplesLoGain()-1; 182 183 if (lastavailable < 0) 184 *fLog << warn << GetDescriptor() << " - WARNING: Number of available Low-Gain Slices is smaller than or equal zero!" << endl; 185 186 if (lastdesired > lastavailable) 187 { 188 const Int_t diff = lastdesired - lastavailable; 189 190 *fLog << endl; 191 *fLog << warn << GetDescriptor() << ": Selected Lo Gain FADC Window ["; 192 *fLog << Form("%2i,%2i", (int)fLoGainFirst, lastdesired); 193 *fLog << "] ranges out of the available limits: [0," << Form("%2i", lastavailable) << "]" << endl; 194 *fLog << GetDescriptor() << ": Will reduce the upper edge to " << (int)(fLoGainLast - diff) << endl; 195 SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff); 196 } 197 198 lastdesired = (Int_t)fHiGainLast; 199 lastavailable = (Int_t)fRunHeader->GetNumSamplesHiGain()-1; 200 201 if (lastavailable < 0) 202 { 203 *fLog << err << GetDescriptor(); 204 *fLog << " - ERROR: Number of available High-Gain Slices is smaller than or equal zero!" << endl; 205 return kFALSE; 206 } 207 188 208 if (lastdesired > lastavailable) 189 209 { 190 210 const Int_t diff = lastdesired - lastavailable; 191 *fLog << endl; 192 *fLog << warn << GetDescriptor() 193 << Form("%s%2i%s%2i%s%2i%s",": Selected Lo Gain FADC Window [", 194 (int)fLoGainFirst,",",lastdesired, 195 "] ranges out of the available limits: [0,",lastavailable,"].") << endl; 196 *fLog << GetDescriptor() << ": Will reduce the upper edge to " << (int)(fLoGainLast - diff) << endl; 197 SetRange(fHiGainFirst, fHiGainLast, fLoGainFirst, fLoGainLast-diff); 198 } 199 200 lastdesired = (Int_t)fHiGainLast; 201 lastavailable = (Int_t)fRunHeader->GetNumSamplesHiGain()-1; 202 203 if (lastavailable < 0) 204 { 205 *fLog << err << GetDescriptor() 206 << ": ERROR: Number of available High-Gain Slices is smaller than or equal zero!" << endl; 207 return kFALSE; 208 } 209 210 if (lastdesired > lastavailable) 211 { 212 const Int_t diff = lastdesired - lastavailable; 211 213 212 *fLog << endl; 214 *fLog << warn << GetDescriptor() 215 << Form("%s%2i%s%2i%s%2i%s",": Selected Hi Gain FADC Window [",216 (int)fHiGainFirst,",",lastdesired,217 "] ranges out of the available limits: [0,",lastavailable,"].") << endl;218 *fLog << warn << GetDescriptor()219 << Form("%s%2i%s",": Will use ",diff," samples from the Low-Gain for the High-Gain extraction")220 << endl; 213 *fLog << warn << GetDescriptor() << ": Selected Hi Gain FADC Window ["; 214 *fLog << Form("%2i,%2i%s%2i%s", (int)fHiGainFirst,",",lastdesired); 215 *fLog << "] ranges out of the available limits: [0," << Form("%2i", lastavailable) << "]" << endl; 216 *fLog << warn << GetDescriptor() << ": Will use "; 217 *fLog << Form("%2i", diff) << " samples from the Low-Gain for the High-Gain extraction"; 218 *fLog << endl; 219 221 220 fHiGainLast -= diff; 222 221 fHiLoLast = diff; 223 222 } 224 223 225 224 return kTRUE; 226 }227 228 229 230 void MExtractor::FindSignalHiGain(Byte_t *firstused, Byte_t *logain, Float_t &sum, Byte_t &sat) const231 {232 return;233 }234 235 void MExtractor::FindSignalLoGain(Byte_t *firstused, Float_t &sum, Byte_t &sat) const236 {237 return;238 225 } 239 226 … … 245 232 Int_t MExtractor::Process() 246 233 { 247 248 234 MRawEvtPixelIter pixel(fRawEvt); 249 235 fSignals->Clear(); … … 290 276 void MExtractor::StreamPrimitive(ofstream &out) const 291 277 { 292 293 278 out << " " << ClassName() << " " << GetUniqueName() << "(\""; 294 279 out << "\"" << fName << "\", \"" << fTitle << "\");" << endl; 295 280 296 281 if (fSaturationLimit!=fgSaturationLimit) 297 282 { 298 283 out << " " << GetUniqueName() << ".SetSaturationLimit("; 299 284 out << (int)fSaturationLimit << ");" << endl; 300 285 } 301 286 302 287 out << " " << GetUniqueName() << ".SetRange("; … … 308 293 } 309 294 295 // -------------------------------------------------------------------------- 296 // 297 // Read the setup from a TEnv, eg: 298 // MJPedestal.MExtractor.HiGainFirst: 5 299 // MJPedestal.MExtractor.LoGainFirst: 5 300 // MJPedestal.MExtractor.HiGainLast: 10 301 // MJPedestal.MExtractor.LoGainLast: 10 302 // MJPedestal.MExtractor.SaturationLimit: 88 303 // 304 Bool_t MExtractor::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 305 { 306 Byte_t hf = fHiGainFirst; 307 Byte_t lf = fLoGainFirst; 308 Byte_t hl = fHiGainLast; 309 Byte_t ll = fLoGainLast; 310 311 if (IsEnvDefined(env, prefix, "HiGainFirst", print)) 312 hf = GetEnvValue(env, prefix, "HiGainFirst", hf); 313 if (IsEnvDefined(env, prefix, "LoGainFirst", print)) 314 lf = GetEnvValue(env, prefix, "LoGainFirst", lf); 315 316 if (IsEnvDefined(env, prefix, "HiGainLast", print)) 317 hl = GetEnvValue(env, prefix, "HiGainLast", hl); 318 if (IsEnvDefined(env, prefix, "LoGainLast", print)) 319 ll = GetEnvValue(env, prefix, "LoGainLast", ll); 320 321 SetRange(hf, hl, lf, ll); 322 323 if (IsEnvDefined(env, prefix, "SaturationLimit", print)) 324 SetSaturationLimit(GetEnvValue(env, prefix, "SaturationLimit", fSaturationLimit)); 325 326 return kTRUE; 327 } -
trunk/MagicSoft/Mars/msignal/MExtractor.h
r4339 r4368 47 47 Byte_t fSaturationLimit; 48 48 49 virtual void FindSignalHiGain(Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat) const ;50 virtual void FindSignalLoGain(Byte_t *firstused, Float_t &sum, Byte_t &sat) const ;49 virtual void FindSignalHiGain(Byte_t *firstused, Byte_t *lowgain, Float_t &sum, Byte_t &sat) const { } 50 virtual void FindSignalLoGain(Byte_t *firstused, Float_t &sum, Byte_t &sat) const { } 51 51 52 virtual Int_t PreProcess(MParList *pList); 53 virtual Bool_t ReInit(MParList *pList); 54 virtual Int_t Process(); 55 virtual void StreamPrimitive(ofstream &out) const; 52 Int_t PreProcess(MParList *pList); 53 Bool_t ReInit(MParList *pList); 54 Int_t Process(); 55 void StreamPrimitive(ofstream &out) const; 56 Bool_t ReadEnv(const TEnv &env, TString prefix, Bool_t print); 56 57 57 58 public: 58 59 59 MExtractor(const char *name=NULL, const char *title=NULL); 60 60 61 Byte_t GetHiGainFirst() const 62 Byte_t GetHiGainLast () const 63 Byte_t GetLoGainFirst() const 64 Byte_t GetLoGainLast () const 65 Float_t GetNumHiGainSamples() const 66 Float_t GetNumLoGainSamples() const 61 Byte_t GetHiGainFirst() const { return fHiGainFirst; } 62 Byte_t GetHiGainLast () const { return fHiGainLast ; } 63 Byte_t GetLoGainFirst() const { return fLoGainFirst; } 64 Byte_t GetLoGainLast () const { return fLoGainLast ; } 65 Float_t GetNumHiGainSamples() const { return fNumHiGainSamples; } 66 Float_t GetNumLoGainSamples() const { return fNumLoGainSamples; } 67 67 68 68 virtual void SetRange (Byte_t hifirst=0, Byte_t hilast=0, Byte_t lofirst=0, Byte_t lolast=0);
Note:
See TracChangeset
for help on using the changeset viewer.