/* ======================================================================== *\ ! ! * ! * 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, 2016 ! ! Copyright: MAGIC Software Development, 2016 ! ! \* ======================================================================== */ ////////////////////////////////////////////////////////////////////////////// // // MSoftwareTriggerCalc // ////////////////////////////////////////////////////////////////////////////// #include "MSoftwareTriggerCalc.h" #include #include "MLog.h" #include "MLogManip.h" #include "MParList.h" #include "MRawEvtData.h" #include "MSoftwareTrigger.h" #include "MPedestalSubtractedEvt.h" ClassImp(MSoftwareTriggerCalc); using namespace std; // -------------------------------------------------------------------------- // // Default constructor. // MSoftwareTriggerCalc::MSoftwareTriggerCalc(const char *name, const char *title) : fRawEvt(0), fSignal(0), fTrigger(0) { fName = name ? name : "MSoftwareTriggerCalc"; fTitle = title ? title : "Calculate the FACT trigger in software"; } // -------------------------------------------------------------------------- // Int_t MSoftwareTriggerCalc::PreProcess(MParList *pList) { fRawEvt = (MRawEvtData*)pList->FindObject("MRawEvtData");//, AddSerialNumber(fNamePedestalSubtractedEvt)); if (!fRawEvt) { *fLog << err << "MRawEvtData not found... aborting." << endl; return kFALSE; } fSignal = (MPedestalSubtractedEvt*)pList->FindObject("MPedestalSubtractedEvt");//, AddSerialNumber(fNamePedestalSubtractedEvt)); if (!fSignal) { *fLog << err << "MPedestalSubtractedEvt not found... aborting." << endl; return kFALSE; } fTrigger = (MSoftwareTrigger*)pList->FindCreateObj("MSoftwareTrigger"); if (!fTrigger) return kFALSE; return kTRUE; } // -------------------------------------------------------------------------- // Bool_t MSoftwareTriggerCalc::ReInit(MParList *pList) { // FIXME: Check number of samples! return kTRUE; } // -------------------------------------------------------------------------- // Int_t MSoftwareTriggerCalc::Process() { const UInt_t nch = fRawEvt->GetNumPixels(); // HW Channels in file [1440] const UInt_t npix = fSignal->GetNumPixels(); // Pixel in camera [1440 or 64] const UShort_t *ids = fRawEvt->GetPixelIds(); // FACT: Exclude time marker, FAMOUS take the whole range const int beg = 10; const int end = npix==1440 ? std::min(UInt_t(200), fSignal->GetNumSamples()) : fSignal->GetNumSamples()-10; const int num = end-beg; MArrayF buf(160*num); double avg = 0; for (UInt_t hw=0; hw=npix) continue; if (npix==1440) // FACT[1440] else FAMOUS[64] { // dead pixels if (hw==927 || hw==80 || hw==873) // 3 continue; // crazy pixels if (hw==863 || hw==297 || hw==868) // 3 continue; // broken DRS board if (hw>=720 && hw<=728) // 9 continue; // broken/suspicious bias channels if ((hw>=171 && hw<=174) || (hw>=184 && hw<=188)) // 9 continue; } const Float_t *raw = fSignal->GetSamples(ids[hw]); Float_t *sum = buf.GetArray()+(hw/9)*num; // Sum all nine pixel of one trigger patch for (const Float_t *ptr=raw+beg; ptr=0; e++) { Float_t *raw = buf.GetArray() + *e * num; for (Float_t *ptr=raw; ptrSetData(patch, avg, pos, max); fTrigger->SetReadyToSave(); return kTRUE; } // -------------------------------------------------------------------------- // Int_t MSoftwareTriggerCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print) { return kTRUE; }