#include #include #include "ITrigger.hxx" ClassImp(COMET::ITrigger); ClassImp(COMET::IWritableTrigger); // ================================================================================================= COMET::ITrigger::ITrigger() : fTriggerId(-1), fTriggerTick(-1000000) { } // ================================================================================================= COMET::ITrigger::~ITrigger() { for(CombinedTriggers::iterator triggerIt = fCombinedTriggers.begin(); triggerIt != fCombinedTriggers.end(); triggerIt++){ delete const_cast(*triggerIt); } } // ================================================================================================= COMET::ITrigger::TriggerStatus COMET::ITrigger::GetTriggerStatus(const COMET::IChannelId& chanId) const { TriggerStatusMap::const_iterator it = fTriggerStatuses.find(chanId); // No found, hence kIgnored (Don't generate a key uselessly for saving the heap mamory) if(fTriggerStatuses.end() == it) return kIgnored; // Found, return the status return it->second; } // ================================================================================================= void COMET::ITrigger::ls(Option_t* opt) const { std::string option(opt); TROOT::IncreaseDirLevel(); TROOT::IndentLevel(); if(GetTriggerId() < 0){ std::cout << "Invalid trigger" << std::endl; } else{ std::cout << Form("Trigger ID: %4d", GetTriggerId()) << Form(" w/ independent %3d triggers", GetMultiplicity()) << Form(" at tick: %+6d, ", GetTriggerTick()) << Form(" from %3d channels, ", (Int_t)GetChannelIds().size()) << Form(" related to %4d digits.", (Int_t)(GetDigits().size())) << std::endl; if(option.find("trigger") != std::string::npos){ TROOT::IndentLevel(); for(DigitContainer::const_iterator it = GetDigits().begin(); it != GetDigits().end(); it++){ (*it)->ls(); } TROOT::DecreaseDirLevel(); } } TROOT::DecreaseDirLevel(); } // ================================================================================================= Int_t COMET::ITrigger::GetMultiplicity() const { if(fCombinedTriggers.size()) return (Int_t)fCombinedTriggers.size(); return 1; } // ================================================================================================= COMET::IWritableTrigger::IWritableTrigger() : COMET::ITrigger() { } // ================================================================================================= COMET::IWritableTrigger::IWritableTrigger(const Int_t triggerTick) : COMET::ITrigger() { fTriggerTick = triggerTick; } // ================================================================================================= COMET::IWritableTrigger::~IWritableTrigger() { } // ================================================================================================= void COMET::IWritableTrigger::AddChannelIds(const ChannelIdContainer& chanIds) { for(ChannelIdContainer::const_iterator chanIt = chanIds.begin(); chanIt != chanIds.end(); chanIt++) AddChannelId(*chanIt); } // ================================================================================================= void COMET::IWritableTrigger::AddTriggerStatuses(const TriggerStatusMap& triggerStatuses) { TriggerStatusMap::iterator foundIt; for(TriggerStatusMap::const_iterator statusIt = triggerStatuses.begin(); statusIt != triggerStatuses.end(); statusIt++){ foundIt = fTriggerStatuses.find(statusIt->first); // New status is added if(fTriggerStatuses.end() == foundIt) fTriggerStatuses[statusIt->first] = statusIt->second; // Already exists, then compare both. If different... else if (foundIt->second != statusIt->second ){ COMETNamedWarn("IIWritableTrigger", "AddTriggerStatuses(): Different status at the same IChannelId: " << statusIt->first.AsUInt() << ", used the lower level now."); foundIt->second = std::min(foundIt->second, statusIt->second); } } } // ================================================================================================= void COMET::IWritableTrigger::AddDigits(const DigitContainer& digits) { for(DigitContainer::const_iterator digitIt = digits.begin(); digitIt != digits.end(); digitIt++) AddDigit(*digitIt); } // ================================================================================================= void COMET::IWritableTrigger::AddUniqueDigit(const COMET::IDigit* digit) { if(not digit) return; DigitContainer::const_iterator location = std::find(fDigits.begin(), fDigits.end(), digit); if(location == fDigits.end()) fDigits.push_back(digit); } // ================================================================================================= void COMET::IWritableTrigger::AddUniqueDigits(const DigitContainer& digits) { for(DigitContainer::const_iterator digitIt = digits.begin(); digitIt != digits.end(); digitIt++) AddUniqueDigit(*digitIt); } // ================================================================================================= void COMET::IWritableTrigger::AddCombinedTriggers(const CombinedTriggers& triggers) { for(CombinedTriggers::const_iterator triggerIt = triggers.begin(); triggerIt != triggers.end(); triggerIt++) AddCombinedTrigger(*triggerIt); }