///Less-then operator needed for STL containers ///@param [in] rhs : the ChannelConfiguration to compare ///@return true if the type, subtype, or location are less than those in rhs bool operator<(const ChanEvent &rhs) const { if(GetWalkCorrectedTime() == 0) return GetTime() < rhs.GetTime(); return GetWalkCorrectedTime() < rhs.GetWalkCorrectedTime(); }
bool ImplantSsdProcessor::Process(RawEvent &event) { using namespace dammIds::implantSsd; if (!EventProcessor::Process(event)) { EndProcess(); return false; } static bool firstTime = true; static LogicProcessor *logProc = NULL; static Correlator &corr = event.GetCorrelator(); static const DetectorSummary *tacSummary = event.GetSummary("generic:tac", true); static DetectorSummary *impSummary = event.GetSummary("ssd:sum", true); static const DetectorSummary *mcpSummary = event.GetSummary("logic:mcp", true); static const DetectorSummary *vetoSummary = event.GetSummary("ssd:veto", true); static const DetectorSummary *boxSummary = event.GetSummary("ssd:box", true); DetectorDriver* driver = DetectorDriver::get(); if (impSummary->GetMult() == 0) { EndProcess(); return false; } if (firstTime) { vector<EventProcessor *> vecProc = driver->GetProcessors("logic"); for (vector< EventProcessor * >::iterator it = vecProc.begin(); it != vecProc.end(); it++) { if ( (*it)->GetName() == "triggerlogic" || (*it)->GetName() == "logic" ) { logProc = reinterpret_cast < LogicProcessor * >(*it); cout << "Implant SSD processor grabbed logic processor" << endl; } } firstTime=false; } EventInfo info; ChanEvent *ch = impSummary->GetMaxEvent(true); info.hasVeto = ( vetoSummary && vetoSummary->GetMult() > 0 ); int location = ch->GetChanID().GetLocation(); if (ch->IsSaturated()) { info.energy = 16000; // arbitrary large number } else { info.energy = ch->GetCalEnergy(); } if (ch->GetTrace().HasValue("position")) { info.position = ch->GetTrace().GetValue("position"); } // else it defaults to nan info.time = ch->GetTime(); info.beamOn = true; // recect noise events if (info.energy < 10 || ch->GetTrace().HasValue("badqdc")) { EndProcess(); return true; } if (logProc) { info.clockCount = logProc->StartCount(2); if (logProc->LogicStatus(3) || logProc->LogicStatus(4) || logProc->LogicStatus(5)) { info.beamOn = true; info.offTime = 0; } else { info.beamOn = false; if (!logProc->LogicStatus(3)) info.offTime = logProc->TimeOff(3, info.time); else if (!logProc->LogicStatus(4)) info.offTime = logProc->TimeOff(4, info.time) + 300e-6; else if (!logProc->LogicStatus(5)) info.offTime = logProc->TimeOff(5, info.time) + 600e-6; } for (int i=0; i < dammIds::logic::MAX_LOGIC; i++) { info.logicBits[i] = (logProc->LogicStatus(i) ? '1' : '0'); } } double digitalTof = NAN; if (mcpSummary) { info.mcpMult = mcpSummary->GetMult(); vector<ChanEvent*> mcpEvents = mcpSummary->GetList(); double dtMin = DBL_MAX; for (vector<ChanEvent*>::iterator it = mcpEvents.begin(); it != mcpEvents.end(); it++) { double dt = info.time - (*it)->GetTime(); plot(D_TDIFF_FOIL_IMPLANT, 500 + dt); if (mcpEvents.size() == 1) { digitalTof = -10.*dt; plot(D_TDIFF_FOIL_IMPLANT_MULT1, 500 + dt); } dtMin = min(dtMin, dt); } if (dtMin != DBL_MAX) info.foilTime= dtMin; } else { info.mcpMult = 0; info.foilTime = NAN; } if (impSummary) { info.impMult = impSummary->GetMult(); } else { info.impMult = 0; } if (boxSummary) { info.boxMult = boxSummary->GetMult(); if (info.boxMult > 0) { const ChanEvent *boxCh = boxSummary->GetMaxEvent(); info.energyBox = boxCh->GetCalEnergy(); //raw? info.boxMax = boxCh->GetChanID().GetLocation(); } else { info.energyBox = 0; info.boxMax = -1; } } else { info.boxMult = 0; } info.tof = NAN; if (tacSummary) { const vector<ChanEvent*> events = tacSummary->GetList(); for (vector<ChanEvent*>::const_iterator it = events.begin(); it != events.end(); it++) { int loc = (*it)->GetChanID().GetLocation(); if (loc == 2) { info.tof = (*it)->GetCalEnergy(); info.hasTof = true; break; } } } else { info.hasTof = true; } Trace &trace = ch->GetTrace(); if (trace.HasValue("filterEnergy2")) { info.pileUp = true; } SetType(info); Correlate(corr, info, location); // TOF spectra update if (tacSummary) { const vector<ChanEvent*> events = tacSummary->GetList(); for (vector<ChanEvent*>::const_iterator it = events.begin(); it != events.end(); it++) { double tof = (*it)->GetCalEnergy(); int ntof = (*it)->GetChanID().GetLocation(); plot(DD_ALL_ENERGY__TOFX + ntof - 1, info.energy, tof); if (!isnan(digitalTof) && digitalTof > 1500. && digitalTof < 2000) plot(DD_ALL_ENERGY__TOFX_GATED + ntof - 1, info.energy, tof); if (info.type == EventInfo::IMPLANT_EVENT) { plot(DD_IMPLANT_ENERGY__TOFX + ntof - 1, info.energy, tof); } else if (info.type == EventInfo::PROTON_EVENT) { plot(DD_VETO_ENERGY__TOFX + ntof - 1, info.energy, tof); } } // TAC channel 0 is missing, so use it for the digital tof if (!isnan(digitalTof)) { plot(DD_ALL_ENERGY__TOFX, info.energy, digitalTof); if (info.type == EventInfo::IMPLANT_EVENT) { plot(DD_IMPLANT_ENERGY__TOFX, info.energy, digitalTof); } else if (info.type == EventInfo::PROTON_EVENT) { plot(DD_VETO_ENERGY__TOFX, info.energy, digitalTof); } } } if (info.type == EventInfo::PROTON_EVENT) { const ChanEvent *chVeto = vetoSummary->GetMaxEvent(); unsigned int posVeto = chVeto->GetChanID().GetLocation(); double vetoEnergy = chVeto->GetCalEnergy(); plot(DD_LOC_VETO__LOC_SSD, posVeto, location); plot(DD_TOTENERGY__ENERGY, vetoEnergy + info.energy, info.energy); } if (info.pileUp) { double trigTime = info.time; info.energy = driver->cali.GetCalEnergy(ch->GetChanID(), trace.GetValue("filterEnergy2")); info.time = trigTime + trace.GetValue("filterTime2") - trace.GetValue("filterTime"); SetType(info); Correlate(corr, info, location); int numPulses = trace.GetValue("numPulses"); if ( numPulses > 2 ) { corr.Flag(location, 1); cout << "Flagging triple event" << endl; for (int i=3; i <= numPulses; i++) { stringstream str; str << "filterEnergy" << i; info.energy = driver->cali.GetCalEnergy(ch->GetChanID(), trace.GetValue(str.str())); str.str(""); // clear it str << "filterTime" << i; info.time = trigTime + trace.GetValue(str.str()) - trace.GetValue("filterTime"); SetType(info); Correlate(corr, info, location); } } // corr.Flag(location, 1); #ifdef VERBOSE cout << "Flagging for pileup" << endl; cout << "fast trace " << fastTracesWritten << " in strip " << location << " : " << trace.GetValue("filterEnergy") << " " << trace.GetValue("filterTime") << " , " << trace.GetValue("filterEnergy2") << " " << trace.GetValue("filterTime2") << endl; cout << " mcp mult " << info.mcpMult << endl; #endif // VERBOSE if (fastTracesWritten < numTraces) { trace.Plot(D_FAST_DECAY_TRACE + fastTracesWritten); fastTracesWritten++; } } if (info.energy > 10000 && !ch->IsSaturated() && !isnan(info.position) ) { corr.Flag(location, info.position); } if (info.energy > 8000 && !trace.empty()) { #ifdef VERBOSE cout << "high energy decay of " << info.energy << "(raw energy " << ch->GetEnergy() << ") with beam " << (info.beamOn ? "present" : "absent") << endl; cout << "Flagging for high energy " << info.energy << " with trace" << endl; #endif //VERBOSE // corr.Flag(location, 1); if (highTracesWritten < numTraces) { trace.Plot(D_HIGH_ENERGY_TRACE + highTracesWritten); highTracesWritten++; } } EndProcess(); // update the processing time return true; }
///Equality operator, we only check to see if the module number, channel number, and times are equal. ///@param [in] rhs : the configuration to compare to ///@return true if the module number, channel number, and time are identical bool operator==(const ChanEvent &rhs) const { return GetModuleNumber() == rhs.GetModuleNumber() && GetChannelNumber() == rhs.GetChannelNumber() && GetTime() == rhs.GetTime(); }