- code version from TPC commissioning merged
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 31 Aug 2006 14:16:35 +0000 (14:16 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 31 Aug 2006 14:16:35 +0000 (14:16 +0000)
- DigitReaderRaw added with different read modes (sorted/unsorted;
  several data specifications to adapt to the real data)
- sorting of incoming data in DigitReaderPacked
- straight line fit implemented in Conformal Mapping Fit

37 files changed:
HLT/BASE/AliHLTComponentHandler.cxx
HLT/BASE/AliHLTComponentHandler.h
HLT/BASE/Makefile.am
HLT/ChangeLog
HLT/SampleLib/tutorial.c
HLT/TPCLib/AliHLTTPCClusterFinder.cxx
HLT/TPCLib/AliHLTTPCClusterFinder.h
HLT/TPCLib/AliHLTTPCClusterFinderComponent.cxx
HLT/TPCLib/AliHLTTPCClusterFinderComponent.h
HLT/TPCLib/AliHLTTPCConfMapFit.cxx
HLT/TPCLib/AliHLTTPCConfMapFit.h
HLT/TPCLib/AliHLTTPCConfMapTrack.cxx
HLT/TPCLib/AliHLTTPCDDLDataFileHandler.cxx
HLT/TPCLib/AliHLTTPCDigitReader.cxx
HLT/TPCLib/AliHLTTPCDigitReader.h
HLT/TPCLib/AliHLTTPCDigitReaderPacked.cxx
HLT/TPCLib/AliHLTTPCDigitReaderPacked.h
HLT/TPCLib/AliHLTTPCDigitReaderRaw.cxx [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCDigitReaderRaw.h [new file with mode: 0644]
HLT/TPCLib/AliHLTTPCDigitReaderUnpacked.cxx
HLT/TPCLib/AliHLTTPCDigitReaderUnpacked.h
HLT/TPCLib/AliHLTTPCDisplay.cxx
HLT/TPCLib/AliHLTTPCDisplay.h
HLT/TPCLib/AliHLTTPCGlobalMergerComponent.cxx
HLT/TPCLib/AliHLTTPCLinkDef.h
HLT/TPCLib/AliHLTTPCLog.cxx
HLT/TPCLib/AliHLTTPCLog.h
HLT/TPCLib/AliHLTTPCPad.cxx
HLT/TPCLib/AliHLTTPCSliceTrackerComponent.cxx
HLT/TPCLib/AliHLTTPCSliceTrackerComponent.h
HLT/TPCLib/AliHLTTPCTrack.cxx
HLT/TPCLib/AliHLTTPCTrackArray.cxx
HLT/TPCLib/AliHLTTPCTransform.cxx
HLT/TPCLib/Makefile
HLT/TPCLib/Makefile.am
HLT/TPCLib/mapping2array.cxx.in [new file with mode: 0644]
HLT/configure.ac

index bf63982f80c5f05c590d72a19740cb92ce79b3b2..48310998ee8d9a3d01abcf7762de98208719539d 100644 (file)
@@ -127,7 +127,7 @@ int AliHLTComponentHandler::CreateComponent(const char* componentID, void* pEnv,
   return iResult;
 }
 
-Int_t AliHLTComponentHandler::FindComponentIndex(const Char_t* componentID)
+Int_t AliHLTComponentHandler::FindComponentIndex(const char* componentID)
 {
   Int_t iResult=0;
   if (componentID) {
@@ -146,7 +146,7 @@ Int_t AliHLTComponentHandler::FindComponentIndex(const Char_t* componentID)
   return iResult;
 }
 
-AliHLTComponent* AliHLTComponentHandler::FindComponent(const Char_t* componentID)
+AliHLTComponent* AliHLTComponentHandler::FindComponent(const char* componentID)
 {
   AliHLTComponent* pSample=NULL;
   Int_t index=FindComponentIndex(componentID);
index 638164d9adfffbbdfa9cb6e5b9986cba8fc78978..12d4000040549f89e74e8ef749741fd439040a95 100644 (file)
@@ -109,10 +109,10 @@ class AliHLTComponentHandler : public AliHLTLogging {
    * Create a component of the given name (ID).
    * @param componentID  ID of the component to create
    * @param pEnv         environment for the component
-   * @param argc         number of arguments in @ref argv
+   * @param argc         number of arguments in argv
    * @param argv         argument array like in main()
    * @param component    reference to receive the create component instance
-   * @return component pointer in @ref component, neg. error code if failed
+   * @return component pointer in component, neg. error code if failed
    */
   int CreateComponent( const char* componentID, void* pEnv, 
                       int argc, const char** argv, AliHLTComponent*& component );
@@ -123,7 +123,7 @@ class AliHLTComponentHandler : public AliHLTLogging {
    * @param componentID  ID of the component to create
    * @param pEnv         environment for the component
    * @param component    reference to receive the create component instance
-   * @return component pointer in @ref component, neg. error code if failed
+   * @return component pointer in component, neg. error code if failed
    */
   int CreateComponent( const char* componentID, void* pEnv, 
                       AliHLTComponent*& component ) 
index dc9c950e41e0259bfd40eb305356a1ac6d6a2d8a..971f2c3688ef0472fe196e509535f7f834a12d0d 100644 (file)
@@ -51,7 +51,7 @@ DICTCPP                               =  HLTbase-DICT.cxx
 nodist_libHLTbase_la_SOURCES    =  $(COMPILE_INFO) \
                                   $(DICTCPP)
 
-CLEANFILES                     =
+CLEANFILES                     =  $(COMPILE_INFO)
 
 include $(top_srcdir)/make.dict
 
@@ -62,11 +62,3 @@ $(COMPILE_INFO): $(libHLTbase_la_SOURCES) $(pkginclude_HEADERS) $(noinst_HEADERS
        @echo 'void $(MODULE)CompileInfo( char*& date, char*& time)' >> $@
        @echo '{date=__DATE__; time=__TIME__; return;}' >> $@
 
-#      @echo '//automatically generated compilation info' > $@
-#      @echo '//!!! DO NOT EDIT THIS FILE !!!' >> $@
-#      @echo '//add changes in Makefile.am' >> $@
-#      @echo 'void __$(MODULE)_compile_info(const char** pDate, const char** pDate)' >> $@
-#      @echo '{' >> $@
-#      @echo 'if (pDate) *pDate=__DATE__;' >> $@
-#      @echo 'if (pTime) *pTime=__TIME__;' >> $@
-#      @echo '}' >> $@
index 0ce8a5786571c90e79985a21715f6302d6781708..f7c88ec7c35e65764c11849768328c01e483f948 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-31 code from TPC commissioning version merged
+       - DigitReaderRaw added with different read modes (sorted/unsorted;
+         several data specifications to adapt to the real data)
+       - quick hack to sort incoming data in DigitReaderPacked 
+       - straight line fit implemented in Conformal Mapping Fit
 2006-08-23 version HLT-v0-3
        - check for AliRoot features/libs/files and corresponding conditional
          build
index 817b9602044f273be18fcc59345092a6b7ca905f..808465a6e0195fe86c165fee77dc5824e915e32c 100644 (file)
     A description will follow ...
 */
 
+/* note pad
+
+Making a new module/library
+
+Automatic ROOT dictionary generation:
+The automatic ROOT dictionary generation relies on the rule, that the main class
+of a header file has the same name as the file (except the prefix).
+
+Troubleshooting:
+Error: link requested for unknown class <class name> <library>-LinkDef.h:<line no>
+most likely there is no class <class name> defined in the header file <class name>.h*
+
+ */
 #error Not for compilation
 //
 // EOF
index 5edd95a619e60f06d1b256a3427678e3838f90b3..6ceb41895c62f31d87930babe36cc77055a9a8aa 100644 (file)
@@ -198,11 +198,11 @@ void AliHLTTPCClusterFinder::ProcessDigits()
   fNClusters = 0;
 
   // initialize block for reading packed data
-  fDigitReader->InitBlock(fPtr,fSize,fFirstRow,fLastRow);
+  fDigitReader->InitBlock(fPtr,fSize,fFirstRow,fLastRow,fCurrentPatch,fCurrentSlice);
   readValue = fDigitReader->Next();
 
   if (!readValue)return;
+
   pad = fDigitReader->GetPad();
   time = fDigitReader->GetTime();
   fCurrentRow = fDigitReader->GetRow();
@@ -500,7 +500,7 @@ void AliHLTTPCClusterFinder::ProcessDigits()
 
     pad = newPad;
     time = newTime;
-  
+
   } // END while(readValue)
 
   if (pCurrentPad) pCurrentPad->StopEvent();
index 439c6cc71ed48e72c8da972671e87da7d8ee8c87..135734ddded0bf0f0563a779ac0760da1635e8ad 100644 (file)
@@ -86,6 +86,6 @@ class AliHLTTPCClusterFinder : public AliHLTLogging {
   void SetReader(AliHLTTPCDigitReader* f){fDigitReader = f;}
   Int_t GetNumberOfClusters() const {return fNClusters;}
   
-  ClassDef(AliHLTTPCClusterFinder,1) //Fast cluster finder
+  ClassDef(AliHLTTPCClusterFinder,0) //Fast cluster finder
 };
 #endif
index b99b4e8d880ad29260c793d04da2c6a473ecc111..51346d15d28dc06ef4e3cd9ecc9f20f2b735b12d 100644 (file)
 ///////////////////////////////////////////////////////////////////////////////
 
 
-#if __GNUC__== 3
+#if __GNUC__>= 3
 using namespace std;
 #endif
-
+#include "AliHLTTPCLogging.h"
 #include "AliHLTTPCClusterFinderComponent.h"
 #include "AliHLTTPCDigitReaderPacked.h"
 #include "AliHLTTPCDigitReaderUnpacked.h"
+#include "AliHLTTPCDigitReaderRaw.h"
 #include "AliHLTTPCClusterFinder.h"
 #include "AliHLTTPCSpacePointData.h"
 #include "AliHLTTPCRawDataFormat.h"
@@ -124,39 +125,98 @@ int AliHLTTPCClusterFinderComponent::DoInit( int argc, const char** argv )
 
     fClusterFinder = new AliHLTTPCClusterFinder();
 
-    if (fPackedSwitch) {
+    Int_t rawreadermode =  -1;
+
+    // Data Format version numbers:
+    // 0: RCU Data format as delivered during TPC commissioning, pads/padrows are sorted, RCU trailer is one 32 bit word.
+    // 1: As 0, but pads/padrows are delivered "as is", without sorting
+    // 2: As 0, but RCU trailer is 3 32 bit words.
+    // 3: As 1, but RCU trailer is 3 32 bit words.
+    // -1: use offline raw reader
+
+    Int_t i = 0;
+    Char_t* cpErr;
+
+    while ( i < argc ) {      
+
+      // -- raw reader mode option
+      if ( !strcmp( argv[i], "rawreadermode" ) ) {
+       if ( argc <= i+1 ) {
+         Logging( kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Missing rawreadermode", "Raw Reader Mode not specified" );
+         return ENOTSUP;
+       }
+       
+       if ( !strcmp( argv[i+1], "sorted_1_trailerword" ) ) {
+         rawreadermode = 0;
+       }
+       else if ( !strcmp( argv[i+1], "sorted_3_trailerword" ) ) {
+         rawreadermode = 2;
+       }
+       else if ( !strcmp( argv[i+1], "unsorted_1_trailerword" ) ) {
+         rawreadermode = 1;
+       }
+       else if ( !strcmp( argv[i+1], "unsorted_3_trailerword" ) ) {
+         rawreadermode = 3;
+       }
+       else if ( !strcmp( argv[i+1], "offline" ) ) {
+         rawreadermode = -1;
+       }
+       else {
+         rawreadermode = strtoul( argv[i+1], &cpErr ,0);
+           if ( *cpErr ) {
+             Logging( kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Missing rawreadermode", "Cannot convert rawreadermode specifier '%s'.", argv[i+1] );
+             return EINVAL;
+           }
+       }
+
+       i += 2;
+       continue;
+      }
+
+      // -- pp run option
+      if ( !strcmp( argv[i], "pp-run" ) ) {
+       fClusterDeconv = false;
+       i++;
+       continue;
+      }
+
+      Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
+      return EINVAL;
+
+    }
+
+    // Choose reader
+
+    if (fPackedSwitch) { 
+      if (rawreadermode == -1) {
 #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
-      fReader = new AliHLTTPCDigitReaderPacked();
-      fClusterFinder->SetReader(fReader);
+       fReader = new AliHLTTPCDigitReaderPacked();
+       fClusterFinder->SetReader(fReader);
 #else // ! defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
-      HLTFatal("DigitReaderPacked not available - check your build");
-      return -ENODEV;
+       HLTFatal("DigitReaderPacked not available - check your build");
+       return -ENODEV;
 #endif //  defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
+      } else {
+#if defined(HAVE_TPC_MAPPING)
+       fReader = new AliHLTTPCDigitReaderRaw(rawreadermode);
+       fClusterFinder->SetReader(fReader);
+#else //! defined(HAVE_TPC_MAPPING)
+      HLTFatal("DigitReaderRaw not available - check your build");
+      return -ENODEV;
+#endif //defined(HAVE_TPC_MAPPING)
+      }
     }
     else {
       fReader = new AliHLTTPCDigitReaderUnpacked();
       fClusterFinder->SetReader(fReader);
     }
-    
+      
     // Variables to setup the Clusterfinder
     fClusterDeconv = true;
     fXYClusterError = -1;
     fZClusterError = -1;
 
-    int i = 0;
-    while ( i < argc )
-       {
-         if ( !strcmp( argv[i], "pp-run" ) ){
-           fClusterDeconv = false;
-           i++;
-           continue;
-         }
-
-       Logging(kHLTLogError, "HLT::TPCClusterFinder::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
-       return EINVAL;
-       }
-
-
     fClusterFinder->SetDeconv( fClusterDeconv );
     fClusterFinder->SetXYError( fXYClusterError );
     fClusterFinder->SetZError( fZClusterError );
@@ -186,6 +246,7 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponent_EventData& e
                                              AliHLTUInt32_t& size, 
                                              vector<AliHLTComponent_BlockData>& outputBlocks )
     {
+
     //  == init iter (pointer to datablock)
     const AliHLTComponent_BlockData* iter = NULL;
     unsigned long ndx;
@@ -244,7 +305,7 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponent_EventData& e
        outPtr = (AliHLTTPCClusterData*)outBPtr;
 
        maxPoints = (size-tSize-sizeof(AliHLTTPCClusterData))/sizeof(AliHLTTPCSpacePointData);
-       
+
        fClusterFinder->InitSlice( slice, patch, row[0], row[1], maxPoints );
        fClusterFinder->SetOutputArray( outPtr->fSpacePoints );
        fClusterFinder->Read(iter->fPtr, iter->fSize );
@@ -261,8 +322,6 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponent_EventData& e
        Logging( kHLTLogDebug, "HLT::TPCClusterFinder::DoEvent", "Input Spacepoints", 
                 "Number of spacepoints: %lu Slice/Patch/RowMin/RowMax: %d/%d/%d/%d.",
                 realPoints, slice, patch, row[0], row[1] );
-       
-       
        AliHLTComponent_BlockData bd;
        FillBlockData( bd );
        bd.fOffset = offset;
@@ -285,6 +344,7 @@ int AliHLTTPCClusterFinderComponent::DoEvent( const AliHLTComponent_EventData& e
        }
     
     size = tSize;
+
     return 0;
     }
 
index 2a1f5380a39797342a912cb9aaf16d3f46f3f5a6..e9f4b1fa91ce6b1259a7fa8b59057d9ec749f8bc 100644 (file)
@@ -13,6 +13,7 @@
 #include "AliHLTTPCDefinitions.h"
 #include "AliHLTTPCDigitReaderPacked.h"
 #include "AliHLTTPCDigitReaderUnpacked.h"
+#include "AliHLTTPCDigitReaderRaw.h"
 
 class AliHLTTPCClusterFinder;
 
@@ -53,9 +54,11 @@ class AliHLTTPCClusterFinderComponent : public AliHLTProcessor
                     AliHLTUInt32_t& size, vector<AliHLTComponent_BlockData>& outputBlocks );
        
     private:
+       /** the cluster finder object */
+       AliHLTTPCClusterFinder* fClusterFinder;
+       /** the reader object for data decoding */
+       AliHLTTPCDigitReader* fReader;
 
-      AliHLTTPCClusterFinder* fClusterFinder;
-      AliHLTTPCDigitReader* fReader;
       bool fClusterDeconv;
       float fXYClusterError;
       float fZClusterError;
index 0fa10a21c5169657e010d7e6e4998e078af079a2..441233d4da368e46e01cdc0fb072e4eb6c8fe5c9 100644 (file)
@@ -53,6 +53,25 @@ Int_t AliHLTTPCConfMapFit::FitHelix()
   return 0;
 }
 
+// #### -B0-CHANGE-START == JMT
+
+Int_t AliHLTTPCConfMapFit::FitStraightLine() {
+    //fit the straight line 
+    if(FitLineXY()) {
+       LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapFit::FitStraightLine","TrackFit")<<AliHLTTPCLog::kDec<<
+           "Problems during stright line fit in XY plane"<<ENDLOG;
+       return 1;
+    }
+    if(FitLineSZ()){
+       LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapFit::FitStraightLine","TrackFit")<<AliHLTTPCLog::kDec<<
+           "Problems during stright line fit in SZ plane"<<ENDLOG;
+       return 1;
+    }
+    return 0;
+}
+
+// #### -B0-CHANGE-END == JMT
+
 Int_t AliHLTTPCConfMapFit::FitCircle()
 {
   //-----------------------------------------------------------------
@@ -504,3 +523,211 @@ Int_t AliHLTTPCConfMapFit::FitLine ( )
   
   return 0 ;
 } 
+
+
+// #### -B0-CHANGE-START == JMT
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//    Straight Line Fit  in x-y plane
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Int_t AliHLTTPCConfMapFit::FitLineXY ( ){
+    // -----------------------------------------------------------------------------
+    // Implementation after Numerical Recipes in C, 2nd Edtion, chapter 15.2, p. 661
+    // with y = b*x + a
+    // and Data Analysis for Physical Science Students, Luis Lyons, chapter 2.4 p.51 
+    // with y = a' + bx' , x' = x - <x>
+    // -----------------------------------------------------------------------------
+
+    Double_t S = 0.;
+    Double_t Sx = 0.;
+
+    Double_t SPrime = 0.;
+    Double_t SxPrime = 0.;
+    Double_t SxxPrime = 0.;
+    Double_t SyPrime = 0.;
+    Double_t SxyPrime = 0.;
+
+    Double_t chi2 = 0.;
+
+    Int_t num_of_hits = fTrack->GetNumberOfPoints();
+
+    Int_t co=0;
+    
+    // - Loop over hits calculating average : xav
+    for(fTrack->StartLoop(); fTrack->LoopDone(); fTrack->GetNextHit()) {
+       co++;
+       AliHLTTPCConfMapPoint *currentHit = (AliHLTTPCConfMapPoint*)fTrack->GetCurrentHit();
+       // ** maybe not necessary, already done in ConfMapPoint
+       currentHit->SetXYWeight( 1./ (Double_t)(currentHit->GetXerr()*currentHit->GetXerr() + currentHit->GetYerr()*currentHit->GetYerr()) );
+       // **
+       S   += currentHit->GetXYWeight();
+       Sx  += currentHit->GetXYWeight() * currentHit->GetX();
+    }   
+    
+    if(co!=num_of_hits) 
+       LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapFit::FitLineXY","TrackFit") << "Mismatch of hits. Counter: "<<co<<" nHits: "<<num_of_hits<<ENDLOG;
+
+    Double_t xav = (Double_t)Sx / S;
+    
+    // Calculate weighted means
+    for(fTrack->StartLoop(); fTrack->LoopDone(); fTrack->GetNextHit()) {
+       AliHLTTPCConfMapPoint *currentHit = (AliHLTTPCConfMapPoint*)fTrack->GetCurrentHit();
+
+       Double_t xPrime =  currentHit->GetX() - xav;
+       SPrime   += currentHit->GetXYWeight();
+       SxPrime  += currentHit->GetXYWeight() * xPrime;
+       SxxPrime += currentHit->GetXYWeight() * xPrime * xPrime;
+       SyPrime  += currentHit->GetXYWeight() * currentHit->GetY();
+       SxyPrime += currentHit->GetXYWeight() * xPrime * currentHit->GetY();
+    }
+
+    Double_t det = SPrime*SxxPrime + SxPrime*SxPrime;
+
+    if (fabs(det) < 1e-20) { 
+       LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapFit::FitLineXY","TrackFit") << "Determinant == 0" << ENDLOG;  
+       chi2 = 99999.F ;
+       fTrack->SetChiSq1(chi2);
+       return -1 ;
+    }
+
+    Double_t b   = (Double_t)(SPrime*SxyPrime - SxPrime*SyPrime) / det;        // line parameter b
+    Double_t aPrime   = (Double_t)(SxxPrime*SyPrime - SxPrime*SxyPrime) / det; // line parameter a
+
+    Double_t sigma2b = (Double_t)1. / SxxPrime;
+    //-- Double_t sigma2aprime = (Double_t)1. /SPrime;
+
+    // Get gradient angle psi of line in xy plane
+    Double_t psi  = (Double_t) atan(b) ; 
+
+    // Calculate chi2
+    for(fTrack->StartLoop(); fTrack->LoopDone(); fTrack->GetNextHit()) {
+       AliHLTTPCConfMapPoint *currentHit = (AliHLTTPCConfMapPoint*)fTrack->GetCurrentHit();
+       Double_t tempchi = currentHit->GetY() - aPrime - b*(currentHit->GetX() - xav);
+       chi2 += tempchi*tempchi*currentHit->GetXYWeight() ;
+    }
+
+    Double_t a = aPrime - b*xav;
+
+
+    // Set TrackParameter
+    fTrack->SetChiSq1(chi2);
+    fTrack->SetPsi(psi);
+    fTrack->SetPsierr(sigma2b);   
+    fTrack->SetCenterX(0.);    // Set to point on the track (for UpdateToFirstPoint)
+    fTrack->SetCenterY(a);     // Set to point on the track (for UpdateToFirstPoint)
+
+    //Set the first point on the track to the space point coordinates of the innermost track
+    //This will be updated to lie on the fit later on (AliHLTTPCTrack::UpdateToFirstPoint).
+    AliHLTTPCConfMapPoint *lastHit = (AliHLTTPCConfMapPoint*)fTrack->GetLastHit();
+    Double_t x0 = lastHit->GetX();
+    Double_t y0 = lastHit->GetY();
+    fTrack->SetFirstPoint(x0,y0,0); //Z-value is set in FitLineSZ
+    
+
+    //Set Defaults
+    fTrack->SetRadius(-1.);
+    fTrack->SetCharge(1);
+    fTrack->SetPt(-1.);
+  
+
+    return 0;
+}
+
+
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//    Straight Line Fit  in s-z plane
+//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+Int_t AliHLTTPCConfMapFit::FitLineSZ ( ){
+    // -----------------------------------------------------------------------------
+    // Implementation after Numerical Recipes in C, 2nd Edtion, chapter 15.2, p. 661
+    // with z = b*s + a
+    // and Data Analysis for Physical Science Students, Luis Lyons, chapter 2.4 p.51 
+    // with z = a' + bs' , s' = s - <s>
+    // -----------------------------------------------------------------------------
+
+    Double_t S = 0.;
+    Double_t Ss = 0.;
+
+    Double_t SPrime = 0.;
+    Double_t SsPrime = 0.;
+    Double_t SssPrime = 0.;
+    Double_t SzPrime = 0.;
+    Double_t SszPrime = 0.;
+
+    Double_t chi2 = 0.;
+    Double_t s = 0.;
+
+    AliHLTTPCConfMapPoint *previousHit = NULL;
+  
+    // - Loop over hits calculating length in xy-plane: s
+    // - Loop over hits calculating average : sav
+    for(fTrack->StartLoop(); fTrack->LoopDone(); fTrack->GetNextHit()) {
+       AliHLTTPCConfMapPoint *currentHit = (AliHLTTPCConfMapPoint*)fTrack->GetCurrentHit();
+       if(currentHit != fTrack->GetFirstHit()) {
+           Double_t dx = currentHit->GetX() - previousHit->GetX() ;
+           Double_t dy = currentHit->GetY() - previousHit->GetY() ;
+           s = previousHit->GetS() - (Double_t)sqrt ( dx*dx + dy*dy );
+       }
+       else{
+           Double_t dx = ((AliHLTTPCConfMapPoint *)fTrack->GetFirstHit())->GetX() - ((AliHLTTPCConfMapPoint *)fTrack->GetLastHit())->GetX(); 
+           Double_t dy = ((AliHLTTPCConfMapPoint *)fTrack->GetFirstHit())->GetY() - ((AliHLTTPCConfMapPoint *)fTrack->GetLastHit())->GetY();
+           s = (Double_t)sqrt ( dx*dx + dy*dy );
+       }
+
+       currentHit->SetS(s);
+
+       S   += currentHit->GetZWeight();
+       Ss  += currentHit->GetZWeight() * currentHit->GetS();
+    }
+
+    Double_t sav = (Double_t)Ss / S;
+
+    // Calculate weighted means
+    for(fTrack->StartLoop(); fTrack->LoopDone(); fTrack->GetNextHit()) {
+       AliHLTTPCConfMapPoint *currentHit = (AliHLTTPCConfMapPoint*)fTrack->GetCurrentHit();
+
+       Double_t sPrime =  currentHit->GetS() - sav;
+       SPrime   += currentHit->GetZWeight();
+       SsPrime  += currentHit->GetZWeight() * sPrime;
+       SssPrime += currentHit->GetZWeight() * sPrime * sPrime;
+       SzPrime  += currentHit->GetZWeight() * currentHit->GetZ();
+       SszPrime += currentHit->GetZWeight() * sPrime * currentHit->GetZ();
+    }
+
+    Double_t det = SPrime*SssPrime + SsPrime*SsPrime;
+
+    if (fabs(det) < 1e-20) { 
+       LOG(AliHLTTPCLog::kDebug,"AliHLTTPCConfMapFit::FitLineSZ","TrackFit") << "Determinant == 0" << ENDLOG;  
+       chi2 = 99999.F ;
+       fTrack->SetChiSq2(chi2);
+       return -1 ;
+    }
+
+    Double_t b   = (Double_t)(SPrime*SszPrime - SsPrime*SzPrime) / det;        // line parameter b
+    Double_t aPrime   = (Double_t)(SssPrime*SzPrime - SsPrime*SszPrime) / det; // line parameter a
+
+    Double_t a = aPrime - b*sav;
+
+    Double_t sigma2b = (Double_t) 1. / SssPrime;
+    Double_t sigma2aprime = (Double_t) 1. /SPrime;
+
+    Double_t sigma2a = sigma2aprime + sav*sav * sigma2b*sigma2b;
+
+    // Calculate chi2
+    for(fTrack->StartLoop(); fTrack->LoopDone(); fTrack->GetNextHit()) {
+       AliHLTTPCConfMapPoint *currentHit = (AliHLTTPCConfMapPoint*)fTrack->GetCurrentHit();
+       Double_t tempchi = currentHit->GetZ() - aPrime - b*(currentHit->GetS() - sav);
+       chi2 += tempchi*tempchi*currentHit->GetZWeight() ;
+    }
+
+    // Set TrackParameter
+    fTrack->SetChiSq2(chi2);
+    fTrack->SetTgl(b);
+    fTrack->SetZ0(a);
+    fTrack->SetTglerr(sigma2b);
+//  fTrack->SetZ0err(sigma2aprime);   // maybe subject to check
+    fTrack->SetZ0err(sigma2a);        // maybe subject to check
+    return 0;
+}
+
+// #### -B0-CHANGE-END == JMT
index 5a6e2811a059b1711ab033b889961cc0ce81176d..b68a483a2d918323f2f52e879cf593353e2f156d 100644 (file)
@@ -17,10 +17,16 @@ class AliHLTTPCConfMapFit {
   AliHLTTPCConfMapFit (AliHLTTPCConfMapTrack *track,AliHLTTPCVertex *vertex);
   virtual ~AliHLTTPCConfMapFit() {};
 
+  // helix fit
   Int_t FitHelix();
   Int_t FitCircle();
   Int_t FitLine();
 
+  // straight line fit
+  Int_t FitStraightLine();
+  Int_t FitLineXY();
+  Int_t FitLineSZ();
+  
   ClassDef(AliHLTTPCConfMapFit,1) //Conformal mapping fit class
 };
 
index 8580f38b4f41500177924a09021a32d7532bbfb9..27d07f26a195e44daf72e52375a7cca89835c0cb 100644 (file)
@@ -163,38 +163,64 @@ void AliHLTTPCConfMapTrack::UpdateParam(AliHLTTPCConfMapPoint *thisHit)
 
 void AliHLTTPCConfMapTrack::Fill(AliHLTTPCVertex *vertex,Double_t max_Dca)
 {
-  //Fill track variables with or without fit.
-  
-  //fRadius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
-  Double_t radius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
-  SetRadius(radius);
-
-  //fPt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * fRadius);
-  Double_t pt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * GetRadius());
-  SetPt(pt);
+    //Fill track variables with or without fit.
+    
+// #### -B0-CHANGE-START == JMT
+    // for straight line fit
+    if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
 
-  if(GetPt() > max_Dca) //go for fit of helix in real space
-    {
-      AliHLTTPCConfMapFit *fit = new AliHLTTPCConfMapFit(this,vertex);
-      ComesFromMainVertex(AliHLTTPC::DoVertexFit());
-      fit->FitHelix();
-      
-      //AliHLTTPCConfMapPoint *lHit = (AliHLTTPCConfMapPoint*)fLastHit;
-      AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
-      SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
-      
-      UpdateToFirstPoint();
-      
-      delete fit;
+       SetRadius(0.);  
+       SetPt(0.);
+       
+       //go for fit of straight line in real space
+       AliHLTTPCConfMapFit *fit = new AliHLTTPCConfMapFit(this,vertex);
+       ComesFromMainVertex(AliHLTTPC::DoVertexFit());
+       fit->FitStraightLine();
+           
+       AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
+       SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
+       
+       UpdateToFirstPoint();
+       
+       delete fit;
+       
     }
-  else if(GetPt() == 0)
-    LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
-      "Found track with Pt=0!!!"<<ENDLOG;
-  else
-    {
-      LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
-       "Track with pt<max_Dca :"<<GetPt()<<ENDLOG;
+    // for helix fit
+    else { 
+// #### -B0-UNCHANGED-START == JMT
+       //fRadius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
+       Double_t radius = sqrt(fa2Xy*fa2Xy+1)/(2*fabs(fa1Xy));
+       SetRadius(radius);
+       
+       //fPt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * fRadius);
+       Double_t pt = (Double_t)(AliHLTTPCTransform::GetBFieldValue() * GetRadius());
+       SetPt(pt);
+       
+       if(GetPt() > max_Dca) //go for fit of helix in real space
+       {
+           AliHLTTPCConfMapFit *fit = new AliHLTTPCConfMapFit(this,vertex);
+           ComesFromMainVertex(AliHLTTPC::DoVertexFit());
+           fit->FitHelix();
+           
+           //AliHLTTPCConfMapPoint *lHit = (AliHLTTPCConfMapPoint*)fLastHit;
+           AliHLTTPCConfMapPoint *fHit = (AliHLTTPCConfMapPoint*)fFirstHit;
+           SetLastPoint(fHit->GetX(),fHit->GetY(),fHit->GetZ());
+           
+           UpdateToFirstPoint();
+           
+           delete fit;
+       }
+       else if(GetPt() == 0)
+           LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
+               "Found track with Pt=0!!!"<<ENDLOG;
+       else
+       {
+           LOG(AliHLTTPCLog::kError,"AliHLTTPCConfMapTrack::Fill","Tracks")<<AliHLTTPCLog::kDec<<
+               "Track with pt<max_Dca :"<<GetPt()<<ENDLOG;
+       }
+// #### -B0-UNCHANGED-END == JMT
     }
+// #### -B0-CHANGE-END == JMT
 }
 
 Int_t AliHLTTPCConfMapTrack::GetMCLabel()
index aa4b4ae4e60e0965f2e4b8807532d807150d203d..b46e2db1334a4f4cae81a546cca9e44ab8dde0b9 100644 (file)
@@ -17,7 +17,7 @@
 #endif
 #include "AliHLTTPCDDLDataFileHandler.h"
 
-#if __GNUC__ == 3
+#if __GNUC__ >= 3
 using namespace std;
 #endif
 
index 99b8aab521dd908719585eab17ae194c409e990d..1d6c3782a44516d8347b88427d42516cf1ad3033 100644 (file)
@@ -23,7 +23,7 @@
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#if __GNUC__== 3
+#if __GNUC__>= 3
 using namespace std;
 #endif
 
index baa902d9274faba70baaad4e6f63dabe282045b1..83330a46f78962f4cea38520ca3e46cac5b583be 100644 (file)
 /* AliHLTTPCDigitReader
  */
 
+#include "AliHLTLogging.h"
 #include "TObject.h"
 
-class AliHLTTPCDigitReader{
+class AliHLTTPCDigitReader : public AliHLTLogging {
 public:
   AliHLTTPCDigitReader();
   virtual ~AliHLTTPCDigitReader();
   
-  virtual int InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow)=0;
+  virtual int InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow, Int_t patch, Int_t slice)=0;
   virtual bool Next()=0;
   virtual int GetRow()=0;
   virtual int GetPad()=0;
index 3ad77b0626aec9f1671fe194696dfa0de2993566..e3d097d26e0152a44b5c8d28a4b1d6b5f1be4d7f 100644 (file)
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
 // class for reading packed data for the HLT                                 //
+// includes reordering of the pads                                           //
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#if __GNUC__== 3
+
+#if __GNUC__>= 3
 using namespace std;
 #endif
 
 #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
 #include "AliHLTTPCDigitReaderPacked.h"
+
 #include "AliTPCRawStream.h"
 #include "AliRawReaderMemory.h"
 #include "AliRawDataHeader.h"
 
+#if ENABLE_PAD_SORTING
+#include "AliHLTTPCTransform.h"
+#endif // ENABLE_PAD_SORTING
 #include "AliHLTStdIncludes.h"
 
 ClassImp(AliHLTTPCDigitReaderPacked)
 
 AliHLTTPCDigitReaderPacked::AliHLTTPCDigitReaderPacked(){
   fRawMemoryReader = new AliRawReaderMemory;
+  
   fTPCRawStream = new AliTPCRawStream( fRawMemoryReader );
+
+#if ENABLE_PAD_SORTING
+  fCurrentRow = 0;
+  fCurrentPad = 0;
+  fCurrentBin = -1;
+
+  fNRows = 0;
+  fRowOffset = 0;
+
+  // get max number of rows
+  fNMaxRows = 0;
+  for (Int_t ii=0; ii < 6; ii++)
+      if (AliHLTTPCTransform::GetNRows(ii) > fNMaxRows) 
+         fNMaxRows = AliHLTTPCTransform::GetNRows(ii);
+
+  // get max number of pads
+  fNMaxPads = 0;
+  for (Int_t ii=0; ii < AliHLTTPCTransform::GetNRows();ii++ )
+      if (AliHLTTPCTransform::GetNPads(ii) > fNMaxPads) 
+         fNMaxPads = AliHLTTPCTransform::GetNPads(ii);
+
+  // get max number of bins
+  fNTimeBins = AliHLTTPCTransform::GetNTimeBins();
+
+  HLTDebug("||| MAXPAD=%d ||| MAXROW=%d ||| MAXBIN=%d ||| MAXMUL=%d", 
+          fNMaxPads, fNMaxRows, fNTimeBins, fNTimeBins*fNMaxRows*fNMaxPads);
+
+  // init Data array
+  fData = new Int_t[ fNMaxRows*fNMaxPads*fNTimeBins ];
+#endif // ENABLE_PAD_SORTING
 }
 
 AliHLTTPCDigitReaderPacked::~AliHLTTPCDigitReaderPacked(){
@@ -47,42 +84,145 @@ AliHLTTPCDigitReaderPacked::~AliHLTTPCDigitReaderPacked(){
     delete fRawMemoryReader;
   fRawMemoryReader = NULL;
   if ( fTPCRawStream )
-    delete fTPCRawStream;
+      delete fTPCRawStream;
   fTPCRawStream = NULL;
+#if ENABLE_PAD_SORTING 
+  if ( fData )
+      delete [] fData;
+  fData = NULL;
+#endif // ENABLE_PAD_SORTING
 }
 
-int AliHLTTPCDigitReaderPacked::InitBlock(void* ptr,unsigned long size,Int_t firstrow, Int_t lastrow){
+Int_t AliHLTTPCDigitReaderPacked::InitBlock(void* ptr,unsigned long size,Int_t firstrow, Int_t lastrow, Int_t patch, Int_t slice){
+
   fRawMemoryReader->SetMemory( reinterpret_cast<UChar_t*>( ptr ), size );
+
+  //get DDL ID in order to tell the memory reader which slice/patch to use
+  Int_t DDLid= 0;
+  if (patch < 2)
+    DDLid = 2 *slice + patch;
+  else 
+    DDLid = 70 + 4*slice + patch;
+
+  //fRawMemoryReader->SetEquipmentID(DDLid);
+//fRawMemoryReader->SetEquipmentID(1);
+
+// fTPCRawStream->SetOldRCUFormat(kTRUE);
+
+#if ENABLE_PAD_SORTING
+
+  fCurrentRow = 0;
+  fCurrentPad = 0;
+  fCurrentBin = -1;
+
+  fNRows = lastrow - firstrow + 1;
+
+  Int_t offset=0;
+  if (patch > 1) offset =  AliHLTTPCTransform::GetFirstRow( 2 );
+
+  fRowOffset = firstrow - offset;
+  firstrow -= offset;
+  lastrow  -= offset;
+
+  // Init array with -1
+  memset( fData, 0xFF, sizeof(Int_t)*(fNMaxRows*fNMaxPads*fNTimeBins) );
+
+  // read data and fill in array
+  while( fTPCRawStream->Next()){
+
+      Int_t row = fTPCRawStream->GetRow();
+      Int_t pad = fTPCRawStream->GetPad();
+      Int_t bin = fTPCRawStream->GetTime();
+
+      if ( row < firstrow || row > lastrow || pad > AliHLTTPCTransform::GetNPads(row + offset) || bin > fNTimeBins){
+       HLTFatal("Index out of Range Probably wrong patch! %d - %d", slice, patch);
+       if ( row < firstrow || row > lastrow ) 
+         HLTFatal("Row out of Range %d < %d < %d",firstrow, row, lastrow);
+       if ( pad > AliHLTTPCTransform::GetNPads(row + offset) ) 
+         HLTFatal("Pad out of Range %d < %d < %d",pad, AliHLTTPCTransform::GetNPads(row + offset));
+       if ( bin > fNTimeBins )
+         HLTFatal("Bin out of Range %d < %d < %d",bin, fNTimeBins);
+      }
+      else {  
+         if ((row-fRowOffset)*fNMaxPads*fNTimeBins+ pad*fNTimeBins + bin >=  fNMaxRows*fNMaxPads*fNTimeBins ) {
+             HLTFatal("Index out of array range PAD=%d ||| ROW=%d ||| BIN=%d ||| OFFSET=%d ||| ROWOFFSET=%d", pad, row, bin, offset, fRowOffset);
+             continue;
+         }
+         else {
+             fData[ (row-fRowOffset)*fNMaxPads*fNTimeBins+ pad*fNTimeBins + bin ] = fTPCRawStream->GetSignal() ;
+         }
+      }
+  }
+#endif // ENABLE_PAD_SORTING
+
   return 0;
 }
 
-bool AliHLTTPCDigitReaderPacked::Next(){
-  bool rreadvalue;
-  rreadvalue = fTPCRawStream->Next();
-  return rreadvalue;
+Bool_t AliHLTTPCDigitReaderPacked::Next(){
+  Bool_t readvalue = kTRUE;
+
+#if ENABLE_PAD_SORTING
+  while (1) {
+      fCurrentBin++;
+      if (fCurrentBin >= fNTimeBins){
+         fCurrentBin = 0;
+         fCurrentPad++;
+     
+         if (fCurrentPad >=fNMaxPads){
+             fCurrentPad = 0;
+             fCurrentRow++;
+             
+             if (fCurrentRow >= fNMaxRows){
+                 readvalue = kFALSE;
+                 break;
+             }
+         }
+      }
+
+      if (fCurrentRow*fNMaxPads*fNTimeBins+ fCurrentPad*fNTimeBins + fCurrentBin >=  fNMaxRows*fNMaxPads*fNTimeBins ) {
+         HLTFatal("Overflow: row=%d pad=%d bin=%d", fCurrentRow, fCurrentPad, fCurrentBin);
+         readvalue = kFALSE;
+         break;
+      }
+
+      if (fData[ fCurrentRow*fNMaxPads*fNTimeBins + fCurrentPad*fNTimeBins + fCurrentBin  ] != -1) break;
+  }
+#else // !ENABLE_PAD_SORTING
+  readvalue = fTPCRawStream->Next();
+#endif // ENABLE_PAD_SORTING
+
+  return readvalue;
 }
 
-int AliHLTTPCDigitReaderPacked::GetRow(){
-  int rrow;
-  rrow = (int)fTPCRawStream->GetRow();
-  return rrow;
+Int_t AliHLTTPCDigitReaderPacked::GetRow(){
+#if ENABLE_PAD_SORTING
+  return (fCurrentRow + fRowOffset);
+#else // !ENABLE_PAD_SORTING
+  return (Int_t) fTPCRawStream->GetRow();
+#endif // ENABLE_PAD_SORTING
 }
 
 int AliHLTTPCDigitReaderPacked::GetPad(){
-  int rpad;
-  rpad = fTPCRawStream->GetPad();
-  return rpad   ;
+#if ENABLE_PAD_SORTING
+  return fCurrentPad;
+#else // !ENABLE_PAD_SORTING
+  return fTPCRawStream->GetPad();
+#endif // ENABLE_PAD_SORTING
 }
 
-int AliHLTTPCDigitReaderPacked::GetSignal(){ 
-  int rsignal;
-  rsignal = fTPCRawStream->GetSignal();
-  return rsignal;
+Int_t AliHLTTPCDigitReaderPacked::GetSignal(){ 
+#if ENABLE_PAD_SORTING
+  return fData[ fCurrentRow*fNMaxPads*fNTimeBins+ fCurrentPad*fNTimeBins + fCurrentBin ];
+#else // !ENABLE_PAD_SORTING
+  return fTPCRawStream->GetSignal();
+#endif // ENABLE_PAD_SORTING
 }
 
-int AliHLTTPCDigitReaderPacked::GetTime(){
-  int rtime;
-  rtime = fTPCRawStream->GetTime();
-  return rtime;
+Int_t AliHLTTPCDigitReaderPacked::GetTime(){
+#if ENABLE_PAD_SORTING
+  return fCurrentBin;
+#else // !ENABLE_PAD_SORTING
+  return fTPCRawStream->GetTime();
+#endif // ENABLE_PAD_SORTING
 }
 #endif //defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
index 286d7200b1076236541f6612404404f2095d4221..b7698b7ca07a6f974520e5a945449423a1110b31 100644 (file)
@@ -4,6 +4,8 @@
 #ifndef ALIHLTTPCDIGITREADERPACKED_H
 #define ALIHLTTPCDIGITREADERPACKED_H
 
+#define ENABLE_PAD_SORTING 1
+
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
 #if defined(HAVE_ALIRAWDATA) && defined(HAVE_ALITPCRAWSTREAM_H)
 
 class AliRawReaderMemory;
+
 class AliTPCRawStream;
 
 class AliHLTTPCDigitReaderPacked : public AliHLTTPCDigitReader{
 public:
-  AliHLTTPCDigitReaderPacked();
-  virtual ~AliHLTTPCDigitReaderPacked();
-  
-  int InitBlock(void* ptr,unsigned long size, Int_t firstrow, Int_t lastrow);
-  bool Next();
-  int GetRow();
-  int GetPad();
-  int GetSignal();
-  int GetTime();
+    AliHLTTPCDigitReaderPacked(); 
+    virtual ~AliHLTTPCDigitReaderPacked();
   
+  Int_t InitBlock(void* ptr,ULong_t size, Int_t firstrow, Int_t lastrow, Int_t patch, Int_t slice);
+    Bool_t Next();
+    Int_t GetRow();
+    Int_t GetPad();
+    Int_t GetSignal();
+    Int_t GetTime();
+    
 protected:
-
+    
 private:
-  // Initialize AliROOT TPC raw stream parsing class
-  AliRawReaderMemory *fRawMemoryReader;
-  AliTPCRawStream *fTPCRawStream;
-  
-  ClassDef(AliHLTTPCDigitReaderPacked, 0)
+    // Initialize AliROOT TPC raw stream parsing class
+    AliRawReaderMemory *fRawMemoryReader;
+
+    AliTPCRawStream *fTPCRawStream;
     
+#if ENABLE_PAD_SORTING 
+    Int_t fCurrentRow;
+    Int_t fCurrentPad;
+    Int_t fCurrentBin;
+    Int_t fRowOffset;
+    Int_t fNRows;
+
+    Int_t fNMaxRows;
+    Int_t fNMaxPads;
+    Int_t fNTimeBins;
+
+    Int_t *fData;
+#endif // ENABLE_PAD_SORTING
+    ClassDef(AliHLTTPCDigitReaderPacked, 0)
+       
 };
 
 #else
diff --git a/HLT/TPCLib/AliHLTTPCDigitReaderRaw.cxx b/HLT/TPCLib/AliHLTTPCDigitReaderRaw.cxx
new file mode 100644 (file)
index 0000000..7e3d843
--- /dev/null
@@ -0,0 +1,567 @@
+// $Id$
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Authors: Matthias Richter <Matthias.Richter@ift.uib.no>                *
+ *          Timm Steinbeck <timm@kip.uni-heidelberg.de>                   *
+ *          Jochen Thaeder <thaeder@kip.uni-heidelberg.de>                *
+ *          for The ALICE Off-line Project.                               *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+// base class for reading packed and unpacked data for the HLT               //
+//                                                                           //
+///////////////////////////////////////////////////////////////////////////////
+
+#if __GNUC__>= 3
+using namespace std;
+#endif
+
+#if defined(HAVE_TPC_MAPPING)
+
+#include "AliHLTTPCDigitReaderRaw.h"
+#include "AliHLTTPCTransform.h"
+#include "AliHLTTPCRootTypes.h"
+#include "AliHLTTPCStandardIncludes.h"
+#include "AliHLTTPCLogging.h"
+
+ClassImp(AliHLTTPCDigitReaderRaw)
+
+  char gTmpHexBuffer[16][128];
+char* AsHex( AliHLTUInt64_t value, unsigned off=0 )
+{
+  sprintf( gTmpHexBuffer[off], "%016LX", (unsigned long long)value );
+  return gTmpHexBuffer[off];
+}
+
+AliHLTTPCDigitReaderRaw::AliHLTTPCDigitReaderRaw( unsigned formatVersion ){
+    fBuffer = NULL;
+    fBufferSize = 0;
+    fPatch = -1;
+    fSlice = -1;
+    fDataFormatVersion = formatVersion;
+    fCurrentRow = 0;
+    fCurrentPad = 0;
+    fCurrentBin = -1;
+    fVerify = false;
+    
+    // For sorting
+    fNRows = 0;
+    fRowOffset = 0;
+    fNMaxRows = 0;
+    fNMaxPads = 0;
+    fNTimeBins = 0;
+    fData = NULL;
+
+    if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
+      {
+       
+       // get max number of rows
+       for (Int_t ii=0; ii < 6; ii++)
+         if (AliHLTTPCTransform::GetNRows(ii) > fNMaxRows) 
+           fNMaxRows = AliHLTTPCTransform::GetNRows(ii);
+       
+       // get max number of pads
+       for (Int_t ii=0; ii < AliHLTTPCTransform::GetNRows();ii++ )
+         if (AliHLTTPCTransform::GetNPads(ii) > fNMaxPads) 
+           fNMaxPads = AliHLTTPCTransform::GetNPads(ii);
+       
+       // get max number of bins
+       fNTimeBins = AliHLTTPCTransform::GetNTimeBins();
+       
+       LOG(AliHLTTPCLog::kDebug,"AliHLTTPCDigitReaderRaw::AliHLTTPCDigitReaderRaw","Array Borders") 
+         << " ||| MAXPAD="   << fNMaxPads  << " ||| MAXROW="  << fNMaxRows 
+         << " ||| MAXBIN="   << fNTimeBins << " ||| MAXMUL="  << fNTimeBins*fNMaxRows*fNMaxPads << ENDLOG;
+       
+       // init Data array
+       fData = new Int_t[ fNMaxRows*fNMaxPads*fNTimeBins ];
+      }
+}
+
+AliHLTTPCDigitReaderRaw::~AliHLTTPCDigitReaderRaw(){
+  if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
+    {
+      if ( fData )
+       delete [] fData;
+      fData = NULL;
+    }
+}
+
+int AliHLTTPCDigitReaderRaw::InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow, Int_t patch, Int_t slice){
+
+    fBuffer = (AliHLTUInt8_t*) ptr;
+    fBufferSize = size;
+    fPatch = patch;
+    fSlice = slice;
+    fPad = -1;
+    fRow = -1;
+    
+    fAltroBlockPositionBytes = 0;
+    fAltroBlockLengthBytes = 0;
+    fAltroBlock10BitWordCnt = 0xFFFFU;
+    fAltroBlockHWAddress = 0xFFFFU;
+    fBunchPosition = 0xFFFFU;
+    fBunchTimebinStart = ~0U;
+    fBunchLength = 0;
+    fWordInBunch = (unsigned)-1;
+
+
+    if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
+      {
+       fCurrentRow = 0;
+       fCurrentPad = 0;
+       fCurrentBin = -1;
+       
+       fNRows = lastrow - firstrow + 1;
+       
+       Int_t offset=0;
+       if (patch > 1) offset =  AliHLTTPCTransform::GetFirstRow( 2 );
+       
+       fRowOffset = firstrow - offset;
+       firstrow -= offset;
+       lastrow  -= offset;
+       
+       // Init array with -1
+       memset( fData, 0xFF, sizeof(Int_t)*(fNMaxRows*fNMaxPads*fNTimeBins) );
+       
+       // read data and fill in array
+       while( RealNext()){
+         
+         Int_t row = GetRealRow();
+         Int_t pad = GetRealPad();
+         Int_t bin = GetRealTime();
+         
+//       LOG(AliHLTTPCLog::kFatal,"AliHLTTPCDigitReaderRaw::FILL","Index out of array range") 
+//             << "PAD=" << pad  << " ||| ROW=" << row << " ||| BIN="  <<  bin   <<" ||| OFFSET="<< offset <<" ||| ROWOFFSET="<< fRowOffset << ENDLOG;
+
+         if ( row < firstrow || row > lastrow || pad > AliHLTTPCTransform::GetNPads(row + offset) || bin > fNTimeBins || pad<0 || bin<0){
+//       if ( row < firstrow || row > lastrow || pad > AliHLTTPCTransform::GetNPads(row + offset) || bin > fNTimeBins){
+           LOG(AliHLTTPCLog::kFatal,"AliHLTTPCDigitReaderRaw::InitBlock","Index out of Range") << "Probably wrong patch!"<< slice << "-" << patch << ENDLOG;
+           LOG(AliHLTTPCLog::kFatal,"AliHLTTPCDigitReaderRaw::FILL","Index out of array range") 
+             << "PAD=" << pad <<"|" << AliHLTTPCTransform::GetNPads(row + offset)
+             << " ||| ROW=" << row <<"|" << firstrow <<"|" << lastrow
+             << " ||| BIN="  <<  bin <<"|" <<  fNTimeBins
+             <<" ||| OFFSET="<< offset <<" ||| ROWOFFSET="<< fRowOffset << ENDLOG;
+
+           if ( row < firstrow || row > lastrow ) 
+             LOG(AliHLTTPCLog::kFatal,"AliHLTTPCDigitReaderRaw::InitBlock","Row out of Range") << firstrow << "<" << row << "<" << lastrow << ENDLOG;
+           if ( pad > AliHLTTPCTransform::GetNPads(row + offset) ) 
+             LOG(AliHLTTPCLog::kFatal,"AliHLTTPCDigitReaderRaw::InitBlock","Pad out of Range") << pad << "<" << AliHLTTPCTransform::GetNPads(row + offset)  << ENDLOG;
+           if ( bin > fNTimeBins )
+             LOG(AliHLTTPCLog::kFatal,"AliHLTTPCDigitReaderRaw::InitBlock","Bin out of Range") << bin << "<" << fNTimeBins << ENDLOG;
+         }
+         else {  
+           if ((row-fRowOffset)*fNMaxPads*fNTimeBins+ pad*fNTimeBins + bin >=  fNMaxRows*fNMaxPads*fNTimeBins ) {
+             LOG(AliHLTTPCLog::kFatal,"AliHLTTPCDigitReaderRaw::FILL","Index out of array range") 
+               << "PAD=" << pad  << " ||| ROW=" << row << " ||| BIN="  <<  bin   <<" ||| OFFSET="<< offset <<" ||| ROWOFFSET="<< fRowOffset << ENDLOG;
+             continue;
+           }
+           else {
+             fData[ (row-fRowOffset)*fNMaxPads*fNTimeBins+ pad*fNTimeBins + bin ] = GetRealSignal() ;
+           }
+         }
+       }
+      }
+
+    return 0;
+}
+
+bool AliHLTTPCDigitReaderRaw::Next(){
+  if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
+    {
+      Bool_t readvalue = kTRUE;
+      while (1) {
+       fCurrentBin++;
+       if (fCurrentBin >= fNTimeBins){
+         fCurrentBin = 0;
+         fCurrentPad++;
+         
+         if (fCurrentPad >=fNMaxPads){
+           fCurrentPad = 0;
+           fCurrentRow++;
+           
+           if (fCurrentRow >= fNMaxRows){
+             readvalue = kFALSE;
+             break;
+           }
+         }
+       }
+       
+       if (fCurrentRow*fNMaxPads*fNTimeBins+ fCurrentPad*fNTimeBins + fCurrentBin >=  fNMaxRows*fNMaxPads*fNTimeBins ) {
+         LOG(AliHLTTPCLog::kFatal,"AliHLTTPCDigitReaderRaw::NEXT","Overflow") << fCurrentRow << " " << fCurrentPad << " " << fCurrentBin << ENDLOG;
+         readvalue = kFALSE;
+         break;
+       }
+       
+       if (fData[ fCurrentRow*fNMaxPads*fNTimeBins + fCurrentPad*fNTimeBins + fCurrentBin  ] != -1) break;
+      }
+      return readvalue;
+    }
+  else
+    return RealNext();
+}
+
+int AliHLTTPCDigitReaderRaw::GetRow(){
+  if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
+    {
+      return (fCurrentRow + fRowOffset);
+    }
+  else
+    return GetRealRow();
+}
+int AliHLTTPCDigitReaderRaw::GetPad(){
+  if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
+    {
+      return fCurrentPad;
+    }
+  else
+    return GetRealPad();
+}
+int AliHLTTPCDigitReaderRaw::GetSignal(){
+  if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
+    {
+      return fData[ fCurrentRow*fNMaxPads*fNTimeBins+ fCurrentPad*fNTimeBins + fCurrentBin ];
+    }
+  else
+    return GetRealSignal();
+}
+int AliHLTTPCDigitReaderRaw::GetTime(){
+  if ( fDataFormatVersion==0 || fDataFormatVersion==2 )
+    {
+      return fCurrentBin;
+    }
+  else
+    return GetRealTime();
+}
+
+
+bool AliHLTTPCDigitReaderRaw::RealNext(){
+//    printf( "%u %u %u %u %u\n", fBunchPosition, fBunchLength, fBunchTimebinStart, fWordInBunch, (unsigned)fAltroBlock10BitWordCnt );
+    fWordInBunch++; // use next word in bunch
+    if ( fWordInBunch==fBunchLength ) { // we have a bunch at all but have reached its end (or do not have an altro block yet)
+       if ( fBunchPosition+fBunchLength==fAltroBlock10BitWordCnt ) { // We were at the last bunch of this altro block (or do not have an altro block yet)
+           if ( !NextAltroBlock() )
+               return false;
+           fBunchPosition = 0;
+       }
+       else {
+           fBunchPosition += fBunchLength;
+       }
+       fBunchLength = GetAltroBlock10BitWord( fBunchPosition );
+       fBunchTimebinStart = GetAltroBlock10BitWord( fBunchPosition+1 );
+       fWordInBunch = 2;
+    }
+//    printf( "%u %u %u %u %u\n", fBunchPosition, fBunchLength, fBunchTimebinStart, fWordInBunch, (unsigned)fAltroBlock10BitWordCnt );
+    return true;
+}
+int AliHLTTPCDigitReaderRaw::GetRealRow(){
+    return fRow;
+}
+int AliHLTTPCDigitReaderRaw::GetRealPad(){
+    return fPad;
+}
+int AliHLTTPCDigitReaderRaw::GetRealSignal(){
+    return GetAltroBlock10BitWord( fBunchPosition+fWordInBunch );
+}
+int AliHLTTPCDigitReaderRaw::GetRealTime(){
+  //printf( "GetRealTime: %u - %u\n", fBunchTimebinStart, fWordInBunch );
+    return fBunchTimebinStart-(fWordInBunch-2);
+}
+
+AliHLTUInt32_t AliHLTTPCDigitReaderRaw::GetRCUTrailer(){
+unsigned rcuDataBlockLen = GetRCUDataBlockLength(); 
+return *((AliHLTUInt32_t*)(fBuffer+fBufferSize-rcuDataBlockLen));
+}
+
+bool AliHLTTPCDigitReaderRaw::NextAltroBlock()
+    {
+    if ( !fAltroBlockLengthBytes )
+       {
+       // First block in back linked list (last block in memory)
+       fAltroBlockPositionBytes = fBufferSize-GetRCUDataBlockLength();
+       }
+    else
+       {
+       if ( fAltroBlockPositionBytes<fAltroBlockLengthBytes+GetCommonDataHeaderSize() )
+         {
+           LOG(AliHLTTPCLog::kFatal,"AliHLTTPCDigitReaderRaw::NextAltroBlock","Data Error")
+             << "Inconsistent Data: fAltroBlockPositionBytes: " << AliHLTTPCLog::kDec << fAltroBlockPositionBytes << " - fAltroBlockLengthBytes: " << fAltroBlockLengthBytes << "." << ENDLOG;
+         }
+       if ( fAltroBlockPositionBytes<=fAltroBlockLengthBytes+GetCommonDataHeaderSize() )
+           return false; // We have reached the end of the back linked list
+       fAltroBlockPositionBytes -= fAltroBlockLengthBytes;
+       }
+
+      AliHLTUInt64_t altroTrailerWord = GetAltroBlock40BitWord( 0 );
+
+      if ( fVerify && ((altroTrailerWord & 0xFFFC000000ULL)!=0xAAA8000000ULL) )
+       {
+         LOG(AliHLTTPCLog::kFatal,"AliHLTTPCDigitReaderRaw::NextAltroBlock","Data Error")
+           << "Data inconsistency in Altro Block at byte position 0x" << AsHex( fAltroBlockPositionBytes, 0 ) << " (" << AliHLTTPCLog::kDec
+           << fAltroBlockPositionBytes << "): Expected 0x2AAA in high 14 bits of altro trailer word; Found 0x" << AsHex( ((altroTrailerWord & 0xFFFC000000ULL) >> 26), 1 ) << " (" << AsHex( altroTrailerWord, 2 ) << ")" << "." << ENDLOG;
+
+
+         return false;
+       }
+
+      if ( fVerify && ((altroTrailerWord & 0x000000F000ULL)!=0x000000A000ULL) )
+       {
+         LOG(AliHLTTPCLog::kFatal,"AliHLTTPCDigitReaderRaw::NextAltroBlock","Data Error")
+           << "Data inconsistency in Altro Block at byte position 0x" << AsHex( fAltroBlockPositionBytes, 0 ) << " (" << AliHLTTPCLog::kDec
+           << fAltroBlockPositionBytes << "): Expected 0xA in bits 12-15 of altro trailer word; Found 0x" << AsHex( ((altroTrailerWord & 0x000000F000ULL) >> 12), 1 ) << "." << ENDLOG;
+
+         return false;
+       }
+
+      fAltroBlock10BitWordCnt = (altroTrailerWord >> 16) & 0x3FF;
+      fAltroBlockHWAddress = altroTrailerWord & 0xFFF;
+
+      // ApplyMapping
+      if (!ApplyMapping())
+       {
+         LOG(AliHLTTPCLog::kFatal,"AliHLTTPCDigitReaderRaw::NextAltroBlock","Mapping Error")
+           << "Mapping failed Patch " << AliHLTTPCLog::kDec << fPatch << " HWA 0x"
+           << AsHex( fAltroBlockHWAddress, 0 ) << " (" << AliHLTTPCLog::kDec
+           << fAltroBlockHWAddress << ") - maxHWA 0x" << AsHex( fMaxHWA[fPatch], 1 )
+           << AliHLTTPCLog::kDec << " (" << fMaxHWA[fPatch] << ")." << ENDLOG;
+
+       }
+
+      unsigned words40Bit = fAltroBlock10BitWordCnt/4;
+      if ( fAltroBlock10BitWordCnt % 4 )
+         words40Bit++;
+      words40Bit++;
+      fAltroBlockLengthBytes = words40Bit*5;
+    if ( fAltroBlock10BitWordCnt % 4 )
+       fAltroBlock10BitFillWordCnt = 4-(fAltroBlock10BitWordCnt % 4);
+    else
+       fAltroBlock10BitFillWordCnt=0;
+    if ( fVerify )
+      {
+       for ( unsigned b = 0; b < fAltroBlock10BitFillWordCnt; b++ )
+         {
+           if ( GetAltroBlockReal10BitWord(b)!=0x2AA )
+             {
+               LOG(AliHLTTPCLog::kFatal,"AliHLTTPCDigitReaderRaw::NextAltroBlock","Data Error")
+                 << "Data inconsistency in trailing 10 bit fill word of Altro Block at byte position 0x" << AliHLTTPCLog::kHex
+                 << AsHex( fAltroBlockPositionBytes, 0 ) << " (" << AliHLTTPCLog::kDec
+                 << fAltroBlockPositionBytes << "): Expected 0x2AA; Found 0x" << AliHLTTPCLog::kHex << AsHex( GetAltroBlockReal10BitWord(b), 1 ) << "." << ENDLOG;
+               
+               return false;
+             }
+         }
+      }
+    return true;
+    }
+
+AliHLTUInt32_t AliHLTTPCDigitReaderRaw::GetAltroBlockHWaddr(){
+return fAltroBlockHWAddress;
+}
+unsigned AliHLTTPCDigitReaderRaw::GetAltroBlock10BitWordCnt(){
+return fAltroBlock10BitWordCnt;
+}
+AliHLTUInt64_t AliHLTTPCDigitReaderRaw::GetAltroBlock40BitWord( unsigned long ndx ){
+AliHLTUInt64_t val=0;
+unsigned wordOffset32Bit = (ndx / 4)*5;
+switch ( ndx % 4 ) // 40 bit word index in a 4*40 bit=5*32 bit group
+    {
+    case 0:
+       val = (*(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+1)*sizeof(AliHLTUInt32_t)));
+       val <<= 8;
+       val |= (*(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+2)*sizeof(AliHLTUInt32_t))) >> 24;
+       break;
+    case 1:
+       val = ((*(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+2)*sizeof(AliHLTUInt32_t))) & 0x00FFFFFF);
+       val <<= 16;
+       val |= ((*(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+3)*sizeof(AliHLTUInt32_t))) >> 16) & 0xFFFF;
+       break;
+    case 2:
+       val = ((*(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+3)*sizeof(AliHLTUInt32_t))) & 0xFFFF);
+       val <<= 24;
+       val |= ((*(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+4)*sizeof(AliHLTUInt32_t))) >> 8);
+       break;
+    case 3:
+       val = ((*(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+4)*sizeof(AliHLTUInt32_t))) & 0xFF);
+       val <<= 32;
+       val |= *(AliHLTUInt32_t*)(fBuffer+fAltroBlockPositionBytes-(wordOffset32Bit+5)*sizeof(AliHLTUInt32_t));
+       break;
+    }
+return val;
+}
+AliHLTUInt16_t AliHLTTPCDigitReaderRaw::GetAltroBlock10BitWord( unsigned long ndx ){
+unsigned long realNdx = ndx+fAltroBlock10BitFillWordCnt;
+unsigned long word40BitNdx = (realNdx / 4)+1;
+AliHLTUInt64_t word40Bit = GetAltroBlock40BitWord( word40BitNdx );
+switch ( realNdx % 4 )
+    {
+    case 3:
+       return word40Bit & 0x3FF;
+    case 2:
+       return (word40Bit>>10) & 0x3FF;
+    case 1:
+       return (word40Bit>>20) & 0x3FF;
+    case 0:
+       return (word40Bit>>30) & 0x3FF;
+    }
+
+ return 0xFFFF; 
+}
+
+AliHLTUInt16_t AliHLTTPCDigitReaderRaw::GetAltroBlockReal10BitWord( unsigned long ndx ){
+unsigned long word40BitNdx = (ndx / 4)+1;
+AliHLTUInt64_t word40Bit = GetAltroBlock40BitWord( word40BitNdx );
+switch ( ndx % 4 )
+    {
+    case 3:
+       return word40Bit & 0x3FF;
+    case 2:
+       return (word40Bit>>10) & 0x3FF;
+    case 1:
+       return (word40Bit>>20) & 0x3FF;
+    case 0:
+       return (word40Bit>>30) & 0x3FF;
+    }
+
+ return 0xFFFF; 
+}
+
+// Return length of trailing RCU data block in bytes
+unsigned AliHLTTPCDigitReaderRaw::GetRCUDataBlockLength() const
+    {
+    switch ( fDataFormatVersion )
+       {
+       case 0:
+       case 1:
+           return 4;
+           break;
+       case 2:
+       case 3:
+           return 12;
+           break;
+       default:
+           return fBufferSize;
+       }
+    }
+
+unsigned AliHLTTPCDigitReaderRaw::GetCommonDataHeaderSize() const
+    {
+    return 32;
+    }
+
+
+Bool_t AliHLTTPCDigitReaderRaw::ApplyMapping(){
+
+    if ( (unsigned)fAltroBlockHWAddress > fMaxHWA[fPatch]){
+       fPad = -1;
+       fRow = -1;
+       return kFALSE;
+    }
+
+    switch(fPatch){
+       case 0:
+           fRow = fMapping_0[(unsigned)fAltroBlockHWAddress][0];
+           fPad = fMapping_0[(unsigned)fAltroBlockHWAddress][1];
+           break;
+        case 1:
+           fRow = AliHLTTPCDigitReaderRaw::fMapping_1[(unsigned)fAltroBlockHWAddress][0];
+           fPad = AliHLTTPCDigitReaderRaw::fMapping_1[(unsigned)fAltroBlockHWAddress][1];
+#if 0
+           printf ("pad %d # row %d (hwa: %u / 0x%08X\n", fMapping_1[(unsigned)fAltroBlockHWAddress][0],fMapping_1[(unsigned)fAltroBlockHWAddress][1], (unsigned)fAltroBlockHWAddress, (unsigned)fAltroBlockHWAddress);
+           printf ("pad %d # row %d (hwa: %u / 0x%08X\n", fMapping_1[(unsigned)fAltroBlockHWAddress-1][0],fMapping_1[(unsigned)fAltroBlockHWAddress-1][1], (unsigned)fAltroBlockHWAddress-1, (unsigned)fAltroBlockHWAddress-1);
+           printf ("pad %d # row %d (hwa: %u / 0x%08X\n", fMapping_1[(unsigned)fAltroBlockHWAddress+1][0],fMapping_1[(unsigned)fAltroBlockHWAddress+1][1], (unsigned)fAltroBlockHWAddress+1, (unsigned)fAltroBlockHWAddress+1);
+#endif
+           break;
+       case 2:
+           fRow = fMapping_2[(unsigned)fAltroBlockHWAddress][0];
+           fPad = fMapping_2[(unsigned)fAltroBlockHWAddress][1];
+           break;
+        case 3:
+           fRow = fMapping_3[(unsigned)fAltroBlockHWAddress][0];
+           fPad = fMapping_3[(unsigned)fAltroBlockHWAddress][1];
+           break;
+       case 4:
+           fRow = fMapping_4[(unsigned)fAltroBlockHWAddress][0];
+           fPad = fMapping_4[(unsigned)fAltroBlockHWAddress][1];
+           break;
+        case 5:
+           fRow = fMapping_5[(unsigned)fAltroBlockHWAddress][0];
+           fPad = fMapping_5[(unsigned)fAltroBlockHWAddress][1];
+           break;
+       default:
+           fRow = -1;
+           fPad = -1;
+           return kFALSE;
+    }
+    return kTRUE;
+}
+
+
+Int_t AliHLTTPCDigitReaderRaw::GetRow( unsigned patch, unsigned hw_addr )
+{
+    if ( (unsigned)hw_addr > fMaxHWA[fPatch]){
+       return -1;
+    }
+
+    switch(fPatch){
+       case 0:
+           return fMapping_0[hw_addr][0];
+        case 1:
+           return fMapping_1[hw_addr][0];
+       case 2:
+           return fMapping_2[hw_addr][0];
+        case 3:
+           return fMapping_3[hw_addr][0];
+       case 4:
+           return fMapping_4[hw_addr][0];
+        case 5:
+           return fMapping_5[hw_addr][0];
+       default:
+         return -1;
+    }
+}
+Int_t AliHLTTPCDigitReaderRaw::GetPad( unsigned patch, unsigned hw_addr )
+{
+    if ( (unsigned)hw_addr > fMaxHWA[fPatch]){
+       return -1;
+    }
+
+    switch(fPatch){
+       case 0:
+           return fMapping_0[hw_addr][1];
+        case 1:
+           return fMapping_1[hw_addr][1];
+       case 2:
+           return fMapping_2[hw_addr][1];
+        case 3:
+           return fMapping_3[hw_addr][1];
+       case 4:
+           return fMapping_4[hw_addr][1];
+        case 5:
+           return fMapping_5[hw_addr][1];
+       default:
+         return -1;
+    }
+}
+
+unsigned AliHLTTPCDigitReaderRaw::GetMaxHWA( unsigned patch )
+{
+  if ( patch>=6 )
+    return 0;
+  return fMaxHWA[patch];
+}
+
+
+// ----- MAPPING ARRAYS
+#include "mapping_array_out.inc"
+
+#endif //#if defined(HAVE_TPC_MAPPING)
diff --git a/HLT/TPCLib/AliHLTTPCDigitReaderRaw.h b/HLT/TPCLib/AliHLTTPCDigitReaderRaw.h
new file mode 100644 (file)
index 0000000..ac95a51
--- /dev/null
@@ -0,0 +1,153 @@
+// XEmacs -*-C++-*-
+// @(#) $Id$
+
+#ifndef ALIHLTTPCDIGITREADERRAW_H
+#define ALIHLTTPCDIGITREADERRAW_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+/* AliHLTTPCDigitReaderRaw
+ */
+
+#include "TObject.h"
+
+#include "AliHLTLogging.h"
+
+#if defined(HAVE_TPC_MAPPING)
+#include "AliHLTTPCDigitReader.h"
+#include "AliHLTDataTypes.h"
+
+
+class AliHLTTPCDigitReaderRaw : public AliHLTTPCDigitReader  {
+public:
+  // Data Format version numbers:
+  // 0: RCU Data format as delivered during TPC commissioning, pads/padrows are sorted, RCU trailer is one 32 bit word.
+  // 1: As 0, but pads/padrows are delivered "as is", without sorting
+  // 2: As 0, but RCU trailer is 3 32 bit words.
+  // 3: As 1, but RCU trailer is 3 32 bit words.
+    AliHLTTPCDigitReaderRaw( unsigned formatVersion );
+    virtual ~AliHLTTPCDigitReaderRaw();
+    
+    virtual int InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow, Int_t patch, Int_t slice);
+  // Deliver values sorted for format 0, otherwise pass through to corresponding *Real* method
+    virtual bool Next();
+    virtual int GetRow();
+    virtual int GetPad();
+    virtual int GetSignal();
+    virtual int GetTime();
+
+  bool Verify( bool verify )
+  {
+    bool old = fVerify;
+    fVerify=verify;
+    return old;
+  }
+
+  bool GetVerify() const
+  {
+    return fVerify;
+  }
+
+  // Deliver values unsorted
+    bool RealNext();
+    int GetRealRow();
+    int GetRealPad();
+    int GetRealSignal();
+    int GetRealTime();
+
+  // Low level methods for accessing the data
+    AliHLTUInt32_t GetRCUTrailer();
+    bool NextAltroBlock();
+    AliHLTUInt32_t GetAltroBlockHWaddr();
+    unsigned GetAltroBlock10BitWordCnt();
+    AliHLTUInt64_t GetAltroBlock40BitWord( unsigned long ndx ); // ndx counts from end, 0 is last
+    AliHLTUInt16_t GetAltroBlock10BitWord( unsigned long ndx );
+    AliHLTUInt16_t GetAltroBlockReal10BitWord( unsigned long ndx );
+
+    unsigned GetAltroBlockPositionBytes() const
+       {return fAltroBlockPositionBytes;}
+    unsigned GetAltroBlockLengthBytes() const
+       {return fAltroBlockLengthBytes;}
+
+    // Return length of trailing RCU data block in bytes
+    unsigned GetRCUDataBlockLength() const;
+    unsigned GetCommonDataHeaderSize() const;
+       
+    Bool_t ApplyMapping();
+
+  Int_t GetRow( unsigned patch, unsigned hw_addr );
+  Int_t GetPad( unsigned patch, unsigned hw_addr );
+  unsigned GetMaxHWA( unsigned patch );
+
+protected:
+
+    AliHLTUInt8_t* fBuffer;
+    unsigned long fBufferSize;
+    /*
+    Int_t fFirstRow;
+    Int_t fLastRow;
+    */
+    Int_t fPatch;
+    Int_t fSlice;
+    Int_t fRow;
+    Int_t fPad;
+
+    unsigned fAltroBlockPositionBytes;
+    unsigned fAltroBlockLengthBytes;
+
+    AliHLTUInt16_t fAltroBlockHWAddress;
+    AliHLTUInt16_t fAltroBlock10BitWordCnt;
+    AliHLTUInt16_t fAltroBlock10BitFillWordCnt;
+
+    unsigned fDataFormatVersion;
+
+    unsigned fBunchPosition;
+    unsigned fBunchTimebinStart;
+    unsigned fBunchLength;
+    unsigned fWordInBunch;
+
+  bool fVerify;
+
+private:
+    static Int_t fMapping_0[3200][2];
+    static Int_t fMapping_1[3584][2];
+    static Int_t fMapping_2[3200][2];
+    static Int_t fMapping_3[3328][2];
+    static Int_t fMapping_4[3328][2];
+    static Int_t fMapping_5[3328][2];
+
+    static unsigned fMaxHWA[6];
+
+  // For reordering
+    Int_t fCurrentRow;
+    Int_t fCurrentPad;
+    Int_t fCurrentBin;
+    Int_t fRowOffset;
+    Int_t fNRows;
+
+    Int_t fNMaxRows;
+    Int_t fNMaxPads;
+    Int_t fNTimeBins;
+
+    Int_t *fData;
+
+
+  ClassDef(AliHLTTPCDigitReaderRaw, 0)
+    
+};
+
+#else
+// add a dummy class to make CINT happy
+class AliHLTTPCDigitReaderRaw : public AliHLTLogging{
+public:
+  AliHLTTPCDigitReaderRaw()
+  {
+    HLTFatal("AliHLTTPCDigitReaderRaw not build");
+  }
+};
+#endif //#if defined(HAVE_TPC_MAPPING)
+
+#endif
+
index b9fc2e1d58b848f0746b931f791a3f4d6d2cfeb7..7c568350145e00fb49382e5956a45d5887356a28 100644 (file)
@@ -48,7 +48,7 @@ AliHLTTPCDigitReaderUnpacked::AliHLTTPCDigitReaderUnpacked(){
 AliHLTTPCDigitReaderUnpacked::~AliHLTTPCDigitReaderUnpacked(){
 }
 
-int AliHLTTPCDigitReaderUnpacked::InitBlock(void* ptr,unsigned long size, Int_t firstrow, Int_t lastrow){
+int AliHLTTPCDigitReaderUnpacked::InitBlock(void* ptr,unsigned long size, Int_t firstrow, Int_t lastrow, Int_t patch, Int_t slice){
   AliHLTTPCUnpackedRawData *tmpptr;
   fPtr = ptr;
   fSize = size;
index 84bc8a936a7538dc2170eb3b01c9bb8d2257562e..e4e67c98a871fb370d5fb1ea8e4e26f01c9dcd60 100644 (file)
@@ -20,7 +20,7 @@ public:
   AliHLTTPCDigitReaderUnpacked();
   virtual ~AliHLTTPCDigitReaderUnpacked();
   
-  int InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow);
+  int InitBlock(void* ptr,unsigned long size,Int_t firstrow,Int_t lastrow, Int_t patch, Int_t slice);
   bool Next();
   int GetRow();
   int GetPad();
index 843f0c3d3c3278c200ff163b02146eb29599167e..914a8a6fcba968dd975370e1170bc45e7431944d 100644 (file)
 #define TRACKHELIX 0
 #define TRACKPOLYMARKER 0
 #define BACKWARD 0
+#define FIRSTLASTPOINT 0
+
+#define TRACKCOLOR 
+#define USEDCLUSTERCOLOR
+#define UNUSEDCLUSTERCOLOR
 
 #include <TView.h>
 #include <TPolyMarker3D.h>
@@ -145,6 +150,29 @@ Bool_t AliHLTTPCDisplay::LoadGeometrie(Char_t *gfile) {
     return kTRUE;
 }
 
+// #############################################################################
+//                 EXECUTER
+// #############################################################################
+void AliHLTTPCDisplay::ExecPadRow(){
+   int event = gPad->GetEvent();
+   if (event != 11) return;
+
+   printf("TEST !!!!!!!!!!!!!!!");
+/*   int px = gPad->GetEventX();
+   TObject *select = gPad->GetSelected();
+   if (!select) return;
+   if (select->InheritsFrom("TH1")) {
+      TH1 *h = (TH1*)select;
+      Float_t xx = gPad->AbsPixeltoX(px);
+      Float_t x  = gPad->PadtoX(xx);
+      Int_t binx = h->GetXaxis()->FindBin(x);
+      printf("event=%d, hist:%s, bin=%d, content=%f\n",event,h->GetName(),binx,h->GetBinContent(binx));
+   }
+
+*/
+
+}
+
 // #############################################################################
 //                 SETTER
 // #############################################################################
@@ -303,8 +331,8 @@ void AliHLTTPCDisplay::SetupHist(){
     fHistpad1 = new TH1F ("fHistpad1","Selected Pad -1;Timebin #",fNTimes,0,fNTimes-1);
     fHistpad2 = new TH1F ("fHistpad2","Selected Pad;Timebin #",fNTimes,0,fNTimes-1); 
     fHistpad3 = new TH1F ("fHistpad3","Selected Pad +1;Timebin #",fNTimes,0,fNTimes-1);
-    fHistallresidualsY = new TH1F ("fHistallresiduals","Y Residuals of all Tracks in selected slices;residuals",5000,0,100);
-    fHistallresidualsZ = new TH1F ("fHistallresiduals","Z Residuals of all Tracks in selected slices;residuals",5000,0,100);
+    fHistallresidualsY = new TH1F ("fHistallresiduals","Y Residuals of all Tracks in selected slices;residuals",5000,-100,100);
+    fHistallresidualsZ = new TH1F ("fHistallresiduals","Z Residuals of all Tracks in selected slices;residuals",5000,-100,100);
     fHistcharge = new TH1F ("fHistcharge","Cluster distribution per charge;charge;#cluster",5000,0,30000);
 
     fHistraw->SetOption("COLZ"); 
@@ -372,7 +400,7 @@ void AliHLTTPCDisplay::FillPadRow(Int_t patch, ULong_t dataBlock, ULong_t dataLe
 
     // Initialize block for reading packed data
     void* tmpdataBlock = (void*) dataBlock;
-    fDigitReader->InitBlock(tmpdataBlock,dataLen,firstRow,lastRow);
+    fDigitReader->InitBlock(tmpdataBlock,dataLen,firstRow,lastRow,patch,0);
 
     readValue = fDigitReader->Next();
 
@@ -431,7 +459,7 @@ void AliHLTTPCDisplay::FillPadRow(Int_t patch, ULong_t dataBlock, ULong_t dataLe
        fpmarr[19] = new Float_t[fcolorbin[19]*3]; 
        
        // Rewind the raw reader and fill the polymarker3D
-       fDigitReader->InitBlock(tmpdataBlock,dataLen,firstRow,lastRow);
+       fDigitReader->InitBlock(tmpdataBlock,dataLen,firstRow,lastRow,patch,0);
        
        readValue = fDigitReader->Next();
     } // END if (fSwitch3DPadRow)
@@ -982,12 +1010,12 @@ void AliHLTTPCDisplay::Draw3D(){
            // Draw last point of Track
            pmL->SetMarkerSize(3);
            pmL->SetMarkerColor(4); 
-           pmL->Draw();
+//         pmL->Draw();
 
            // Draw first point of Track
            pmF->SetMarkerSize(3);
            pmF->SetMarkerColor(5); 
-           pmF->Draw();
+//         pmF->Draw();
 
 #if TRACKPOLYMARKER
            // Draw Track -- as polymarker
@@ -1058,8 +1086,8 @@ void AliHLTTPCDisplay::Draw3D(){
 
        } // END for tracks
 
-       fHistallresidualsY->SetAxisRange(0,maxResidualY);
-       fHistallresidualsZ->SetAxisRange(0,maxResidualZ);
+       fHistallresidualsY->SetAxisRange(-maxResidualY,maxResidualY);
+       fHistallresidualsZ->SetAxisRange(-maxResidualZ,maxResidualZ);
 
     }   // END - DRAW 3D Tracks
 
index dc101774cb97c6eeceeadb2f8645a804ddce9ee6..87f63f777039dec80f558925eac1ff8c3477258e 100644 (file)
@@ -98,6 +98,9 @@ class AliHLTTPCDisplay : public TObject, public AliHLTLogging {
 
     Bool_t GetSelectTrackSwitch() {return fSelectTrackSwitch;}
 
+    // EXECUTER
+    void ExecPadRow();
+
     struct AliHLTTPCTrackParameter{
        Int_t nHits;
        Int_t charge;
index c4b22bd74e2d6624b975e68d1ba796128408cf2b..94433db7844f09f76e843ba464e9eb1fd5b6509f 100644 (file)
@@ -144,7 +144,7 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponent_EventData& ev
                break;
            sdIter++;
            }
-       if ( sdIter->fSlice>slice || sdIter==sdEnd )
+       if ( sdIter==sdEnd || sdIter->fSlice>slice )
            {
            if ( sdIter == sdEnd )
                maxSlice = slice;
@@ -192,11 +192,12 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponent_EventData& ev
            }
        }
 
-    fGlobalMerger->Setup( minSlice, maxSlice );
+    //fGlobalMerger->Setup( minSlice, maxSlice );
+    fGlobalMerger->Setup( 0, 35 );
 
     if ( !lastVertexBlock )
        {
-       Logging( kHLTLogError, "HLT::GlobalMerger::DoEvent", "No vertex data block",
+       Logging( kHLTLogInfo, "HLT::GlobalMerger::DoEvent", "No vertex data block",
                 "No vertex data block found  for event  0x%08lX (%lu).", evtData.fEventID, evtData.fEventID );
        fVertex->SetZero();
        }
@@ -206,6 +207,7 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponent_EventData& ev
     // Add all tracks into the merger
     sdIter = slices.begin();
     sdEnd = slices.end();
+    int lastSlice = -1;
     while ( sdIter != sdEnd )
        {
        if ( sdIter->fVertexBlock )
@@ -213,20 +215,28 @@ int AliHLTTPCGlobalMergerComponent::DoEvent( const AliHLTComponent_EventData& ev
            fVertex->Read( (AliHLTTPCVertexData*)( sdIter->fVertexBlock->fPtr ) );
            fGlobalMerger->SetVertex( fVertex );
            }
-       inPtr = (AliHLTTPCTrackletData*)( sdIter->fTrackletBlock->fPtr );
-       if ( !inPtr )
+       for ( int slNr=lastSlice+1; slNr<=sdIter->fSlice; slNr++ )
+           fGlobalMerger->InitSlice( slNr );
+        if ( sdIter->fTrackletBlock )
            {
-           Logging( kHLTLogError, "HLT::GlobalMerger::DoEvent", "No track data block",
-                    "No track data block found  for event  0x%08lX (%lu).", evtData.fEventID, evtData.fEventID );
+           inPtr = (AliHLTTPCTrackletData*)( sdIter->fTrackletBlock->fPtr );
+           if ( !inPtr )
+                 {
+                 Logging( kHLTLogError, "HLT::GlobalMerger::DoEvent", "No track data block",
+                          "No track data block found  for event  0x%08lX (%lu).", evtData.fEventID, evtData.fEventID );
+                 }
+           else
+               {
+               //fGlobalMerger->InitSlice( sdIter->fSlice );
+               fGlobalMerger->FillTracks( inPtr->fTrackletCnt, inPtr->fTracklets );
+               } 
            }
-       else
-           {
-           fGlobalMerger->InitSlice( sdIter->fSlice );
-           fGlobalMerger->FillTracks( inPtr->fTrackletCnt, inPtr->fTracklets );
-           }
-       
+       lastSlice = sdIter->fSlice;
        sdIter++;
        }
+    for ( int slNr=lastSlice+1; slNr<=35; slNr++ )
+        fGlobalMerger->InitSlice( slNr );
+    
 
     // Now we can really merge
     fGlobalMerger->Merge();
index 59637cc307f95e30182314e446ad24d2bbe23283..49df5eca57db2bf62023120a58fb1534c72833bb 100644 (file)
@@ -32,6 +32,7 @@
 #pragma link C++ class AliHLTTPCClustFinderNew;
 #pragma link C++ class AliHLTTPCClusterFinder;
 #pragma link C++ class AliHLTTPCDigitReader;
+#pragma link C++ class AliHLTTPCDigitReaderRaw;
 #pragma link C++ class AliHLTTPCDigitReaderPacked;
 #pragma link C++ class AliHLTTPCDigitReaderUnpacked;
 #pragma link C++ class AliHLTTPCFitter;
@@ -39,6 +40,8 @@
 /* #pragma link C++ class AliHLTTPCTPCBeamTestMemHandler; */
 #pragma link C++ class AliHLTTPCModelTrack;
 
+
+
 #ifdef use_aliroot
 #pragma link C++ class AliHLTTPCFileHandler;
 /* #pragma link C++ class AliHLTTPCEvaluate;  */
 #pragma link C++ class AliHLTTPCVertexFinderComponent;
 #pragma link C++ class AliHLTTPCSliceTrackerComponent;
 #pragma link C++ class AliHLTTPCGlobalMergerComponent;
+
 /* #pragma link C++ class AliRawReaderMemory; */
 
 #endif
index 834805c95d98efe11fb0f2ea24848d17246754e9..ceba38cade060689101e8ce1aedc5b15eb4ea559 100644 (file)
@@ -7,4 +7,12 @@
 
 AliHLTTPCLog::TLogLevel AliHLTTPCLog::fgLevel=AliHLTTPCLog::kNone;
 
+const char* AliHLTTPCLog::kEnd = "";
+const char* AliHLTTPCLog::kPrec = "";
+const char* AliHLTTPCLog::kHex = "";
+const char* AliHLTTPCLog::kDec = "";
+// const std::ios_base::fmtflags AliHLTTPCLog::kHex = std::ios_base::hex;
+// const std::ios_base::fmtflags AliHLTTPCLog::kDec = std::ios_base::dec;
+
+
 #endif
index ac2f0edc066bb2d7b9edde44b9ab751a3b479d6c..05aadcb9217fad7e80317071d98e10f508d642f6 100644 (file)
@@ -4,18 +4,29 @@
 #ifndef ALIHLTTPCLOG_H
 #define ALIHLTTPCLOG_H
 
+#ifndef __CINT__
+#include <bits/ios_base.h>
+#endif
+
 class AliHLTTPCLog {
   public:
   enum TLogLevel { kNone = 0, kDebug= 0x01, kInformational = 0x02, kWarning = 0x04, kError = 0x08 , kFatal = 0x10, kPrimary = 0x80, kAll = 0x9F };
-  enum TLogCmd { kEnd, kPrec, kHex, kDec };
+  //enum TLogCmd { kEnd, kPrec, kHex=std::ios_base::hex, kDec=std::ios_base::dec };
+  static const char* kEnd;
+  static const char* kPrec;
+  static const char* kHex;
+  static const char* kDec;
+/*   static const std::ios_base::fmtflags kHex; */
+/*   static const std::ios_base::fmtflags kDec; */
   static TLogLevel fgLevel;
 };
 
-#if __GNUC__ == 3
+#if __GNUC__ >= 3
 #define LOG( lvl, origin, keyword ) \
  if (lvl>=AliHLTTPCLog::fgLevel) std::cerr<<"["<<origin<<": "<<keyword<<"] "
 #define ENDLOG std::endl
 #else
+#error old gcc!
 #define LOG( lvl, origin, keyword ) \
  if (lvl>=AliHLTTPCLog::fgLevel) cerr<<"["<<origin<<": "<<keyword<<"] "
 #define ENDLOG endl
index 1a673e33ac31bca83abca2ff0dc06ba7a62a0c29..36d35fc8969e2e5546976a05f0bea55fa49027b4 100644 (file)
@@ -155,7 +155,7 @@ Int_t AliHLTTPCPad::CalculateBaseLine(Int_t reqMinCount)
            fAverage=fSum/fCount;
            HLTDebug("new average %f", fAverage);
          } else {
-           HLTWarning("baseline re-eveluation skipped because of to few "
+           HLTDebug("baseline re-eveluation skipped because of to few "
                       "contributing bins: total=%d, contributing=%d, req=%d"
                       "\ndata might be already zero suppressed"
                       , fTotal, fCount, reqMinCount);
@@ -178,7 +178,7 @@ Int_t AliHLTTPCPad::CalculateBaseLine(Int_t reqMinCount)
       fAverage=avBackup;
     }
   } else {
-    HLTWarning("baseline calculation skipped because of to few contributing "
+    HLTDebug("baseline calculation skipped because of to few contributing "
               "bins: total=%d, contributing=%d, required=%d \ndata might be "
               "already zero suppressed", fTotal, fCount, reqMinCount);
   }
index a14540ab457697d20150fd9255cd4b522b7e7078..73733c9f7cd04bde91e97a5fb189a8502e3b6434 100644 (file)
@@ -22,7 +22,7 @@
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-#if __GNUC__== 3
+#if __GNUC__>= 3
 using namespace std;
 #endif
 
@@ -116,14 +116,14 @@ void AliHLTTPCSliceTrackerComponent::SetTrackerParam(Int_t phi_segments, Int_t e
 
 // BEGINN ############################################## MODIFIY JMT
 #if 1
-    Logging( kHLTLogError, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "==============================" );
+    Logging( kHLTLogDebug, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "==============================" );
 
     if ( fmainvertextracking == kTRUE && fnonvertextracking == kFALSE){
        fTracker->SetTrackCuts(hitChi2Cut,goodHitChi2,trackChi2Cut,maxdist,kTRUE);
        fTracker->SetTrackletCuts(maxangle,goodDist,kTRUE);
 
        fTracker->MainVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack, maxphi, maxeta);    
-       Logging( kHLTLogError, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "MAINVERTEXTRACKING" );
+       Logging( kHLTLogDebug, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "MAINVERTEXTRACKING" );
     }
     else if ( fmainvertextracking == kTRUE && fnonvertextracking == kTRUE){
        fTracker->SetTrackCuts(hitChi2Cut,goodHitChi2,trackChi2Cut,maxdist,kTRUE);
@@ -133,14 +133,14 @@ void AliHLTTPCSliceTrackerComponent::SetTrackerParam(Int_t phi_segments, Int_t e
 
        fTracker->MainVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack, maxphi, maxeta);
        fTracker->NonVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack);     
-       Logging( kHLTLogError, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "MAINVERTEXTRACKING - NONVERTEXTRACKING" );
+       Logging( kHLTLogDebug, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "MAINVERTEXTRACKING - NONVERTEXTRACKING" );
     }
     else if ( fmainvertextracking == kFALSE && fnonvertextracking == kTRUE){
        fTracker->SetTrackCuts(hitChi2Cut,goodHitChi2,trackChi2Cut,maxdist,kFALSE);
        fTracker->SetTrackletCuts(maxangle,goodDist,kFALSE);
 
        fTracker->NonVertexSettings( trackletlength, tracklength, rowscopetracklet, rowscopetrack);
-       Logging( kHLTLogError, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "NONVERTEXTRACKING" );
+       Logging( kHLTLogDebug, "HLT::TPCSliceTracker::SetTrackerParam", "Tracking", "NONVERTEXTRACKING" );
     }
 #else
     fTracker->SetTrackCuts(hitChi2Cut,goodHitChi2,trackChi2Cut,maxdist,vertexConstraints);
@@ -162,8 +162,7 @@ void AliHLTTPCSliceTrackerComponent::SetTrackerParam(Int_t phi_segments, Int_t e
 void AliHLTTPCSliceTrackerComponent::SetTrackerParam( bool doPP, int multiplicity, double bField )
     {
     AliHLTTPCTransform::SetBField( bField );
-    Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f\n", bField );
-    Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "B field is  %f\n",AliHLTTPCTransform::GetBFieldValue()); 
+    Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "BField", "Setting b field to %f T\n", bField );
 
     if ( doPP )
        {
@@ -301,7 +300,6 @@ void AliHLTTPCSliceTrackerComponent::SetTrackerParam( bool doPP, int multiplicit
 int AliHLTTPCSliceTrackerComponent::DoInit( int argc, const char** argv )
     {
     Logging( kHLTLogDebug, "HLT::TPCSliceTracker::DoInit", "DoInit", "DoInit()" );
-    fprintf( stderr, "sizeof(AliHLTTPCTrackSegmentData): %d\n", sizeof(AliHLTTPCTrackSegmentData) );
 
     if ( fTracker || fVertex )
        return EINPROGRESS;
@@ -388,6 +386,15 @@ int AliHLTTPCSliceTrackerComponent::DoInit( int argc, const char** argv )
        Logging(kHLTLogError, "HLT::TPCSliceTracker::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
        return EINVAL;
        }
+// #### -B0-CHANGE-START == JMT
+    if (fBField == 0.){
+       // parameter for B=0 T 
+       fDoPP = kTRUE;
+       fnonvertextracking = kTRUE;
+       fmainvertextracking = kFALSE;
+    }
+// #### -B0-CHANGE-END == JMT
+
     SetTrackerParam( fDoPP, fMultiplicity, fBField );
     return 0;
     }
index 53d1e8af98e1aabb55dd86fd05ff5fa2a185cd19..ea93cbdd3197f9e80738f5ca4d3fbf4b2cb7864c 100644 (file)
@@ -63,11 +63,11 @@ class AliHLTTPCSliceTrackerComponent : public AliHLTProcessor
 
        AliHLTTPCConfMapper* fTracker;
        AliHLTTPCVertex* fVertex;
-       float fEta[2];
-       bool fDoNonVertex;
-       bool fDoPP;
-       int fMultiplicity;
-       double fBField;
+       Float_t fEta[2];
+       Bool_t fDoNonVertex;
+       Bool_t  fDoPP;
+       Int_t fMultiplicity;
+       Double_t fBField;
 
 // BEGINN ############################################## MODIFIY JMT
        Bool_t fnonvertextracking;   // enable NONVERTEX Tracking
index 0bb4d6fa4cec1e090c87269d81f3ff38ffb3c5c6..11a4fcfbc39e76eaf8d0b0c3646fe109b47e0b02 100644 (file)
@@ -180,17 +180,31 @@ void AliHLTTPCTrack::Rotate(Int_t slice,Bool_t tolocal)
 
 void AliHLTTPCTrack::CalculateHelix()
 {
-  //Calculate Radius, CenterX and CenterY from Psi, X0, Y0
-  fRadius = fPt / (AliHLTTPCTransform::GetBFieldValue());
-  if(fRadius) fKappa = -fQ*1./fRadius;
-  else fRadius = 999999;  //just zero
-  Double_t trackPhi0 = fPsi + fQ * AliHLTTPCTransform::PiHalf();
-
-  fCenterX = fFirstPoint[0] - fRadius *  cos(trackPhi0);
-  fCenterY = fFirstPoint[1] - fRadius *  sin(trackPhi0);
-  
-  SetPhi0(atan2(fFirstPoint[1],fFirstPoint[0]));
-  SetR0(sqrt(fFirstPoint[0]*fFirstPoint[0]+fFirstPoint[1]*fFirstPoint[1]));
+// #### -B0-CHANGE-START == JMT
+    // for straight line fit
+    if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
+       fRadius = 999999;  //just zero
+
+       SetPhi0(atan2(fFirstPoint[1],fFirstPoint[0]));
+       SetR0(sqrt(fFirstPoint[0]*fFirstPoint[0]+fFirstPoint[1]*fFirstPoint[1]));
+    }
+    // for helix fit
+    else { 
+// #### -B0-UNCHANGED-START == JMT
+       //Calculate Radius, CenterX and CenterY from Psi, X0, Y0
+       fRadius = fPt / (AliHLTTPCTransform::GetBFieldValue());
+       if(fRadius) fKappa = -fQ*1./fRadius;
+       else fRadius = 999999;  //just zero
+       Double_t trackPhi0 = fPsi + fQ * AliHLTTPCTransform::PiHalf();
+       
+       fCenterX = fFirstPoint[0] - fRadius *  cos(trackPhi0);
+       fCenterY = fFirstPoint[1] - fRadius *  sin(trackPhi0);
+       
+       SetPhi0(atan2(fFirstPoint[1],fFirstPoint[0]));
+       SetR0(sqrt(fFirstPoint[0]*fFirstPoint[0]+fFirstPoint[1]*fFirstPoint[1]));
+// #### -B0-UNCHANGED-END == JMT
+    }
+// #### -B0-CHANGE-END == JMT
 }
 
 Double_t AliHLTTPCTrack::GetCrossingAngle(Int_t padrow,Int_t slice) 
@@ -242,42 +256,62 @@ Bool_t AliHLTTPCTrack::GetCrossingPoint(Int_t padrow,Float_t *xyz)
   Double_t xHit = AliHLTTPCTransform::Row2X(padrow);
 
 // BEGINN ############################################## MODIFIY JMT
-  if (xHit < xyz[0]){
-      LOG(AliHLTTPCLog::kError,"AliHLTTPCTRACK::GetCrossingPoint","")<< "Track doesn't cross padrow " << padrow <<"(x=" << xHit << "). Smallest x=" << xyz[0] << ENDLOG;
-      return false;
-  }
+//if (xHit < xyz[0]){
+//    LOG(AliHLTTPCLog::kError,"AliHLTTPCTRACK::GetCrossingPoint","")<< "Track doesn't cross padrow " 
+//                             << padrow <<"(x=" << xHit << "). Smallest x=" << xyz[0] << ENDLOG;
+//      return false;
+//}
 // END ################################################# MODIFIY JMT
 
-  xyz[0] = xHit;
-  Double_t aa = (xHit - GetCenterX())*(xHit - GetCenterX());
-  Double_t r2 = GetRadius()*GetRadius();
-  if(aa > r2)
-    return false;
-
-  Double_t aa2 = sqrt(r2 - aa);
-  Double_t y1 = GetCenterY() + aa2;
-  Double_t y2 = GetCenterY() - aa2;
-  xyz[1] = y1;
-  if(fabs(y2) < fabs(y1)) xyz[1] = y2;
-  Double_t yHit = xyz[1];
-  Double_t angle1 = atan2((yHit - GetCenterY()),(xHit - GetCenterX()));
-  if(angle1 < 0) angle1 += 2.*AliHLTTPCTransform::Pi();
-  Double_t angle2 = atan2((GetFirstPointY() - GetCenterY()),(GetFirstPointX() - GetCenterX()));
-  if(angle2 < 0) angle2 += AliHLTTPCTransform::TwoPi();
-
-  Double_t diffangle = angle1 - angle2;
-  diffangle = fmod(diffangle,AliHLTTPCTransform::TwoPi());
-  if((GetCharge()*diffangle) > 0) diffangle = diffangle - GetCharge()*AliHLTTPCTransform::TwoPi();
+// #### -B0-CHANGE-START == JMT
+  // for straight line fit
+    if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
 
-  Double_t stot = fabs(diffangle)*GetRadius();
+       Double_t yHit = GetFirstPointY() + (Double_t) tan( GetPsi() ) * (xHit - GetFirstPointX());   
+       
+       Double_t s = (xHit - GetFirstPointX())*(xHit - GetFirstPointX()) + (yHit - GetFirstPointY())*(yHit - GetFirstPointY()); 
+       
+       Double_t zHit = GetFirstPointZ() + s * GetTgl();
 
-  Double_t zHit = GetFirstPointZ() + stot*GetTgl();
-
-  xyz[2] = zHit;
-  return true;
+       xyz[0] = xHit;
+       xyz[1] = yHit;
+       xyz[2] = zHit;
+    }
+    // for helix fit
+    else { 
+// #### -B0-UNCHANGED-START == JMT
+       xyz[0] = xHit;
+       Double_t aa = (xHit - GetCenterX())*(xHit - GetCenterX());
+       Double_t r2 = GetRadius()*GetRadius();
+       if(aa > r2)
+           return false;
+       
+       Double_t aa2 = sqrt(r2 - aa);
+       Double_t y1 = GetCenterY() + aa2;
+       Double_t y2 = GetCenterY() - aa2;
+       xyz[1] = y1;
+       if(fabs(y2) < fabs(y1)) xyz[1] = y2;
+       
+       Double_t yHit = xyz[1];
+       Double_t angle1 = atan2((yHit - GetCenterY()),(xHit - GetCenterX()));
+       if(angle1 < 0) angle1 += 2.*AliHLTTPCTransform::Pi();
+       Double_t angle2 = atan2((GetFirstPointY() - GetCenterY()),(GetFirstPointX() - GetCenterX()));
+       if(angle2 < 0) angle2 += AliHLTTPCTransform::TwoPi();
+       
+       Double_t diffangle = angle1 - angle2;
+       diffangle = fmod(diffangle,AliHLTTPCTransform::TwoPi());
+       if((GetCharge()*diffangle) > 0) diffangle = diffangle - GetCharge()*AliHLTTPCTransform::TwoPi();
+       
+       Double_t stot = fabs(diffangle)*GetRadius();
+       
+       Double_t zHit = GetFirstPointZ() + stot*GetTgl();
+       
+       xyz[2] = zHit;
+// #### -B0-UNCHANGED-END == JMT
+    }
+// #### -B0-CHANGE-END == JMT
 
+    return true;
 }
 
 Bool_t AliHLTTPCTrack::CalculateReferencePoint(Double_t angle,Double_t radius)
@@ -446,45 +480,69 @@ void AliHLTTPCTrack::UpdateToFirstPoint()
   //However, if you later on want to do more precise local calculations, such
   //as impact parameter, residuals etc, you need to give the track parameters
   //according to the actual fit.
-// BEGINN ############################################## MODIFIY JMT
-    LOG(AliHLTTPCLog::kError,"AliHLTTPCTrack::UpdateToFirstPoint","ENTER") <<ENDLOG;
-// END ################################################# MODIFIY JMT
-  Double_t xc = GetCenterX() - GetFirstPointX();
-  Double_t yc = GetCenterY() - GetFirstPointY();
-  
-  Double_t distx1 = xc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
-  Double_t disty1 = yc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
-  Double_t distance1 = sqrt(distx1*distx1 + disty1*disty1);
-  
-  Double_t distx2 = xc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
-  Double_t disty2 = yc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
-  Double_t distance2 = sqrt(distx2*distx2 + disty2*disty2);
-  
-  //Choose the closest:
-  Double_t point[2];
-  if(distance1 < distance2)
-    {
-      point[0] = distx1 + GetFirstPointX();
-      point[1] = disty1 + GetFirstPointY();
+// #### -B0-CHANGE-START == JMT
+    // for straight line fit
+    if (AliHLTTPCTransform::GetBFieldValue() == 0.0 ){
+       Double_t xc = GetCenterX() - GetFirstPointX();
+       Double_t yc = GetCenterY() - GetFirstPointY();
+
+       Double_t xn = (Double_t) sin( GetPsi() );
+       Double_t yn = -1. * (Double_t) cos( GetPsi() );
+
+       Double_t d = xc*xn + yc*yn;
+
+       Double_t distx = d * xn;
+       Double_t disty = d * yn;
+
+       Double_t point[2];
+
+       point[0] = distx + GetFirstPointX();
+       point[1] = disty + GetFirstPointY();
+
+       //Update the track parameters
+       SetR0(sqrt(point[0]*point[0]+point[1]*point[1]));
+       SetPhi0(atan2(point[1],point[0]));
+       SetFirstPoint(point[0],point[1],GetZ0());
     }
-  else
-    {
-      point[0] = distx2 + GetFirstPointX();
-      point[1] = disty2 + GetFirstPointY();
+    // for helix fit
+    else { 
+// #### -B0-UNCHANGED-START == JMT
+       Double_t xc = GetCenterX() - GetFirstPointX();
+       Double_t yc = GetCenterY() - GetFirstPointY();
+       
+       Double_t distx1 = xc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
+       Double_t disty1 = yc*(1 + GetRadius()/sqrt(xc*xc + yc*yc));
+       Double_t distance1 = sqrt(distx1*distx1 + disty1*disty1);
+       
+       Double_t distx2 = xc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
+       Double_t disty2 = yc*(1 - GetRadius()/sqrt(xc*xc + yc*yc));
+       Double_t distance2 = sqrt(distx2*distx2 + disty2*disty2);
+       
+       //Choose the closest:
+       Double_t point[2];
+       if(distance1 < distance2)
+       {
+           point[0] = distx1 + GetFirstPointX();
+           point[1] = disty1 + GetFirstPointY();
+       }
+       else
+       {
+           point[0] = distx2 + GetFirstPointX();
+           point[1] = disty2 + GetFirstPointY();
+       }
+
+       Double_t pointpsi = atan2(point[1]-GetCenterY(),point[0]-GetCenterX());
+       pointpsi -= GetCharge()*AliHLTTPCTransform::PiHalf();
+       if(pointpsi < 0) pointpsi += AliHLTTPCTransform::TwoPi();
+       
+       //Update the track parameters
+       SetR0(sqrt(point[0]*point[0]+point[1]*point[1]));
+       SetPhi0(atan2(point[1],point[0]));
+       SetFirstPoint(point[0],point[1],GetZ0());
+       SetPsi(pointpsi);
+// #### -B0-UNCHANGED-END == JMT
     }
-
-  Double_t pointpsi = atan2(point[1]-GetCenterY(),point[0]-GetCenterX());
-  pointpsi -= GetCharge()*AliHLTTPCTransform::PiHalf();
-  if(pointpsi < 0) pointpsi += AliHLTTPCTransform::TwoPi();
-  
-  //Update the track parameters
-  SetR0(sqrt(point[0]*point[0]+point[1]*point[1]));
-  SetPhi0(atan2(point[1],point[0]));
-  SetFirstPoint(point[0],point[1],GetZ0());
-  SetPsi(pointpsi);
-  // BEGINN ############################################## MODIFIY JMT
-    LOG(AliHLTTPCLog::kError,"AliHLTTPCTrack::UpdateToFirstPoint","LEAVE") <<ENDLOG;
-// END ################################################# MODIFIY JMT
+// #### -B0-CHANGE-END == JMT
 }
 
 void AliHLTTPCTrack::GetClosestPoint(AliHLTTPCVertex *vertex,Double_t &closestx,Double_t &closesty,Double_t &closestz)
index 92ca6ba28fec94d6388a6f88daf78729172c01f2..06aa48a6e5bd22185fad4dc861f67f828fcb2b1b 100644 (file)
@@ -367,9 +367,9 @@ UInt_t AliHLTTPCTrackArray::WriteTracks(AliHLTTPCTrackSegmentData* tr)
     tP = (AliHLTTPCTrackSegmentData*)tmpP;
 
 // BEGINN ############################################## MODIFIY JMT
-    LOG(AliHLTTPCLog::kError,"AliHLTTPCTrackArray::WriteTracks","TRACKPARAMETER") <<ENDLOG;
-    track->Rotate(0,kFALSE);
-    track->Print();
+//    LOG(AliHLTTPCLog::kError,"AliHLTTPCTrackArray::WriteTracks","TRACKPARAMETER") <<ENDLOG;
+//    track->Rotate(0,kFALSE);
+//    track->Print();
 // END ################################################# MODIFIY JMT
 
   }
index 14d422176b1596ddb035ce4b45fabd428ba43b21..cd8c0ccbc367ca8a3d0a520f8f38d3b8e217b2fb 100644 (file)
@@ -100,7 +100,7 @@ Double_t AliHLTTPCTransform::fgBField = 0.2;
 Double_t AliHLTTPCTransform::fgSolenoidBField = 2;
 Double_t AliHLTTPCTransform::fgBFieldFactor = 1;
 Int_t AliHLTTPCTransform::fgVersion = kVdefault;
-Int_t AliHLTTPCTransform::fgNTimeBins = 446;
+Int_t AliHLTTPCTransform::fgNTimeBins = 1024; //446
 Int_t AliHLTTPCTransform::fgNRowLow = 63;
 Int_t AliHLTTPCTransform::fgNRowUp = 96;
 Int_t AliHLTTPCTransform::fgNRowUp1 = 64;
@@ -476,6 +476,173 @@ Double_t AliHLTTPCTransform::fgX[159] = { 85.195,
                                     245.930
 };
 
+#if 0
+// New  number of pads changed 2006-04-15 Jochen Thaeder
+// changed according to formula in AliTPCROC.cxx
+// according to real Pad Distribution on build TPC
+Int_t AliHLTTPCTransform::fgNPads[159] = {68,
+                                     68,
+                                     68,
+                                     68,
+                                     70,
+                                     70,
+                                     70,
+                                     72,
+                                     72,
+                                     72,
+                                     74,
+                                     74,
+                                     74,
+                                     76,
+                                     76,
+                                     76,
+                                     78,
+                                     78,
+                                     78,
+                                     80,
+                                     80,
+                                     80,
+                                     82,
+                                     82,
+                                     82,
+                                     84,
+                                     84,
+                                     84,
+                                     86,
+                                     86,
+                                     86,
+                                     88,
+                                     88,
+                                     88,
+                                     90,
+                                     90,
+                                     90,
+                                     92,
+                                     92,
+                                     92,
+                                     94,
+                                     94,
+                                     94,
+                                     96,
+                                     96,
+                                     96,
+                                     98,
+                                     98,
+                                     98,
+                                     100,
+                                     100,
+                                     100,
+                                     102,
+                                     102,
+                                     102,
+                                     104,
+                                     104,
+                                     104,
+                                     106,
+                                     106,
+                                     106,
+                                     108,
+                                     108,
+                                     74,
+                                     76,
+                                     76,
+                                     76,
+                                     76,
+                                     78,
+                                     78,
+                                     78,
+                                     80,
+                                     80,
+                                     80,
+                                     80,
+                                     82,
+                                     82,
+                                     82,
+                                     84,
+                                     84,
+                                     84,
+                                     86,
+                                     86,
+                                     86,
+                                     86,
+                                     88,
+                                     88,
+                                     88,
+                                     90,
+                                     90,
+                                     90,
+                                     90,
+                                     92,
+                                     92,
+                                     92,
+                                     94,
+                                     94,
+                                     94,
+                                     96,
+                                     96,
+                                     96,
+                                     96,
+                                     98,
+                                     98,
+                                     98,
+                                     100,
+                                     100,
+                                     100,
+                                     100,
+                                     102,
+                                     102,
+                                     102,
+                                     104,
+                                     104,
+                                     104,
+                                     106,
+                                     106,
+                                     106,
+                                     106,
+                                     108,
+                                     108,
+                                     108,
+                                     110,
+                                     110,
+                                     110,
+                                     110,
+                                     112,
+                                     112,
+                                     114,
+                                     114,
+                                     114,
+                                     116,
+                                     116,
+                                     118,
+                                     118,
+                                     120,
+                                     120,
+                                     122,
+                                     122,
+                                     122,
+                                     124,
+                                     124,
+                                     126,
+                                     126,
+                                     128,
+                                     128,
+                                     130,
+                                     130,
+                                     130,
+                                     132,
+                                     132,
+                                     134,
+                                     134,
+                                     136,
+                                     136,
+                                     138,
+                                     138,
+                                     138,
+                                     140
+};
+
+#else
+//   OLD  number of pads changed 2006-04-15 Jochen Thaeder
 Int_t AliHLTTPCTransform::fgNPads[159] = {67,
                                      67,
                                      69,
@@ -636,6 +803,7 @@ Int_t AliHLTTPCTransform::fgNPads[159] = {67,
                                      137,
                                      139
 };
+#endif
 
 Double_t AliHLTTPCTransform::fgCos[36] = { 0.9848077297,
                                      0.8660253882,
index 0583538937d4049f5d8031df8c2244d9938356d4..f746bbdebca31131b3f017349bc5cc7ddb3c3fba 100644 (file)
@@ -30,6 +30,7 @@ SRCS  = AliHLTTPCLog.cxx \
           AliHLTTPCDigitReader.cxx \
           AliHLTTPCDigitReaderPacked.cxx \
           AliHLTTPCDigitReaderUnpacked.cxx \
+         AliHLTTPCDigitReaderRaw.cxx \
           AliHLTTPCVertex.cxx \
           AliHLTTPCVertexArray.cxx \
           AliHLTTPCVertexFinder.cxx \
@@ -51,8 +52,7 @@ SRCS  = AliHLTTPCLog.cxx \
           AliHLTTPCClusterFinderComponent.cxx \
           AliHLTTPCVertexFinderComponent.cxx \
           AliHLTTPCSliceTrackerComponent.cxx \
-          AliHLTTPCGlobalMergerComponent.cxx \
-
+          AliHLTTPCGlobalMergerComponent.cxx 
 
 #          AliRawReaderMemory.cxx
 
index b0684cbbf4ea72f9f13fd0a231034fd10eb4eff3..5b84908e3c752d9ea6b0c8471a969d1d212155e0 100644 (file)
@@ -6,6 +6,20 @@ MODULE                                 = AliHLTTPC
 AM_CPPFLAGS                    = @ALIROOT_CPPFLAGS@         \
                                  -I$(top_srcdir)/BASE
 
+# generation of the TPC Pad mapping tables for the 
+# AliHLTTPCDigitReaderRaw reader
+if USE_TPC_MAPPING
+TPC_MAPPING_NOINST_SRC         = mapping2array.cxx
+TPC_MAPPING_INC                        = mapping_array_out.inc
+TPC_MAPPING_NOINST_PGM         = mapping2array
+TPC_MAPPING_COMPONENTS         = AliHLTTPCDigitReaderRaw.cxx
+endif
+
+noinst_PROGRAMS                        = $(TPC_MAPPING_NOINST_PGM)
+if USE_TPC_MAPPING
+mapping2array_SOURCES          = $(TPC_MAPPING_NOINST_SRC)
+endif
+
 # library definition
 lib_LTLIBRARIES                        =  libAliHLTTPC.la
 
@@ -23,6 +37,7 @@ libAliHLTTPC_la_SOURCES               = AliHLTTPCLog.cxx \
                                  AliHLTTPCDigitReader.cxx \
                                  AliHLTTPCDigitReaderPacked.cxx \
                                  AliHLTTPCDigitReaderUnpacked.cxx \
+                                 AliHLTTPCDigitReaderRaw.cxx \
                                  AliHLTTPCVertex.cxx \
                                  AliHLTTPCVertexArray.cxx \
                                  AliHLTTPCVertexFinder.cxx \
@@ -73,6 +88,7 @@ CLASS_HDRS                    = AliHLTTPCLog.h \
                                  AliHLTTPCDigitReader.h \
                                  AliHLTTPCDigitReaderPacked.h \
                                  AliHLTTPCDigitReaderUnpacked.h \
+                                 AliHLTTPCDigitReaderRaw.h \
                                  AliHLTTPCVertex.h \
                                  AliHLTTPCVertexArray.h \
                                  AliHLTTPCVertexFinder.h \
@@ -113,15 +129,18 @@ pkginclude_HEADERS                = $(CLASS_HDRS) \
 
 
 # version info for the library
-libAliHLTTPC_la_LDFLAGS                = @ALIROOT_LDFLAGS@ \
+libAliHLTTPC_la_LDFLAGS                = -L@ROOTLIBDIR@ \
+                                 @ROOTLIBS@ \
+                                 @ALIROOT_LDFLAGS@ \
                                  @ALIROOT_LIBS@ \
-                                 -version-info 2:0:0
+                                 -version-info 2:1:0
 
 # set the file name for the generated root dictionary
 DICTCPP                                =  AliHLTTPC-DICT.cxx
 nodist_libAliHLTTPC_la_SOURCES  =  $(DICTCPP)
 
-CLEANFILES                     =
+BUILT_SOURCES                  = $(TPC_MAPPING_INC)
+CLEANFILES                     = $(BUILT_SOURCES)
 
 include $(top_srcdir)/make.dict
 
@@ -129,3 +148,6 @@ if EN_HLT_TPCREF
 REFDIR                         = Ref
 endif
 SUBDIRS                        = . $(REFDIR)
+
+$(TPC_MAPPING_INC): $(TPC_MAPPING_NOINST_PGM)
+       ./$<
diff --git a/HLT/TPCLib/mapping2array.cxx.in b/HLT/TPCLib/mapping2array.cxx.in
new file mode 100644 (file)
index 0000000..c7bfc05
--- /dev/null
@@ -0,0 +1,94 @@
+#include <stdio.h>
+#include <fcntl.h>
+#include <iostream>
+#include <fstream>
+#include <stdlib.h>
+#include <iomanip>
+
+using namespace std;
+
+int main(){
+    ifstream inFile[6];
+    ofstream outFile;
+    int ofile;
+   
+    
+    char * mappingpath="@TPC_PAD_MAPPING_PATH@/";
+    char * mappingfiles[6]= {"@TPC_PAD_MAPPING_PATH@/Patch0.data",
+                            "@TPC_PAD_MAPPING_PATH@/Patch1.data",
+                            "@TPC_PAD_MAPPING_PATH@/Patch2.data",
+                            "@TPC_PAD_MAPPING_PATH@/Patch3.data",
+                            "@TPC_PAD_MAPPING_PATH@/Patch4.data",
+                            "@TPC_PAD_MAPPING_PATH@/Patch5.data"};
+
+    int numberOfChannels[6];
+    int maxHWAddress[6];
+
+    outFile.open("mapping_array_out.inc");
+
+    outFile << "// **** WARNING: This file is generated automatically. DO NOT EDIT" << endl << endl;
+    
+
+    for (int ii = 0; ii< 6; ii++) {
+      
+      //for (int ii = 1; ii< 2; ii++) {
+       
+       inFile[ii].open(mappingfiles[ii]);
+       inFile[ii].seekg (0, ios::beg);
+
+       int* tmpPad;
+       int* tmpRow;
+
+       inFile[ii] >> numberOfChannels[ii] >> maxHWAddress[ii];
+
+       cout << numberOfChannels[ii] << "  "<< maxHWAddress[ii]<< endl;
+       
+       outFile << "Int_t AliHLTTPCDigitReaderRaw::fMapping_"<< ii << "["<< maxHWAddress[ii]+1 << "][2] = { " << endl;
+       tmpPad = new int[maxHWAddress[ii]+1];
+       tmpRow = new int[maxHWAddress[ii]+1];
+
+       for (int jj = 0; jj <= maxHWAddress[ii]; jj++){
+           tmpPad[jj] = -1;
+           tmpRow[jj] = -1;
+       }
+           
+       while (1) {
+           int address,row,pad;
+           
+           inFile[ii] >> address >> row >>  pad;
+           tmpPad[address] = pad;
+           tmpRow[address] = row;
+
+           if (!inFile[ii].good()) break;
+       }
+
+       for (int jj = 0; jj <= maxHWAddress[ii]; jj++)
+         {
+//         if ( tmpRow[jj]==-1 )
+//           printf( "Found -1 (%d)\n", jj );
+           outFile <<  "{" << tmpRow[jj] << "," << tmpPad[jj] << "},"<< endl;
+         }
+
+
+       cout << " ---------------" << ii << endl;
+       
+       inFile[ii].close();
+       outFile << "};\n" << endl;
+    }
+
+    outFile << "unsigned AliHLTTPCDigitReaderRaw::fMaxHWA[6]= {";
+    for ( int ii=0; ii<6; ii++ )
+      {
+       outFile << maxHWAddress[ii];
+       if ( ii<5 )
+         outFile << ",";
+      }
+    outFile << "};" << endl;
+
+    
+       outFile.close();
+
+  
+   
+    return 0;
+}
index ab1876e82de5eb6d8ad66449cae26c0d9a6d471f..1732e69e82675579c11d47f28b38d2709e10b6a6 100644 (file)
@@ -5,7 +5,7 @@ dnl template for the configuration script for the Alice HLT
 dnl framework and components
 dnl 
 dnl ------------------------------------------------------------------
-AC_INIT([Alice High Level Trigger] , [0.3], [Matthias.Richter@ift.uib.no], alice-hlt)
+AC_INIT([Alice High Level Trigger] , [0.4-dev], [Matthias.Richter@ift.uib.no], alice-hlt)
 
 dnl ------------------------------------------------------------------
 dnl the package from CVS contains the old Makefiles as well. In order to
@@ -44,7 +44,6 @@ ALIHLT_USEPACKAGE=ALIROOT
 AC_DEFINE(use_aliroot)
 AC_DEFINE(use_root)
 CPPFLAGS="$CPPFLAGS ${ROOTCFLAGS}"
-LDFLAGS="$LDFLAGS -L${ROOTLIBDIR} ${ROOTLIBS}"
 
 dnl ------------------------------------------------------------------
 dnl check for AliRoot features
@@ -83,8 +82,8 @@ if test ! "x$have_aliroot" = "xno" ; then
   save_LDFLAGS=$LDFLAGS
   save_LIBS=$LIBS
   CPPFLAGS="$save_CPPFLAGS $ALIROOT_CPPFLAGS"
-  LDFLAGS="$save_LDFLAGS $ALIROOT_LDFLAGS"
-  LIBS="$save_LIBS $ALIROOT_LIBS"
+  LDFLAGS="$save_LDFLAGS -L${ROOTLIBDIR} $ALIROOT_LDFLAGS"
+  LIBS="$save_LIBS $ROOTLIBS $ALIROOT_LIBS"
  
   # check for certain AliRoot libraries/files/features
   if test ! "x$have_aliroot" = "xno" ; then
@@ -95,7 +94,7 @@ if test ! "x$have_aliroot" = "xno" ; then
     AC_MSG_CHECKING(for AliRawReader classes in RAWData libraries)
     if test ! "x$have_alirawdata" = "xno" ; then
       CHECKLIB="-lRAWDatarec"
-      LIBS="$save_LIBS $ALIROOT_LIBS -lRAWDatabase $CHECKLIB"
+      LIBS="$save_LIBS $ROOTLIBS $ALIROOT_LIBS -lRAWDatabase $CHECKLIB"
       AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <AliRawReaderMemory.h>
                                       #include <AliRawReaderFile.h>
                                       #include <AliRawReaderDate.h>
@@ -111,7 +110,7 @@ if test ! "x$have_aliroot" = "xno" ; then
       # second pass with -RAWData
       if test "x$have_alirawdata" = "xno" ; then
         CHECKLIB="-lRAWData"
-        LIBS="$save_LIBS $ALIROOT_LIBS $CHECKLIB"
+        LIBS="$save_LIBS $ROOTLIBS $ALIROOT_LIBS $CHECKLIB"
         AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <AliRawReaderMemory.h>
                                       #include <AliRawReaderFile.h>
                                       #include <AliRawReaderDate.h>
@@ -152,7 +151,7 @@ if test ! "x$have_aliroot" = "xno" ; then
     if test ! "x$have_alitpc" = "xno" ; then
       save_ALIROOT_LIBS=$ALIROOT_LIBS
       ALIROOT_LIBS="$save_ALIROOT_LIBS -lTPCbase -lTPCrec"
-      LIBS="$save_LIBS $ALIROOT_LIBS"
+      LIBS="$save_LIBS $ROOTLIBS $ALIROOT_LIBS"
       AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <AliSimDigits.h>
                                       #include <AliTPCParam.h>
                                       #include <AliTPCParamSR.h>
@@ -186,6 +185,24 @@ if test ! "x$have_aliroot" = "xno" ; then
     AC_CHECK_HEADERS([AliTPCRawStream.h])
   fi
 
+  have_tpc_mapping=no
+  if test ! "x$have_aliroot" = "xno" ; then
+    # the TPCLib/AliHLTTPCRawReader needs the actual Pad layot of the TPC 
+    # which is stored in the TPC/mapping/Patchx.data files from
+    # AliRoot version v4-04-Release (May 2006)
+    AH_TEMPLATE([HAVE_TPC_MAPPING],[TPC pad mapping available])
+    TPC_PAD_MAPPING_PATH=$have_aliroot/TPC/mapping
+    AC_CHECK_FILE( [$TPC_PAD_MAPPING_PATH/Patch0.data], 
+                  [have_tpc_mapping=yes
+                   AC_SUBST(TPC_PAD_MAPPING_PATH)
+                   AC_DEFINE(HAVE_TPC_MAPPING)],
+                  [])
+    
+  fi
+  AC_MSG_CHECKING([for TPC mapping layout])
+  AM_CONDITIONAL(USE_TPC_MAPPING, test x$have_tpc_mapping = xyes)
+  AC_MSG_RESULT([$have_tpc_mapping])
+  
   if test "x$have_aliroot" = "xno" ; then
     ALIROOT_CPPFLAGS=
     ALIROOT_LDFLAGS=
@@ -333,6 +350,7 @@ AC_CONFIG_FILES([Makefile
                 BASE/Makefile
                 SampleLib/Makefile
                 TPCLib/Makefile
+                TPCLib/mapping2array.cxx
                 TPCLib/Ref/Makefile
                 doc/Makefile
                 doc/doxygen.conf])