]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONData.cxx
adapted for reading Digits or RecPoints (Philippe)
[u/mrichter/AliRoot.git] / MUON / AliMUONData.cxx
index 2f327ca973707ab95414c0371d2f683caebde29b..787ede70812a792b5d13455d81392a2eb08d171c 100644 (file)
 
 #include "AliLog.h"
 #include "AliMUONConstants.h"
+#include "AliMUONHit.h"
 #include "AliMUONDigit.h"
 #include "AliMUONGlobalTrigger.h"
-#include "AliMUONHit.h"
 #include "AliMUONLocalTrigger.h"
+#include "AliMUONRegionalTrigger.h"
 #include "AliMUONRawCluster.h"
 #include "AliMUONTrack.h"
 #include "AliMUONTriggerTrack.h"
@@ -38,7 +39,9 @@
 #include "TArrayI.h"
 #include "TString.h"
 
+/// \cond CLASSIMP
 ClassImp(AliMUONData)
+/// \endcond
  
 //_____________________________________________________________________________
   AliMUONData::AliMUONData():
@@ -50,6 +53,7 @@ ClassImp(AliMUONData)
     fRawClusters(0x0),
     fGlobalTrigger(0x0),
     fLocalTrigger(0x0),
+    fRegionalTrigger(0x0),
     fRecTracks(0x0),
     fRecTriggerTracks(0x0),
     fNhits(0),
@@ -58,6 +62,7 @@ ClassImp(AliMUONData)
     fNrawclusters(0x0),
     fNglobaltrigger(0),
     fNlocaltrigger(0),
+    fNregionaltrigger(0),
     fNrectracks(0),
     fNrectriggertracks(0),
     fSplitLevel(0),
@@ -75,6 +80,7 @@ AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title
     fRawClusters(0x0),
     fGlobalTrigger(0x0),
     fLocalTrigger(0x0),
+    fRegionalTrigger(0x0),
     fRecTracks(0x0),
     fRecTriggerTracks(0x0),
     fNhits(0),
@@ -83,26 +89,19 @@ AliMUONData::AliMUONData(AliLoader * loader, const char* name, const char* title
     fNrawclusters(0x0),
     fNglobaltrigger(0),
     fNlocaltrigger(0),
+    fNregionaltrigger(0),
     fNrectracks(0),
     fNrectriggertracks(0),
     fSplitLevel(0),
     fCurrentEvent(-1)
 {
-  // Constructor for AliMUONData
-}
-
-//_____________________________________________________________________________
-AliMUONData::AliMUONData(const AliMUONData& rMUONData):TNamed(rMUONData)
-{
-// Protected copy constructor
-
-  AliFatal("Not implemented.");
+/// Standard constructor
 }
 
 //_____________________________________________________________________________
 AliMUONData::~AliMUONData()
 {
-  // Destructor for AliMUONData
+/// Destructor for AliMUONData
   if (fHits) {
     fHits->Delete();
     delete fHits;
@@ -124,6 +123,10 @@ AliMUONData::~AliMUONData()
     fGlobalTrigger->Delete();
     delete fGlobalTrigger;
   }  
+  if (fRegionalTrigger){
+    fRegionalTrigger->Delete();
+    delete fRegionalTrigger;
+  }
   if (fLocalTrigger){
     fLocalTrigger->Delete();
     delete fLocalTrigger;
@@ -137,152 +140,93 @@ AliMUONData::~AliMUONData()
     delete fRecTriggerTracks;
   }
 }
-
-//_____________________________________________________________________________
-AliMUONData& AliMUONData::operator=(const AliMUONData& rhs)
+//____________________________________________________________________________
+void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t detElemId, 
+                        Int_t idpart, Float_t X, Float_t Y, Float_t Z, 
+                        Float_t tof, Float_t momentum, Float_t theta, 
+                        Float_t phi, Float_t length, Float_t destep,
+                        Float_t Xref,Float_t Yref,Float_t Zref)
 {
-// Protected assignement operator
-
-  if (this == &rhs) return *this;
-
-  AliFatal("Not implemented.");
-    
-  return *this;  
-}    
-          
+ // Add new hit to the hit list
 
-//_____________________________________________________________________________
-void AliMUONData::AddDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
-{
-  //
-  // Add a MUON digit to the list of Digits of the detection plane id
-  //
-  TClonesArray &ldigits = * Digits(id) ; 
-  new(ldigits[fNdigits[id]++]) AliMUONDigit(tracks,charges,digits);
+  TClonesArray &lhits = *fHits;
+  new(lhits[fNhits++]) AliMUONHit(fIshunt, track, detElemId, 
+                                 idpart, X, Y, Z, 
+                                 tof, momentum, theta, 
+                                 phi, length, destep,
+                                 Xref,Yref,Zref);
 }
 //_____________________________________________________________________________
 void AliMUONData::AddDigit(Int_t id, const AliMUONDigit& digit)
 {
-  //
-  // Add a MUON digit to the list of Digits of the detection plane id
-  //
+/// Add a MUON digit to the list of Digits of the detection plane id
+
   TClonesArray &ldigits = * Digits(id) ; 
   new(ldigits[fNdigits[id]++]) AliMUONDigit(digit);
 }
 //_____________________________________________________________________________
