]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Removing quick code hack and unnecessary methods. Now have a much cleaner implementat...
authorszostak <szostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 27 Sep 2007 19:40:13 +0000 (19:40 +0000)
committerszostak <szostak@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 27 Sep 2007 19:40:13 +0000 (19:40 +0000)
HLT/MUON/OnlineAnalysis/AliHLTMUONTriggerReconstructor.cxx
HLT/MUON/OnlineAnalysis/AliHLTMUONTriggerReconstructor.h
HLT/MUON/OnlineAnalysis/AliHLTMUONTriggerReconstructorComponent.cxx
HLT/MUON/OnlineAnalysis/AliHLTMUONTriggerReconstructorComponent.h

index 3d09bc42cb40cb335212264f51272397ba64d4ef..8d2caf6c6eef3219cca9de180f1ebb9be30acfaa 100644 (file)
@@ -51,8 +51,8 @@ const int AliHLTMUONTriggerReconstructor::fgkOddLutSize = 2528735 + 1;
 
 const int AliHLTMUONTriggerReconstructor::fgkLutLine = 10496;
 
-const int AliHLTMUONTriggerReconstructor::fgkMinIdManuChannel[2] = {819616, 862288};
-const int AliHLTMUONTriggerReconstructor::fgkMaxIdManuChannel[2] = {3421966, 3391022};
+const int AliHLTMUONTriggerReconstructor::fgkMinIdUnique[2] = {819616, 862288};
+const int AliHLTMUONTriggerReconstructor::fgkMaxIdUnique[2] = {3421966, 3391022};
 
 const float AliHLTMUONTriggerReconstructor::fgkHalfPadSizeXB[3] = {8.5, 17.0, 25.5};
 const float AliHLTMUONTriggerReconstructor::fgkHalfPadSizeYNB[2] = {25.5, 34.0};
@@ -60,37 +60,22 @@ const float AliHLTMUONTriggerReconstructor::fgkHalfPadSizeYNB[2] = {25.5, 34.0};
 const int AliHLTMUONTriggerReconstructor::fgkDetElem = 9*4 ; // 9 detele per half chamber
 
 
-AliHLTMUONTriggerReconstructor::AliHLTMUONTriggerReconstructor()
-  :
-  fPadData(NULL),
-  fLookUpTableData(NULL),
-  fRecPoints(NULL),
-  fRecPointsCount(NULL),
-  fMaxRecPointsCount(0),
-  fMaxFiredPerDetElem(),
-  fDetElemToDataId(),
-  fDDLId(0),
-  fIdOffSet(0),
-  fTrigRecId(0)
+AliHLTMUONTriggerReconstructor::AliHLTMUONTriggerReconstructor() :
+       fLookUpTableData(NULL),
+       fMaxRecPointsCount(0),
+       fDDLId(0),
+       fIdOffSet(0),
+       fTrigRecId(0)
 {
-  // ctor 
-  
-  if(AliHLTMUONTriggerReconstructor::fgkEvenLutSize > AliHLTMUONTriggerReconstructor::fgkOddLutSize){
-    fPadData = new AliHLTMUONHitReconstructor::DHLTPad[AliHLTMUONTriggerReconstructor::fgkEvenLutSize];
-  }
-  else{
-    fPadData = new AliHLTMUONHitReconstructor::DHLTPad[AliHLTMUONTriggerReconstructor::fgkOddLutSize];
-  }
-
-  bzero(fGetIdTotalData,104*64*2*sizeof(int));
+       // ctor
 }
 
 
 AliHLTMUONTriggerReconstructor::~AliHLTMUONTriggerReconstructor()
 {
-  // dtor
-  delete []fPadData;
-  delete []fLookUpTableData;
+       // dtor
+       if (fLookUpTableData != NULL)
+               delete [] fLookUpTableData;
 }
 
 bool AliHLTMUONTriggerReconstructor::SetRegToLocCardMap(RegToLoc* regToLoc)
