#include #include using namespace RAT; IsCalibrationSource::IsCalibrationSource() : Processor("IsCalibrationSource"){} void IsCalibrationSource::BeginOfRun(DS::Run&){ DBLinkPtr fFECD = DB::Get()->GetLink("FECDTAG"); fLCN = fFECD->GetI("lcn"); checkLCN = true; wrongLCN = false; DBLinkPtr fRun = DB::Get()->GetLink("RUN"); fRunType = fRun->GetI("runtype"); } Processor::Result IsCalibrationSource::DSEvent(DS::Run&, DS::Entry& ds){ // Identified that the user might have the wrong lcn for the FECD tag, // so don't run the tagged source processor if(wrongLCN){ return Processor::OKFALSE; } bool iscal = false; for(size_t iEV = 0; iEV < ds.GetEVCount(); iEV++){ DS::EV& ev = ds.GetEV(iEV); DS::UncalPMTs& uncalPMTs = ev.GetUncalPMTs(); for(size_t iPMT = 0; iPMT < uncalPMTs.GetFECDCount(); iPMT++){ DS::PMTUncal& pmt = uncalPMTs.GetFECDPMT(iPMT); int id = pmt.GetID(); // Check we have the correct LCN for the FECD tag between 17/15/0 - 17/15/15 // with the latch board this is tricky, since the output of that board can be // plugged into any FECD channel. Currently we only use the top two DBs on the // FECD for the latch board, and we typically use channel 4 for the FECD tag. // Note that this would also break if the FECD has a bunch of noisy channels, // which should not occur given that we keep the thresholds at 255. // If the wrong channel was hit, we assume we've got the wrong LCN and // we set wrongLCN true which will stop this processor from running and // filling the DS with incorrect information if(checkLCN && id != fLCN && id < 9200 && id >= 9184){ warn << "IsCalibrationSource: Wrong LCN for calibration source! \n" << endl; wrongLCN = true; checkLCN = false; return Processor::OKFALSE; } // Tagged by the FECD, this was a tagged calibration source event if(id == fLCN){ iscal = true; checkLCN = false; } } // Only need to check our tag is correct once ev.SetCalibrationEvent(iscal); } if(iscal) return Processor::OKTRUE; else return Processor::OKFALSE; }