#include "AliMpSegmentation.h"
+#include "AliMpDataStreams.h"
#include "AliMpDetElement.h"
#include "AliMpDEStore.h"
#include "AliMpDEManager.h"
#include "AliMpTriggerReader.h"
#include "AliMpTriggerSegmentation.h"
#include "AliMpCathodType.h"
+#include "AliMpSlatMotifMap.h"
+
#include "AliLog.h"
-#include "AliCDBManager.h"
-#include "AliCDBEntry.h"
#include <Riostream.h>
#include <TMap.h>
#include <TSystem.h>
#include <TClass.h>
+#include <cassert>
+
/// \cond CLASSIMP
ClassImp(AliMpSegmentation)
/// \endcond
}
//______________________________________________________________________________
-AliMpSegmentation* AliMpSegmentation::ReadData(Bool_t warn)
+AliMpSegmentation* AliMpSegmentation::ReadData(const AliMpDataStreams& dataStreams,
+ Bool_t warn)
{
/// Load the sementation from ASCII data files
/// and return its instance
return fgInstance;
}
- AliInfoClass("Reading segmentation from ASCII files.");
+ if ( dataStreams.GetReadFromFiles() )
+ AliInfoClass("Reading segmentation from ASCII files.");
- fgInstance = new AliMpSegmentation();
+ fgInstance = new AliMpSegmentation(dataStreams);
return fgInstance;
}
//
//______________________________________________________________________________
-AliMpSegmentation::AliMpSegmentation()
+AliMpSegmentation::AliMpSegmentation(const AliMpDataStreams& dataStreams)
: TObject(),
+ fDataStreams(dataStreams),
fDetElements(0),
fMpSegmentations(true),
- fElCardsMap(true),
- fSlatMotifMap()
+ fElCardsMap(),
+ fSlatMotifMap(new AliMpSlatMotifMap)
{
/// Standard constructor - segmentation is loaded from ASCII data files
AliDebug(1,"");
- fElCardsMap.SetOwner(true);
+
+ fElCardsMap.SetOwner(kTRUE);
// Load DE data
if ( ! AliMpDEStore::Instance(false) )
- AliMpDEStore::ReadData();
+ AliMpDEStore::ReadData(dataStreams);
fDetElements = AliMpDEStore::Instance();
// Create mapping segmentations for all detection elements
- for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; cath ++ ) {
- AliMpDEIterator it;
- for ( it.First(); ! it.IsDone(); it.Next() ) {
- CreateMpSegmentation(it.CurrentDEId(), AliMp::GetCathodType(cath));
- }
- }
-
- // Fill el cards map for all detection elements
- // of tracking chambers
AliMpDEIterator it;
- for ( it.First(); ! it.IsDone(); it.Next() ) {
- if ( AliMpDEManager::GetStationType(it.CurrentDEId()) != AliMp::kStationTrigger ) {
- FillElCardsMap(it.CurrentDEId());
+ for ( it.First(); ! it.IsDone(); it.Next() )
+ {
+ Int_t n(0);
+
+ for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
+ {
+ if ( CreateMpSegmentation(it.CurrentDEId(), AliMp::GetCathodType(cath)) ) ++n;
}
- }
+
+ if ( n == 2 && // should always be the case except when we play with the CreateMpSegmentation method...
+ AliMpDEManager::GetStationType(it.CurrentDEId()) != AliMp::kStationTrigger ) // only for tracker
+ {
+ // Fill el cards map for all detection elements
+ // of tracking chambers
+ FillElCardsMap(it.CurrentDEId());
+ }
+ }
}
//______________________________________________________________________________
-AliMpSegmentation::AliMpSegmentation(TRootIOCtor* /*ioCtor*/)
+AliMpSegmentation::AliMpSegmentation(TRootIOCtor* ioCtor)
: TObject(),
+ fDataStreams(ioCtor),
fDetElements(0),
fMpSegmentations(),
- fElCardsMap(),
- fSlatMotifMap()
+ fElCardsMap(ioCtor),
+ fSlatMotifMap(0)
{
/// Constructor for IO
// Segmentations are deleted with fMpSegmentations
// El cards arrays are deleted with fElCardsMap
+ delete fSlatMotifMap;
+
fgInstance = 0;
}
AliMpVSegmentation* mpSegmentation = 0;
if ( stationType == AliMp::kStation1 || stationType == AliMp::kStation2 ) {
- AliMpSectorReader reader(stationType, planeType);
+ AliMpSectorReader reader(fDataStreams, stationType, planeType);
AliMpSector* sector = reader.BuildSector();
mpSegmentation = new AliMpSectorSegmentation(sector, true);
}
else if ( stationType == AliMp::kStation345 ) {
- AliMpSt345Reader reader(fSlatMotifMap);
+ AliMpSt345Reader reader(fDataStreams,fSlatMotifMap);
AliMpSlat* slat = reader.ReadSlat(deTypeName, planeType);
mpSegmentation = new AliMpSlatSegmentation(slat, true);
}
else if ( stationType == AliMp::kStationTrigger ) {
- AliMpTriggerReader reader(fSlatMotifMap);
+ AliMpTriggerReader reader(fDataStreams,fSlatMotifMap);
AliMpTrigger* trigger = reader.ReadSlat(deTypeName, planeType);
mpSegmentation = new AliMpTriggerSegmentation(trigger, true);
}
else
AliErrorStream() << "Unknown station type" << endl;
- fMpSegmentations.Add(deSegName, mpSegmentation);
+ if ( mpSegmentation ) fMpSegmentations.Add(deSegName, mpSegmentation);
// StdoutToAliDebug(3, fSlatMotifMap.Print(););
AliDebugStream(2) << "detElemId=" << detElemId << endl;;
- AliMpExMap* mde = new AliMpExMap(true);
+ AliMpExMap* mde = new AliMpExMap;
mde->SetOwner(kFALSE);
fElCardsMap.Add(detElemId,mde);
const AliMpVSegmentation* seg[2];
TArrayI ecn[2];
- // Do it in 2 steps to be able to set the AliMpExMap size once for all,
- // to avoid annoying warning message in case of dynamical resizing.
- // (not critical).
for ( Int_t cathode = AliMp::kCath0; cathode <= AliMp::kCath1; ++cathode )
{
seg[cathode] = GetMpSegmentation(detElemId,AliMp::GetCathodType(cathode));
seg[cathode]->GetAllElectronicCardIDs(ecn[cathode]);
- }
-
- mde->SetSize(ecn[0].GetSize()+ecn[1].GetSize());
-
- for ( Int_t cathode = AliMp::kCath0; cathode <= AliMp::kCath1; ++ cathode )
- {
for ( Int_t i = 0; i < ecn[cathode].GetSize(); ++i )
{
mde->Add(ecn[cathode][i],const_cast<AliMpVSegmentation*>(seg[cathode]));
}
}
+ assert( mde->GetSize() > 0 );
+
return mde;
+
}
//