]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONClusterReconstructor.cxx
New segmentation with switch between old and new (Ch. Finck)
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterReconstructor.cxx
index 9abd297251b895e2a4a35e772f03312a0a86fffe..9a6caf339eb0640bfe7faaaea4da4a72b29e8116 100644 (file)
@@ -44,18 +44,12 @@ ClassImp(AliMUONClusterReconstructor) // Class implementation in ROOT context
 
 //__________________________________________________________________________
 AliMUONClusterReconstructor::AliMUONClusterReconstructor(AliLoader* loader)
-  : TObject()
+  : TObject(),
+    fMUONData(0),
+    fPrintLevel(fgkDefaultPrintLevel),
+    fDebug(0)
 {
   // Standard Constructor
-  fDebug           = 0;
-  fNCh             = 0;
-  fNTrackingCh     = 0;
-  fChambers        = 0;
-  fMUONData        = 0;
-  fChambers = new TObjArray(AliMUONConstants::NCh());
-
-  fPrintLevel = fgkDefaultPrintLevel;
 
   // initialize loader's
   fLoader = loader;
@@ -63,23 +57,16 @@ AliMUONClusterReconstructor::AliMUONClusterReconstructor(AliLoader* loader)
   // initialize container
   fMUONData  = new AliMUONData(fLoader,"MUON","MUON");
 
-  // Loading AliRun master
-  AliRunLoader* runloader = fLoader->GetRunLoader();
-  if (runloader->GetAliRun() == 0x0) runloader->LoadgAlice();
-  gAlice = runloader->GetAliRun();
+  // reconstruction model
+  fRecModel = new AliMUONClusterFinderVS();
+  //fRecModel = new AliMUONClusterFinderAZ();
 
-  // getting MUON
-  fMUON = (AliMUON*) gAlice->GetDetector("MUON");
 }
 
 //__________________________________________________________________________
 AliMUONClusterReconstructor::AliMUONClusterReconstructor()
   : TObject(),
-    fNCh(0),
-    fNTrackingCh(0),
     fMUONData(0),
-    fMUON(0),
-    fChambers(0),
     fPrintLevel(fgkDefaultPrintLevel),
     fDebug(0),
     fLoader(0)
@@ -87,18 +74,6 @@ AliMUONClusterReconstructor::AliMUONClusterReconstructor()
   // Default Constructor
 }
 
-//____________________________________________________________________
-void AliMUONClusterReconstructor::SetReconstructionModel(Int_t id, AliMUONClusterFinderVS *reconst)
-{
-  // take infos chambers from AliMUON
-  AliMUONChamber* pCh = 0;
-  pCh = &(fMUON->Chamber(id));
-
-  fChambers->AddAt(pCh, id);
-
-  // Set ClusterFinder for chamber id
-  ((AliMUONChamber*) fChambers->At(id))->SetReconstructionModel(reconst);
-}
 //_______________________________________________________________________
 AliMUONClusterReconstructor::AliMUONClusterReconstructor (const AliMUONClusterReconstructor& rhs)
   : TObject(rhs)
