]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
- fixing bug in clusterizer
authorodjuvsla <odjuvsla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 25 Feb 2010 19:43:51 +0000 (19:43 +0000)
committerodjuvsla <odjuvsla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 25 Feb 2010 19:43:51 +0000 (19:43 +0000)
HLT/BASE/util/AliHLTCaloClusterReader.cxx
HLT/BASE/util/AliHLTESDCaloClusterMaker.cxx
HLT/CALO/AliHLTCaloClusterAnalyser.cxx
HLT/CALO/AliHLTCaloClusterizer.cxx
HLT/PHOS/AliHLTPHOSRawAnalyzerComponentv3.cxx

index 2bc5a3437d533b159e09834aaa36eba0a2a73310..f71a69c03dee489870fd54dd147363a7421c042f 100644 (file)
@@ -64,9 +64,9 @@ AliHLTCaloClusterReader::NextCluster()
 //                                                           + sizeof(AliHLTCaloClusterDataStruct) 
 //                                                           + (fCurrentClusterPtr->fNCells-1)*(sizeof(Float_t) + sizeof(Short_t)));
       fCurrentClusterPtr = reinterpret_cast<AliHLTCaloClusterDataStruct*>(reinterpret_cast<UChar_t*>(fCurrentClusterPtr)
-                                                             + sizeof(AliHLTCaloClusterDataStruct) 
-                                                             + (fCurrentClusterPtr->fNCells-1)*(sizeof(Float_t) + sizeof(Short_t))
-                                                             - sizeof(Short_t)); //TODO: Why?;
+                                                             + sizeof(AliHLTCaloClusterDataStruct) );
+                                                             //+ (fCurrentClusterPtr->fNCells-1)*(sizeof(Float_t) + sizeof(Short_t))
+                                                             //- sizeof(Short_t)); //TODO: Why?;
                                                
                                                              
       // return the cluster
