AliPhysics  a34469b (a34469b)
 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 "AliEMCALTriggerPatchInfo.h"
25 #include "AliLog.h"
26 
30 
31 namespace EMCalTriggerPtAnalysis {
32 
33 const TString AliEmcalTriggerOfflineSelection::fgkTriggerNames[AliEmcalTriggerOfflineSelection::kTrgn] = {
34  "EMC7", "EG1", "EG2", "EJ1", "EJ2", "DMC7", "DG1", "DG2", "DJ1", "DJ2"
35 };
36 
37 AliEmcalTriggerOfflineSelection::AliEmcalTriggerOfflineSelection() {
38  for(int itrg = 0; itrg < kTrgn; itrg++) fOfflineEnergyThreshold[itrg] = 100000.; // unimplemented triggers get very high threshold assinged, so that the result is automatically false
39  memset(fAcceptanceMaps, 0, sizeof(TH2 *) * kTrgn);
40 }
41 
42 AliEmcalTriggerOfflineSelection::~AliEmcalTriggerOfflineSelection(){
43  for(int itrg = 0; itrg < kTrgn; itrg++){
44  if(fAcceptanceMaps[itrg]) delete fAcceptanceMaps[itrg];
45  }
46 }
47 
48 Bool_t AliEmcalTriggerOfflineSelection::IsOfflineSelected(EmcalTriggerClass trgcls, const TClonesArray * const triggerpatches) const {
49  if(fOfflineEnergyThreshold[trgcls] < 0) return true;
50  AliDebugStream(1) << "Applying offline threshold " << fOfflineEnergyThreshold[trgcls] << " for trigger class " << GetTriggerName(trgcls) << std::endl;
51  bool isSingleShower = IsSingleShower(trgcls), isDCAL = IsDCAL(trgcls);
52  int nfound = 0;
53  AliEMCALTriggerPatchInfo *patch = NULL;
54  std::vector<double> patchefficiencies;
55  for(auto patchIter : *triggerpatches){
56  patch = static_cast<AliEMCALTriggerPatchInfo *>(patchIter);
57  if(!patch->IsOfflineSimple()) continue;
58  if((isDCAL && !patch->IsDCalPHOS()) || (!isDCAL && patch->IsDCalPHOS())) continue; // reject patches in opposite detector
59  if(isSingleShower){
60  if(!patch->IsGammaLowSimple()) continue;
61  } else {
62  if(!patch->IsJetLowSimple()) continue;
63  }
64  if(patch->GetPatchE() > fOfflineEnergyThreshold[trgcls]){
65  AliDebugStream(2) << GetTriggerName(trgcls) << " patch above threshold (" << patch->GetPatchE() << " | " << fOfflineEnergyThreshold[trgcls] << ")" << std::endl;
66  if(fAcceptanceMaps[trgcls]){
67  // Handle azimuthal inefficiencies of the trigger observed online:
68  // For each patch provide an efficiency. Once all patches in the event
69  // is determined, only the patch with the maximum efficiency is chosen.
70  // The event is selected in this case if the sample value is below the
71  // efficiency for the chosen patch.
72  double peff = fAcceptanceMaps[trgcls]->GetBinContent(patch->GetColStart(), patch->GetRowStart());
73  patchefficiencies.push_back(peff);
74  AliDebugStream(2) << "Spatial Efficiency " << peff
75  << " for trigger patch at position (" << patch->GetColStart()
76  << "," << patch->GetRowStart() << ")" << std::endl;
77  } else{
78  patchefficiencies.push_back(1.);
79  }
80  }
81  }
82  if(patchefficiencies.size()){
83  std::sort(patchefficiencies.begin(), patchefficiencies.end(), std::greater<double>());
84  double sample = gRandom->Uniform(0., 1.);
85  if(sample < patchefficiencies[0]){
86  AliDebugStream(1) << "Event selected for trigger class " << GetTriggerName(trgcls) << ", " << nfound << " good patch(es) found" << std::endl;
87  return true;
88  }
89  }
90  return false;
91 }
92 
93 Bool_t AliEmcalTriggerOfflineSelection::IsSingleShower(EmcalTriggerClass cls){
94  return ((cls == kTrgEG1) || (cls == kTrgEG2) || (cls == kTrgEL0) || (cls == kTrgDG1) || (cls == kTrgDG2) || (cls == kTrgDL0));
95 
96 }
97 
98 Bool_t AliEmcalTriggerOfflineSelection::IsDCAL(EmcalTriggerClass cls){
99  return ((cls == kTrgDL0) || (cls == kTrgDG1) || (cls == kTrgDG2) || (cls == kTrgDJ1) || (cls == kTrgDJ2));
100 }
101 
102 } /* namespace EMCalTriggerPtAnalysis */
Helper class selecting events on the presence of a trigger patch for the given type above threshold...
TRandom * gRandom
EmcalTriggerClass
Definition of the various supported trigger types.
Definition: External.C:220
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
bool Bool_t
Definition: External.C:53