]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PHOS/AliPHOSTrigger.cxx
replace hardcoded calls to geometry transformation matrices with calls to the TGeoMan...
[u/mrichter/AliRoot.git] / PHOS / AliPHOSTrigger.cxx
index 470db21bb95f55af620888b3dd10fb3bac10232b..5e5d5395d32fea9a600352583ef069d449db7da0 100644 (file)
@@ -121,6 +121,17 @@ 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 &)
 {
@@ -316,7 +327,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 +544,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 ){
@@ -553,13 +564,16 @@ void AliPHOSTrigger::SetTriggers(const TClonesArray * ampmatrix, const Int_t iMo
       fIs2x2Isol =  IsPatchIsolated(0, ampmatrix, iMod, mtru2,  f2x2MaxAmp,  static_cast<Int_t>(max2[1]), static_cast<Int_t>(max2[2])) ;
 
     //Transform digit amplitude in Raw Samples
-    fADCValuesLow2x2  = new Int_t[nTimeBins];
-    fADCValuesHigh2x2 = new Int_t[nTimeBins];
+    if (fADCValuesLow2x2 == 0) {
+      fADCValuesLow2x2  = 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
@@ -588,13 +602,15 @@ void AliPHOSTrigger::SetTriggers(const TClonesArray * ampmatrix, const Int_t iMo
       fIsnxnIsol =  IsPatchIsolated(1, ampmatrix, iMod, mtrun,  fnxnMaxAmp,  static_cast<Int_t>(maxn[1]), static_cast<Int_t>(maxn[2])) ;
 
     //Transform digit amplitude in Raw Samples
-    fADCValuesHighnxn = new Int_t[nTimeBins];
-    fADCValuesLownxn  = new Int_t[nTimeBins];
+    if (fADCValuesHighnxn == 0) {
+      fADCValuesHighnxn = new Int_t[nTimeBins];
+      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,11 +642,29 @@ void AliPHOSTrigger::Trigger()
 {
 
   //Main Method to select triggers.
-  AliRunLoader *rl = gAlice->GetRunLoader();
-  //Getter
-  AliPHOSGetter * gime = AliPHOSGetter::Instance( rl->GetFileName() ) ;
-  //AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
 
+  AliRunLoader * rl = AliRunLoader::GetRunLoader(); 
+  TString fileName = rl->GetFileName() ; 
+  DoIt(fileName.Data()) ; 
+}
+
+//____________________________________________________________________________
+void AliPHOSTrigger::Trigger(const char * fileName) 
+{
+
+  //Main Method to select triggers.
+
+  
+  DoIt(fileName) ; 
+}
+
+//____________________________________________________________________________
+void AliPHOSTrigger::DoIt(const char * fileName) 
+{
+  // does the trigger job
+
+  AliPHOSGetter * gime = AliPHOSGetter::Instance( fileName ) ;
+  
   //Get Geometry
   const AliPHOSGeometry * geom = AliPHOSGetter::Instance()->PHOSGeometry() ;
    
@@ -673,6 +707,12 @@ void AliPHOSTrigger::Trigger()
       SetTriggers(amptrus,imod,ampmax2,ampmaxn) ;
   }
 
+  amptrus->Delete();
+  delete amptrus; amptrus=0;
+  ampmods->Delete();
+  delete ampmods; ampmods=0;
+  timeRtrus->Delete();
+  delete timeRtrus; timeRtrus=0;
   //Print();
 
 }