22 #include "FairRecoEventHeader.h" 
   24 #include "FairRootManager.h" 
   25 #include "FairRunAna.h" 
   26 #include "FairRuntimeDb.h" 
   28 #include "TClonesArray.h" 
   42 using std::setprecision;
 
   52   : FairEventBuilder(
"GEMEvTrack",
"PndTrack",
"GEM",kTRUE),
 
   67   : FairEventBuilder(
"GEMEvTrack",
"PndTrack",
"GEM",kTRUE),
 
   92     cout << endl << 
"======== PndGemEventBuilderOnTracks::FindEvents(Event = " << 
fTNofEvents << 
" ) ====================" << endl;
 
  103     cout << 
"There are " << 
fGemTracks->GetEntries() << 
" tracks." << endl;
 
  105   for ( Int_t itrack = 0 ; itrack < 
fGemTracks->GetEntries() ; itrack++ ) {
 
  109       cout << 
"    " << 
fTNofEvents << 
" . " << itrack << 
" @ " << tempTrack->GetTimeStamp() << 
"ns" << endl
 
  110            << 
"         trying to match to one of " << 
fRecoEvents.size() << 
" reco events" << endl;
 
  115     FillNewData(tempTrack,
 
  116                 tempTrack->GetTimeStamp(),
 
  117                 tempTrack->GetTimeStamp());
 
  127   std::vector<std::pair<double, FairRecoEventHeader*> > result;
 
  128   std::pair<double,FairRecoEventHeader*> singleResult;
 
  131     cout << 
"There are " << 
fRecoEvents.size() << 
" events." << endl;
 
  133   for ( Int_t irev = 0 ; irev < 
fRecoEvents.size() ; irev++ ) {
 
  134     FairRecoEventHeader recoEvent;
 
  136     recoEvent.SetIdentifier(GetIdentifier());
 
  137     SetMaxAllowedTime(recoEvent.GetEventTime());
 
  139     fEvent_map[recoEvent] = recoEvent.GetEventTime();
 
  141     singleResult.first  = recoEvent.GetEventTime();
 
  142     singleResult.second = (FairRecoEventHeader*)&fEvent_map.rbegin()->first;
 
  145       cout << 
"FOUND EVENT @ " << singleResult.first << endl;
 
  147     result.push_back(singleResult);
 
  159   cout << 
" print " << endl;
 
  160   cout << 
" fEventMap has " << 
fEvent_map.size() << 
" entries" << endl;
 
  161   std::map<FairRecoEventHeader,double>::iterator iter;
 
  163     cout << 
" // for time " << iter->second << 
" got " << iter->first.GetEventTime() << 
" at an address " << &iter->first << endl;
 
  165   cout << 
"-------" << endl;
 
  171   typedef std::multimap<double, std::pair<double, FairTimeStamp*> >::iterator startTimeMapIter;
 
  174     cout << 
"* " << 
fData_map.size() << 
" in fData_map "  
  175          << 
"* " << fStartTime_map.size() << 
" in fStartTime_map " 
  176          << 
" TO PUT IN EVENT AT " << recoEvent->GetEventTime() << endl;
 
  177     cout << 
"CHECK TRACKS WITH TimeStamps:" << endl;
 
  178     for (startTimeMapIter jter = fStartTime_map.begin() ; jter != fStartTime_map.end(); ++jter) {
 
  179       std::pair<double, FairTimeStamp*> datb = jter->second;
 
  180       cout << 
"@@@ " << datb.second->GetTimeStamp() << endl;
 
  184   startTimeMapIter iter = fStartTime_map.begin();
 
  185   while ( iter != fStartTime_map.end() ) {
 
  186     std::pair<double, FairTimeStamp*> data = iter->second;
 
  188       cout << 
" ---> check data at " << data.second->GetTimeStamp() 
 
  189            << 
" /// " << data.second->GetTimeStamp()-recoEvent->GetEventTime()-
fGemTrackDelay << endl;
 
  192       if ( 
fVerbose ) cout << 
"WILL ADD THIS ONE" << endl;
 
  193       FillDataToDeadTimeMap(data.second, data.first);
 
  195       startTimeMapIter save = iter;
 
  197       fStartTime_map.erase(iter);
 
  207   std::vector<std::pair<double, PndTrack*> > result;
 
  208   result.push_back(newData);
 
  214   FairRootManager* ioman = FairRootManager::Instance();
 
  215   TClonesArray* myArray = ioman->GetTClonesArray(fBranchName);
 
  216   if (
fVerbose > 1) std::cout << 
"Data Inserted: "  <<  *(
PndTrack*)(data) << std::endl;
 
  222   std::map<PndTrack, double>::iterator it;
 
  245   Double_t trackTime = tempTrack->GetTimeStamp();
 
  246   Int_t    recoEvent = -1;
 
  247   for ( Int_t irev = 0 ; irev < 
fRecoEvents.size() ; irev++ ) { 
 
  255       if ( 
fVerbose && recoEvent != -1 ) {
 
  256         cout << 
"track @ " << trackTime << 
" matches to two reco events: " << irev << 
" and " << recoEvent << endl;
 
  265   if ( recoEvent != -1 ) { 
 
  268     fRecoEvents[recoEvent].trackIndex.push_back(trackId);
 
  287   FairRunAna* 
run = FairRunAna::Instance();
 
  288   if ( ! run ) Fatal(
"SetParContainers", 
"No analysis run");
 
  290   FairRuntimeDb* db = run->GetRuntimeDb();
 
  291   if ( ! db ) Fatal(
"SetParContainers", 
"No runtime database");
 
  302   FairRootManager* ioman = FairRootManager::Instance();
 
  303   if ( ! ioman ) Fatal(
"Init", 
"No FairRootManager");
 
  305   fGemTracks = (TClonesArray*) ioman->GetObject(
"GEMTrack");
 
  336   cout << 
"-------------------- " << GetBuilderName() << 
" : Summary -----------------------" << endl;
 
  337   cout << 
" Events:        " << setw(10) << 
fTNofEvents     << endl;
 
  340   cout << 
" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . " << endl;
 
  341   cout << 
" >>> EB >>> all   time  = " << 
fExecTime << 
"s" << endl;
 
  342   cout << 
"---------------------------------------------------------------------" << endl; 
 
TClonesArray * fGemTracks
void FillDataMap(FairTimeStamp *data, double activeTime)
void EraseDataFromDataMap(FairTimeStamp *data)
std::vector< std::pair< double, FairRecoEventHeader * > > FindEvents()
std::map< FairRecoEventHeader, double > fEvent_map
std::vector< Int_t > trackIndex
std::vector< std::pair< double, PndTrack * > > Modify(std::pair< double, PndTrack * > oldData, std::pair< double, PndTrack * > newData)
double FindTimeForData(FairTimeStamp *data)
void AddNewDataToTClonesArray(FairTimeStamp *data)
std::vector< RecoEvent > fRecoEvents
bool CompareRecoEvents(RecoEvent ev1, RecoEvent ev2)
Int_t CompareTrackToPreviousEvents(Int_t trackId, PndTrack *tempTrack)
PndGemEventBuilderOnTracks()
virtual void StoreEventData(FairRecoEventHeader *recoEvent)
virtual ~PndGemEventBuilderOnTracks()
std::map< PndTrack, double > fData_map
virtual void SetParContainers()