**************************************************************************/
// $Id$
-// $MpId: AliMpMotifType.cxx,v 1.9 2006/03/17 11:38:06 ivana Exp $
+// $MpId: AliMpMotifType.cxx,v 1.10 2006/05/24 13:58:41 ivana Exp $
// Category: motif
-//
+
+//-----------------------------------------------------------------------------
// Class AliMpMotifType
// --------------------
// Class that defines the motif properties.
// Included in AliRoot: 2003/05/02
// Authors: David Guez, Ivana Hrivnacova; IPN Orsay
+//-----------------------------------------------------------------------------
+#include <cstdlib>
#include "AliMpMotifType.h"
+
+#include "AliMpExMapIterator.h"
#include "AliMpMotifTypePadIterator.h"
#include "AliMpConnection.h"
+#include "AliLog.h"
+#include "AliMpFiles.h"
+#include "TSystem.h"
+
#include <Riostream.h>
-#include <stdlib.h>
+/// \cond CLASSIMP
+ClassImp(AliMpMotifType)
+/// \endcond
const Int_t AliMpMotifType::fgkPadNumForA = 65;
-ClassImp(AliMpMotifType)
-
//______________________________________________________________________________
AliMpMotifType::AliMpMotifType(const TString &id)
: TObject(),
fID(id),
fNofPadsX(0),
fNofPadsY(0),
- fVerboseLevel(0),
-#ifdef WITH_STL
fConnections()
-#endif
-#ifdef WITH_ROOT
- fConnections(true)
-#endif
{
- /// Standard constructor
+ /// Standard constructor \n
+ /// Please note that id should be of the form %s for station 1,2,
+ // %s-%e-%e for station345 and %sx%e for stationTrigger
+
+ AliDebug(1,Form("this=%p id=%s",this,id.Data()));
}
//______________________________________________________________________________
-AliMpMotifType::AliMpMotifType()
+AliMpMotifType::AliMpMotifType(TRootIOCtor* ioCtor)
: TObject(),
fID(""),
fNofPadsX(0),
fNofPadsY(0),
- fVerboseLevel(0),
+#ifdef WITH_STL
fConnections()
+#endif
+#ifdef WITH_ROOT
+ fConnections(ioCtor)
+#endif
{
/// Default constructor
+ AliDebug(1,Form("this=%p",this));
+}
+
+//______________________________________________________________________________
+AliMpMotifType::AliMpMotifType(const AliMpMotifType& rhs)
+: TObject(),
+ fID(""),
+ fNofPadsX(0),
+ fNofPadsY(0),
+ fConnections()
+{
+ /// Copy constructor
+
+ AliDebug(1,Form("this=%p (copy ctor)",this));
+ rhs.Copy(*this);
+}
+
+//______________________________________________________________________________
+AliMpMotifType&
+AliMpMotifType::operator=(const AliMpMotifType& rhs)
+{
+ /// Assignment operator
+
+ TObject::operator=(rhs);
+ rhs.Copy(*this);
+ return *this;
+}
+
+//______________________________________________________________________________
+TObject*
+AliMpMotifType::Clone(const char* /*newname*/) const
+{
+ /// Returns a full copy of this object
+ return new AliMpMotifType(*this);
+}
+
+//______________________________________________________________________________
+void
+AliMpMotifType::Copy(TObject& object) const
+{
+ /// Copy object
+
+ TObject::Copy(object);
+ AliMpMotifType& mt = static_cast<AliMpMotifType&>(object);
+ mt.fID = fID;
+ mt.fNofPadsX = fNofPadsX;
+ mt.fNofPadsY = fNofPadsY;
+ mt.fConnections = fConnections;
}
//______________________________________________________________________________
fConnections.erase(fConnections.begin(),fConnections.end());
#endif
+
+ AliDebug(1,Form("this=%p",this));
+// StdoutToAliDebug(1,this->Print(););
}
//______________________________________________________________________________
#endif
#ifdef WITH_ROOT
- TExMapIter i = fConnections.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- AliMpConnection* connection = (AliMpConnection*)value;
- if (connection->GetPadNum()==padNum) return connection;
- }
- return 0;
+ TIter next(fConnections.CreateIterator());
+ AliMpConnection* connection;
+
+ while ( ( connection = static_cast<AliMpConnection*>(next()) ) )
+ {
+ if (connection->GetPadNum()==padNum) return connection;
+ }
+ return 0x0;
#endif
}
#endif
#ifdef WITH_ROOT
- TExMapIter i = fConnections.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- AliMpConnection* connection = (AliMpConnection*)value;
- if (connection->GetGassiNum()==gassiNum) return connection;
- }
- return 0;
+ TIter next(fConnections.CreateIterator());
+ AliMpConnection* connection;
+
+ while ( ( connection = static_cast<AliMpConnection*>(next()) ) )
+ {
+ if (connection->GetGassiNum()==gassiNum) return connection;
+ }
+ return 0x0;
#endif
}
#endif
#ifdef WITH_ROOT
- TExMapIter i = fConnections.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- AliMpConnection* connection = (AliMpConnection*)value;
- if (connection->GetKaptonNum()==kaptonNum) return connection;
- }
- return 0;
+ TIter next(fConnections.CreateIterator());
+ AliMpConnection* connection;
+
+ while ( ( connection = static_cast<AliMpConnection*>(next()) ) )
+ {
+ if (connection->GetKaptonNum()==kaptonNum) return connection;
+ }
+ return 0x0;
#endif
}
//______________________________________________________________________________
#endif
#ifdef WITH_ROOT
- TExMapIter i = fConnections.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- AliMpConnection* connection = (AliMpConnection*)value;
- if (connection->GetBergNum()==bergNum) return connection;
- }
- return 0;
+ TIter next(fConnections.CreateIterator());
+ AliMpConnection* connection;
+
+ while ( ( connection = static_cast<AliMpConnection*>(next()) ) )
+ {
+ if (connection->GetBergNum()==bergNum) return connection;
+ }
+ return 0x0;
#endif
}
//______________________________________________________________________________
-AliMpIntPair AliMpMotifType::FindLocalIndicesByConnection(
- const AliMpConnection* connection) const
+AliMpIntPair AliMpMotifType::FindLocalIndicesByConnection(const AliMpConnection* connection) const
{
- /// Retrieve the pad position from the connection pointer.
- /// Not to be used widely, since it use a search in the
- /// connection list...
+ /// Reurn the pad position from the connection pointer.
-#ifdef WITH_STL
- for(ConnectionMapCIterator i = fConnections.begin();
- i!=fConnections.end();++i)
- if (i->second==connection) return i->first;
-#endif
-
-#ifdef WITH_ROOT
- TExMapIter i = fConnections.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- AliMpConnection* aConnection = (AliMpConnection*)value;
- if (aConnection == connection) return AliMpExMap::GetPair(key);
- }
-#endif
-
- return AliMpIntPair::Invalid();
+ return connection->LocalIndices();
}
//______________________________________________________________________________
#endif
#ifdef WITH_ROOT
- TExMapIter i = fConnections.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- AliMpConnection* connection = (AliMpConnection*)value;
- if (connection->GetPadNum() == padNum) return AliMpExMap::GetPair(key);
- }
+ TIter next(fConnections.CreateIterator());
+ AliMpConnection* connection;
+
+ while ( ( connection = static_cast<AliMpConnection*>(next()) ) )
+ {
+ if (connection->GetPadNum()==padNum) return connection->LocalIndices();
+ }
#endif
return AliMpIntPair::Invalid();
}
#endif
#ifdef WITH_ROOT
- TExMapIter i = fConnections.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- AliMpConnection* connection = (AliMpConnection*)value;
- if (connection->GetGassiNum()==gassiNum) return AliMpExMap::GetPair(key);
- }
+ TIter next(fConnections.CreateIterator());
+ AliMpConnection* connection;
+
+ while ( ( connection = static_cast<AliMpConnection*>(next()) ) )
+ {
+ if (connection->GetGassiNum()==gassiNum) return connection->LocalIndices();
+ }
#endif
return AliMpIntPair::Invalid();
#endif
#ifdef WITH_ROOT
- TExMapIter i = fConnections.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- AliMpConnection* connection = (AliMpConnection*)value;
- if (connection->GetKaptonNum()==kaptonNum) return AliMpExMap::GetPair(key);
- }
+ TIter next(fConnections.CreateIterator());
+ AliMpConnection* connection;
+
+ while ( ( connection = static_cast<AliMpConnection*>(next()) ) )
+ {
+ if (connection->GetKaptonNum()==kaptonNum) return connection->LocalIndices();
+ }
#endif
return AliMpIntPair::Invalid();
#endif
#ifdef WITH_ROOT
- TExMapIter i = fConnections.GetIterator();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- AliMpConnection* connection = (AliMpConnection*)value;
- if (connection->GetBergNum()==bergNum) return AliMpExMap::GetPair(key);
- }
+ TIter next(fConnections.CreateIterator());
+ AliMpConnection* connection;
+
+ while ( ( connection = static_cast<AliMpConnection*>(next()) ) )
+ {
+ if (connection->GetBergNum()==bergNum) return connection->LocalIndices();
+ }
#endif
return AliMpIntPair::Invalid();
//______________________________________________________________________________
Bool_t AliMpMotifType::HasPad(const AliMpIntPair& localIndices) const
{
- /// Return true if the pad indexed by <localIndices> has a connection
+ /// Return true if the pad indexed by \a localIndices has a connection
if (!localIndices.IsValid()) return false;
AliMpConnection *connexion = FindConnectionByLocalIndices(AliMpIntPair(i,j));
TString str;
if (connexion){
- switch (option[0]){
- case 'N':str=PadName(connexion->GetPadNum());
- break;
- case 'K':str=Form("%d",connexion->GetKaptonNum());
- break;
- case 'B':str=Form("%d",connexion->GetBergNum());
- break;
- case 'G':str=Form("%d",connexion->GetGassiNum());
- break;
- default:str= Form("%d",connexion->GetPadNum());
- }
- cout<<setw(2)<<str;
+ AliDebug(1,Form("i,j=%2d,%2d connexion=%p",i,j,connexion));
+
+ switch (option[0]){
+ case 'N':str=PadName(connexion->GetPadNum());
+ break;
+ case 'K':str=Form("%d",connexion->GetKaptonNum());
+ break;
+ case 'B':str=Form("%d",connexion->GetBergNum());
+ break;
+ case 'G':str=Form("%d",connexion->GetGassiNum());
+ break;
+ default:str= Form("%d",connexion->GetPadNum());
+ }
+ cout<<setw(2)<<str;
} else cout<<setw(2)<<"--";
cout<<" ";
}
cout<<endl;
}
}
+
+//_____________________________________________________________________________
+Bool_t
+AliMpMotifType::Save() const
+{
+/// Save this motif type
+
+ return Save(fID.Data());
+}
+
+//_____________________________________________________________________________
+Bool_t
+AliMpMotifType::Save(const char* motifName) const
+{
+ /// Generate the 2 files needed to describe the motif
+
+ TString padPosFileName(AliMpFiles::PadPosFileName(motifName));
+
+ TString motifTypeFileName(AliMpFiles::MotifFileName(motifName));
+
+ // first a protection : do not allow overwriting existing files...
+ Bool_t test = gSystem->AccessPathName(padPosFileName.Data());
+ if (test==kFALSE) // AccessPathName has a strange return value convention...
+ {
+ AliError("Cannot overwrite existing padPos file");
+ return kFALSE;
+ }
+ test = gSystem->AccessPathName(motifTypeFileName.Data());
+ if (test==kFALSE)
+ {
+ AliError("Cannot overwrite existing motifType file");
+ return kFALSE;
+ }
+
+ ofstream padPosFile(padPosFileName.Data());
+ ofstream motifFile(motifTypeFileName.Data());
+
+ motifFile << "# Motif " << motifName << endl
+ << "#" << endl
+ << "#connecteur_berg kapton padname not_used" << endl
+ << "#for slats there's no kapton connector, so it's always 1"
+ << " (zero make the reader" << endl
+ << "#abort, so it's not a valid value here)." << endl
+ << "#" << endl;
+
+ for ( Int_t ix = 0; ix < GetNofPadsX(); ++ix )
+ {
+ for ( Int_t iy = 0; iy < GetNofPadsY(); ++iy )
+ {
+ AliMpConnection* con = FindConnectionByLocalIndices(AliMpIntPair(ix,iy));
+ if (con)
+ {
+ motifFile << con->GetBergNum() << "\t1\t" << con->GetPadNum() << "\t-" << endl;
+ padPosFile << con->GetPadNum() << "\t" << ix << "\t" << iy << endl;
+ }
+ }
+ }
+
+ padPosFile.close();
+ motifFile.close();
+
+ return kTRUE;
+}
+
+
+