/* ======================================================================== *\ ! ! * ! * This file is part of MARS, the MAGIC Analysis and Reconstruction ! * Software. It is distributed to you in the hope that it can be a useful ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes. ! * It is distributed WITHOUT ANY WARRANTY. ! * ! * Permission to use, copy, modify and distribute this software and its ! * documentation for any purpose is hereby granted without fee, ! * provided that the above copyright notice appear in all copies and ! * that both that copyright notice and this permission notice appear ! * in supporting documentation. It is provided "as is" without express ! * or implied warranty. ! * ! ! ! Author(s): Thomas Bretz, 1/2009 ! ! Copyright: MAGIC Software Development, 2000-2009 ! ! \* ======================================================================== */ ///////////////////////////////////////////////////////////////////////////// // // MJSimulation // // // Force reading a corsika file even if the footer (RUNE-section) is missing // by setting fForceMode to kTRUE or from the resource file by // // ForceMode: Yes // // // In case of a pedestal or calibration run the artificial trigger can // be "switched off" and the cosmics trrigger "switched on" by setting // fForceTrigger to kTRUE or from the resource file by // // ForceTrigger: Yes // // ///////////////////////////////////////////////////////////////////////////// #include "MJSimulation.h" #include // Core #include "MLog.h" #include "MLogManip.h" #include "MArgs.h" //#include "MDirIter.h" #include "MParList.h" #include "MTaskList.h" #include "MEvtLoop.h" #include "MStatusDisplay.h" // Tasks #include "MCorsikaRead.h" #include "MContinue.h" #include "MFillH.h" #include "MGeomApply.h" #include "MHillasCalc.h" #include "MImgCleanStd.h" #include "MWriteRootFile.h" #include "MSimAbsorption.h" #include "MSimReflector.h" #include "MSimPointingPos.h" #include "MSimPSF.h" #include "MSimGeomCam.h" #include "MSimSignalCam.h" #include "MSimAPD.h" #include "MSimExcessNoise.h" #include "MSimCamera.h" #include "MSimTrigger.h" #include "MSimReadout.h" #include "MSimRandomPhotons.h" #include "MSimBundlePhotons.h" #include "MSimCalibrationSignal.h" // Histograms #include "MBinning.h" #include "MHn.h" #include "MHCamEvent.h" #include "MHPhotonEvent.h" // Container #include "MRawRunHeader.h" #include "MParameters.h" #include "MReflector.h" #include "MParEnv.h" #include "MPulseShape.h" #include "MPedestalCam.h" #include "MPedestalPix.h" ClassImp(MJSimulation); using namespace std; // -------------------------------------------------------------------------- // // Default constructor. // // Sets fRuns to 0, fExtractor to NULL, fDataCheck to kFALSE // MJSimulation::MJSimulation(const char *name, const char *title) : fForceMode(kFALSE), fForceTrigger(kFALSE) { fName = name ? name : "MJSimulation"; fTitle = title ? title : "Standard analysis and reconstruction"; } Bool_t MJSimulation::CheckEnvLocal() { fForceMode = GetEnv("ForceMode", fForceMode); fForceTrigger = GetEnv("ForceTrigger", fForceTrigger); return kTRUE; } Bool_t MJSimulation::WriteResult() { if (fPathOut.IsNull()) { *fLog << inf << "No output path specified via SetPathOut - no output written." << endl; return kTRUE; } TObjArray cont; cont.Add(const_cast(GetEnv())); //cont.Add(const_cast(&fSequence)); if (fDisplay) { // TString title = "-- Reflector: "; // title += fSequence.GetSequence(); // title += " --"; // fDisplay->SetTitle(title, kFALSE); fDisplay->SetTitle("Ceres", kFALSE); cont.Add(fDisplay); } // const TString oname = Form("reflector%08d.root", fSequence.GetSequence()); const TString oname = "ceres.root"; return WriteContainer(cont, oname, "RECREATE"); } void MJSimulation::SetupHist(MHn &hist) const { hist.AddHist("MCorsikaEvtHeader.fTotalEnergy"); hist.InitName("Energy"); hist.InitTitle("Energy;E [GeV]"); hist.SetLog(kTRUE, kTRUE, kFALSE); hist.AddHist("MPhotonEvent.GetNumExternal"); hist.InitName("Size"); hist.InitTitle("Size;S [#]"); hist.SetLog(kTRUE, kTRUE, kFALSE); hist.AddHist("MCorsikaEvtHeader.fX/100","MCorsikaEvtHeader.fY/100"); hist.SetDrawOption("colz"); hist.InitName("Impact;Impact;Impact"); hist.InitTitle("Impact;West <--> East [m];South <--> North [m]"); hist.AddHist("MCorsikaEvtHeader.fFirstInteractionHeight/100000"); hist.InitName("Height"); hist.InitTitle("FirstInteractionHeight;h [km]"); hist.AddHist("MCorsikaEvtHeader.fAz*TMath::RadToDeg()", "MCorsikaEvtHeader.fZd*TMath::RadToDeg()"); hist.InitName("SkyOrigin;Az;Zd"); hist.InitTitle("Sky Origin;Az [deg];Zd [deg]"); hist.SetDrawOption("colz"); TString sin2 = "sin(MCorsikaEvtHeader.fZd)*sin(MCorsikaRunHeader.fZdMin*TMath::DegToRad())"; TString cos2 = "cos(MCorsikaEvtHeader.fZd)*cos(MCorsikaRunHeader.fZdMin*TMath::DegToRad())"; TString cos = "cos(MCorsikaEvtHeader.fAz-MCorsikaRunHeader.fAzMin*TMath::DegToRad())"; TString form = "acos("+sin2+"*"+cos+"+"+cos2+")*TMath::RadToDeg()"; hist.AddHist(form); hist.InitName("ViewCone"); hist.InitTitle("Incident Angle;\\alpha [\\deg]"); } Bool_t MJSimulation::Process(const MArgs &args) { /* if (!fSequence.IsValid()) { *fLog << err << "ERROR - Sequence invalid!" << endl; return kFALSE; } */ //if (!HasWritePermission(GetPathOut())) // return kFALSE; *fLog << inf; fLog->Separator(GetDescriptor()); if (!CheckEnv()) return kFALSE; *fLog << warn << "FIXME: Monte Carlo simulation: Sequences not supported yet."; //*fLog << fSequence.GetFileName() << endl; *fLog << endl; // -------------------------------------------------------------------------------- //MDirIter iter; //if (fSequence.GetRuns(iter, MSequence::kCalibrated)<=0) // return kFALSE; // Setup Parlist MParList plist; plist.AddToList(this); // take care of fDisplay! // setup TaskList MTaskList tasks; plist.AddToList(&tasks); // -------------------------------------------------------------------------------- // ---------- FIXME FIXME FIXME ----------- // FIXME: Find a better name (What if both cams are identical?) MParEnv env1("GeomAPDs"); // Inheritance! MParEnv env2("MGeomCam"); // Inheritance! env1.SetClassName("MGeomCam"); env2.SetClassName("MGeomCam"); plist.AddToList(&env1); plist.AddToList(&env2); // FIXME: Allow the user to create other reflectors MReflector reflector; plist.AddToList(&reflector); plist.FindCreateObj("MPedPhotCam", "MPedPhotFromExtractorRndm"); MPulseShape shape; plist.AddToList(&shape); MRawRunHeader header; header.SetValidMagicNumber(); //header.InitFadcType(3); header.SetRunInfo(/*MRawRunHeader::kRTMonteCarlo|*/MRawRunHeader::kRTData, 1, 1); if (args.GetNumArguments()==1) { if (!args.GetArgumentStr(0).CompareTo("pedestal", TString::kIgnoreCase)) { header.SetRunInfo(/*MRawRunHeader::kRTMonteCarlo|*/MRawRunHeader::kRTPedestal, 1, 1); header.SetSourceInfo("Pedestal"); } if (!args.GetArgumentStr(0).CompareTo("calibration", TString::kIgnoreCase)) { header.SetRunInfo(/*MRawRunHeader::kRTMonteCarlo|*/MRawRunHeader::kRTCalibration, 1, 1); header.SetSourceInfo("Calibration"); } if (!args.GetArgumentStr(0).CompareTo("pointrun", TString::kIgnoreCase)) header.SetRunInfo(/*MRawRunHeader::kRTMonteCarlo|*/MRawRunHeader::kRTPointRun, 1, 1); } // FIXME: Move to MSimPointingPos, MSimCalibrationSignal header.SetObservation("On", "MonteCarlo"); plist.AddToList(&header); // ++++++++ FIXME FIXME FIXME +++++++++++++ /* MPedestalCam pedcam; pedcam.Init(geomcam.GetNumPixels()); for (UInt_t i=0; i