Made it possible to read different and several events from rootfile.
authorvestbo <vestbo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 29 May 2002 11:30:10 +0000 (11:30 +0000)
committervestbo <vestbo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 29 May 2002 11:30:10 +0000 (11:30 +0000)
Also included a ntuppel, for storing different characteristics of the
peaks in AliL3HoughMaxFinder.

HLT/hough/AliL3Hough.cxx
HLT/hough/AliL3Hough.h
HLT/hough/AliL3HoughEval.cxx
HLT/hough/AliL3HoughMaxFinder.cxx
HLT/hough/AliL3HoughMaxFinder.h
HLT/hough/AliL3HoughTrack.cxx

index 6e4c5cc82bdb06ff4b6d35327d034534edcd7155..1573bfb7e7b122324c1aa29de1aaa8367e3b4604 100644 (file)
@@ -110,7 +110,6 @@ void AliL3Hough::Init(Char_t *path,Bool_t binary,Int_t n_eta_segments,Bool_t bit
   fUse8bits = bit8;
   
   AliL3Transform::Init(fPath);
-  fPeakThreshold = 0;
   fNPatches = AliL3Transform::GetNPatches();
   fHoughTransformer = new AliL3HoughBaseTransformer*[fNPatches];
   fMemHandler = new AliL3MemHandler*[fNPatches];
@@ -161,7 +160,7 @@ void AliL3Hough::Process(Int_t minslice,Int_t maxslice)
   
 }
 
