]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG/CaloTrackCorrBase/AliCaloTrackReader.cxx
make sure EMCal trigger-cluster matching is done when event is EMCal triggered, in...
[u/mrichter/AliRoot.git] / PWG / CaloTrackCorrBase / AliCaloTrackReader.cxx
index e1cd4743cf7776cc41ecef599962173c4663ede1..b0fed7c03edc6dc2cf4ad0ec2ca7cc157e0b88e3 100755 (executable)
@@ -60,6 +60,7 @@
 #include "AliCaloTrackReader.h"
 // ---- Jets ----
 #include "AliAODJet.h"
+#include "AliAODJetEventBackground.h"
 
 ClassImp(AliCaloTrackReader)
 
@@ -130,6 +131,8 @@ fEventPlaneMethod(""),
 fAcceptOnlyHIJINGLabels(0),  fNMCProducedMin(0), fNMCProducedMax(0),
 fFillInputNonStandardJetBranch(kFALSE),
 fNonStandardJets(new TClonesArray("AliAODJet",100)),fInputNonStandardJetBranchName("jets"),
+fFillInputBackgroundJetBranch(kFALSE), 
+fBackgroundJets(0x0),fInputBackgroundJetBranchName("jets"),
 fAcceptEventsWithBit(0),     fRejectEventsWithBit(0)
 {
   //Ctor
@@ -192,7 +195,8 @@ AliCaloTrackReader::~AliCaloTrackReader()
     else               fNonStandardJets->Delete() ;
     delete fNonStandardJets ;
   }
-  
+  delete fBackgroundJets ;
+
   fRejectEventsWithBit.Reset();
   fAcceptEventsWithBit.Reset();
   
@@ -730,7 +734,10 @@ void AliCaloTrackReader::InitParameters()
   fInputNonStandardJetBranchName = "jets";
   fFillInputNonStandardJetBranch = kFALSE;
   if(!fNonStandardJets) fNonStandardJets = new TClonesArray("AliAODJet",100);
-  
+  fInputBackgroundJetBranchName = "jets";
+  fFillInputBackgroundJetBranch = kFALSE; 
+  if(!fBackgroundJets) fBackgroundJets = new AliAODJetEventBackground();
+
 }
 
 //___________________________________________________________________
