Skip to content

Commit

Permalink
Shorter names i memory map manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielWielanek committed Dec 16, 2024
1 parent b6a3642 commit 4a41530
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 85 deletions.
93 changes: 44 additions & 49 deletions analysis/base/MemoryMapManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace Hal {
* this stuff is needed to check if all track collections belong to given
* event collections have some particles to avoid e.g. mixing empty kaon
* events with full pion events in non-id femto this checking is provide if
* call update counters (event_collection, kTRUE)
* call update counters (eventCol, kTRUE)
*/
for (int i = 0; i < fEventCollectionsNo; i++) {
fEventToTrackNo[i] = cont->GetEventCollection(i)->GetNextNo();
Expand Down Expand Up @@ -177,13 +177,13 @@ namespace Hal {
}
}

Int_t MemoryMapManager::GetTracksNo(Int_t event_collection, Int_t track_collection) const {
return fTrackCounter->Get(event_collection, track_collection, fCounter[event_collection]);
// return fTrackCounter[event_collection][track_collection][
// fCounter[event_collection] ];
Int_t MemoryMapManager::GetTracksNo(Int_t eventCol, Int_t trackCol) const {
return fTrackCounter->Get(eventCol, trackCol, fCounter[eventCol]);
// return fTrackCounter[eventCol][trackCol][
// fCounter[eventCol] ];
}

Int_t MemoryMapManager::GetRawTracksNo(Int_t event_collection) const { return fTotalTracks[event_collection]; }
Int_t MemoryMapManager::GetRawTracksNo(Int_t eventCol) const { return fTotalTracks[eventCol]; }

Bool_t MemoryMapManager::IsReadyToMixing(Int_t collection) const { return fReadyToMix[collection]; }

Expand All @@ -199,56 +199,51 @@ namespace Hal {
fReadyToMix[collection] = kFALSE;
}

void MemoryMapManager::AddTrackToMapTrack(Int_t event_collection, Int_t track_collection, Int_t index) {
Int_t counter = fCounter[event_collection];
fTrackMap->Set(event_collection,
track_collection,
counter,
fTrackCounter->IncrementAfter(event_collection, track_collection, counter),
index);
void MemoryMapManager::AddTrackToMapTrack(Int_t eventCol, Int_t trackCol, Int_t index) {
Int_t counter = fCounter[eventCol];
fTrackMap->Set(eventCol, trackCol, counter, fTrackCounter->IncrementAfter(eventCol, trackCol, counter), index);
}

void MemoryMapManager::ResetTrackMaps(Int_t event_collection, Int_t counter) {
void MemoryMapManager::ResetTrackMaps(Int_t eventCol, Int_t counter) {
for (int i = 0; i < fTrackCollectionsNo; i++)
fTrackCounter->Set(event_collection, i, counter, 0);
fTrackCounter->Set(eventCol, i, counter, 0);
}

void MemoryMapManager::ResetTrackMaps(Int_t event_collection, Int_t track_collection, Int_t counter) {
// fTrackCounter[event_collection][track_collection][counter]=0;
fTrackCounter->Set(event_collection, track_collection, counter, 0);
void MemoryMapManager::ResetTrackMaps(Int_t eventCol, Int_t trackCol, Int_t counter) {
// fTrackCounter[eventCol][trackCol][counter]=0;
fTrackCounter->Set(eventCol, trackCol, counter, 0);
}

Int_t MemoryMapManager::GetTracksNo(Int_t event_collection, Int_t track_collection, Int_t counter) const {
// return fTrackCounter[event_collection][track_collection][counter];
return fTrackCounter->Get(event_collection, track_collection, counter);
Int_t MemoryMapManager::GetTracksNo(Int_t eventCol, Int_t trackCol, Int_t counter) const {
// return fTrackCounter[eventCol][trackCol][counter];
return fTrackCounter->Get(eventCol, trackCol, counter);
}

Int_t MemoryMapManager::GetTrackCollectionsNo(Int_t event_collection) const { return fEventToTrackNo[event_collection]; }
Int_t MemoryMapManager::GetTrackCollectionsNo(Int_t eventCol) const { return fEventToTrackNo[eventCol]; }

Int_t MemoryMapManager::GetTemporaryTotalTracksNo() const { return fCurrentEvent->GetTotalTrackNo(); }

Event* MemoryMapManager::GetEvent(Int_t collection) const { return (Event*) (fEvents[collection]->At(fCounter[collection])); }

Track* MemoryMapManager::GetTrack(Int_t event_collection, Int_t track_collection, Int_t index) const {
//(fEvents[event_collection]->At(fCounter[event_collection])
//)->GetTrack(track,fTrackMap[event_collection][track_collection][fCounter[event_collection]][index]
Track* MemoryMapManager::GetTrack(Int_t eventCol, Int_t trackCol, Int_t index) const {
//(fEvents[eventCol]->At(fCounter[eventCol])
//)->GetTrack(track,fTrackMap[eventCol][trackCol][fCounter[eventCol]][index]
//);
return (fEvents[event_collection]->At(fCounter[event_collection]))
->GetTrack(fTrackMap->Get(event_collection, track_collection, fCounter[event_collection], index));
return (fEvents[eventCol]->At(fCounter[eventCol]))->GetTrack(fTrackMap->Get(eventCol, trackCol, fCounter[eventCol], index));
}

Track* MemoryMapManager::GetRawTrack(Int_t event_collection, Int_t index) const {
return (fEvents[event_collection]->At(fCounter[event_collection]))->GetTrack(index);
Track* MemoryMapManager::GetRawTrack(Int_t eventCol, Int_t index) const {
return (fEvents[eventCol]->At(fCounter[eventCol]))->GetTrack(index);
}

Event* MemoryMapManager::GetEvent(Int_t collection, Int_t counter) const { return (Event*) (fEvents[collection]->At(counter)); }

Track* MemoryMapManager::GetTrack(Int_t event_collection, Int_t track_collection, Int_t counter, Int_t index) const {
return (fEvents[event_collection]->At(counter))->GetTrack(fTrackMap->Get(event_collection, track_collection, counter, index));
Track* MemoryMapManager::GetTrack(Int_t eventCol, Int_t trackCol, Int_t counter, Int_t index) const {
return (fEvents[eventCol]->At(counter))->GetTrack(fTrackMap->Get(eventCol, trackCol, counter, index));
}

Track* MemoryMapManager::GetRawTrack(Int_t event_collection, Int_t counter, Int_t index) const {
return (fEvents[event_collection]->At(counter))->GetTrack(index);
Track* MemoryMapManager::GetRawTrack(Int_t eventCol, Int_t counter, Int_t index) const {
return (fEvents[eventCol]->At(counter))->GetTrack(index);
}

void MemoryMapManager::PrintMap() const {
Expand Down Expand Up @@ -279,32 +274,32 @@ namespace Hal {
}
}

void MemoryMapManager::RejectLastEvent(Int_t event_collection) {
void MemoryMapManager::RejectLastEvent(Int_t eventCol) {
for (int i = 0; i < fTrackCollectionsNo; i++)
fTrackCounter->Set(event_collection, i, fCounter[event_collection], 0);
--fCounter[event_collection];
fTrackCounter->Set(eventCol, i, fCounter[eventCol], 0);
--fCounter[eventCol];
}

Int_t MemoryMapManager::GetCounter(Int_t event_collection) const { return fCounter[event_collection]; }
Int_t MemoryMapManager::GetCounter(Int_t eventCol) const { return fCounter[eventCol]; }

void MemoryMapManager::ClearEvent() {
// need to be called before next Exec() or lead to memory leak
fCurrentEvent->Clear();
}

void MemoryMapManager::CalculateCompressedMap(Int_t event_collection) {
void MemoryMapManager::CalculateCompressedMap(Int_t eventCol) {
int total_tracks = fCurrentEvent->GetTotalTrackNo();
int collections = fEventToTrackNo[event_collection];
int collections = fEventToTrackNo[eventCol];

Int_t counter = fCounter[event_collection];
Int_t counter = fCounter[eventCol];
fCompression.Reset(total_tracks);

std::vector<int> links;
links.resize(fCurrentEvent->GetMaxExpectedLinks());
// index global map - if fIndexMap[i=>0 need to store particle
for (int iTrackCollection = 0; iTrackCollection < collections; iTrackCollection++) {
for (int j = 0; j < GetTracksNo(event_collection, iTrackCollection); j++) {
Int_t index = fTrackMap->Get(event_collection, iTrackCollection, counter, j);
for (int j = 0; j < GetTracksNo(eventCol, iTrackCollection); j++) {
Int_t index = fTrackMap->Get(eventCol, iTrackCollection, counter, j);
Track* track = fCurrentEvent->GetTrack(index);
Int_t size = track->GetLinksFast(links, kTRUE);
for (int iLink = 0; iLink < size; iLink++) {
Expand All @@ -314,8 +309,8 @@ namespace Hal {
}
fCompression.Recalculate();
for (int iTrackCollection = 0; iTrackCollection < collections; iTrackCollection++) {
auto submap = fTrackMap->At(event_collection)->At(iTrackCollection)->At(counter);
for (int iTrack = 0; iTrack < GetTracksNo(event_collection, iTrackCollection); iTrack++) {
auto submap = fTrackMap->At(eventCol)->At(iTrackCollection)->At(counter);
for (int iTrack = 0; iTrack < GetTracksNo(eventCol, iTrackCollection); iTrack++) {
Int_t old_index = submap->Get(iTrack);
submap->Set(iTrack, fCompression.GetNewIndex(old_index));
}
Expand All @@ -325,8 +320,8 @@ namespace Hal {
std::cout << " collections at" << counter << std::endl;
for (int i = 0; i < collections; i++) {
std::cout << "Collection " << i << " end = " << End[i] << std::endl;
for (int j = 0; j < fTrackCounter->Get(event_collection, i, counter); j++) {
std::cout << Form(" %4d", fTrackMap->Get(event_collection, i, counter, j));
for (int j = 0; j < fTrackCounter->Get(eventCol, i, counter); j++) {
std::cout << Form(" %4d", fTrackMap->Get(eventCol, i, counter, j));
}
std::cout << std::endl;
}
Expand All @@ -336,7 +331,7 @@ namespace Hal {
#ifdef MAPMANAGER_DEBUG
std::cout << "SUMM" << std::endl;
for (int i = 0; i < fSumMapSize; i++) {
// std::cout<<Form(" %4d",fTrackMap->Get(event_collection,0,counter,i));
// std::cout<<Form(" %4d",fTrackMap->Get(eventCol,0,counter,i));
}
std::cout << std::endl;
for (int i = 0; i < fSumMapSize; i++) {
Expand Down Expand Up @@ -380,7 +375,7 @@ namespace Hal {
}
}

Track* MemoryMapManager::GetTemporaryTrack(Int_t event_collection, Int_t track_collection, Int_t index) const {
return fCurrentEvent->GetTrack(fTrackMap->Get(event_collection, track_collection, fCounter[event_collection], index));
Track* MemoryMapManager::GetTemporaryTrack(Int_t eventCol, Int_t trackCol, Int_t index) const {
return fCurrentEvent->GetTrack(fTrackMap->Get(eventCol, trackCol, fCounter[eventCol], index));
}
} // namespace Hal
72 changes: 36 additions & 36 deletions analysis/base/MemoryMapManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,22 @@ namespace Hal {
Array_4<Int_t>* fTrackMap;
Array_3<Int_t>* fTrackCounter;
void ReloadMap(Int_t size);
void CalculateCompressedMap(Int_t event_collection);
Int_t GetTrackCollectionsNo(Int_t event_collection) const;
Int_t GetCounter(Int_t event_collection, Int_t track_collection) const;
void CalculateCompressedMap(Int_t eventCol);
Int_t GetTrackCollectionsNo(Int_t eventCol) const;
Int_t GetCounter(Int_t eventCol, Int_t trackCol) const;
/**
* reset track maps for all track collections for given event
* @param event_collection event collection
* @param eventCol event collection
* @param counter position of event in buffer
*/
void ResetTrackMaps(Int_t event_collection, Int_t counter);
void ResetTrackMaps(Int_t eventCol, Int_t counter);
/**
* reset track maps
* @param event_collection event collection
* @param track_collection track collection
* @param eventCol event collection
* @param trackCol track collection
* @param counter event position in buffer
*/
void ResetTrackMaps(Int_t event_collection, Int_t track_collection, Int_t counter);
void ResetTrackMaps(Int_t eventCol, Int_t trackCol, Int_t counter);

public:
/**
Expand Down Expand Up @@ -134,11 +134,11 @@ namespace Hal {
void Init(Int_t event_factor, Int_t task_id, Bool_t compress, std::vector<TString> direct);
/**
* add track to map
* @param event_collection even collection number
* @param track_collection track collection number
* @param eventCol even collection number
* @param trackCol track collection number
* @param index position of added track in track array
*/
void AddTrackToMapTrack(Int_t event_collection, Int_t track_collection, Int_t index);
void AddTrackToMapTrack(Int_t eventCol, Int_t trackCol, Int_t index);
/**
* buffer event with memory
* @param collection collection number of event
Expand All @@ -152,26 +152,26 @@ namespace Hal {
Event* GetEvent(Int_t collection) const;
/**
* fill track from buffered event (last buffered)
* @param event_collection event collection number
* @param track_collection track collection number
* @param eventCol event collection number
* @param trackCol track collection number
* @param index position in map
* @return track
*/
Track* GetTrack(Int_t event_collection, Int_t track_collection, Int_t index) const;
Track* GetTrack(Int_t eventCol, Int_t trackCol, Int_t index) const;
/**
*
* @param track_collection track collection
* @param trackCol track collection
* @param index number
* @return track from temporary event via map
*/
Track* GetTemporaryTrack(Int_t event_collection, Int_t track_collection, Int_t index) const;
Track* GetTemporaryTrack(Int_t eventCol, Int_t trackCol, Int_t index) const;
/**
* get track from buffered event (last buffered)
* @param event_collection event collection no
* @param eventCol event collection no
* @param index position in track array
* @return track
*/
Track* GetRawTrack(Int_t event_collection, Int_t index) const;
Track* GetRawTrack(Int_t eventCol, Int_t index) const;
/**
* @param collection event collection number
* @param counter position in event buffer
Expand All @@ -180,26 +180,26 @@ namespace Hal {
Event* GetEvent(Int_t collection, Int_t counter) const;
/**
* return track from event
* @param event_collection event collection number
* @param track_collection track collection number
* @param eventCol event collection number
* @param trackCol track collection number
* @param counter position of event in buffer
* @param index position of particle in map
* @return track from event
*/
Track* GetTrack(Int_t event_collection, Int_t track_collection, Int_t counter, Int_t index) const;
Track* GetTrack(Int_t eventCol, Int_t trackCol, Int_t counter, Int_t index) const;
/**
* return raw track from event
* @param event_collection event collection number
* @param eventCol event collection number
* @param counter position of event in buffer
* @param index position of particle in track array
* @return raw track (without using maps)
*/
Track* GetRawTrack(Int_t event_collection, Int_t counter, Int_t index) const;
Track* GetRawTrack(Int_t eventCol, Int_t counter, Int_t index) const;
/**
* reject last event from buffer
* @param event_collection event collection of rejected event
* @param eventCol event collection of rejected event
*/
void RejectLastEvent(Int_t event_collection);
void RejectLastEvent(Int_t eventCol);
/**
* reset buffer, track maps and event buffer become empty
* @param collection event collection number
Expand All @@ -210,7 +210,7 @@ namespace Hal {
*/
void ClearEvent();
/**
* preapre maps of tracks for event that potentialy will be buffered
* Prepare maps of tracks for event that potentially will be buffered
* @param collection
*/
void PrepareMaps(Int_t collection);
Expand All @@ -220,31 +220,31 @@ namespace Hal {
void PrintMap() const;
/**
*
* @param event_collection event collection number
* @param eventCol event collection number
* @return position of currently processed (or last buffered) event in array
*/
Int_t GetCounter(Int_t event_collection) const;
Int_t GetCounter(Int_t eventCol) const;
/**
* return number of track in latest buffered event (or current)
* @param event_collection event collection no
* @param track_collection track collection no
* @param eventCol event collection no
* @param trackCol track collection no
* @return number of tracks in map
*/
Int_t GetTracksNo(Int_t event_collection, Int_t track_collection) const;
Int_t GetTracksNo(Int_t eventCol, Int_t trackCol) const;
/**
*
* @param event_collection event collection no
* @param track_collection track collection no
* @param eventCol event collection no
* @param trackCol track collection no
* @param counter event position
* @return number of tracks
*/
Int_t GetTracksNo(Int_t event_collection, Int_t track_collection, Int_t counter) const;
Int_t GetTracksNo(Int_t eventCol, Int_t trackCol, Int_t counter) const;
/**
*
* @param event_collection event collection number
* @param eventCol event collection number
* @return number of tracks in current (or latest buffered) event
*/
Int_t GetRawTracksNo(Int_t event_collection) const;
Int_t GetRawTracksNo(Int_t eventCol) const;
/**
* check if can mix events
* @param collection event collection no
Expand Down

0 comments on commit 4a41530

Please sign in to comment.