]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCmapper.cxx
Handle missing rec-point tree in a uniform way: return null pointer to TEvePointSet.
[u/mrichter/AliRoot.git] / TPC / AliTPCmapper.cxx
index 6dcafb71cf68bb49a07171f290d6f293a4f6eb33..7798c641345ade939807b0f03dab13f7eb5ae109 100644 (file)
@@ -46,7 +46,6 @@
 #include "AliDAQ.h"
 
 ClassImp(AliTPCmapper)
-
 //______________________________________________________________
 AliTPCmapper::AliTPCmapper() :
   fNside(0),
@@ -58,11 +57,33 @@ AliTPCmapper::AliTPCmapper() :
   fNpadrow(0),
   fNpadrowIROC(0),
   fNpadrowOROC(0),
-  fTpcDdlOffset(0),
-  fROC(NULL)
+  fTpcDdlOffset(0)
+{
+  //
+  // Constructor
+  //
+  for ( Int_t i = 0; i < 6; i++ )  fMapping[i]=0;
+}
+
+//______________________________________________________________
+AliTPCmapper::AliTPCmapper(const char * dirname) :
+  fNside(0),
+  fNsector(0),
+  fNrcu(0),
+  fNbranch(0),
+  fNaltro(0),
+  fNchannel(0),
+  fNpadrow(0),
+  fNpadrowIROC(0),
+  fNpadrowOROC(0),
+  fTpcDdlOffset(0)
 {
+  //
   // Constructor
-  Init();
+  //
+  // dirname - specify the directory with the ascii Altro mapping files
+  //
+  Init(dirname);
 }
 
 //______________________________________________________________
@@ -70,8 +91,6 @@ AliTPCmapper::~AliTPCmapper()
 {
   // Destructor
 
-  delete fROC;
-
   for ( Int_t i = 0; i < fNrcu; i++ ) {
     delete fMapping[i];
     fMapping[i] = 0;
@@ -91,8 +110,7 @@ AliTPCmapper::AliTPCmapper(const AliTPCmapper& mapper) :
   fNpadrow(mapper.fNpadrow),
   fNpadrowIROC(mapper.fNpadrowIROC),
   fNpadrowOROC(mapper.fNpadrowOROC),
-  fTpcDdlOffset(mapper.fTpcDdlOffset),
-  fROC(mapper.fROC)
+  fTpcDdlOffset(mapper.fTpcDdlOffset)
 {
   // Copy Constructor
   for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
@@ -107,7 +125,6 @@ AliTPCmapper& AliTPCmapper::operator = (const AliTPCmapper& mapper)
   ((TObject *)this)->operator=(mapper);
 
   for ( Int_t i = 0; i < fNrcu; i++ ) fMapping[i] = mapper.fMapping[i];
-  fROC = mapper.fROC;
 
   fNside = mapper.fNside;
   fNsector = mapper.fNsector;
@@ -124,7 +141,7 @@ AliTPCmapper& AliTPCmapper::operator = (const AliTPCmapper& mapper)
 }
 
 //______________________________________________________________
-void AliTPCmapper::Init()
+void AliTPCmapper::Init(const char *dirname)
 {
   // Initialize all
   fNside    = 2;
@@ -136,8 +153,15 @@ void AliTPCmapper::Init()
 
   // Load and read mapping files. AliTPCAltroMapping contains the mapping for
   // each patch (rcu).
-  TString path = gSystem->Getenv("ALICE_ROOT");
-  path += "/TPC/mapping/Patch";
+  TString path;
+  if (dirname==0){
+    path  =gSystem->Getenv("ALICE_ROOT");
+    path += "/TPC/mapping/Patch";
+  }else{
+    path  = dirname;
+    path +="Patch";
+  }
+
   TString path2;
   for(Int_t i = 0; i < fNrcu; i++) {
     path2 = path;
@@ -147,11 +171,10 @@ void AliTPCmapper::Init()
   }
 
   // Create instance of AliTPCROC object
-  fROC = AliTPCROC::Instance();
-
+  AliTPCROC *fROC = AliTPCROC::Instance();
   fNpadrowIROC = fROC->GetNRows(0);
   fNpadrowOROC = fROC->GetNRows(36);
-  fNpadrow = fNpadrowIROC+fNpadrowOROC;
+  fNpadrow     = fNpadrowIROC+fNpadrowOROC;
 
   AliDAQ daq;
   fTpcDdlOffset = daq.DdlIDOffset("TPC");
@@ -495,7 +518,9 @@ Int_t AliTPCmapper::DecodedHWAddressChanneladdr(Int_t hwAddress) const
 //______________________________________________________________
 Int_t AliTPCmapper::GetNpads(Int_t roc, Int_t padrow) const{
   // Get number of pads in padrow for this ROC.
-  return fROC->GetNPads((UInt_t)roc, (UInt_t)padrow);
+  AliTPCROC *fROC = AliTPCROC::Instance();
+  Int_t retval = fROC->GetNPads((UInt_t)roc, (UInt_t)padrow);
+  return retval;
 }
 
 
@@ -518,7 +543,9 @@ Int_t AliTPCmapper::GetNpads(Int_t globalpadrow) const{
 Int_t AliTPCmapper::GetNpadrows(Int_t roc) const
 {
   // Get number of padrows
-  return fROC->GetNRows(roc);
+  if      (roc < 36) return fNpadrowIROC;
+  else if (roc < 72) return fNpadrowOROC;
+  return -1;
 }
 
 
@@ -711,6 +738,7 @@ Int_t AliTPCmapper::GetNfec(Int_t patch, Int_t branch) const
   if( (branch == 1) && (patch == 1) ){
     retval = 12;
   }
+
   return retval;
 }