-void AliL3Hough::ReadData(Int_t slice)
+void AliL3Hough::ReadData(Int_t slice,Int_t eventnr=0)
 {
   //Read data from files, binary or root.
 
@@ -185,7 +184,8 @@ void AliL3Hough::ReadData(Int_t slice)
       else //read data from root file
        {
 #ifdef use_aliroot
-         digits=(AliL3DigitRowData *)fMemHandler[i]->AliDigits2Memory(ndigits); 
+         digits=(AliL3DigitRowData *)fMemHandler[i]->AliDigits2Memory(ndigits,eventnr); 
+         fMemHandler[i]->FreeDigitsTree();
 #else
          cerr<<"You cannot read from rootfile now"<<endl;
 #endif
@@ -319,8 +319,9 @@ void AliL3Hough::FindTrackCandidates()
          if(hist->GetNEntries()==0) continue;
          fPeakFinder->Reset();
          fPeakFinder->SetHistogram(hist);
-         fPeakFinder->SetThreshold(fPeakThreshold);
-         fPeakFinder->FindMaxima(); //Simple maxima finder
+         fPeakFinder->FindMaxima(0,0); //Simple maxima finder
+         //fPeakFinder->FindAbsMaxima();
+         cout<<"Found "<<fPeakFinder->GetEntries()<<endl;
          for(Int_t k=0; k<fPeakFinder->GetEntries(); k++)
            {
              if(fPeakFinder->GetWeight(k) == 0) continue;
@@ -339,7 +340,7 @@ void AliL3Hough::InitEvaluate()
 {
   //Pass the transformer objects to the AliL3HoughEval objects:
   //This will provide the evaluation objects with all the necessary
-  //data it needs.
+  //data and parameters it needs.
   
   for(Int_t i=0; i<fNPatches; i++) 
     fEval[i]->InitTransformer(fHoughTransformer[i]);
@@ -437,9 +438,10 @@ void AliL3Hough::WriteTracks(Int_t slice,Char_t *path)
   delete mem;
   
 }
-#ifdef use_aliroot
+
 void AliL3Hough::WriteDigits(Char_t *outfile)
 {
+#ifdef use_aliroot  
   //Write the current data to a new rootfile.
 
   for(Int_t i=0; i<fNPatches; i++)
@@ -447,6 +449,9 @@ void AliL3Hough::WriteDigits(Char_t *outfile)
       AliL3DigitRowData *tempPt = (AliL3DigitRowData*)fHoughTransformer[i]->GetDataPointer();
       fMemHandler[i]->AliDigits2RootFile(tempPt,outfile);
     }
-  
+#else
+  cerr<<"AliL3Hough::WriteDigits : You need to compile with AliROOT!"<<endl;
+  return;
+#endif  
 }
-#endif
+
index 1319655f5af91cbc12a953cf650348314dd61279..1c034a31f6fddfe9d20f5a854a8d528cc02d5a71 100644 (file)
@@ -25,7 +25,6 @@ class AliL3Hough {
   Bool_t fUse8bits;
   Int_t fNEtaSegments;
   Int_t fNPatches;
-  Int_t fPeakThreshold;
   AliL3MemHandler **fMemHandler; //!
   AliL3HoughBaseTransformer **fHoughTransformer; //!
   AliL3HoughEval **fEval; //!
@@ -44,7 +43,7 @@ class AliL3Hough {
   
   void Init(Char_t *path,Bool_t binary,Int_t n_eta_segments,Bool_t bit8=kFALSE);
   void Process(Int_t minslice,Int_t maxslice);
-  void ReadData(Int_t slice);
+  void ReadData(Int_t slice,Int_t eventnr=0);
   void Transform(Int_t row_range = -1);
   void ProcessSliceIter();
   void ProcessPatchIter(Int_t patch);
@@ -56,9 +55,7 @@ class AliL3Hough {
   void Evaluate(Int_t road_width=1);
   void EvaluateWithEta();
   void WriteTracks(Int_t slice,Char_t *path="./");
-#ifdef use_aliroot
   void WriteDigits(Char_t *outfile="output_digits.root");
-#endif
   void InitEvaluate();
   
   //Setters
@@ -66,7 +63,6 @@ class AliL3Hough {
   void SetAddHistograms() {fAddHistograms = kTRUE;}
   void DoIterative() {fDoIterative = kTRUE;}
   void SetWriteDigits() {fWriteDigits = kTRUE;}
-  void SetPeakThreshold(Int_t i) {fPeakThreshold = i;}
   
   //Getters
   AliL3HoughBaseTransformer *GetTransformer(Int_t i) {if(!fHoughTransformer[i]) return 0; return fHoughTransformer[i];}
@@ -75,7 +71,7 @@ class AliL3Hough {
   AliL3HoughMerger *GetMerger() {if(!fMerger) return 0; return fMerger;}
   AliL3HoughIntMerger *GetInterMerger() {if(!fInterMerger) return 0; return fInterMerger;}
   AliL3MemHandler *GetMemHandler(Int_t i) {if(!fMemHandler[i]) return 0; return fMemHandler[i];}
-
+  AliL3HoughMaxFinder *GetMaxFinder() {return fPeakFinder;}
 
   ClassDef(AliL3Hough,1) //Hough transform base class
 
index 35fd89258e4f87d01737448cb4c1145abb854e6c..a26cc42be22c0230627f1e837a0595476e69f34d 100644 (file)
@@ -92,9 +92,7 @@ Bool_t AliL3HoughEval::LookInsideRoad(AliL3HoughTrack *track,Int_t eta_index,Boo
   Float_t xyz[3];
   
   Int_t total_charge=0;//total charge along the road
-  Double_t etaslice = (fEtaMax - fEtaMin)/fNEtaSegments;
-
-
+  
   //Check if the track is leaving the sector at some point
   Float_t maxrow=300;
   Double_t angle=AliL3Transform::Pi()/18;
@@ -269,7 +267,6 @@ void AliL3HoughEval::DisplayEtaSlice(Int_t eta_index,AliL3Histogram *hist)
       return;
     }
   
-  Double_t etaslice = (fEtaMax - fEtaMin)/fNEtaSegments;
   for(Int_t padrow = AliL3Transform::GetFirstRow(fPatch); padrow <= AliL3Transform::GetLastRow(fPatch); padrow++)
     {
       Int_t prow = padrow - AliL3Transform::GetFirstRow(fPatch);
@@ -298,7 +295,7 @@ void AliL3HoughEval::DisplayEtaSlice(Int_t eta_index,AliL3Histogram *hist)
          AliL3Transform::Slice2Sector(fSlice,padrow,sector,row);
          AliL3Transform::Raw2Local(xyz,sector,row,pad,time);
          Double_t eta = AliL3Transform::GetEta(xyz);
-         Int_t pixel_index = (Int_t)(eta/etaslice);
+         Int_t pixel_index = fHoughTransformer->GetEtaIndex(eta);//(Int_t)(eta/etaslice);
          if(pixel_index != eta_index) continue;
          hist->Fill(xyz[0],xyz[1],charge);
        }
index 2bf9a71b738f26683a1d676cf5887ef9c8eac747..3a93770f5b4673a435e4896ff712814ec8896b4b 100644 (file)
@@ -7,6 +7,9 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <TNtuple.h>
+#include <TFile.h>
+
 #include "AliL3Histogram.h"
 #include "AliL3TrackArray.h"
 #include "AliL3HoughTrack.h"
@@ -29,6 +32,7 @@ AliL3HoughMaxFinder::AliL3HoughMaxFinder()
   fYPeaks=0;
   fNPeaks=0;
   fNMax=0;
+  fNtuppel = 0;
 }
 
 
@@ -47,6 +51,8 @@ AliL3HoughMaxFinder::AliL3HoughMaxFinder(Char_t *histotype,Int_t nmax,AliL3Histo
   fXPeaks = new Float_t[fNMax];
   fYPeaks = new Float_t[fNMax];
   fWeight = new Int_t[fNMax];
+  fNtuppel = 0;
+  fThreshold=0;
 }
 
 
@@ -59,6 +65,8 @@ AliL3HoughMaxFinder::~AliL3HoughMaxFinder()
     delete [] fYPeaks;
   if(fWeight)
     delete [] fWeight;
+  if(fNtuppel)
+    delete fNtuppel;
 }
 
 void AliL3HoughMaxFinder::Reset()
@@ -72,11 +80,31 @@ void AliL3HoughMaxFinder::Reset()
   fNPeaks=0;
 }
 
+void AliL3HoughMaxFinder::CreateNtuppel()
+{
+  fNtuppel = new TNtuple("ntuppel","Peak charateristics","kappa:phi0:weigth:content3:content5:content1:content7");
+  //content#; neighbouring bins of the peak.
+  
+}
+
+void AliL3HoughMaxFinder::WriteNtuppel(Char_t *filename)
+{
+  TFile *file = TFile::Open(filename,"RECREATE");
+  if(!file)
+    {
+      cerr<<"AliL3HoughMaxFinder::WriteNtuppel : Error opening file "<<filename<<endl;
+      return;
+    }
+  fNtuppel->Write();
+  file->Close();
+}
+
 void AliL3HoughMaxFinder::FindAbsMaxima()
 {
+  
   if(!fCurrentHisto)
     {
-      printf("AliL3HoughMaxFinder::FindAbsMaxima : No histogram!\n");
+      cerr<<"AliL3HoughMaxFinder::FindAbsMaxima : No histogram"<<endl;
       return;
     }
   AliL3Histogram *hist = fCurrentHisto;
@@ -110,13 +138,24 @@ void AliL3HoughMaxFinder::FindAbsMaxima()
       return;
     }
   
+      
   Double_t max_x = hist->GetBinCenterX(max_xbin);
   Double_t max_y = hist->GetBinCenterY(max_ybin);
   fXPeaks[fNPeaks] = max_x;
   fYPeaks[fNPeaks] = max_y;
   fWeight[fNPeaks] = (Int_t)max_value;
   fNPeaks++;
-
+  
+  if(fNtuppel)
+    {
+      Int_t bin3 = hist->GetBin(max_xbin-1,max_ybin);
+      Int_t bin5 = hist->GetBin(max_xbin+1,max_ybin);
+      Int_t bin1 = hist->GetBin(max_xbin,max_ybin-1);
+      Int_t bin7 = hist->GetBin(max_xbin,max_ybin+1);
+      
+      fNtuppel->Fill(max_x,max_y,max_value,hist->GetBinContent(bin3),hist->GetBinContent(bin5),hist->GetBinContent(bin1),hist->GetBinContent(bin7));
+    }
+  
 }
 
 void AliL3HoughMaxFinder::FindBigMaxima()
@@ -173,7 +212,7 @@ void AliL3HoughMaxFinder::FindBigMaxima()
 }
 
 
-void AliL3HoughMaxFinder::FindMaxima()
+void AliL3HoughMaxFinder::FindMaxima(Double_t grad_x,Double_t grad_y)
 {
   //Locate all the maxima in input histogram.
   //Maxima is defined as bins with more entries than the
@@ -186,9 +225,6 @@ void AliL3HoughMaxFinder::FindMaxima()
   Int_t bin[9];
   Double_t value[9];
   
-  Double_t grad_x = 3;
-  Double_t grad_y = 3;
-
   for(Int_t xbin=xmin+1; xbin<xmax-1; xbin++)
     {
       for(Int_t ybin=ymin+1; ybin<ymax-1; ybin++)
@@ -222,7 +258,7 @@ void AliL3HoughMaxFinder::FindMaxima()
              Float_t max_x = fCurrentHisto->GetBinCenterX(xbin);
              Float_t max_y = fCurrentHisto->GetBinCenterY(ybin);
              
-             
+             cout<<"Checking for threshols "<<value[4]<<" "<<fThreshold<<endl;
              if((Int_t)value[4] <= fThreshold) continue;//central bin below threshold
              
              if(fNPeaks > fNMax)
@@ -236,7 +272,6 @@ void AliL3HoughMaxFinder::FindMaxima()
                 value[4]/value[1] < grad_y || value[4]/value[7] < grad_y)
                continue;
              
-             
              fXPeaks[fNPeaks] = max_x;
              fYPeaks[fNPeaks] = max_y;
              fWeight[fNPeaks] = (Int_t)value[4];
index 648406254317f30caaff7d4747c2170c6ab98295..f2e91d1d832fcc9fe8c5efd9e98c527c8c4c6cab 100644 (file)
@@ -7,6 +7,7 @@
 class AliL3Histogram;
 class AliL3TrackArray;
 class AliL3HoughTrack;
+class TNtuple;
 
 struct AxisWindow
 {
@@ -31,16 +32,21 @@ class AliL3HoughMaxFinder {
   
   Char_t fHistoType;
 
+  TNtuple *fNtuppel; //!
+
+
  public:
   AliL3HoughMaxFinder(); 
   AliL3HoughMaxFinder(Char_t *histotype,Int_t nmax,AliL3Histogram *hist=0);
   virtual ~AliL3HoughMaxFinder();
   void Reset();
-  
+  void CreateNtuppel();
+  void WriteNtuppel(Char_t *filename);
+
   //Simple maxima finders:
   void FindAbsMaxima();
   void FindBigMaxima();
-  void FindMaxima();
+  void FindMaxima(Double_t grad_x,Double_t grad_y);
   
   //More sophisticated peak finders:
   AliL3TrackArray *LookForPeaks(AliL3Histogram *hist,Int_t nbins);
index 6cfbbd7d2e68a305735c99a91b073a3c3b8f0fe6..ba6c1a44a492503875096f916d4c863d03e77975 100644 (file)
@@ -27,6 +27,8 @@ AliL3HoughTrack::AliL3HoughTrack()
   fPsiLine = 0;
   fIsHelix = true;
   fEtaIndex = -1;
+  fEta = 0;
+  
 }