| 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/2002 <mailto:tbretz@astro.uni-wuerzburg.de> | 
|---|
| 19 | ! | 
|---|
| 20 | !   Copyright: MAGIC Software Development, 2000-2003 | 
|---|
| 21 | ! | 
|---|
| 22 | ! | 
|---|
| 23 | \* ======================================================================== */ | 
|---|
| 24 |  | 
|---|
| 25 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 26 | // | 
|---|
| 27 | // MHCerPhotEvt | 
|---|
| 28 | // | 
|---|
| 29 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 30 | #include "MHCerPhotEvt.h" | 
|---|
| 31 |  | 
|---|
| 32 | #include <TCanvas.h> | 
|---|
| 33 |  | 
|---|
| 34 | #include "MLog.h" | 
|---|
| 35 | #include "MLogManip.h" | 
|---|
| 36 |  | 
|---|
| 37 | #include "MParList.h" | 
|---|
| 38 | #include "MCamEvent.h" | 
|---|
| 39 | #include "MCamDisplay.h" | 
|---|
| 40 |  | 
|---|
| 41 | #include "MGeomCam.h" | 
|---|
| 42 | #include "MGeomPix.h" | 
|---|
| 43 |  | 
|---|
| 44 | ClassImp(MHCerPhotEvt); | 
|---|
| 45 |  | 
|---|
| 46 | using namespace std; | 
|---|
| 47 |  | 
|---|
| 48 | // -------------------------------------------------------------------------- | 
|---|
| 49 | // | 
|---|
| 50 | // Initialize the name and title of the task. | 
|---|
| 51 | // Resets the sum histogram | 
|---|
| 52 | // | 
|---|
| 53 | MHCerPhotEvt::MHCerPhotEvt(const char *name, const char *title) | 
|---|
| 54 | : fSum(NULL), fEvt(NULL) | 
|---|
| 55 | { | 
|---|
| 56 | // | 
|---|
| 57 | //   set the name and title of this object | 
|---|
| 58 | // | 
|---|
| 59 | fName  = name  ? name  : "MHCerPhotEvt"; | 
|---|
| 60 | fTitle = title ? title : "Average of MCerPhotEvts"; | 
|---|
| 61 | } | 
|---|
| 62 |  | 
|---|
| 63 | // -------------------------------------------------------------------------- | 
|---|
| 64 | // | 
|---|
| 65 | // Delete the corresponding camera display if available | 
|---|
| 66 | // | 
|---|
| 67 | MHCerPhotEvt::~MHCerPhotEvt() | 
|---|
| 68 | { | 
|---|
| 69 | if (fSum) | 
|---|
| 70 | delete fSum; | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 | // -------------------------------------------------------------------------- | 
|---|
| 74 | // | 
|---|
| 75 | // Get the event (MCerPhotEvt) the histogram might be filled with. If | 
|---|
| 76 | // it is not given, it is assumed, that it is filled with the argument | 
|---|
| 77 | // of the Fill function. | 
|---|
| 78 | // Looks for the camera geometry MGeomCam and resets the sum histogram. | 
|---|
| 79 | // | 
|---|
| 80 | Bool_t MHCerPhotEvt::SetupFill(const MParList *plist) | 
|---|
| 81 | { | 
|---|
| 82 | fEvt = (MCamEvent*)plist->FindObject(fNameEvt, "MCamEvent"); | 
|---|
| 83 | if (!fEvt) | 
|---|
| 84 | *fLog << warn << GetDescriptor() << ": No MCerPhotEvt available..." << endl; | 
|---|
| 85 |  | 
|---|
| 86 | MGeomCam *cam = (MGeomCam*)plist->FindObject("MGeomCam"); | 
|---|
| 87 | if (!cam) | 
|---|
| 88 | *fLog << warn << GetDescriptor() << ": No MGeomCam found." << endl; | 
|---|
| 89 |  | 
|---|
| 90 | if (fSum) | 
|---|
| 91 | delete (fSum); | 
|---|
| 92 | fSum = new MCamDisplay(*cam, fNameEvt+";avg", fNameEvt+" Avarage"); | 
|---|
| 93 |  | 
|---|
| 94 | return kTRUE; | 
|---|
| 95 | } | 
|---|
| 96 |  | 
|---|
| 97 | // -------------------------------------------------------------------------- | 
|---|
| 98 | // | 
|---|
| 99 | // Fill the histograms with data from a MCerPhotEvt-Container. | 
|---|
| 100 | // | 
|---|
| 101 | Bool_t MHCerPhotEvt::Fill(const MParContainer *par, const Stat_t w) | 
|---|
| 102 | { | 
|---|
| 103 | const MCamEvent *evt = par ? dynamic_cast<const MCamEvent*>(par) : fEvt; | 
|---|
| 104 | if (!evt) | 
|---|
| 105 | { | 
|---|
| 106 | *fLog << err << dbginf << "No MCerPhotEvt found..." << endl; | 
|---|
| 107 | return kFALSE; | 
|---|
| 108 | } | 
|---|
| 109 | fSum->AddCamContent(*evt); | 
|---|
| 110 |  | 
|---|
| 111 | return kTRUE; | 
|---|
| 112 | } | 
|---|
| 113 |  | 
|---|
| 114 | // -------------------------------------------------------------------------- | 
|---|
| 115 | // | 
|---|
| 116 | // Scale the sum container with the number of entries | 
|---|
| 117 | // | 
|---|
| 118 | Bool_t MHCerPhotEvt::Finalize() | 
|---|
| 119 | { | 
|---|
| 120 | if (fSum->GetEntries()>0) | 
|---|
| 121 | fSum->Scale(1./fSum->GetEntries()); | 
|---|
| 122 | return kTRUE; | 
|---|
| 123 | } | 
|---|
| 124 | /* | 
|---|
| 125 | // -------------------------------------------------------------------------- | 
|---|
| 126 | // | 
|---|
| 127 | // Draw the present 'fill status' | 
|---|
| 128 | // | 
|---|
| 129 | void MHCerPhotEvt::Draw(Option_t *) | 
|---|
| 130 | { | 
|---|
| 131 | if (!fSum) | 
|---|
| 132 | { | 
|---|
| 133 | *fLog << warn << "WARNING - Cannot draw " << GetDescriptor() << ": No Camera Geometry available." << endl; | 
|---|
| 134 | return; | 
|---|
| 135 | } | 
|---|
| 136 |  | 
|---|
| 137 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this, 750, 600); | 
|---|
| 138 | pad->SetBorderMode(0); | 
|---|
| 139 | //pad->Divide(1,1); | 
|---|
| 140 | //gPad->SetBorderMode(0); | 
|---|
| 141 |  | 
|---|
| 142 | AppendPad(""); | 
|---|
| 143 | } | 
|---|
| 144 |  | 
|---|
| 145 | // -------------------------------------------------------------------------- | 
|---|
| 146 | // | 
|---|
| 147 | // If a camera display is not yet assigned, assign a new one. | 
|---|
| 148 | // | 
|---|
| 149 | void MHCerPhotEvt::Paint(Option_t *option) | 
|---|
| 150 | { | 
|---|
| 151 | if (!fSum) | 
|---|
| 152 | return; | 
|---|
| 153 |  | 
|---|
| 154 | fSum->Paint(); | 
|---|
| 155 | } | 
|---|
| 156 | */ | 
|---|
| 157 |  | 
|---|
| 158 | TH1 *MHCerPhotEvt::GetHistByName(const TString name) | 
|---|
| 159 | { | 
|---|
| 160 | return fSum; | 
|---|
| 161 | } | 
|---|