X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;ds=sidebyside;f=MUON%2FAliMUONClusterStoreV2.cxx;h=8d06032b5c76110ce7409827f48ce4b0afa64754;hb=6daac008f3b008af11c273f7cc660bec28fa1468;hp=39ac6b2b16450fc3acfe53c5688febd5a7aae63b;hpb=2060b21706c6613c64fa306ff1789fd4bbc8d54b;p=u%2Fmrichter%2FAliRoot.git diff --git a/MUON/AliMUONClusterStoreV2.cxx b/MUON/AliMUONClusterStoreV2.cxx index 39ac6b2b164..8d06032b5c7 100644 --- a/MUON/AliMUONClusterStoreV2.cxx +++ b/MUON/AliMUONClusterStoreV2.cxx @@ -44,6 +44,16 @@ ClassImp(AliMUONClusterStoreV2) /// \endcond +//_____________________________________________________________________________ +AliMUONClusterStoreV2::AliMUONClusterStoreV2(TRootIOCtor* /*dummy*/) +: AliMUONVClusterStore(), +fClusters(0x0), +fMap(0x0), +fMapped(kFALSE) +{ + /// Dummy IO ctor that does not allocate memory +} + //_____________________________________________________________________________ AliMUONClusterStoreV2::AliMUONClusterStoreV2() : AliMUONVClusterStore(), @@ -69,10 +79,13 @@ AliMUONClusterStoreV2::AliMUONClusterStoreV2(const AliMUONClusterStoreV2& store) AliMUONClusterStoreV2& AliMUONClusterStoreV2::operator=(const AliMUONClusterStoreV2& store) { /// Assignment operator - fClusters = new TClonesArray(*(store.fClusters)); - fMap = 0x0; - fMapped = kFALSE; - if (store.fMapped) ReMap(); + if ( this != &store ) + { + fClusters = new TClonesArray(*(store.fClusters)); + fMap = 0x0; + fMapped = kFALSE; + if (store.fMapped) ReMap(); + } return *this; } @@ -88,10 +101,17 @@ AliMUONClusterStoreV2::~AliMUONClusterStoreV2() void AliMUONClusterStoreV2::Clear(Option_t*) { /// Clear the internal cluster array AND the index - fClusters->Clear("C"); - if (fMap) { - fMap->Clear("C"); - fMapped = kFALSE; + if ( fClusters ) + { + fClusters->Clear("C"); + if (fMap) { + Int_t nChamber = AliMpConstants::NofTrackingChambers(); + for (Int_t chamber=0; chamber(fMap->UncheckedAt(chamber)); + map->Clear("C"); + } + fMapped = kFALSE; + } } } @@ -124,7 +144,7 @@ AliMUONVCluster* AliMUONClusterStoreV2::CreateCluster(Int_t chamberId, Int_t det } //_____________________________________________________________________________ -Bool_t AliMUONClusterStoreV2::Add(const AliMUONVCluster& vCluster) +AliMUONVCluster* AliMUONClusterStoreV2::Add(const AliMUONVCluster& vCluster) { /// Add a cluster to this store const AliMUONRawClusterV2* cluster = dynamic_cast(&vCluster); @@ -132,21 +152,30 @@ Bool_t AliMUONClusterStoreV2::Add(const AliMUONVCluster& vCluster) if (!cluster) { AliError(Form("Cluster is not of the expected type (%s vs AliMUONRawClusterV2)", vCluster.ClassName())); - return kFALSE; + return 0x0; + } + + // check chamberId + Int_t chamberId = cluster->GetChamberId(); + if (chamberId < 0 || chamberId >= AliMpConstants::NofTrackingChambers()) { + AliError(Form("ChamberId (%d) out of boundaries [0,%d[",chamberId,AliMpConstants::NofTrackingChambers())); + return 0x0; } // check that there is no cluster with the same Id - if (FindObject(cluster->GetUniqueID())) { - AliError("cluster store already contains a cluster with the same ID --> add() aborted"); - return kFALSE; + AliMUONVCluster *c = FindObject(cluster->GetUniqueID()); + if (c) { + AliError("cluster store already contains a cluster with the same ID --> add() exited:"); + c->Print("FULL"); + return 0x0; } // add new cluster - AliMUONVCluster *c = new((*fClusters)[fClusters->GetLast()+1]) AliMUONRawClusterV2(*cluster); + c = new((*fClusters)[fClusters->GetLast()+1]) AliMUONRawClusterV2(*cluster); if (c) UpdateMap(*c); - return kTRUE; + return c; } //_____________________________________________________________________________ @@ -154,10 +183,16 @@ AliMUONVCluster* AliMUONClusterStoreV2::Add(Int_t chamberId, Int_t detElemId, In { /// Add an empty cluster with an unique ID to this store + // check chamberId + if (chamberId < 0 || chamberId >= AliMpConstants::NofTrackingChambers()) { + AliError(Form("ChamberId (%d) out of boundaries [0,%d[",chamberId,AliMpConstants::NofTrackingChambers())); + return 0x0; + } + // check that there is no cluster with the same Id AliMUONVCluster *c = FindObject(AliMUONVCluster::BuildUniqueID(chamberId, detElemId, clusterIndex)); if (c) { - AliError("cluster store already contains a cluster with the same ID --> add() aborted:"); + AliError("cluster store already contains a cluster with the same ID --> add() exited:"); c->Print("FULL"); return 0x0; } @@ -176,10 +211,15 @@ AliMUONVCluster* AliMUONClusterStoreV2::Remove(AliMUONVCluster& cluster) /// Remove a cluster AliMUONVCluster* c = static_cast(fClusters->Remove(&cluster)); - if (c) { + if (c) + { fClusters->Compress(); fMapped = kFALSE; } + else + { + AliError("Could not remove cluster from array"); + } return c; } @@ -192,16 +232,24 @@ void AliMUONClusterStoreV2::ReMap() // Create (or clear) the TClonesArray of map Int_t nChamber = AliMpConstants::NofTrackingChambers(); - if (!fMap) fMap = new TClonesArray("AliMpExMap",nChamber); - else fMap->Clear("C"); - // Create one map per chamber - AliMpExMap *map; - for (Int_t chamber=0; chamberSetOwner(kFALSE); + if (!fMap) { + fMap = new TClonesArray("AliMpExMap",nChamber); + + // Create one map per chamber + AliMpExMap *map; + for (Int_t chamber=0; chamberSetOwner(kFALSE); + } } - + else { + for (Int_t chamber=0; chamber(fMap->UncheckedAt(chamber)); + map->Clear("C"); + } + } + // Fill the maps TIter next(fClusters); AliMUONVCluster* cluster;