]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMD.cxx
Violations fixed
[u/mrichter/AliRoot.git] / FMD / AliFMD.cxx
index 321c68fda9ab46a436aff38089d028830d36914c..0c21558482f0e72aae4fff6c0a54678300213a60 100644 (file)
  * 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                    //
 //  This class contains the base procedures for the Forward Multiplicity     //
 //  detector                                                                 //
-//  Detector consists of 6 Si volumes covered pseudorapidity interval         //
-//  from 1.6 to 6.0.                                                         //
+//  Detector consists of 5 Si volumes covered pseudorapidity interval         //
+//  from 1.7 to 5.1.                                                         //
 //                                                                           //
 //Begin_Html
 /*
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#include <TTUBE.h>
-#include <TNode.h>
+#define DEBUG
+
+#include <Riostream.h>
+#include <stdlib.h>
+
+#include <TClonesArray.h>
+#include <TFile.h>
 #include <TGeometry.h>
+#include <TNode.h>
+#include <TTUBE.h>
 #include <TTree.h>
+#include <TVirtualMC.h>
+
+#include "AliDetector.h"
+#include "AliFMDReconstParticles.h"
+#include "AliFMDdigit.h"
+#include "AliFMDhit.h"
+#include "AliFMDv1.h"
+#include "AliLoader.h"
 #include "AliRun.h"
 #include "AliMC.h"
-#include "AliFMD.h"
-#include "AliFMDhit.h"
+#include "AliFMDDigitizer.h"
 
-ClassImp(AliFMD)
-//_____________________________________________________________________________
-AliFMD::AliFMD(): AliDetector()
+ClassImp (AliFMD)
+  //_____________________________________________________________________________
+AliFMD::AliFMD ():AliDetector ()
 {
   //
   // Default constructor for class AliFMD
   //
-  fIshunt   = 0;
+  fIshunt = 0;
+  fHits     = 0;
+  fDigits   = 0;
+  fReconParticles=0; 
 }
+
 //_____________________________________________________________________________
-AliFMD::AliFMD(const char *name, const char *title)
-       : AliDetector(name,title)
+AliFMD::AliFMD (const char *name, const char *title):
+AliDetector (name, title)
 {
   //
   // Standard constructor for Forward Multiplicity Detector
   //
+
   //
   // Initialise Hit array
-  fHits     = new TClonesArray("AliFMDhit", 1000);
-  
-  fIshunt     =  0;
-  fIdSens1    =  0;
+  fHits = new TClonesArray ("AliFMDhit", 1000);
+  // Digits for each Si disk
+  fDigits = new TClonesArray ("AliFMDdigit", 1000);
+  fReconParticles=new TClonesArray("AliFMDReconstParticles",1000); 
+  gAlice->GetMCApp()->AddHitList (fHits);
 
-  SetMarkerColor(kRed);
+  fIshunt = 0;
+  //  fMerger = 0;
+  SetMarkerColor (kRed);
 }
 
-AliFMD::~AliFMD()
+//-----------------------------------------------------------------------------
+AliFMD::~AliFMD ()
 {
-  delete fHits;
+  //destructor for base class AliFMD
+  if (fHits)
+    {
+      fHits->Delete ();
+      delete fHits;
+      fHits = 0;
+    }
+  if (fDigits)
+    {
+      fDigits->Delete ();
+      delete fDigits;
+      fDigits = 0;
+    }
+   if (fReconParticles)
+    {
+      fReconParticles->Delete ();
+      delete fReconParticles;
+      fReconParticles = 0;
+    }
+
 }
+
 //_____________________________________________________________________________
-void AliFMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
+void AliFMD::AddHit (Int_t track, Int_t * vol, Float_t * hits)
 {
   //
   // Add a hit to the list
   //
-  TClonesArray &lhits = *fHits;
-  new(lhits[fNhits++]) AliFMDhit(fIshunt,track,vol,hits);
+  TClonesArray & lhits = *fHits;
+  new (lhits[fNhits++]) AliFMDhit (fIshunt, track, vol, hits);
 }
+
+//_____________________________________________________________________________
+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()
+void AliFMD::BuildGeometry ()
 {
   //
   // Build simple ROOT TNode geometry for event display
   //
   TNode *node, *top;
-  const int kColorFMD  = 7;
+  const int kColorFMD = 5;
   //
-  top=gAlice->GetGeometry()->GetNode("alice");
+  top = gAlice->GetGeometry ()->GetNode ("alice");
 
   // FMD define the different volumes
-  new TRotMatrix("rot901","rot901",  90, 0, 90, 90, 180, 0);
-
-  new TTUBE("S_FMD0","FMD  volume 0","void",4.73,17.7,1.5);
-  top->cd();
-  node = new TNode("FMD0","FMD0","S_FMD0",0,0,64,"");
-  node->SetLineColor(kColorFMD);
-  fNodes->Add(node);
-
-  new TTUBE("S_FMD1","FMD  volume 1","void",23.4,36.,1.5);
-  top->cd();
-  node = new TNode("FMD1","FMD1","S_FMD1",0,0,85,"");
-  node->SetLineColor(kColorFMD);
-  fNodes->Add(node);
-  
-  new TTUBE("S_FMD2","FMD  volume 2","void",4.73,17.7,1.5);
-  top->cd();
-  node = new TNode("FMD2","FMD2","S_FMD2",0,0,-64,"");
-  node->SetLineColor(kColorFMD);
-  fNodes->Add(node);
-
-  new TTUBE("S_FMD3","FMD  volume 3","void",23.4,36.,1.5);
-  top->cd();
-  node = new TNode("FMD3","FMD3","S_FMD3",0,0,-85,"");
-  node->SetLineColor(kColorFMD);
-  fNodes->Add(node);
-
-  new TTUBE("S_FMD4","FMD  volume 4","void",5,15,0.015);
-  top->cd();
-  node = new TNode("FMD4","FMD4","S_FMD4",0,0,-270,"");
-  node->SetLineColor(kColorFMD);
-  fNodes->Add(node);
-  
-  
-  new TTUBE("S_FMD5","FMD  volume 5","void",5,14,0.015);
-  top->cd();
-  node = new TNode("FMD5","FMD5","S_FMD5",0,0,-630,"");
-  node->SetLineColor(kColorFMD);
-  fNodes->Add(node);
+  new TRotMatrix ("rot901", "rot901", 90, 0, 90, 90, 180, 0);
+
+  new TTUBE ("S_FMD0", "FMD  volume 0", "void", 4.2, 17.2, 1.5);
+  top->cd ();
+  node = new TNode ("FMD0", "FMD0", "S_FMD0", 0, 0, -62.8, "");
+  node->SetLineColor (kColorFMD);
+  fNodes->Add (node);
+
+  new TTUBE ("S_FMD1", "FMD  volume 1", "void", 15.4, 28.4, 1.5);
+  top->cd ();
+  node = new TNode ("FMD1", "FMD1", "S_FMD1", 0, 0, -75.2, "");
+  node->SetLineColor (kColorFMD);
+  fNodes->Add (node);
 
+  new TTUBE ("S_FMD2", "FMD  volume 2", "void", 4.2, 17.2, 1.5);
+  top->cd ();
+  node = new TNode ("FMD2", "FMD2", "S_FMD2", 0, 0, 83.2, "");
+  node->SetLineColor (kColorFMD);
+  fNodes->Add (node);
+
+  new TTUBE ("S_FMD3", "FMD  volume 3", "void", 15.4, 28.4, 1.5);
+  top->cd ();
+  node = new TNode ("FMD3", "FMD3", "S_FMD3", 0, 0, 75.2, "");
+  node->SetLineColor (kColorFMD);
+  fNodes->Add (node);
+
+  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, 340, "");
+  node->SetLineColor (kColorFMD);
+  fNodes->Add (node);
 }
+
 //_____________________________________________________________________________
-Int_t AliFMD::DistanceToPrimitive(Int_t px, Int_t py)
+const Int_t AliFMD::DistanceToPrimitive (Int_t /*px*/, Int_t /*py*/)
 {
   //
   // Calculate the distance from the mouse to the FMD on the screen
@@ -150,61 +195,129 @@ Int_t AliFMD::DistanceToPrimitive(Int_t px, Int_t py)
   //
   return 9999;
 }
