]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSTrigger.cxx
Bug fix: corrected file name (Levente)
[u/mrichter/AliRoot.git] / PHOS / AliPHOSTrigger.cxx
index 7cc3e501481c8a9c5c59cd54db81065e5209c38c..ba2bbc4fb58d66ce34c8e150a223105e8a8f2815 100644 (file)
 
 
 // --- ROOT system ---
+#include "TMath.h"
 
 // --- ALIROOT system ---
+#include "AliConfig.h"
 #include "AliPHOS.h"
 #include "AliPHOSTrigger.h" 
 #include "AliPHOSGeometry.h"
-#include "AliPHOSGetter.h" 
+#include "AliPHOSDigit.h" 
+#include "AliPHOSLoader.h" 
 #include "AliPHOSPulseGenerator.h" 
 #include "AliTriggerInput.h"
 
@@ -121,6 +124,18 @@ AliPHOSTrigger::AliPHOSTrigger(const AliPHOSTrigger & trig) :
   // cpy ctor
 }
 
+//_________________________________________________________________________
+AliPHOSTrigger::~AliPHOSTrigger() 
+{
+  // dtor
+  
+  if(fADCValuesHighnxn)delete [] fADCValuesHighnxn;
+  if(fADCValuesLownxn)delete [] fADCValuesLownxn;
+  if(fADCValuesHigh2x2)delete []  fADCValuesHigh2x2;
+  if(fADCValuesLow2x2)delete [] fADCValuesLow2x2;
+  // fDigitsList is now ours...
+}
+
 //_________________________________________________________________________
 AliPHOSTrigger & AliPHOSTrigger::operator = (const AliPHOSTrigger &)
 {
@@ -134,11 +149,13 @@ void AliPHOSTrigger::CreateInputs()
    
    // Do not create inputs again!!
    if( fInputs.GetEntriesFast() > 0 ) return;
+
+   TString name = GetName();
    
-   fInputs.AddLast( new AliTriggerInput( "PHOS_L0",       "PHOS L0", 0x02 ) );
-   fInputs.AddLast( new AliTriggerInput( "PHOS_JetHPt_L1","PHOS Jet High Pt L1", 0x04 ) );
-   fInputs.AddLast( new AliTriggerInput( "PHOS_JetMPt_L1","PHOS Jet Medium Pt L1", 0x08 ) );
-   fInputs.AddLast( new AliTriggerInput( "PHOS_JetLPt_L1","PHOS Jet Low Pt L1", 0x016 ) );
+   fInputs.AddLast( new AliTriggerInput( "PHOS_L0",       name, 0 ) );
+   fInputs.AddLast( new AliTriggerInput( "PHOS_JetHPt_L1",name, 1 ) );
+   fInputs.AddLast( new AliTriggerInput( "PHOS_JetMPt_L1",name, 1 ) );
+   fInputs.AddLast( new AliTriggerInput( "PHOS_JetLPt_L1",name, 1 ) );
  
 }
 
