AliPhysics  vAN-20150425 (2dcf1b0)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliEMCalTriggerPatchAnalysisComponent.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2014, 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 <map>
16 #include <memory>
17 #include <string>
18 #include <sstream>
19 #include <vector>
20 #include <TClonesArray.h>
21 
22 #include "AliEmcalTriggerPatchInfo.h"
26 
30 
31 namespace EMCalTriggerPtAnalysis {
32 
37 AliEMCalTriggerPatchAnalysisComponent::AliEMCalTriggerPatchAnalysisComponent() :
39  fSwapOnlineThresholds(kFALSE),
40  fSwapOfflineThresholds(kFALSE),
41  fWithEventSelection(kFALSE),
42  fTriggerMethod(kTriggerString)
43 {
44 }
45 
55  fSwapOnlineThresholds(kFALSE),
56  fSwapOfflineThresholds(kFALSE),
57  fWithEventSelection(withEventSelection),
58  fTriggerMethod(kTriggerString)
59 {
60 }
61 
83 
85  *phibinning = fBinning->GetBinning("phi");
86  const TAxis *patchaxes[6] = {
87  DefineAxis("energy", 100, 0., 100),
88  DefineAxis("energyRough", 100, 0., 100),
89  DefineAxis("amplitude", 5000, 0., 5000.), // limit for the moment
90  DefineAxis("eta", etabinning),
91  DefineAxis("phi", phibinning),
92  DefineAxis("isMain", 2, -0.5, 1.5)
93  };
94 
95  const TAxis *ampaxes[5] = {
96  DefineAxis("amplitudeOnline", 5000, 0., 5000.),
97  DefineAxis("amplitudeOffline", 5000, 0., 5000.),
98  DefineAxis("eta", etabinning),
99  DefineAxis("phi", phibinning),
100  DefineAxis("isMain", 2, -0.5, 1.5)
101  };
102 
103  // Create trigger definitions
104  std::map<std::string, std::string> triggerCombinations;
105  const char *triggernames[11] = {"MinBias", "EMCJHigh", "EMCJLow", "EMCGHigh",
106  "EMCGLow", "EMCHighBoth", "EMCHighGammaOnly", "EMCHighJetOnly",
107  "EMCLowBoth", "EMCLowGammaOnly", "EMCLowJetOnly"};
108  // Define names and titles for different triggers in the histogram container
109  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[0], "min. bias events"));
110  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[1], "jet-triggered events (high threshold)"));
111  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[2], "jet-triggered events (low threshold)"));
112  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[3], "gamma-triggered events (high threshold)"));
113  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[4], "gamma-triggered events (low threshold)"));
114  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[5], "jet and gamma triggered events (high threshold)"));
115  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[6], "exclusively gamma-triggered events (high threshold)"));
116  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[7], "exclusively jet-triggered events (high threshold)"));
117  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[8], "jet and gamma triggered events (low threshold)"));
118  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[9], "exclusively gamma-triggered events (low threshold)"));
119  triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[10], "exclusively-triggered events (low threshold)"));
120 
121  std::string patchnames[] = {"Level0", "JetHigh", "JetLow", "GammaHigh", "GammaLow"};
122  std::string triggermodes[] = {"Online", "Offline"};
123  for(std::string * triggerpatch = patchnames; triggerpatch < patchnames + sizeof(patchnames)/sizeof(std::string); ++triggerpatch){
124  for(std::string *triggermode = triggermodes; triggermode < triggermodes + sizeof(triggermodes)/sizeof(std::string); ++triggermode){
126  for(std::map<std::string, std::string>::iterator trgiter = triggerCombinations.begin(); trgiter != triggerCombinations.end(); ++trgiter){
127  printf("Adding patch for trigger %s in case of %s for event selection %s\n", triggerpatch->c_str(), triggermode->c_str(), trgiter->second.c_str());
128  fHistos->CreateTHnSparse(Form("PatchInfo%s%s%s", triggerpatch->c_str(), triggermode->c_str(), trgiter->first.c_str()), Form("Patch energy for %s %s trigger patches", triggerpatch->c_str(), triggermode->c_str()), 6, patchaxes, "s");
129  }
130  } else {
131  if((!strcmp(triggermode->c_str(), "Offline")) && (!strcmp(triggerpatch->c_str(), "Level0"))) continue; // Don't process L0 in case of offline
132  printf("Adding patch for trigger %s in case of %s\n", triggerpatch->c_str(), triggermode->c_str());
133  fHistos->CreateTHnSparse(Form("PatchInfo%s%s", triggerpatch->c_str(), triggermode->c_str()), Form("Patch energy for %s %s trigger patches", triggerpatch->c_str(), triggermode->c_str()), 6, patchaxes, "s");
134  if(strcmp(triggerpatch->c_str(), "Level0")){
135  // Add histogram for online-offline of amplitudes
136  fHistos->CreateTHnSparse(Form("PatchAmplitude%s%s", triggerpatch->c_str(), triggermode->c_str()), Form("Patch amplitudes for %s %s trigger patches", triggerpatch->c_str(), triggermode->c_str()), 5, ampaxes, "s");
137  }
138  }
139  }
140  }
141 }
142 
154  AliEmcalTriggerPatchInfo *triggerpatch(NULL);
155  TIter patchIter(data->GetTriggerPatchContainer());
156  while((triggerpatch = dynamic_cast<AliEmcalTriggerPatchInfo *>(patchIter()))){
158  std::vector<std::string> triggernames;
159  GetMachingTriggerNames(triggernames, fTriggerMethod);
160  for(std::vector<std::string>::iterator trgclassit = triggernames.begin(); trgclassit != triggernames.end(); ++trgclassit){
161  FillStandardMonitoring(triggerpatch, trgclassit->c_str());
162  }
163  } else {
164  FillStandardMonitoring(triggerpatch);
165  }
166  }
167 }
168 
175 void AliEMCalTriggerPatchAnalysisComponent::FillStandardMonitoring(const AliEmcalTriggerPatchInfo* const patch, TString eventType) {
176  std::vector<TString> triggerclasses;
177  triggerclasses.push_back("JetHigh");
178  triggerclasses.push_back("JetLow");
179  triggerclasses.push_back("GammaHigh");
180  triggerclasses.push_back("GammaLow");
181  triggerclasses.push_back("Level0");
183  for(std::vector<TString>::iterator trgclassit = triggerclasses.begin(); trgclassit != triggerclasses.end(); ++trgclassit){
184  if(mypatchhandler.IsPatchOfType(patch, *trgclassit)){
185  std::stringstream infohistname;
186  infohistname << "PatchInfo" << trgclassit->Data() << (patch->IsOfflineSimple() ? "Offline" : "Online");
187  if(eventType.Length()) infohistname << eventType.Data();
188  FillTriggerInfoHistogram(infohistname.str().c_str(), patch);
189  if((!eventType.Length()) &&(*trgclassit != "Level0")){
190  std::stringstream amphistname;
191  amphistname << "PatchAmplitude" << trgclassit->Data() << (patch->IsOfflineSimple() ? "Offline" : "Online");
192  FillAmplitudeHistogram(amphistname.str().c_str(), patch);
193  }
194  }
195  }
196 }
197 
203 void AliEMCalTriggerPatchAnalysisComponent::FillTriggerInfoHistogram(TString histo, const AliEmcalTriggerPatchInfo* const patch) {
204  bool isMain = patch->IsOfflineSimple() ? patch->IsMainTriggerSimple() : patch->IsMainTrigger();
205  double triggerpatchinfo[6] = {patch->GetPatchE(),patch->GetADCAmpGeVRough(),
206  static_cast<double>(patch->IsOfflineSimple() ? patch->GetADCOfflineAmp() : patch->GetADCAmp()), patch->GetEtaGeo(),
207  patch->GetPhiGeo(), isMain ? 1. : 0.};
208  fHistos->FillTHnSparse(histo.Data(), triggerpatchinfo);
209 }
210 
211 
217 void AliEMCalTriggerPatchAnalysisComponent::FillAmplitudeHistogram(TString histo, const AliEmcalTriggerPatchInfo* const patch) {
218  bool isMain = patch->IsOfflineSimple() ? patch->IsMainTriggerSimple() : patch->IsMainTrigger();
219  double amplitudeinfo[5] = {(double)patch->GetADCAmp(), (double)patch->GetADCOfflineAmp(), (double)patch->GetEtaGeo(), (double)patch->GetPhiGeo(), isMain ? 1. : 0.};
220  fHistos->FillTHnSparse(histo.Data(), amplitudeinfo);
221 }
222 
223 //
224 // Implementation of patch handlers and patch handler factory
225 //
226 
234  Bool_t result = false;
235  if(patch->IsOfflineSimple()){
236  result = ((!fPatchSwapThresholdsOffline && patch->IsJetLowSimple()) || (fPatchSwapThresholdsOffline && patch->IsJetHighSimple()));
237  } else {
238  result = ((!fPatchSwapThresholdsOnline && patch->IsJetLow()) || (fPatchSwapThresholdsOnline && patch->IsJetHigh()));
239  }
240  return result;
241 }
242 
250  Bool_t result = false;
251  if(patch->IsOfflineSimple()){
252  result = ((!fPatchSwapThresholdsOffline && patch->IsJetHighSimple()) || (fPatchSwapThresholdsOffline && patch->IsJetLowSimple()));
253  } else {
254  result = ((!fPatchSwapThresholdsOnline && patch->IsJetHigh()) || (fPatchSwapThresholdsOnline && patch->IsJetLow()));
255  }
256  return result;
257 }
258 
266  Bool_t result = false;
267  if(patch->IsOfflineSimple()){
268  result = ((!fPatchSwapThresholdsOffline && patch->IsGammaLowSimple()) || (fPatchSwapThresholdsOffline && patch->IsGammaHighSimple()));
269  } else {
270  result = ((!fPatchSwapThresholdsOnline && patch->IsGammaLow()) || (fPatchSwapThresholdsOnline && patch->IsGammaHigh()));
271  }
272  return result;
273 }
274 
282  Bool_t result = false;
283  if(patch->IsOfflineSimple()){
284  result = ((!fPatchSwapThresholdsOffline && patch->IsGammaHighSimple()) || (fPatchSwapThresholdsOffline && patch->IsGammaLowSimple()));
285  } else {
286  result = ((!fPatchSwapThresholdsOnline && patch->IsGammaHigh()) || (fPatchSwapThresholdsOnline && patch->IsGammaLow()));
287  }
288  return result;
289 }
290 
298  if(patch->IsLevel0()) return true;
299  return false;
300 }
301 
309  const AliEmcalTriggerPatchInfo* const patch, TString patchtype) const {
310  Bool_t result = false;
311  std::auto_ptr<AliEmcalTriggerPatchHandler> myhandler(NULL);
312  if (patchtype == "JetHigh") myhandler = std::auto_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerGammaHigh(fSwapThresholdsOnline, fSwapThresholdsOffline));
313  else if (patchtype == "JetLow") myhandler = std::auto_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerGammaLow(fSwapThresholdsOnline, fSwapThresholdsOffline));
314  else if (patchtype == "GammaHigh") myhandler = std::auto_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerJetHigh(fSwapThresholdsOnline, fSwapThresholdsOffline));
315  else if (patchtype == "GammaLow") myhandler = std::auto_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerJetLow(fSwapThresholdsOnline, fSwapThresholdsOffline));
316  else if (patchtype == "Level0") myhandler = std::auto_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerLevel0(fSwapThresholdsOnline, fSwapThresholdsOffline));
317  if(!myhandler.get()) return false;
318  return myhandler->IsOfType(patch);
319 }
320 
321 } /* namespace EMCalTriggerPtAnalysis */
322 
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
void FillAmplitudeHistogram(TString histo, const AliEmcalTriggerPatchInfo *const patch)
void GetMachingTriggerNames(std::vector< std::string > &triggernames, ETriggerMethod_t usePatches)
Bool_t fWithEventSelection
Define whether patches are analysed with event selection.
TAxis * DefineAxis(const char *name, const AliEMCalTriggerBinningDimension *binning)
void FillTHnSparse(const char *name, const double *x, double weight=1.)
void CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
AliEMCalHistoContainer * fHistos
Histogram container of the analysis component.
AliEMCalTriggerBinningDimension * GetBinning(const char *name) const
ETriggerMethod_t fTriggerMethod
Trigger method used for event selection.
void FillTriggerInfoHistogram(TString histo, const AliEmcalTriggerPatchInfo *const patch)
Base class for analysis components in the analysis of EMCAL-triggered events.
Declaration of the classes AliEMCalTriggerBinningComponent and AliEMCalTriggerBinningDimension.
void FillStandardMonitoring(const AliEmcalTriggerPatchInfo *const patch, TString eventclass="")
Bool_t fSwapOfflineThresholds
Swap trigger thresholds for offline patches.
Analysis component for EMCAL trigger patches.
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.