]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGJE/EMCALJetTasks/Tracks/AliEMCalTriggerEventCounterAnalysisComponent.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGJE / EMCALJetTasks / Tracks / AliEMCalTriggerEventCounterAnalysisComponent.cxx
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 /*
16  * Analysis component counting events for different trigger classes. Task needs
17  * to be grouped with a global event selection
18  *
19  *   Author: Markus Fasel
20  */
21 #include <map>
22 #include <string>
23
24 #include "AliVEvent.h"
25 #include "AliVVertex.h"
26
27 #include "AliEMCalTriggerAnaTriggerDecision.h"
28 #include "AliEMCalTriggerBinningComponent.h"
29 #include "AliEMCalTriggerEventData.h"
30 #include "AliEMCalHistoContainer.h"
31 #include "AliEMCalTriggerEventCounterAnalysisComponent.h"
32
33 ClassImp(EMCalTriggerPtAnalysis::AliEMCalTriggerEventCounterAnalysisComponent)
34
35 namespace EMCalTriggerPtAnalysis {
36
37 //______________________________________________________________________________
38 AliEMCalTriggerEventCounterAnalysisComponent::AliEMCalTriggerEventCounterAnalysisComponent():
39   AliEMCalTriggerTracksAnalysisComponent(),
40   fUsePatches(kFALSE)
41 {
42   /*
43    * Default (I/O) constructor, not to be used
44    */
45 }
46
47 //______________________________________________________________________________
48 AliEMCalTriggerEventCounterAnalysisComponent::AliEMCalTriggerEventCounterAnalysisComponent(const char *name):
49   AliEMCalTriggerTracksAnalysisComponent(name),
50   fUsePatches(kFALSE)
51 {
52   /*
53    * Main constructor
54    */
55 }
56
57 //______________________________________________________________________________
58 void AliEMCalTriggerEventCounterAnalysisComponent::CreateHistos() {
59   /*
60    * Create event counter histograms
61    */
62   AliEMCalTriggerTracksAnalysisComponent::CreateHistos();
63
64   // Create trigger definitions
65   std::map<std::string, std::string> triggerCombinations;
66   const char *triggernames[11] = {"MinBias", "EMCJHigh", "EMCJLow", "EMCGHigh",
67       "EMCGLow", "EMCHighBoth", "EMCHighGammaOnly", "EMCHighJetOnly",
68       "EMCLowBoth", "EMCLowGammaOnly", "EMCLowJetOnly"};
69   // Define names and titles for different triggers in the histogram container
70   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[0], "min. bias events"));
71   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[1], "jet-triggered events (high threshold)"));
72   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[2], "jet-triggered events (low threshold)"));
73   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[3], "gamma-triggered events (high threshold)"));
74   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[4], "gamma-triggered events (low threshold)"));
75   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[5], "jet and gamma triggered events (high threshold)"));
76   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[6], "exclusively gamma-triggered events (high threshold)"));
77   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[7], "exclusively jet-triggered events (high threshold)"));
78   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[8], "jet and gamma triggered events (low threshold)"));
79   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[9], "exclusively gamma-triggered events (low threshold)"));
80   triggerCombinations.insert(std::pair<std::string,std::string>(triggernames[10], "exclusively-triggered events (low threshold)"));
81
82   AliEMCalTriggerBinningDimension *vertexbinning = fBinning->GetBinning("zvertex");
83
84   for(std::map<std::string,std::string>::iterator it = triggerCombinations.begin(); it != triggerCombinations.end(); ++it){
85     const std::string name = it->first, &title = it->second;
86     // Create event-based histogram
87     fHistos->CreateTH1(Form("hEventHist%s", name.c_str()), Form("Event-based data for %s events; pileup rejection; z_{V} (cm)", title.c_str()), vertexbinning->GetNumberOfBins(), vertexbinning->GetBinLimits());
88   }
89
90   // Make correlation histogram for different trigger classes
91   const TAxis *triggeraxis[5]; memset(triggeraxis, 0, sizeof(const TAxis *) * 5);
92   const char *binlabels[2] = {"OFF", "ON"};
93   TAxis mytrgaxis[5];
94   for(int itrg = 0; itrg < 5; ++itrg){
95     DefineAxis(mytrgaxis[itrg], triggernames[itrg], triggernames[itrg], 2, -0.5, 1.5, binlabels);
96     triggeraxis[itrg] = mytrgaxis+itrg;
97   }
98   fHistos->CreateTHnSparse("hEventTriggers", "Trigger type per event", 5, triggeraxis);
99 }
100
101 //______________________________________________________________________________
102 void AliEMCalTriggerEventCounterAnalysisComponent::Process(const AliEMCalTriggerEventData* const data) {
103   /*
104    * Do event counting
105    */
106   if(!fTriggerDecision) return;
107
108   double vz = data->GetRecEvent()->GetPrimaryVertex()->GetZ();
109   double triggerCorrelation[5]; memset(triggerCorrelation, 0, sizeof(double) * 5);
110
111   if(fTriggerDecision->IsMinBias()){
112     triggerCorrelation[0] = 1.;
113     fHistos->FillTH1("hEventHistMinBias", vz);
114   }
115   if(fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCJHigh, fUsePatches)){
116     triggerCorrelation[2] = 1.;
117     fHistos->FillTH1("hEventHistEMCJHigh", vz);
118     // Check whether also the gamma high-threshold trigger fired
119     if(fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCGHigh, fUsePatches)){
120       fHistos->FillTH1("hEventHistEMCHighBoth", vz);
121     } else {
122       fHistos->FillTH1("hEventHistEMCHighJetOnly", vz);
123     }
124   }
125   if(fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCJLow, fUsePatches)){
126     triggerCorrelation[1] = 1.;
127     fHistos->FillTH1("hEventHistEMCJLow", vz);
128     // Check whether also the gamma high-threshold trigger fired
129     if(fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCGLow, fUsePatches)){
130       fHistos->FillTH1("hEventHistEMCLowBoth", vz);
131     } else {
132       fHistos->FillTH1("hEventHistEMCLowJetOnly", vz);
133     }
134   }
135   if(fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCGHigh, fUsePatches)){
136     triggerCorrelation[3] = 1.;
137     fHistos->FillTH1("hEventHistEMCGHigh", vz);
138     if(!fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCJHigh, fUsePatches))
139       fHistos->FillTH1("hEventHistEMCHighGammaOnly", vz);
140   }
141   if(fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCGLow, fUsePatches)){
142     triggerCorrelation[4] = 1.;
143     fHistos->FillTH1("hEventHistEMCGLow", vz);
144     if(!fTriggerDecision->IsTriggered(AliEMCalTriggerAnaTriggerDecision::kTAEMCJLow, fUsePatches))
145       fHistos->FillTH1("hEventHistEMCLowGammaOnly", vz);
146   }
147
148   fHistos->FillTHnSparse("hEventTriggers", triggerCorrelation);
149 }
150
151 //______________________________________________________________________________
152 void AliEMCalTriggerEventCounterAnalysisComponent::DefineAxis(TAxis& axis, const char* name,
153     const char* title, int nbins, double min, double max,
154     const char** labels) const {
155   /*
156    * Define an axis with number of bins from min to max
157    *
158    * @param axis: Axis to be defined
159    * @param name: Name of the axis
160    * @param title: Title of the axis
161    * @param nbins: Number of bins
162    * @param min: lower limit of the axis
163    * @param max: upper limit of the axis
164    * @param labels (@optional): array of bin labels
165    */
166   axis.Set(nbins, min, max);
167   axis.SetName(name);
168   axis.SetTitle(title);
169   if(labels){
170     for(int ib = 1; ib <= axis.GetNbins(); ++ib)
171       axis.SetBinLabel(ib, labels[ib-1]);
172   }
173 }
174
175 } /* namespace EMCalTriggerPtAnalysis */