]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
correct Hash in TMap, reading channel names
authoralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 19 Jul 2007 07:57:56 +0000 (07:57 +0000)
committeralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 19 Jul 2007 07:57:56 +0000 (07:57 +0000)
T0/AliT0CalibData.cxx
T0/AliT0LookUpValue.cxx
T0/AliT0LookUpValue.h
T0/AliT0Parameters.cxx
T0/AliT0Parameters.h
T0/AliT0RawData.cxx

index fe72750cdd476b4acb0e54bce7b1f7a393e55cfb..2dff0cad0f5502ebefae0b30341eb6cf84cfca3b 100644 (file)
@@ -128,24 +128,32 @@ void  AliT0CalibData::PrintLookup(Option_t*, Int_t iTRM, Int_t iTDC, Int_t iChan
   AliT0LookUpValue*  lookvalue= new AliT0LookUpValue();
 
   cout<<" Number Of TRMs in setup "<<GetNumberOfTRMs()<<endl;
-  lookvalue->SetTRM(iTRM);
-  lookvalue->SetTDC(iTDC);
-  lookvalue->SetChain(0);
-  lookvalue->SetChannel(iChannel);
-
-  
-  printf(" AliT0CalibData::PrintLookup ::start GetValue %i %i %i \n",iTRM, iTDC, iChannel);
-  lookkey = (AliT0LookUpKey*) fLookup.GetValue((TObject*)lookvalue);
-  
-
-  if (lookkey)
-    {
-      cout<<" lookup KEY!!! "<<lookkey->GetKey()<<" VALUE "<<lookvalue->GetTRM()<<" "
-         <<lookvalue->GetTDC()<<" "
-         << lookvalue->GetChain()<<" "
+  iTRM=0; iTDC=0; Int_t chain=0; iChannel=0;
+
+  for (Int_t ik=0; ik<105; ik++){
+    lookvalue->SetTRM(iTRM);
+    lookvalue->SetTDC(iTDC);
+    lookvalue->SetChain(chain);
+    lookvalue->SetChannel(iChannel);
+    
+    if (iChannel<6) iChannel +=2;
+    else {iChannel = 0; iTDC++;}
+    if(ik==57) { iTDC=0; iChannel=0; iTRM=1;}
+   
+  printf(" AliT0CalibData::PrintLookup ::start GetValue %i %i %i %i\n",iTRM, iTDC,chain, iChannel);
+    lookkey = (AliT0LookUpKey*) fLookup.GetValue((TObject*)lookvalue);
+    cout<<"  lookkey "<< lookkey<<endl;
+    //    TString name= lookkey->GetChannelName();
+    // cout<<name.Data()<<endl;
+    if (lookkey)
+      {
+       TString name= lookkey->GetChannelName();
+       cout<<" lookup KEY!!! "<<name.Data()<<" "<<lookkey->GetKey()<<" VALUE "<<lookvalue->GetTRM()<<" "
+           <<lookvalue->GetTDC()<<" "
+           << lookvalue->GetChain()<<" "
          <<lookvalue->GetChannel()<<endl;
-    }
-  
+      }
+  }
   
 }
 
@@ -310,6 +318,7 @@ void AliT0CalibData::ReadAsciiLookup(const Char_t *filename)
          lookvalue->SetChain(chain);
          lookvalue->SetChannel(channel);
          lookkey->SetKey(key);
+         lookkey->SetChannelName(varname);
          cout<<"lookup "<<varname<<" "<<key<<" "<<trm<<" "<<chain<<" "<<tdc<<" "<<channel<<endl;         
          
          fLookup.Add((TObject*)lookvalue,(TObject*)lookkey);
index 72e472f50ab8bae7efde366df1bf283eb5aca594..d7c76ffddcab6a043e9cfdeb27bfb87fc0c677d2 100644 (file)
@@ -13,6 +13,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 #include "AliT0LookUpValue.h"
+#include "iostream.h"
 
 ClassImp(AliT0LookUpValue)
 
@@ -27,34 +28,33 @@ ClassImp(AliT0LookUpValue)
 
   ///
 }
