| 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 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | ! Author(s): Harald Kornmayer 1/2001
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2002
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | //
|
|---|
| 28 | // MHMcCollectionAreaCalc
|
|---|
| 29 | //
|
|---|
| 30 | // Remark: The initialization is maily done in the ReInit function.
|
|---|
| 31 | // Please make sure, that you don't use MReadTree when processing
|
|---|
| 32 | // a file. Use a 'ReInit'-calling task like MReadMarsFile
|
|---|
| 33 | //
|
|---|
| 34 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 35 |
|
|---|
| 36 | #include "MMcCollectionAreaCalc.h"
|
|---|
| 37 |
|
|---|
| 38 | #include "MParList.h"
|
|---|
| 39 |
|
|---|
| 40 | #include "MLog.h"
|
|---|
| 41 | #include "MLogManip.h"
|
|---|
| 42 |
|
|---|
| 43 | #include "MMcEvt.hxx"
|
|---|
| 44 | #include "MMcTrig.hxx"
|
|---|
| 45 | #include "MMcRunHeader.hxx"
|
|---|
| 46 |
|
|---|
| 47 | #include "MHMcCollectionArea.h"
|
|---|
| 48 |
|
|---|
| 49 | ClassImp(MMcCollectionAreaCalc);
|
|---|
| 50 |
|
|---|
| 51 | MMcCollectionAreaCalc::MMcCollectionAreaCalc(const char *input,
|
|---|
| 52 | const char *name, const char *title)
|
|---|
| 53 | {
|
|---|
| 54 | fName = name ? name : "MMcCollectionAreaCalc";
|
|---|
| 55 | fTitle = title ? title : "Task to calculate the collection area";
|
|---|
| 56 |
|
|---|
| 57 | fObjName = input ? input : "MMcTrig";
|
|---|
| 58 | AddToBranchList(Form("%s.fNumFirstLevel", input));
|
|---|
| 59 |
|
|---|
| 60 | AddToBranchList("MMcEvt.fEnergy");
|
|---|
| 61 | AddToBranchList("MMcEvt.fImpact");
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | Bool_t MMcCollectionAreaCalc::PreProcess (MParList *pList)
|
|---|
| 65 | {
|
|---|
| 66 | // connect the raw data with this task
|
|---|
| 67 |
|
|---|
| 68 | fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
|
|---|
| 69 | if (!fMcEvt)
|
|---|
| 70 | {
|
|---|
| 71 | *fLog << err << dbginf << "MMcEvt not found... exit." << endl;
|
|---|
| 72 | return kFALSE;
|
|---|
| 73 | }
|
|---|
| 74 |
|
|---|
| 75 | fCollArea = (MHMcCollectionArea*)pList->FindCreateObj("MHMcCollectionArea");
|
|---|
| 76 | if (!fCollArea)
|
|---|
| 77 | return kFALSE;
|
|---|
| 78 |
|
|---|
| 79 | fTheta = -1;
|
|---|
| 80 | fTotalNumSimulatedShowers = 0;
|
|---|
| 81 | fCorsikaVersion = 0;
|
|---|
| 82 | fAllEvtsTriggered = kFALSE;
|
|---|
| 83 |
|
|---|
| 84 | return kTRUE;
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | Bool_t MMcCollectionAreaCalc::ReInit(MParList *plist)
|
|---|
| 88 | {
|
|---|
| 89 | MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader");
|
|---|
| 90 | if (!runheader)
|
|---|
| 91 | {
|
|---|
| 92 | *fLog << err << dbginf << "Error - MMcRunHeader not found... exit." << endl;
|
|---|
| 93 | return kFALSE;
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers();
|
|---|
| 97 |
|
|---|
| 98 | *fLog << inf << "Total Number of Simulated showers: " << fTotalNumSimulatedShowers << endl;
|
|---|
| 99 |
|
|---|
| 100 | if (fTheta>=0 && fTheta!=runheader->GetTelesTheta())
|
|---|
| 101 | {
|
|---|
| 102 | *fLog << warn << dbginf << "Warning - Read files have different TelesTheta (";
|
|---|
| 103 | *fLog << fTheta << ", " << runheader->GetTelesTheta() << ")..." << endl;
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | fTheta = runheader->GetTelesTheta();
|
|---|
| 107 |
|
|---|
| 108 | if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion())
|
|---|
| 109 | *fLog << warn << dbginf << "Warning - Read files have different Corsika versions..." << endl;
|
|---|
| 110 |
|
|---|
| 111 | fCorsikaVersion = runheader->GetCorsikaVersion();
|
|---|
| 112 |
|
|---|
| 113 | fAllEvtsTriggered |= runheader->GetAllEvtsTriggered();
|
|---|
| 114 |
|
|---|
| 115 | *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl;
|
|---|
| 116 |
|
|---|
| 117 | if (fAllEvtsTriggered)
|
|---|
| 118 | return kTRUE;
|
|---|
| 119 |
|
|---|
| 120 | fMcTrig = (MMcTrig*)plist->FindObject(fObjName);
|
|---|
| 121 | if (!fMcTrig)
|
|---|
| 122 | {
|
|---|
| 123 | *fLog << err << dbginf << fObjName << " [MMcTrig] not found... exit." << endl;
|
|---|
| 124 | return kFALSE;
|
|---|
| 125 | }
|
|---|
| 126 |
|
|---|
| 127 | return kTRUE;
|
|---|
| 128 | }
|
|---|
| 129 |
|
|---|
| 130 | Bool_t MMcCollectionAreaCalc::Process()
|
|---|
| 131 | {
|
|---|
| 132 | // *fLog << all << fMcEvt << " " << (int)fAllEvtsTriggered << " " << fCollArea << endl;
|
|---|
| 133 | const Float_t energy = fMcEvt->GetEnergy();
|
|---|
| 134 | const Float_t impact = fMcEvt->GetImpact()/100.;
|
|---|
| 135 |
|
|---|
| 136 | if (!fAllEvtsTriggered)
|
|---|
| 137 | {
|
|---|
| 138 | fCollArea->FillAll(energy, impact);
|
|---|
| 139 |
|
|---|
| 140 | if (fMcTrig->GetFirstLevel() <= 0)
|
|---|
| 141 | return kTRUE;
|
|---|
| 142 | }
|
|---|
| 143 |
|
|---|
| 144 | fCollArea->FillSel(energy, impact);
|
|---|
| 145 |
|
|---|
| 146 | return kTRUE;
|
|---|
| 147 | }
|
|---|
| 148 |
|
|---|
| 149 | Bool_t MMcCollectionAreaCalc::PostProcess()
|
|---|
| 150 | {
|
|---|
| 151 | //
|
|---|
| 152 | // do the calculation of the effectiv area
|
|---|
| 153 | //
|
|---|
| 154 | *fLog << inf << "Calculation Collection Area..." << endl;
|
|---|
| 155 |
|
|---|
| 156 | if (!fAllEvtsTriggered)
|
|---|
| 157 | fCollArea->CalcEfficiency();
|
|---|
| 158 | else
|
|---|
| 159 | {
|
|---|
| 160 | *fLog << inf << "Total number of showers: " << fTotalNumSimulatedShowers << endl;
|
|---|
| 161 | fCollArea->CalcEfficiency(fTotalNumSimulatedShowers,
|
|---|
| 162 | fCorsikaVersion == 5200 ? fTheta : 0);
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | return kTRUE;
|
|---|
| 166 | }
|
|---|
| 167 |
|
|---|