Fix OCDB induced problem in trigger calculation
authorguernane <guernane@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 26 Apr 2012 13:12:25 +0000 (13:12 +0000)
committerguernane <guernane@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 26 Apr 2012 13:12:25 +0000 (13:12 +0000)
EMCAL/AliEMCALGeometry.cxx
EMCAL/AliEMCALTriggerElectronics.cxx
EMCAL/AliEMCALTriggerElectronics.h
EMCAL/AliEMCALTriggerSTURawStream.cxx
EMCAL/AliEMCALTriggerTRU.cxx

index d750ab2..a980211 100644 (file)
@@ -1439,7 +1439,7 @@ Bool_t AliEMCALGeometry::GetTRUIndexFromOnlineIndex(const Int_t id, Int_t& idx)
                AliError(Form("TRU index out of range: %d",id));
                return kFALSE;
        }
-
+       
        idx = ((id % 6) < 3) ? 6 * int(id / 6) + 2 * (id % 3) : 6 * int(id / 6) + 2 * (2 - (id % 3)) + 1;
 
        return kTRUE;
@@ -1455,7 +1455,7 @@ Int_t AliEMCALGeometry::GetTRUIndexFromOnlineIndex(const Int_t id) const
                AliError(Form("TRU index out of range: %d",id));
        }
        
-       Int_t idx = (id > 15) ? 2 * (31 - id) : 2 * (15 - id) + 1;
+       Int_t idx = ((id % 6) < 3) ? 6 * int(id / 6) + 2 * (id % 3) : 6 * int(id / 6) + 2 * (2 - (id % 3)) + 1;
        
        return idx;
 }
@@ -1471,7 +1471,7 @@ Bool_t AliEMCALGeometry::GetOnlineIndexFromTRUIndex(const Int_t id, Int_t& idx)
                return kFALSE;
        }
        
-       idx = (id % 2) ? int((6 - (id % 6)) / 2) + 3 * (int(id / 6) + 1) : 3 * int(id / 6) + int(id / 2);
+       idx = (id % 2) ? int((6 - (id % 6)) / 2) + 3 * (2 * int(id / 6) + 1) : 3 * int(id / 6) + int(id / 2);
        
        return kTRUE;
 }
@@ -1486,7 +1486,7 @@ Int_t AliEMCALGeometry::GetOnlineIndexFromTRUIndex(const Int_t id) const
                AliError(Form("TRU index out of range: %d",id));
        }
        
-       Int_t idx = (id % 2) ? int((6 - (id % 6)) / 2) + 3 * (int(id / 6) + 1) : 3 * int(id / 6) + int(id / 2);
+       Int_t idx = (id % 2) ? int((6 - (id % 6)) / 2) + 3 * (2 * int(id / 6) + 1) : 3 * int(id / 6) + int(id / 2);
        
        return idx;
 }
index 8e24bc1..4c67bf0 100644 (file)
@@ -42,7 +42,7 @@ Author: R. GUERNANE LPSC Grenoble CNRS/IN2P3
 
 namespace
 {
-       const Int_t kNTRU = 30;
+       const Int_t kNTRU = 32;
 }
 
 ClassImp(AliEMCALTriggerElectronics)
@@ -50,19 +50,30 @@ ClassImp(AliEMCALTriggerElectronics)
 //__________________
 AliEMCALTriggerElectronics::AliEMCALTriggerElectronics(const AliEMCALTriggerDCSConfig *dcsConf) : TObject(),
 fTRU(new TClonesArray("AliEMCALTriggerTRU",32)),
-fSTU(0x0)
+fSTU(0x0),
+fGeometry(0)
 {
        // Ctor
        
        TVector2 rSize;
        
        rSize.Set( 24.,  4. );
-
+       
+       AliRunLoader *rl = AliRunLoader::Instance();
+       if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL")) {
+               AliEMCAL *emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
+               if (emcal) fGeometry = emcal->GetGeometry();
+       }
+       
+       if (!fGeometry) {               
+               fGeometry =  AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
+               AliError("Cannot access geometry, create a new default one!");
+       }
+       
        // 32 TRUs