@@ -1160,34 +1167,43 @@ Bool_t AliCaloTrackReader::FillInputEvent(Int_t iEntry, const char * /*curFileNa
 
   
   //----------------------------------------------------------------------
-  // Do not count events that where likely triggered by an exotic cluster
+  // Do not count events that were likely triggered by an exotic cluster
   // or out BC cluster
   //----------------------------------------------------------------------
   
-       // Set a bit with the event kind, MB, L0, L1 ...
-       SetEventTriggerBit();
+  // Set a bit with the event kind, MB, L0, L1 ...
+  SetEventTriggerBit();
        
-  //Get Patches that triggered
-  TArrayI patches = GetTriggerPatches(fTriggerPatchTimeWindow[0],fTriggerPatchTimeWindow[1]);
-  
-  MatchTriggerCluster(patches);
-  
-  // If requested, remove badly triggeed events, but only when the EMCal trigger bit is set
-  if(fRemoveBadTriggerEvents  && (IsEventEMCALL1() || IsEventEMCALL0()))
+  if( IsEventEMCALL1() || IsEventEMCALL0()  )
   {
-    if(fDebug > 0)  printf("AliCaloTrackReader::FillInputEvent() - ACCEPT triggered event? \n exotic? %d - bad cell %d - bad Max cell %d - BC %d  - Matched %d\n",
-           fIsExoticEvent,fIsBadCellEvent, fIsBadMaxCellEvent, fTriggerClusterBC,fIsTriggerMatch);
-    if     (fIsExoticEvent)         return kFALSE;
-    else if(fIsBadCellEvent)        return kFALSE;
-    else if(fRemoveUnMatchedTriggers && !fIsTriggerMatch) return kFALSE ;
-    else if(fTriggerClusterBC != 0) return kFALSE;
-    //printf("\t *** YES\n");
-  }
-  
-  patches.Reset();
-  
-  if(fDebug > 0) printf("AliCaloTrackReader::FillInputEvent()-Pass EMCal triggered event rejection \n");
+    //Get Patches that triggered
+    TArrayI patches = GetTriggerPatches(fTriggerPatchTimeWindow[0],fTriggerPatchTimeWindow[1]);
+    
+    MatchTriggerCluster(patches);
+
+    patches.Reset();
 
+    // If requested, remove badly triggeed events, but only when the EMCal trigger bit is set
+    if(fRemoveBadTriggerEvents)
+    {
+      if(fDebug > 0)
+        printf("AliCaloTrackReader::FillInputEvent() - ACCEPT triggered event? \n exotic? %d - bad cell %d - bad Max cell %d - BC %d  - Matched %d\n",
+                              fIsExoticEvent,fIsBadCellEvent, fIsBadMaxCellEvent, fTriggerClusterBC,fIsTriggerMatch);
+      if     (fIsExoticEvent)         return kFALSE;
+      else if(fIsBadCellEvent)        return kFALSE;
+      else if(fRemoveUnMatchedTriggers && !fIsTriggerMatch) return kFALSE ;
+      else if(fTriggerClusterBC != 0) return kFALSE;
+      if(fDebug > 0) printf("\t *** YES\n");
+    }
+    
+    if(fDebug > 0)
+      printf("AliCaloTrackReader::FillInputEvent()-Pass EMCal triggered event rejection \n");
+  }
+  else if(!IsEventEMCALL1Jet() && !IsEventMinimumBias() && !IsEventCentral() && !IsEventSemiCentral())
+  {
+    // In case there was a EG1&&EG2, it is selected as EG1, reject when requesting EG2
+    return kFALSE;
+  }
   
   // Get the main vertex BC, in case not available
   // it is calculated in FillCTS checking the BC of tracks
@@ -1233,6 +1249,9 @@ Bool_t AliCaloTrackReader::FillInputEvent(Int_t iEntry, const char * /*curFileNa
   //one specified jet branch
   if(fFillInputNonStandardJetBranch)
     FillInputNonStandardJets();
+  if(fFillInputBackgroundJetBranch)
+    FillInputBackgroundJets();
+
   
   return kTRUE ;
 }
@@ -2034,6 +2053,44 @@ void AliCaloTrackReader::FillInputNonStandardJets()
   
 }
 
+//_________________________________________________
+void AliCaloTrackReader::FillInputBackgroundJets()
+{
+  //
+  //fill array with Background jets
+  //
+  // Adam T. Matyja
+  
+  if(fDebug > 2 ) printf("AliCaloTrackReader::FillInputBackgroundJets()\n");
+  //
+  //check if branch name is given
+  if(!fInputBackgroundJetBranchName.Length())
+  {
+    Printf("No background jet branch name specified. Specify among existing ones.");
+    fInputEvent->Print();
+    abort();
+  }
+  
+  fBackgroundJets = (AliAODJetEventBackground*)(fInputEvent->FindListObject(fInputBackgroundJetBranchName.Data()));
+  
+  if(!fBackgroundJets)
+  {
+    //check if jet branch exist; exit if not
+    Printf("%s:%d no reconstructed jet array with name %s in AOD", (char*)__FILE__,__LINE__,fInputBackgroundJetBranchName.Data());
+    fInputEvent->Print();
+    abort();
+  }
+  else
+  {
+    if(fDebug > 1){
+      printf("AliCaloTrackReader::FillInputBackgroundJets()\n");
+      fBackgroundJets->Print("");
+    }
+  }
+  
+}
+
+
 //________________________________________________
 Bool_t AliCaloTrackReader::CheckForPrimaryVertex()
 {
@@ -2084,6 +2141,7 @@ TArrayI AliCaloTrackReader::GetTriggerPatches(Int_t tmin, Int_t tmax )
   // get object pointer
   AliVCaloTrigger *caloTrigger = GetInputEvent()->GetCaloTrigger( "EMCAL" );
   
+  //printf("CaloTrigger Entries %d\n",caloTrigger->GetEntries() );
   // class is not empty
   if( caloTrigger->GetEntries() > 0 )
   {
@@ -2110,7 +2168,7 @@ TArrayI AliCaloTrackReader::GetTriggerPatches(Int_t tmin, Int_t tmax )
         // get timing array
         caloTrigger->GetL0Times( trigtimes );
         
-        //printf("trigger time window %d - %d\n",fTriggerPatchTimeWindow[0],fTriggerPatchTimeWindow[1]);
+        //printf("Get L0 patch : n times %d - trigger time window %d - %d\n",ntimes, tmin,tmax);
         // go through the array
         for( i = 0; i < ntimes; i++ )
         {
@@ -2120,7 +2178,7 @@ TArrayI AliCaloTrackReader::GetTriggerPatches(Int_t tmin, Int_t tmax )
             //printf("Accepted trigger time %d \n",trigtimes[i]);
             //if(nTrig > 99) continue;
             GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(globCol,globRow, absId);
-            //printf("pass the time cut globCol %d, globRow %d absId %d\n",globCol,globRow, absIDTrig[nTrig]);
+            //printf("pass the time cut globCol %d, globRow %d absId %d\n",globCol,globRow, absId);
             patches.Set(nPatch+1);
             patches.AddAt(absId,nPatch++);
           }
@@ -2136,6 +2194,8 @@ TArrayI AliCaloTrackReader::GetTriggerPatches(Int_t tmin, Int_t tmax )
         
         if(!isEGA && !isEJE) continue;
         
+        //printf("**** Get L1 Patch: EGA %d, EJE %d\n",isEGA,isEJE);
+        
         Int_t patchsize = -1;
         if      (isEGA) patchsize =  2;
         else if (isEJE) patchsize = 16;
@@ -2146,7 +2206,7 @@ TArrayI AliCaloTrackReader::GetTriggerPatches(Int_t tmin, Int_t tmax )
           for(Int_t icol=0; icol < patchsize; icol++)
           {
             GetCaloUtils()->GetEMCALGeometry()->GetAbsFastORIndexFromPositionInEMCAL(globCol+icol,globRow+irow, absId);
-            //printf("pass the time cut globCol %d, globRow %d absId %d\n",globCol,globRow, absIDTrig[nTrig]);
+            //printf("pass the time cut globCol %d, globRow %d absId %d\n",globCol,globRow, absId);
             patches.Set(nPatch+1);
             patches.AddAt(absId,nPatch++);
           }
@@ -2187,6 +2247,8 @@ void  AliCaloTrackReader::MatchTriggerCluster(TArrayI patches)
     return;
   }
   
+  //printf("***** Try to match trigger to cluster %d **** L0 %d, L1 %d\n",fTriggerPatchClusterMatch,IsEventEMCALL0(),IsEventEMCALL1());
+  
   //Recover the list of clusters
   TClonesArray * clusterList = 0;
   if      (fInputEvent->FindListObject(fEMCALClustersListName))
@@ -2226,8 +2288,10 @@ void  AliCaloTrackReader::MatchTriggerCluster(TArrayI patches)
   Float_t minE = fTriggerEventThreshold / 2.;
   // This method is not really suitable for JET trigger
   // but in case, reduce the energy cut since we do not trigger on high energy particle
-  if(IsEventEMCALL1()) minE = 1;
-       
+  if(IsEventEMCALL1Jet() || minE < 1) minE = 1;
+
+  //printf("Min trigger Energy threshold %f\n",minE);
+  
   // Loop on the clusters, check if there is any that falls into one of the patches
   for (Int_t iclus =  0; iclus <  nclusters; iclus++)
   {
@@ -2464,6 +2528,7 @@ void  AliCaloTrackReader::MatchTriggerCluster(TArrayI patches)
     patchOpen.Reset();
     
   }// No trigger match found
+  //printf("Trigger BC %d, Id %d, Index %d\n",fTriggerClusterBC,fTriggerClusterId,fTriggerClusterIndex);
   
 }
 
@@ -2601,7 +2666,8 @@ void AliCaloTrackReader::ResetLists()
   fV0Mul[0] = 0;   fV0Mul[1] = 0;
   
   if(fNonStandardJets) fNonStandardJets -> Clear("C");
-  
+  fBackgroundJets->Reset();
+
 }
 
 //___________________________________________
@@ -2618,7 +2684,8 @@ void AliCaloTrackReader::SetEventTriggerBit()
   fEventTrigEMCALL1Jet1   = kFALSE;
   fEventTrigEMCALL1Jet2   = kFALSE;
   
-  if(fDebug > 0) printf("AliCaloTrackReader::SetEventTriggerBit() - Select trigger mask bit %d - Trigger Event %s\n",fEventTriggerMask,GetFiredTriggerClasses().Data());
+  if(fDebug > 0)
+    printf("AliCaloTrackReader::SetEventTriggerBit() - Select trigger mask bit %d - Trigger Event %s\n",fEventTriggerMask,GetFiredTriggerClasses().Data());
   
   if(fEventTriggerMask <=0 )// in case no mask set
   {
@@ -2680,11 +2747,12 @@ void AliCaloTrackReader::SetEventTriggerBit()
          // EMC L1 Gamma
          if     ( fEventTriggerMask & AliVEvent::kEMCEGA      )
     {
+      //printf("EGA trigger bit\n");
       if     (GetFiredTriggerClasses().Contains("EG1" ) ||
               GetFiredTriggerClasses().Contains("EGA" )    )
       {
                                fEventTrigEMCALL1Gamma1 = kTRUE;
-                               if( GetFiredTriggerClasses().Contains("EG1" ) && !fFiredTriggerClassName.Contains("EG1") ) fEventTrigEMCALL1Gamma1 = kFALSE;
+        if( GetFiredTriggerClasses().Contains("EG1" ) && !fFiredTriggerClassName.Contains("EG1") ) fEventTrigEMCALL1Gamma1 = kFALSE;
       }
       else if(GetFiredTriggerClasses().Contains("EG2" ))
       {
@@ -2695,6 +2763,7 @@ void AliCaloTrackReader::SetEventTriggerBit()
          // EMC L1 Jet
          else if( fEventTriggerMask & AliVEvent::kEMCEJE      )
     {
+      //printf("EJE trigger bit\n");
       if     (GetFiredTriggerClasses().Contains("EJ1" )||
               GetFiredTriggerClasses().Contains("EJE" )  )
       {
@@ -2711,16 +2780,19 @@ void AliCaloTrackReader::SetEventTriggerBit()
          else if((fEventTriggerMask & AliVEvent::kEMC7) ||
             (fEventTriggerMask & AliVEvent::kEMC1)       )
     {
+      //printf("L0 trigger bit\n");
            fEventTrigEMCALL0 = kTRUE;
     }
          // Min Bias Pb-Pb
          else if( fEventTriggerMask & AliVEvent::kCentral     )
     {
+      //printf("MB semi central trigger bit\n");
            fEventTrigSemiCentral = kTRUE;
     }
          // Min Bias Pb-Pb
          else if( fEventTriggerMask & AliVEvent::kSemiCentral )
     {
+      //printf("MB central trigger bit\n");
            fEventTrigCentral = kTRUE;
     }
          // Min Bias pp, PbPb, pPb
@@ -2729,6 +2801,7 @@ void AliCaloTrackReader::SetEventTriggerBit()
             (fEventTriggerMask & AliVEvent::kINT8) ||
             (fEventTriggerMask & AliVEvent::kAnyINT) )
     {
+      //printf("MB trigger bit\n");
            fEventTrigMinBias = kTRUE;
     }
        }
@@ -2763,8 +2836,8 @@ void AliCaloTrackReader::SetEventTriggerBit()
           fBitEGA = 6;
           fBitEJE = 8;
         }
-           }  else printf("AliCaloTrackReader()::Init() - Streamer info for trigger class not available, bit not changed\n");
-    } else printf("AliCaloTrackReader::Init() -  Streamer list not available!, bit not changed\n");
+           }  else printf("AliCaloTrackReader()::SetEventTriggerBit() - Streamer info for trigger class not available, bit not changed\n");
+    } else printf("AliCaloTrackReader::SetEventTriggerBit() -  Streamer list not available!, bit not changed\n");
     
   } // set once the EJE, EGA trigger bit