@@ -89,17 +89,30 @@ bool
 AliHLTCaloClusterReader::GetCell(AliHLTCaloClusterDataStruct *clusterPtr, UShort_t &cellId, Double32_t &cellAmp, UInt_t index)
 {
   // See header file for documentation
-
+   UShort_t *tmpId = 0;
+   Float_t *tmpfrac = 0;
   // check if the index is within bounds
-  if(index < clusterPtr->fNCells)
+  //if(index < clusterPtr->fNCells)
+    if(0)
     {
       // the absolute ID is located in the memory address of the first ID plus the size of the pair of cell properties times the index
       //cellId = *(UShort_t*)((UChar_t*)(&(clusterPtr->fCellsAbsId)) + index * (sizeof(Short_t) + sizeof(Float_t)));
-      cellId = * reinterpret_cast<UShort_t*>(reinterpret_cast<UChar_t*>(&(clusterPtr->fCellsAbsId)) + index * (sizeof(Short_t) + sizeof(Float_t)));
-//      printf("CR: Cell ID: %d, cell ID pointer: %x\n", cellId,  reinterpret_cast<UShort_t*>(reinterpret_cast<UChar_t*>(&(clusterPtr->fCellsAbsId)) + index * (sizeof(Short_t) + sizeof(Float_t))));
+      
+      tmpId = reinterpret_cast<UShort_t*>(reinterpret_cast<UChar_t*>(&(clusterPtr->fCellsAbsId)) + index * (sizeof(Short_t) + sizeof(Float_t)));
+      //cellId = * reinterpret_cast<UShort_t*>(reinterpret_cast<UChar_t*>(&(clusterPtr->fCellsAbsId)) + index * (sizeof(Short_t) + sizeof(Float_t)));
+      cellId = *tmpId;
+      //printf("CR: Cell ID: %d, cell ID pointer: %x, # cells: %d\n", cellId,  reinterpret_cast<UShort_t*>(reinterpret_cast<UChar_t*>(&(clusterPtr->fCellsAbsId)) + index * (sizeof(Short_t) + sizeof(Float_t))), clusterPtr->fNCells);
+      //printf("CR: Cell ID: %d, cell ID pointer: %x, # cells: %d\n", cellId,  tmpId, clusterPtr->fNCells);
       // the amplitude fraction is located in the memory address of the first ID plus the size of the pair of cell properties times the index
       //cellAmp = *(Float_t*)((UChar_t*)(&(clusterPtr->fCellsAmpFraction)) + index * (sizeof(Short_t) + sizeof(Float_t)));
-      cellAmp = *reinterpret_cast<Float_t*>(reinterpret_cast<UChar_t*>(&(clusterPtr->fCellsAmpFraction)) + index*(sizeof(Short_t) + sizeof(Float_t)));
+      //cellAmp = *reinterpret_cast<Float_t*>(reinterpret_cast<UChar_t*>(&(clusterPtr->fCellsAmpFraction)) + index*(sizeof(Short_t) + sizeof(Float_t)));
+      //tmpfrac = reinterpret_cast<Float_t*>(reinterpret_cast<UChar_t*>(&(clusterPtr->fCellsAbsId)) + sizeof(Short_t) + index*(sizeof(Short_t) + sizeof(Float_t)));
+      tmpfrac = reinterpret_cast<Float_t*>(tmpId + 1);
+      cellAmp = *tmpfrac;
+      //cellAmp = *reinterpret_cast<Float_t*>(reinterpret_cast<UChar_t*>(&(clusterPtr->fCellsAbsId)) + sizeof(Short_t) + index*(sizeof(Short_t) + sizeof(Float_t)));
+      //printf("CR: cell amp: %f, pointer: %x\n", cellAmp, tmpfrac);
+
+
       return true;
     }
   else return false;
index 4d7ecfd2ef4fdcdd8c47f8259d009f79fd7b7395..6624139781aad7fa12f61363af3846ebdbd4d38d 100644 (file)
@@ -80,14 +80,15 @@ AliHLTESDCaloClusterMaker::FillESD(AliESDEvent *esdPtr, const AliHLTCaloClusterH
       esdCluster.SetNExMax(caloClusterStructPtr->fNExMax);
       esdCluster.SetEmcCpvDistance(caloClusterStructPtr->fEmcCpvDistance);
       esdCluster.SetDistanceToBadChannel(caloClusterStructPtr->fDistToBadChannel);
-      esdCluster.SetNCells(caloClusterStructPtr->fNCells);
+      //esdCluster.SetNCells(caloClusterStructPtr->fNCells);
+      esdCluster.SetNCells(0);
       if(caloClusterStructPtr->GetNTracksMatched())
       {
         TArrayI tracksMatched(caloClusterStructPtr->GetNTracksMatched(), caloClusterStructPtr->fTracksMatched);
         esdCluster.AddTracksMatched(tracksMatched);
       }
 
-      UShort_t *idArrayPtr = new UShort_t[caloClusterStructPtr->fNCells];
+/*      UShort_t *idArrayPtr = new UShort_t[caloClusterStructPtr->fNCells];
       Double32_t *ampFracArrayPtr = new Double32_t[caloClusterStructPtr->fNCells];
       
       for(UInt_t index = 0; index < caloClusterStructPtr->fNCells; index++)
@@ -99,9 +100,9 @@ AliHLTESDCaloClusterMaker::FillESD(AliESDEvent *esdPtr, const AliHLTCaloClusterH
       esdCluster.SetCellsAmplitudeFraction(ampFracArrayPtr);
    
       delete [] idArrayPtr;
-      delete [] ampFracArrayPtr;
-      idArrayPtr = 0;
-      ampFracArrayPtr = 0;
+      delete [] ampFracArrayPtr;*/
+//      idArrayPtr = 0;
+      //ampFracArrayPtr = 0;
       
       esdPtr->AddCaloCluster(&esdCluster);
       //printf("EM: Energy: %f\n", esdCluster.E());
index 4d0f3ecaee80e3cdc679862ae777dfeacb5b0f02..5b9395cc05fbc8a4c3bc25e91489863f8b92883c 100644 (file)
@@ -195,7 +195,7 @@ AliHLTCaloClusterAnalyser::CreateClusters(Int_t nRecPoints, UInt_t availableSize
     {
       if((availableSize - totSize)  < sizeof(AliHLTCaloClusterDataStruct))
       {
-        HLTError("Out of buffer");
+        HLTError("Out of buffer: available size is: %d, total size used: %d", availableSize, totSize);
         return -ENOBUFS;
       }
       
@@ -216,20 +216,21 @@ AliHLTCaloClusterAnalyser::CreateClusters(Int_t nRecPoints, UInt_t availableSize
       HLTDebug("Cluster local position: x = %f, z = %f, module = %d", recPointPtr->fX, recPointPtr->fZ, recPointPtr->fModule);
       HLTDebug("Cluster global position: x = %f, y = %f, z = %f", globalCoord.fX, globalCoord.fY, globalCoord.fZ);
       
-      //caloClusterPtr->fNCells = 0;//recPointPtr->fMultiplicity;
-      caloClusterPtr->fNCells = recPointPtr->fMultiplicity;
+      caloClusterPtr->fNCells = 0;//recPointPtr->fMultiplicity;
+      //caloClusterPtr->fNCells = recPointPtr->fMultiplicity;
 
       caloClusterPtr->fClusterType = fClusterType;
-//      Int_t tmpSize = 0;//totSize + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t));
+      Int_t tmpSize = 0;//totSize + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t));
 
       //TODO remove hardcoded 10; 
       memset(caloClusterPtr->fTracksMatched, 0xff, sizeof(Int_t)*10);
 
-      Int_t tmpSize = totSize + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t));
+      //Int_t tmpSize = totSize + (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t));
+//      Int_t tmpSize = (caloClusterPtr->fNCells-1)*(sizeof(Short_t) + sizeof(Float_t));
 
       if((availableSize - totSize)  < tmpSize)
       {
-        HLTError("Out of buffer");
+        HLTError("Out of buffer, available size is: %d, total size used: %d, extra size needed: %d", availableSize, totSize, tmpSize);
         return -ENOBUFS;
       }
       Int_t *digitIndexPtr = &(recPointPtr->fDigits);
@@ -244,11 +245,14 @@ AliHLTCaloClusterAnalyser::CreateClusters(Int_t nRecPoints, UInt_t availableSize
          *cellAmpFracPtr = digitPtr->fEnergy/recPointPtr->fAmp;
          //printf("Cell ID pointer: %x\n", cellIDPtr);
         //printf("Cell Amp Pointer: %x\n", cellAmpFracPtr);
-        //printf("Digit ID: %d\n", *cellIDPtr);
-         digitPtr++;
-         //cellIDPtr = reinterpret_cast<UShort_t*>(reinterpret_cast<char*>(cellAmpFracPtr) + sizeof(Float_t)); 
-         cellIDPtr = reinterpret_cast<UShort_t*>(reinterpret_cast<char*>(cellIDPtr) + sizeof(Float_t) + sizeof(Short_t)); 
-         cellAmpFracPtr = reinterpret_cast<Float_t*>(reinterpret_cast<char*>(cellAmpFracPtr) + sizeof(Short_t) + sizeof(Float_t));
+        //printf("Cell pos: x = %d, z = %d\n", digitPtr->fX, digitPtr->fZ);
+        //printf("Cell ID: %d, pointer: %x\n", *cellIDPtr, cellIDPtr);
+        //printf("Cell Amp: %f, pointer: %x\n", *cellAmpFracPtr, cellAmpFracPtr);
+         digitPtr++;
+         cellIDPtr = reinterpret_cast<UShort_t*>(reinterpret_cast<char*>(cellAmpFracPtr) + sizeof(Float_t)); 
+        // cellIDPtr = reinterpret_cast<UShort_t*>(reinterpret_cast<char*>(cellIDPtr) + sizeof(Float_t) + sizeof(Short_t)); 
+         //cellAmpFracPtr = reinterpret_cast<Float_t*>(reinterpret_cast<char*>(cellAmpFracPtr) + sizeof(Short_t) + sizeof(Float_t));
+         cellAmpFracPtr = reinterpret_cast<Float_t*>(reinterpret_cast<char*>(cellIDPtr) + sizeof(Short_t));
          
          digitIndexPtr++;
          
index fe06bfe1e2fb484a8c9a72e9eec7f042d6b0df55..38ff7ab4f4bb95a901b5013ec2b36f299f275912 100644 (file)
@@ -72,8 +72,8 @@ AliHLTCaloClusterizer::AliHLTCaloClusterizer(TString det):
   fRecPointArray = new AliHLTCaloRecPointDataStruct*[fArraySize];\r
   \r
   fAvailableSize = sizeof(AliHLTCaloRecPointDataStruct) * 20;\r
-  fRecPointDataPtr = reinterpret_cast<AliHLTCaloRecPointDataStruct*>(new UChar_t[fAvailableSize]);\r
-  fFirstRecPointPtr = fRecPointDataPtr;  \r
+  fFirstRecPointPtr = reinterpret_cast<AliHLTCaloRecPointDataStruct*>(new UChar_t[fAvailableSize]);\r
+  fRecPointDataPtr = fFirstRecPointPtr;  \r
 \r
 }//end\r
 \r
@@ -246,10 +246,11 @@ Int_t AliHLTCaloClusterizer::CheckArray()
 {\r
       if(fArraySize == fNRecPoints)\r
        {\r
+          cout << "Increasing array!" << endl;\r
           fArraySize *= 2;\r
           AliHLTCaloRecPointDataStruct **tmp = new AliHLTCaloRecPointDataStruct*[fArraySize];\r
           memcpy(tmp, fRecPointArray, fArraySize/2 * sizeof(AliHLTCaloRecPointDataStruct*));\r
-          delete fRecPointArray;\r
+          delete [] fRecPointArray;\r
           fRecPointArray = tmp;\r
        }\r
    return 0;\r
@@ -261,6 +262,7 @@ Int_t AliHLTCaloClusterizer::CheckBuffer()
        if((fAvailableSize - fUsedSize) < sizeof(AliHLTCaloRecPointDataStruct))\r
        {\r
            Int_t recPointOffset = reinterpret_cast<UChar_t*>(fRecPointDataPtr) - reinterpret_cast<UChar_t*>(fFirstRecPointPtr);\r
+           Int_t digitIndexOffset = reinterpret_cast<UChar_t*>(fDigitIndexPtr) - reinterpret_cast<UChar_t*>(fRecPointDataPtr);\r
            UChar_t *tmp = new UChar_t[fAvailableSize*2];\r
            memcpy(tmp, fFirstRecPointPtr, fAvailableSize);\r
            fAvailableSize *= 2;\r
@@ -268,9 +270,10 @@ Int_t AliHLTCaloClusterizer::CheckBuffer()
            {\r
               fRecPointArray[n] = reinterpret_cast<AliHLTCaloRecPointDataStruct*>(reinterpret_cast<UChar_t*>(fRecPointArray[n]) - reinterpret_cast<UChar_t*>(fFirstRecPointPtr) + reinterpret_cast<UChar_t*>(tmp));\r
            }\r
-           delete fFirstRecPointPtr;\r
+           delete [] fFirstRecPointPtr;\r
            fFirstRecPointPtr = reinterpret_cast<AliHLTCaloRecPointDataStruct*>(tmp);\r
            fRecPointDataPtr = reinterpret_cast<AliHLTCaloRecPointDataStruct*>(tmp + recPointOffset);\r
+           fDigitIndexPtr = reinterpret_cast<Int_t*>(reinterpret_cast<UChar_t*>(fRecPointDataPtr) + digitIndexOffset);\r
            fUsedSize = 0;\r
        }\r
    return 0;\r
index 76e81128c0e5413f3091200fe0b747af18c50ad9..a78922a4d933779e5074de1ea96b17c0c7baab92 100644 (file)
@@ -27,7 +27,7 @@ AliHLTPHOSRawAnalyzerComponentv3::AliHLTPHOSRawAnalyzerComponentv3() :
    ,fCurrentSpec(-1)
 {
    // See header file for class documentation
-  InitMapping(0);
+   InitMapping(0x1); //using 0x1 to avoid error message
 }
 
 AliHLTPHOSRawAnalyzerComponentv3::~AliHLTPHOSRawAnalyzerComponentv3()
@@ -116,7 +116,6 @@ void AliHLTPHOSRawAnalyzerComponentv3::InitMapping ( const int specification )
 {
    // See header file for class documentation
    fMapperPtr = new AliHLTPHOSMapper;
-   cout << "Initialising mapper..." << endl;
    fMapperPtr->InitDDLSpecificationMapping();
    fMapperPtr->InitAltroMapping(specification);