#include "AliMpSegmentation.h"
+#include "AliMpDataStreams.h"
#include "AliMpDetElement.h"
#include "AliMpDEStore.h"
#include "AliMpDEManager.h"
#include "AliMpDEIterator.h"
#include "AliMpExMap.h"
+#include "AliMpFastSegmentation.h"
+//#include "AliMpFastSegmentationV2.h"
#include "AliMpSector.h"
#include "AliMpSectorReader.h"
#include "AliMpSectorSegmentation.h"
}
//______________________________________________________________________________
-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(),
+ fkDataStreams(dataStreams),
fDetElements(0),
- fMpSegmentations(),
+ fMpSegmentations(true),
fElCardsMap(),
- fSlatMotifMap(AliMpSlatMotifMap::Instance())
+ fSlatMotifMap(new AliMpSlatMotifMap)
{
/// Standard constructor - segmentation is loaded from ASCII data files
AliDebug(1,"");
+ 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
//______________________________________________________________________________
AliMpSegmentation::AliMpSegmentation(TRootIOCtor* ioCtor)
: TObject(),
+ fkDataStreams(ioCtor),
fDetElements(0),
fMpSegmentations(),
fElCardsMap(ioCtor),
// 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);
+ if ( stationType == AliMp::kStation12 ) {
+ AliMq::Station12Type station12Type = detElement->GetStation12Type();
+ AliMpSectorReader reader(fkDataStreams, station12Type, planeType);
AliMpSector* sector = reader.BuildSector();
- mpSegmentation = new AliMpSectorSegmentation(sector, true);
+ mpSegmentation = new AliMpFastSegmentation(new AliMpSectorSegmentation(sector, true));
}
else if ( stationType == AliMp::kStation345 ) {
- AliMpSt345Reader reader;
+ AliMpSt345Reader reader(fkDataStreams,fSlatMotifMap);
AliMpSlat* slat = reader.ReadSlat(deTypeName, planeType);
- mpSegmentation = new AliMpSlatSegmentation(slat, true);
+ mpSegmentation = new AliMpFastSegmentation(new AliMpSlatSegmentation(slat, true));
}
else if ( stationType == AliMp::kStationTrigger ) {
- AliMpTriggerReader reader;
+ AliMpTriggerReader reader(fkDataStreams,fSlatMotifMap);
AliMpTrigger* trigger = reader.ReadSlat(deTypeName, planeType);
mpSegmentation = new AliMpTriggerSegmentation(trigger, true);
}
return static_cast<AliMpVSegmentation*>(object);
}
+
+//_____________________________________________________________________________
+const AliMpSector*
+AliMpSegmentation::GetSector(const AliMpVSegmentation* kSegmentation,
+ Bool_t warn) const
+{
+/// Return sector for given mapping segmentation.
+/// If segmentation is not of sector type, zero is returned
+/// and an Error is issued if warn is set true (default).
+
+ if ( ! kSegmentation ) return 0;
+
+ if ( kSegmentation->StationType() != AliMp::kStation12 ) {
+ if ( warn ) {
+ AliErrorStream()
+ << "Segmentation is not of sector type" << endl;
+ }
+ return 0;
+ }
+
+ // If fast segmentation
+ const AliMpFastSegmentation* fseg
+ = dynamic_cast<const AliMpFastSegmentation*>(kSegmentation);
+ if ( fseg ) {
+ return
+ static_cast<const AliMpSectorSegmentation*>(fseg->GetHelper())->GetSector();
+ }
+
+ // If fast segmentation V2
+/*
+ const AliMpFastSegmentationV2* fsegV2
+ = dynamic_cast<const AliMpFastSegmentationV2*>(kSegmentation);
+ if ( fsegV2 ) {
+ return
+ static_cast<const AliMpSectorSegmentation*>(fsegV2->GetHelper())->GetSector();
+ }
+*/
+ // If sector segmentation
+ const AliMpSectorSegmentation* sseg
+ = dynamic_cast<const AliMpSectorSegmentation*>(kSegmentation);
+ if ( sseg ) {
+ return sseg->GetSector();
+ }
+
+ // Should not get to this line
+ AliErrorStream() << "Segemntation type not identified." << endl;
+ return 0;
+}
+
+//_____________________________________________________________________________
+const AliMpSector*
+AliMpSegmentation::GetSector(Int_t detElemId, AliMp::CathodType cath,
+ Bool_t warn) const
+{
+/// Return sector for given detElemId and cath.
+/// If segmentation is not of sector type, zero is returned
+/// and an Error is issued if warn is set true (default).
+
+ return GetSector(GetMpSegmentation(detElemId, cath, warn), warn);
+}
+
+//_____________________________________________________________________________
+const AliMpSector*
+AliMpSegmentation::GetSectorByElectronics(Int_t detElemId, Int_t elCardID,
+ Bool_t warn) const
+{
+/// Return sector for given detElemId and elCardID.
+/// If segmentation is not of sector type, zero is returned
+/// and an Error is issued if warn is set true (default).
+
+ return GetSector(GetMpSegmentationByElectronics(detElemId, elCardID, warn), warn);
+}
+
+//_____________________________________________________________________________
+const AliMpSlat*
+AliMpSegmentation::GetSlat(const AliMpVSegmentation* kSegmentation,
+ Bool_t warn) const
+{
+/// Return slat for given mapping segmentation.
+/// If segmentation is not of slat type, zero is returned
+/// and an Error is issued if warn is set true (default).
+
+ if ( ! kSegmentation ) return 0;
+
+ if ( kSegmentation->StationType() != AliMp::kStation345 ) {
+ if ( warn ) {
+ AliErrorStream()
+ << "Segmentation is not of slat type" << endl;
+ }
+ return 0;
+ }
+
+ // If fast segmentation
+ const AliMpFastSegmentation* fseg
+ = dynamic_cast<const AliMpFastSegmentation*>(kSegmentation);
+ if ( fseg ) {
+ return
+ static_cast<const AliMpSlatSegmentation*>(fseg->GetHelper())->Slat();
+ }
+
+ // If fast segmentation V2
+/*
+ const AliMpFastSegmentationV2* fsegV2
+ = dynamic_cast<const AliMpFastSegmentationV2*>(kSegmentation);
+ if ( fsegV2 ) {
+ return
+ static_cast<const AliMpSlatSegmentation*>(fsegV2->GetHelper())->Slat();
+ }
+*/
+ // If slat segmentation
+ const AliMpSlatSegmentation* sseg
+ = dynamic_cast<const AliMpSlatSegmentation*>(kSegmentation);
+
+ if ( sseg ) {
+ return sseg->Slat();
+ }
+
+ // Should not get to this line
+ AliErrorStream() << "Segemntation type not identified." << endl;
+ return 0;
+}
+
+//_____________________________________________________________________________
+const AliMpSlat*
+AliMpSegmentation::GetSlat(Int_t detElemId, AliMp::CathodType cath,
+ Bool_t warn) const
+{
+/// Return slat for given detElemId and cath.
+/// If segmentation is not of slat type, zero is returned
+/// and an Error is issued if warn is set true (default).
+
+ return GetSlat(GetMpSegmentation(detElemId, cath, warn), warn);
+}
+
+//_____________________________________________________________________________
+const AliMpSlat*
+AliMpSegmentation::GetSlatByElectronics(Int_t detElemId, Int_t elCardID,
+ Bool_t warn) const
+{
+/// Return slat for given detElemId and elCardID.
+/// If segmentation is not of slat type, zero is returned
+/// and an Error is issued if warn is set true (default).
+
+ return GetSlat(GetMpSegmentationByElectronics(detElemId, elCardID, warn), warn);
+}
+
+//_____________________________________________________________________________
+const AliMpTrigger*
+AliMpSegmentation::GetTrigger(const AliMpVSegmentation* kSegmentation,
+ Bool_t warn) const
+{
+/// Return trigger for given mapping segmentation.
+/// If segmentation is not of trigger type, zero is returned
+/// and an Error is issued if warn is set true (default).
+
+ if ( ! kSegmentation ) return 0;
+
+ if ( kSegmentation->StationType() != AliMp::kStationTrigger ) {
+ if ( warn ) {
+ AliErrorStream()
+ << "Segmentation is not of trigger type" << endl;
+ }
+ return 0;
+ }
+
+ // If slat segmentation
+ const AliMpTriggerSegmentation* tseg
+ = dynamic_cast<const AliMpTriggerSegmentation*>(kSegmentation);
+ if ( tseg ) {
+ return tseg->Slat();
+ }
+
+ // If fast segmentation
+ const AliMpFastSegmentation* fseg
+ = dynamic_cast<const AliMpFastSegmentation*>(kSegmentation);
+
+ if ( fseg ) {
+ return
+ static_cast<const AliMpTriggerSegmentation*>(fseg->GetHelper())->Slat();
+ }
+
+ // If fast segmentation V2
+/*
+ const AliMpFastSegmentationV2* fsegV2
+ = dynamic_cast<const AliMpFastSegmentationV2*>(kSegmentation);
+
+ if ( fsegV2 ) {
+ return
+ static_cast<const AliMpTriggerSegmentation*>(fsegV2->GetHelper())->Slat();
+ }
+*/
+
+ // Should not get to this line
+ AliErrorStream() << "Segemntation type not identified." << endl;
+ return 0;
+}
+
+//_____________________________________________________________________________
+const AliMpTrigger*
+AliMpSegmentation::GetTrigger(Int_t detElemId, AliMp::CathodType cath,
+ Bool_t warn) const
+{
+/// Return trigger for given detElemId and cath.
+/// If segmentation is not of trigger type, zero is returned
+/// and an Error is issued if warn is set true (default).
+
+ return GetTrigger(GetMpSegmentation(detElemId, cath, warn), warn);
+}
+
+//_____________________________________________________________________________
+const AliMpTrigger*
+AliMpSegmentation::GetTriggerByElectronics(Int_t detElemId, Int_t elCardID,
+ Bool_t warn) const
+{
+/// Return trigger for given detElemId and elCardID.
+/// If segmentation is not of trigger type, zero is returned
+/// and an Error is issued if warn is set true (default).
+
+ return GetTrigger(GetMpSegmentationByElectronics(detElemId, elCardID, warn), warn);
+}