**************************************************************************/
// $Id$
-// $MpId: AliMpMotifMap.cxx,v 1.13 2006/03/15 10:04:36 ivana Exp $
+// $MpId: AliMpMotifMap.cxx,v 1.16 2006/05/24 13:58:41 ivana Exp $
// Category: motif
// -------------------
// Class AliMpMotifMap
// Included in AliRoot: 2003/05/02
// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
-#include <Riostream.h>
-#include <TVector2.h>
-
#include "AliMpMotifMap.h"
#include "AliMpVMotif.h"
#include "AliMpMotif.h"
#include "AliMpMotifSpecial.h"
#include "AliMpMotifType.h"
#include "AliMpMotifPosition.h"
-#include "TArrayI.h"
+#include "AliLog.h"
+
+#include <Riostream.h>
+#include <TVector2.h>
+#include <TArrayI.h>
+
+/// \cond CLASSIMP
ClassImp(AliMpMotifMap)
+/// \endcond
//_____________________________________________________________________________
AliMpMotifMap::AliMpMotifMap(Bool_t /*standardConstructor*/)
void AliMpMotifMap::PrintMotif(const AliMpVMotif* motif) const
{
/// Print the motif.
-// ---
cout << motif->GetID().Data() << " "
<< motif->GetMotifType()->GetID() << " "
#endif
}
+//_____________________________________________________________________________
+UInt_t AliMpMotifMap::GetNofMotifPositions() const
+{
+/// 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
+}
+
+//_____________________________________________________________________________
+AliMpMotifPosition* AliMpMotifMap::GetMotifPosition(UInt_t index) const
+{
+/// Return the motif position which is in the map on the index-th position
+
+ 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
+}
+
//_____________________________________________________________________________
Int_t AliMpMotifMap::CalculateNofPads() const
{
+/// Calculate total number of pads in the map
+
Int_t nofPads = 0;
#ifdef WITH_STL
//_____________________________________________________________________________
void AliMpMotifMap::PrintMotifPositions() const
{
-/// Print all the the motifs positions.
+/// Print all motif positions.
#ifdef WITH_STL
if (fMotifPositions.size()) {
//_____________________________________________________________________________
void AliMpMotifMap::PrintMotifPositions2() const
{
-/// Print all the the motifs positions from the second map
+/// Print all motif positions from the second map
/// (by global indices)
#ifdef WITH_STL
AliMpVMotif* found = FindMotif(motif->GetID());
if (found) {
if (warn && found == motif)
- Warning("AddMotif", "The motif is already in map.");
- if (warn && found != motif)
- Warning("AddMotif", "Another motif with the same ID is already in map.");
+ AliWarningStream() << "The motif is already in map." << endl;
+
+ if (warn && found != motif) {
+ AliWarningStream()
+ << "Another motif with the same ID is already in map." << endl;
+ }
return false;
}
AliMpMotifType* found = FindMotifType(motifType->GetID());
if (found) {
if (warn && found == motifType)
- Warning("AddMotifType", "The motif type is already in map.");
- if (warn && found != motifType)
- Warning("AddMotifType",
- "Another motif type with the same ID is already in map.");
+ AliWarningStream() << "The motif type is already in map." << endl;
+
+ if (warn && found != motifType) {
+ AliWarningStream()
+ << "Another motif type with the same ID is already in map." << endl;
+ }
return false;
}
AliMpMotifPosition* found = FindMotifPosition(motifPosition->GetID());
if (found) {
if (warn && found == motifPosition) {
- cerr << "ID: " << motifPosition->GetID()
+ AliWarningStream()
+ << "ID: " << motifPosition->GetID()
<< " found: " << found
- << " new: " << motifPosition << endl;
- Warning("AddMotifPosition", "This motif position is already in map.");
+ << " new: " << motifPosition << endl
+ << "This motif position is already in map." << endl;
}
+
if (warn && found != motifPosition) {
- cerr << "ID: " << motifPosition->GetID()
+ AliWarningStream()
+ << "ID: " << motifPosition->GetID()
<< " found: " << found
- << " new: " << motifPosition << endl;
- Warning("AddMotifposition",
- "Another motif position with the same ID is already in map.");
- }
+ << " new: " << motifPosition << endl
+ << "Another motif position with the same ID is already in map."
+ << endl;
+ }
+
return false;
}
#ifdef WITH_STL
if (fMotifPositions2.size() > 0 ) {
- Warning("FillMotifPositionMap2", "Map has been already filled.");
+ AliWarningStream() << "Map has been already filled." << endl;
return;
}
#ifdef WITH_ROOT
if (fMotifPositions2.GetSize() > 0 ) {
- Warning("FillMotifPositionMap2", "Map has been already filled.");
+ AliWarningStream() <<"Map has been already filled." << endl;
return;
}
//_____________________________________________________________________________
void AliMpMotifMap::PrintGlobalIndices(const char* fileName) const
{
-/// Print all the motifs positions and their global indices.
+/// Print all motif positions and their global indices.
ofstream out(fileName, ios::out);
//_____________________________________________________________________________
void AliMpMotifMap::UpdateGlobalIndices(const char* fileName)
{
-/// Updates the motifs positions global indices
-/// from the file.
+/// Update the motif positions global indices from the file.
ifstream in(fileName, ios::in);
AliMpMotifPosition* motifPosition = FindMotifPosition(motifPositionId);
if (motifPosition) {
- cout << "Processing "
+ AliDebugStream(1)
+ << "Processing "
<< motifPosition->GetID() << " " << offx << " " << offy << endl;
motifPosition->SetLowIndicesLimit(AliMpIntPair(offx, offy));
motifPosition->SetHighIndicesLimit(AliMpIntPair(offx2, offy2));
}
else {
- cerr <<"Motif position " << motifPositionId << endl;
- Warning("UpdateGlobalIndices", "Motif position not found !!!");
+ AliWarningStream()
+ << "Motif position " << motifPositionId << " not found" << endl;
}
}
while (!in.eof());
//_____________________________________________________________________________
AliMpVMotif* AliMpMotifMap::FindMotif(const TString& motifID) const
{
-/// Finds the motif with the specified ID.
+/// Find the motif with the specified ID.
#ifdef WITH_STL
MotifMapIterator i = fMotifs.find(motifID);
const TString& motifTypeID,
const TVector2& padDimensions ) const
{
-/// Finds the motif with the specified ID and returns it
+/// Find the motif with the specified ID and returns it
/// only if its motif type and motif dimensions agree
/// with the given motifTypeID and motifDimensions.
/// Disagreement causes fatal error.