-void AliMUONData::AddSDigit(Int_t id, Int_t *tracks, Int_t *charges, Int_t *sdigits)
-{
-  //
-  // Add a MUON Sdigit to the list of SDigits of the detection plane id
-  //
-  TClonesArray &lSdigits = * SDigits(id) ; 
-  new(lSdigits[fNSdigits[id]++]) AliMUONDigit(tracks,charges,sdigits);
-}
-//_____________________________________________________________________________
 void AliMUONData::AddSDigit(Int_t id, const AliMUONDigit& Sdigit)
 {
-  //
-  // Add a MUON Sdigit to the list of SDigits of the detection plane id
-  //
+/// Add a MUON Sdigit to the list of SDigits of the detection plane id
+
   TClonesArray &lSdigits = * SDigits(id) ; 
   new(lSdigits[fNSdigits[id]++]) AliMUONDigit(Sdigit);
 }
-//_____________________________________________________________________________
-void AliMUONData::AddGlobalTrigger(Int_t *singlePlus, Int_t *singleMinus,
-                                  Int_t *singleUndef,
-                                  Int_t *pairUnlike, Int_t *pairLike)
-{
-  // add a MUON Global Trigger to the list (only one GlobalTrigger per event !)
-  TClonesArray &globalTrigger = *fGlobalTrigger;
-  new(globalTrigger[fNglobaltrigger++]) 
-    AliMUONGlobalTrigger(singlePlus, singleMinus,  singleUndef, pairUnlike, pairLike);
-}
+
 //_____________________________________________________________________________
 void AliMUONData::AddGlobalTrigger(const AliMUONGlobalTrigger& trigger )
 {
-  // add a MUON Global Trigger to the list (only one GlobalTrigger per event !);
+/// Add a MUON Global Trigger to the list (only one GlobalTrigger per event !);
+
   TClonesArray &globalTrigger = *fGlobalTrigger;
   new(globalTrigger[fNglobaltrigger++]) AliMUONGlobalTrigger(trigger);
 }
+
 //____________________________________________________________________________
-void AliMUONData::AddHit(Int_t fIshunt, Int_t track, Int_t iChamber, 
-                        Int_t idpart, Float_t X, Float_t Y, Float_t Z, 
-                        Float_t tof, Float_t momentum, Float_t theta, 
-                        Float_t phi, Float_t length, Float_t destep,
-                        Float_t Xref,Float_t Yref,Float_t Zref)
-{
- // Add new hit to the hit list
-  TClonesArray &lhits = *fHits;
-  new(lhits[fNhits++]) AliMUONHit(fIshunt, track, iChamber, 
-                                 idpart, X, Y, Z, 
-                                 tof, momentum, theta, 
-                                 phi, length, destep,
-                                 Xref,Yref,Zref);
-}
-//____________________________________________________________________________
-void AliMUONData::AddHit2(Int_t fIshunt, Int_t track, Int_t detElemId, 
-                        Int_t idpart, Float_t X, Float_t Y, Float_t Z, 
-                        Float_t tof, Float_t momentum, Float_t theta, 
-                        Float_t phi, Float_t length, Float_t destep,
-                        Float_t Xref,Float_t Yref,Float_t Zref)
-{
- // Add new hit to the hit list
-  TClonesArray &lhits = *fHits;
-  new(lhits[fNhits++]) AliMUONHit(fIshunt, track, detElemId, 
-                                 idpart, X, Y, Z, 
-                                 tof, momentum, theta, 
-                                 phi, length, destep,
-                                 Xref,Yref,Zref, true);
-}
-//____________________________________________________________________________
-void AliMUONData::AddLocalTrigger(const Int_t *localtr, const TArrayI& digits)
+void AliMUONData::AddRegionalTrigger(const  AliMUONRegionalTrigger& trigger)
 {
-  // add a MUON Local Trigger to the list
-  TClonesArray &localTrigger = *fLocalTrigger;
-  new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(localtr, digits);
+/// add a MUON regional Trigger to the list
+  TClonesArray &regionalTrigger = *fRegionalTrigger;
+  new(regionalTrigger[fNregionaltrigger++]) AliMUONRegionalTrigger(trigger);
 }
 //____________________________________________________________________________
 void AliMUONData::AddLocalTrigger(const  AliMUONLocalTrigger& trigger)
 {
-  // add a MUON Local Trigger to the list
+/// add a MUON Local Trigger to the list
+
   TClonesArray &localTrigger = *fLocalTrigger;
   new(localTrigger[fNlocaltrigger++]) AliMUONLocalTrigger(trigger);
 }
+
 //_____________________________________________________________________________
 void AliMUONData::AddRawCluster(Int_t id, const AliMUONRawCluster& c)
 {
-  //
-  // Add a MUON rawcluster to the list in the detection plane id
-  //
+/// Add a MUON rawcluster to the list in the detection plane id
+
   TClonesArray &lrawcl = *((TClonesArray*) fRawClusters->At(id));
   new(lrawcl[fNrawclusters[id]++]) AliMUONRawCluster(c);
 }
 //_____________________________________________________________________________
 void AliMUONData::AddRecTrack(const AliMUONTrack& track)
 {
-  //
-  // Add a MUON rectrack
-  //
+/// Add a MUON rectrack
+
   TClonesArray &lrectracks = *fRecTracks;
   new(lrectracks[fNrectracks++]) AliMUONTrack(track);
-  //  printf("TTTTTT %d ,\n",((AliMUONTrack*)fRecTracks->At(fNrectracks-1))->GetNTrackHits());
 }
 //_____________________________________________________________________________
 void AliMUONData::AddRecTriggerTrack(const AliMUONTriggerTrack& triggertrack)
 {
-  //
-  // Add a MUON triggerrectrack
-  //
+/// Add a MUON triggerrectrack
+
   TClonesArray &lrectriggertracks = *fRecTriggerTracks;  
   new(lrectriggertracks[fNrectriggertracks++]) AliMUONTriggerTrack(triggertrack);
-  //  printf("TTTTTT %d ,\n",((AliMUONTrack*)fRecTracks->At(fNrectracks-1))->GetNTrackHits());
 }
