]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/AliEMCALv2.cxx
This is a backward incompatible change in AliRoot. The following methods have been...
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALv2.cxx
index 5286ad19c76595f406dd181813eb86f3404ebb28..4ca0f071d6ed276f06ec420671c60566e8b54ae4 100644 (file)
@@ -29,7 +29,6 @@
 // --- ROOT system ---
 #include <TBrowser.h>
 #include <TClonesArray.h>
-#include <TH1.h>
 #include <TH2.h>
 #include <TParticle.h>
 #include <TROOT.h>
 #include "AliHeader.h"
 #include "AliMC.h"
 #include "AliStack.h"
-#include "AliPoints.h"
+#include "AliTrackReference.h"
 // for TRD1 case only; May 31,2006
 
 ClassImp(AliEMCALv2)
 
 //______________________________________________________________________
 AliEMCALv2::AliEMCALv2()
-  : AliEMCALv1(), 
-    fHDe(0),
-    fHNhits(0)
+  : AliEMCALv1()
 {
   // ctor
 }
 
 //______________________________________________________________________
 AliEMCALv2::AliEMCALv2(const char *name, const char *title)
-  : AliEMCALv1(name,title),
-    fHDe(0),
-    fHNhits(0)
+  : AliEMCALv1(name,title)
 {
     // Standard Creator.
 
@@ -75,16 +70,6 @@ AliEMCALv2::AliEMCALv2(const char *name, const char *title)
     fTimeCut  = 30e-09;
 
     fGeometry = GetGeometry(); 
-    fHDe = fHNhits = 0;
-    //    if (gDebug>0){
-    if (1){
-      TH1::AddDirectory(0);
-      fHDe    = new TH1F("fHDe","De in EMCAL", 1000, 0., 10.);
-      fHNhits = new TH1F("fHNhits","#hits in EMCAL", 2001, -0.5, 2000.5);
-      fHistograms->Add(fHDe);
-      fHistograms->Add(fHNhits);
-      TH1::AddDirectory(1);
-    }
 }
 
 //______________________________________________________________________
