| 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): Wolfgang Wittek 02/2003 <wittek@mppmu.mpg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2002
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | // //
|
|---|
| 27 | // MSelBasic //
|
|---|
| 28 | // //
|
|---|
| 29 | // This is a task to evaluate basic cuts //
|
|---|
| 30 | // //
|
|---|
| 31 | // to be called after the calibration (when the number of photons is //
|
|---|
| 32 | // available for all pixels) //
|
|---|
| 33 | // //
|
|---|
| 34 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 35 |
|
|---|
| 36 | #include "MSelBasic.h"
|
|---|
| 37 |
|
|---|
| 38 | #include "MParList.h"
|
|---|
| 39 |
|
|---|
| 40 | #include "MHillas.h"
|
|---|
| 41 | #include "MCerPhotEvt.h"
|
|---|
| 42 | #include "MMcEvt.hxx"
|
|---|
| 43 | #include "MRawRunHeader.h"
|
|---|
| 44 | #include "MGeomCam.h"
|
|---|
| 45 | #include "MPedestalCam.h"
|
|---|
| 46 | #include "MPedestalPix.h"
|
|---|
| 47 | #include "MGeomPix.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "MLog.h"
|
|---|
| 50 | #include "MLogManip.h"
|
|---|
| 51 |
|
|---|
| 52 | ClassImp(MSelBasic);
|
|---|
| 53 |
|
|---|
| 54 | // --------------------------------------------------------------------------
|
|---|
| 55 | //
|
|---|
| 56 | // Default constructor.
|
|---|
| 57 | //
|
|---|
| 58 | MSelBasic::MSelBasic(const char *name, const char *title)
|
|---|
| 59 | {
|
|---|
| 60 | fName = name ? name : "MSelBasic";
|
|---|
| 61 | fTitle = title ? title : "Task to evaluate basic cuts";
|
|---|
| 62 |
|
|---|
| 63 | ThetaMin = 0.0;
|
|---|
| 64 | ThetaMax = 60.0;
|
|---|
| 65 | }
|
|---|
| 66 |
|
|---|
| 67 | // --------------------------------------------------------------------------
|
|---|
| 68 | //
|
|---|
| 69 | //
|
|---|
| 70 | //
|
|---|
| 71 | //
|
|---|
| 72 | //
|
|---|
| 73 | Bool_t MSelBasic::PreProcess(MParList *pList)
|
|---|
| 74 | {
|
|---|
| 75 | fRawRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
|
|---|
| 76 | if (!fRawRun)
|
|---|
| 77 | {
|
|---|
| 78 | *fLog << dbginf << "MRawRunHeader not found... aborting." << endl;
|
|---|
| 79 | return kFALSE;
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | fMcEvt = (MMcEvt*)pList->FindObject("MMcEvt");
|
|---|
| 83 | if (!fMcEvt)
|
|---|
| 84 | {
|
|---|
| 85 | *fLog << dbginf << "MMcEvt not found... aborting." << endl;
|
|---|
| 86 | return kFALSE;
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | fEvt = (MCerPhotEvt*)pList->FindObject("MCerPhotEvt");
|
|---|
| 90 | if (!fEvt)
|
|---|
| 91 | {
|
|---|
| 92 | *fLog << dbginf << "MCerPhotEvt not found... aborting." << endl;
|
|---|
| 93 | return kFALSE;
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 | fCam = (MGeomCam*)pList->FindObject("MGeomCam");
|
|---|
| 98 | if (!fCam)
|
|---|
| 99 | {
|
|---|
| 100 | *fLog << dbginf << "MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
|
|---|
| 101 | return kFALSE;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | fPed = (MPedestalCam*)pList->FindObject("MPedestalCam");
|
|---|
| 105 | if (!fPed)
|
|---|
| 106 | {
|
|---|
| 107 | *fLog << dbginf << "MPedestalCam missing in Parameter List... aborting." << endl;
|
|---|
| 108 | return kFALSE;
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | memset(fErrors, 0, sizeof(fErrors));
|
|---|
| 112 |
|
|---|
| 113 | return kTRUE;
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 | // --------------------------------------------------------------------------
|
|---|
| 117 | //
|
|---|
| 118 | // Evaluate basic cuts
|
|---|
| 119 | //
|
|---|
| 120 | // if cuts are fulfilled : return 0
|
|---|
| 121 | // if they are not fullfilled : skip remaining tasks for this event
|
|---|
| 122 | //
|
|---|
| 123 | Bool_t MSelBasic::Process()
|
|---|
| 124 | {
|
|---|
| 125 | /*
|
|---|
| 126 | //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
|---|
| 127 | *fLog << "=========================================================" << endl;
|
|---|
| 128 | *fLog << "" << endl;
|
|---|
| 129 | *fLog << "MmcEvt data : " << endl;
|
|---|
| 130 | *fLog << "" << endl;
|
|---|
| 131 | fMcEvt->Print();
|
|---|
| 132 | *fLog << "" << endl;
|
|---|
| 133 | *fLog << "PartId() = " << fMcEvt->GetPartId() << endl;
|
|---|
| 134 | *fLog << "Energy() = " << fMcEvt->GetEnergy() << endl;
|
|---|
| 135 | *fLog << "Theta() = " << fMcEvt->GetTheta() << endl;
|
|---|
| 136 |
|
|---|
| 137 | *fLog << "Phi() = " << fMcEvt->GetPhi() << endl;
|
|---|
| 138 | //*fLog << "CoreD() = " << fMcEvt->GetCoreD() << endl;
|
|---|
| 139 | //*fLog << "CoreX() = " << fMcEvt->GetCoreX() << endl;
|
|---|
| 140 |
|
|---|
| 141 | //*fLog << "CoreY() = " << fMcEvt->GetCoreY() << endl;
|
|---|
| 142 | *fLog << "Impact() = " << fMcEvt->GetImpact() << endl;
|
|---|
| 143 | //*fLog << "PhotIni()= " << fMcEvt->GetPhotIni() << endl;
|
|---|
| 144 |
|
|---|
| 145 | //*fLog << "PassPhotAtm() = " << fMcEvt->GetPassPhotAtm() << endl;
|
|---|
| 146 | //*fLog << "PassPhotRef() = " << fMcEvt->GetPassPhotRef() << endl;
|
|---|
| 147 | //*fLog << "PassPhotCone() = " << fMcEvt->GetPassPhotCone() << endl;
|
|---|
| 148 |
|
|---|
| 149 | //*fLog << "PhotElfromShower() = " << fMcEvt->GetPhotElfromShower() << endl;
|
|---|
| 150 | //*fLog << "PhotElinCamera() = " << fMcEvt->GetPhotElinCamera() << endl;
|
|---|
| 151 | *fLog << "TelescopePhi() = " << fMcEvt->GetTelescopePhi() << endl;
|
|---|
| 152 |
|
|---|
| 153 | *fLog << "TelescopeTheta() = " << fMcEvt->GetTelescopeTheta() << endl;
|
|---|
| 154 | *fLog << "Impact() = " << fMcEvt->GetImpact() << endl;
|
|---|
| 155 | //*fLog << "PhotIni()= " << fMcEvt->GetPhotIni() << endl;
|
|---|
| 156 | *fLog << "" << endl;
|
|---|
| 157 | *fLog << "=========================================================" << endl;
|
|---|
| 158 |
|
|---|
| 159 | *fLog << "=========================================================" << endl;
|
|---|
| 160 | *fLog << "" << endl;
|
|---|
| 161 | *fLog << "MPedestalPix data : " << endl;
|
|---|
| 162 | *fLog << "" << endl;
|
|---|
| 163 |
|
|---|
| 164 | Int_t ntot;
|
|---|
| 165 | ntot = fPed->GetSize();
|
|---|
| 166 | *fLog << "MeanRms() :" << endl;
|
|---|
| 167 | for (Int_t i=0; i<ntot; i++)
|
|---|
| 168 | {
|
|---|
| 169 | MPedestalPix &pix = (*fPed)[i];
|
|---|
| 170 | //*fLog << "Mean() = " << i << ", " << pix.GetMean() << endl;
|
|---|
| 171 | //*fLog << "Sigma() = " << i << ", " << pix.GetSigma() << endl;
|
|---|
| 172 | *fLog << pix.GetMeanRms() << " ";
|
|---|
| 173 | //*fLog << "SigmaRms()= " << i << ", " << pix.GetSigmaRms() << endl;
|
|---|
| 174 | }
|
|---|
| 175 | *fLog << "" << endl;
|
|---|
| 176 |
|
|---|
| 177 | *fLog << "" << endl;
|
|---|
| 178 | ntot = fEvt->GetNumPixels();
|
|---|
| 179 | *fLog << "MCerPhotPix : pix.GetNumPhotons()" << endl;
|
|---|
| 180 | for (Int_t i=0; i<ntot; i++)
|
|---|
| 181 | {
|
|---|
| 182 | MCerPhotPix &pix = (*fEvt)[i];
|
|---|
| 183 | *fLog << pix.GetNumPhotons() << " ";
|
|---|
| 184 | }
|
|---|
| 185 | *fLog << "" << endl;
|
|---|
| 186 |
|
|---|
| 187 | *fLog << "" << endl;
|
|---|
| 188 | ntot = fEvt->GetNumPixels();
|
|---|
| 189 | *fLog << "MCerPhotPix : pix.GetErrorPhot()" << endl;
|
|---|
| 190 | for (Int_t i=0; i<ntot; i++)
|
|---|
| 191 | {
|
|---|
| 192 | MCerPhotPix &pix = (*fEvt)[i];
|
|---|
| 193 | *fLog << pix.GetErrorPhot() << " ";
|
|---|
| 194 | }
|
|---|
| 195 | *fLog << "" << endl;
|
|---|
| 196 |
|
|---|
| 197 | //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
|---|
| 198 | */
|
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 | Int_t rc = 0;
|
|---|
| 202 |
|
|---|
| 203 | //if ( fRawRun->GetRunNumber() < 16279 )
|
|---|
| 204 | //{
|
|---|
| 205 | // rc = 1;
|
|---|
| 206 | // return kCONTINUE;
|
|---|
| 207 | //}
|
|---|
| 208 |
|
|---|
| 209 | Double_t Theta = kRad2Deg*fMcEvt->GetTelescopeTheta();
|
|---|
| 210 | if ( Theta < ThetaMin )
|
|---|
| 211 | {
|
|---|
| 212 | *fLog << "MSelBasic::Process; Run, Event, Theta = "
|
|---|
| 213 | << fRawRun->GetRunNumber()<< ", "
|
|---|
| 214 | << fMcEvt->GetEvtNumber() << ", " << Theta << endl;
|
|---|
| 215 | rc = 1;
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | else if ( Theta > ThetaMax )
|
|---|
| 219 | {
|
|---|
| 220 | rc = 2;
|
|---|
| 221 | }
|
|---|
| 222 |
|
|---|
| 223 | else if ( !SwTrigger() )
|
|---|
| 224 | {
|
|---|
| 225 | //*fLog << "MSelBasic::Process; SwTrigger = " << SwTrigger << endl;
|
|---|
| 226 | rc = 3;
|
|---|
| 227 | }
|
|---|
| 228 |
|
|---|
| 229 | fErrors[rc]++;
|
|---|
| 230 |
|
|---|
| 231 | return rc==0 ? kTRUE : kCONTINUE;
|
|---|
| 232 | }
|
|---|
| 233 | // --------------------------------------------------------------------------
|
|---|
| 234 | //
|
|---|
| 235 | // Software trigger
|
|---|
| 236 | //
|
|---|
| 237 | // require 2 neighboring pixels (which are not in the outermost ring),
|
|---|
| 238 | // each having at least 'minphotons' photons
|
|---|
| 239 | //
|
|---|
| 240 | //
|
|---|
| 241 | Bool_t MSelBasic::SwTrigger()
|
|---|
| 242 | {
|
|---|
| 243 | // minimum number of photons required
|
|---|
| 244 | Double_t minphotons = 13.0;
|
|---|
| 245 |
|
|---|
| 246 | const Int_t entries = fEvt->GetNumPixels();
|
|---|
| 247 |
|
|---|
| 248 | //$$$$$$$$$$$$$$$$$$
|
|---|
| 249 | //const Int_t nall = fPed->GetSize();
|
|---|
| 250 | //*fLog << "nall = " << nall << endl;
|
|---|
| 251 | //for (Int_t id=0; id<nall; id++)
|
|---|
| 252 | //{
|
|---|
| 253 | // MGeomPix &gpix = (*fCam)[id];
|
|---|
| 254 | // if ( gpix.IsInOutermostRing() )
|
|---|
| 255 | // {
|
|---|
| 256 | // *fLog << "IsInOutermostRing : pixel no. = " << id << endl;
|
|---|
| 257 | // }
|
|---|
| 258 |
|
|---|
| 259 | // if ( gpix.IsInOuterRing() )
|
|---|
| 260 | // {
|
|---|
| 261 | // *fLog << "IsInOuterRing : pixel no. = " << id << endl;
|
|---|
| 262 | // }
|
|---|
| 263 | //}
|
|---|
| 264 | //$$$$$$$$$$$$$$$$$$
|
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 | for (Int_t i=0; i<entries; i++)
|
|---|
| 268 | {
|
|---|
| 269 | MCerPhotPix &pix = (*fEvt)[i];
|
|---|
| 270 | Int_t id = pix.GetPixId();
|
|---|
| 271 | if (!pix.IsPixelUsed()) continue;
|
|---|
| 272 |
|
|---|
| 273 | Double_t photons = pix.GetNumPhotons();
|
|---|
| 274 | if (photons < minphotons) continue;
|
|---|
| 275 |
|
|---|
| 276 | // this pixel is used and has the required no.of photons
|
|---|
| 277 | // check whether this is also true for a neigboring pixel
|
|---|
| 278 |
|
|---|
| 279 | MGeomPix &gpix = (*fCam)[id];
|
|---|
| 280 | if ( gpix.IsInOutermostRing() ) continue;
|
|---|
| 281 |
|
|---|
| 282 | const Int_t nneighbors = gpix.GetNumNeighbors();
|
|---|
| 283 | for (Int_t n=0; n<nneighbors; n++)
|
|---|
| 284 | {
|
|---|
| 285 | const Int_t id1 = gpix.GetNeighbor(n);
|
|---|
| 286 | if ( !fEvt->IsPixelUsed(id1) ) continue;
|
|---|
| 287 |
|
|---|
| 288 | MGeomPix &gpix1 = (*fCam)[id1];
|
|---|
| 289 | if ( gpix1.IsInOutermostRing() ) continue;
|
|---|
| 290 |
|
|---|
| 291 | //MCerPhotPix &pix1 = (*fEvt)[id1];
|
|---|
| 292 | MCerPhotPix &pix1 = *(fEvt->GetPixById(id1));
|
|---|
| 293 | if ( &pix1 == NULL )
|
|---|
| 294 | {
|
|---|
| 295 | *fLog << "MSelBasic::SwTrigger; &pix1 is NULL" << endl;
|
|---|
| 296 | continue;
|
|---|
| 297 | }
|
|---|
| 298 |
|
|---|
| 299 | Double_t photons1 = pix1.GetNumPhotons();
|
|---|
| 300 | if (photons1 >= minphotons) return kTRUE;
|
|---|
| 301 | }
|
|---|
| 302 | }
|
|---|
| 303 | return kFALSE;
|
|---|
| 304 | }
|
|---|
| 305 |
|
|---|
| 306 | // --------------------------------------------------------------------------
|
|---|
| 307 | //
|
|---|
| 308 | // Prints some statistics about the Basic selections.
|
|---|
| 309 | //
|
|---|
| 310 | Bool_t MSelBasic::PostProcess()
|
|---|
| 311 | {
|
|---|
| 312 | if (GetNumExecutions()==0)
|
|---|
| 313 | return kTRUE;
|
|---|
| 314 |
|
|---|
| 315 | *fLog << inf << endl;
|
|---|
| 316 | *fLog << GetDescriptor() << " execution statistics:" << endl;
|
|---|
| 317 | *fLog << dec << setfill(' ');
|
|---|
| 318 | *fLog << " " << setw(7) << fErrors[1] << " (" << setw(3)
|
|---|
| 319 | << (int)(fErrors[1]*100/GetNumExecutions())
|
|---|
| 320 | << "%) Evts skipped due to: Zenith angle < " << ThetaMin << endl;
|
|---|
| 321 |
|
|---|
| 322 | *fLog << " " << setw(7) << fErrors[2] << " (" << setw(3)
|
|---|
| 323 | << (int)(fErrors[2]*100/GetNumExecutions())
|
|---|
| 324 | << "%) Evts skipped due to: Zenith angle > " << ThetaMax << endl;
|
|---|
| 325 |
|
|---|
| 326 | *fLog << " " << setw(7) << fErrors[3] << " (" << setw(3)
|
|---|
| 327 | << (int)(fErrors[3]*100/GetNumExecutions())
|
|---|
| 328 | << "%) Evts skipped due to: Software trigger not fullfilled" << endl;
|
|---|
| 329 |
|
|---|
| 330 | *fLog << " " << fErrors[0] << " (" << (int)(fErrors[0]*100/GetNumExecutions())
|
|---|
| 331 | << "%) Evts survived Basic selections!" << endl;
|
|---|
| 332 | *fLog << endl;
|
|---|
| 333 |
|
|---|
| 334 | return kTRUE;
|
|---|
| 335 | }
|
|---|
| 336 |
|
|---|
| 337 |
|
|---|