AliPhysics  cda3415 (cda3415)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalTriggerOfflineSelection.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2016, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 #include <algorithm>
16 #include <iostream>
17 #include <vector>
18 
19 #include <TClonesArray.h>
20 #include <TH2.h>
21 #include <TRandom.h>
22 
23 #include "AliEMCALTriggerConstants.h"
24 #include "AliEMCALTriggerPatchInfo.h"
26 #include "AliLog.h"
27 
31 
32 namespace EMCalTriggerPtAnalysis {
33 
34 const TString AliEmcalTriggerOfflineSelection::fgkTriggerNames[AliEmcalTriggerOfflineSelection::kTrgn] = {
35  "EMC7", "EG1", "EG2", "EJ1", "EJ2", "DMC7", "DG1", "DG2", "DJ1", "DJ2"
36 };
37 
38 AliEmcalTriggerOfflineSelection::AliEmcalTriggerOfflineSelection():
39  TObject(),
40  fEnergyDefinition(kFEEEnergy)
41 {
42  for(int itrg = 0; itrg < kTrgn; itrg++) fOfflineEnergyThreshold[itrg] = 100000.; // unimplemented triggers get very high threshold assinged, so that the result is automatically false
43  memset(fAcceptanceMaps, 0, sizeof(TH2 *) * kTrgn);
44 }
45 
47  for(int itrg = 0; itrg < kTrgn; itrg++){
48  if(fAcceptanceMaps[itrg]) delete fAcceptanceMaps[itrg];
49  }
50 }
51 
52 Bool_t AliEmcalTriggerOfflineSelection::IsOfflineSelected(EmcalTriggerClass trgcls, const TClonesArray * const triggerpatches) const {
53  if(fOfflineEnergyThreshold[trgcls] < 0) return true;
54  AliDebugStream(1) << "Applying offline threshold " << fOfflineEnergyThreshold[trgcls] << " for trigger class " << GetTriggerName(trgcls) << std::endl;
55  bool isSingleShower = IsSingleShower(trgcls), isDCAL = IsDCAL(trgcls);
56  int nfound = 0;
57  AliEMCALTriggerPatchInfo *patch = NULL;
58  std::vector<double> patchefficiencies;
59  for(auto patchIter : *triggerpatches){
60  patch = static_cast<AliEMCALTriggerPatchInfo *>(patchIter);
61  if(!patch->IsOfflineSimple()) continue;
62  if((isDCAL && !patch->IsDCalPHOS()) || (!isDCAL && patch->IsDCalPHOS())) continue; // reject patches in opposite detector
63  if(isSingleShower){
64  if(!patch->IsGammaLowSimple()) continue;
65  } else {
66  if(!patch->IsJetLowSimple()) continue;
67  }
68  double energy;
69  switch(fEnergyDefinition){
70  case kFEEEnergy: energy = patch->GetPatchE(); break;
71  case kFEETransverseEnergy: energy = patch->GetPatchET(); break;
72  case kFEEADC: energy = patch->GetADCOfflineAmp(); break;
73  case kFEETransverseADC: energy = patch->GetPatchET() / EMCALTrigger::kEMCL1ADCtoGeV ; break;
74  };
75  if(energy > fOfflineEnergyThreshold[trgcls]){
76  AliDebugStream(2) << GetTriggerName(trgcls) << " patch above threshold (" << patch->GetPatchE() << " | " << fOfflineEnergyThreshold[trgcls] << ")" << std::endl;
77  if(fAcceptanceMaps[trgcls]){
78  // Handle azimuthal inefficiencies of the trigger observed online:
79  // For each patch provide an efficiency. Once all patches in the event
80  // is determined, only the patch with the maximum efficiency is chosen.
81  // The event is selected in this case if the sample value is below the
82  // efficiency for the chosen patch.
83  double peff = fAcceptanceMaps[trgcls]->GetBinContent(patch->GetColStart(), patch->GetRowStart());
84  patchefficiencies.push_back(peff);
85  AliDebugStream(2) << "Spatial Efficiency " << peff
86  << " for trigger patch at position (" << patch->GetColStart()
87  << "," << patch->GetRowStart() << ")" << std::endl;
88  } else{
89  patchefficiencies.push_back(1.);
90  }
91  }
92  }
93  if(patchefficiencies.size()){
94  std::sort(patchefficiencies.begin(), patchefficiencies.end(), std::greater<double>());
95  double sample = gRandom->Uniform(0., 1.);
96  if(sample < patchefficiencies[0]){
97  AliDebugStream(1) << "Event selected for trigger class " << GetTriggerName(trgcls) << ", " << nfound << " good patch(es) found" << std::endl;
98  return true;
99  }
100  }
101  return false;
102 }
103 
105  return ((cls == kTrgEG1) || (cls == kTrgEG2) || (cls == kTrgEL0) || (cls == kTrgDG1) || (cls == kTrgDG2) || (cls == kTrgDL0));
106 
107 }
108 
110  return ((cls == kTrgDL0) || (cls == kTrgDG1) || (cls == kTrgDG2) || (cls == kTrgDJ1) || (cls == kTrgDJ2));
111 }
112 
113 } /* namespace EMCalTriggerPtAnalysis */
static const TString & GetTriggerName(EmcalTriggerClass cls)
Helper class selecting events on the presence of a trigger patch for the given type above threshold...
TRandom * gRandom
Double_t fOfflineEnergyThreshold[kTrgn]
Thresholds applied on offline energy.
EmcalTriggerClass
Definition of the various supported trigger types.
energy
Bool_t IsOfflineSelected(EmcalTriggerClass trgcls, const TClonesArray *const triggerpatches) const
Definition: External.C:220
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
EmcalEnergyDefinition_t fEnergyDefinition
Define type of energy to be use for the patch selection.
const TH2 * fAcceptanceMaps[kTrgn]
! Online acceptance distribution
bool Bool_t
Definition: External.C:53