-
+//--------------------------------------------------------------------------------------
  AliT0LookUpValue:: AliT0LookUpValue(Int_t trm, Int_t tdc, Int_t chain, Int_t channel) : TObject(),
   fTRM(trm),
   fTDC(tdc),
   fChain(chain),
   fChannel(channel)
 {
+
+//--------------------------------------------------------------------------------------
  
 }
  Bool_t AliT0LookUpValue:: IsEqual(const TObject* obj) const
 {
      AliT0LookUpValue *b = ( AliT0LookUpValue*)obj;
-/*
-printf("IsEqual %i %i\n %i %i\n %i %i\n %i %i\n \n",b->GetTRM(), fTRM, 
-b->GetTDC(), fTDC, b->GetChain(), fChain, b->GetChannel(), fChannel );
-*/
      if ( b->GetTRM() == fTRM && 
          b->GetTDC() == fTDC && 
          b->GetChain() == fChain &&
          b->GetChannel() == fChannel  ) return kTRUE;
      else return kFALSE;
 }
-ULong_t AliT0LookUpValue:: Hash(void) const 
+
+//------------------------------------------------------------------------------------ 
+void AliT0LookUpValue::Print(Option_t *) const
 {
-  ULong_t hash = 1000*fTRM+100*fTDC+10*fChain+1*fChannel;
-  //printf("hash=%i\n",hash);
-  return hash; 
+  printf("AliT0LookUpValue TRM %i, TDC %i, chain %i channel %i\n",fTRM,fTDC,fChain,fChannel);
 }
+//--------------------------------------------------------------------------------------
 
 ClassImp(AliT0LookUpKey)
 
@@ -66,6 +66,7 @@ ClassImp(AliT0LookUpKey)
  
  }
 
+//--------------------------------------------------------------------------------------
  AliT0LookUpKey::AliT0LookUpKey(Int_t key):
    TObject(),
    fKey(key),
@@ -74,6 +75,7 @@ ClassImp(AliT0LookUpKey)
  
  }
 
+//--------------------------------------------------------------------------------------
  AliT0LookUpKey::AliT0LookUpKey(TString name):
    TObject(),
    fKey(),
@@ -81,6 +83,7 @@ ClassImp(AliT0LookUpKey)
  {
  
  }
+//--------------------------------------------------------------------------------------
 
 Bool_t AliT0LookUpKey:: IsEqual(const TObject* obj) const
 {
@@ -89,3 +92,9 @@ Bool_t AliT0LookUpKey:: IsEqual(const TObject* obj) const
     k=((AliT0LookUpKey*)obj)->GetKey();
     if (k==fKey) return kTRUE; else return kFALSE;
 }
+//--------------------------------------------------------------------------------------
+void AliT0LookUpKey::Print(Option_t *) const
+{
+  printf(" AliT0LookUpKey key %i name %s\n",fKey,fName.Data());
+
+}
index 67b8ddd1df97ad19aa71beeb239ac6fbf31b51b6..47e8adc6120ee7a890e5da3115fcabf46aec41d0 100644 (file)
@@ -12,18 +12,19 @@ class AliT0LookUpValue: public TObject
   AliT0LookUpValue(); 
   AliT0LookUpValue(Int_t trm, Int_t tdc, Int_t chain, Int_t channel );
   virtual Bool_t IsEqual(const TObject* obj) const ;
-  virtual ULong_t Hash(void) const;
-  //  virtual ULong_t Hash(void) const {return TString::Hash(this, sizeof(*this));};
-   Int_t GetTRM(void) const {return fTRM;};
-   Int_t GetTDC(void) const {return fTDC;};
-   Int_t GetChain(void) const {return fChain;};
-   Int_t GetChannel(void) const {return fChannel;};
+  virtual ULong_t Hash() const {return (ULong_t) 1000000*fTRM+100000*fTDC+1000*fChannel;}
+  //   virtual ULong_t Hash(void) const {return TString::Hash(this, sizeof(*this));};
+   Int_t GetTRM() const {return fTRM;};
+   Int_t GetTDC() const {return fTDC;};
+   Int_t GetChain() const {return fChain;};
+   Int_t GetChannel() const {return fChannel;};
    void SetTRM(Int_t n) {fTRM=n;};
    void SetTDC(Int_t n) {fTDC=n;};
    void SetChain(Int_t n) {fChain=n;};
    void SetChannel(Int_t n) {fChannel=n;};
