]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMD.cxx
Hits -> Digits directly
[u/mrichter/AliRoot.git] / FMD / AliFMD.cxx
index 84ff0b8f7f89a9b1a639e4206e4416f847675e00..5c0a72405599275ab608666cd9dccc515e906e62 100644 (file)
@@ -13,7 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
  //////////////////////////////////////////////////////////////////////////////
-//                                                                           //
+//                                                                            //
 //  Forward Multiplicity Detector based on Silicon plates                    //
 //  This class contains the base procedures for the Forward Multiplicity     //
 //  detector                                                                 //
 #include <TTUBE.h>
 #include <TTree.h>
 #include <TNode.h>
+#include <TFile.h>
 
 #include <TClonesArray.h>
 #include <TLorentzVector.h>
 #include "AliFMDv1.h"
 #include "AliRun.h"
 #include "AliMC.h"
+#include "AliDetector.h"
 #include <iostream.h>
 #include <fstream.h>
 #include "AliMagF.h"
 #include "AliFMDhit.h"
 #include "AliFMDdigit.h"
+#include "AliFMDReconstruction.h"
+#include "AliFMDReconstParticles.h"
 #include <stdlib.h>
 
 
-ClassImp(AliFMD)
+ClassImp (AliFMD)
   //_____________________________________________________________________________
-  AliFMD::AliFMD(): AliDetector()
+AliFMD::AliFMD ():AliDetector ()
 {
   //
   // Default constructor for class AliFMD
   //
-  fIshunt   = 0;
+  fIshunt = 0;
+  fHits     = 0;
+  fDigits   = 0;
+  fSDigits  = 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);
+  fHits = new TClonesArray ("AliFMDhit", 1000);
   // Digits for each Si disk
-  fDigits   = new TClonesArray("AliFMDdigit", 1000);
-  fSDigits  = new TClonesArray("AliFMDdigit", 1000) ; 
-  gAlice->AddHitList(fHits);
-
-  fIshunt     =  0;
-  fIdSens1    =  0;
-
-  SetMarkerColor(kRed);
+  fDigits = new TClonesArray ("AliFMDdigit", 1000);
+  fSDigits = new TClonesArray ("AliFMDdigit", 1000);
+  fReconParticles=new TClonesArray("AliFMDReconstParticles",1000); 
+  gAlice->AddHitList (fHits);
+
+  fIshunt = 0;
+  fIdSens1 = 0;
+  fIdSens2 = 0;
+  fIdSens3 = 0;
+  fIdSens4 = 0;
+  fIdSens5 = 0;
+  //  fMerger = 0;
+  SetMarkerColor (kRed);
 }
 
-AliFMD::~AliFMD()
+//-----------------------------------------------------------------------------
+AliFMD::~AliFMD ()
 {
-  if (fHits) {
-      fHits->Delete();
+  if (fHits)
+    {
+      fHits->Delete ();
       delete fHits;
       fHits = 0;
-  }
-  if (fDigits) {
-      fDigits->Delete();
+    }
+  if (fDigits)
+    {
+      fDigits->Delete ();
       delete fDigits;
       fDigits = 0;
-  }
-  if (fSDigits) {
-      fSDigits->Delete();
+    }
+  if (fSDigits)
+    {
+      fSDigits->Delete ();
       delete fSDigits;
       fSDigits = 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) 
+void AliFMD::AddDigit (Int_t * digits)
 {
   // add a real digit - as coming from data
 
-  // printf("AddDigit\n");
 
-   TClonesArray &ldigits = *fDigits;
-   new(ldigits[fNdigits++]) AliFMDdigit(digits);
+  TClonesArray & ldigits = *fDigits;
+  new (ldigits[fNdigits++]) AliFMDdigit (digits);
 
 }
 //_____________________________________________________________________________
-void AliFMD::BuildGeometry()
+void AliFMD::AddSDigit (Int_t * digits)
+{
+  // add a real digit - as coming from data
+
+  TClonesArray & ldigits = *fSDigits;
+  new (ldigits[fNdigits++]) AliFMDdigit (digits);
+
+}
+//_____________________________________________________________________________
+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,-270,"");
+  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)
+Int_t AliFMD::DistanceToPrimitive (Int_t px, Int_t py)
 {
   //
   // Calculate the distance from the mouse to the FMD on the screen
@@ -191,144 +215,249 @@ Int_t AliFMD::DistanceToPrimitive(Int_t px, Int_t py)
   //
   return 9999;
 }
+
 //___________________________________________
-void AliFMD::ResetHits()
+void AliFMD::ResetHits ()
 {
   // Reset number of clusters and the cluster array for this detector
-  AliDetector::ResetHits();
+  AliDetector::ResetHits ();
 }
 
 //____________________________________________