@@ -316,7 +333,7 @@ Bool_t AliPHOSTrigger::IsPatchIsolated(Int_t iPatchType, const TClonesArray * am
 
   AliDebug(2,Form("Type %d, Maximum amplitude %f, patch+isol square %f",iPatchType, maxamp, amp));
 
-  if(amp < maxamp){
+  if(TMath::Nint(amp*1E5) < TMath::Nint(maxamp*1E5)){
     AliError(Form("Bad sum: Type %d, Maximum amplitude %f, patch+isol square %f",iPatchType, maxamp, amp));
     return kFALSE;
   }
@@ -533,8 +550,8 @@ void AliPHOSTrigger::SetTriggers(const TClonesArray * ampmatrix, const Int_t iMo
   Float_t maxtimeR2 = -1 ;
   Float_t maxtimeRn = -1 ;
   // Create a shaper pulse object
-  AliPHOSPulseGenerator *pulse = new AliPHOSPulseGenerator();
-  Int_t nTimeBins = pulse->GetRawFormatTimeBins() ;
+  AliPHOSPulseGenerator pulse ;
+  Int_t nTimeBins = pulse.GetRawFormatTimeBins() ;
  
   //Set max 2x2 amplitude and select L0 trigger
   if(max2[0] > f2x2MaxAmp ){
@@ -555,13 +572,14 @@ void AliPHOSTrigger::SetTriggers(const TClonesArray * ampmatrix, const Int_t iMo
     //Transform digit amplitude in Raw Samples
     if (fADCValuesLow2x2 == 0) {
       fADCValuesLow2x2  = new Int_t[nTimeBins];
-      fADCValuesHigh2x2 = new Int_t[nTimeBins];
     }
+    if(!fADCValuesHigh2x2) fADCValuesHigh2x2 = new Int_t[nTimeBins];
+
     
-    pulse->SetAmplitude(f2x2MaxAmp);
-    pulse->SetTZero(maxtimeR2);
-    pulse->MakeSamples();
-    pulse->GetSamples(fADCValuesHigh2x2, fADCValuesLow2x2) ; 
+    pulse.SetAmplitude(f2x2MaxAmp);
+    pulse.SetTZero(maxtimeR2);
+    pulse.MakeSamples();
+    pulse.GetSamples(fADCValuesHigh2x2, fADCValuesLow2x2) ; 
     
     //Set Trigger Inputs, compare ADC time bins until threshold is attained
     //Set L0
@@ -595,10 +613,10 @@ void AliPHOSTrigger::SetTriggers(const TClonesArray * ampmatrix, const Int_t iMo
       fADCValuesLownxn  = new Int_t[nTimeBins];
     }
 
-    pulse->SetAmplitude(maxtimeRn);
-    pulse->SetTZero(fnxnMaxAmp);
-    pulse->MakeSamples();
-    pulse->GetSamples(fADCValuesHighnxn, fADCValuesLownxn) ;
+    pulse.SetAmplitude(fnxnMaxAmp);
+    pulse.SetTZero(maxtimeRn);
+    pulse.MakeSamples();
+    pulse.GetSamples(fADCValuesHighnxn, fADCValuesLownxn) ;
     
     //Set Trigger Inputs, compare ADC time bins until threshold is attained
     //SetL1 Low
@@ -626,17 +644,26 @@ void AliPHOSTrigger::SetTriggers(const TClonesArray * ampmatrix, const Int_t iMo
 }
 
 //____________________________________________________________________________
-void AliPHOSTrigger::Trigger() 
+void AliPHOSTrigger::Trigger(TClonesArray *digits
 {
-
   //Main Method to select triggers.
-  AliRunLoader *rl = gAlice->GetRunLoader();
-  //Getter
-  AliPHOSGetter * gime = AliPHOSGetter::Instance( rl->GetFileName() ) ;
-  //AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
 
-  //Get Geometry
-  const AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ;
+  fDigitsList = digits;
+  DoIt() ; 
+}
+
+//____________________________________________________________________________
+void AliPHOSTrigger::DoIt()
+{
+  // does the trigger job
+
+  AliRunLoader* rl = AliRunLoader::GetRunLoader() ;
+  AliPHOSLoader * phosLoader = dynamic_cast<AliPHOSLoader*>(rl->GetLoader("PHOSLoader"));
+  
+  // Get PHOS Geometry object
+  AliPHOSGeometry *geom;
+  if (!(geom = AliPHOSGeometry::GetInstance())) 
+        geom = AliPHOSGeometry::GetInstance("IHEP","");
    
   //Define parameters
   Int_t nModules     = geom->GetNModules();
@@ -649,7 +676,7 @@ void AliPHOSTrigger::Trigger()
 
   //Take the digits list if simulation
   if(fSimulation)
-    fDigitsList = gime->Digits() ;
+    fDigitsList = phosLoader->Digits() ;
   
   if(!fDigitsList)
     AliFatal("Digits not found !") ;
@@ -673,7 +700,7 @@ void AliPHOSTrigger::Trigger()
     //Set the trigger
     if(fIsolateInModule)
       SetTriggers(ampmods,imod,ampmax2,ampmaxn) ;
-    if(!fIsolateInModule)
+    else
       SetTriggers(amptrus,imod,ampmax2,ampmaxn) ;
   }