]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMD.cxx
Transition to NewIO
[u/mrichter/AliRoot.git] / FMD / AliFMD.cxx
index 5c2d456e7b4a73dcc6ec9f762573bc18cfa3c614..6ad1f1beada301f28821f58cd7d841e476e6267e 100644 (file)
@@ -12,6 +12,9 @@
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
+
+/* $Id$ */
+
  //////////////////////////////////////////////////////////////////////////////
 //                                                                            //
 //  Forward Multiplicity Detector based on Silicon plates                    //
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-
 #define DEBUG
-#include <TMath.h>
+
+#include <Riostream.h>
+#include <stdlib.h>
+
+#include <TClonesArray.h>
+#include <TFile.h>
 #include <TGeometry.h>
+#include <TLorentzVector.h>
+#include <TMath.h>
+#include <TNode.h>
 #include <TTUBE.h>
 #include <TTree.h>
-#include <TNode.h>
-#include <TFile.h>
+#include <TVirtualMC.h>
 
-#include <TClonesArray.h>
-#include <TLorentzVector.h>
-#include "AliFMDv1.h"
-#include "AliRun.h"
 #include "AliDetector.h"
-#include <TBranch.h>
-#include <Riostream.h>
-#include "AliMagF.h"
-#include "AliFMDhit.h"
-#include "AliFMDdigit.h"
-#include "AliFMDReconstruction.h"
 #include "AliFMDReconstParticles.h"
-#include <stdlib.h>
+#include "AliFMDReconstruction.h"
+#include "AliFMDdigit.h"
+#include "AliFMDhit.h"
+#include "AliFMDv1.h"
+#include "AliLoader.h"
+#include "AliMagF.h"
+#include "AliRun.h"
 
 ClassImp (AliFMD)
   //_____________________________________________________________________________
@@ -113,7 +118,7 @@ AliFMD::~AliFMD ()
       delete fDigits;
       fDigits = 0;
     }