-void AliFMD::ResetDigits()
+void AliFMD::ResetDigits ()
 {
-    //
-    // Reset number of digits and the digits array for this detector
-   AliDetector::ResetHits();
-   //
+  //
+  // 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();
+  AliMC *pMC = AliMC::GetMC ();
   //
-  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");
-  }
+  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");
+    }
   //
   //
-  if (IsVersion()!=0)
-    fIdSens1=pMC->VolId("GRIN"); //Si sensetive volume
-  else
-    fIdSens1=pMC->VolId("GFSI"); //Si sensetive volume
+    fIdSens1 = pMC->VolId ("GRN1");    //Si sensetive volume
+    fIdSens2 = pMC->VolId ("GRN2");    //Si sensetive volume
+    fIdSens3 = pMC->VolId ("GRN3");    //Si sensetive volume
+    fIdSens4 = pMC->VolId ("GRN4");    //Si sensetive volume
 
 }
 //---------------------------------------------------------------------
-void AliFMD::MakeBranch(Option_t* option, const char *file)
+void AliFMD::MakeBranch (Option_t * option, const char *file)
 {
   // Create Tree branches for the FMD.
-  const Int_t kBufferSize = 4000;
   char branchname[10];
-  sprintf(branchname,"%s",GetName());
+  const Int_t kBufferSize = 16000;
+  sprintf (branchname, "%s", GetName ());
+  
+  AliDetector::MakeBranch (option, file);
+  const char *cD = strstr(option,"D");
+  const char *cR = strstr(option,"R");
+  const char *cS = strstr(option,"S");
+  
+  if (cS){
 
-  AliDetector::MakeBranch(option,file);
+    MakeBranchInTree(gAlice->TreeS(), 
+                    branchname,&fSDigits, 
+                    kBufferSize, file);
+  }
+  if (cD){
 
-  const char *cD = strstr(option,"D");
-  if (cD) {
-    
     MakeBranchInTree(gAlice->TreeD(), 
-                     branchname, &fDigits, kBufferSize, file);
-
-    printf("Making Branch %s for digits\n",branchname);
-    gAlice->TreeD()->Print();
+                    branchname,&fDigits, 
+                    kBufferSize, file);
+    cout<<" tree "<<gAlice->TreeD()<<" "<<branchname<<" "<<&fDigits<<endl;
   }
+  if (cR){
+    MakeBranchInTree(gAlice->TreeR(), 
+                    branchname,&fReconParticles,
+                    kBufferSize, file);
+  }
+  
 }
+
 //_____________________________________________________________________________
-void AliFMD::SetTreeAddress()
+void AliFMD::SetTreeAddress ()
 {
   // Set branch address for the Hits and Digits Tree.
   char branchname[30];
-  AliDetector::SetTreeAddress();
+  AliDetector::SetTreeAddress ();
 
   TBranch *branch;
-  TTree *treeD = gAlice->TreeD();
+  TTree *treeD = gAlice->TreeD ();
 
 
-  if (treeD) {
-       if (fDigits) {
-             branch = treeD->GetBranch(branchname);
-             if (branch) branch->SetAddress(&fDigits);
-        }
-      
-  }
-  if(fSDigits)
-    fSDigits->Clear();
+  if (treeD)
+    {
+      if (fDigits)
+       {
+         branch = treeD->GetBranch (branchname);
+         if (branch)
+           branch->SetAddress (&fDigits);
+       }
 
-  if (gAlice->TreeS()  && fSDigits ) {
-    branch = gAlice->TreeS()->GetBranch("FMD");
-    if (branch) branch->SetAddress(&fSDigits) ;
-  } 
+    }
+  if (fSDigits)
+    //  fSDigits->Clear ();
+
+  if (gAlice->TreeS () && fSDigits)
+    {
+      branch = gAlice->TreeS ()->GetBranch ("FMD");
+      if (branch)
+       branch->SetAddress (&fSDigits);
+    }
 
+  if (gAlice->TreeR() && fReconParticles) 
+    {
+      branch = gAlice->TreeR()->GetBranch("FMD"); 
+      if (branch) branch->SetAddress(&fReconParticles) ;
+    }   
+}
 
