]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/AliPMD.cxx
Version 3 of the PMD. (Tapan K. Nayak)
[u/mrichter/AliRoot.git] / PMD / AliPMD.cxx
index 21a783a2fa550282dc20f3b2edda12947676f25f..b1d0ff657db895383cb448ee51638f12f4a4a524 100644 (file)
 
 /*
 $Log$
+Revision 1.13  2001/01/26 20:02:43  hristov
+Major upgrade of AliRoot code
+
+Revision 1.12  2000/12/04 08:48:18  alibrary
+Fixing problems in the HEAD
+
+Revision 1.11  2000/11/17 10:15:24  morsch
+Call to AliDetector::ResetHits() added to method  AliPMD::ResetHits()
+
+Revision 1.10  2000/11/06 09:07:13  morsch
+Set  fRecPoints to zero in default constructor.
+
+Revision 1.9  2000/10/30 09:03:59  morsch
+Prototype for PMD reconstructed hits (AliPMDRecPoint) added.
+
+Revision 1.8  2000/10/20 06:24:40  fca
+Put the PMD at the right position in the event display
+
+Revision 1.7  2000/10/02 21:28:12  fca
+Removal of useless dependecies via forward declarations
+
+Revision 1.6  2000/01/19 17:17:06  fca
+Introducing a list of lists of hits -- more hits allowed for detector now
+
+Revision 1.5  1999/09/29 09:24:27  fca
+Introduction of the Copyright and cvs Log
+
 */
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -42,11 +69,17 @@ $Log$
 
 #include <TBRIK.h>
 #include <TNode.h>
+#include <TTree.h>
+#include <TGeometry.h>
+#include <TClonesArray.h>
+#include <TFile.h>
+
 #include "AliPMD.h"
 #include "AliRun.h"
 #include "AliMC.h" 
 #include "AliConst.h" 
+#include "AliPMDRecPoint.h"
+  
 ClassImp(AliPMD)
  
 //_____________________________________________________________________________
@@ -56,6 +89,10 @@ AliPMD::AliPMD()
   // Default constructor
   //
   fIshunt = 0;
+
+  // Always make the TClonesArray, otherwise the automatic streamer gets angry
+  fRecPoints  = new TClonesArray("AliPMDRecPoint",10000); 
+
 }
  
 //_____________________________________________________________________________
@@ -69,7 +106,12 @@ AliPMD::AliPMD(const char *name, const char *title)
   // 
   // Allocate the array of hits
   fHits   = new TClonesArray("AliPMDhit",  405);
+  gAlice->AddHitList(fHits);
+
+  fRecPoints  = new TClonesArray("AliPMDRecPoint",10000); 
+  fNRecPoints = 0;
   
+
   fIshunt =  1;
   
   fPar[0] = 1;
@@ -90,6 +132,15 @@ AliPMD::AliPMD(const char *name, const char *title)
   fPadSize[3] = 1.5;
 }
 
+AliPMD::~AliPMD()
+{
+  //
+  // Default constructor
+  //
+    delete fRecPoints;
+    fNRecPoints=0;
+}
+
 //_____________________________________________________________________________
 void AliPMD::AddHit(Int_t track, Int_t *vol, Float_t *hits)
 {
@@ -134,7 +185,7 @@ void AliPMD::BuildGeometry()
   // PMD
   new TBRIK("S_PMD","PMD box","void",300,300,5);
   Top->cd();
-  Node = new TNode("PMD","PMD","S_PMD",0,0,600,"");
+  Node = new TNode("PMD","PMD","S_PMD",0,0,-600,"");
   Node->SetLineColor(kColorPMD);
   fNodes->Add(Node);
 }
@@ -205,6 +256,64 @@ void AliPMD::StepManager()
   //
 }
 
+void AliPMD::AddRecPoint(const AliPMDRecPoint &p)
+{
+    //
+    // Add a PMD reconstructed hit to the list
+    //
+    TClonesArray &lrecpoints = *fRecPoints;
+    new(lrecpoints[fNRecPoints++]) AliPMDRecPoint(p);
+}
+
+void AliPMD::MakeBranch(Option_t* option, char *file)
+{
+    // Create Tree branches for the PMD
+    
+    const char *cR = strstr(option,"R");
+    
+    AliDetector::MakeBranch(option,file);
+
+    if (cR) {
+      printf("Make Branch - TreeR address %p\n",gAlice->TreeR());
+    
+      const Int_t kBufferSize = 4000;
+      char branchname[30];
+      
+      sprintf(branchname,"%sRecPoints",GetName());
+      if (fRecPoints   && gAlice->TreeR()) {
+        gAlice->MakeBranchInTree(gAlice->TreeR(), 
+                                 branchname, &fRecPoints, kBufferSize, file) ;
+      }
+   }   
+}
+
+
+void AliPMD::SetTreeAddress()
+{
+  // Set branch address for the TreeR
+    char branchname[30];
+    AliDetector::SetTreeAddress();
+
+    TBranch *branch;
+    TTree *treeR = gAlice->TreeR();
+
+    sprintf(branchname,"%s",GetName());
+    if (treeR && fRecPoints) {
+       branch = treeR->GetBranch(branchname);
+       if (branch) branch->SetAddress(&fRecPoints);
+    }
+}
+
+void AliPMD::ResetHits()
+{
+  //
+  // Reset number of hits and the hits array
+  //
+    AliDetector::ResetHits();
+    fNRecPoints   = 0;
+    if (fRecPoints)   fRecPoints->Clear();
+}
+
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
 //  Photon Multiplicity Detector Version 1                                   //
@@ -217,6 +326,8 @@ void AliPMD::StepManager()
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
+
+
 ClassImp(AliPMDhit)
   
 //_____________________________________________________________________________