| 1 | /* ======================================================================== *\
|
|---|
| 2 | !
|
|---|
| 3 | ! *
|
|---|
| 4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
|---|
| 5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
|---|
| 6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
|---|
| 7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
|---|
| 8 | ! *
|
|---|
| 9 | ! * Permission to use, copy, modify and distribute this software and its
|
|---|
| 10 | ! * documentation for any purpose is hereby granted without fee,
|
|---|
| 11 | ! * provided that the above copyright notice appear in all copies and
|
|---|
| 12 | ! * that both that copyright notice and this permission notice appear
|
|---|
| 13 | ! * in supporting documentation. It is provided "as is" without express
|
|---|
| 14 | ! * or implied warranty.
|
|---|
| 15 | ! *
|
|---|
| 16 | !
|
|---|
| 17 | !
|
|---|
| 18 | ! Author(s): Thomas Bretz, 1/2009 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2009
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MJSimulation
|
|---|
| 28 | //
|
|---|
| 29 | //
|
|---|
| 30 | // Force reading a corsika file even if the footer (RUNE-section) is missing
|
|---|
| 31 | // by setting fForceMode to kTRUE or from the resource file by
|
|---|
| 32 | //
|
|---|
| 33 | // ForceMode: Yes
|
|---|
| 34 | //
|
|---|
| 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 | //
|
|---|
| 46 | // In case of a pedestal or calibration run the artificial trigger can
|
|---|
| 47 | // be "switched off" and the cosmics trrigger "switched on" by setting
|
|---|
| 48 | // fForceTrigger to kTRUE or from the resource file by
|
|---|
| 49 | //
|
|---|
| 50 | // ForceTrigger: Yes
|
|---|
| 51 | //
|
|---|
| 52 | //
|
|---|
| 53 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 54 | #include "MJSimulation.h"
|
|---|
| 55 |
|
|---|
| 56 | #include <TEnv.h>
|
|---|
| 57 | #include <TCanvas.h>
|
|---|
| 58 |
|
|---|
| 59 | // Core
|
|---|
| 60 | #include "MLog.h"
|
|---|
| 61 | #include "MLogManip.h"
|
|---|
| 62 |
|
|---|
| 63 | #include "MArgs.h"
|
|---|
| 64 | //#include "MDirIter.h"
|
|---|
| 65 | #include "MParList.h"
|
|---|
| 66 | #include "MTaskList.h"
|
|---|
| 67 | #include "MEvtLoop.h"
|
|---|
| 68 |
|
|---|
| 69 | #include "MStatusDisplay.h"
|
|---|
| 70 |
|
|---|
| 71 | // Tasks
|
|---|
| 72 | #include "MCorsikaRead.h"
|
|---|
| 73 | #include "MContinue.h"
|
|---|
| 74 | #include "MFillH.h"
|
|---|
| 75 | #include "MGeomApply.h"
|
|---|
| 76 | #include "MHillasCalc.h"
|
|---|
| 77 | #include "MImgCleanStd.h"
|
|---|
| 78 | #include "MWriteRootFile.h"
|
|---|
| 79 |
|
|---|
| 80 | #include "MSimAbsorption.h"
|
|---|
| 81 | #include "MSimReflector.h"
|
|---|
| 82 | #include "MSimPointingPos.h"
|
|---|
| 83 | #include "MSimPSF.h"
|
|---|
| 84 | #include "MSimGeomCam.h"
|
|---|
| 85 | #include "MSimSignalCam.h"
|
|---|
| 86 | #include "MSimAPD.h"
|
|---|
| 87 | #include "MSimExcessNoise.h"
|
|---|
| 88 | #include "MSimCamera.h"
|
|---|
| 89 | #include "MSimTrigger.h"
|
|---|
| 90 | #include "MSimReadout.h"
|
|---|
| 91 | #include "MSimRandomPhotons.h"
|
|---|
| 92 | #include "MSimBundlePhotons.h"
|
|---|
| 93 | #include "MSimCalibrationSignal.h"
|
|---|
| 94 |
|
|---|
| 95 | // Histograms
|
|---|
| 96 | #include "MBinning.h"
|
|---|
| 97 |
|
|---|
| 98 | #include "MHn.h"
|
|---|
| 99 | #include "MHCamera.h"
|
|---|
| 100 | #include "MHCamEvent.h"
|
|---|
| 101 | #include "MHPhotonEvent.h"
|
|---|
| 102 |
|
|---|
| 103 | // Container
|
|---|
| 104 | #include "MRawRunHeader.h"
|
|---|
| 105 | #include "MParameters.h"
|
|---|
| 106 | #include "MReflector.h"
|
|---|
| 107 | #include "MParEnv.h"
|
|---|
| 108 | #include "MPulseShape.h"
|
|---|
| 109 | #include "MGeomCam.h"
|
|---|
| 110 |
|
|---|
| 111 | #include "MPedestalCam.h"
|
|---|
| 112 | #include "MPedestalPix.h"
|
|---|
| 113 |
|
|---|
| 114 | ClassImp(MJSimulation);
|
|---|
| 115 |
|
|---|
| 116 | using namespace std;
|
|---|
| 117 |
|
|---|
| 118 | // --------------------------------------------------------------------------
|
|---|
| 119 | //
|
|---|
| 120 | // Default constructor.
|
|---|
| 121 | //
|
|---|
| 122 | // Sets fRuns to 0, fExtractor to NULL, fDataCheck to kFALSE
|
|---|
| 123 | //
|
|---|
| 124 | MJSimulation::MJSimulation(const char *name, const char *title)
|
|---|
| 125 | : fForceMode(kFALSE), fCamera(kTRUE) ,fForceTrigger(kFALSE)
|
|---|
| 126 | {
|
|---|
| 127 | fName = name ? name : "MJSimulation";
|
|---|
| 128 | fTitle = title ? title : "Standard analysis and reconstruction";
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | Bool_t MJSimulation::CheckEnvLocal()
|
|---|
| 132 | {
|
|---|
| 133 | fForceMode = GetEnv("ForceMode", fForceMode);
|
|---|
| 134 | fForceTrigger = GetEnv("ForceTrigger", fForceTrigger);
|
|---|
| 135 | fCamera = GetEnv("Camera", fCamera);
|
|---|
| 136 |
|
|---|
| 137 | return kTRUE;
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | Bool_t MJSimulation::WriteResult(const MParList &plist)
|
|---|
| 141 | {
|
|---|
| 142 | if (fPathOut.IsNull())
|
|---|
| 143 | {
|
|---|
| 144 | *fLog << inf << "No output path specified via SetPathOut - no output written." << endl;
|
|---|
| 145 | return kTRUE;
|
|---|
| 146 | }
|
|---|
| 147 |
|
|---|
| 148 | TObjArray cont;
|
|---|
| 149 | cont.Add(const_cast<TEnv*>(GetEnv()));
|
|---|
| 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"));
|
|---|
| 156 |
|
|---|
| 157 | if (fDisplay)
|
|---|
| 158 | {
|
|---|
| 159 | // TString title = "-- Reflector: ";
|
|---|
| 160 | // title += fSequence.GetSequence();
|
|---|
| 161 | // title += " --";
|
|---|
| 162 | // fDisplay->SetTitle(title, kFALSE);
|
|---|
| 163 | fDisplay->SetTitle("Ceres", kFALSE);
|
|---|
| 164 |
|
|---|
| 165 | cont.Add(fDisplay);
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|
| 168 | // const TString oname = Form("reflector%08d.root", fSequence.GetSequence());
|
|---|
| 169 | const TString oname = "ceres.root";
|
|---|
| 170 | return WriteContainer(cont, oname, "RECREATE");
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | void MJSimulation::SetupHist(MHn &hist) const
|
|---|
| 174 | {
|
|---|
| 175 | hist.AddHist("MCorsikaEvtHeader.fTotalEnergy");
|
|---|
| 176 | hist.InitName("Energy");
|
|---|
| 177 | hist.InitTitle("Energy;E [GeV]");
|
|---|
| 178 | hist.SetLog(kTRUE, kTRUE, kFALSE);
|
|---|
| 179 |
|
|---|
| 180 | hist.AddHist("MPhotonEvent.GetNumExternal");
|
|---|
| 181 | hist.InitName("Size");
|
|---|
| 182 | hist.InitTitle("Size;S [#]");
|
|---|
| 183 | hist.SetLog(kTRUE, kTRUE, kFALSE);
|
|---|
| 184 |
|
|---|
| 185 | hist.AddHist("MCorsikaEvtHeader.fX/100","MCorsikaEvtHeader.fY/100");
|
|---|
| 186 | hist.SetDrawOption("colz");
|
|---|
| 187 | hist.InitName("Impact;Impact;Impact");
|
|---|
| 188 | hist.InitTitle("Impact;West <--> East [m];South <--> North [m]");
|
|---|
| 189 |
|
|---|
| 190 | hist.AddHist("MCorsikaEvtHeader.fFirstInteractionHeight/100000");
|
|---|
| 191 | hist.InitName("Height");
|
|---|
| 192 | hist.InitTitle("FirstInteractionHeight;h [km]");
|
|---|
| 193 |
|
|---|
| 194 | hist.AddHist("MCorsikaEvtHeader.fAz*TMath::RadToDeg()", "MCorsikaEvtHeader.fZd*TMath::RadToDeg()");
|
|---|
| 195 | hist.InitName("SkyOrigin;Az;Zd");
|
|---|
| 196 | hist.InitTitle("Sky Origin;Az [deg];Zd [deg]");
|
|---|
| 197 | hist.SetDrawOption("colz");
|
|---|
| 198 |
|
|---|
| 199 | TString sin2 = "sin(MCorsikaEvtHeader.fZd)*sin(MCorsikaRunHeader.fZdMin*TMath::DegToRad())";
|
|---|
| 200 | TString cos2 = "cos(MCorsikaEvtHeader.fZd)*cos(MCorsikaRunHeader.fZdMin*TMath::DegToRad())";
|
|---|
| 201 | TString cos = "cos(MCorsikaEvtHeader.fAz-MCorsikaRunHeader.fAzMin*TMath::DegToRad())";
|
|---|
| 202 |
|
|---|
| 203 | TString form = "acos("+sin2+"*"+cos+"+"+cos2+")*TMath::RadToDeg()";
|
|---|
| 204 |
|
|---|
| 205 | hist.AddHist(form);
|
|---|
| 206 | hist.InitName("ViewCone");
|
|---|
| 207 | hist.InitTitle("Incident Angle;\\alpha [\\deg]");
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | Bool_t MJSimulation::Process(const MArgs &args)
|
|---|
| 211 | {
|
|---|
| 212 | /*
|
|---|
| 213 | if (!fSequence.IsValid())
|
|---|
| 214 | {
|
|---|
| 215 | *fLog << err << "ERROR - Sequence invalid!" << endl;
|
|---|
| 216 | return kFALSE;
|
|---|
| 217 | }
|
|---|
| 218 | */
|
|---|
| 219 |
|
|---|
| 220 | //if (!HasWritePermission(GetPathOut()))
|
|---|
| 221 | // return kFALSE;
|
|---|
| 222 |
|
|---|
| 223 | *fLog << inf;
|
|---|
| 224 | fLog->Separator(GetDescriptor());
|
|---|
| 225 |
|
|---|
| 226 | if (!CheckEnv())
|
|---|
| 227 | return kFALSE;
|
|---|
| 228 |
|
|---|
| 229 | *fLog << warn << "FIXME: Monte Carlo simulation: Sequences not supported yet.";
|
|---|
| 230 | //*fLog << fSequence.GetFileName() << endl;
|
|---|
| 231 | *fLog << endl;
|
|---|
| 232 |
|
|---|
| 233 | // --------------------------------------------------------------------------------
|
|---|
| 234 |
|
|---|
| 235 | //MDirIter iter;
|
|---|
| 236 | //if (fSequence.GetRuns(iter, MSequence::kCalibrated)<=0)
|
|---|
| 237 | // return kFALSE;
|
|---|
| 238 |
|
|---|
| 239 | // Setup Parlist
|
|---|
| 240 | MParList plist;
|
|---|
| 241 | plist.AddToList(this); // take care of fDisplay!
|
|---|
| 242 |
|
|---|
| 243 | // setup TaskList
|
|---|
| 244 | MTaskList tasks;
|
|---|
| 245 | plist.AddToList(&tasks);
|
|---|
| 246 |
|
|---|
| 247 | // --------------------------------------------------------------------------------
|
|---|
| 248 |
|
|---|
| 249 | // ---------- FIXME FIXME FIXME -----------
|
|---|
| 250 | // FIXME: Find a better name (What if both cams are identical?)
|
|---|
| 251 | MParEnv env1("GeomAPDs"); // Inheritance!
|
|---|
| 252 | MParEnv env2("MGeomCam"); // Inheritance!
|
|---|
| 253 | env1.SetClassName("MGeomCam");
|
|---|
| 254 | env2.SetClassName("MGeomCam");
|
|---|
| 255 | plist.AddToList(&env1);
|
|---|
| 256 | plist.AddToList(&env2);
|
|---|
| 257 |
|
|---|
| 258 | // FIXME: Allow the user to create other reflectors
|
|---|
| 259 | MReflector reflector;
|
|---|
| 260 | plist.AddToList(&reflector);
|
|---|
| 261 |
|
|---|
| 262 | plist.FindCreateObj("MPedPhotCam", "MPedPhotFromExtractorRndm");
|
|---|
| 263 |
|
|---|
| 264 | MPulseShape shape;
|
|---|
| 265 | plist.AddToList(&shape);
|
|---|
| 266 |
|
|---|
| 267 | // *** FIXME *** FIXME *** FIXME ***
|
|---|
| 268 | plist.FindCreateObj("MMcRunHeader");
|
|---|
| 269 |
|
|---|
| 270 | MRawRunHeader header;
|
|---|
| 271 | header.SetValidMagicNumber();
|
|---|
| 272 | //header.InitFadcType(3);
|
|---|
| 273 |
|
|---|
| 274 | header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTData);
|
|---|
| 275 | if (args.GetNumArguments()==1)
|
|---|
| 276 | {
|
|---|
| 277 | if (!args.GetArgumentStr(0).CompareTo("pedestal", TString::kIgnoreCase))
|
|---|
| 278 | {
|
|---|
| 279 | header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPedestal);
|
|---|
| 280 | header.SetSourceInfo("Pedestal");
|
|---|
| 281 | }
|
|---|
| 282 | if (!args.GetArgumentStr(0).CompareTo("calibration", TString::kIgnoreCase))
|
|---|
| 283 | {
|
|---|
| 284 | header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTCalibration);
|
|---|
| 285 | header.SetSourceInfo("Calibration");
|
|---|
| 286 | }
|
|---|
| 287 | if (!args.GetArgumentStr(0).CompareTo("pointrun", TString::kIgnoreCase))
|
|---|
| 288 | header.SetRunType(MRawRunHeader::kRTMonteCarlo|MRawRunHeader::kRTPointRun);
|
|---|
| 289 | }
|
|---|
| 290 |
|
|---|
| 291 | // FIXME: Move to MSimPointingPos, MSimCalibrationSignal
|
|---|
| 292 | // Can we use this as input for MSimPointingPos?
|
|---|
| 293 | header.SetObservation("On", "MonteCarlo");
|
|---|
| 294 | plist.AddToList(&header);
|
|---|
| 295 | // ++++++++ FIXME FIXME FIXME +++++++++++++
|
|---|
| 296 |
|
|---|
| 297 | /*
|
|---|
| 298 | MPedestalCam pedcam;
|
|---|
| 299 | pedcam.Init(geomcam.GetNumPixels());
|
|---|
| 300 | for (UInt_t i=0; i<geomcam.GetNumPixels(); i++)
|
|---|
| 301 | pedcam[i].Set(128./header.GetScale(), 22.5/header.GetScale());
|
|---|
| 302 | plist.AddToList(&pedcam);
|
|---|
| 303 | */
|
|---|
| 304 |
|
|---|
| 305 | // -------------------------------------------------------------------
|
|---|
| 306 |
|
|---|
| 307 | MCorsikaRead read;
|
|---|
| 308 | read.SetForceMode(fForceMode);
|
|---|
| 309 |
|
|---|
| 310 | for (int i=0; i<args.GetNumArguments();i ++)
|
|---|
| 311 | read.AddFile(args.GetArgumentStr(i));
|
|---|
| 312 |
|
|---|
| 313 | MSimMMCS simmmcs;
|
|---|
| 314 |
|
|---|
| 315 | MSimAbsorption absapd("AbsorptionAPDs");
|
|---|
| 316 | MSimAbsorption absmir("AbsorptionMirrors");
|
|---|
| 317 | MSimAbsorption cones("AbsorptionCones");
|
|---|
| 318 | cones.SetUseTheta();
|
|---|
| 319 |
|
|---|
| 320 | MSimPointingPos pointing;
|
|---|
| 321 |
|
|---|
| 322 | MSimReflector reflect;
|
|---|
| 323 | reflect.SetNameGeomCam("GeomAPDs");
|
|---|
| 324 | // MSimStarField stars;
|
|---|
| 325 |
|
|---|
| 326 | MContinue cont1("MPhotonEvent.GetNumPhotons<1", "ContEmpty1");
|
|---|
| 327 | MContinue cont2("MPhotonEvent.GetNumPhotons<1", "ContEmpty2");
|
|---|
| 328 |
|
|---|
| 329 | // -------------------------------------------------------------------
|
|---|
| 330 |
|
|---|
| 331 | MBinning binse( 100, 1, 100000, "BinningEnergy", "log");
|
|---|
| 332 | MBinning binss( 100, 1, 10000000, "BinningSize", "log");
|
|---|
| 333 | MBinning binsi( 50, -250, 250, "BinningImpact");
|
|---|
| 334 | MBinning binsh( 50, 0, 12, "BinningHeight");
|
|---|
| 335 | MBinning binsaz(360, -360, 360, "BinningAz");
|
|---|
| 336 | MBinning binszd( 70, 0, 70, "BinningZd");
|
|---|
| 337 | MBinning binsvc(155, 0, 31, "BinningViewCone");
|
|---|
| 338 | MBinning binsew(150, 0, 25, "BinningEvtWidth");
|
|---|
| 339 | MBinning binstr("BinningTrigPos");
|
|---|
| 340 |
|
|---|
| 341 | plist.AddToList(&binse);
|
|---|
| 342 | plist.AddToList(&binss);
|
|---|
| 343 | plist.AddToList(&binsi);
|
|---|
| 344 | plist.AddToList(&binsh);
|
|---|
| 345 | plist.AddToList(&binszd);
|
|---|
| 346 | plist.AddToList(&binsaz);
|
|---|
| 347 | plist.AddToList(&binsvc);
|
|---|
| 348 | plist.AddToList(&binsew);
|
|---|
| 349 | plist.AddToList(&binstr);
|
|---|
| 350 |
|
|---|
| 351 | MHn mhn1, mhn2, mhn3;
|
|---|
| 352 | SetupHist(mhn1);
|
|---|
| 353 | SetupHist(mhn2);
|
|---|
| 354 | SetupHist(mhn3);
|
|---|
| 355 |
|
|---|
| 356 | MH3 mhtp("TriggerPos.fVal-IntendedPulsePos.fVal-MPulseShape.GetPulseWidth");
|
|---|
| 357 | mhtp.SetName("TrigPos");
|
|---|
| 358 | mhtp.SetTitle("Trigger position w.r.t. the first photon hitting an APD");
|
|---|
| 359 |
|
|---|
| 360 | MH3 mhew("MPhotonStatistics.fTimeLast-MPhotonStatistics.fTimeFirst - MRawRunHeader.GetFreqSampling/1000.*MRawRunHeader.fNumSamplesHiGain - 2*MPulseShape.GetPulseWidth");
|
|---|
| 361 | mhew.SetName("EvtWidth");
|
|---|
| 362 | mhew.SetTitle("Time between first and last photon hitting an APD");
|
|---|
| 363 |
|
|---|
| 364 | MFillH fillh1(&mhn1, "", "FillH1");
|
|---|
| 365 | MFillH fillh2(&mhn2, "", "FillH2");
|
|---|
| 366 | MFillH fillh3(&mhn3, "", "FillH3");
|
|---|
| 367 | MFillH filltp(&mhtp, "", "FillTriggerPos");
|
|---|
| 368 | MFillH fillew(&mhew, "", "FillEvtWidth");
|
|---|
| 369 | fillh1.SetNameTab("H1", "Distribution of Muons as simulated");
|
|---|
| 370 | fillh2.SetNameTab("H2", "Distribution of Muons as available after all");
|
|---|
| 371 | fillh3.SetNameTab("H3", "Distribution after trigger");
|
|---|
| 372 | filltp.SetNameTab("TrigPos", "TriggerPosition w.r.t the first photon");
|
|---|
| 373 | fillew.SetNameTab("EvtWidth", "Time between first and last photon hitting an APD");
|
|---|
| 374 |
|
|---|
| 375 | MHPhotonEvent planeG(1); // Get from MaxImpact
|
|---|
| 376 | MHPhotonEvent plane0(2); // Get from MReflector
|
|---|
| 377 | MHPhotonEvent plane1(2);
|
|---|
| 378 | MHPhotonEvent plane2(2);
|
|---|
| 379 | MHPhotonEvent plane3(2);
|
|---|
| 380 | MHPhotonEvent plane4(2);
|
|---|
| 381 | MHPhotonEvent planeF1(3); // Get from MGeomCam
|
|---|
| 382 | MHPhotonEvent planeF2(header.IsPointRun()?4:3); // Get from MGeomCam
|
|---|
| 383 |
|
|---|
| 384 | //MHPSF psf;
|
|---|
| 385 |
|
|---|
| 386 | MFillH fillG(&planeG, "MPhotonEvent", "FillGround");
|
|---|
| 387 | MFillH fill0(&plane0, "MirrorPlane0", "FillReflector");
|
|---|
| 388 | MFillH fill1(&plane1, "MirrorPlane1", "FillCamShadow");
|
|---|
| 389 | MFillH fill2(&plane2, "MirrorPlane2", "FillCandidates");
|
|---|
| 390 | MFillH fill3(&plane3, "MirrorPlane3", "FillReflected");
|
|---|
| 391 | MFillH fill4(&plane4, "MirrorPlane4", "FillFocal");
|
|---|
| 392 | MFillH fillF1(&planeF1, "MPhotonEvent", "FillCamera");
|
|---|
| 393 | MFillH fillF2(&planeF2, "MPhotonEvent", "FillAPDs");
|
|---|
| 394 | //MFillH fillP(&psf, "MPhotonEvent", "FillPSF");
|
|---|
| 395 |
|
|---|
| 396 | fillG.SetNameTab("Ground", "Photon distribution at ground");
|
|---|
| 397 | fill0.SetNameTab("Reflector", "Photon distribution at reflector plane w/o camera shadow");
|
|---|
| 398 | fill1.SetNameTab("CamShadow", "Photon distribution at reflector plane w/ camera shadow");
|
|---|
| 399 | fill2.SetNameTab("Candidates", "'Can hit' photon distribution at reflector plane w/ camera shadow");
|
|---|
| 400 | fill3.SetNameTab("Reflected", "Photon distribution after reflector projected to reflector plane");
|
|---|
| 401 | fill4.SetNameTab("Focal", "Photon distribution at focal plane");
|
|---|
| 402 | fillF1.SetNameTab("Camera", "Photon distribution which hit the detector");
|
|---|
| 403 | fillF2.SetNameTab("APDs", "Photon distribution after cones");
|
|---|
| 404 | //fillP.SetNameTab("PSF", "Photon distribution after cones for all mirrors");
|
|---|
| 405 |
|
|---|
| 406 | // -------------------------------------------------------------------
|
|---|
| 407 |
|
|---|
| 408 | const TString rule1(Form("s/cer([0-9]+)/%s\\/ref$1.root/", Esc(fPathOut).Data()));
|
|---|
| 409 | const TString rule2(Form("s/cer([0-9]+)/%s\\/sig$1.root/", Esc(fPathOut).Data()));
|
|---|
| 410 | const TString rule3(Form("s/cer([0-9]+)/%s\\/cam$1.root/", Esc(fPathOut).Data()));
|
|---|
| 411 |
|
|---|
| 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");
|
|---|
| 436 | /* Monte Carlo Headers
|
|---|
| 437 | write.AddContainer("MMcRunHeader", "RunHeaders", kFALSE);
|
|---|
| 438 | write.AddContainer("MMcFadcHeader", "RunHeaders", kFALSE);
|
|---|
| 439 | write.AddContainer("MMcTrigHeader", "RunHeaders", kFALSE);
|
|---|
| 440 | write.AddContainer("MMcConfigRunHeader", "RunHeaders", kFALSE);
|
|---|
| 441 | write.AddContainer("MMcCorsikaRunHeader", "RunHeaders", kFALSE);
|
|---|
| 442 | // Monte Carlo
|
|---|
| 443 | write.AddContainer("MMcEvt", "Events", kFALSE);
|
|---|
| 444 | write.AddContainer("MMcTrig", "Events", kFALSE);
|
|---|
| 445 | */// Data tree
|
|---|
| 446 | //write.AddContainer("MPedPhotFromExtractor", "Events");
|
|---|
| 447 | //write.AddContainer("MPedPhotFromExtractorRndm", "Events");
|
|---|
| 448 | //write.AddContainer("MTime", "Events", kFALSE);
|
|---|
| 449 | //write.AddContainer("MRawEvtHeader", "Events");
|
|---|
| 450 | //write.AddContainer("MTriggerPattern", "Events");
|
|---|
| 451 |
|
|---|
| 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");
|
|---|
| 464 |
|
|---|
| 465 | // -------------------------------------------------------------------
|
|---|
| 466 |
|
|---|
| 467 | MGeomApply apply;
|
|---|
| 468 |
|
|---|
| 469 | MSimPSF simpsf;
|
|---|
| 470 |
|
|---|
| 471 | MSimGeomCam simgeom;
|
|---|
| 472 | simgeom.SetNameGeomCam("GeomAPDs");
|
|---|
| 473 |
|
|---|
| 474 | MSimCalibrationSignal simcal;
|
|---|
| 475 | simcal.SetNameGeomCam("GeomAPDs");
|
|---|
| 476 |
|
|---|
| 477 | // Dark Current: 4MHz = 0.004 GHz
|
|---|
| 478 | // Light of night sky at La Palma: ~ 0.2 ph / cm^2 / sr / ns
|
|---|
| 479 | // 5deg camera: 6e-3 sr
|
|---|
| 480 | // NSB = 0.2*6e-3
|
|---|
| 481 |
|
|---|
| 482 | MSimRandomPhotons simnsb;
|
|---|
| 483 | // simnsb.SetFreq(0.005, 0.004); // 5MHz/cm^2, 4MHz
|
|---|
| 484 | simnsb.SetFreq(0, 0.04); // 40MHz fixed for each APD
|
|---|
| 485 | simnsb.SetNameGeomCam("GeomAPDs");
|
|---|
| 486 |
|
|---|
| 487 | // FIXME: How do we handle star-light? We need the rate but we also
|
|---|
| 488 | // need to process it through the mirror!
|
|---|
| 489 |
|
|---|
| 490 | MSimAPD simapd;
|
|---|
| 491 | simapd.SetFreq(0.04); // Must be identical to MSimRanodmPhotons!!
|
|---|
| 492 | simapd.SetNameGeomCam("GeomAPDs");
|
|---|
| 493 |
|
|---|
| 494 | MSimExcessNoise simexcnoise;
|
|---|
| 495 | MSimBundlePhotons simsum;
|
|---|
| 496 | MSimSignalCam simsignal;
|
|---|
| 497 | MSimCamera simcam;
|
|---|
| 498 | MSimTrigger simtrig;
|
|---|
| 499 | MSimReadout simdaq;
|
|---|
| 500 |
|
|---|
| 501 | MContinue conttrig("TriggerPos.fVal<0", "ContTrigger");
|
|---|
| 502 |
|
|---|
| 503 | MParameterD pulpos("IntendedPulsePos");
|
|---|
| 504 | // pulpos.SetVal(40); // [ns]
|
|---|
| 505 | plist.AddToList(&pulpos);
|
|---|
| 506 |
|
|---|
| 507 | MParameterD trigger("TriggerPos");
|
|---|
| 508 | trigger.SetVal(0);
|
|---|
| 509 | plist.AddToList(&trigger);
|
|---|
| 510 |
|
|---|
| 511 | // -------------------------------------------------------------------
|
|---|
| 512 |
|
|---|
| 513 | MImgCleanStd clean(7, 4.5);
|
|---|
| 514 | clean.SetMethod(MImgCleanStd::kAbsolute);
|
|---|
| 515 |
|
|---|
| 516 | //clean.SetNamePedPhotCam("MPedPhotFromExtractorRndm");
|
|---|
| 517 |
|
|---|
| 518 | MHillasCalc hcalc;
|
|---|
| 519 | hcalc.Disable(MHillasCalc::kCalcConc);
|
|---|
| 520 |
|
|---|
| 521 | MHCamEvent evt0a(/*10*/0, "Signal", "Average signal;;S [ph]");
|
|---|
| 522 | MHCamEvent evt0c(/*10*/0, "MaxSignal", "Maximum signal;;S [ph]");
|
|---|
| 523 | MHCamEvent evt0d(/*11*/8, "ArrTm", "Time after first photon;;T [ns]");
|
|---|
| 524 | evt0a.SetErrorSpread(kFALSE);
|
|---|
| 525 | evt0c.SetCollectMax();
|
|---|
| 526 |
|
|---|
| 527 | MFillH fillx0a(&evt0a, "MSignalCam", "FillAvgSignal");
|
|---|
| 528 | MFillH fillx0c(&evt0c, "MSignalCam", "FillMaxSignal");
|
|---|
| 529 | MFillH fillx0d(&evt0d, "MSignalCam", "FillArrTm");
|
|---|
| 530 | MFillH fillx1("MHHillas", "MHillas", "FillHillas");
|
|---|
| 531 | //MFillH fillx2("MHHillasExt", "", "FillHillasExt");
|
|---|
| 532 | MFillH fillx3("MHHillasSrc", "MHillasSrc", "FillHillasSrc");
|
|---|
| 533 | //MFillH fillx4("MHImagePar", "MImagePar", "FillImagePar");
|
|---|
| 534 | //MFillH fillx5("MHNewImagePar", "MNewImagePar", "FillNewImagePar");
|
|---|
| 535 |
|
|---|
| 536 | // -------------------------------------------------------------------
|
|---|
| 537 |
|
|---|
| 538 | if (header.IsDataRun())
|
|---|
| 539 | {
|
|---|
| 540 | tasks.AddToList(&read);
|
|---|
| 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 | }
|
|---|
| 550 | // if (header.IsPointRun())
|
|---|
| 551 | // tasks.AddToList(&stars);
|
|---|
| 552 | //tasks.AddToList(&print);
|
|---|
| 553 | tasks.AddToList(&fillh1);
|
|---|
| 554 | tasks.AddToList(&fillG);
|
|---|
| 555 | if (!header.IsPointRun())
|
|---|
| 556 | {
|
|---|
| 557 | tasks.AddToList(&absapd);
|
|---|
| 558 | tasks.AddToList(&absmir);
|
|---|
| 559 | }
|
|---|
| 560 | tasks.AddToList(&reflect);
|
|---|
| 561 | if (!header.IsPointRun())
|
|---|
| 562 | {
|
|---|
| 563 | tasks.AddToList(&fill0);
|
|---|
| 564 | tasks.AddToList(&fill1);
|
|---|
| 565 | tasks.AddToList(&fill2);
|
|---|
| 566 | tasks.AddToList(&fill3);
|
|---|
| 567 | tasks.AddToList(&fill4);
|
|---|
| 568 | tasks.AddToList(&fillF1);
|
|---|
| 569 | }
|
|---|
| 570 | tasks.AddToList(&cones);
|
|---|
| 571 | tasks.AddToList(&fillF2);
|
|---|
| 572 | //if (header.IsPointRun())
|
|---|
| 573 | // tasks.AddToList(&fillP);
|
|---|
| 574 | tasks.AddToList(&cont1);
|
|---|
| 575 | if (!header.IsPointRun())
|
|---|
| 576 | tasks.AddToList(&fillh2);
|
|---|
| 577 | }
|
|---|
| 578 | // -------------------------------
|
|---|
| 579 | tasks.AddToList(&apply);
|
|---|
| 580 | if (header.IsDataRun())
|
|---|
| 581 | {
|
|---|
| 582 | tasks.AddToList(&simpsf);
|
|---|
| 583 | tasks.AddToList(&simgeom);
|
|---|
| 584 | tasks.AddToList(&cont2);
|
|---|
| 585 | }
|
|---|
| 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 | }
|
|---|
| 594 | tasks.AddToList(&simsum);
|
|---|
| 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 | }
|
|---|
| 603 | tasks.AddToList(&simsignal); // What do we do if signal<0?
|
|---|
| 604 | if (!fPathOut.IsNull() && !HasNullOut())
|
|---|
| 605 | {
|
|---|
| 606 | tasks.AddToList(&write1a);
|
|---|
| 607 | if (!header.IsPedestalRun())
|
|---|
| 608 | tasks.AddToList(&write2a);
|
|---|
| 609 | if (fCamera)
|
|---|
| 610 | tasks.AddToList(&write3a);
|
|---|
| 611 | }
|
|---|
| 612 | // -------------------------------
|
|---|
| 613 | if (fCamera)
|
|---|
| 614 | {
|
|---|
| 615 | if (header.IsDataRun())
|
|---|
| 616 | tasks.AddToList(&fillh3);
|
|---|
| 617 | tasks.AddToList(&filltp);
|
|---|
| 618 | }
|
|---|
| 619 | if (header.IsDataRun())
|
|---|
| 620 | tasks.AddToList(&fillew);
|
|---|
| 621 | if (!header.IsPedestalRun())
|
|---|
| 622 | {
|
|---|
| 623 | tasks.AddToList(&fillx0a);
|
|---|
| 624 | tasks.AddToList(&fillx0c);
|
|---|
| 625 | //tasks.AddToList(&clean);
|
|---|
| 626 | tasks.AddToList(&hcalc);
|
|---|
| 627 | tasks.AddToList(&fillx0d);
|
|---|
| 628 | tasks.AddToList(&fillx1);
|
|---|
| 629 | //tasks.AddToList(&fillx2);
|
|---|
| 630 | tasks.AddToList(&fillx3);
|
|---|
| 631 | //tasks.AddToList(&fillx4);
|
|---|
| 632 | //tasks.AddToList(&fillx5);
|
|---|
| 633 | }
|
|---|
| 634 | //-------------------------------------------
|
|---|
| 635 |
|
|---|
| 636 | tasks.SetAccelerator(MTask::kAccDontReset|MTask::kAccDontTime);
|
|---|
| 637 |
|
|---|
| 638 | // Create and setup the eventloop
|
|---|
| 639 | MEvtLoop evtloop(fName);
|
|---|
| 640 | evtloop.SetParList(&plist);
|
|---|
| 641 | evtloop.SetDisplay(fDisplay);
|
|---|
| 642 | evtloop.SetLogStream(&gLog);
|
|---|
| 643 | if (!SetupEnv(evtloop))
|
|---|
| 644 | return kFALSE;
|
|---|
| 645 |
|
|---|
| 646 | //-------------------------------------------
|
|---|
| 647 |
|
|---|
| 648 | if (binstr.IsDefault())
|
|---|
| 649 | binstr.SetEdgesLin(150, -shape.GetPulseWidth(),
|
|---|
| 650 | header.GetFreqSampling()/1000.*header.GetNumSamples()+shape.GetPulseWidth());
|
|---|
| 651 |
|
|---|
| 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 | //-------------------------------------------
|
|---|
| 715 |
|
|---|
| 716 | // Execute first analysis
|
|---|
| 717 | if (!evtloop.Eventloop(fMaxEvents))
|
|---|
| 718 | {
|
|---|
| 719 | gLog << err << GetDescriptor() << ": Failed." << endl;
|
|---|
| 720 | return kFALSE;
|
|---|
| 721 | }
|
|---|
| 722 |
|
|---|
| 723 | //-------------------------------------------
|
|---|
| 724 | // FIXME: Display Spline in tab
|
|---|
| 725 | // FIXME: Display Reflector in tab
|
|---|
| 726 | // FIXME: Display Routing(?) in tab
|
|---|
| 727 | // FIXME: Display Camera(s) in tab
|
|---|
| 728 | //-------------------------------------------
|
|---|
| 729 |
|
|---|
| 730 | if (!WriteResult(plist))
|
|---|
| 731 | return kFALSE;
|
|---|
| 732 |
|
|---|
| 733 | *fLog << all << GetDescriptor() << ": Done." << endl << endl << endl;;
|
|---|
| 734 |
|
|---|
| 735 | return kTRUE;
|
|---|
| 736 | }
|
|---|