/* * PndOnlineHitProducer.h * * Created on: Nov. 14, 2012 * Author: Sean Dobbs (s-dobbs@northwestern.edu) */ #include "PndOnlineHitProducer.h" #include "FairRootManager.h" #include void PndOnlineHitProducer::LoadStream(int detector_id, char *branch_name) { // debug info cout << "registering detector number " << detector_id << " with branch name " << branch_name << endl; input_branches.insert( pair< int, TString >(detector_id, TString(branch_name)) ); } // return all the hits between currtime -> currtime + delta_t // times in ns // always returns a new list, calling function should check to see if there is anything in it list *PndOnlineHitProducer::GetHits(int detector_id, double delta_t) { double event_time = GetCurrentTime(); cout << " in PndOnlineHitProducer::GetHits(): current time = " << event_time << " delta_t = " << delta_t << std::endl; list *hit_list = new list; // output store if(delta_t < 0) // the functor interface to the sorted hits only reads forward in time, going backwards makes no sense return hit_list; // loop over the branches associated with the detector pair< multimap< int, TString >::iterator, multimap< int, TString >::iterator > branches; branches = input_branches.equal_range( detector_id ); for (multimap::iterator it = branches.first; it != branches.second; ++it) { cout << "Reading in " << it->second.Data() << " with time = " << event_time + delta_t << endl; // read in new hits TClonesArray *new_hits = FairRootManager::Instance()->GetData(it->second.Data(), stop_time_functor, event_time + delta_t); for(int i=0; iGetEntriesFast(); ++i) { hit_list->push_back( (FairHit *)(new_hits->At(i)->Clone()) ); //FairHit *newhit = (FairHit*)(new_hits->At(i)); //cout << " hit timestamp = " << newhit->GetTimeStamp() << endl; } new_hits->Delete(); // need to clear the TClonesArray since it doesn't get automagically cleared. } //SetCurrentTime( event_time + delta_t ); //AdvanceCurrentTime(delta_t); return hit_list; } // public interface for setting a new starting time // we have to go through and mark as read hits before this time, due to the functor-based interface // there is no reversing time bool PndOnlineHitProducer::SetStartTime(double new_time) { if(new_time < current_time) return false; // throw away all the hits before our new time for (multimap::iterator it = input_branches.begin(); it != input_branches.end(); ++it) { // read in new hits TClonesArray *new_hits = FairRootManager::Instance()->GetData(it->second.Data(), stop_time_functor, new_time); // and get rid of them new_hits->Delete(); } // now we can set the time current_time = new_time; return true; }