]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/CALO/AliHLTCaloRawAnalyzerComponentv3.cxx
repairing server's action after EOR signal
[u/mrichter/AliRoot.git] / HLT / CALO / AliHLTCaloRawAnalyzerComponentv3.cxx
index 43fd33359db79f14a2daf72e842f84f1b84ae5d8..befbde795fe2072abf2d30420f630d8baa4a4955 100644 (file)
@@ -1,3 +1,4 @@
+// $Id$
 
 /**************************************************************************
  * This file is property of and copyright by the ALICE HLT Project        * 
@@ -14,6 +15,7 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+
 #include "AliCaloRawAnalyzer.h"
 #include "AliCaloBunchInfo.h"
 #include "AliCaloFitResults.h"
 #include "AliHLTCaloChannelDataStruct.h"
 #include "AliHLTCaloMapper.h"
 #include "AliHLTCaloSanityInspector.h"
-// #include "AliAltroRawStreamV3.h"
 #include "AliRawReaderMemory.h"
 #include "AliCaloRawStreamV3.h"
 #include "AliHLTCaloConstantsHandler.h"
 #include "AliHLTCaloChannelRawDataStruct.h"
 #include "AliLog.h"
+#include "TStopwatch.h"
+
+#include "AliCaloRawAnalyzerFactory.h"
+
+//#include "AliCaloConstants.h"
+
+//#include "AliCaloRawAnalyzer.h"
+
+//using namespace Algo;
 
 #include <vector>
 using namespace std;
@@ -35,52 +45,38 @@ using namespace std;
 ClassImp(AliHLTCaloRawAnalyzerComponentv3);
 
 
-#include  "TStopwatch.h"
-
-//TStopwatch  fgWatch; //CRAP PTH
-
-
-AliHLTCaloRawAnalyzerComponentv3::AliHLTCaloRawAnalyzerComponentv3(TString det):AliHLTCaloProcessor(),
-                                                                               AliHLTCaloConstantsHandler(det),
-                                                                               fAnalyzerPtr(0),
-                                                                               fMapperPtr(0),     
-                                                                               fCurrentSpec(-1),
-                                                                               fDebug(false),
-                                                                               fSanityInspectorPtr(0),
-                                                                               fRawReaderMemoryPtr(0),
-                                                                               fAltroRawStreamPtr(0),
-                                                                               fAlgorithm(0),  
-                                                                               fOffset(0),
-                                                                               fBunchSizeCut(0),
-                                                                               fMinPeakPosition(0),
-                                                                               fMaxPeakPosition(100),
-                                                                               fDoPushBadRawData(false),
-                                                                               fDoPushRawData(false),
-                                                                               fRawDataWriter(0)
+
+AliHLTCaloRawAnalyzerComponentv3::AliHLTCaloRawAnalyzerComponentv3(TString det, fitAlgorithm algo  ):AliHLTCaloProcessor(),
+                                                                                                    AliHLTCaloConstantsHandler(det),
+                                                                                                    fAnalyzerPtr(0),
+                                                                                                    fMapperPtr(0),     
+                                                                                                    fCurrentSpec(-1),
+                                                                                                    fDebug(false),
+                                                                                                    fSanityInspectorPtr(0),
+                                                                                                    fRawReaderMemoryPtr(0),
+                                                                                                    fAltroRawStreamPtr(0),
+                                                                                                    fDetector(det),
+                                                                                                    fAlgorithm(algo),  
+                                                                                                    fOffset(0),
+                                                                                                    fBunchSizeCut(0),
+                                                                                                    fMinPeakPosition(0),
+                                                                                                    fMaxPeakPosition(100),
+                                                                                                    fDoPushBadRawData(false),
+                                                                                                    fDoPushRawData(false),
+                                                                                                    fRawDataWriter(0)
                                                                        
 {
-  fSanityInspectorPtr = new AliHLTCaloSanityInspector();
+  //Constructor
   
-  if( fDoPushRawData == true  )
-  {
-    fRawDataWriter  = new RawDataWriter(fCaloConstants); 
-  }
-  
-  fRawReaderMemoryPtr = new AliRawReaderMemory();
-  fAltroRawStreamPtr = new AliCaloRawStreamV3(fRawReaderMemoryPtr, det);  
 }
 
 
 AliHLTCaloRawAnalyzerComponentv3::~AliHLTCaloRawAnalyzerComponentv3()
 {
-  delete fRawReaderMemoryPtr;
-  delete fAltroRawStreamPtr;
-  delete fRawDataWriter;
-  delete fSanityInspectorPtr;
+  //destructor
 }
 
 
-
 int
 AliHLTCaloRawAnalyzerComponentv3::DoInit( int argc, const char** argv )
 { 
@@ -123,6 +119,17 @@ AliHLTCaloRawAnalyzerComponentv3::DoInit( int argc, const char** argv )
            AliLog::SetGlobalLogLevel(AliLog::kError);  //PHOS sometimes produces bad data -> Fill up the HLT logs...
        }
     }
+
+  fAnalyzerPtr = AliCaloRawAnalyzerFactory::CreateAnalyzer(fAlgorithm);
+  fAnalyzerPtr->SetIsZeroSuppressed(true);
+  fSanityInspectorPtr = new AliHLTCaloSanityInspector();
+  
+  if( fDoPushRawData == true  )
+    {
+      fRawDataWriter  = new RawDataWriter(fCaloConstants); 
+    }
+  fRawReaderMemoryPtr = new AliRawReaderMemory();
+  fAltroRawStreamPtr = new AliCaloRawStreamV3(fRawReaderMemoryPtr, fDetector);  
  
   return iResult;
 }
@@ -131,11 +138,22 @@ AliHLTCaloRawAnalyzerComponentv3::DoInit( int argc, const char** argv )
 int 
 AliHLTCaloRawAnalyzerComponentv3::DoDeinit()
 {
+  //comment
   if(fAltroRawStreamPtr)
     {
       delete fAltroRawStreamPtr;
       fAltroRawStreamPtr = 0;
     }
+
+  if (fRawReaderMemoryPtr) delete fRawReaderMemoryPtr;
+  fRawReaderMemoryPtr=NULL;
+  if (fAltroRawStreamPtr) delete fAltroRawStreamPtr;
+  fAltroRawStreamPtr=NULL;
+  if (fRawDataWriter) delete fRawDataWriter;
+  fRawDataWriter=NULL;
+  if (fSanityInspectorPtr) delete fSanityInspectorPtr;
+  fSanityInspectorPtr=NULL;
+
   return 0;
 }
 
@@ -144,7 +162,8 @@ AliHLTCaloRawAnalyzerComponentv3::DoDeinit()
 void 
 AliHLTCaloRawAnalyzerComponentv3::PrintDebugInfo()
 {
-  static TStopwatch  Watch; //CRAP PTH
+  //comment
+  static TStopwatch  watch; //CRAP PTH
   static double wlast = -1;
   static double wcurrent = 0;
   
@@ -154,9 +173,9 @@ AliHLTCaloRawAnalyzerComponentv3::PrintDebugInfo()
        {
          cout << __FILE__ << __LINE__ << " : Processing event "  << fCaloEventCount << endl; 
          wlast =  wcurrent;
-         wcurrent =  Watch.RealTime();
+         wcurrent =  watch.RealTime();
          cout << __FILE__ << __LINE__ << "The event rate is " <<  
-           1000/( wcurrent  -  wlast ) << "  Hz" << endl;        Watch.Start(kFALSE); 
+           1000/( wcurrent  -  wlast ) << "  Hz" << endl;        watch.Start(kFALSE); 
        }
     }
 }
@@ -174,10 +193,11 @@ AliHLTCaloRawAnalyzerComponentv3::GetOutputDataSize(unsigned long& constBase, do
 bool 
 AliHLTCaloRawAnalyzerComponentv3::CheckInputDataType(const AliHLTComponentDataType &datatype)
 {
+  //comment
   vector <AliHLTComponentDataType> validTypes;
   GetInputDataTypes(validTypes);
   
-  for(int i=0; i < validTypes.size(); i++ )
+  for(UInt_t i=0; i < validTypes.size(); i++ )
     {
       if ( datatype  ==  validTypes.at(i) )
        {
@@ -195,6 +215,7 @@ AliHLTCaloRawAnalyzerComponentv3::DoEvent( const AliHLTComponentEventData& evtDa
                                          AliHLTComponentTriggerData& /*trigData*/, 
                                          AliHLTUInt8_t* outputPtr, AliHLTUInt32_t& size, vector<AliHLTComponentBlockData>& outputBlocks )
 {
+  //comment
   if(!IsDataEvent())
    {
      size = 0;
@@ -247,6 +268,7 @@ AliHLTCaloRawAnalyzerComponentv3::DoEvent( const AliHLTComponentEventData& evtDa
 Int_t
 AliHLTCaloRawAnalyzerComponentv3::DoIt(const AliHLTComponentBlockData* iter, AliHLTUInt8_t* outputPtr, const AliHLTUInt32_t size, UInt_t& totSize)
 {
+  //comment
   int tmpsize=  0;
   Int_t crazyness          = 0;
   Int_t nSamples           = 0;
@@ -278,9 +300,10 @@ AliHLTCaloRawAnalyzerComponentv3::DoIt(const AliHLTComponentBlockData* iter, Ali
          else
            {
              ++ cnt;
-             UShort_t* firstBunchPtr = 0;
+             //UShort_t* firstBunchPtr = 0;
              int chId = fMapperPtr->GetChannelID(iter->fSpecification, fAltroRawStreamPtr->GetHWAddress()); 
-           
+                               //patch to skip LG in EMC
+                               if(fDetector.CompareTo("EMCAL") == 0 && (int)((chId >> 12)&0x1) == 0) continue;
              if( fDoPushRawData == true)
                {
                  fRawDataWriter->SetChannelId( chId );
@@ -299,7 +322,7 @@ AliHLTCaloRawAnalyzerComponentv3::DoIt(const AliHLTComponentBlockData* iter, Ali
                      fRawDataWriter->WriteBunchData( fAltroRawStreamPtr->GetSignals(), 
                                                      nSamples,  fAltroRawStreamPtr->GetEndTimeBin()  );
                    }
-                 firstBunchPtr = const_cast< UShort_t* >(  fAltroRawStreamPtr->GetSignals()  );
+                 //firstBunchPtr = const_cast< UShort_t* >(  fAltroRawStreamPtr->GetSignals()  );
                }
            
              totSize += sizeof( AliHLTCaloChannelDataStruct );
@@ -318,6 +341,7 @@ AliHLTCaloRawAnalyzerComponentv3::DoIt(const AliHLTComponentBlockData* iter, Ali
                channelDataPtr->fChannelID =  chId;
                channelDataPtr->fEnergy = static_cast<Float_t>( res.GetAmp()  ) - fOffset;
                channelDataPtr->fTime = static_cast<Float_t>(  res.GetTof() );
+               if(fDetector.CompareTo("EMCAL") == 0) channelDataPtr->fTime = static_cast<Float_t>(  res.GetTof() )*100E-9 - fAltroRawStreamPtr->GetL1Phase();
                channelDataPtr->fCrazyness = static_cast<Short_t>(crazyness);
                channelCount++;
                channelDataPtr++; // Updating position of the free output.
@@ -359,6 +383,7 @@ AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::RawDataWriter(AliHLTCaloConstan
   fCurrentChannelDataPtr(0),
   fTotalSize(0)
 {
+  //comment
   fRawDataBuffer = new UShort_t[fBufferSize];
   Init();
 }
@@ -373,6 +398,7 @@ AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::~RawDataWriter()
 void  
 AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::Init()
 {
+  //comment
   fCurrentChannelIdPtr = fRawDataBuffer;
   fCurrentChannelSizePtr = fRawDataBuffer +1;
   fCurrentChannelDataPtr = fRawDataBuffer +2;
@@ -383,6 +409,7 @@ AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::Init()
 void
 AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::NewEvent()
 {
+  //comment
   Init();
   fTotalSize = 0;
 }
@@ -391,6 +418,7 @@ AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::NewEvent()
 void
 AliHLTCaloRawAnalyzerComponentv3::RawDataWriter::NewChannel( )
 {
+  //comment
   *fCurrentChannelSizePtr   = fCurrentChannelSize;
   fCurrentChannelIdPtr     += fCurrentChannelSize;
   fCurrentChannelSizePtr    += fCurrentChannelSize;