Changeset 9317 for trunk/MagicSoft/Mars/mjobs/MJSimulation.cc
- Timestamp:
- 02/11/09 12:36:28 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MJSimulation.cc
r9309 r9317 34 34 // 35 35 // 36 // To switch off the simulation of the camera electronics, use: 37 // 38 // Camera: Off 39 // 40 // Note, that the border of the camera and the propertied of the cones 41 // are still simulated (simply because it is fast). Furthermore, this 42 // switches off the trigger for the output, i.e. all data which deposits 43 // at least one photon in at least one pixel is written to the output file. 44 // 45 // 36 46 // In case of a pedestal or calibration run the artificial trigger can 37 47 // be "switched off" and the cosmics trrigger "switched on" by setting … … 45 55 46 56 #include <TEnv.h> 57 #include <TCanvas.h> 47 58 48 59 // Core … … 86 97 87 98 #include "MHn.h" 99 #include "MHCamera.h" 88 100 #include "MHCamEvent.h" 89 101 #include "MHPhotonEvent.h" … … 95 107 #include "MParEnv.h" 96 108 #include "MPulseShape.h" 109 #include "MGeomCam.h" 97 110 98 111 #include "MPedestalCam.h" … … 110 123 // 111 124 MJSimulation::MJSimulation(const char *name, const char *title) 112 : fForceMode(kFALSE), f ForceTrigger(kFALSE)125 : fForceMode(kFALSE), fCamera(kTRUE) ,fForceTrigger(kFALSE) 113 126 { 114 127 fName = name ? name : "MJSimulation"; … … 120 133 fForceMode = GetEnv("ForceMode", fForceMode); 121 134 fForceTrigger = GetEnv("ForceTrigger", fForceTrigger); 135 fCamera = GetEnv("Camera", fCamera); 122 136 123 137 return kTRUE; 124 138 } 125 139 126 Bool_t MJSimulation::WriteResult( )140 Bool_t MJSimulation::WriteResult(const MParList &plist) 127 141 { 128 142 if (fPathOut.IsNull()) … … 135 149 cont.Add(const_cast<TEnv*>(GetEnv())); 136 150 //cont.Add(const_cast<MSequence*>(&fSequence)); 151 152 cont.Add(plist.FindObject("MPulseShape")); 153 cont.Add(plist.FindObject("MReflector")); 154 cont.Add(plist.FindObject("MGeomCam")); 155 cont.Add(plist.FindObject("GeomAPDs")); 137 156 138 157 if (fDisplay) … … 246 265 plist.AddToList(&shape); 247 266 267 // *** FIXME *** FIXME *** FIXME *** 268 plist.FindCreateObj("MMcRunHeader"); 269 248 270 MRawRunHeader header; 249 271 header.SetValidMagicNumber(); 250 272 //header.InitFadcType(3); 251 273 252 header.SetRun Info(/*MRawRunHeader::kRTMonteCarlo|*/MRawRunHeader::kRTData, 1, 1);274 header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTData); 253 275 if (args.GetNumArguments()==1) 254 276 { 255 277 if (!args.GetArgumentStr(0).CompareTo("pedestal", TString::kIgnoreCase)) 256 278 { 257 header.SetRun Info(/*MRawRunHeader::kRTMonteCarlo|*/MRawRunHeader::kRTPedestal, 1, 1);279 header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPedestal); 258 280 header.SetSourceInfo("Pedestal"); 259 281 } 260 282 if (!args.GetArgumentStr(0).CompareTo("calibration", TString::kIgnoreCase)) 261 283 { 262 header.SetRun Info(/*MRawRunHeader::kRTMonteCarlo|*/MRawRunHeader::kRTCalibration, 1, 1);284 header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTCalibration); 263 285 header.SetSourceInfo("Calibration"); 264 286 } 265 287 if (!args.GetArgumentStr(0).CompareTo("pointrun", TString::kIgnoreCase)) 266 header.SetRun Info(/*MRawRunHeader::kRTMonteCarlo|*/MRawRunHeader::kRTPointRun, 1, 1);288 header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPointRun); 267 289 } 268 290 269 291 // FIXME: Move to MSimPointingPos, MSimCalibrationSignal 292 // Can we use this as input for MSimPointingPos? 270 293 header.SetObservation("On", "MonteCarlo"); 271 294 plist.AddToList(&header); … … 287 310 for (int i=0; i<args.GetNumArguments();i ++) 288 311 read.AddFile(args.GetArgumentStr(i)); 312 313 MSimMMCS simmmcs; 289 314 290 315 MSimAbsorption absapd("AbsorptionAPDs"); … … 385 410 const TString rule3(Form("s/cer([0-9]+)/%s\\/cam$1.root/", Esc(fPathOut).Data())); 386 411 387 MWriteRootFile write1( 2, rule1, fOverwrite?"RECREATE":"NEW", "Reflector file"); 388 MWriteRootFile write2( 2, rule2, fOverwrite?"RECREATE":"NEW", "Signal file"); 389 MWriteRootFile write3( 2, rule3, fOverwrite?"RECREATE":"NEW", "Camera file"); 390 391 write1.SetName("WriteRef"); 392 write2.SetName("WriteSig"); 393 write3.SetName("WriteCam"); 394 395 write1.AddContainer("MCorsikaEvtHeader", "Events", kFALSE); 396 write1.AddContainer("MPhotonEvent", "Events"); 397 398 write2.AddContainer("MRawRunHeader", "RunHeaders"); 399 write2.AddContainer("MGeomCam", "RunHeaders"); 400 write2.AddContainer("MSignalCam", "Events"); 401 write2.AddContainer("MRawEvtHeader", "Events"); 402 write2.AddContainer("MPedPhotFromExtractorRndm", "RunHeaders"); 412 MWriteRootFile write3a( 2, rule3, fOverwrite?"RECREATE":"NEW", "Camera file"); 413 MWriteRootFile write3b( 2, rule3, fOverwrite?"RECREATE":"NEW", "Camera file"); 414 MWriteRootFile write2a( 2, rule2, fOverwrite?"RECREATE":"NEW", "Signal file"); 415 MWriteRootFile write2b( 2, rule2, fOverwrite?"RECREATE":"NEW", "Signal file"); 416 MWriteRootFile write1a( 2, rule1, fOverwrite?"RECREATE":"NEW", "Reflector file"); 417 MWriteRootFile write1b( 2, rule1, fOverwrite?"RECREATE":"NEW", "Reflector file"); 418 419 write1a.SetName("WriteRefData"); 420 write1b.SetName("WriteRefMC"); 421 write2a.SetName("WriteSigData"); 422 write2b.SetName("WriteSigMC"); 423 write3a.SetName("WriteCamData"); 424 write3b.SetName("WriteCamMC"); 425 426 write1a.AddContainer("MCorsikaEvtHeader", "Events", kFALSE); 427 write1a.AddContainer("MPhotonEvent", "Events"); 428 429 write2a.AddContainer("MCorsikaRunHeader", "RunHeaders", kFALSE); 430 write2a.AddContainer("MRawRunHeader", "RunHeaders"); 431 write2a.AddContainer("MGeomCam", "RunHeaders"); 432 write2a.AddContainer("MSignalCam", "Events"); 433 write2a.AddContainer("MRawEvtHeader", "Events", kFALSE); 434 write2a.AddContainer("MPedPhotFromExtractorRndm", "RunHeaders"); // FIXME: Needed for the signal files to be display in MARS 435 write2a.AddContainer("MMcRunHeader", "RunHeaders"); 403 436 /* Monte Carlo Headers 404 437 write.AddContainer("MMcRunHeader", "RunHeaders", kFALSE); … … 417 450 //write.AddContainer("MTriggerPattern", "Events"); 418 451 419 write3.AddContainer("MRawEvtData", "Events"); 420 write3.AddContainer("MRawRunHeader", "RunHeaders"); 421 write3.AddContainer("MGeomCam", "RunHeaders"); 422 write3.AddContainer("MRawEvtHeader", "Events"); 423 write3.AddContainer("MPedestalCam", "RunHeaders", kFALSE); 452 write3a.AddContainer("MRawEvtData", "Events"); 453 write3a.AddContainer("MRawRunHeader", "RunHeaders"); 454 write3a.AddContainer("MGeomCam", "RunHeaders"); 455 write3a.AddContainer("MRawEvtHeader", "Events", kFALSE); 456 //write3.AddContainer("MPedestalCam", "RunHeaders", kFALSE); 457 write3a.AddContainer("MMcRunHeader", "RunHeaders"); 458 write3a.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE); 459 write3a.AddContainer("MMcEvt", "Events", kFALSE); 460 461 write1b.AddContainer("MMcEvtBasic", "OriginalMC"); 462 write2b.AddContainer("MMcEvtBasic", "OriginalMC"); 463 write3b.AddContainer("MMcEvtBasic", "OriginalMC"); 424 464 425 465 // ------------------------------------------------------------------- … … 500 540 tasks.AddToList(&read); 501 541 tasks.AddToList(&pointing); 542 tasks.AddToList(&simmmcs); 543 if (!fPathOut.IsNull() && !HasNullOut()) 544 { 545 tasks.AddToList(&write1b); 546 tasks.AddToList(&write2b); 547 if (fCamera) 548 tasks.AddToList(&write3b); 549 } 502 550 // if (header.IsPointRun()) 503 551 // tasks.AddToList(&stars); … … 536 584 tasks.AddToList(&cont2); 537 585 } 538 if (header.IsPedestalRun() || header.IsCalibrationRun()) 539 tasks.AddToList(&simcal); 540 tasks.AddToList(&simnsb); 541 tasks.AddToList(&simapd); 542 tasks.AddToList(&simexcnoise); 586 if (fCamera) 587 { 588 if (header.IsPedestalRun() || header.IsCalibrationRun()) 589 tasks.AddToList(&simcal); 590 tasks.AddToList(&simnsb); 591 tasks.AddToList(&simapd); 592 tasks.AddToList(&simexcnoise); 593 } 543 594 tasks.AddToList(&simsum); 544 tasks.AddToList(&simcam); 545 if (header.IsDataRun() || fForceTrigger) 546 tasks.AddToList(&simtrig); 547 tasks.AddToList(&conttrig); 595 if (fCamera) 596 { 597 tasks.AddToList(&simcam); 598 if (header.IsDataRun() || fForceTrigger) 599 tasks.AddToList(&simtrig); 600 tasks.AddToList(&conttrig); 601 tasks.AddToList(&simdaq); 602 } 548 603 tasks.AddToList(&simsignal); // What do we do if signal<0? 549 tasks.AddToList(&simdaq);550 604 if (!fPathOut.IsNull() && !HasNullOut()) 551 605 { 552 tasks.AddToList(&write1 );606 tasks.AddToList(&write1a); 553 607 if (!header.IsPedestalRun()) 554 tasks.AddToList(&write2); 555 tasks.AddToList(&write3); 608 tasks.AddToList(&write2a); 609 if (fCamera) 610 tasks.AddToList(&write3a); 556 611 } 557 612 // ------------------------------- 558 if (header.IsDataRun()) 559 tasks.AddToList(&fillh3); 560 tasks.AddToList(&filltp); 613 if (fCamera) 614 { 615 if (header.IsDataRun()) 616 tasks.AddToList(&fillh3); 617 tasks.AddToList(&filltp); 618 } 561 619 if (header.IsDataRun()) 562 620 tasks.AddToList(&fillew); … … 574 632 //tasks.AddToList(&fillx5); 575 633 } 576 577 634 //------------------------------------------- 578 635 … … 587 644 return kFALSE; 588 645 646 //------------------------------------------- 647 589 648 if (binstr.IsDefault()) 590 649 binstr.SetEdgesLin(150, -shape.GetPulseWidth(), … … 592 651 593 652 header.Print(); 653 654 if (fDisplay) 655 { 656 TCanvas &c = fDisplay->AddTab("Info"); 657 c.Divide(2,2); 658 659 c.cd(1); 660 gPad->SetBorderMode(0); 661 gPad->SetFrameBorderMode(0); 662 gPad->SetGridx(); 663 gPad->SetGridy(); 664 gROOT->SetSelectedPad(0); 665 shape.DrawClone()->SetBit(kCanDelete); 666 667 if (header.IsDataRun() || header.IsPointRun()) 668 { 669 c.cd(3); 670 gPad->SetBorderMode(0); 671 gPad->SetFrameBorderMode(0); 672 gPad->SetGridx(); 673 gPad->SetGridy(); 674 gROOT->SetSelectedPad(0); 675 reflector.DrawClone("line")->SetBit(kCanDelete); 676 677 } 678 679 if (fCamera) 680 { 681 if (dynamic_cast<MGeomCam*>(env1.GetCont())) 682 { 683 c.cd(2); 684 gPad->SetBorderMode(0); 685 gPad->SetFrameBorderMode(0); 686 gPad->SetGridx(); 687 gPad->SetGridy(); 688 gROOT->SetSelectedPad(0); 689 MHCamera *c = new MHCamera(static_cast<MGeomCam&>(*env1.GetCont())); 690 c->SetStats(kFALSE); 691 c->SetBit(MHCamera::kNoLegend); 692 c->SetBit(kCanDelete); 693 c->Draw(); 694 695 } 696 697 if (dynamic_cast<MGeomCam*>(env2.GetCont())) 698 { 699 c.cd(4); 700 gPad->SetBorderMode(0); 701 gPad->SetFrameBorderMode(0); 702 gPad->SetGridx(); 703 gPad->SetGridy(); 704 gROOT->SetSelectedPad(0); 705 MHCamera *c = new MHCamera(static_cast<MGeomCam&>(*env2.GetCont())); 706 c->SetStats(kFALSE); 707 c->SetBit(MHCamera::kNoLegend); 708 c->SetBit(kCanDelete); 709 c->Draw(); 710 } 711 } 712 } 713 714 //------------------------------------------- 594 715 595 716 // Execute first analysis … … 607 728 //------------------------------------------- 608 729 609 if (!WriteResult( ))730 if (!WriteResult(plist)) 610 731 return kFALSE; 611 732
Note:
See TracChangeset
for help on using the changeset viewer.