-   virtual void Clear (void) {fTRM = -1; fTDC=-1; fChain=-1;  fChannel=-1;}
+   virtual void Clear () {fTRM = -1; fTDC=-1; fChain=-1;  fChannel=-1;}
    void Clear(const Option_t*) {};
+   void Print(Option_t* opt= "") const;
 
  protected:
 
@@ -41,12 +42,14 @@ class AliT0LookUpKey: public TObject
   AliT0LookUpKey();
   AliT0LookUpKey(Int_t key); 
   AliT0LookUpKey(TString name); 
-  Int_t GetKey(void) const {return fKey;};
+  Int_t GetKey() const {return fKey;};
   void SetKey(Int_t n)  {fKey=n;};
   TString GetChannelName() {return fName;};
   void SetChannelName(TString name) {fName = name;};
   virtual Bool_t IsEqual(const TObject *obj) const;
-  virtual ULong_t Hash(void) const {return TString::Hash(this, sizeof(*this));};
+  void Print(Option_t* opt= "") const;
+    virtual ULong_t Hash() const {return 10000*fKey;}
+  //    virtual ULong_t Hash(void) const {return TString::Hash(this, sizeof(*this));};
   //   virtual void Clear(void) {fKey=0;}
  protected:
   Int_t fKey;   //logical channel number
index fd2f306a69f76dd22151eb45aa1add67ae4f1706..8a7e18da5e40bfc66ee79115a3537bbc85d8526f 100644 (file)
@@ -103,23 +103,22 @@ AliT0Parameters::Init()
    if (fIsInit) return;
 
    AliCDBManager *stor =AliCDBManager::Instance();
-
    //time equalizing
-  fCalibentry  = stor->Get("T0/Calib/TimeDelay");
-  if (fCalibentry)
-   fgCalibData  = (AliT0CalibData*)fCalibentry->GetObject();
-  else {
-    AliFatal(" ALARM !!!! No time delays in CDB "); 
-    fIsInit = kFALSE;
-    return;
-  }
+   fCalibentry  = stor->Get("T0/Calib/TimeDelay");
+   if (fCalibentry)
+     fgCalibData  = (AliT0CalibData*)fCalibentry->GetObject();
+   else {
+         AliFatal(" ALARM !!!! No time delays in CDB "); 
+     fIsInit = kFALSE;
+     return;
+   }
  //slewing correction
   fSlewCorr  = stor->Get("T0/Calib/Slewing_Walk");
   if (fSlewCorr){
     fgSlewCorr  = (AliT0CalibData*)fSlewCorr->GetObject();
   }
   else {
-    AliFatal(" ALARM !!!! No slewing correction in CDB "); 
+      AliFatal(" ALARM !!!! No slewing correction in CDB "); 
     fIsInit = kFALSE;
     return;
   }
@@ -129,7 +128,7 @@ AliT0Parameters::Init()
     fgLookUp  = (AliT0CalibData*)fLookUpentry->GetObject();
   }
   else {
-    AliFatal(" ALARM !!!! No Lookup table  in CDB "); 
+     AliFatal(" ALARM !!!! No Lookup table  in CDB "); 
     fIsInit = kFALSE;
     return;
   }
@@ -271,20 +270,18 @@ Int_t
 AliT0Parameters::GetChannel(Int_t trm,  Int_t tdc, Int_t chain, Int_t channel)
 {
 
-  
-  AliT0LookUpKey * lookkey;  //= new AliT0LookUpKey();
-  AliT0LookUpValue * lookvalue= new AliT0LookUpValue(trm,tdc,chain,channel);
+  AliT0LookUpKey * val;  //= new AliT0LookUpKey();
+  AliT0LookUpValue * key= new AliT0LookUpValue(trm,tdc,chain,channel);
   if (fgLookUp)
-       lookkey = (AliT0LookUpKey*) fgLookUp->GetMapLookup()->GetValue((TObject*)lookvalue);
+       val = (AliT0LookUpKey*) fgLookUp->GetMapLookup()->GetValue((TObject*)key);
    else
-   lookkey = (AliT0LookUpKey*) fLookUp.GetValue((TObject*)lookvalue);
-
-  if (!lookkey ) {
+     cout<<" !!!!!!!!! no look up table !!!"<<endl;
+  if (!val ) {
     AliInfo(Form("No such address (%d %d %d %d)!",trm,tdc,chain,channel));
     return -1;
   }
   
-  return lookkey->GetKey();
+  return val->GetKey();
   
 
 }
@@ -310,6 +307,7 @@ AliT0Parameters::GetNumberOfTRMs()
   } 
   return  fgLookUp ->GetNumberOfTRMs();
 }