@@ -145,7 +130,7 @@ void AliEMCALv2::StepManager(void){
   static TString curVolName;
   static int supModuleNumber, moduleNumber, yNumber, xNumber, absid;
   static int keyGeom=1;  //real TRD1 geometry
-  static char *vn = "SCMX"; // Apr 13, 2006 - only TRD1 case now
+  static const char *vn = "SCMX"; // Apr 13, 2006 - only TRD1 case now
   static int nSMOP[7]={1,3,5,7,9,11}; // 30-mar-05
   static int nSMON[7]={2,4,6,8,10,12};
   static Float_t depositedEnergy=0.0; 
@@ -161,6 +146,8 @@ void AliEMCALv2::StepManager(void){
     if(gMC->VolId("WSUC")==1) printf(" WSUC - cosmic ray stand geometry \n");
   }
   Int_t tracknumber =  gAlice->GetMCApp()->GetCurrentTrackNumber();
+  Int_t parent;
+  TParticle* part;
 
   curVolName = gMC->CurrentVolName();
   if(curVolName.Contains(vn) || curVolName.Contains("SCX")) { // We are in a scintillator layer; SCX for 3X3
@@ -172,16 +159,20 @@ void AliEMCALv2::StepManager(void){
 
       if (fCurParent==-1 || tracknumber != fCurTrack) {
        // Check parentage
-       Int_t parent=tracknumber;
+       parent=tracknumber;
+
        if (fCurParent != -1) {
          while (parent != fCurParent && parent != -1) {
-           TParticle *part=gAlice->GetMCApp()->Particle(parent);
+           //TParticle *part=gAlice->GetMCApp()->Particle(parent);
+           part=gAlice->GetMCApp()->Particle(parent);
            parent=part->GetFirstMother();
          }
        }
        if (fCurParent==-1 || parent==-1) {
-         Int_t parent=tracknumber;
-         TParticle *part=gAlice->GetMCApp()->Particle(parent);
+         //Int_t parent=tracknumber;
+         //TParticle *part=gAlice->GetMCApp()->Particle(parent);
+         parent=tracknumber;
+         part=gAlice->GetMCApp()->Particle(parent);
          while (parent != -1 && fGeometry->IsInEMCAL(part->Vx(),part->Vy(),part->Vz())) {
            parent=part->GetFirstMother();
            if (parent!=-1) 
@@ -191,8 +182,13 @@ void AliEMCALv2::StepManager(void){
          if (fCurParent==-1)
            Error("StepManager","Cannot find parent");
          else {
-           TParticle *part=gAlice->GetMCApp()->Particle(fCurParent);
+           //TParticle *part=gAlice->GetMCApp()->Particle(fCurParent);
+           part=gAlice->GetMCApp()->Particle(fCurParent);
            ienergy = part->Energy(); 
+
+           //Add reference to parent in TR tree.       
+           AddTrackReference(tracknumber, AliTrackReference::kEMCAL);
+
          }
          while (parent != -1) {
            part=gAlice->GetMCApp()->Particle(parent);
@@ -227,7 +223,7 @@ void AliEMCALv2::StepManager(void){
           if     (strcmp(gMC->CurrentVolOffName(0),"SCX1")==0) xNumber=1;
           else if(strcmp(gMC->CurrentVolOffName(0),"SCX2")==0) xNumber=2;
           else if(strcmp(gMC->CurrentVolOffName(0),"SCX3")==0) xNumber=3;
-          else Fatal("StepManager()", "Wrong name of sensetive volume in 3X3 case : %s ", gMC->CurrentVolOffName(0));
+          else Fatal("StepManager()", "Wrong name of sensitive volume in 3X3 case : %s ", gMC->CurrentVolOffName(0));
        }
       } else {
         gMC->CurrentVolOffID(5, supModuleNumber);
@@ -238,11 +234,30 @@ void AliEMCALv2::StepManager(void){
         else if(strcmp(gMC->CurrentVolOffName(5),"SMON")==0) supModuleNumber = nSMON[supModuleNumber-1];
         else   assert(0); // something wrong
       }
-      absid = fGeometry->GetAbsCellId(supModuleNumber-1, moduleNumber-1, yNumber-1, xNumber-1);
-    
+               
+      // Due to problem with index ordering conventions the calcultation of absid is no more like this:        
+      //absid = fGeometry->GetAbsCellId(smNumber, moduleNumber-1, yNumber-1, xNumber-1);
+      
+      //Swap A side in Phi and C side in Eta due to wrong indexing.
+      Int_t iphi = -1;
+      Int_t ieta = -1;
+      Int_t smNumber = supModuleNumber-1;
+      Int_t smType   = 1;
+      fGeometry->GetCellPhiEtaIndexInSModule(smNumber,moduleNumber-1,yNumber-1,xNumber-1, iphi, ieta);
+      if (smNumber%2 == 0) {
+       ieta = ((fGeometry->GetCentersOfCellsEtaDir()).GetSize()-1)-ieta;// 47-ieta, revert the ordering on A side in order to keep convention.
+      }
+      else {  
+       if(smNumber >= 10) smType = 2 ; //half supermodule
+       iphi= ((fGeometry->GetCentersOfCellsPhiDir()).GetSize()/smType-1)-iphi;//23-iphi, revert the ordering on C side in order to keep convention.
+      }
+      
+      //Once we know the indexes, calculate the absolute ID
+      absid = fGeometry->GetAbsCellIdFromCellIndexes(smNumber, iphi, ieta);
+      
       if (absid < 0) {
         printf(" supModuleNumber %i : moduleNumber %i : yNumber %i : xNumber %i \n",
-        supModuleNumber, moduleNumber, yNumber, xNumber); 
+              supModuleNumber, moduleNumber, yNumber, xNumber); 
        Fatal("StepManager()", "Wrong id : %i ", absid) ; 
       }
 
@@ -275,37 +290,6 @@ void AliEMCALv2::StepManager(void){
   }
 }
 
-//_________________________________________________________________
-void AliEMCALv2::FinishEvent()
-{ 
-  // Calculate deposit energy and fill control histogram; 26-may-05
-  static double de=0.;
-  fHNhits->Fill(double(fHits->GetEntries()));
-  de = GetDepositEnergy(0);
-  if(fHDe) fHDe->Fill(de);
-}
-
-//_________________________________________________________________
-Double_t AliEMCALv2::GetDepositEnergy(int print)
-{ 
-  // 23-mar-05 - for testing
-  if(fHits == 0) return 0.;
-  AliEMCALHit  *hit=0;
-  Double_t de=0.;
-  for(int ih=0; ih<fHits->GetEntries(); ih++) {
-    hit = (AliEMCALHit*)fHits->UncheckedAt(ih);
-    de += hit->GetEnergy();
-  }
-  if(print>0) {
-    cout<<"AliEMCALv2::GetDepositEnergy() : fHits "<<fHits<<endl; 
-    printf(" #hits %i de %f \n", fHits->GetEntries(), de);
-    if(print>1) {
-      printf(" #primary particles %i\n", gAlice->GetHeader()->GetNprimary()); 
-    }
-  }
-  return de;
-}
-
 //___________________________________________________________
 void AliEMCALv2::Browse(TBrowser* b)
 {
@@ -334,7 +318,7 @@ void AliEMCALv2::DrawCalorimeterCut(const char *name, int axis, double dcut)
   st += ", zcut, ";
   st += name;
 
-  char *optShad = "on", *optHide="on";
+  const char *optShad = "on", *optHide="on";
   double cxy=0.02;
   if     (axis==1) {
     dcut = 0.;
@@ -361,7 +345,7 @@ void AliEMCALv2::DrawSuperModuleCut(const char *name, int axis, double dcut, int
  // Size of tower is 5.6x5.6x24.8 (25.0); cut on Z axiz
   TString sn(GetGeometry()->GetName());
   sn.ToUpper();
-  char *tit[3]={"xcut", "ycut", "zcut"};
+  const char *tit[3]={"xcut", "ycut", "zcut"};
   if(axis<1) axis=1; if(axis>3) axis=3;
 
   gMC->Gsatt("*", "seen", 0);
@@ -371,7 +355,7 @@ void AliEMCALv2::DrawSuperModuleCut(const char *name, int axis, double dcut, int
   SetVolumeAttributes(name, 1, 5, fill);    // yellow 
 
   double cxy=0.055, x0=10., y0=10.;
-  char *optShad = "on", *optHide="on";
+  const char *optShad = "on", *optHide="on";
   SetVolumeAttributes("STPL", 1, 3, fill);  // green 
   if     (axis==1) {
     gMC->Gsatt("STPL", "seen", 0);
@@ -403,7 +387,7 @@ void AliEMCALv2::DrawSuperModuleCut(const char *name, int axis, double dcut, int
 }
 
 //___________________________________________________________
-void AliEMCALv2::DrawTowerCut(const char *name, int axis, double dcut, int fill, char *optShad)
+void AliEMCALv2::DrawTowerCut(const char *name, int axis, double dcut, int fill, const char *optShad)
 { 
   // Size of tower is 5.6x5.6x24.8 (25.0); cut on Z axiz
   if(axis<1) axis=1; if(axis>3) axis=3;