-       for (Int_t i=0;i<kNTRU;i++) 
-       {
-               AliEMCALTriggerTRUDCSConfig* truConf = dcsConf->GetTRUDCSConfig(i);
-               new ((*fTRU)[i]) AliEMCALTriggerTRU(truConf, rSize, i % 2);
+       for (Int_t i = 0; i < kNTRU; i++) {
+               AliEMCALTriggerTRUDCSConfig *truConf = dcsConf->GetTRUDCSConfig(fGeometry->GetOnlineIndexFromTRUIndex(i));
+               if (truConf) new ((*fTRU)[i]) AliEMCALTriggerTRU(truConf, rSize, i % 2);
        }
        
        rSize.Set( 48., 64. );
@@ -72,11 +83,16 @@ fSTU(0x0)
        fSTU = new AliEMCALTriggerSTU(stuConf, rSize);
        
        TString str = "map";
-       for (Int_t i=0;i<kNTRU;i++) fSTU->Build(str,
-                                                                                       i,
-                                                                                       (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->Map(),
-                                                                                       (static_cast<AliEMCALTriggerTRU*>(fTRU->At(i)))->RegionSize() 
-                                                                                   );
+       for (Int_t i = 0; i < kNTRU; i++) {
+               AliEMCALTriggerTRU *iTRU = static_cast<AliEMCALTriggerTRU*>(fTRU->At(i));
+               if (!iTRU) continue;
+
+               fSTU->Build(str,
+                                       i,
+                                       iTRU->Map(),
+                                       iTRU->RegionSize() 
+                                       );
+       }
 }
 
 //________________
@@ -92,18 +108,6 @@ AliEMCALTriggerElectronics::~AliEMCALTriggerElectronics()
 void AliEMCALTriggerElectronics::Digits2Trigger(TClonesArray* digits, const Int_t V0M[], AliEMCALTriggerData* data)
 {
        // Digits to trigger
-
-       AliEMCALGeometry* geom = 0x0;
-       
-       AliRunLoader *rl = AliRunLoader::Instance();
-       if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL")){
-         AliEMCAL* emcal = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"));
-         if(emcal)geom = emcal->GetGeometry();
-       }
-       
-       if(!geom) geom =  AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName());
-       
-       if(!geom) AliError("Cannot access geometry!");
        
        Int_t pos, px, py, id; 
        
@@ -122,9 +126,9 @@ void AliEMCALTriggerElectronics::Digits2Trigger(TClonesArray* digits, const Int_
                
                Int_t iTRU, iADC;
                
-               Bool_t isOK1 = geom->GetTRUFromAbsFastORIndex(id, iTRU, iADC);
+               Bool_t isOK1 = fGeometry->GetTRUFromAbsFastORIndex(id, iTRU, iADC);
                
-               if ((isOK1 && iTRU >= kNTRU) || !isOK1) continue;
+               if (!isOK1) continue;
 
                for (Int_t j = 0; j < digit->GetNSamples(); j++)
                {
@@ -141,18 +145,19 @@ void AliEMCALTriggerElectronics::Digits2Trigger(TClonesArray* digits, const Int_
                        }
                }
                
-               if (geom->GetPositionInEMCALFromAbsFastORIndex(id, px, py)) posMap[px][py] = i;
+               if (fGeometry->GetPositionInEMCALFromAbsFastORIndex(id, px, py)) posMap[px][py] = i;
        }
 
        Int_t iL0 = 0;
 
        Int_t timeL0[kNTRU] = {0}, timeL0min = 999;
        