-//_____________________________________________________________________________
+
+//___________________________________________
+void AliFMD::ResetHits ()
+{
+  // Reset number of clusters and the cluster array for this detector
+  AliDetector::ResetHits ();
+}
+
+//____________________________________________
+void AliFMD::ResetDigits ()
+{
+  //
+  // Reset number of digits and the digits array for this detector
+  AliDetector::ResetDigits ();
+  //
+}
 
 //-------------------------------------------------------------------------
-void AliFMD::Init()
+void  AliFMD::Init ()
 {
   //
   // Initialis the FMD after it has been built
   Int_t i;
-  AliMC* pMC = AliMC::GetMC();
   //
-  printf("\n");
-  for(i=0;i<35;i++) printf("*");
-  printf(" FMD_INIT ");
-  for(i=0;i<35;i++) printf("*");
-  printf("\n");
+  if (fDebug)
+    {
+      printf ("\n%s: ", ClassName ());
+      for (i = 0; i < 35; i++)
+       printf ("*");
+      printf (" FMD_INIT ");
+      for (i = 0; i < 35; i++)
+       printf ("*");
+      printf ("\n%s: ", ClassName ());
+      //
+      // Here the FMD initialisation code (if any!)
+      for (i = 0; i < 80; i++)
+       printf ("*");
+      printf ("\n");
+    }
   //
-  // Here the FMD initialisation code (if any!)
-  for(i=0;i<80;i++) printf("*");
-  printf("\n");
- //
- //
-  fIdSens1=pMC->VolId("GFSI"); //Si sensetive volume
-
+  //
 }
 //---------------------------------------------------------------------