@@ -117,9 +102,9 @@ bool AliHLTMUONTriggerReconstructor::LoadLookUpTable(AliHLTMUONHitReconstructor:
 
   int lutSize = ((lookUpTableId%2)==0) ? fgkEvenLutSize : fgkOddLutSize ;
   int nofLutLine = fgkLutLine ;
-  fIdOffSet = fgkMinIdManuChannel[lookUpTableId%2];
+  fIdOffSet = fgkMinIdUnique[lookUpTableId%2];
 
-  int detManuChannelId;
+  int detUniqueId;
 
   fLookUpTableData = new AliHLTMUONHitReconstructor::DHLTLut[lutSize];
 
@@ -127,69 +112,37 @@ bool AliHLTMUONTriggerReconstructor::LoadLookUpTable(AliHLTMUONHitReconstructor:
 
   for(int i=0; i<nofLutLine; i++){
 
-    detManuChannelId = lookUpTableData[i].fIdManuChannel - fIdOffSet + 1;
-    fLookUpTableData[detManuChannelId].fIdManuChannel = lookUpTableData[i].fIdManuChannel - fIdOffSet;
-    fLookUpTableData[detManuChannelId].fIX = lookUpTableData[i].fIX ;
-    fLookUpTableData[detManuChannelId].fIY = lookUpTableData[i].fIY ;
-    fLookUpTableData[detManuChannelId].fRealX = lookUpTableData[i].fRealX ;
-    fLookUpTableData[detManuChannelId].fRealY = lookUpTableData[i].fRealY ;
-    fLookUpTableData[detManuChannelId].fRealZ = lookUpTableData[i].fRealZ ;
-    fLookUpTableData[detManuChannelId].fPcbZone = lookUpTableData[i].fPcbZone ;
-    fLookUpTableData[detManuChannelId].fPlane = lookUpTableData[i].fPlane ;
+    detUniqueId = lookUpTableData[i].fIdManuChannel - fIdOffSet + 1;
+    fLookUpTableData[detUniqueId].fIdManuChannel = lookUpTableData[i].fIdManuChannel - fIdOffSet;
+    fLookUpTableData[detUniqueId].fIX = lookUpTableData[i].fIX ;
+    fLookUpTableData[detUniqueId].fIY = lookUpTableData[i].fIY ;
+    fLookUpTableData[detUniqueId].fRealX = lookUpTableData[i].fRealX ;
+    fLookUpTableData[detUniqueId].fRealY = lookUpTableData[i].fRealY ;
+    fLookUpTableData[detUniqueId].fRealZ = lookUpTableData[i].fRealZ ;
+    fLookUpTableData[detUniqueId].fPcbZone = lookUpTableData[i].fPcbZone ;
+    fLookUpTableData[detUniqueId].fPlane = lookUpTableData[i].fPlane ;
   }
-  return true;
-
+  
   return true;
 }
 
 bool AliHLTMUONTriggerReconstructor::Run(
                const AliHLTUInt32_t* rawData,
-               AliHLTUInt32_t rawDataSize,
+               // TODO: if we are not checking rawDataSize then it means we are
+               // not parsing the raw data safely or checking for corruption carefully.
+               // This must be fixed at some point.
+               AliHLTUInt32_t /*rawDataSize*/,
                AliHLTMUONTriggerRecordStruct* trigRecord,
-               AliHLTUInt32_t& nofTrigRec
+               AliHLTUInt32_t& nofTrigRec,
+               bool suppressPartialTrigs
        )
 {
-
-  fRecPoints = trigRecord;
   fMaxRecPointsCount = nofTrigRec;
-  fRecPointsCount = &nofTrigRec;
-  *fRecPointsCount = 0;
-  fMaxFiredPerDetElem.clear();
-  fDetElemToDataId.clear();
-
-  fPadData[0].fDetElemId = 0;
-  fPadData[0].fBuspatchId = 0;
-  fPadData[0].fIdManuChannel = 0;
-  fPadData[0].fIX = 0 ;
-  fPadData[0].fIY = 0 ;
-  fPadData[0].fRealX = 0.0 ;
-  fPadData[0].fRealY = 0.0 ;
-  fPadData[0].fRealZ = 0.0 ;
-  fPadData[0].fPlane = -1 ;
-  fPadData[0].fPcbZone = -1 ;
-  fPadData[0].fCharge = 0 ;
   
-  if(!ReadDDL(rawData, rawDataSize)){
-    HLTError("Failed to read the complete DDL file\n");
-    return false;
-  }
-
-  if(!FindTrigHits()){
-    HLTError("Failed to generate RecHits\n");
-    return false;
-  }
-    
-  return true;
-}
-
-
-bool AliHLTMUONTriggerReconstructor::ReadDDL(
-               const AliHLTUInt32_t* rawData,
-               AliHLTUInt32_t /*rawDataSize*/
-       )
-{
-
-  int idManuChannel ;
+  // nofTrigRec now becomes the output of how many trigger records were found.
+  nofTrigRec = 0;
+  
+  int lutAddress;
   
   int index = 0;
   int dataCount = 0;
@@ -203,8 +156,7 @@ bool AliHLTMUONTriggerReconstructor::ReadDDL(
 
   int shiftIndex = 10 - 6 - 1; // the one comes due to indexing from zero
 
-  DataIdIndex dataIndex;
-#ifdef DEBUG
+#ifdef __DEBUG
   int globalcard_data_occurance = (rawData[index]>>10)&0x1; //Set to 1 if global info present in DDL else set to 0 
   int version = (rawData[index]>>12)&0xFF; // software version
   int serial_number =  (rawData[index]>>20)&0xF; // serial number set to 0xF 
@@ -212,7 +164,8 @@ bool AliHLTMUONTriggerReconstructor::ReadDDL(
   int phys_trig_occur = (rawData[index]>>30)&0x1; // 1 for physics trigger, 0 for software trigger
   
   HLTDebug("globalcard_data_occurance  %d, version  %d, serial_number  %d, phys_trig_occur  %d",
-        globalcard_data_occurance,version,serial_number,phys_trig_occur);
+        globalcard_data_occurance,version,serial_number,phys_trig_occur
+  );
 
   if(!phys_trig_occur) // for software trigger
     index += 8 ;// corresponding to scalar words
@@ -224,7 +177,7 @@ bool AliHLTMUONTriggerReconstructor::ReadDDL(
   index += 1 ; // reaches to global output
   
   if((fDDLId - AliHLTMUONTriggerReconstructor::fgkDDLOffSet) == 0){ //if globalData is present in DDL 0 (presummed may be changed)
-#ifdef DEBUG
+#ifdef __DEBUG
     int singleLpt = rawData[index] & 0x1;
     int singleHpt = (rawData[index] >> 1) & 0x1;
     
@@ -235,11 +188,12 @@ bool AliHLTMUONTriggerReconstructor::ReadDDL(
     int pairLikeHpt = (rawData[index] >> 3)  & 0x1;
 #endif
     HLTDebug("singleLpt : %x, singleHpt : %x, pairUnlikeLpt : %x, pairUnlikeHpt : %x, pairLikeLpt : %x, pairLikeHpt : %x",
-            singleLpt,singleHpt,pairUnlikeLpt,pairUnlikeHpt,pairLikeLpt,pairLikeHpt);
+            singleLpt,singleHpt,pairUnlikeLpt,pairUnlikeHpt,pairLikeLpt,pairLikeHpt
+    );
   }
 
   if(!phys_trig_occur)
-    index += 10 ;// corresponds to scalar words
+    index += 10// corresponds to scalar words
 
   index += 1; // separator 0xDEADBEEF 
 
@@ -256,24 +210,24 @@ bool AliHLTMUONTriggerReconstructor::ReadDDL(
     if(!reg_phys_trig_occur)
       index += 10;
     
-    index += 1 ; // end of Regeonal header 0xBEEFFACE
+    index += 1; // end of Regeonal header 0xBEEFFACE
 
     for(int iLoc = 0; iLoc < 16 ; iLoc++){
 
-      iLocIndex = index ;      
+      iLocIndex = index;      
 
       loc = (rawData[index+5] >> 19) &  0xF ;
       
       locDec = (rawData[index+5] >> 15) & 0xF;
-      triggY = (rawData[index+5] >> 14) & 0x1 ;
+      triggY = (rawData[index+5] >> 14) & 0x1;
       sign = (rawData[index+5] >> 9) & 0x1;
       loDev = (rawData[index+5] >> 5) & 0xF ;
-      triggX = (loDev >> 4 & 0x1 ) && !(loDev & 0xF) ;
+      triggX = (loDev >> 4 & 0x1 ) && !(loDev & 0xF);
 
       if( locDec != 0x9 ){ // check for Dec
        
        iRegLoc = iReg*16 + iLoc;
-       locId = fRegToLocCard[iRegLoc].fLocId 
+       locId = fRegToLocCard[iRegLoc].fLocId; 
        
        if(locId<=234){ // to avoid the copy locCards
          
@@ -290,20 +244,33 @@ bool AliHLTMUONTriggerReconstructor::ReadDDL(
          index += 1; 
          pattern[1][2] = rawData[index] & 0xFFFF; 
          pattern[1][3] = (rawData[index] >> 16) & 0xFFFF; 
-         
-         if(pattern[0][0] || pattern[0][1] || pattern[0][2] || pattern[0][3]
-            || pattern[1][0] || pattern[1][1] || pattern[1][2] || pattern[1][3]
-            ){
+
+         if (pattern[0][0] || pattern[0][1] || pattern[0][2] || pattern[0][3]
+             || pattern[1][0] || pattern[1][1] || pattern[1][2] || pattern[1][3]
+            )
+         {
+           if (nofTrigRec == fMaxRecPointsCount) {
+             HLTError("Output buffer is overflowed maximum assiged arraysize : %d, present array index : %d",
+                      fMaxRecPointsCount, nofTrigRec
+             );
+             return false;
+           }
 
            HLTDebug("iReg: %d, iLoc :%d, locId : %d,X : %x, %x, %x, %x ...Y : %x, %x, %x, %x",
                    iReg,iLoc,locId,pattern[0][0],pattern[0][1],pattern[0][2],pattern[0][3],
-                   pattern[1][0],pattern[1][1],pattern[1][2],pattern[1][3]);
+                   pattern[1][0],pattern[1][1],pattern[1][2],pattern[1][3]
+           );
+
+           // hitset indicates which hits on chambers 7 to 10 have been found and filled.
+           bool hitset[4] = {false, false, false, false};
 
            for(int iChamber = 0; iChamber < 4 ; iChamber++){ //4 chambers per DDL 
              for(int iPlane = 0; iPlane < 2 ; iPlane++){// 2 cathode plane
                if(pattern[iPlane][iChamber]){
                  detElemId = fRegToLocCard[iRegLoc].fDetElemId[iChamber];
+                 
                  HLTDebug("\tdetElemId : %d\n",detElemId);
+                 
                  for (Int_t ibitxy = 0; ibitxy < 16; ++ibitxy) {
                    if ((pattern[iPlane][iChamber] >> ibitxy) & 0x1) {
          
@@ -316,58 +283,35 @@ bool AliHLTMUONTriggerReconstructor::ReadDDL(
                      
                      idetElemId = detElemId%1000;
 
-                     idetElemId &= 0x1FF ;
-                     iPlane &= 0x1 ;
-                     locId &= 0xFF ;
-                     secondLocation &= 0xF ;
+                     idetElemId &= 0x1FF;
+                     iPlane &= 0x1;
+                     locId &= 0xFF;
+                     secondLocation &= 0xF;
                      
-                     idManuChannel &= 0x0;
-                     idManuChannel = (idManuChannel|idetElemId)<<1;  
-                     idManuChannel = (idManuChannel|iPlane)<<8;  
-                     idManuChannel = (idManuChannel|locId)<<4 ;
-                     idManuChannel |= secondLocation  ;
+                     lutAddress &= 0x0;
+                     lutAddress = (lutAddress|idetElemId)<<1;  
+                     lutAddress = (lutAddress|iPlane)<<8;  
+                     lutAddress = (lutAddress|locId)<<4;
+                     lutAddress |= secondLocation;
 
-                     idManuChannel -= fIdOffSet ;
+                     lutAddress -= fIdOffSet;
                      
-                     if(fLookUpTableData[idManuChannel+1].fIdManuChannel == -1) //skip uninitialized values
+                     if(fLookUpTableData[lutAddress+1].fIdManuChannel == -1) //skip uninitialized values
                        continue;
-
-                     fPadData[idManuChannel].fDetElemId = detElemId;
-                     fPadData[idManuChannel].fIdManuChannel = idManuChannel;
-                     fPadData[idManuChannel].fIX = fLookUpTableData[idManuChannel+1].fIX;
-                     fPadData[idManuChannel].fIY = fLookUpTableData[idManuChannel+1].fIY;
-                     fPadData[idManuChannel].fRealX = fLookUpTableData[idManuChannel+1].fRealX;
-                     fPadData[idManuChannel].fRealY = fLookUpTableData[idManuChannel+1].fRealY;
-                     fPadData[idManuChannel].fRealZ = fLookUpTableData[idManuChannel+1].fRealZ;
-                     fPadData[idManuChannel].fPcbZone = fLookUpTableData[idManuChannel+1].fPcbZone;
-                     fPadData[idManuChannel].fPlane = fLookUpTableData[idManuChannel+1].fPlane;
-                     
-                     // !!!!!!!!!!!! THIS IS A COMPLETE HACK !!!!!!!!!
-                     // Have to use fBuspatchId to store the chamber number,
-                     // and fCharge as the trigger records ID number.
-                     // This must be fixed in the future by using more appropriate
-                     // structures.
-                     fPadData[idManuChannel].fBuspatchId = iChamber;
-                     fPadData[idManuChannel].fCharge = fTrigRecId;
-                     // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-                     HLTDebug("\t Hit Found fo ich : %d, iPlane : %d, detelem %d, id : %d, at (%lf, %lf, %lf) cm"
-                             ,iChamber,fLookUpTableData[idManuChannel+1].fPlane,detElemId,fLookUpTableData[idManuChannel+1].fIdManuChannel,
-                             fPadData[idManuChannel].fRealX,
-                             fPadData[idManuChannel].fRealY,fPadData[idManuChannel].fRealZ);
-                             
-                     if(fMaxFiredPerDetElem[detElemId] == 0){
-                       DataIdIndex first;
-                       first.push_back(idManuChannel);
-                       fDetElemToDataId[detElemId] = first;
-                     }else{
-                       dataIndex =  fDetElemToDataId[detElemId];
-                       dataIndex.push_back(idManuChannel);
-                       fDetElemToDataId[detElemId] = dataIndex;
-                     }
-
-                     fMaxFiredPerDetElem[detElemId] = fMaxFiredPerDetElem[detElemId] + 1;
-
-                     dataCount ++;
+                       
+                     hitset[iChamber] = true;
+                     trigRecord[nofTrigRec].fHit[iChamber].fX = fLookUpTableData[lutAddress+1].fRealX;
+                     trigRecord[nofTrigRec].fHit[iChamber].fY = fLookUpTableData[lutAddress+1].fRealY;
+                     trigRecord[nofTrigRec].fHit[iChamber].fZ = fLookUpTableData[lutAddress+1].fRealZ;
+
+                     HLTDebug("\t Hit Found fo ich : %d, iPlane : %d, detelem %d, id : %d, at (%lf, %lf, %lf) cm",
+                              iChamber,fLookUpTableData[lutAddress+1].fPlane,detElemId,fLookUpTableData[lutAddress+1].fIdUnique,
+                              fLookUpTableData[lutAddress+1].fRealX,
+                              fLookUpTableData[lutAddress+1].fRealY,
+                              fLookUpTableData[lutAddress+1].fRealZ
+                     );
+                     
+                     dataCount++;
                      
                    }//pattern maching is found 
                  }// loop of ibitxy
@@ -375,22 +319,83 @@ bool AliHLTMUONTriggerReconstructor::ReadDDL(
              }// iplane
            }// ichamber
            
+             {
+               // Make sure the hits that are not set, get set to a nil value.
+               for (int i = 0; i < 4; i++)
+               {
+                       if (not hitset[i])
+                       {
+                               trigRecord[nofTrigRec].fHit[i]
+                                       = AliHLTMUONConstants::NilRecHitStruct();
+                       }
+               }
+
+               trigRecord[nofTrigRec].fId = fTrigRecId;
+           
                // Increment trigger record Id and keep it positive.
                //TODO: handle the wrapparound better.
                if (fTrigRecId < 0x7FFFFFFF)
                        fTrigRecId++;
                else
                        fTrigRecId = 0;
+               
+               AliHLTMUONRecHitStruct* hit1 = NULL;
+               if (hitset[0])
+                       hit1 = &trigRecord[nofTrigRec].fHit[0];
+               else if (hitset[1])
+                       hit1 = &trigRecord[nofTrigRec].fHit[1];
+               AliHLTMUONRecHitStruct* hit2 = NULL;
+               if (hitset[2])
+                       hit2 = &trigRecord[nofTrigRec].fHit[2];
+               else if (hitset[3])
+                       hit2 = &trigRecord[nofTrigRec].fHit[3];
+               
+               if (hit1 != NULL and hit2 != NULL)
+               {
+                       // Calculate the momentum and fill in the flags and momentum fields.
+                       AliHLTMUONCalculations::ComputeMomentum(
+                                       hit1->fX,
+                                       hit1->fY, hit2->fY,
+                                       hit1->fZ, hit2->fZ
+                               );
+                       trigRecord[nofTrigRec].fPx = AliHLTMUONCalculations::Px();
+                       trigRecord[nofTrigRec].fPy = AliHLTMUONCalculations::Py();
+                       trigRecord[nofTrigRec].fPz = AliHLTMUONCalculations::Pz();
+
+                       trigRecord[nofTrigRec].fFlags =
+                               AliHLTMUONUtils::PackTriggerRecordFlags(
+                                       AliHLTMUONCalculations::Sign(),
+                                       hitset
+                               );
+                       
+                       nofTrigRec++;
+               }
+               else if ((hit1 != NULL or hit2 != NULL) and not suppressPartialTrigs)
+               {
+                       trigRecord[nofTrigRec].fPx = 0;
+                       trigRecord[nofTrigRec].fPy = 0;
+                       trigRecord[nofTrigRec].fPz = 0;
+
+                       trigRecord[nofTrigRec].fFlags =
+                               AliHLTMUONUtils::PackTriggerRecordFlags(
+                                       kSignUnknown,
+                                       hitset
+                               );
+                       
+                       nofTrigRec++;
+               }
            
+               //int xPos = rawData[index] & 0x1F;
+               //int dev = (rawData[index]>>5) & 0x1F;
+               //int yPos = (rawData[index]>>10) & 0xF;
+           }
+         
          }// if any non zero pattern found
 
-
-         index += 1 ; // skipping the last word though it is important
-         
+         index += 1 ; // the last word, important one
        }// if locId <=234
       }// Dec Condn
-       
-      
+
       if(!reg_phys_trig_occur)
         index += 45;
        
@@ -399,7 +404,7 @@ bool AliHLTMUONTriggerReconstructor::ReadDDL(
       HLTDebug("iReg %d, iLoc %d, locId : %d, trigY %x, triggX %x, loDev %x, dec %x, sign %x,rawData : %x",
               iReg,iLoc,locId,triggY,triggX,loDev,dec,sign, rawData[index]);
 
-      index = iLocIndex + 6 ; //important to reset the index counter for fake locids like 235 
+      index = iLocIndex + 6; //important to reset the index counter for fake locids like 235 
       
      }// iLoc loop
      
@@ -407,205 +412,3 @@ bool AliHLTMUONTriggerReconstructor::ReadDDL(
 
   return true;
 }
-
-
-// !!!!!!!!!!!! THIS IS A COMPLETE HACK !!!!!!!!!
-// The following intermediate structures should not be necessary
-// in a proper implementation. This will have to be fixed.
-struct HitInfo
-{
-       AliHLTMUONRecHitStruct fHit;
-       AliHLTInt32_t fChamber;
-       AliHLTInt32_t fTrigRecId;
-};
-
-// This array stores the reconstructed hits with extra chamber numbers
-// and trigger records numbers.
-std::vector<HitInfo> hitInfo;
-// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-
-bool AliHLTMUONTriggerReconstructor::FindTrigHits() 
-{
-
-  map<int,DataIdIndex>::iterator it;
-
-  hitInfo.clear();
-  for(it = fDetElemToDataId.begin(); it != fDetElemToDataId.end(); it++){
-    HLTDebug("Nof data found in Detelem : %d = %d",it->first,(it->second).size());
-    if(!MergeTrigHits(it->second))
-      return false;
-  }// loop over detection element
-  
-// !!!!!!!!!!!! THIS IS A COMPLETE HACK !!!!!!!!!
-
-       // We now have to go through the list of reconstructed hits
-       // and collect all the ones that belong to a given trigger record.
-       while (hitInfo.size() > 0)
-       {
-               // Must check if we have not overflowed the buffer.
-               if((*fRecPointsCount) == fMaxRecPointsCount){
-                       HLTError("Nof RecHit (i.e. %d) exceeds the max nof RecHit limit %d\n",(*fRecPointsCount),fMaxRecPointsCount);
-                       return false;
-               }
-       
-               bool hitset[4] = {false, false, false, false};
-               
-               // Choose the current trigger record we are collecting hits for.
-               AliHLTInt32_t currentTrig = hitInfo[0].fTrigRecId;
-               
-               // Find the hits that belong to the current trigger record "currentTrig"
-               for (int n = (int)hitInfo.size() - 1; n >= 0; n--)
-               {
-                       if (hitInfo[n].fTrigRecId != currentTrig) continue;
-                       
-                       assert( 0 <= hitInfo[n].fChamber and hitInfo[n].fChamber < 4 );
-                       fRecPoints[(*fRecPointsCount)].fHit[hitInfo[n].fChamber] = hitInfo[n].fHit;
-                       hitset[hitInfo[n].fChamber] = true;
-                       hitInfo.erase(hitInfo.end());
-               }
-               
-               // Make sure the hits that are not set, get set to a nil value.
-               for (int i = 0; i < 4; i++)
-               {
-                       if (not hitset[i])
-                       {
-                               fRecPoints[(*fRecPointsCount)].fHit[i]
-                                       = AliHLTMUONConstants::NilRecHitStruct();
-                       }
-               }
-               
-               fRecPoints[(*fRecPointsCount)].fId = currentTrig;
-               
-               // Calculate the momentum and fill in the flags and momentum fields.
-               AliHLTMUONCalculations::ComputeMomentum(
-                               fRecPoints[(*fRecPointsCount)].fHit[0].fX,
-                               fRecPoints[(*fRecPointsCount)].fHit[0].fY,
-                               fRecPoints[(*fRecPointsCount)].fHit[2].fY,
-                               fRecPoints[(*fRecPointsCount)].fHit[0].fZ,
-                               fRecPoints[(*fRecPointsCount)].fHit[2].fZ
-                       );
-               fRecPoints[(*fRecPointsCount)].fPx = AliHLTMUONCalculations::Px();
-               fRecPoints[(*fRecPointsCount)].fPy = AliHLTMUONCalculations::Py();
-               fRecPoints[(*fRecPointsCount)].fPz = AliHLTMUONCalculations::Pz();
-               
-               fRecPoints[(*fRecPointsCount)].fFlags =
-                       AliHLTMUONUtils::PackTriggerRecordFlags(
-                               AliHLTMUONCalculations::Sign(),
-                               hitset
-                       );
-               
-               // Increment the counter for the number of trigger records found.
-               (*fRecPointsCount)++;
-       }
-  
-       hitInfo.clear();
-// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-  // Reseting the fPadData to zero for next call to Run.
-  DataIdIndex dataIndex;
-  for(it = fDetElemToDataId.begin(); it != fDetElemToDataId.end(); it++){
-    dataIndex = it->second;
-    for(size_t i=0;i<dataIndex.size();i++){
-      fPadData[dataIndex.at(i)].fDetElemId = 0;
-      fPadData[dataIndex.at(i)].fBuspatchId = 0;
-      fPadData[dataIndex.at(i)].fIdManuChannel = 0;
-      fPadData[dataIndex.at(i)].fIX = 0 ;
-      fPadData[dataIndex.at(i)].fIY = 0 ;
-      fPadData[dataIndex.at(i)].fRealX = 0.0 ;
-      fPadData[dataIndex.at(i)].fRealY = 0.0 ;
-      fPadData[dataIndex.at(i)].fRealZ = 0.0 ;
-      fPadData[dataIndex.at(i)].fPlane = -1 ;
-      fPadData[dataIndex.at(i)].fPcbZone = -1 ;
-      fPadData[dataIndex.at(i)].fCharge = 0 ;
-    }// data per detelem loop  
-  }//detelem loop
-  
-  return true;
-}
-
-
-bool AliHLTMUONTriggerReconstructor::MergeTrigHits(DataIdIndex& dataIndex)
-{
-  int idManuChannelB, idManuChannelNB;
-  float halfPadLengthX,halfPadLengthY;
-  float diffX,diffY;
-
-  HLTDebug("\tThe bending plane hits are :");
-  for(size_t iPad=0;iPad<dataIndex.size();iPad++){
-    idManuChannelB   = dataIndex.at(iPad);
-    if(fPadData[idManuChannelB].fPlane == 0){
-      HLTDebug("\t detelem :%d, pcbzone : %d, (%f, %f, %f) cm",fPadData[idManuChannelB].fDetElemId,fPadData[idManuChannelB].fPcbZone,fPadData[idManuChannelB].fRealX,
-             fPadData[idManuChannelB].fRealY,fPadData[idManuChannelB].fRealZ);
-    }
-  }
-
-  HLTDebug("\tThe non-bending plane hits are :");
-  for(size_t jPad=0;jPad<dataIndex.size();jPad++){
-    idManuChannelNB   = dataIndex.at(jPad);
-    if(fPadData[idManuChannelNB].fPlane == 1){
-      HLTDebug("\t detelem :%d, pcbzone : %d,(%f, %f, %f) cm",fPadData[idManuChannelNB].fDetElemId,fPadData[idManuChannelNB].fPcbZone,fPadData[idManuChannelNB].fRealX,
-             fPadData[idManuChannelNB].fRealY,fPadData[idManuChannelNB].fRealZ);
-    }
-  }
-
-  for(size_t iPad=0;iPad<dataIndex.size();iPad++){
-    idManuChannelB   = dataIndex.at(iPad);
-    if(fPadData[idManuChannelB].fPlane == 0){
-      
-      halfPadLengthX = AliHLTMUONTriggerReconstructor::fgkHalfPadSizeXB[fPadData[idManuChannelB].fPcbZone] ;
-
-      for(size_t jPad=0;jPad<dataIndex.size();jPad++){
-       idManuChannelNB   = dataIndex.at(jPad);;
-       if(fPadData[idManuChannelNB].fPlane == 1){
-         
-         halfPadLengthY = AliHLTMUONTriggerReconstructor::fgkHalfPadSizeYNB[fPadData[idManuChannelNB].fPcbZone] ;
-         
-         if(fabsf(fPadData[idManuChannelNB].fRealX) > fabsf(fPadData[idManuChannelB].fRealX))
-           diffX = fabsf(fPadData[idManuChannelNB].fRealX) - fabsf(fPadData[idManuChannelB].fRealX);
-         else
-           diffX = fabsf(fPadData[idManuChannelB].fRealX) - fabsf(fPadData[idManuChannelNB].fRealX) ;
-
-         
-         if(fabsf(fPadData[idManuChannelNB].fRealY) > fabsf(fPadData[idManuChannelB].fRealY))
-           diffY = fabsf(fPadData[idManuChannelNB].fRealY) - fabsf(fPadData[idManuChannelB].fRealY);
-         else
-           diffY = fabsf(fPadData[idManuChannelB].fRealY) - fabsf(fPadData[idManuChannelNB].fRealY) ;
-         HLTDebug("\tdiffX %f,  halfPadLengthX %f,  diffY  %f, halfPadLengthY  %f\n",diffX,halfPadLengthX,diffY,halfPadLengthY);
-
-         if(diffX < halfPadLengthX + 1.0 && diffY < halfPadLengthY + 1.0 ){// added redundancy of 1.0 cm due to the pb of geometrical segmentation 
-
-           HitInfo hit;
-           hit.fHit.fX = fPadData[idManuChannelNB].fRealX;
-           hit.fHit.fY = fPadData[idManuChannelB].fRealY;
-           hit.fHit.fZ = fPadData[idManuChannelNB].fRealZ;
-           // !!!!!!!!!!!! THIS IS A COMPLETE HACK !!!!!!!!!
-           // Remember we had to use fBuspatchId to store the chamber number,
-           // and fCharge for the trigger record's ID number.
-           hit.fChamber = fPadData[idManuChannelNB].fBuspatchId;
-           hit.fTrigRecId = fPadData[idManuChannelNB].fCharge;
-           hitInfo.push_back(hit);
-           // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
-           //fRecPoints[(*fRecPointsCount)].fHit[0] = hit;
-           //fRecPoints[(*fRecPointsCount)].fId = fPadData[idManuChannelB].fDetElemId ;
-           
-           //(*fRecPointsCount)++;
-           //if((*fRecPointsCount) == fMaxRecPointsCount){
-           //  HLTFatal("Nof RecHit (i.e. %d) exceeds the max nof RecHit limit %d\n",(*fRecPointsCount),fMaxRecPointsCount);
-           //  return false;
-           //}
-
-           HLTDebug("\t\t\tdetelem : %d, x %f, y %f, z %f\n",fPadData[idManuChannelB].fDetElemId,fPadData[idManuChannelNB].fRealX,
-                  fPadData[idManuChannelB].fRealY,fPadData[idManuChannelB].fRealZ);
-         }
-         
-       }//condn for non-bending plane
-      }//for loop for non-bending plane
-
-    }// condn for bending plane
-  }// for loop for bending plane
-       
-  return true;
-}
-
index 6d4c5947ed7a392fa9a80836453174a9fc1c40bb..b71d355e5ce7a93a643e655daaed030123abd885 100644 (file)
  Email      : indra.das@saha.ac.in | indra.ehep@gmail.com
 **********************************************************************/
 
-#include <vector>
-
 #include "AliHLTLogging.h"
 #include "AliHLTMUONTriggerRecordsBlockStruct.h"
 #include "AliHLTMUONHitReconstructor.h"
 
-#if __GNUC__ < 3
-#define std
-#endif
-
-typedef std::vector<int> DataIdIndex;
 
 class AliHLTMUONTriggerReconstructor : public AliHLTLogging
 {
+public:
+
+       struct RegToLoc
+       {
+               int fTrigDDL;  // trigger id (0 or 1)
+               int fRegId,fLoc,fLocId;  // regeonal and local id.
+               int fSwitch;  // packed switch word of 10 bits.
+               int fDetElemId[4];  // Four detection element correspond to four detection element for each local card.
+       };
+
+       AliHLTMUONTriggerReconstructor();
+       virtual ~AliHLTMUONTriggerReconstructor();
+
+       bool LoadLookUpTable(
+                       AliHLTMUONHitReconstructor::DHLTLut* lookUpTableData,
+                       int lookUpTableId
+               );
+
+       bool SetRegToLocCardMap(RegToLoc* regToLoc);
+
+       bool Run(
+                       const AliHLTUInt32_t* rawData,
+                       AliHLTUInt32_t rawDataSize,
+                       AliHLTMUONTriggerRecordStruct* trigRecord,
+                       AliHLTUInt32_t& nofTrigRec,
+                       bool suppressPartialTrigs = false
+               );
+
+       int GetLutLine() { return fgkLutLine; }
+
+       static int GetkDetectorId() { return AliHLTMUONTriggerReconstructor::fgkDetectorId; }
+       static int GetkDDLOffSet() { return AliHLTMUONTriggerReconstructor::fgkDDLOffSet; }
+       static int GetkNofDDL() { return AliHLTMUONTriggerReconstructor::fgkNofDDL; }
+       static int GetkDDLHeaderSize() { return AliHLTMUONTriggerReconstructor::fgkDDLHeaderSize; } 
+
+protected:
+
+       AliHLTMUONTriggerReconstructor(const AliHLTMUONTriggerReconstructor& rhs); // copy constructor
+       AliHLTMUONTriggerReconstructor& operator=(const AliHLTMUONTriggerReconstructor& rhs); // assignment operator
+
+private:
+
+       static const int fgkDetectorId;            // Detector ID
+       static const int fgkDDLOffSet;             // DDL Offset
+       static const int fgkNofDDL;                // Number of DDL 
+       static const int fgkDDLHeaderSize;         // DDL header size  
+
+       static const int fgkEvenLutSize;           // Size of the LookupTable with event DDLID
+       static const int fgkOddLutSize;            // Size of the LookupTable with odd DDLID
+       static const int fgkLutLine;               // nof Line in LookupTable    
+
+       static const int fgkMinIdUnique[2];   // Minimum value of idUnique in LookupTable, 2 corresponds to two types of DDL (even/odd)  
+       static const int fgkMaxIdUnique[2];   // Maximum value of idUnique in LookupTable  
+       static const float fgkHalfPadSizeXB[3];    // pad halflength for the pcb zones, 3 corresponds to 3 types of pad in bending side  
+       static const float fgkHalfPadSizeYNB[2];   // pad halflength for the pcb zones, 2 corresponds to 2 types on nonbneding pad  
+
+       static const int fgkDetElem;               // nof Detection element per DDL    
+
+       AliHLTMUONHitReconstructor::DHLTLut* fLookUpTableData; // pointer to the array of Lookuptable data
+       AliHLTUInt32_t fMaxRecPointsCount;            // max nof reconstructed hit  
+
+       //104 correspond to maximum nuber of x indices a nonbending side of detelem may have (i.e. 1101) 
+       //and 64 corresponds to the maximum number of y indices occurs in bending side of detelem (i.e 1100)
+       int fGetIdTotalData[104][64][2];  // an array of idUnique with argumrnt of centralX,centralY and  planeType
+       RegToLoc fRegToLocCard[128];      // 8 regional card per ddl and 16 slots per regional crate together made 16*8 = 128.
+
+       int fDDLId;
+       int fIdOffSet;
 
- public:
-
-  struct RegToLoc{
-    int fTrigDDL;  // trigger id (0 or 1)
-    int fRegId,fLoc,fLocId;  // regeonal and local id.
-    int fSwitch;  // packed switch word of 10 bits.
-    int fDetElemId[4];  // Four detection element correspond to four detection element for each local card.
-  };
-
-
-  AliHLTMUONTriggerReconstructor();
-  virtual ~AliHLTMUONTriggerReconstructor();
-
-  bool LoadLookUpTable(AliHLTMUONHitReconstructor::DHLTLut* lookUpTableData, int lookUpTableId);
-  
-  bool SetRegToLocCardMap(RegToLoc* regToLoc);
-  bool Run(const AliHLTUInt32_t* rawData, AliHLTUInt32_t rawDataSize, AliHLTMUONTriggerRecordStruct* trigRecord, AliHLTUInt32_t& nofTrigRec);
-
-  int GetLutLine(){return fgkLutLine ;}
-
-  static int GetkDetectorId() { return AliHLTMUONTriggerReconstructor::fgkDetectorId ; }
-  static int GetkDDLOffSet() { return AliHLTMUONTriggerReconstructor::fgkDDLOffSet; }
-  static int GetkNofDDL() { return AliHLTMUONTriggerReconstructor::fgkNofDDL; }
-  static int GetkDDLHeaderSize() { return AliHLTMUONTriggerReconstructor::fgkDDLHeaderSize; }
-  
- private: 
-  static const int fgkDetectorId ;            // Detector ID
-  static const int fgkDDLOffSet ;             // DDL Offset
-  static const int fgkNofDDL ;                // Number of DDL 
-  static const int fgkDDLHeaderSize  ;        // DDL header size  
-
- protected:
-
-  AliHLTMUONTriggerReconstructor(const AliHLTMUONTriggerReconstructor& rhs); // copy constructor
-  AliHLTMUONTriggerReconstructor& operator=(const AliHLTMUONTriggerReconstructor& rhs); // assignment operator
-  
- private:
-
-  static const int fgkEvenLutSize ;           // Size of the LookupTable with event DDLID
-  static const int fgkOddLutSize ;            // Size of the LookupTable with odd DDLID
-  static const int fgkLutLine;                // nof Line in LookupTable    
-
-  static const int fgkMinIdManuChannel[2];    // Minimum value of idManuChannel in LookupTable, 2 corresponds to two types of DDL (even/odd)  
-  static const int fgkMaxIdManuChannel[2];    // Maximum value of idManuChannel in LookupTable  
-  static const float fgkHalfPadSizeXB[3];       // pad halflength for the pcb zones, 3 corresponds to 3 types of pad in bending side  
-  static const float fgkHalfPadSizeYNB[2];       // pad halflength for the pcb zones, 2 corresponds to 2 types on nonbneding pad  
-
-  static const int fgkDetElem;                // nof Detection element per DDL    
-
-  
-  AliHLTMUONHitReconstructor::DHLTPad* fPadData;                          // pointer to the array containing the information of each padhits
-  AliHLTMUONHitReconstructor::DHLTLut* fLookUpTableData;                  // pointer to the array of Lookuptable data
-  
-  AliHLTMUONTriggerRecordStruct *fRecPoints;    // Reconstructed hits
-  AliHLTUInt32_t *fRecPointsCount;                       // nof reconstructed hit  
-  AliHLTUInt32_t fMaxRecPointsCount;                    // max nof reconstructed hit  
-
-  //104 correspond to maximum nuber of x indices a nonbending side of detelem may have (i.e. 1101) 
-  //and 64 corresponds to the maximum number of y indices occurs in bending side of detelem (i.e 1100)
-  int fGetIdTotalData[104][64][2] ;           // an array of idManuChannel with argumrnt of centralX,centralY and  planeType
-  RegToLoc fRegToLocCard[128];              // 8 regional card per ddl and 16 slots per regional crate together made 16*8 = 128. 
-
-  map<int,int> fMaxFiredPerDetElem;                    // counter for detector elements that are fired 
-  map<int,DataIdIndex> fDetElemToDataId;              // detelem to pointer to dataId index mapping
-  
-  int fDDLId ;
-  int fIdOffSet ;
-  
-  AliHLTInt32_t fTrigRecId;  // A running counter for the trigger record ID.
-
-  bool MergeTrigHits(DataIdIndex& dataIndex);
-  bool FindTrigHits() ;
-
-  bool ReadDDL(const AliHLTUInt32_t* rawData, AliHLTUInt32_t rawDataSize);
+       AliHLTInt32_t fTrigRecId;  // A running counter for the trigger record ID.
 };
 
 #endif // AliHLTMUONTRIGGERRECONSTRUCTOR_H
index 73252dd8046120cbf2dcb789e689280dc130e1d1..405793b3571fcf7886db785c224626d0cf8f90fd 100644 (file)
@@ -46,7 +46,8 @@ AliHLTMUONTriggerReconstructorComponent::AliHLTMUONTriggerReconstructorComponent
        fTrigRec(NULL),
        fDDLDir(""),
        fDDL(0),
-       fWarnForUnexpecedBlock(false)
+       fWarnForUnexpecedBlock(false),
+       fSuppressPartialTrigs(false)
 {
 }
 
@@ -80,7 +81,7 @@ void AliHLTMUONTriggerReconstructorComponent::GetOutputDataSize(
        )
 {
        constBase = sizeof(AliHLTMUONTriggerRecordsBlockWriter::HeaderType);
-       inputMultiplier = 100;
+       inputMultiplier = 1;
 }
 
 
@@ -98,6 +99,7 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
   HLTInfo("Initialising DHLT Trigger Record Component");
 
   fWarnForUnexpecedBlock = false;
+  fSuppressPartialTrigs = false;
   fTrigRec = new AliHLTMUONTriggerReconstructor();
       
   // this is just to get rid of the warning "unused parameter"
@@ -171,6 +173,12 @@ int AliHLTMUONTriggerReconstructorComponent::DoInit(int argc, const char** argv)
        i++;
        continue;
       }
+         
+      if ( !strcmp( argv[i], "-suppress_partial_triggers" ) ) {
+        fSuppressPartialTrigs = true;
+       i++;
+       continue;
+      }
 
       HLTError("Unknown option '%s'", argv[i] );
       return EINVAL;
@@ -299,7 +307,12 @@ int AliHLTMUONTriggerReconstructorComponent::DoEvent(
                        + fTrigRec->GetkDDLHeaderSize();
                AliHLTUInt32_t nofTrigRec = block.MaxNumberOfEntries();
 
-               if (not fTrigRec->Run(buffer, ddlRawDataSize, block.GetArray(), nofTrigRec))
+               bool runOk = fTrigRec->Run(
+                               buffer, ddlRawDataSize,
+                               block.GetArray(), nofTrigRec,
+                               fSuppressPartialTrigs
+                       );
+               if (not runOk)
                {
                        HLTError("Error while processing of trigger DDL reconstruction algorithm.");
                        size = totalSize; // Must tell the framework how much buffer space was used.
index 57dd79f46d7b372554ca50f9030bed2a40209925..1c69800a812646894d8852055410adc29c042c34 100644 (file)
@@ -83,6 +83,7 @@ private:
        TString fDDLDir;
        Int_t fDDL;
        bool fWarnForUnexpecedBlock;  // Flag indicating if we should log a warning if we got a block of an unexpected type.
+       bool fSuppressPartialTrigs;   // Flag indicating if we should suppress triggers that did not trigger the L0
 
        ClassDef(AliHLTMUONTriggerReconstructorComponent, 0)