+//---------------------------------------------------------------------
+
+void AliFMD::SetRingsSi1(Int_t ringsSi1=256)
+{
+  //  fRingsSi1=ringsSi1;
+  fRingsSi1=256;
+}
+void AliFMD::SetSectorsSi1(Int_t sectorsSi1=20)
+{
+  fSectorsSi1=20;
+}
+void AliFMD::SetRingsSi2(Int_t ringsSi2=128)
+{
+  fRingsSi2=128;
+}
+void AliFMD::SetSectorsSi2(Int_t sectorsSi2=40)
+{
+  fSectorsSi2=40;
 }
 
 //---------------------------------------------------------------------
 /*
 void AliFMD::SDigits2Digits() 
 {
-     Int_t  ibg=0, bgr=0;
-    Int_t nbgr_ev= 0;
-       
-    if (ibg) {
-         printf("nbgr_ev %d\n",nbgr_ev);
- //        Hit2Digits(nbgr_ev,"Add"," ","galice_bgr.root");
-    } 
-       else {
-   //      Hit2Digits(nbgr_ev,"rien","",""); 
+  cout<<"AliFMD::SDigits2Digits"<<endl; 
+    if (!fMerger) {
+      fMerger = new AliFMDMerger();
+    }
+    
+    fMerger ->SetRingsSi1(fRingsSi1);
+    fMerger->SetRingsSi2(fRingsSi2);
+    fMerger ->SetSectorsSi1(fSectorsSi1);
+    fMerger ->SetSectorsSi2(fSectorsSi2);
+     
+    fMerger->Init();
+    cout<<"AliFMD::SDigits2Digits Init"<<endl; 
+    fMerger->Digitise();
+    cout<<"AliFMD::SDigits2Digits Digitise() "<<endl; 
+
     }
 
+    //---------------------------------------------------------------------
+void   AliFMD::SetMerger(AliFMDMerger* merger)
+{
+// Set pointer to merger
+    fMerger = merger;
+}
+
+AliFMDMerger*  AliFMD::Merger()
+{
+// Return pointer to merger
+    return fMerger;
 }
 */
 //---------------------------------------------------------------------
 
 
 
-void AliFMD::Eta2Radius(Float_t eta, Float_t zDisk, Float_t *radius)
+void
+AliFMD::Eta2Radius (Float_t eta, Float_t zDisk, Float_t * radius)
 {
-  Float_t expEta=TMath::Exp(-eta);
-  Float_t theta=TMath::ATan(expEta);
-  theta=2.*theta;
-  Float_t rad=zDisk*(TMath::Tan(theta));
-  *radius=rad;
-   
-  if(fDebug) printf("%s: eta %f radius %f\n", ClassName(), eta, rad);
+  Float_t expEta = TMath::Exp (-eta);
+  Float_t theta = TMath::ATan (expEta);
+  theta = 2. * theta;
+  Float_t rad = zDisk * (TMath::Tan (theta));
+  *radius = rad;
+
+  if (fDebug)
+    printf ("%s: eta %f radius %f\n", ClassName (), eta, rad);
 }
 
 //---------------------------------------------------------------------
 
-void AliFMD::Hits2SDigits(){
-  if(fDebug) cout << ClassName() << ": ALiFMD::Hits2SDigits> start...\n";
-  //  char * fileSDigits = 0 ;
-  // char * fileHeader=0 ;
-  AliFMDSDigitizer * sd = new AliFMDSDigitizer("mgalice.root","FMD.SDigit.root") ;
+void AliFMD::Hits2SDigits ()
+{
+
+  //#ifdef DEBUG
+  cout<<"ALiFMD::Hits2SDigits> start...\n";
+  //#endif
+  
+  char * fileSDigits = "FMD.SDigits.root";
+  char * fileHeader = 0;
+  AliFMDSDigitizer * sd = new AliFMDSDigitizer(fileHeader,fileSDigits) ;
+  sd->SetRingsSi1(fRingsSi1);
+  sd->SetRingsSi2(fRingsSi2);
+  sd->SetSectorsSi1(fSectorsSi1);
+  sd->SetSectorsSi2(fSectorsSi2);
+  //  sd->SetEventNumber(fEvNrSig);
   sd->Exec("") ;
-  sd->Print("");
   
   delete sd ;
+  
 }
+//-----------------------------------------------------------------------
 
+void AliFMD::Digits2Reco()
+{
+  char * fileReconParticles=0;
+  char * fileHeader=0;
+  AliFMDReconstruction * reconstruction =
+    new AliFMDReconstruction(fileHeader,fileReconParticles) ;
+  //  fReconParticles=new TClonesArray("AliFMDReconstParticles",1000);
+  reconstruction->Exec("");
+  delete  reconstruction;
+}
+//-----------------------------------------------------------------------
+
+void AliFMD::MakeBranchInTreeD(TTree *treeD, const char *file)
+{
+    //
+    // Create TreeD branches for the MUON.
+    //
+
+    const Int_t kBufferSize = 4000;
+    char branchname[20];
+    
 
+    sprintf(branchname,"%s",GetName());        
+    if(treeD){
+    MakeBranchInTree(treeD, 
+                    branchname,&fDigits, 
+                    kBufferSize, file);
+    }
+}