#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; namespace RAT { Processor::Result NhitBurstCut::DSEvent(DS::Run&, DS::Entry& ds) { bool pass = true; // If any triggered event fails, they all fail for( size_t iEV = 0; iEV < ds.GetEVCount(); iEV++ ) if( Event(ds, ds.GetEV(iEV)) != OKTRUE ) pass = false; return pass ? OKTRUE : OKFALSE; } Processor::Result NhitBurstCut::Event(DS::Entry&, DS::EV& ev) { fPassFlag = true; if (foundCut && (BurstIdentifier(ev))) { fPassFlag = false; fBit = nhitBurstBit; UpdateMask(ev); } return fPassFlag ? OKFALSE : OKTRUE; } bool NhitBurstCut::BurstIdentifier(DS::EV& ev) { std::vector::iterator burstSearch; burstSearch = find (fNhitBurstReadout.begin(), fNhitBurstReadout.end(), ev.GetGTID()); if (burstSearch == fNhitBurstReadout.end()) return false; return true; } void NhitBurstCut::BeginOfRun(DS::Run& run) { //Read Retrigger Cut Bits from DataCleaningBits std::string cutName = "NhitBurstCut"; nhitBurstBit = DU::Utility::Get()->GetDataCleaningBits().GetBitIndex("tpburstcut"); bool foundDBTable = false; bool foundJSONFile = false; foundCut = false; try{ DBLinkPtr fData = DB::Get()->GetLink("LIVETIME_CUT","burstcut"); if (fData->GetI("cutapplied") == 1) { fFirstNhitBurstReadout = fData->GetIArray("firstburst"); fLastNhitBurstReadout = fData->GetIArray("lastburst"); fNhitBurstReadout = fData->GetIArray("burst"); foundCut = true; } else { std::string readDetail = "NhitBurstCut::BeginOfRun: No livetime is cut by " + cutName; detail << readDetail << endl; } foundDBTable = true; } catch(DBNotFoundError &e){ std::string readWarn = "NhitBurstCut::BeginOfRun: Could not find " + cutName + " info, Looking for .json file"; warn << readWarn << endl; } if (!foundDBTable) { std::ostringstream fname; fname << "livetimecut_" << cutName << "_" << run.GetRunID() << ".json"; try { std::vector contents = DBJsonLoader::parse(fname.str()); json::Value firstEventTemp = contents[0]->GetJSON("firstburst"); json::Value lastEventTemp = contents[0]->GetJSON("lastburst"); json::Value burstEventTemp = contents[0]->GetJSON("burst"); foundJSONFile = true; if ((int)firstEventTemp.getArraySize() != 0 ) { foundCut = true; for (int i=0; i<(int)burstEventTemp.getArraySize(); i++) { int gtid = burstEventTemp[i].cast(); fNhitBurstReadout.push_back(gtid); } for (int j = 0; j < (int)firstEventTemp.getArraySize(); j++) { int firstgtid = firstEventTemp[j].cast(); int lastgtid = lastEventTemp[j].cast(); fFirstNhitBurstReadout.push_back(firstgtid); fLastNhitBurstReadout.push_back(lastgtid); } } else { std::string readJSONDetail = "NhitBurstCut::BeginOfRun: No livetime is cut by " + cutName; detail << readJSONDetail << endl; } } catch(FileError &e){ std::string readJSONWarn = "NhitBurstCut::BeginOfRun: Could not find " + cutName + ".json file"; warn << readJSONWarn << endl; } } if ((!foundDBTable) && (!foundJSONFile)) { std::string readNoInfo = "NhitBurstCut::BeginOfRun: Could not find " + cutName + " info, " + cutName + " will not be applied.."; warn << readNoInfo << endl; } } } // namespace RAT