+/*
 //________________________________________________________________________________
 Double_t AliT0Parameters::GetZPosition(const char* symname){
 // Get the global z coordinate of the given T0 alignable volume
@@ -318,6 +316,33 @@ Double_t AliT0Parameters::GetZPosition(const char* symname){
 
   return tr[2];
 }
+*/
+//________________________________________________________________________________
+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];
+
+}
 //________________________________________________________________________________
 
 Double_t AliT0Parameters::GetZPositionShift(const char* symname)
index 761d08664e223314e777d4e19da2e403085f6b83..45ff52a5eb012ff43d81e03af5f9521a25e049eb 100644 (file)
@@ -74,7 +74,7 @@ public:
   //  void SetMeanT0(Int_t mean=500) { fMeanT0 = mean; };
   Int_t GetMeanT0 (); //{return fMeanT0;};
 
-  TMap * GetMapLookup();
+    TMap * GetMapLookup();
   Int_t GetChannel(Int_t trm,  Int_t tdc, Int_t chain, Int_t channel);
   Int_t GetNumberOfTRMs();
   void SetNumberOfTRMs(Int_t ntrms=2) {fNumberOfTRMs = ntrms;}
index 404121301315ec97b498608ef59da20b232786ad..ca52741379ec95106e34cf3865d99b29b4ad0891 100644 (file)
@@ -99,12 +99,12 @@ uncertances
   for( Int_t iline=0; iline<106; iline++)
     {
       lookvalue = ( AliT0LookUpValue*) iter->Next();
-      lookkey = (AliT0LookUpKey*) lookup->GetValue((TObject*)lookvalue);
-      fLookUp.Add((TObject*)lookkey,(TObject*)lookvalue);
+      lookkey = (AliT0LookUpKey*) lookup->GetValue(lookvalue);
+      fLookUp.Add(lookkey, lookvalue);
       lookkey= new AliT0LookUpKey();
       lookvalue= new AliT0LookUpValue();
     }
+    
 }
 
 //_____________________________________________________________________________
@@ -225,14 +225,11 @@ void AliT0RawData::GetDigits(AliT0digit *fDigits)
   Int_t channel=0;
   Int_t trm1words=0;
   Int_t itrm=0, oldtrm=0;
-  
+  AliT0LookUpKey * lookkey  = new AliT0LookUpKey();
+  AliT0LookUpValue * lookvalue ;//= new AliT0LookUpValue(trm,tdc,chain,channel);
   for (Int_t det = 0; det < 105; det++) {
     time = allData->At(det);
-     if (time >0) {
-      
-      AliT0LookUpKey * lookkey = new AliT0LookUpKey();
-      AliT0LookUpValue * lookvalue ;//= new AliT0LookUpValue(trm,tdc,chain,channel);
+    if (time >0) {
       lookkey->SetKey(det);
       lookvalue = (AliT0LookUpValue*) fLookUp.GetValue((TObject*)lookkey);     
       if (lookvalue ) 
@@ -258,7 +255,6 @@ void AliT0RawData::GetDigits(AliT0digit *fDigits)
          chain = lookvalue->GetChain();
          iTDC = lookvalue->GetTDC();
          channel = lookvalue->GetChannel();
-         //      cout<<det<<" "<<itrm<<" "<<chain<<" "<<iTDC<<" "<<channel<<" time "<<time<<endl;
          FillTime(channel,  iTDC,  time);
        }
       else
@@ -277,7 +273,7 @@ void AliT0RawData::GetDigits(AliT0digit *fDigits)
   WriteTrailer(15,0,fEventNumber,5); // 1st TRM trailer
   
   
- trm1words = fIndex - startTRM;
 trm1words = fIndex - startTRM;
   //space for 2st TRM header
   
   WriteTRMDataHeader(1, trm1words , positionOfTRMHeader);