Changeset 4368 for trunk/MagicSoft/Mars/mjobs
- Timestamp:
- 06/30/04 17:55:26 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mjobs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.