-       for (Int_t i=0; i<kNTRU; i++) 
+       for (Int_t i = 0; i < kNTRU; i++) 
        {
-               AliDebug(999, Form("===========< TRU %2d >============", i));
+               AliEMCALTriggerTRU *iTRU = static_cast<AliEMCALTriggerTRU*>(fTRU->At(i));
+               if (!iTRU) continue;
                
-               AliEMCALTriggerTRU* iTRU = static_cast<AliEMCALTriggerTRU*>(fTRU->At(i));
+               AliDebug(999, Form("===========< TRU %2d >============", i));
                
                if (iTRU->L0()) // L0 recomputation: *ALWAYS* done from FALTRO
                {
@@ -170,7 +175,7 @@ void AliEMCALTriggerElectronics::Digits2Trigger(TClonesArray* digits, const Int_
                        data->SetL0Trigger(0, i, 0);
        }
 
-       AliDebug(999, Form("=== %2d TRU (out of %2d) has issued a L0 / Min L0 time: %d", iL0, kNTRU, timeL0min));
+       AliDebug(999, Form("=== %2d TRU (out of %2d) has issued a L0 / Min L0 time: %d", iL0, fTRU->GetEntriesFast(), timeL0min));
        
        AliEMCALTriggerRawDigit* dig = 0x0;
        
@@ -180,7 +185,8 @@ void AliEMCALTriggerElectronics::Digits2Trigger(TClonesArray* digits, const Int_
                for (Int_t i = 0; i < kNTRU; i++)
                {
                        AliEMCALTriggerTRU *iTRU = static_cast<AliEMCALTriggerTRU*>(fTRU->At(i));
-
+                       if (!iTRU) continue;
+                       
                        Int_t reg[24][4];
                        for (int j = 0; j < 24; j++) for (int k = 0; k < 4; k++) reg[j][k] = 0;
                                        
@@ -192,9 +198,9 @@ void AliEMCALTriggerElectronics::Digits2Trigger(TClonesArray* digits, const Int_
                                {
                                        if (reg[j][k]
                                                && 
-                                               geom->GetAbsFastORIndexFromPositionInTRU(i, j, k, id)
+                                               fGeometry->GetAbsFastORIndexFromPositionInTRU(i, j, k, id)
                                                &&
-                                               geom->GetPositionInEMCALFromAbsFastORIndex(id, px, py))
+                                               fGeometry->GetPositionInEMCALFromAbsFastORIndex(id, px, py))
                                        {
                                                pos = posMap[px][py];
                                                                        
@@ -226,7 +232,8 @@ void AliEMCALTriggerElectronics::Digits2Trigger(TClonesArray* digits, const Int_
        {
                for (Int_t i = 0; i < kNTRU; i++)
                {
-                       AliEMCALTriggerTRU* iTRU = static_cast<AliEMCALTriggerTRU*>(fTRU->At(i));
+                       AliEMCALTriggerTRU *iTRU = static_cast<AliEMCALTriggerTRU*>(fTRU->At(i));
+                       if (!iTRU) continue;
                        
                        AliDebug(999, Form("=== TRU# %2d found %d patches", i, (iTRU->Patches()).GetEntriesFast()));
                        
@@ -236,9 +243,9 @@ void AliEMCALTriggerElectronics::Digits2Trigger(TClonesArray* digits, const Int_
                                p->Position(px, py);
                        
                                // Local 2 Global
-                               if (geom->GetAbsFastORIndexFromPositionInTRU(i, px, py, id) 
+                               if (fGeometry->GetAbsFastORIndexFromPositionInTRU(i, px, py, id) 
                                        && 
-                                       geom->GetPositionInEMCALFromAbsFastORIndex(id, px, py)) p->SetPosition(px, py);
+                                       fGeometry->GetPositionInEMCALFromAbsFastORIndex(id, px, py)) p->SetPosition(px, py);
                                
                                if (AliDebugLevel()) p->Print("");
                                
@@ -351,7 +358,7 @@ void AliEMCALTriggerElectronics::Digits2Trigger(TClonesArray* digits, const Int_
                        
                        if (AliDebugLevel()) p->Print("");
                        
-                       if (geom->GetAbsFastORIndexFromPositionInEMCAL(px, py, id))
+                       if (fGeometry->GetAbsFastORIndexFromPositionInEMCAL(px, py, id))
                        {
                                if (posMap[px][py] == -1)
                                {
@@ -387,7 +394,7 @@ void AliEMCALTriggerElectronics::Digits2Trigger(TClonesArray* digits, const Int_
                        
                        if (AliDebugLevel()) p->Print("");
                        
-                       if (geom->GetAbsFastORIndexFromPositionInEMCAL(px, py, id))
+                       if (fGeometry->GetAbsFastORIndexFromPositionInEMCAL(px, py, id))
                        {
                                if (posMap[px][py] == -1)
                                {
index a486f88..1a46c26 100644 (file)
@@ -21,6 +21,7 @@ class AliEMCALTriggerSTU;
 class AliESDVZERO;
 class AliEMCALTriggerTRU;
 class TTree;
+class AliEMCALGeometry;
 
 class AliEMCALTriggerElectronics : public TObject 
 {
@@ -41,7 +42,8 @@ private:
 
        TClonesArray*        fTRU; // 32 TRU
        AliEMCALTriggerSTU*  fSTU; //  1 STU
-               
+       AliEMCALGeometry     *fGeometry; // EMCal geometry
+       
   ClassDef(AliEMCALTriggerElectronics,1)
 };
 
index 9c47bc1..4639e9f 100644 (file)
@@ -282,8 +282,6 @@ Bool_t AliEMCALTriggerSTURawStream::ReadPayLoad()
                        
                        break;
                }
-               default:
-                       AliError(Form("STU payload size not found! %d word32", iword));
        }
        
 //     jetSize += (fFwVersion >> 16);
index 23e7fcb..d654708 100644 (file)
@@ -167,11 +167,14 @@ Int_t AliEMCALTriggerTRU::L0()
        
        AliDebug(999,Form("=== TRU fw version %x ===",fDCSConfig->GetFw()));
        
-//     if (fDCSConfig->GetFw() < 0x4d) {
+       if (fDCSConfig->IsA()->GetClassVersion() >= 3) {
+               if (fDCSConfig->GetFw() < 0x4d) {
+                       return L0v0(nb, ma);
+               } else {
+                       return L0v1(nb, ma);
+               }
+       } else
                return L0v0(nb, ma);
-//     } else {
-//             return L0v1(nb, ma);
-//     }
 }
 
 //________________