/* ======================================================================== *\ ! ! * ! * 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, 2014 ! ! Copyright: MAGIC Software Development, 2014 ! ! \* ======================================================================== */ ////////////////////////////////////////////////////////////////////////////// // // MTreatSaturation // ////////////////////////////////////////////////////////////////////////////// #include "MTreatSaturation.h" #include #include #include "MLog.h" #include "MLogManip.h" #include "MParList.h" #include "MRawRunHeader.h" #include "MExtralgoSpline.h" #include "MArrivalTimeCam.h" #include "MArrivalTimePix.h" #include "MExtractedSignalCam.h" #include "MExtractedSignalPix.h" #include "MPedestalSubtractedEvt.h" ClassImp(MTreatSaturation); using namespace std; // -------------------------------------------------------------------------- // // Default constructor. // MTreatSaturation::MTreatSaturation(const char *name, const char *title) : fRaw(0), fEvt(0) { fName = name ? name : "MTreatSaturation"; fTitle = title ? title : "Base class for replacing saturation with pulses"; } // -------------------------------------------------------------------------- // Int_t MTreatSaturation::PreProcess(MParList *pList) { fRaw = (MRawEvtData*)pList->FindObject("MRawEvtData"); if (!fRaw) { *fLog << err << "MRawEvtData not found... aborting." << endl; return kFALSE; } fEvt = (MPedestalSubtractedEvt*)pList->FindObject("MPedestalSubtractedEvt"); if (!fEvt) { *fLog << err << "MPedestalSubtractedEvt not found... aborting." << endl; return kFALSE; } return kTRUE; } // -------------------------------------------------------------------------- // Int_t MTreatSaturation::Process() { const UInt_t fHiGainFirst = 50; const UInt_t fHiGainLast = 225; const UInt_t npix = fEvt->GetNumPixels(); const UInt_t rangehi = fHiGainLast - fHiGainFirst - 1; if (fDev1.GetSize()!=rangehi) { fDev1.Set(rangehi); fDev2.Set(rangehi); } for (UInt_t ch=0; chGetSamples(ch); const Float_t *pbeg = ptr+fHiGainFirst+1; const Float_t *pend = ptr+fHiGainLast-1; // Find maximum const Float_t *pmax = pbeg; for (const Float_t *p=pbeg; p*pmax) pmax = p; // Is there any chance for saturation? if (*pmax<1900) continue; // Determine a rough estimate for the average baseline double baseline = 0; for (const Float_t *p=ptr+10; pptr[i]) ptr[i] = v; } } return kTRUE; }