AliPhysics  1168478 (1168478)
 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 #include <TLinearBinning.h>
23 
24 #include "AliEMCALTriggerPatchInfo.h"
28 
32 
33 namespace EMCalTriggerPtAnalysis {
34 
39 AliEMCalTriggerPatchAnalysisComponent::AliEMCalTriggerPatchAnalysisComponent() :
41  fSwapOnlineThresholds(kFALSE),
42  fSwapOfflineThresholds(kFALSE),
43  fWithEventSelection(kFALSE)
44 {
45 }
46 
56  fSwapOnlineThresholds(kFALSE),
57  fSwapOfflineThresholds(kFALSE),
58  fWithEventSelection(withEventSelection)
59 {
60 }
61 
83 
84  const TBinning *etabinning = fBinning->GetBinning("eta"),
85  *phibinning = fBinning->GetBinning("phi");
86  const TAxis *patchaxes[6] = {
87  DefineAxis("energy", TLinearBinning(100, 0., 100)),
88  DefineAxis("energyRough", TLinearBinning(100, 0., 100)),
89  DefineAxis("amplitude", TLinearBinning(2100, 0., 2100.)), // limit for the moment
90  DefineAxis("eta", *etabinning),
91  DefineAxis("phi", *phibinning),
92  DefineAxis("isMain", TLinearBinning(2, -0.5, 1.5))
93  };
94 
95  const TAxis *ampaxes[5] = {
96  DefineAxis("amplitudeOnline", TLinearBinning(2000, 0., 2100.)),
97  DefineAxis("amplitudeOffline", TLinearBinning(2000, 0., 2100.)),
98  DefineAxis("eta", *etabinning),
99  DefineAxis("phi", *phibinning),
100  DefineAxis("isMain", TLinearBinning(2, -0.5, 1.5))
101  };
102 
103  // Create trigger definitions
104  std::map<std::string, std::string> triggerCombinations;
105  GetAllTriggerNamesAndTitles(triggerCombinations);
106 
107  std::string patchnames[] = {"Level0", "JetHigh", "JetLow", "GammaHigh", "GammaLow"};
108  std::string triggermodes[] = {"Online", "Offline"};
109  for(std::string * triggerpatch = patchnames; triggerpatch < patchnames + sizeof(patchnames)/sizeof(std::string); ++triggerpatch){
110  for(std::string *triggermode = triggermodes; triggermode < triggermodes + sizeof(triggermodes)/sizeof(std::string); ++triggermode){
112  for(std::map<std::string, std::string>::iterator trgiter = triggerCombinations.begin(); trgiter != triggerCombinations.end(); ++trgiter){
113  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());
114  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");
115  }
116  } else {
117  if((!strcmp(triggermode->c_str(), "Offline")) && (!strcmp(triggerpatch->c_str(), "Level0"))) continue; // Don't process L0 in case of offline
118  printf("Adding patch for trigger %s in case of %s\n", triggerpatch->c_str(), triggermode->c_str());
119  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");
120  if(strcmp(triggerpatch->c_str(), "Level0")){
121  // Add histogram for online-offline of amplitudes
122  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");
123  }
124  }
125  }
126  }
127 }
128 
140  AliEMCALTriggerPatchInfo *triggerpatch(NULL);
141  TIter patchIter(data->GetTriggerPatchContainer());
142  while((triggerpatch = dynamic_cast<AliEMCALTriggerPatchInfo *>(patchIter()))){
144  std::vector<std::string> triggernames;
145  GetMachingTriggerNames(triggernames);
146  for(std::vector<std::string>::iterator trgclassit = triggernames.begin(); trgclassit != triggernames.end(); ++trgclassit){
147  FillStandardMonitoring(triggerpatch, trgclassit->c_str());
148  }
149  } else {
150  FillStandardMonitoring(triggerpatch);
151  }
152  }
153 }
154 
161 void AliEMCalTriggerPatchAnalysisComponent::FillStandardMonitoring(const AliEMCALTriggerPatchInfo* const patch, TString eventType) {
162  std::vector<TString> triggerclasses;
163  triggerclasses.push_back("JetHigh");
164  triggerclasses.push_back("JetLow");
165  triggerclasses.push_back("GammaHigh");
166  triggerclasses.push_back("GammaLow");
167  triggerclasses.push_back("Level0");
169  for(std::vector<TString>::iterator trgclassit = triggerclasses.begin(); trgclassit != triggerclasses.end(); ++trgclassit){
170  if(mypatchhandler.IsPatchOfType(patch, *trgclassit)){
171  std::stringstream infohistname;
172  infohistname << "PatchInfo" << trgclassit->Data() << (patch->IsOfflineSimple() ? "Offline" : "Online");
173  if(eventType.Length()) infohistname << eventType.Data();
174  FillTriggerInfoHistogram(infohistname.str().c_str(), patch);
175  if((!eventType.Length()) &&(*trgclassit != "Level0")){
176  std::stringstream amphistname;
177  amphistname << "PatchAmplitude" << trgclassit->Data() << (patch->IsOfflineSimple() ? "Offline" : "Online");
178  FillAmplitudeHistogram(amphistname.str().c_str(), patch);
179  }
180  }
181  }
182 }
183 
189 void AliEMCalTriggerPatchAnalysisComponent::FillTriggerInfoHistogram(TString histo, const AliEMCALTriggerPatchInfo* const patch) {
190  bool isMain = patch->IsOfflineSimple() ? patch->IsMainTriggerSimple() : patch->IsMainTrigger();
191  double triggerpatchinfo[6] = {patch->GetPatchE(),patch->GetADCAmpGeVRough(),
192  static_cast<double>(patch->IsOfflineSimple() ? patch->GetADCOfflineAmp() : patch->GetADCAmp()), patch->GetEtaGeo(),
193  patch->GetPhiGeo(), isMain ? 1. : 0.};
194  fHistos->FillTHnSparse(histo.Data(), triggerpatchinfo);
195 }
196 
197 
203 void AliEMCalTriggerPatchAnalysisComponent::FillAmplitudeHistogram(TString histo, const AliEMCALTriggerPatchInfo* const patch) {
204  bool isMain = patch->IsOfflineSimple() ? patch->IsMainTriggerSimple() : patch->IsMainTrigger();
205  double amplitudeinfo[5] = {(double)patch->GetADCAmp(), (double)patch->GetADCOfflineAmp(), (double)patch->GetEtaGeo(), (double)patch->GetPhiGeo(), isMain ? 1. : 0.};
206  fHistos->FillTHnSparse(histo.Data(), amplitudeinfo);
207 }
208 
209 //
210 // Implementation of patch handlers and patch handler factory
211 //
212 
220  Bool_t result = false;
221  if(patch->IsOfflineSimple()){
222  result = ((!fPatchSwapThresholdsOffline && patch->IsJetLowSimple()) || (fPatchSwapThresholdsOffline && patch->IsJetHighSimple()));
223  } else {
224  result = ((!fPatchSwapThresholdsOnline && patch->IsJetLow()) || (fPatchSwapThresholdsOnline && patch->IsJetHigh()));
225  }
226  return result;
227 }
228 
236  Bool_t result = false;
237  if(patch->IsOfflineSimple()){
238  result = ((!fPatchSwapThresholdsOffline && patch->IsJetHighSimple()) || (fPatchSwapThresholdsOffline && patch->IsJetLowSimple()));
239  } else {
240  result = ((!fPatchSwapThresholdsOnline && patch->IsJetHigh()) || (fPatchSwapThresholdsOnline && patch->IsJetLow()));
241  }
242  return result;
243 }
244 
252  Bool_t result = false;
253  if(patch->IsOfflineSimple()){
254  result = ((!fPatchSwapThresholdsOffline && patch->IsGammaLowSimple()) || (fPatchSwapThresholdsOffline && patch->IsGammaHighSimple()));
255  } else {
256  result = ((!fPatchSwapThresholdsOnline && patch->IsGammaLow()) || (fPatchSwapThresholdsOnline && patch->IsGammaHigh()));
257  }
258  return result;
259 }
260 
268  Bool_t result = false;
269  if(patch->IsOfflineSimple()){
270  result = ((!fPatchSwapThresholdsOffline && patch->IsGammaHighSimple()) || (fPatchSwapThresholdsOffline && patch->IsGammaLowSimple()));
271  } else {
272  result = ((!fPatchSwapThresholdsOnline && patch->IsGammaHigh()) || (fPatchSwapThresholdsOnline && patch->IsGammaLow()));
273  }
274  return result;
275 }
276 
284  if(patch->IsLevel0()) return true;
285  return false;
286 }
287 
295  const AliEMCALTriggerPatchInfo* const patch, TString patchtype) const {
296  Bool_t result = false;
297  std::unique_ptr<AliEmcalTriggerPatchHandler> myhandler;
298  if (patchtype == "JetHigh") myhandler = std::unique_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerGammaHigh(fSwapThresholdsOnline, fSwapThresholdsOffline));
299  else if (patchtype == "JetLow") myhandler = std::unique_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerGammaLow(fSwapThresholdsOnline, fSwapThresholdsOffline));
300  else if (patchtype == "GammaHigh") myhandler = std::unique_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerJetHigh(fSwapThresholdsOnline, fSwapThresholdsOffline));
301  else if (patchtype == "GammaLow") myhandler = std::unique_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerJetLow(fSwapThresholdsOnline, fSwapThresholdsOffline));
302  else if (patchtype == "Level0") myhandler = std::unique_ptr<AliEmcalTriggerPatchHandler>(new AliEmcalTriggerPatchHandlerLevel0(fSwapThresholdsOnline, fSwapThresholdsOffline));
303  if(!myhandler.get()) return false;
304  return myhandler->IsOfType(patch);
305 }
306 
307 } /* namespace EMCalTriggerPtAnalysis */
Class creating a linear binning, used in the histogram manager.
void GetMachingTriggerNames(std::vector< std::string > &triggernames) const
Bool_t fWithEventSelection
Define whether patches are analysed with event selection.
Interface for binnings used by the histogram handler.
Definition: TBinning.h:21
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="")
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.
bool Bool_t
Definition: External.C:53
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="")
Create a new THnSparse within the container.
const AliEMCalTriggerBinningComponent * fBinning
Global binning handler.
Event Data used in exchange to the different analysis components.