/* ======================================================================== *\ ! ! * ! * This file is part of MARS, the MAGIC Analysis and Reconstruction ! * Software. It is distributed to you in the hope that it can be a useful ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes. ! * It is distributed WITHOUT ANY WARRANTY. ! * ! * Permission to use, copy, modify and distribute this software and its ! * documentation for any purpose is hereby granted without fee, ! * provided that the above copyright notice appear in all copies and ! * that both that copyright notice and this permission notice appear ! * in supporting documentation. It is provided "as is" without express ! * or implied warranty. ! * ! ! ! Author(s): Thomas Bretz, 4/2014 ! ! Copyright: MAGIC Software Development, 2014 ! ! \* ======================================================================== */ ///////////////////////////////////////////////////////////////////////////// // // MImgCleanTime // // Input Containers: // MGeomCam // MSignalCam // // Output Containers: // MSignalCam // ///////////////////////////////////////////////////////////////////////////// #include "MImgCleanTime.h" #include #include "MLog.h" #include "MLogManip.h" #include "MParList.h" #include "MGeomPix.h" #include "MGeomCam.h" #include "MSignalPix.h" #include "MSignalCam.h" ClassImp(MImgCleanTime); using namespace std; // -------------------------------------------------------------------------- // // Default constructor. Here you can specify the cleaning method and levels. // If you don't specify them the 'common standard' values 3.0 and 2.5 (sigma // above mean) are used. // Here you can also specify how many rings around the core pixels you want // to analyze (with the fixed lvl2). The default value for "rings" is 1. // MImgCleanTime::MImgCleanTime(const char *name, const char *title) : fCam(0), fEvt(0), fMinCount(0), fMinSize(25), fDeltaT(2.5*17.5*0.1111), fNameSignalCam("MSignalCam") { fName = name ? name : "MImgCleanTime"; fTitle = title ? title : "Task to perform image cleaning"; } // -------------------------------------------------------------------------- // // Check if MEvtHeader exists in the Parameter list already. // if not create one and add them to the list // Int_t MImgCleanTime::PreProcess (MParList *pList) { fCam = (MGeomCam*)pList->FindObject("MGeomCam"); if (!fCam) { *fLog << err << "MGeomCam not found (no geometry information available)... aborting." << endl; return kFALSE; } fEvt = (MSignalCam*)pList->FindObject(fNameSignalCam, "MSignalCam"); if (!fEvt) { *fLog << err << fNameSignalCam << " [MSignalCam] not found... aborting." << endl; return kFALSE; } return kTRUE; } Island MImgCleanTime::CalcIsland(MSignalPix &pix1, const MGeom &gpix1, const uint16_t &island1) { pix1.SetIdxIsland(island1); const Float_t time1 = pix1.GetArrivalTime(); Island island(pix1.GetNumPhotons(), time1); for (UInt_t i=0; i=0) { if (island1==island2) continue; // The entries are sorted naturally, therefore // there is no need to check the whole array const auto it = fContacts.rbegin(); if (it==fContacts.rend() || (it->first!=island1 && it->second!=island2)) fContacts.emplace_back(island1, island2); continue; } const Float_t time2 = pix2.GetArrivalTime(); if (fabs(time2-time1)GetNumPixels(); for (UInt_t i=0; ifirst]; const uint16_t &idx2 = fLut[it->second]; if (idx1==idx2) continue; // FIXME: Put a limit on count? Put a limit on size? if ((fIslands[idx1].minfIslands[idx2].max) && (fIslands[idx1].maxfIslands[idx2].max) && (fIslands[idx2].minfIslands[idx1].max) && (fIslands[idx2].maxfIslands[idx1].max)) continue; // Combine both islands fIslands[idx1] += fIslands[idx2]; // Remove idx2 from the list for (auto is=fLut.begin(); is!=fLut.end(); is++) if (*is==idx2) *is=idx1; // Erase entry form contact list fContacts.erase(it); // Start over again it = fContacts.begin(); } uint16_t num_islands = 0; double size_main = 0; double size_tot = 0; vector used(fIslands.size()); for (UInt_t i=0; isize_main) size_main = island.size; } pix.SetPixelUsed(); pix.SetPixelCore(); } fEvt->SetIslandInfo(num_islands, size_main, size_tot-size_main); return kTRUE; } // -------------------------------------------------------------------------- // Int_t MImgCleanTime::ReadEnv(const TEnv &env, TString prefix, Bool_t print) { Bool_t rc = kFALSE; if (IsEnvDefined(env, prefix, "MinSize", print)) { rc = kTRUE; SetMinSize(GetEnvValue(env, prefix, "MinSize", fMinSize)); } if (IsEnvDefined(env, prefix, "MinCount", print)) { rc = kTRUE; SetMinSize(GetEnvValue(env, prefix, "MinCount", (Int_t)fMinCount)); } if (IsEnvDefined(env, prefix, "DeltaT", print)) { rc = kTRUE; SetMinSize(GetEnvValue(env, prefix, "DeltaT", fDeltaT)); } return rc; }