-  if (fReconParticles)
+   if (fReconParticles)
     {
       fReconParticles->Delete ();
       delete fReconParticles;
@@ -137,11 +142,11 @@ void AliFMD::AddDigit (Int_t * digits)
 {
   // add a real digit - as coming from data
 
-
+  if (fDigits == 0x0) fDigits = new TClonesArray ("AliFMDdigit", 1000);  
   TClonesArray & ldigits = *fDigits;
   new (ldigits[fNdigits++]) AliFMDdigit (digits);
-
 }
+
 //_____________________________________________________________________________
 void AliFMD::BuildGeometry ()
 {
@@ -182,7 +187,6 @@ void AliFMD::BuildGeometry ()
 
   new TTUBE ("S_FMD4", "FMD  volume 4", "void", 4.2, 17.2, 1.5);
   top->cd ();
-  //  node = new TNode("FMD4","FMD4","S_FMD4",0,0,-270,"");
   node = new TNode ("FMD4", "FMD4", "S_FMD4", 0, 0, -340, "");
   node->SetLineColor (kColorFMD);
   fNodes->Add (node);
@@ -215,7 +219,6 @@ void AliFMD::ResetDigits ()
 }
 
 //-------------------------------------------------------------------------
-
 void  AliFMD::Init ()
 {
   //
@@ -246,30 +249,31 @@ void  AliFMD::Init ()
     fIdSens5 = gMC->VolId ("GRN5");    //Si sensetive volume
 
 }
-
 //---------------------------------------------------------------------
-void AliFMD::MakeBranch (Option_t * option, const char *file)
+void AliFMD::MakeBranch (Option_t * option)
 {
   // Create Tree branches for the FMD.
   char branchname[10];
   const Int_t kBufferSize = 16000;
   sprintf (branchname, "%s", GetName ());
   
-  AliDetector::MakeBranch (option, file);
+  const char *cH = strstr(option,"H");
   const char *cD = strstr(option,"D");
   const char *cR = strstr(option,"R");
   
-  if (cD){
+  if (cH && (fHits == 0x0)) fHits = new TClonesArray ("AliFMDhit", 1000);
 
-    MakeBranchInTree(gAlice->TreeD(), 
-                    branchname,&fDigits, 
-                    kBufferSize, file);
-    cout<<" tree "<<gAlice->TreeD()<<" "<<branchname<<" "<<&fDigits<<endl;
+  AliDetector::MakeBranch (option);
+  
+  if (cD){
+    if (fDigits == 0x0) fDigits = new TClonesArray ("AliFMDdigit", 1000);  
+    MakeBranchInTree(fLoader->TreeD(), branchname,&fDigits, kBufferSize, 0);
   }
+
   if (cR){
-    MakeBranchInTree(gAlice->TreeR(), 
-                    branchname,&fReconParticles,
-                    kBufferSize, file);
+    if (fReconParticles == 0x0) 
+      fReconParticles=new TClonesArray("AliFMDReconstParticles",1000); 
+    MakeBranchInTree(fLoader->TreeR(), branchname,&fReconParticles, kBufferSize, 0);
   }
   
 }
@@ -279,27 +283,28 @@ void AliFMD::SetTreeAddress ()
 {
   // Set branch address for the Hits and Digits Tree.
   char branchname[30];
+
+  if (fLoader->TreeH() && (fHits == 0x0)) 
+    fHits = new TClonesArray ("AliFMDhit", 1000);  
+
   AliDetector::SetTreeAddress ();
 
   TBranch *branch;
-  TTree *treeD = gAlice->TreeD ();
-
+  TTree *treeD = fLoader->TreeD();
 
   if (treeD)
     {
-      if (fDigits)
-       {
-         branch = treeD->GetBranch (branchname);
-         if (branch)
-           branch->SetAddress (&fDigits);
-       }
-
+      if (fDigits == 0x0) fDigits = new TClonesArray ("AliFMDdigit", 1000);
+      branch = treeD->GetBranch (branchname);
+      if (branch)
+       branch->SetAddress (&fDigits);
     }
-
-  if (gAlice->TreeR() && fReconParticles) 
+  
+  if (fLoader->TreeR() && fReconParticles) 
     {
-      branch = gAlice->TreeR()->GetBranch("FMD"); 
+      if (fReconParticles == 0x0) 
+        fReconParticles=new TClonesArray("AliFMDReconstParticles",1000); 
+      branch = fLoader->TreeR()->GetBranch("FMD"); 
       if (branch) branch->SetAddress(&fReconParticles) ;
     }   
 }
@@ -308,8 +313,7 @@ void AliFMD::SetTreeAddress ()
 
 void AliFMD::SetRingsSi1(Int_t ringsSi1)
 {
-  //  fRingsSi1=ringsSi1;
-  fRingsSi1=768;
+   fRingsSi1=512;
 }
 void AliFMD::SetSectorsSi1(Int_t sectorsSi1)
 {
@@ -317,15 +321,13 @@ void AliFMD::SetSectorsSi1(Int_t sectorsSi1)
 }
 void AliFMD::SetRingsSi2(Int_t ringsSi2)
 {
-  fRingsSi2=384;
+  fRingsSi2=256;
 }
 void AliFMD::SetSectorsSi2(Int_t sectorsSi2)
 {
   fSectorsSi2=40;
 }
 
-//---------------------------------------------------------------------
-
 
 
 void
@@ -341,14 +343,13 @@ AliFMD::Eta2Radius (Float_t eta, Float_t zDisk, Float_t * radius)
     printf ("%s: eta %f radius %f\n", ClassName (), eta, rad);
 }
 
-//-----------------------------------------------------------------------
+//---------------------------------------------------------------------
+
 
 void AliFMD::Digits2Reco()
 {
-  char * fileReconParticles=0;
-  char * fileHeader=0;
-  AliFMDReconstruction * reconstruction =
-    new AliFMDReconstruction(fileHeader,fileReconParticles) ;
+  AliFMDReconstruction * reconstruction =  new AliFMDReconstruction(fLoader->GetRunLoader());
+  cout<<" AliFMD::Digits2Reco >> "<<reconstruction<<endl;
   reconstruction->Exec("");
   delete  reconstruction;
 }
@@ -357,18 +358,14 @@ void AliFMD::Digits2Reco()
 void AliFMD::MakeBranchInTreeD(TTree *treeD, const char *file)
 {
     //
-    // Create TreeD branches for the MUON.
+    // Create TreeD branches for the FMD
     //
-
     const Int_t kBufferSize = 4000;
     char branchname[20];
-    
-
     sprintf(branchname,"%s",GetName());        
-    if(treeD){
-    MakeBranchInTree(treeD, 
-                    branchname,&fDigits, 
-                    kBufferSize, file);
-    }
+    if(treeD)
+     {
+       MakeBranchInTree(treeD,  branchname,&fDigits, kBufferSize, file);
+     }
 }