AliPhysics  ff0b22e (ff0b22e)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 #include <THistManager.h>
22 
23 #include "AliEMCALTriggerPatchInfo.h"
27 
31 
32 namespace EMCalTriggerPtAnalysis {
33 
38 AliEMCalTriggerPatchAnalysisComponent::AliEMCalTriggerPatchAnalysisComponent() :
40  fSwapOnlineThresholds(kFALSE),
41  fSwapOfflineThresholds(kFALSE),
42  fWithEventSelection(kFALSE)
43 {
44 }
45 
55  fSwapOnlineThresholds(kFALSE),
56  fSwapOfflineThresholds(kFALSE),
57  fWithEventSelection(withEventSelection)
58 {
59 }
60 
82 
84  *phibinning = fBinning->GetBinning("phi");
85  const TAxis *patchaxes[6] = {
86  DefineAxis("energy", 100, 0., 100),
87  DefineAxis("energyRough", 100, 0., 100),
88  DefineAxis("amplitude", 2100, 0., 2100.), // limit for the moment
89  DefineAxis("eta", etabinning),
90  DefineAxis("phi", phibinning),
91  DefineAxis("isMain", 2, -0.5, 1.5)
92  };
93 
94  const TAxis *ampaxes[5] = {
95  DefineAxis("amplitudeOnline", 2000, 0., 2100.),
96  DefineAxis("amplitudeOffline", 2000, 0., 2100.),
97  DefineAxis("eta", etabinning),
98  DefineAxis("phi", phibinning),
99  DefineAxis("isMain", 2, -0.5, 1.5)
100  };
101 
102  // Create trigger definitions
103  std::map<std::string, std::string> triggerCombinations;
104  GetAllTriggerNamesAndTitles(triggerCombinations);
105 
106  std::string patchnames[] = {"Level0", "JetHigh", "JetLow", "GammaHigh", "GammaLow"};
107  std::string triggermodes[] = {"Online", "Offline"};
108  for(std::string * triggerpatch = patchnames; triggerpatch < patchnames + sizeof(patchnames)/sizeof(std::string); ++triggerpatch){
109  for(std::string *triggermode = triggermodes; triggermode < triggermodes + sizeof(triggermodes)/sizeof(std::string); ++triggermode){
111  for(std::map<std::string, std::string>::iterator trgiter = triggerCombinations.begin(); trgiter != triggerCombinations.end(); ++trgiter){
112  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());
113  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");
114  }
115  } else {
116  if((!strcmp(triggermode->c_str(), "Offline")) && (!strcmp(triggerpatch->c_str(), "Level0"))) continue; // Don't process L0 in case of offline
117  printf("Adding patch for trigger %s in case of %s\n", triggerpatch->c_str(), triggermode->c_str());
118  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");
119  if(strcmp(triggerpatch->c_str(), "Level0")){
120  // Add histogram for online-offline of amplitudes
121  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");
122  }
123  }
124  }
125  }
126 }
127 
139  AliEMCALTriggerPatchInfo *triggerpatch(NULL);
140  TIter patchIter(data->GetTriggerPatchContainer());
141  while((triggerpatch = dynamic_cast<AliEMCALTriggerPatchInfo *>(patchIter()))){
143  std::vector<std::string> triggernames;
144  GetMachingTriggerNames(triggernames);
145  for(std::vector<std::string>::iterator trgclassit = triggernames.begin(); trgclassit != triggernames.end(); ++trgclassit){
146  FillStandardMonitoring(triggerpatch, trgclassit->c_str());
147  }
148  } else {
149  FillStandardMonitoring(triggerpatch);
150  }
151  }
152 }
153 
160 void AliEMCalTriggerPatchAnalysisComponent::FillStandardMonitoring(const AliEMCALTriggerPatchInfo* const patch, TString eventType) {
161  std::vector<TString> triggerclasses;
162  triggerclasses.push_back("JetHigh");
163  triggerclasses.push_back("JetLow");
164  triggerclasses.push_back("GammaHigh");
165  triggerclasses.push_back("GammaLow");
166  triggerclasses.push_back("Level0");
168  for(std::vector<TString>::iterator trgclassit = triggerclasses.begin(); trgclassit != triggerclasses.end(); ++trgclassit){
169  if(mypatchhandler.IsPatchOfType(patch, *trgclassit)){
170  std::stringstream infohistname;
171  infohistname << "PatchInfo" << trgclassit->Data() << (patch->IsOfflineSimple() ? "Offline" : "Online");
172  if(eventType.Length()) infohistname << eventType.Data();
173  FillTriggerInfoHistogram(infohistname.str().c_str(), patch);
174  if((!eventType.Length()) &&(*trgclassit != "Level0")){
175  std::stringstream amphistname;
176  amphistname << "PatchAmplitude" << trgclassit->Data() << (patch->IsOfflineSimple() ? "Offline" : "Online");
177  FillAmplitudeHistogram(amphistname.str().c_str(), patch);
178  }
179  }
180  }
181 }
182 
188 void AliEMCalTriggerPatchAnalysisComponent::FillTriggerInfoHistogram(TString histo, const AliEMCALTriggerPatchInfo* const patch) {
189  bool isMain = patch->IsOfflineSimple() ? patch->IsMainTriggerSimple() : patch->IsMainTrigger();
190  double triggerpatchinfo[6] = {patch->GetPatchE(),patch->GetADCAmpGeVRough(),
191  static_cast<double>(patch->IsOfflineSimple() ? patch->GetADCOfflineAmp() : patch->GetADCAmp()), patch->GetEtaGeo(),
192  patch->GetPhiGeo(), isMain ? 1. : 0.};
193  fHistos->FillTHnSparse(histo.Data(), triggerpatchinfo);
194 }
195 
196 
202 void AliEMCalTriggerPatchAnalysisComponent::FillAmplitudeHistogram(TString histo, const AliEMCALTriggerPatchInfo* const patch) {
203  bool isMain = patch->IsOfflineSimple() ? patch->IsMainTriggerSimple() : patch->IsMainTrigger();
204  double amplitudeinfo[5] = {(double)patch->GetADCAmp(), (double)patch->GetADCOfflineAmp(), (double)patch->GetEtaGeo(), (double)patch->GetPhiGeo(), isMain ? 1. : 0.};
205  fHistos->FillTHnSparse(histo.Data(), amplitudeinfo);
206 }
207 
208 //
209 // Implementation of patch handlers and patch handler factory
210 //
211 
219  Bool_t result = false;
220  if(patch->IsOfflineSimple()){
221  result = ((!fPatchSwapThresholdsOffline && patch->IsJetLowSimple()) || (fPatchSwapThresholdsOffline && patch->IsJetHighSimple()));
222  } else {
223  result = ((!fPatchSwapThresholdsOnline && patch->IsJetLow()) || (fPatchSwapThresholdsOnline && patch->IsJetHigh()));
224  }
225  return result;
226 }
227 
235  Bool_t result = false;
236  if(patch->IsOfflineSimple()){
237  result = ((!fPatchSwapThresholdsOffline && patch->IsJetHighSimple()) || (fPatchSwapThresholdsOffline && patch->IsJetLowSimple()));
238  } else {
239  result = ((!fPatchSwapThresholdsOnline && patch->IsJetHigh()) || (fPatchSwapThresholdsOnline && patch->IsJetLow()));
240  }
241  return result;
242 }
243 
251  Bool_t result = false;
252  if(patch->IsOfflineSimple()){
253  result = ((!fPatchSwapThresholdsOffline && patch->IsGammaLowSimple()) || (fPatchSwapThresholdsOffline && patch->IsGammaHighSimple()));
254  } else {
255  result = ((!fPatchSwapThresholdsOnline && patch->IsGammaLow()) || (fPatchSwapThresholdsOnline && patch->IsGammaHigh()));
256  }
257  return result;
258 }
259 
267  Bool_t result = false;
268  if(patch->IsOfflineSimple()){
269  result = ((!fPatchSwapThresholdsOffline && patch->IsGammaHighSimple()) || (fPatchSwapThresholdsOffline && patch->IsGammaLowSimple()));
270  } else {
271  result = ((!fPatchSwapThresholdsOnline && patch->IsGammaHigh()) || (fPatchSwapThresholdsOnline && patch->IsGammaLow()));
272  }
273  return result;
274 }
275 
283  if(patch->IsLevel0()) return true;
284  return false;
285 }
286 
294  const AliEMCALTriggerPatchInfo* const patch, TString patchtype) const {
295  Bool_t result = false;
296  std::unique_ptr<AliEmcalTriggerPatchHandler> myhandler;
297  if (patchtype == "JetHigh") myhandler = std::unique_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerGammaHigh(fSwapThresholdsOnline, fSwapThresholdsOffline));
298  else if (patchtype == "JetLow") myhandler = std::unique_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerGammaLow(fSwapThresholdsOnline, fSwapThresholdsOffline));
299  else if (patchtype == "GammaHigh") myhandler = std::unique_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerJetHigh(fSwapThresholdsOnline, fSwapThresholdsOffline));
300  else if (patchtype == "GammaLow") myhandler = std::unique_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerJetLow(fSwapThresholdsOnline, fSwapThresholdsOffline));
301  else if (patchtype == "Level0") myhandler = std::unique_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerLevel0(fSwapThresholdsOnline, fSwapThresholdsOffline));
302  if(!myhandler.get()) return false;
303  return myhandler->IsOfType(patch);
304 }
305 
306 } /* namespace EMCalTriggerPtAnalysis */
307 
void GetMachingTriggerNames(std::vector< std::string > &triggernames) const
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., Option_t *opt="")
void FillTriggerInfoHistogram(TString histo, const AliEMCALTriggerPatchInfo *const patch)
void GetAllTriggerNamesAndTitles(std::map< std::string, std::string > &triggers) const
THistManager * fHistos
Histogram container of the analysis component.
void FillStandardMonitoring(const AliEMCALTriggerPatchInfo *const patch, TString eventclass="")
AliEMCalTriggerBinningDimension * GetBinning(const char *name) const
Base class for analysis components in the analysis of EMCAL-triggered events.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Bool_t fSwapOfflineThresholds
Swap trigger thresholds for offline patches.
Analysis component for EMCAL trigger patches.
Simple event container within the high- track analysis.
void FillAmplitudeHistogram(TString histo, const AliEMCALTriggerPatchInfo *const patch)
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.
Event Data used in exchange to the different analysis components.