-
 //____________________________________________________________________________
 TClonesArray*  AliMUONData::Digits(Int_t DetectionPlane) const
 {
-  //Getting List of Digits
+/// Getting List of Digits
+
   if (fDigits)
     return ( (TClonesArray*) fDigits->At(DetectionPlane) );
   else
@@ -291,7 +235,8 @@ TClonesArray*  AliMUONData::Digits(Int_t DetectionPlane) const
 //____________________________________________________________________________
 TClonesArray*  AliMUONData::SDigits(Int_t DetectionPlane) const
 {
-  //Getting List of SDigits
+/// Getting List of SDigits
+
   if (fSDigits)
     return ( (TClonesArray*) fSDigits->At(DetectionPlane) );
   else
@@ -300,7 +245,8 @@ TClonesArray*  AliMUONData::SDigits(Int_t DetectionPlane) const
 //____________________________________________________________________________
 Bool_t   AliMUONData::IsRawClusterBranchesInTree()
 {
-  // Checking if there are RawCluster Branches In TreeR
+/// Checking if there are RawCluster Branches In TreeR
+
   if (TreeR()==0x0) {
     AliError("No treeR in memory");
     return kFALSE;
@@ -317,7 +263,8 @@ Bool_t   AliMUONData::IsRawClusterBranchesInTree()
 //____________________________________________________________________________
 Bool_t   AliMUONData::IsDigitsBranchesInTree()
 {
-  // Checking if there are RawCluster Branches In TreeR
+/// Checking if there are RawCluster Branches In TreeR
+
   if (TreeD()==0x0) {
     AliError("No treeD in memory");
     return kFALSE;
@@ -334,7 +281,7 @@ Bool_t   AliMUONData::IsDigitsBranchesInTree()
 //____________________________________________________________________________
 Bool_t   AliMUONData::IsTriggerBranchesInTree()
 {
-  // Checking if there are Trigger Branches In TreeR
+/// Checking if there are Trigger Branches In TreeR
  if (TreeR()==0x0) {
     AliError("No treeR in memory");
     return kFALSE;
@@ -351,7 +298,7 @@ Bool_t   AliMUONData::IsTriggerBranchesInTree()
 //____________________________________________________________________________
 Bool_t   AliMUONData::IsTriggerBranchesInTreeD()
 {
-  // Checking if there are Trigger Branches In TreeR
+/// Checking if there are Trigger Branches In TreeR
  if (TreeD()==0x0) {
     AliError("No treeD in memory");
     return kFALSE;
@@ -369,7 +316,7 @@ Bool_t   AliMUONData::IsTriggerBranchesInTreeD()
 //____________________________________________________________________________
 Bool_t   AliMUONData::IsTrackBranchesInTree()
 {
-  // Checking if there are Track Branches In TreeT
+/// Checking if there are Track Branches In TreeT
   if (TreeT()==0x0) {
     AliError("No treeT in memory");
     return kFALSE;
@@ -386,7 +333,7 @@ Bool_t   AliMUONData::IsTrackBranchesInTree()
 //____________________________________________________________________________
 Bool_t   AliMUONData::IsTriggerTrackBranchesInTree()
 {
-  // Checking if there are TriggerTrack Branches In TreeT
+/// Checking if there are TriggerTrack Branches In TreeT
   if (TreeT()==0x0) {
     AliError("No treeT in memory");
     return kFALSE;
@@ -403,7 +350,7 @@ Bool_t   AliMUONData::IsTriggerTrackBranchesInTree()
 //____________________________________________________________________________
 void AliMUONData::Fill(Option_t* option)
 {
-  // Method to fill the trees
+/// Method to fill the trees
   const char *cH   = strstr(option,"H");
   const char *cD   = strstr(option,"D");   // Digits branches in TreeD
   const char *cS   = strstr(option,"S");   // SDigits branches in TreeS
@@ -457,9 +404,13 @@ void AliMUONData::Fill(Option_t* option)
         sprintf(branchname,"%sLocalTrigger",GetName());
         branch = TreeD()->GetBranch(branchname); 
         branch->Fill();
+       sprintf(branchname,"%sRegionalTrigger",GetName());
+        branch = TreeD()->GetBranch(branchname);
+        branch->Fill();
         sprintf(branchname,"%sGlobalTrigger",GetName());
         branch = TreeD()->GetBranch(branchname);
         branch->Fill();
+
       } 
       else
       {
@@ -508,6 +459,9 @@ void AliMUONData::Fill(Option_t* option)
         sprintf(branchname,"%sLocalTrigger",GetName());
         branch = TreeR()->GetBranch(branchname); 
         branch->Fill();
+       sprintf(branchname,"%sRegionalTrigger",GetName());
+        branch = TreeR()->GetBranch(branchname); 
+        branch->Fill();
         sprintf(branchname,"%sGlobalTrigger",GetName());
         branch = TreeR()->GetBranch(branchname);
         branch->Fill();
@@ -560,19 +514,20 @@ void AliMUONData::Fill(Option_t* option)
 //_____________________________________________________________________________
 void AliMUONData::MakeBranch(Option_t* option)
 {
-  //
-  // Create Tree branches for the MUON.
-  //
+/// Create Tree branches for the MUON.
+
   const Int_t kBufferSize = 4000;
   char branchname[30];
   
-  
+  //Setting Data Container
+  SetDataContainer(option);  
+
   const char *cH   = strstr(option,"H");
   const char *cD   = strstr(option,"D");   // Digits branches in TreeD
   const char *cS   = strstr(option,"S");   // Digits branches in TreeS
   const char *cRC  = strstr(option,"RC");  // RawCluster branches in TreeR
   const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger branches in TreeD
-  const char *cTC = strstr(option,"TC");   // global and local Trigger branches Copy in TreeR
+  const char *cTC  = strstr(option,"TC");   // global and local Trigger branches Copy in TreeR
   const char *cRT  = strstr(option,"RT");  // Reconstructed Track in TreeT
   const char *cRL  = strstr(option,"RL");  // Reconstructed Trigger Track in TreeT
                                            //const char *cRP  = strstr(option,"RP");  // Reconstructed Particle in TreeP
@@ -581,14 +536,6 @@ void AliMUONData::MakeBranch(Option_t* option)
   
   // Creating Branches for Hits
   if (TreeH() && cH) {
-    
-    if (fHits == 0x0)  {
-      fHits = new TClonesArray("AliMUONHit",1000);
-      //       if (gAlice->GetMCApp())
-      //         gAlice->GetMCApp()->AddHitList (fHits);
-    }
-    
-    fNhits = 0;
     sprintf(branchname,"%sHits",GetName());  
     branch = TreeH()->GetBranch(branchname);
     if (branch) {  
@@ -609,24 +556,6 @@ void AliMUONData::MakeBranch(Option_t* option)
   if ( treeD && cD ) 
   {
     // one branch for digits per chamber
-    if (fDigits  == 0x0) 
-    {
-      fDigits  = new TObjArray(AliMUONConstants::NCh());
-      for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) 
-      {
-        TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
-        tca->SetOwner();
-        fDigits->AddAt(tca,iDetectionPlane); 
-      }
-    }
-    if (fNdigits == 0x0) 
-    {
-      fNdigits = new Int_t[AliMUONConstants::NCh()];
-      for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) 
-      {
-        fNdigits[iDetectionPlane]=0;
-      }
-    }
     for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) 
     {
       sprintf(branchname,"%sDigits%d",GetName(),iDetectionPlane+1);
@@ -647,12 +576,6 @@ void AliMUONData::MakeBranch(Option_t* option)
     // one branch for global trigger
     //
     sprintf(branchname,"%sGlobalTrigger",GetName());
-    
-    if (fGlobalTrigger == 0x0) 
-    {
-      fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger"); 
-      fNglobaltrigger = 0;
-    }
     branch = treeD->GetBranch(branchname);
     if (branch) 
     {  
@@ -661,17 +584,25 @@ void AliMUONData::MakeBranch(Option_t* option)
     }
     branch = treeD->Branch(branchname, &fGlobalTrigger, kBufferSize);
 
+  //
+    // one branch for regional trigger
+    //  
+    sprintf(branchname,"%sRegionalTrigger",GetName());
+    branch = 0x0;
+    branch = treeD->GetBranch(branchname);
+    if (branch) 
+    {  
+      AliInfo(Form("Branch RegionalTrigger is already in treeD."));
+      return;
+    }
+    branch = treeD->Branch(branchname, &fRegionalTrigger, kBufferSize);
+  
+
     //
     // one branch for local trigger
     //  
     sprintf(branchname,"%sLocalTrigger",GetName());
     branch = 0x0;
-    
-    if (fLocalTrigger == 0x0) 
-    {
-      fLocalTrigger  = new TClonesArray("AliMUONLocalTrigger",234);
-      fNlocaltrigger = 0;
-    }
     branch = treeD->GetBranch(branchname);
     if (branch) 
     {  
@@ -684,20 +615,6 @@ void AliMUONData::MakeBranch(Option_t* option)
   //Creating Branches for SDigits
   if (TreeS() && cS ) {
     // one branch for Sdigits per chamber
-    if (fSDigits  == 0x0) {
-      fSDigits  = new TObjArray(AliMUONConstants::NCh());
-      for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
-        TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
-        tca->SetOwner();
-        fSDigits->AddAt(tca,iDetectionPlane); 
-      }
-    }
-    if (fNSdigits == 0x0) {
-      fNSdigits = new Int_t[AliMUONConstants::NCh()];
-      for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
-        fNSdigits[iDetectionPlane]=0;
-      }
-    }
     for (Int_t iDetectionPlane=0; iDetectionPlane<AliMUONConstants::NCh() ;iDetectionPlane++) {
       sprintf(branchname,"%sSDigits%d",GetName(),iDetectionPlane+1);
       branch = 0x0;
@@ -715,23 +632,7 @@ void AliMUONData::MakeBranch(Option_t* option)
   if (TreeR() && cRC ) {
     //  one branch for raw clusters per tracking detection plane
     //        
-    Int_t i;
-    if (fRawClusters == 0x0) {
-      fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
-      for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
-        TClonesArray * tca = new TClonesArray("AliMUONRawCluster",1000);
-        tca->SetOwner();
-        fRawClusters->AddAt(tca,i); 
-      }
-    }
-    
-    if (fNrawclusters == 0x0) {
-      fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
-      for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
-        fNrawclusters[i]=0;
-      }
-    }
-    
+    Int_t i; 
     for (i=0; i<AliMUONConstants::NTrackingCh() ;i++) {
       sprintf(branchname,"%sRawClusters%d",GetName(),i+1);     
       branch = 0x0;
@@ -751,11 +652,6 @@ void AliMUONData::MakeBranch(Option_t* option)
     //
     sprintf(branchname,"%sGlobalTrigger",GetName());
     branch = 0x0;
-    
-    if (fGlobalTrigger == 0x0) {
-      fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger"); 
-      fNglobaltrigger = 0;
-    }
     branch = TreeR()->GetBranch(branchname);
     if (branch) {  
       AliInfo(Form("Branch GlobalTrigger is already in treeR."));
@@ -763,17 +659,24 @@ void AliMUONData::MakeBranch(Option_t* option)
     }
     branch = TreeR()->Branch(branchname, &fGlobalTrigger, kBufferSize);
     //Info("MakeBranch", "Making Branch %s for Global Trigger\n",branchname);
-    
+
+  //
+    // one branch for regional trigger
+    //  
+    sprintf(branchname,"%sRegionalTrigger",GetName());
+    branch = 0x0;
+    branch = TreeR()->GetBranch(branchname);
+    if (branch) {  
+      AliInfo(Form("Branch RegionalTrigger is already in treeR."));
+      return;
+    }
+    branch = TreeR()->Branch(branchname, &fRegionalTrigger, kBufferSize);
+     
     //
     // one branch for local trigger
     //  
     sprintf(branchname,"%sLocalTrigger",GetName());
     branch = 0x0;
-    
-    if (fLocalTrigger == 0x0) {
-      fLocalTrigger  = new TClonesArray("AliMUONLocalTrigger",234);
-      fNlocaltrigger = 0;
-    }
     branch = TreeR()->GetBranch(branchname);
     if (branch) {  
       AliInfo(Form("Branch LocalTrigger is already in treeR."));
@@ -784,8 +687,6 @@ void AliMUONData::MakeBranch(Option_t* option)
   }
   
   if (TreeT() && cRT ) {
-    if (fRecTracks == 0x0)  fRecTracks = new TClonesArray("AliMUONTrack",100);
-    fNrectracks = 0;
     sprintf(branchname,"%sTrack",GetName());  
     branch = TreeT()->GetBranch(branchname);
     if (branch) {  
@@ -797,8 +698,6 @@ void AliMUONData::MakeBranch(Option_t* option)
   }  
   // trigger tracks
   if (TreeT() && cRL ) {
-    if (fRecTriggerTracks == 0x0)  fRecTriggerTracks = new TClonesArray("AliMUONTriggerTrack",100);
-    fNrectriggertracks = 0;
     sprintf(branchname,"%sTriggerTrack",GetName());  
     branch = TreeT()->GetBranch(branchname);
     if (branch) {  
@@ -812,7 +711,8 @@ void AliMUONData::MakeBranch(Option_t* option)
 //____________________________________________________________________________
 TClonesArray*  AliMUONData::RawClusters(Int_t DetectionPlane)
 {
-  // Getting Raw Clusters
+/// Getting Raw Clusters
+
   if (fRawClusters) 
     return ( (TClonesArray*) fRawClusters->At(DetectionPlane) );
   else
@@ -823,19 +723,45 @@ TClonesArray*  AliMUONData::RawClusters(Int_t DetectionPlane)
 TClonesArray*  
 AliMUONData::LocalTrigger() const
 {
+/// Getting local trigger
+
   return fLocalTrigger;
 }
 
+//____________________________________________________________________________
+TClonesArray*  
+AliMUONData::RegionalTrigger() const
+{
+/// Getting regional trigger
+
+  return fRegionalTrigger;
+}
+
+//____________________________________________________________________________
+Int_t          
+AliMUONData::GetNtracks() const      
+{
+/// Get number of entries in hits three
+
+  Int_t ntrk = 0;
+  if (fLoader && fLoader->TreeH())
+    ntrk = (Int_t) fLoader->TreeH()->GetEntries();
+  return ntrk;
+}
+
 //____________________________________________________________________________
 void
 AliMUONData::GetDigits() const 
 {
-  // Load the digits from TreeD for the current event.
+/// Load the digits from TreeD for the current event.
+
   Int_t event = fLoader->GetRunLoader()->GetEventNumber();
   if ( fCurrentEvent != event )
   {
-    fLoader->TreeD()->GetEvent(0);
-    fCurrentEvent = event;
+    if (fLoader->TreeD()) {
+      fLoader->TreeD()->GetEvent(0);
+      fCurrentEvent = event;
+    }
   }
 }
 
@@ -843,16 +769,16 @@ AliMUONData::GetDigits() const
 TClonesArray*  
 AliMUONData::GlobalTrigger() const
 {
-  // Return the global trigger 
+/// Return the global trigger 
+
   return fGlobalTrigger;
 }
 
 //____________________________________________________________________________
 void AliMUONData::ResetDigits()
 {
-    //
-    // Reset number of digits and the digits array for this detector
-    //
+/// Reset number of digits and the digits array for this detector
+
     if (fDigits == 0x0) return;
     for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
       if ((*fDigits)[i])    ((TClonesArray*)fDigits->At(i))->Clear("C");
@@ -862,9 +788,8 @@ void AliMUONData::ResetDigits()
 //____________________________________________________________________________
 void AliMUONData::ResetSDigits()
 {
-    //
-    // Reset number of Sdigits and the Sdigits array for this detector
-    //
+/// Reset number of Sdigits and the Sdigits array for this detector
+
     if (fSDigits == 0x0) return;
     for ( int i=0;i<AliMUONConstants::NCh();i++ ) {
       if ((*fSDigits)[i])    ((TClonesArray*)fSDigits->At(i))->Clear();
@@ -874,15 +799,16 @@ void AliMUONData::ResetSDigits()
 //______________________________________________________________________________
 void AliMUONData::ResetHits()
 {
-  // Reset number of clusters and the cluster array for this detector
+/// Reset number of clusters and the cluster array for this detector
+
   fNhits   = 0;
   if (fHits) fHits->Clear();
 }
 //_______________________________________________________________________________
 void AliMUONData::ResetRawClusters()
 {
-    // Reset number of raw clusters and the raw clust array for this detector
-    //
+/// Reset number of raw clusters and the raw clust array for this detector
+
   for ( int i=0;i<AliMUONConstants::NTrackingCh();i++ ) {
     if ((*fRawClusters)[i])    ((TClonesArray*)fRawClusters->At(i))->Clear();
     if (fNrawclusters)  fNrawclusters[i]=0;
@@ -891,30 +817,162 @@ void AliMUONData::ResetRawClusters()
 //_______________________________________________________________________________
 void AliMUONData::ResetTrigger()
 {
-  //  Reset Local and Global Trigger 
+/// Reset Local and Global Trigger 
+
   fNglobaltrigger = 0;
   if (fGlobalTrigger) fGlobalTrigger->Clear();
+  fNregionaltrigger = 0;
+  if (fRegionalTrigger) fRegionalTrigger->Clear();
   fNlocaltrigger = 0;
   if (fLocalTrigger) fLocalTrigger->Clear();
+
 }
 //____________________________________________________________________________
 void AliMUONData::ResetRecTracks()
 {
-  // Reset tracks information
+/// Reset tracks information
+
   fNrectracks = 0;
   if (fRecTracks) fRecTracks->Delete(); // necessary to delete in case of memory allocation
 }
 //____________________________________________________________________________
 void AliMUONData::ResetRecTriggerTracks()
 {
-  // Reset tracks information
+/// Reset tracks information
+
   fNrectriggertracks = 0;
   if (fRecTriggerTracks) fRecTriggerTracks->Delete(); // necessary to delete in case of memory allocation
 }
-//_____________________________________________________________________________
+//____________________________________________________________________________
+void AliMUONData::SetDataContainer(Option_t* option)
+{
+/// Setting data containers of muon data
+  const char *cH   = strstr(option,"H");
+  const char *cD   = strstr(option,"D");   // Digits
+  const char *cS   = strstr(option,"S");   // SDigits
+  const char *cRC  = strstr(option,"RC");  // RawCluster
+  const char *cGLT = strstr(option,"GLT"); // Global and Local Trigger
+  const char *cTC = strstr(option,"TC");   // global and local Trigger 
+  const char *cRT  = strstr(option,"RT");  // Reconstructed Tracks
+  const char *cRL  = strstr(option,"RL");  // Reconstructed Trigger Tracks
+                                           //const char *cRP  = strstr(option,"RP");  // Reconstructed Particles  
+  AliDebug(1,Form("option=%s",option));
+  //
+  // Clones array for hits
+  if ( cH ) {
+    if (fHits == 0x0) {
+      fHits     = new TClonesArray("AliMUONHit",1000);
+    }
+    ResetHits();
+  }
+  
+  //
+  // ObjArray of ClonesArrays for Digits
+  if ( cD ) {      
+    if (fDigits == 0x0 ) {
+      fDigits = new TObjArray(AliMUONConstants::NCh());
+      fNdigits= new Int_t[AliMUONConstants::NCh()];
+      for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
+       TClonesArray * tca = new TClonesArray("AliMUONDigit",10000);
+       tca->SetOwner();
+        fDigits->AddAt(tca,i); 
+        fNdigits[i]=0;
+      }
+    } 
+    else {
+      AliDebug(1,Form("fDigits already there = %p",fSDigits));
+    }
+    ResetDigits();
+  }
+
+  //
+  // ClonesArrays for Trigger
+  if ( cGLT ) { 
+    if (fLocalTrigger == 0x0) {
+      fLocalTrigger  = new TClonesArray("AliMUONLocalTrigger",234);
+    }
+    if (fRegionalTrigger == 0x0) {
+      fRegionalTrigger  = new TClonesArray("AliMUONRegionalTrigger",16);
+    }
+    if (fGlobalTrigger== 0x0) {
+      fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1); 
+    }
+    ResetTrigger();
+  }
+    
+  //
+  // Container for Sdigits
+  if (cS) {
+    if (fSDigits == 0x0) { 
+      AliDebug(1,"Creating fSDigits TObjArray");
+      fSDigits = new TObjArray(AliMUONConstants::NCh());
+      fNSdigits= new Int_t[AliMUONConstants::NCh()];
+      for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
+       TClonesArray* a = new TClonesArray("AliMUONDigit",10000);
+       a->SetOwner();
+       fSDigits->AddAt(a,i);
+       AliDebug(1,Form("fSDigits[%d]=%p",i,a));
+        fNSdigits[i]=0;
+      }
+    }
+    else {
+      AliDebug(1,Form("fSDigits already there = %p",fSDigits));
+    }
+    ResetSDigits();
+  }
+  
+  //
+  // Containers for rawclusters, globaltrigger and local trigger tree
+  if (cRC ) {
+    if (fRawClusters == 0x0) {
+      fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
+      fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
+      for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
+       TClonesArray* tca = new TClonesArray("AliMUONRawCluster",10000);
+       tca->SetOwner();
+        fRawClusters->AddAt(tca,i); 
+        fNrawclusters[i]=0;
+      }
+    }
+    ResetRawClusters();
+  }
+  if (cTC ) {
+    if (fLocalTrigger == 0x0) {
+      fLocalTrigger  = new TClonesArray("AliMUONLocalTrigger",234);
+    }
+   if (fRegionalTrigger == 0x0) {
+      fRegionalTrigger  = new TClonesArray("AliMUONRegionalTrigger",16);
+    }
+    if (fGlobalTrigger== 0x0) {
+      fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1); 
+    }
+    //    ResetTrigger(); This is not necessary here since trigger info ins copied from digits info on flight to RecPoint output
+  }
+
+  //
+  // Containers for rectracks and rectrigger tracks
+  if ( cRT ) {
+    if (fRecTracks == 0x0)  {
+      fRecTracks  = new TClonesArray("AliMUONTrack",100);
+    }
+    ResetRecTracks();
+  }
+  if (cRL) {
+    if (fRecTriggerTracks == 0x0 && cRL)  {
+      fRecTriggerTracks  = new TClonesArray("AliMUONTriggerTrack",100);
+    }
+    ResetRecTriggerTracks();
+  }  
+}
+
+//____________________________________________________________________________
 void AliMUONData::SetTreeAddress(Option_t* option)
 {
-  //Setting Addresses to the events trees
+  // Setting Data containers
+  SetDataContainer(option);
+
+/// Setting Addresses to the events trees
+
   const char *cH   = strstr(option,"H");
   const char *cD   = strstr(option,"D");   // Digits branches in TreeD
   const char *cS   = strstr(option,"S");   // SDigits branches in TreeS
@@ -932,14 +990,6 @@ void AliMUONData::SetTreeAddress(Option_t* option)
   AliDebug(1,Form("option=%s",option));
   //
   // Branch address for hit tree
-  if ( TreeH() && cH ) {
-    if (fHits == 0x0) {
-      fHits     = new TClonesArray("AliMUONHit",1000);
-      //       if (gAlice->GetMCApp())
-      //  gAlice->GetMCApp()->AddHitList (fHits);  Moved to AliMUON
-    }
-    fNhits =0;
-  } 
   if (TreeH() && fHits && cH) {
     sprintf(branchname,"%sHits",GetName());  
     branch = TreeH()->GetBranch(branchname);
@@ -948,29 +998,12 @@ void AliMUONData::SetTreeAddress(Option_t* option)
       branch->SetAddress(&fHits);
     }
     else { //can be invoked before branch creation
-      AliWarning(Form("(%s) Failed for Hits. Can not find branch in tree.",GetName()));
+      //AliWarning(Form("(%s) Failed for Hits. Can not find branch in tree.",GetName()));
     }
   }
   
   //
   // Branch address for digit tree
-  if ( TreeD() ) {      
-    if (fDigits == 0x0 && cD) {
-      fDigits = new TObjArray(AliMUONConstants::NCh());
-      fNdigits= new Int_t[AliMUONConstants::NCh()];
-      for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) {
-        fDigits->AddAt(new TClonesArray("AliMUONDigit",10000),i); 
-        fNdigits[i]=0;
-      }
-    }
-    if (fLocalTrigger == 0x0 && cGLT) {
-      fLocalTrigger  = new TClonesArray("AliMUONLocalTrigger",234);
-    }
-    if (fGlobalTrigger== 0x0 && cGLT) {
-      fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1); 
-    }
-  }
-  
   if (TreeD() && fDigits && cD) {
     for (int i=0; i<AliMUONConstants::NCh(); i++) {
       sprintf(branchname,"%sDigits%d",GetName(),i+1);
@@ -990,6 +1023,12 @@ void AliMUONData::SetTreeAddress(Option_t* option)
     if (branch) branch->SetAddress(&fLocalTrigger);
     else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeD.",GetName()));
   }
+ if ( TreeD()  && fRegionalTrigger && cGLT) {
+    sprintf(branchname,"%sRegionalTrigger",GetName());
+    branch = TreeD()->GetBranch(branchname);
+    if (branch) branch->SetAddress(&fRegionalTrigger);
+    else AliWarning(Form("(%s) Failed for RegionalTrigger. Can not find branch in treeD.",GetName()));
+  }
   if ( TreeD() && fGlobalTrigger && cGLT) {
     sprintf(branchname,"%sGlobalTrigger",GetName());
     branch = TreeD()->GetBranch(branchname);
@@ -999,27 +1038,6 @@ void AliMUONData::SetTreeAddress(Option_t* option)
   
   //
   // Branch address for Sdigit tree
-  if ( TreeS() && cS) 
-  {
-    if (fSDigits == 0x0) 
-    { 
-      AliDebug(1,"Creating fSDigits TObjArray");
-      fSDigits = new TObjArray(AliMUONConstants::NCh());
-      fNSdigits= new Int_t[AliMUONConstants::NCh()];
-      for (Int_t i=0; i<AliMUONConstants::NCh() ;i++) 
-      {
-        TClonesArray* a = new TClonesArray("AliMUONDigit",10000);
-        fSDigits->AddAt(a,i);
-        AliDebug(1,Form("fSDigits[%d]=%p",i,a));
-        fNSdigits[i]=0;
-      }
-    }
-    else
-    {
-      AliDebug(1,Form("fSDigits already there = %p",fSDigits));
-    }
-  }
-  
   if (TreeS() && fSDigits && cS) {
     AliDebug(1,"Setting branch addresses");
     for (int i=0; i<AliMUONConstants::NCh(); i++) {
@@ -1037,23 +1055,6 @@ void AliMUONData::SetTreeAddress(Option_t* option)
   
   //
   // Branch address for rawclusters, globaltrigger and local trigger tree
-  if (TreeR() ) {
-    if (fRawClusters == 0x0 && cRC) {
-      fRawClusters = new TObjArray(AliMUONConstants::NTrackingCh());
-      fNrawclusters= new Int_t[AliMUONConstants::NTrackingCh()];
-      for (Int_t i=0; i<AliMUONConstants::NTrackingCh();i++) {
-        fRawClusters->AddAt(new TClonesArray("AliMUONRawCluster",10000),i); 
-        fNrawclusters[i]=0;
-      }
-    }
-    if (fLocalTrigger == 0x0 && cTC) {
-      fLocalTrigger  = new TClonesArray("AliMUONLocalTrigger",234);
-    }
-    if (fGlobalTrigger== 0x0 && cTC) {
-      fGlobalTrigger = new TClonesArray("AliMUONGlobalTrigger",1); 
-    }
-    
-  }
   if ( TreeR()  && fRawClusters && cRC && !strstr(cRC,"RCC")) {
     for (int i=0; i<AliMUONConstants::NTrackingCh(); i++) {
       sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
@@ -1070,47 +1071,41 @@ void AliMUONData::SetTreeAddress(Option_t* option)
     if (branch) branch->SetAddress(&fLocalTrigger);
     else AliWarning(Form("(%s) Failed for LocalTrigger. Can not find branch in treeR.",GetName()));
   }
+  if ( TreeR()  && fRegionalTrigger && cTC) {
+    sprintf(branchname,"%sRegionalTrigger",GetName());
+    branch = TreeR()->GetBranch(branchname);
+    if (branch) branch->SetAddress(&fRegionalTrigger);
+    else AliWarning(Form("(%s) Failed for RegionalTrigger. Can not find branch in treeR.",GetName()));
+  }
   if ( TreeR() && fGlobalTrigger && cTC) {
     sprintf(branchname,"%sGlobalTrigger",GetName());
     branch = TreeR()->GetBranch(branchname);
     if (branch) branch->SetAddress(&fGlobalTrigger);
     else AliWarning(Form("(%s) Failed for GlobalTrigger. Can not find branch in treeR.",GetName()));
   }
-  
-  if ( TreeT() ) {
-    if (fRecTracks == 0x0 && cRT)  {
-      fRecTracks  = new TClonesArray("AliMUONTrack",100);
-    }
-    
-  }
+
+  // Rec Trakcs
   if ( TreeT() && fRecTracks && cRT ) {
     sprintf(branchname,"%sTrack",GetName());  
     branch = TreeT()->GetBranch(branchname);
     if (branch) branch->SetAddress(&fRecTracks);
     else AliWarning(Form("(%s) Failed for Tracks. Can not find branch in tree.",GetName()));
   }
-  // trigger tracks
-  if ( TreeT() ) {
-    if (fRecTriggerTracks == 0x0 && cRL)  {
-      fRecTriggerTracks  = new TClonesArray("AliMUONTriggerTrack",100);
-    }
-    
-  }
+  // Trigger tracks
   if ( TreeT() && fRecTriggerTracks && cRL ) {
     sprintf(branchname,"%sTriggerTrack",GetName());  
     branch = TreeT()->GetBranch(branchname);
     if (branch) branch->SetAddress(&fRecTriggerTracks);
     else AliWarning(Form("(%s) Failed for Trigger Tracks. Can not find branch in tree.",GetName()));
   }
-  
-  
 }
 
 //_____________________________________________________________________________
 void
 AliMUONData::Print(Option_t* opt) const
 {
-  // Dump object on screen
+/// Dump object on screen
+
   TString options(opt);
   options.ToUpper();
   
@@ -1144,4 +1139,4 @@ AliMUONData::Print(Option_t* opt) const
     }
   }
   
-}
\ No newline at end of file
+}