#include <Riostream.h>
#include <TMath.h>
+#include <TError.h>
#include "AliMpSectorSegmentation.h"
#include "AliMpSector.h"
ClassImp(AliMpSectorSegmentation)
+#ifdef WITH_ROOT
+const Double_t AliMpSectorSegmentation::fgkS1 = 10000.;
+const Double_t AliMpSectorSegmentation::fgkS2 = 100.;
+#endif
+
//______________________________________________________________________________
AliMpSectorSegmentation::AliMpSectorSegmentation(const AliMpSector* sector)
: AliMpVSegmentation(),
- fkSector(sector)
+ fkSector(sector),
+ fMaxIndexInX(0),
+ fMaxIndexInY(0)
{
//
fPadBuffer = new AliMpPad(AliMpPad::Invalid());
: AliMpVSegmentation(),
fkSector(0),
fPadBuffer(0),
- fPadDimensionsMap()
+ fPadDimensionsMap(),
+ fMaxIndexInX(0),
+ fMaxIndexInY(0)
{
//
}
+//_____________________________________________________________________________
+AliMpSectorSegmentation::AliMpSectorSegmentation(
+ const AliMpSectorSegmentation& right)
+ : AliMpVSegmentation(right) {
+//
+ Fatal("AliMpSectorSegmentation", "Copy constructor not provided.");
+}
+
//______________________________________________________________________________
AliMpSectorSegmentation::~AliMpSectorSegmentation() {
//
delete fPadBuffer;
}
+//
+// operators
+//
+
+//_____________________________________________________________________________
+AliMpSectorSegmentation&
+AliMpSectorSegmentation::operator=(const AliMpSectorSegmentation& right)
+{
+ // check assignement to self
+ if (this == &right) return *this;
+
+ Fatal("operator =", "Assignement operator not provided.");
+
+ return *this;
+}
+
//
// private methods
//
+#ifdef WITH_ROOT
+//______________________________________________________________________________
+Long_t AliMpSectorSegmentation::GetIndex(const TVector2& vector2) const
+{
+// Converts the two vector to long.
+// ---
+
+ return Long_t(TMath::Floor((vector2.X()*fgkS1 + vector2.Y())*fgkS2));
+}
+
+//______________________________________________________________________________
+TVector2 AliMpSectorSegmentation::GetVector(Long_t index) const
+{
+// Converts the long index to twovector.
+// ---
+
+ return TVector2( TMath::Floor(index/fgkS1)/fgkS2,
+ (index - TMath::Floor(index/fgkS1)*fgkS1)/fgkS2 );
+}
+#endif
+
//______________________________________________________________________________
void AliMpSectorSegmentation::FillPadDimensionsMap()
{
Int_t zoneID = zone->GetID();
if (!AliMpConstants::IsEqual(zone->GetPadDimensions(), TVector2())) {
+
// regular zone
+#ifdef WITH_STL
fPadDimensionsMap[zoneID*10] = zone->GetPadDimensions();
+#endif
+#ifdef WITH_ROOT
+ fPadDimensionsMap.Add((Long_t)(zoneID*10),
+ GetIndex(zone->GetPadDimensions()));
+#endif
}
else {
// special zone
for (Int_t k=0; k<motif->GetNofPadDimensions(); k++) {
Int_t index = zoneID*10 + subIndex++;
+#ifdef WITH_STL
fPadDimensionsMap[index] = motif->GetPadDimensions(k);
+#endif
+#ifdef WITH_ROOT
+ fPadDimensionsMap.Add((Long_t)(index),
+ GetIndex(motif->GetPadDimensions(k)));
+#endif
}
}
}
AliMpMotifPosition* motifPos = FindMotifPosition(indices);
if (!motifPos) {
- if (warning) Warning("PadByIndices","Pad indices not contained in any motif!");
+ if (warning) {
+ cout << "indices " << indices << endl;
+ Warning("PadByIndices","Pad indices not contained in any motif!");
+ }
return AliMpPad::Invalid();
}
return AliMpPad::Invalid();
}
+//______________________________________________________________________________
+Int_t AliMpSectorSegmentation::MaxPadIndexX()
+{
+// Return maximum pad index in x
+
+ if (fMaxIndexInX) return fMaxIndexInX;
+
+ for (Int_t i=0; i<fkSector->GetNofRows(); i++) {
+ Int_t ixh = fkSector->GetRow(i)->GetHighIndicesLimit().GetFirst();
+ if ( ixh > fMaxIndexInX ) fMaxIndexInX = ixh;
+ }
+ return fMaxIndexInX;
+}
+
+//______________________________________________________________________________
+Int_t AliMpSectorSegmentation::MaxPadIndexY()
+{
+// Return maximum pad index in y
+
+ if (fMaxIndexInY) return fMaxIndexInY;
+
+ for (Int_t i=0; i<fkSector->GetNofRows(); i++) {
+ Int_t iyh = fkSector->GetRow(i)->GetHighIndicesLimit().GetSecond();
+ if ( iyh > fMaxIndexInY ) fMaxIndexInY = iyh;
+ }
+ return fMaxIndexInY;
+}
+
//______________________________________________________________________________
Bool_t AliMpSectorSegmentation::HasPad(const AliMpIntPair& indices) const
{
return 0;
}
+#ifdef WITH_STL
PadDimensionsMapCIterator it;
for (it = fPadDimensionsMap.begin(); it != fPadDimensionsMap.end(); ++it) {
if (AliMpConstants::IsEqual(it->second, pad.Dimensions()))
return it->first;
}
+#endif
+
+#ifdef WITH_ROOT
+ PadDimensionsMapCIterator it(&fPadDimensionsMap);
+ Long_t key, value;
+ while ( it.Next(key, value) ) {
+ TVector2 dimensions = GetVector(value);
+ if (AliMpConstants::IsEqual(dimensions, pad.Dimensions()))
+ return (Int_t)key;
+ }
+#endif
// Should never happen
- Fatal("Zone(AliMpPad)", "not found");
+ Error("Zone(AliMpPad)", "not found");
+ cerr << pad << endl;
return 0;
}
// Returns the pad dimensions for the zone with the specified zone index.
// ---
+#ifdef WITH_STL
PadDimensionsMapCIterator it = fPadDimensionsMap.find(zone);
if (it != fPadDimensionsMap.end()) return it->second;
+#endif
+
+#ifdef WITH_ROOT
+ Long_t value = fPadDimensionsMap.GetValue(zone);
+ if (value) return GetVector(value);
+#endif
if (warning) Warning("PadDimensions(zone)", "not found");
return TVector2();
return true;
}
+
+//______________________________________________________________________________
+void AliMpSectorSegmentation::PrintZones() const
+{
+// Prints all zones and pads dimensions from the map.
+// ---
+
+ cout << "Zones: " << endl;
+
+#ifdef WITH_STL
+ PadDimensionsMapCIterator it;
+ for (it = fPadDimensionsMap.begin(); it != fPadDimensionsMap.end(); ++it) {
+ cout << " zone: " << setw(4) << it->first;
+ cout << " pad dimensions: ( "
+ << it->second.X() << ", " << it->second.Y() << ")" << endl;
+ }
+#endif
+
+#ifdef WITH_ROOT
+ PadDimensionsMapCIterator it(&fPadDimensionsMap);
+ Long_t key, value;
+ while ( it.Next(key, value) ) {
+ //cout << "Iterating over: " << key << ", " << value << endl;
+ TVector2 dimensions = GetVector(value);
+
+ cout << " zone: " << setw(4) << key;
+ cout << " pad dimensions: ( "
+ << dimensions.X() << ", " << dimensions.Y() << ")" << endl;
+ }
+#endif
+}
+