-void AliFMD::MakeBranch(Option_t* option)
+void AliFMD::MakeBranch (Option_t * option)
 {
   // Create Tree branches for the FMD.
-  Int_t buffersize = 4000;
   char branchname[10];
-  sprintf(branchname,"%s",GetName());
+  const Int_t kBufferSize = 16000;
+  sprintf (branchname, "%s", GetName ());
+  
+  const char *cH = strstr(option,"H");
+  const char *cD = strstr(option,"D");
+  const char *cR = strstr(option,"R");
+  
+  if (cH && (fHits == 0x0)) fHits = new TClonesArray ("AliFMDhit", 1000);
 
-  AliDetector::MakeBranch(option);
+  AliDetector::MakeBranch (option);
+  
+  if (cD){
+    if (fDigits == 0x0) fDigits = new TClonesArray ("AliFMDdigit", 1000);  
+    MakeBranchInTree(fLoader->TreeD(), branchname,&fDigits, kBufferSize, 0);
+  }
 
-  if (fDigits   && gAlice->TreeD()) {
-    gAlice->TreeD()->Branch(branchname,&fDigits, buffersize);
-    printf("Making Branch %s for digits\n",branchname);
+  if (cR){
+    if (fReconParticles == 0x0) 
+      fReconParticles=new TClonesArray("AliFMDReconstParticles",1000); 
+    MakeBranchInTree(fLoader->TreeR(), branchname,&fReconParticles, kBufferSize, 0);
   }
+  
 }
-//---------------------------------------------------------------------
 
-void AliFMD::Eta2Radius(Float_t eta, Float_t zDisk, Float_t *radius)
+//_____________________________________________________________________________
+void AliFMD::SetTreeAddress ()
 {
-   Float_t expEta=TMath::Exp(-eta);
-   Float_t theta=TMath::ATan(expEta);
-   theta=2.*theta;
-   Float_t rad=zDisk*(TMath::Tan(theta));
-   *radius=rad;
-   
-   printf(" eta %f radius %f\n", eta, rad);
+  // 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 = fLoader->TreeD();
+
+  if (treeD)
+    {
+      if (fDigits == 0x0) fDigits = new TClonesArray ("AliFMDdigit", 1000);
+      branch = treeD->GetBranch (branchname);
+      if (branch)
+       branch->SetAddress (&fDigits);
+    }
+  
+  if (fLoader->TreeR() && fReconParticles) 
+    {
+      if (fReconParticles == 0x0) 
+        fReconParticles=new TClonesArray("AliFMDReconstParticles",1000); 
+      branch = fLoader->TreeR()->GetBranch("FMD"); 
+      if (branch) branch->SetAddress(&fReconParticles) ;
+    }   
 }
 
-    
+
+
+//-----------------------------------------------------------------------
+
+void AliFMD::MakeBranchInTreeD(TTree *treeD, const char *file)
+{
+    //
+    // 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);
+     }
+}
+
+//____________________________________________________________________________
+AliDigitizer* AliFMD::CreateDigitizer(AliRunDigitizer* manager) const
+{
+  return new AliFMDDigitizer(manager);
+}