| 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): David Paneque 02/2004 <mailto:dpaneque@mppmu.mpg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2004
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MTSupercutsApplied
|
|---|
| 28 | //
|
|---|
| 29 | // Class derived from TObject and containing a TTree object
|
|---|
| 30 | // used to store the values of the Supercuts applied
|
|---|
| 31 | // to each single event. The supercuts are dynamic, which means that
|
|---|
| 32 | // the cuts depend on the characterics (size, theta, distance) of the
|
|---|
| 33 | // individual events.
|
|---|
| 34 | // For the time being, only Length, Width and Dist are used, yet in
|
|---|
| 35 | // the future more parameters will be added (conc, asym...)
|
|---|
| 36 | //
|
|---|
| 37 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 38 |
|
|---|
| 39 | #include "MTSupercutsApplied.h"
|
|---|
| 40 |
|
|---|
| 41 | #include <TObject.h>
|
|---|
| 42 |
|
|---|
| 43 | #include "MLog.h"
|
|---|
| 44 | #include "MLogManip.h"
|
|---|
| 45 |
|
|---|
| 46 | ClassImp(MTSupercutsApplied);
|
|---|
| 47 |
|
|---|
| 48 | using namespace std;
|
|---|
| 49 |
|
|---|
| 50 | // --------------------------------------------------------------------------
|
|---|
| 51 | //
|
|---|
| 52 | // Default constructor.
|
|---|
| 53 | //
|
|---|
| 54 | MTSupercutsApplied::MTSupercutsApplied(const char* name, const char* title)
|
|---|
| 55 | {
|
|---|
| 56 | fName = name ? name : "MTSupercutsApplied";
|
|---|
| 57 | fTitle = title ? title : "Storage container for the dynamical supercuts";
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 | // TTree object is initialized with same name and titles as parent object
|
|---|
| 61 |
|
|---|
| 62 | fRootTree = new TTree (name, title);
|
|---|
| 63 |
|
|---|
| 64 | fBranchesCreated = kFALSE;
|
|---|
| 65 |
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | // --------------------------------------------------------------------------
|
|---|
| 69 | // DESTRUCTOR deletes dynamic memory allocated for TTree and vectors
|
|---|
| 70 |
|
|---|
| 71 | MTSupercutsApplied::~MTSupercutsApplied()
|
|---|
| 72 | {
|
|---|
| 73 |
|
|---|
| 74 | // If I release the dynamic memory ocupied by this guys a segmentation
|
|---|
| 75 | // fault is produced. I guess this is due to the fact that tryis to
|
|---|
| 76 | // remove something which has been writtenn into a root file...
|
|---|
| 77 | // not sure...
|
|---|
| 78 |
|
|---|
| 79 | // Anyhow, this occupies very little memory... it will not load
|
|---|
| 80 | // too much the system.
|
|---|
| 81 |
|
|---|
| 82 | //delete fCutParameters;
|
|---|
| 83 | //delete fShowerParamBranchName;
|
|---|
| 84 | //delete fRootTree;
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 | // Function that creates the branches of the TTree object
|
|---|
| 93 |
|
|---|
| 94 | Bool_t MTSupercutsApplied::CreateTreeBranches()
|
|---|
| 95 | {
|
|---|
| 96 |
|
|---|
| 97 | // Names of the branches is fixed for the time being
|
|---|
| 98 |
|
|---|
| 99 | fCutParamBranchName = ("SupercutsApplied");
|
|---|
| 100 | fShowerParamBranchName = ("ShowerParameters");
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 | // Number of parameters for the 2 branches is set in cosntructor.
|
|---|
| 104 | // In later versions I might do it in such a way that can be set
|
|---|
| 105 | // by user
|
|---|
| 106 |
|
|---|
| 107 | fNCutParameters = 13;
|
|---|
| 108 | fNShowerParameters = 10;
|
|---|
| 109 |
|
|---|
| 110 |
|
|---|
| 111 | const Int_t dimscparam = fNCutParameters;
|
|---|
| 112 | const Int_t dimshowerparam = fNShowerParameters;
|
|---|
| 113 |
|
|---|
| 114 | fCutParameters = new Double_t [dimscparam];
|
|---|
| 115 | fShowerParameters = new Double_t [dimshowerparam];
|
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 | // Cut parameters names and types for branch CutParameters
|
|---|
| 120 | // will be stored in a member data TString fCutParametersNamesTypes
|
|---|
| 121 | // Eventually might be set from outside the class
|
|---|
| 122 |
|
|---|
| 123 | TString StringVector[dimscparam];
|
|---|
| 124 | StringVector[0] = ("LengthUp/D");
|
|---|
| 125 | StringVector[1] = ("LengthLow/D");
|
|---|
| 126 | StringVector[2] = ("WidthUp/D");
|
|---|
| 127 | StringVector[3] = ("WidthLow/D");
|
|---|
| 128 | StringVector[4] = ("DistUp/D");
|
|---|
| 129 | StringVector[5] = ("DistLow/D");
|
|---|
| 130 | StringVector[6] = ("AsymUp/D");
|
|---|
| 131 | StringVector[7] = ("AsymLow/D");
|
|---|
| 132 | StringVector[8] = ("Log10ConcUp/D");
|
|---|
| 133 | StringVector[9] = ("Log10ConcLow/D");
|
|---|
| 134 | StringVector[10] = ("LeakageUp/D");
|
|---|
| 135 | StringVector[11] = ("LeakageLow/D");
|
|---|
| 136 | StringVector[12] = ("Hadronness/D");
|
|---|
| 137 |
|
|---|
| 138 | fCutParametersNamesTypes = StringVector[0];
|
|---|
| 139 | for (Int_t i = 1; i < dimscparam; i++)
|
|---|
| 140 | {
|
|---|
| 141 | fCutParametersNamesTypes += (":");
|
|---|
| 142 | fCutParametersNamesTypes += StringVector[i];
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 | // Cut parameters names and types for branch CutParameters
|
|---|
| 147 | // will be stored in a member data TString fShowerParametersNamesTypes
|
|---|
| 148 | // Eventually might be set from outside the class
|
|---|
| 149 |
|
|---|
| 150 | TString StringVector2[dimshowerparam];
|
|---|
| 151 |
|
|---|
| 152 | StringVector2[0] = ("Length/D");
|
|---|
| 153 | StringVector2[1] = ("Width/D");
|
|---|
| 154 | StringVector2[2] = ("Dist/D");
|
|---|
| 155 | StringVector2[3] = ("NewDist/D");
|
|---|
| 156 | StringVector2[4] = ("Asym/D");
|
|---|
| 157 | StringVector2[5] = ("Log10Conc/D");
|
|---|
| 158 | StringVector2[6] = ("Leakage/D");
|
|---|
| 159 | StringVector2[7] = ("Theta/D");
|
|---|
| 160 | StringVector2[8] = ("Size/D");
|
|---|
| 161 | StringVector2[9] = ("Alpha/D");
|
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 | fShowerParametersNamesTypes = StringVector2[0];
|
|---|
| 166 | for (Int_t i = 1; i < dimshowerparam; i++)
|
|---|
| 167 | {
|
|---|
| 168 | fShowerParametersNamesTypes += (":");
|
|---|
| 169 | fShowerParametersNamesTypes += StringVector2[i];
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 | *fLog << "MTSupercutsApplied::CreateTreeBranches()" << endl
|
|---|
| 174 | << "Branches created are the following ones (BranchName; Parameters)" << endl
|
|---|
| 175 | << fCutParamBranchName << " ; " << fCutParametersNamesTypes << endl
|
|---|
| 176 | << fShowerParamBranchName << " ; " << fShowerParametersNamesTypes << endl;
|
|---|
| 177 |
|
|---|
| 178 |
|
|---|
| 179 | // Branches are finally created
|
|---|
| 180 |
|
|---|
| 181 | fRootTree -> Branch(fCutParamBranchName.Data(),
|
|---|
| 182 | fCutParameters, fCutParametersNamesTypes.Data());
|
|---|
| 183 |
|
|---|
| 184 | fRootTree -> Branch(fShowerParamBranchName.Data(),
|
|---|
| 185 | fShowerParameters, fShowerParametersNamesTypes.Data());
|
|---|
| 186 |
|
|---|
| 187 | fBranchesCreated = kTRUE;
|
|---|
| 188 |
|
|---|
| 189 |
|
|---|
| 190 | /*
|
|---|
| 191 |
|
|---|
| 192 | fRootTree -> Branch("LengthUp", &fLengthUp, "LengthUp/D");
|
|---|
| 193 | fRootTree -> Branch("LengthLow", &fLengthLow, "LengthLow/D");
|
|---|
| 194 | fRootTree -> Branch("WidthUp", &fWidthUp, "WidthUp/D");
|
|---|
| 195 | fRootTree -> Branch("Widthlow", &fWidthLow, "WidthLow/D");
|
|---|
| 196 | fRootTree -> Branch("DistUp", &fDistUp, "DistUp/D");
|
|---|
| 197 | fRootTree -> Branch("DistLow", &fDistLow, "DistLow/D");
|
|---|
| 198 |
|
|---|
| 199 | */
|
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 | *fLog << "MTSupercutsApplied::CreateTreeBranches();" << endl
|
|---|
| 203 | << "Branches created successfully in TTree object" << endl;
|
|---|
| 204 |
|
|---|
| 205 | return kTRUE;
|
|---|
| 206 |
|
|---|
| 207 | }
|
|---|
| 208 |
|
|---|
| 209 | Bool_t MTSupercutsApplied::FillTreeBranches(const TArrayD cutparameters,
|
|---|
| 210 | const TArrayD showerparameters)
|
|---|
| 211 | {
|
|---|
| 212 |
|
|---|
| 213 | // Check that branches have been created
|
|---|
| 214 | if(!fBranchesCreated)
|
|---|
| 215 | {
|
|---|
| 216 | *fLog << "MTSupercutsApplied::FillTreeBranches" << endl
|
|---|
| 217 | << "Branches for the Tree object have not been created yet..."
|
|---|
| 218 | << "Therefore Tree can not be filled" << endl;
|
|---|
| 219 |
|
|---|
| 220 | return kFALSE;
|
|---|
| 221 |
|
|---|
| 222 | }
|
|---|
| 223 |
|
|---|
| 224 | // Check that dimensions of the argument vectors match with the
|
|---|
| 225 | // dimension of the vectors whose addresses are given to the branches
|
|---|
| 226 |
|
|---|
| 227 | if (fNCutParameters != cutparameters.GetSize()
|
|---|
| 228 | || fNShowerParameters != showerparameters.GetSize())
|
|---|
| 229 | {
|
|---|
| 230 | *fLog << "MTSupercutsApplied::FillTreeBranches" << endl
|
|---|
| 231 | << "Dimension of arrays used in the argument of this function "
|
|---|
| 232 | << "do not match with the dimension of the arrays used in the branches"
|
|---|
| 233 | << endl;
|
|---|
| 234 |
|
|---|
| 235 | return kFALSE;
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | // Parameters are transferred to the member data vectors
|
|---|
| 239 |
|
|---|
| 240 | for (Int_t i = 0; i < fNCutParameters; i++)
|
|---|
| 241 | {
|
|---|
| 242 | fCutParameters[i] = double (cutparameters[i]);
|
|---|
| 243 | }
|
|---|
| 244 |
|
|---|
| 245 | for (Int_t i = 0; i < fNShowerParameters; i++)
|
|---|
| 246 | {
|
|---|
| 247 | fShowerParameters[i] = double (showerparameters[i]);
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 |
|
|---|
| 251 | // Branches are finally filled
|
|---|
| 252 |
|
|---|
| 253 | fRootTree -> Fill();
|
|---|
| 254 |
|
|---|
| 255 | return kTRUE;
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 |
|
|---|
| 259 |
|
|---|
| 260 |
|
|---|
| 261 |
|
|---|
| 262 |
|
|---|
| 263 |
|
|---|
| 264 |
|
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 |
|
|---|
| 275 |
|
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 |
|
|---|
| 280 |
|
|---|
| 281 |
|
|---|