@@ -124,10 +99,7 @@ AliMUONClusterReconstructor::operator=(const AliMUONClusterReconstructor& rhs)
 //__________________________________________________________________________
 AliMUONClusterReconstructor::~AliMUONClusterReconstructor(void)
 {
-  if (fChambers){
-    fChambers->Clear(); // Sets pointers to 0 sinche it is not the owner
-    delete fChambers;
-  } 
+
   if (fMUONData)
     delete fMUONData;
 
@@ -136,6 +108,21 @@ AliMUONClusterReconstructor::~AliMUONClusterReconstructor(void)
 //____________________________________________________________________
 void AliMUONClusterReconstructor::Digits2Clusters()
 {
+//
+//  Perform cluster finding
+//
+
+    AliMUON* pMUON = (AliMUON*) gAlice->GetModule("MUON");
+    if (pMUON->WhichSegmentation() == 1)
+      Digits2ClustersOld();
+    else
+      Digits2ClustersNew();
+
+}
+//____________________________________________________________________
+void AliMUONClusterReconstructor::Digits2ClustersOld()
+{
+
 //
 //  Perform cluster finding
 //
@@ -144,58 +131,156 @@ void AliMUONClusterReconstructor::Digits2Clusters()
     dig1 = new TClonesArray("AliMUONDigit",1000);
     dig2 = new TClonesArray("AliMUONDigit",1000);
     AliMUONDigit *digit;
-// Loop on chambers and on cathode planes
-//
-//    fMUONData->ResetRawClusters();        
+
+// Loop on chambers and on cathode planes     
     TClonesArray * muonDigits;
 
     for (Int_t ich = 0; ich < 10; ich++) {
-       AliMUONChamber* iChamber = (AliMUONChamber*) fChambers->At(ich);
-       AliMUONClusterFinderVS* rec = iChamber->ReconstructionModel();
-       //AliMUONClusterFinderAZ* rec = (AliMUONClusterFinderAZ*)iChamber->ReconstructionModel();
-
-       fMUONData->ResetDigits();
-       fMUONData->GetCathode(0);
-       //TClonesArray *
-       muonDigits = fMUONData->Digits(ich); 
-       ndig=muonDigits->GetEntriesFast();
-       AliDebug(1,Form("1 Found %d digits in %p chamber %d", ndig, (void*)muonDigits,ich));
-       TClonesArray &lhits1 = *dig1;
-       Int_t n = 0;
-       for (k = 0; k < ndig; k++) {
-           digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
-           if (rec->TestTrack(digit->Track(0)))
-             new(lhits1[n++]) AliMUONDigit(*digit);
+
+        fMUONData->ResetDigits();
+        fMUONData->GetCathode(0);
+        //TClonesArray *
+        muonDigits = fMUONData->Digits(ich); 
+        ndig=muonDigits->GetEntriesFast();
+        AliDebug(1,Form("1 Found %d digits in %p chamber %d", ndig, (void*)muonDigits,ich));
+        TClonesArray &lhits1 = *dig1;
+        Int_t n = 0;
+        for (k = 0; k < ndig; k++) {
+            digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
+           new(lhits1[n++]) AliMUONDigit(*digit);
+        }
+        fMUONData->ResetDigits();
+        fMUONData->GetCathode(1);
+        muonDigits =  fMUONData->Digits(ich);  
+        ndig=muonDigits->GetEntriesFast();
+        AliDebug(1,Form("2 Found %d digits in %p %d", ndig, (void*)muonDigits, ich));
+        TClonesArray &lhits2 = *dig2;
+        n=0;
+        
+        for (k=0; k<ndig; k++) {
+            digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
+           new(lhits2[n++]) AliMUONDigit(*digit);
+        }
+
+        if (fRecModel) {         
+            AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
+            fRecModel->FindRawClusters();
+        }
+        // copy into the container
+        TClonesArray* tmp = fRecModel->GetRawClusters();
+        for (Int_t id = 0; id < tmp->GetEntriesFast(); id++) {
+          AliMUONRawCluster* pClus = (AliMUONRawCluster*) tmp->At(id);
+          fMUONData->AddRawCluster(ich, *pClus);
+        }
+        dig1->Delete();
+        dig2->Delete();
+    } // for ich
+    delete dig1;
+    delete dig2;
+}
+//____________________________________________________________________
+void AliMUONClusterReconstructor::Digits2ClustersNew()
+{
+
+    TClonesArray *dig1, *dig2, *digAll;
+    Int_t ndig, k, idDE, idDE_prev;
+    dig1 = new TClonesArray("AliMUONDigit",1000);
+    dig2 = new TClonesArray("AliMUONDigit",1000);
+    digAll = new TClonesArray("AliMUONDigit",2000);
+
+    AliMUONDigit* digit;
+
+    TArrayI id(100); // contains the different IdDE
+    id.Reset();
+  
+// Loop on chambers and on cathode planes     
+    TClonesArray* muonDigits;
+    Int_t n2;
+    Int_t n1;
+    Int_t flag = 0;
+
+    for (Int_t ich = 0; ich < AliMUONConstants::NTrackingCh(); ich++) {
+      n1 = 0;
+      n2 = 0;
+      //cathode 0
+      fMUONData->ResetDigits();
+      fMUONData->GetCathode(0);
+      muonDigits = fMUONData->Digits(ich); 
+      ndig = muonDigits->GetEntriesFast();
+      TClonesArray &lDigit = *digAll;
+
+      idDE_prev = 0;
+
+      for (k = 0; k < ndig; k++) {
+
+       digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
+       new(lDigit[n1++]) AliMUONDigit(*digit);
+       idDE = digit->DetElemId();
+       if (idDE != idDE_prev)
+         id.AddAt(idDE,n2++);
+       idDE_prev = idDE;
+      }
+
+      //cathode 1
+      fMUONData->ResetDigits();
+      fMUONData->GetCathode(1);
+      muonDigits =  fMUONData->Digits(ich);  
+      ndig = muonDigits->GetEntriesFast();
+
+      for (k = 0; k < ndig; k++) {
+
+       digit = (AliMUONDigit*) muonDigits->UncheckedAt(k);
+       new(lDigit[n1++]) AliMUONDigit(*digit);
+       idDE = digit->DetElemId();
+       flag = 0;
+
+       for (Int_t n = 0; n < id.GetSize(); n++) {
+         if (id[n] == idDE) {
+           flag = 1;
+           break;
+         }
+         if (flag) continue;
+         id[id.GetSize()+1] = idDE;
        }
-       fMUONData->ResetDigits();
-       fMUONData->GetCathode(1);
-       muonDigits =  fMUONData->Digits(ich);  
-       ndig=muonDigits->GetEntriesFast();
-       AliDebug(1,Form("2 Found %d digits in %p %d", ndig, (void*)muonDigits, ich));
+      }
+
+      // loop over id DE
+      for (idDE = 0; idDE < id.GetSize(); idDE++) {
+
+       TClonesArray &lhits1 = *dig1;
        TClonesArray &lhits2 = *dig2;
-       n=0;
-       
-       for (k=0; k<ndig; k++) {
-           digit= (AliMUONDigit*) muonDigits->UncheckedAt(k);
-           if (rec->TestTrack(digit->Track(0)))
-             new(lhits2[n++]) AliMUONDigit(*digit);
+       n1 = n2 = 0;
+
+       for (k = 0; k < digAll->GetEntriesFast(); k++) {
+         digit = (AliMUONDigit*) digAll->UncheckedAt(k);
+         if (id[idDE] == digit->DetElemId())
+           if (digit->Cathode() == 1)
+             new(lhits1[n1++]) AliMUONDigit(*digit);
+           else 
+             new(lhits2[n2++]) AliMUONDigit(*digit);
+
        }
 
-       if (rec) {       
-           AliMUONClusterInput::Instance()->SetDigits(ich, dig1, dig2);
-           rec->FindRawClusters();
+       // cluster finder
+       if (fRecModel) {
+         AliMUONClusterInput::Instance()->SetDigits(ich, id[idDE], dig1, dig2);
+         fRecModel->FindRawClusters();
        }
        // copy into the container
-       TClonesArray* tmp = rec->GetRawClusters();
+       TClonesArray* tmp = fRecModel->GetRawClusters();
        for (Int_t id = 0; id < tmp->GetEntriesFast(); id++) {
          AliMUONRawCluster* pClus = (AliMUONRawCluster*) tmp->At(id);
          fMUONData->AddRawCluster(ich, *pClus);
        }
        dig1->Delete();
        dig2->Delete();
+       digAll->Delete();
+
+      }
     } // for ich
     delete dig1;
     delete dig2;
+    delete digAll;
 }
 
 //____________________________________________________________________
@@ -206,3 +291,19 @@ void AliMUONClusterReconstructor::Digits2Clusters(AliRawReader* /*rawReader*/)
 
    AliFatal("clusterization not implemented for raw data input");
 }
+//_______________________________________________________________________
+void AliMUONClusterReconstructor::Trigger2Trigger() 
+{
+// copy trigger from TreeD to TreeR
+
+  fMUONData->SetTreeAddress("GLT");
+  fMUONData->GetTriggerD();
+}
+//_______________________________________________________________________
+void AliMUONClusterReconstructor::Trigger2Trigger(AliRawReader* /*rawReader*/) 
+{
+// call the Trigger Algorithm from raw data and fill TreeR 
+
+   AliFatal("Trigger not implemented for raw data input");
+
+}