//*-- Created : 04/12/2009 by I.Koenig //_HADES_CLASS_DESCRIPTION /////////////////////////////////////////////////////////////////////////////// // // HStart2HitF // // This class implements the hit finder for the Start2 detector. // /////////////////////////////////////////////////////////////////////////////// #include "hades.h" #include "hcategory.h" #include "hevent.h" #include "hruntimedb.h" #include "hspectrometer.h" #include "hstart2cal.h" #include "hstart2detector.h" #include "hstart2hit.h" #include "hstart2hitf.h" #include "hstart2hitfpar.h" #include "hstartdef.h" #include #include using namespace std; ClassImp(HStart2HitF) HStart2HitF::HStart2HitF(void) : HReconstructor() { // default constructor fCatCal = NULL; fCatHit = NULL; fPar = NULL; fSkipEvent = kFALSE; } HStart2HitF::HStart2HitF(const Text_t *name, const Text_t *title, Bool_t skip) : HReconstructor(name, title) { // constructor fCatCal = NULL; fCatHit = NULL; fPar = NULL; fSkipEvent = skip; } Bool_t HStart2HitF::init(void) { // gets the Start2Cal category and creates the Start2Hit category // creates an iterator which loops over all cells in Start2Cal // initialize parameter container HStart2Detector* det = static_cast(gHades->getSetup()->getDetector("Start")); if (NULL == det) { Error("init", "No Start Detector found."); return kFALSE; } fCatCal = gHades->getCurrentEvent()->getCategory(catStart2Cal); if (NULL == fCatCal) { Error("init", "HStart2Cal category not available!"); return kFALSE; } fCatHit = det->buildCategory(catStart2Hit); if (NULL == fCatHit) { Error("init", "HStart2Hit category not available!"); return kFALSE; } HRuntimeDb* rtdb = gHades->getRuntimeDb(); fPar = static_cast(rtdb->getContainer("Start2HitFPar")); if (NULL == fPar) { Error("init", "Pointer to Start2HitFPar parameters is NULL"); return kFALSE; } loc.set(1, 0); fActive = kTRUE; return kTRUE; } Int_t HStart2HitF::execute(void) { // makes the hits and fills the HStartHit category HStart2Cal* pCal = NULL; HStart2Hit* pHit = NULL; Bool_t foundTime = kFALSE; Int_t module = -1; Int_t strip = -1; for (Int_t entry = 0; entry < fCatCal->getEntries(); ++entry) { if (kTRUE == foundTime) { break; } if (NULL == (pCal = static_cast(fCatCal->getObject(entry)))) { Error("execute", "Pointer to HStart2Cal object == NULL, returning"); return -1; } // select start data (module == 0) if (0 != pCal->getModule()) { continue; } // check the 4 times and apply a time cut to remove BKG // in strip 7 at least the reference time after calibration // should be in the data for (Int_t i = 0; i < pCal->getMultiplicity() && i < pCal->getMaxMultiplicity(); ++i) { if (pCal->getTime(i + 1) > (fPar->getMeanTime(pCal->getModule(), pCal->getStrip()) - fPar->getWidth(pCal->getModule(), pCal->getStrip())) && pCal->getTime(i + 1) < (fPar->getMeanTime(pCal->getModule(), pCal->getStrip()) + fPar->getWidth(pCal->getModule(), pCal->getStrip()))) { foundTime = kTRUE; pCal->getAddress(module, strip); // write data to the ouput category pHit = static_cast(fCatHit->getSlot(loc)); if (NULL != pHit) { pHit = new(pHit) HStart2Hit; pHit->setAddress(module, strip); pHit->setTimeAndWidth(pCal->getTime(i + 1), pCal->getWidth(i + 1)); pHit->setFlag(kTRUE); pHit->setMultiplicity(pCal->getMultiplicity()); } else { Error("execute", "Can't get slot mod=%i, chan=%i", loc[0], loc[1]); return -1; } } } } // if no START time was found, now checks module 1 if (kFALSE == foundTime) { for (Int_t entry = 0; entry < fCatCal->getEntries(); ++entry) { if (kTRUE == foundTime) { break; } if (NULL == (pCal = static_cast(fCatCal->getObject(entry)))) { Error("execute", "Pointer to HStart2Cal object == NULL, returning"); return -1; } // select start data (module == 1) if (1 != pCal->getModule()) { continue; } // check the 4 times and apply a time cut to remove BKG // in strip 7 at least the reference time after calibration // should be in the data for (Int_t i = 0; i < pCal->getMultiplicity() && i < pCal->getMaxMultiplicity(); ++i) { if (pCal->getTime(i + 1) > (fPar->getMeanTime(pCal->getModule(), pCal->getStrip()) - fPar->getWidth(pCal->getModule(), pCal->getStrip())) && pCal->getTime(i + 1) < (fPar->getMeanTime(pCal->getModule(), pCal->getStrip()) + fPar->getWidth(pCal->getModule(), pCal->getStrip()))) { foundTime = kTRUE; pCal->getAddress(module, strip); // write data to the ouput category pHit = static_cast(fCatHit->getSlot(loc)); if (NULL != pHit) { pHit = new(pHit) HStart2Hit; pHit->setAddress(module, strip); pHit->setTimeAndWidth(pCal->getTime(i + 1), pCal->getWidth(i + 1)); pHit->setFlag(kTRUE); pHit->setMultiplicity(pCal->getMultiplicity()); } else { Error("execute", "Can't get slot mod=%i, chan=%i", loc[0], loc[1]); return -1; } } } } } if (kFALSE == foundTime && kTRUE == fSkipEvent) { return kSkipEvent; } return 0; }