]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Restoring raw data fit from version of 29-Aug-2004
authorkharlov <kharlov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 26 Jul 2005 13:32:39 +0000 (13:32 +0000)
committerkharlov <kharlov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 26 Jul 2005 13:32:39 +0000 (13:32 +0000)
PHOS/AliPHOS.h
PHOS/AliPHOSGetter.cxx
PHOS/AliPHOSGetter.h

index 4cdfa9b58a24a0fbd1be16197eb86d7ab97289fd..6673b2bcffb51d35b1218d71661ba50dc0d98d44 100644 (file)
@@ -7,6 +7,9 @@
 /* History of cvs commits:
  *
  * $Log$
+ * Revision 1.62  2005/07/06 10:10:32  hristov
+ * Moving the functions used to initialize TF1 and TF2 to the pivate part of the class
+ *
  * Revision 1.61  2005/05/28 12:10:07  schutz
  * Copy constructor is corrected (by T.P.)
  *
@@ -72,6 +75,8 @@ public:
   Double_t GetRawFormatTimePeak() const { return fgTimePeak ; }    
   Double_t GetRawFormatTimeTrigger() const { return fgTimeTrigger ; }   
   static Double_t RawResponseFunctionMax(Double_t charge, Double_t gain) ;
+  static Double_t RawResponseFunction(Double_t *x, Double_t *par) ; 
+  Bool_t   RawSampledResponse(const Double_t dtime, const Double_t damp, Int_t * adcH, Int_t * adcL) const ; 
   //
   virtual AliLoader* MakeLoader(const char* topfoldername);
   virtual void    SetTreeAddress();   
@@ -82,8 +87,6 @@ public:
 
 protected:
 
-  static Double_t RawResponseFunction(Double_t *x, Double_t *par) ; 
-  Bool_t   RawSampledResponse(const Double_t dtime, const Double_t damp, Int_t * adcH, Int_t * adcL) const ; 
   
   
   static Double_t fgCapa ;              // capacitor of the preamplifier for the raw RO signal
index 5fdc8489ad20aa504312f6bc9036bbc5db1f2b77..719daf3c1cfb724c0d487106bc80fe5cfb613c2c 100644 (file)
@@ -550,6 +550,76 @@ Bool_t AliPHOSGetter::OpenESDFile()
   return rv ; 
 }
 
+//____________________________________________________________________________ 
+void AliPHOSGetter::FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Int_t & amp, Double_t & time)
+{
+  // Fits the raw signal time distribution 
+
+  const Int_t kNoiseThreshold = 0 ;
+  Double_t timezero1 = 0., timezero2 = 0., timemax = 0. ;
+  Double_t signal = 0., signalmax = 0. ;       
+  Double_t energy = time = 0. ; 
+
+  if (lowGainFlag) {
+    timezero1 = timezero2 = signalmax = timemax = 0. ;
+    signalF->FixParameter(0, PHOS()->GetRawFormatLowCharge()) ; 
+    signalF->FixParameter(1, PHOS()->GetRawFormatLowGain()) ; 
+    Int_t index ; 
+    for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
+      gLowGain->GetPoint(index, time, signal) ; 
+      if (signal > kNoiseThreshold && timezero1 == 0.) 
+       timezero1 = time ;
+      if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
+       timezero2 = time ; 
+      if (signal > signalmax) {
+       signalmax = signal ; 
+       timemax   = time ; 
+      }
+    }
+    signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatLowCharge(), 
+                                               PHOS()->GetRawFormatLowGain()) ;
+    if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise 
+      signalF->SetParameter(2, signalmax) ; 
+      signalF->SetParameter(3, timezero1) ;                
+      gLowGain->Fit(signalF, "QRON", "", 0., timezero2); //, "QRON") ; 
+      energy = signalF->GetParameter(2) ; 
+      time   = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
+    }
+  } else {
+    timezero1 = timezero2 = signalmax = timemax = 0. ;
+    signalF->FixParameter(0, PHOS()->GetRawFormatHighCharge()) ; 
+    signalF->FixParameter(1, PHOS()->GetRawFormatHighGain()) ; 
+    Int_t index ; 
+    for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
+      gHighGain->GetPoint(index, time, signal) ;               
+      if (signal > kNoiseThreshold && timezero1 == 0.) 
+       timezero1 = time ;
+      if (signal <= kNoiseThreshold && timezero1 > 0. && timezero2 == 0.)
+       timezero2 = time ; 
+      if (signal > signalmax) {
+       signalmax = signal ;   
+       timemax   = time ; 
+      }
+    }
+    signalmax /= PHOS()->RawResponseFunctionMax(PHOS()->GetRawFormatHighCharge(), 
+                                               PHOS()->GetRawFormatHighGain()) ;;
+    if ( timezero1 + PHOS()->GetRawFormatTimePeak() < PHOS()->GetRawFormatTimeMax() * 0.4 ) { // else its noise  
+      signalF->SetParameter(2, signalmax) ; 
+      signalF->SetParameter(3, timezero1) ;               
+      gHighGain->Fit(signalF, "QRON", "", 0., timezero2) ; 
+      energy = signalF->GetParameter(2) ; 
+      time   = signalF->GetMaximumX() - PHOS()->GetRawFormatTimePeak() - PHOS()->GetRawFormatTimeTrigger() ;
+    }
+  }
+  
+  if (time == 0. && energy == 0.) 
+    amp = 0 ; 
+  else {
+  AliPHOSDigitizer * digitizer = Digitizer() ; 
+  amp = static_cast<Int_t>( (energy - digitizer->GetEMCpedestal()) / digitizer->GetEMCchannel() + 0.5 ) ; 
+  }
+}
+
 //____________________________________________________________________________ 
 Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader)
 {
@@ -558,36 +628,103 @@ Int_t AliPHOSGetter::ReadRaw(AliRawReader *rawReader)
 
   AliPHOSRawStream in(rawReader);
  
+  Bool_t first = kTRUE ;
+  
+  TF1 * signalF = new TF1("signal", AliPHOS::RawResponseFunction, 0, PHOS()->GetRawFormatTimeMax(), 4);
+  signalF->SetParNames("Charge", "Gain", "Amplitude", "TimeZero") ; 
+
+  Int_t relId[4], id ;
+  Bool_t lowGainFlag = kFALSE ; 
   TClonesArray * digits = Digits() ;
   digits->Clear() ; 
   Int_t idigit = 0 ; 
+  Int_t amp = 0 ; 
+  Double_t time = 0. ; 
 
-  while ( in.Next() ) { // PHOS entries loop 
-    Int_t amp = in.GetSignal() ; 
-    Double_t time = in.GetTime() ; 
-    Int_t relId[4], id ;
+  TGraph * gLowGain = new TGraph(PHOS()->GetRawFormatTimeBins()) ; 
+  TGraph * gHighGain= new TGraph(PHOS()->GetRawFormatTimeBins()) ;  
 
-    relId[0] = in.GetModule() ;
-    if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) { 
-      relId[0] -=  PHOS()->GetRawFormatLowGainOffset() ; 
-    }
-    relId[1] = 0 ; 
-    relId[2] = in.GetRow() ; 
-    relId[3] = in.GetColumn() ; 
-    PHOSGeometry()->RelToAbsNumbering(relId, id) ;     
-    
-    if (amp > 0 && id >=0 ) {
-      new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;        
-      idigit++ ; 
+  while ( in.Next() ) { // PHOS entries loop 
+    if ( (in.IsNewRow() || in.IsNewColumn() || in.IsNewModule()) ) {
+      if (!first) {
+       FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, amp, time) ; 
+       if (amp > 0) {
+         new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;     
+         idigit++ ; 
+       }
+       Int_t index ; 
+       for (index = 0; index < PHOS()->GetRawFormatTimeBins(); index++) {
+         gLowGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ;  
+         gHighGain->SetPoint(index, index * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 0) ; 
+       } 
+      }
+      first = kFALSE ; 
+      relId[0] = in.GetModule() ;
+      if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) { 
+       relId[0] -=  PHOS()->GetRawFormatLowGainOffset() ; 
+       lowGainFlag = kTRUE ; 
+      } else 
+       lowGainFlag = kFALSE ; 
+      relId[1] = 0 ; 
+      relId[2] = in.GetRow() ; 
+      relId[3] = in.GetColumn() ; 
+      PHOSGeometry()->RelToAbsNumbering(relId, id) ;   
     }
-    
+    if (lowGainFlag)
+      gLowGain->SetPoint(in.GetTime(), 
+                    in.GetTime()* PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 
+                    in.GetSignal()) ;
+    else 
+      gHighGain->SetPoint(in.GetTime(), 
+                        in.GetTime() * PHOS()->GetRawFormatTimeMax() / PHOS()->GetRawFormatTimeBins(), 
+                        in.GetSignal() ) ;
+
   } // PHOS entries loop
-  
+
+  FitRaw(lowGainFlag, gLowGain, gHighGain, signalF, amp, time) ; 
+  if (amp > 0 ) {
+    new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;
+    idigit++ ; 
+  }
   digits->Sort() ; 
+
+  delete signalF ; 
+  delete gLowGain, gHighGain ; 
   
   return digits->GetEntriesFast() ; 
 }
+
+//   TClonesArray * digits = Digits() ;
+//   digits->Clear() ; 
+//   Int_t idigit = 0 ; 
+
+//   while ( in.Next() ) { // PHOS entries loop 
+//     Int_t amp = in.GetSignal() ; 
+//     Double_t time = in.GetTime() ; 
+//     Int_t relId[4], id ;
+
+//     relId[0] = in.GetModule() ;
+//     if ( relId[0] >= PHOS()->GetRawFormatLowGainOffset() ) { 
+//       relId[0] -=  PHOS()->GetRawFormatLowGainOffset() ; 
+//     }
+//     relId[1] = 0 ; 
+//     relId[2] = in.GetRow() ; 
+//     relId[3] = in.GetColumn() ; 
+//     PHOSGeometry()->RelToAbsNumbering(relId, id) ;  
+    
+//     if (amp > 0 && id >=0 ) {
+//       new((*digits)[idigit]) AliPHOSDigit( -1, id, amp, time) ;     
+//       idigit++ ; 
+//     }
+    
+//   } // PHOS entries loop
+  
+//   digits->Sort() ; 
+  
+//   return digits->GetEntriesFast() ; 
+// }
 //____________________________________________________________________________ 
 Int_t AliPHOSGetter::ReadTreeD()
 {
index b765fc1251af2b719975e8f5bb57e823dffb27f9..aeb715ed34843a67993aaefe4825f689adfb3bf3 100644 (file)
@@ -20,6 +20,8 @@
 #include "TObject.h"  
 class TParticle ;
 class TTree ; 
+class TGraph ; 
+class TF1 ; 
 
 // --- Standard library ---
 
@@ -221,6 +223,7 @@ private:
   Bool_t OpenESDFile() ;
   void ReadPrimaries(void) ;
 
+  void FitRaw(Bool_t lowGainFlag, TGraph * gLowGain, TGraph * gHighGain, TF1* signalF, Int_t & amp, Double_t & time) ; 
 
 private: