]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - T0/AliT0Parameters.cxx
reading Zposition from DB, the same RawReader for sim. and test data, reading detecto...
[u/mrichter/AliRoot.git] / T0 / AliT0Parameters.cxx
index d3e22929ac816b2031284121af2671e62183e46e..2c89c6c75a89da220f4eba3f312c70c8d32708d5 100644 (file)
 #include <AliCDBManager.h>        
 #include <AliCDBEntry.h>          
 #include <AliCDBStorage.h>  
-#include <TMath.h>        
+#include <TMath.h>
+#include <TSystem.h>
 #include <Riostream.h>
+#include <TGeoManager.h>
+#include <TGeoPhysicalNode.h>
 
 AliT0CalibData* AliT0Parameters::fgCalibData = 0;
 AliT0CalibData* AliT0Parameters::fgLookUp = 0;
@@ -56,7 +59,14 @@ AliT0Parameters::Instance()
 
 //____________________________________________________________________
 AliT0Parameters::AliT0Parameters()
-  :fIsInit(kFALSE),fPh2Mip(0),fmV2Mip(0),fChannelWidth(0),fmV2Channel(0),fQTmin(0),fQTmax(0),fSlewingLED(),fSlewingRec(),fPMTeff(),fTimeDelayLED(0),fTimeDelayCFD(0),fTimeDelayTVD(0),fCalibentry(), fLookUpentry(),fSlewCorr()
+  :fIsInit(kFALSE),
+   fPh2Mip(0),fmV2Mip(0),
+   fChannelWidth(0),fmV2Channel(0),
+   fQTmin(0),fQTmax(0),
+   fSlewingLED(),fSlewingRec(),
+   fPMTeff(),
+   fTimeDelayLED(0),fTimeDelayCFD(0),fTimeDelayTVD(0),
+   fCalibentry(), fLookUpentry(),fSlewCorr()
 {
   // Default constructor 
 
@@ -76,6 +86,7 @@ AliT0Parameters::AliT0Parameters()
    }
   SetTimeDelayTVD();
   SetZposition();
+  SetNumberOfTRMs(2);
   
 }
 
@@ -87,31 +98,27 @@ AliT0Parameters::Init()
   // CDB here. 
   //   if (fIsInit) return;
   
-  // AliCDBManager* cdb      = AliCDBManager::Instance();
-  // fCalibentry  = cdb->Get("T0/Calib/Gain_TimeDelay_Slewing_Walk");
 
   AliCDBStorage *stor =AliCDBManager::Instance()->GetStorage("local://$ALICE_ROOT");
   //time equalizing
   AliCDBEntry* fCalibentry  = stor->Get("T0/Calib/TimeDelay",0);
- if (fCalibentry){
+  if (fCalibentry)
    fgCalibData  = (AliT0CalibData*)fCalibentry->GetObject();
-  }
- else 
-   { AliError(" ALARM !!!! No time delays in CDB "); }
+  else 
+    AliError(" ALARM !!!! No time delays in CDB "); 
  //slewing correction
   AliCDBEntry* fSlewCorr  = stor->Get("T0/Calib/Slewing_Walk",0);
- if (fSlewCorr){
-   fgSlewCorr  = (AliT0CalibData*)fSlewCorr->GetObject();
 if (fSlewCorr){
+    fgSlewCorr  = (AliT0CalibData*)fSlewCorr->GetObject();
   }
- // fLookUpentry  = cdb->Get("T0/Calib/LookUp_Table");
   fLookUpentry  = stor->Get("T0/Calib/LookUp_Table",0);
   if (fLookUpentry){
     fgLookUp  = (AliT0CalibData*)fLookUpentry->GetObject();
-    //   fgLookUp->Dump();
   }
   else {
-    fgLookUp->ReadAsciiLookup("$ALICE_ROOT/T0/lookUpTable.txt");
+  const char * filename = gSystem->ExpandPathName("$ALICE_ROOT/T0/lookUpTable.txt");
+  ifstream inFile(filename);
+  fgLookUp->ReadAsciiLookup(filename);
   }
 
   fIsInit = kTRUE;
@@ -234,10 +241,11 @@ void AliT0Parameters::SetWalk(Int_t ipmt)
   string buffer;
   Bool_t down=false;
   
-  ifstream inFile("data/CFD-Amp.txt");
+  const char * filename = gSystem->ExpandPathName("$ALICE_ROOT/T0/data/CFD-Amp.txt");
+  ifstream inFile(filename);
   //  if(!inFile) AliError(Form("Cannot open file %s !",filename));
   
-  Int_t i=0, i1=0, i2=0;
+  Int_t i=0;
   while(getline(inFile,buffer)){
     inFile >> ps >> mv;
 
@@ -249,7 +257,7 @@ void AliT0Parameters::SetWalk(Int_t ipmt)
   TMath::Sort(i, y, index,down);
   Int_t amp=0, iin=0, isum=0, sum=0;
   Int_t ind=0;
-  for (Int_t ii=0; ii<70000; ii++)
+  for (Int_t ii=0; ii<i; ii++)
     {
       ind=index[ii];
       if(y[ind] == amp)
@@ -301,7 +309,6 @@ Float_t AliT0Parameters::GetWalkVal(Int_t ipmt, Float_t mv) const
   return fgCalibData -> GetWalkVal(ipmt, mv) ;
 }
 
-//__________________________________________________________________
 
 //__________________________________________________________________
 void 
@@ -344,3 +351,42 @@ AliT0Parameters::GetChannel(Int_t trm,  Int_t tdc, Int_t chain, Int_t channel)
   
 
 }
+//__________________________________________________________________
+Int_t
+AliT0Parameters::GetNumberOfTRMs() 
+{
+  // return number of trms
+  // 
+  if (!fgLookUp) {
+    fNumberOfTRMs = 2;
+    return  fNumberOfTRMs;
+  } 
+  return  fgLookUp ->GetNumberOfTRMs();
+}
+//________________________________________________________________________________
+Double_t AliT0Parameters::GetZPosition(const char* symname){
+// Get the global z coordinate of the given T0 alignable volume
+//
+  Double_t *tr;
+  
+  cout<<symname<<endl;
+  TGeoPNEntry *pne = gGeoManager->GetAlignableEntry(symname);
+  if (!pne) return 0;
+  
+
+  TGeoPhysicalNode *pnode = pne->GetPhysicalNode();
+  if(pnode){
+          TGeoHMatrix* hm = pnode->GetMatrix();
+           tr = hm->GetTranslation();
+  }else{
+          const char* path = pne->GetTitle();
+          if(!gGeoManager->cd(path)){
+                  AliErrorClass(Form("Volume path %s not valid!",path));
+                  return 0;
+          }
+         tr = gGeoManager->GetCurrentMatrix()->GetTranslation();
+  }
+  return tr[2];
+
+}
+