]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/PHOS/AliHLTPHOSRawAnalyzerPeakFinderComponent.cxx
- changes to make the clusterisation work for EMCAL
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSRawAnalyzerPeakFinderComponent.cxx
index 070c9cdfc5ab32733d1153dd1f830302cd7a787e..d5372675b8be067d1d0d0ce55ccabb0f3ab645a1 100644 (file)
@@ -1,3 +1,5 @@
+// $Id$
+
 /**************************************************************************
  * Copyright(c) 2006, ALICE Experiment at CERN, All rights reserved.      *
  *                                                                        *
  **************************************************************************/
 
 #include "AliHLTPHOSRawAnalyzerPeakFinderComponent.h"
-#include "AliHLTPHOSRawAnalyzerPeakFinder.h"
+#include "AliHLTCaloRawAnalyzerPeakFinder.h"
 
-//ClassImp(AliHLTPHOSRawAnalyzerPeakFinderComponent) 
 AliHLTPHOSRawAnalyzerPeakFinderComponent gAliHLTPHOSRawAnalyzerPeakFinderComponent;
 
-AliHLTPHOSRawAnalyzerPeakFinderComponent::AliHLTPHOSRawAnalyzerPeakFinderComponent():AliHLTPHOSRawAnalyzerComponent()
+//___________________________________________________________________________________________________________
+AliHLTPHOSRawAnalyzerPeakFinderComponent::AliHLTPHOSRawAnalyzerPeakFinderComponent():AliHLTPHOSRawAnalyzerComponentv3()
 {
-  Double_t tmpAVector[70];
-  Double_t tmpTVector[70]; 
-  analyzerPtr = new AliHLTPHOSRawAnalyzerPeakFinder();
-  analyzerPtr->SetStartIndex(0);
-  FILE *fp;
-  fp = fopen("/home/perthi/cern/aliroot/AliRoot_head/HLT/PHOS/PFVectors/start0N70tau2fs10.txt", "r");
-  
-  if(fp != 0)
-    {
-      for(int i=0; i < 70; i++)
-       {
-         fscanf(fp, "%lf", &tmpAVector[i]);
-       }
-
-      fscanf(fp, "\n");
-
-      for(int i=0; i < 70; i++)
-       {
-                 fscanf(fp, "%lf", &tmpTVector[i]);
-       }
-
-      analyzerPtr->SetAVector(tmpAVector, 70);
-      analyzerPtr->SetTVector(tmpTVector, 70);
-
-      fclose(fp);
+  fAnalyzerPtr = new AliHLTCaloRawAnalyzerPeakFinder();
 
+  if(1)//LoadPFVector() == kFALSE)
+    {
+      //      cout << "Warning, could not load PF vectors" << endl;
     }
-  
-  else
+  else 
     {
-      cout <<"AliHLTPHOSRawAnalyzerPeakFinderComponent, ERROR: could not  open PF vector file" << endl;
+      //    cout << "Loaded PF vectors" << endl;
     }
-  
-
 } 
 
+
+//___________________________________________________________________________________________________________
 AliHLTPHOSRawAnalyzerPeakFinderComponent::~AliHLTPHOSRawAnalyzerPeakFinderComponent()
 {
 
+  if(fAnalyzerPtr)
+    {
+      delete fAnalyzerPtr;
+      fAnalyzerPtr = 0;
+    }
 }
 
 
-
-AliHLTPHOSRawAnalyzerPeakFinderComponent::AliHLTPHOSRawAnalyzerPeakFinderComponent(const AliHLTPHOSRawAnalyzerPeakFinderComponent & ) : AliHLTPHOSRawAnalyzerComponent()
+//___________________________________________________________________________________________________________
+AliHLTPHOSRawAnalyzerPeakFinderComponent::AliHLTPHOSRawAnalyzerPeakFinderComponent(const AliHLTPHOSRawAnalyzerPeakFinderComponent & ) : AliHLTPHOSRawAnalyzerComponentv3()
 {
 
 }
 
+//-----------------------------------------------------------------------------------------------------------
+int
+AliHLTPHOSRawAnalyzerPeakFinderComponent::Deinit()
+{
+  
+  if(fAnalyzerPtr)
+    {
+      delete fAnalyzerPtr;
+      fAnalyzerPtr = 0;
+    }
+  Logging(kHLTLogInfo, "HLT", "PHOS", ",AliHLTPHOSRawAnalyzerCrudeComponent Deinit");
+  return 0;
+}
 
+//___________________________________________________________________________________________________________
 const char* 
 AliHLTPHOSRawAnalyzerPeakFinderComponent::GetComponentID()
 {
   return "PhosRawPeakFinder";
 }
 
+//___________________________________________________________________________________________________________
+Bool_t 
+AliHLTPHOSRawAnalyzerPeakFinderComponent::LoadPFVector()
+{
+  return LoadPFVector(fCaloConstants->GetPFDEFAULTSTARTINDEX(),  fCaloConstants->GetPFDEFAULTNSAMPLES(), 
+                                 fCaloConstants->GetDEFAULTTAU(), fCaloConstants->GetDEFAULTFS() );
+}
+
+
+//___________________________________________________________________________________________________________
+Bool_t 
+AliHLTPHOSRawAnalyzerPeakFinderComponent::LoadPFVector(int startIndex, int nSamples, int tau, int fs)
+{
+   
+  char tmpPFPath[fCaloConstants->GetPFMAXPATHLENGTH()];
+  Double_t * tmpAVector = new Double_t[nSamples];
+  Double_t * tmpTVector = new Double_t[nSamples]; 
+  sprintf(tmpPFPath,"%s%s/start%dN%dtau%dfs%d.txt", getenv("ALICE_ROOT"), PFVECTORDIR, startIndex, nSamples, tau, fs);
+  FILE *fp;
+  fp = fopen(tmpPFPath, "r");
+  
+  Int_t res = 0; //OD to get rid of warnings
+  if(fp != 0)
+    {
+      for(int i=0; i <  nSamples; i++)
+       {
+         res = fscanf(fp, "%lf", &tmpAVector[i]);
+       }
+
+      res = fscanf(fp, "\n");
+
+      for(int i=0; i < nSamples; i++)
+       {
+         res = fscanf(fp, "%lf", &tmpTVector[i]);
+       }
+      //      fAnalyzerPtr->SetAVector(tmpAVector,  nSamples);
+      //      fAnalyzerPtr->SetTVector(tmpTVector,  nSamples);
+      fclose(fp);
+      delete [] tmpAVector;
+      delete [] tmpTVector;
+      return kTRUE;
+    }
+  
+  else
+    {
+      delete [] tmpAVector;
+      delete [] tmpTVector;
+      HLTFatal("ERROR: could not  open PF vector file");
+      return kFALSE;
+    }
+}
+
 
+//___________________________________________________________________________________________________________
 AliHLTComponent*
 AliHLTPHOSRawAnalyzerPeakFinderComponent::Spawn()
 {