//-----------------------------------------------------------------------------
#include "AliMpMotifMap.h"
+
+#include "AliCodeTimer.h"
+#include "AliMpExMapIterator.h"
#include "AliMpVMotif.h"
#include "AliMpMotif.h"
#include "AliMpMotifSpecial.h"
#include "AliMpMotifType.h"
#include "AliMpMotifPosition.h"
+#include "AliMpEncodePair.h"
#include "AliLog.h"
/// \endcond
//_____________________________________________________________________________
-AliMpMotifMap::AliMpMotifMap(Bool_t /*standardConstructor*/)
- : TObject()
-#ifdef WITH_ROOT
- ,fMotifs(true),
- fMotifTypes(true),
- fMotifPositions(true),
- fMotifPositions2(true)
-#endif
+AliMpMotifMap::AliMpMotifMap()
+ : TObject(),
+ fMotifs(),
+ fMotifTypes(),
+ fMotifPositions(),
+ fMotifPositions2()
{
/// Standard constructor
- //fMotifPositions2.SetOwner(false);
+ fMotifPositions2.SetOwner(false);
}
//_____________________________________________________________________________
-AliMpMotifMap::AliMpMotifMap()
+AliMpMotifMap::AliMpMotifMap(TRootIOCtor* ioCtor)
: TObject(),
- fMotifs(),
- fMotifTypes(),
- fMotifPositions(),
- fMotifPositions2()
+ fMotifs(ioCtor),
+ fMotifTypes(ioCtor),
+ fMotifPositions(ioCtor),
+ fMotifPositions2(ioCtor)
{
-/// Default constructor
+/// Root IO constructor
+
+ fMotifPositions2.SetOwner(false);
}
//_____________________________________________________________________________
/// Destructor
// Delete all registered motifs, motif types, motif positions
-
-#ifdef WITH_STL
- for (MotifMapIterator im=fMotifs.begin(); im != fMotifs.end(); im++) {
- delete im->second;
- }
-
- for (MotifTypeMapIterator it=fMotifTypes.begin();
- it != fMotifTypes.end(); it++) {
- delete it->second;
- }
-
- for (MotifPositionMapIterator ip=fMotifPositions.begin();
- ip != fMotifPositions.end(); ip++) {
- delete ip->second;
- }
-#endif
}
//
{
/// Print the motif position.
- cout << setw(3) << motifPosition->GetLowIndicesLimit().GetFirst() << " "
- << setw(3) << motifPosition->GetLowIndicesLimit().GetSecond() << " "
- << setw(3) << motifPosition->GetHighIndicesLimit().GetFirst() << " "
- << setw(3) << motifPosition->GetHighIndicesLimit().GetSecond() << " "
+ cout << setw(3) << motifPosition->GetLowLimitIx() << " "
+ << setw(3) << motifPosition->GetLowLimitIy() << " "
+ << setw(3) << motifPosition->GetHighLimitIx() << " "
+ << setw(3) << motifPosition->GetHighLimitIy() << " "
<< motifPosition->GetID() << " ";
}
/// Print all the motifs and their motif types
/// for all motifs in the motifs map.
-#ifdef WITH_STL
- if (fMotifs.size()) {
- cout << "Dump of Motif Map - " << fMotifs.size() << " entries:" << endl;
- Int_t counter = 0;
- for (MotifMapIterator i=fMotifs.begin(); i != fMotifs.end(); i++) {
- const TString& id = (*i).first;
- cout << "Map element "
- << setw(3) << counter++ << " "
- << id.Data() << " " ;
- PrintMotif((*i).second);
- cout << endl;
- }
- cout << endl;
- }
-#endif
-
-#ifdef WITH_ROOT
if (fMotifs.GetSize()) {
cout << "Dump of Motif Map - " << fMotifs.GetSize() << " entries:" << endl;
Int_t counter = 0;
- TExMapIter i = fMotifs.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- TString id = fMotifs.AliMpExMap::GetString(key);
- AliMpVMotif* motif = (AliMpVMotif*)value;
+ AliMpExMapIterator* it = fMotifs.CreateIterator();
+ Int_t key;
+ AliMpVMotif* motif;
+
+ while ( ( motif = static_cast<AliMpVMotif*>(it->Next(key)) ) )
+ {
+ TString id = fMotifs.AliMpExMap::GetString(key);
cout << "Map element "
<< setw(3) << counter++ << " "
<< id.Data() << " " ;
cout << endl;
}
cout << endl;
+ delete it;
}
-#endif
}
//_____________________________________________________________________________
/// Print all the the motifs types and their motif dimensions
/// for all motif types in the motif types map.
-#ifdef WITH_STL
- if (fMotifTypes.size()) {
- cout << "Dump of Motif Type Map - " << fMotifTypes.size() << " entries:" << endl;
- Int_t counter = 0;
- for (MotifTypeMapIterator i=fMotifTypes.begin(); i != fMotifTypes.end(); i++) {
- const TString& id = (*i).first;
- cout << "Map element "
- << setw(3) << counter++ << " "
- << id.Data() << " ";
- PrintMotifType((*i).second);
- cout << endl;
- }
- cout << endl;
- }
-#endif
-
-#ifdef WITH_ROOT
if (fMotifTypes.GetSize()) {
cout << "Dump of Motif Type Map - " << fMotifTypes.GetSize() << " entries:" << endl;
- Int_t counter = 0;
- TExMapIter i = fMotifTypes.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
+ Int_t counter = 0;
+ AliMpExMapIterator* it = fMotifTypes.CreateIterator();
+ Int_t key;
+ AliMpMotifType* motifType;
+
+ while ( ( motifType = static_cast<AliMpMotifType*>(it->Next(key)) ) )
+ {
TString id = AliMpExMap::GetString(key);
- AliMpMotifType* motifType = (AliMpMotifType*)value;
cout << "Map element "
<< setw(3) << counter++ << " "
<< id.Data() << " " ;
cout << endl;
}
cout << endl;
+ delete it;
}
-#endif
}
//_____________________________________________________________________________
/// Fill the given array with all motif positions IDs (electronic card numbers)
/// defined in the map
-#ifdef WITH_STL
- ecn.Set(fMotifPositions.size());
- Int_t i(0);
- MotifPositionMapIterator it;
- for (it=fMotifPositions.begin(); it != fMotifPositions.end(); it++) {
- AliMpMotifPosition* motifPosition = (*it).second;
- ecn[i++] = motifPosition->GetID();
- }
-#endif
-
-#ifdef WITH_ROOT
ecn.Set(fMotifPositions.GetSize());
- TExMapIter it = fMotifPositions.GetIterator();
- Long_t key, value;
+ TIter next(fMotifPositions.CreateIterator());
+ AliMpMotifPosition* motifPosition;
Int_t i(0);
-
- while ( it.Next(key, value) )
+ while ( ( motifPosition = static_cast<AliMpMotifPosition*>(next()) ) )
{
- AliMpMotifPosition* motifPosition = reinterpret_cast<AliMpMotifPosition*>(value);
ecn[i] = motifPosition->GetID();
++i;
}
-
-#endif
}
//_____________________________________________________________________________
{
/// Return the number of all motif positions IDs (electronic card numbers)
-#ifdef WITH_STL
- return fMotifPositions.size();
-#endif
-
-#ifdef WITH_ROOT
return fMotifPositions.GetSize();
-#endif
}
//_____________________________________________________________________________
{
/// Return the motif position which is in the map on the index-th position
+ AliCodeTimerAuto("");
+
if ( index >= GetNofMotifPositions() ) {
AliErrorStream() << "Index " << index << " outside limits." << endl;
return 0;
}
-#ifdef WITH_STL
- MotifPositionMapIterator it = fMotifPositions.begin();
- std::advance(it, index);
- return it->second;
-#endif
-
-#ifdef WITH_ROOT
- return (AliMpMotifPosition*)fMotifPositions.GetObject(index);
-#endif
+ TIter next(fMotifPositions.CreateIterator());
+ while (index-- > 0) next();
+ return static_cast<AliMpMotifPosition*>(next());
}
//_____________________________________________________________________________
Int_t nofPads = 0;
-#ifdef WITH_STL
- MotifPositionMapIterator it;
- for (it=fMotifPositions.begin(); it != fMotifPositions.end(); it++) {
- AliMpMotifPosition* motifPosition = (*it).second;
- nofPads += motifPosition->GetMotif()->GetMotifType()->GetNofPads();
- }
-#endif
-
-#ifdef WITH_ROOT
- TExMapIter it = fMotifPositions.GetIterator();
- Long_t key, value;
-
- while ( it.Next(key, value) ) {
- AliMpMotifPosition* motifPosition = reinterpret_cast<AliMpMotifPosition*>(value);
+ TIter next(fMotifPositions.CreateIterator());
+ AliMpMotifPosition* motifPosition;
+ while ( ( motifPosition = static_cast<AliMpMotifPosition*>(next()) ) )
+ {
nofPads += motifPosition->GetMotif()->GetMotifType()->GetNofPads();
}
-#endif
return nofPads;
}
{
/// Print all motif positions.
-#ifdef WITH_STL
- if (fMotifPositions.size()) {
- cout << "Dump of Motif Position Map - " << fMotifPositions.size() << " entries:" << endl;
- Int_t counter = 0;
- for (MotifPositionMapIterator i=fMotifPositions.begin();
- i != fMotifPositions.end(); i++) {
-
- cout << "Map element "
- << setw(3) << counter++ << " ";
- PrintMotifPosition((*i).second);
- cout << endl;
- }
- cout << endl;
- }
-#endif
-
-#ifdef WITH_ROOT
if (fMotifPositions.GetSize()) {
cout << "Dump of Motif Position Map - " << fMotifPositions.GetSize() << " entries:" << endl;
Int_t counter = 0;
- TExMapIter i = fMotifPositions.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- AliMpMotifPosition* motifPosition = (AliMpMotifPosition*)value;
+ TIter next(fMotifPositions.CreateIterator());
+ AliMpMotifPosition* motifPosition;
+
+ while ( ( motifPosition = static_cast<AliMpMotifPosition*>(next()) ) )
+ {
cout << "Map element "
<< setw(3) << counter++ << " ";
PrintMotifPosition(motifPosition);
}
cout << endl;
}
-#endif
}
//_____________________________________________________________________________
/// Print all motif positions from the second map
/// (by global indices)
-#ifdef WITH_STL
- if (fMotifPositions2.size()) {
- cout << "Dump of Motif Position Map 2 - " << fMotifPositions2.size() << " entries:" << endl;
- Int_t counter = 0;
- for (MotifPositionMap2Iterator i=fMotifPositions2.begin();
- i != fMotifPositions2.end(); i++) {
-
- cout << "Map element "
- << setw(3) << counter++ << " ";
- PrintMotifPosition2((*i).second);
- cout << endl;
- }
- cout << endl;
- }
-#endif
-
-#ifdef WITH_ROOT
- if (fMotifPositions2.GetSize()) {
+ if (fMotifPositions2.GetSize())
+ {
cout << "Dump of Motif Position Map 2 - " << fMotifPositions2.GetSize() << " entries:" << endl;
+ TIter next(fMotifPositions2.CreateIterator());
+ AliMpMotifPosition* motifPosition(0x0);
Int_t counter = 0;
- TExMapIter i = fMotifPositions2.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- AliMpMotifPosition* motifPosition = (AliMpMotifPosition*)value;
- cout << "Map element "
- << setw(3) << counter++ << " ";
+
+ while ( ( motifPosition = static_cast<AliMpMotifPosition*>(next()) ) )
+ {
+ cout << "Map element " << setw(3) << counter++ << " ";
PrintMotifPosition2(motifPosition);
cout << endl;
}
cout << endl;
}
-#endif
}
//
return false;
}
-#ifdef WITH_STL
- fMotifs[motif->GetID()] = motif;
-#endif
-
-#ifdef WITH_ROOT
fMotifs.Add(motif->GetID(), motif);
-#endif
return true;
}
return false;
}
-#ifdef WITH_STL
- fMotifTypes[motifType->GetID()] = motifType;
-#endif
-
-#ifdef WITH_ROOT
fMotifTypes.Add(motifType->GetID(), motifType);
-#endif
return true;
}
return false;
}
-#ifdef WITH_STL
- fMotifPositions[motifPosition->GetID()] = motifPosition;
-#endif
-
-#ifdef WITH_ROOT
- fMotifPositions.Add(motifPosition->GetID(), motifPosition);
-#endif
+ fMotifPositions.Add(motifPosition->GetID() << 16, motifPosition);
return true;
}
{
/// Fill the second map (by global indices) of motif positions.
-#ifdef WITH_STL
- if (fMotifPositions2.size() > 0 ) {
- AliWarningStream() << "Map has been already filled." << endl;
- return;
- }
-
- for (MotifPositionMapIterator ip=fMotifPositions.begin();
- ip != fMotifPositions.end(); ip++) {
-
- fMotifPositions2[(*ip).second->GetLowIndicesLimit()] = (*ip).second;
- }
-#endif
-
-#ifdef WITH_ROOT
if (fMotifPositions2.GetSize() > 0 ) {
AliWarningStream() <<"Map has been already filled." << endl;
return;
}
- TExMapIter i = fMotifPositions.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- AliMpMotifPosition* motifPosition = (AliMpMotifPosition*)value;
- fMotifPositions2.Add(motifPosition->GetLowIndicesLimit(), motifPosition);
+ TIter next(fMotifPositions.CreateIterator());
+ AliMpMotifPosition* motifPosition(0x0);
+ while ( ( motifPosition = static_cast<AliMpMotifPosition*>(next()) ) )
+ {
+ fMotifPositions2.Add(motifPosition->GetLowLimitIx(),
+ motifPosition->GetLowLimitIy(),
+ motifPosition);
}
-#endif
-
}
//_____________________________________________________________________________
ofstream out(fileName, ios::out);
-#ifdef WITH_STL
- if (fMotifPositions.size()) {
- for (MotifPositionMapIterator i=fMotifPositions.begin();
- i != fMotifPositions.end(); i++) {
-
- AliMpMotifPosition* motifPosition = (*i).second;
- out << setw(5) << motifPosition->GetID() << " "
- << setw(3) << motifPosition->GetLowIndicesLimit().GetFirst() << " "
- << setw(3) << motifPosition->GetLowIndicesLimit().GetSecond()
- << endl;
- }
- out << endl;
- }
-#endif
-
-#ifdef WITH_ROOT
if (fMotifPositions.GetSize()) {
- TExMapIter i = fMotifPositions.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- AliMpMotifPosition* motifPosition = (AliMpMotifPosition*)value;
+ TIter next(fMotifPositions.CreateIterator());
+ AliMpMotifPosition* motifPosition;
+ while ( ( motifPosition = static_cast<AliMpMotifPosition*>(next()) ) )
+ {
out << setw(5) << motifPosition->GetID() << " "
- << setw(3) << motifPosition->GetLowIndicesLimit().GetFirst() << " "
- << setw(3) << motifPosition->GetLowIndicesLimit().GetSecond()
+ << setw(3) << motifPosition->GetLowLimitIx() << " "
+ << setw(3) << motifPosition->GetLowLimitIy()
<< endl;
}
out << endl;
}
-#endif
}
//_____________________________________________________________________________
<< "Processing "
<< motifPosition->GetID() << " " << offx << " " << offy << endl;
- motifPosition->SetLowIndicesLimit(AliMpIntPair(offx, offy));
+ motifPosition->SetLowIndicesLimit(offx, offy);
Int_t offx2
= offx + motifPosition->GetMotif()->GetMotifType()->GetNofPadsX() - 1;
Int_t offy2
= offy + motifPosition->GetMotif()->GetMotifType()->GetNofPadsY() - 1;
- motifPosition->SetHighIndicesLimit(AliMpIntPair(offx2, offy2));
+ motifPosition->SetHighIndicesLimit(offx2, offy2);
}
else {
AliWarningStream()
{
/// Find the motif with the specified ID.
-#ifdef WITH_STL
- MotifMapIterator i = fMotifs.find(motifID);
- if (i != fMotifs.end())
- return (*i).second;
- else
- return 0;
-#endif
+ //AliCodeTimerAuto("");
-#ifdef WITH_ROOT
return (AliMpVMotif*)fMotifs.GetValue(motifID);
-#endif
}
//_____________________________________________________________________________
/// with the given motifTypeID and motifDimensions.
/// Disagreement causes fatal error.
+ //AliCodeTimerAuto("");
+
AliMpVMotif* motif = FindMotif(motifID);
if (motif && motif->GetMotifType()->GetID() != motifTypeID) {
- Fatal("FindMotif",
- "Motif has been already defined with a different type.");
+ AliFatal("Motif has been already defined with a different type.");
return 0;
}
( motif->GetPadDimensions(0).X() != padDimensions.X() ||
motif->GetPadDimensions(0).Y() != padDimensions.Y())) {
- Fatal("FindMotifType",
- "Motif type has been already defined with different dimensions.");
+ AliFatal("Motif type has been already defined with different dimensions.");
return 0;
}
(padDimensions.X() == 0. && padDimensions.Y() == 0.) &&
!dynamic_cast<AliMpMotifSpecial*>(motif)) {
- Fatal("FindMotifType",
- "Motif type has been already defined with different dimensions.");
+ AliFatal("Motif type has been already defined with different dimensions.");
return 0;
}
{
/// Find the motif type with the specified motif type ID.
-#ifdef WITH_STL
- MotifTypeMapIterator i = fMotifTypes.find(motifTypeID);
- if (i != fMotifTypes.end())
- return (*i).second;
- else
- return 0;
-#endif
+ //AliCodeTimerAuto("");
-#ifdef WITH_ROOT
return (AliMpMotifType*)fMotifTypes.GetValue(motifTypeID);
-#endif
}
//_____________________________________________________________________________
{
/// Find the motif position with the specified motif position ID.
-#ifdef WITH_STL
- MotifPositionMapIterator i = fMotifPositions.find(motifPositionID);
- if (i != fMotifPositions.end())
- return (*i).second;
- else
- return 0;
-#endif
+ //AliCodeTimerAuto("");
-#ifdef WITH_ROOT
- return (AliMpMotifPosition*)fMotifPositions.GetValue(motifPositionID);
-#endif
-}
-
-/*
-//_____________________________________________________________________________
-AliMpMotifPosition*
-AliMpMotifMap::FindMotifPosition(const AliMpIntPair& indices) const
-{
-/// Find the last motif position which has the global indices (low limit)
-/// less then the indices specified.
-
-#ifdef WITH_STL
- MotifPositionMap2Iterator found
- = fMotifPositions2.lower_bound(indices);
-
- if (found == fMotifPositions2.end()) found--;
-
- MotifPositionMap2Iterator i=found;
- do {
- AliMpIntPair low = (*i).second->GetLowIndicesLimit();
- AliMpIntPair up = (*i).second->GetHighIndicesLimit();
-
- if ( indices.GetFirst() >= low.GetFirst() &&
- indices.GetSecond() >= low.GetSecond() &&
- indices.GetFirst() <= up.GetFirst() &&
- indices.GetSecond() <= up.GetSecond())
-
- return (*i).second;
- }
- while ( i-- != fMotifPositions2.begin());
-
- return 0;
-#endif
-
-#ifdef WITH_ROOT
- // HOW TO DO THIS WITH ROOT ????
- // Fortunately it seems not to be used anywhere
- Fatal("FindMotifPosition", "Difficult in Root to do this.");
- return 0;
-#endif
+ return (AliMpMotifPosition*)fMotifPositions.GetValue(motifPositionID << 16);
}
-*/