AliPhysics  0e0bd91 (0e0bd91)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
AliAnalysisTaskTriggerRates.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, 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 #include <TString.h>
17 
18 #include "AliLog.h"
19 #include "AliCounterCollection.h"
20 #include "AliVEvent.h"
21 #include "AliESDEvent.h"
22 #include "AliVParticle.h"
23 #include "AliESDMuonTrack.h"
24 #include "AliInputEventHandler.h"
25 #include "AliCentrality.h"
26 
27 #include "AliAnalysisManager.h"
28 #include "AliAnalysisDataSlot.h"
29 #include "AliAnalysisDataContainer.h"
30 #include "AliAnalysisMuonUtility.h"
31 
33 
35 
36 //________________________________________________________________________
38 : AliAnalysisTaskSE(),
39 fTriggerCounters(0),
40 fnCent(0),
41 fDeltaDev(0),
42 fMULPattern("none"),
43 fMLLPattern("none"),
44 fMSLPattern("none"),
45 fMSHPattern("none"),
46 fPrinfCounts(kFALSE)
47 {
48  // Dummy constructor ALWAYS needed for I/O.
49 
50  InitCentralityBins();
51 
52 }
53 
54 //________________________________________________________________________
56 : AliAnalysisTaskSE(name),
57 fTriggerCounters(0),
58 fnCent(0),
59 fDeltaDev(0),
60 fMULPattern("none"),
61 fMLLPattern("none"),
62 fMSLPattern("none"),
63 fMSHPattern("none"),
64 fPrinfCounts(kFALSE)
65 {
66  // Constructor
67 
69 
70  DefineOutput(1, AliCounterCollection::Class());
71 }
72 
73 //________________________________________________________________________
75 {
76  if (!AliAnalysisManager::GetAnalysisManager()->IsProofMode()) delete fTriggerCounters;
77 }
78 
79 //________________________________________________________________________
81 {
82  // Create outputs
83 
84  TString centKeys = "any";
85  for (Int_t iCent = 0; iCent < fnCent; ++iCent) centKeys += Form("/%s", fCentBinName[iCent].Data());
86 
87  fTriggerCounters = new AliCounterCollection(GetOutputSlot(1)->GetContainer()->GetName());
88  fTriggerCounters->AddRubric("run", 1000);
89  fTriggerCounters->AddRubric("ps", "yes/no");
90  fTriggerCounters->AddRubric("cent", centKeys.Data());
91  fTriggerCounters->AddRubric("mul", "yes/no");
92  fTriggerCounters->AddRubric("mll", "yes/no");
93  fTriggerCounters->AddRubric("msl", "yes/no");
94  fTriggerCounters->AddRubric("msh", "yes/no");
95  fTriggerCounters->AddRubric("muloff", "yes/no");
96  fTriggerCounters->AddRubric("mlloff", "yes/no");
97  fTriggerCounters->AddRubric("msloff", "yes/no");
98  fTriggerCounters->AddRubric("mshoff", "yes/no");
99  fTriggerCounters->Init();
100 
101  PostData(1, fTriggerCounters);
102 }
103 
104 //________________________________________________________________________
106 {
107  // One event processing
108 
109  AliVEvent *evt = InputEvent();
110  if (!dynamic_cast<AliESDEvent*>(evt)) {
111  AliFatal("can only run on ESDs");
112  return;
113  }
114 
115  // select physics events
116  if (evt->GetEventType() != 7) return;
117 
118  // Get Physics selection
119  TString psKey = (fInputHandler->IsEventSelected()) ? "ps:yes" : "ps:no";
120 
121  // Get Centrality
122  Float_t cent = evt->GetCentrality()->GetCentralityPercentile("V0M");
123  TString centKey = "";
124  for (Int_t iCent = 0; iCent < fnCent; iCent++) {
125  if (cent > fCentBinRange[iCent][0] && cent <= fCentBinRange[iCent][1]) {
126  centKey = Form("cent:%s",fCentBinName[iCent].Data());
127  break;
128  }
129  }
130 
131  // Get trigger class
132  TString trigger = evt->GetFiredTriggerClasses();
133  TString onlineMULKey = (trigger.Contains(fMULPattern.Data())) ? "mul:yes" : "mul:no";
134  TString onlineMLLKey = (trigger.Contains(fMLLPattern.Data())) ? "mll:yes" : "mll:no";
135  TString onlineMSLKey = (trigger.Contains(fMSLPattern.Data())) ? "msl:yes" : "msl:no";
136  TString onlineMSHKey = (trigger.Contains(fMSHPattern.Data())) ? "msh:yes" : "msh:no";
137 
138  // Get trigger class from trigger tracks
139  TString offlineMULKey = "muloff:no";
140  TString offlineMLLKey = "mlloff:no";
141  TString offlineMSLKey = "msloff:no";
142  TString offlineMSHKey = "mshoff:no";
143  Int_t ntracks = AliAnalysisMuonUtility::GetNTracks(evt);
144  Int_t *loCircuit = new Int_t[ntracks];
145  Int_t nTrgTracks = 0;
146  for (Int_t i = 0; i < ntracks; ++i) {
147 
148  AliVParticle *tracki = AliAnalysisMuonUtility::GetTrack(i, evt);
149  if (!AliAnalysisMuonUtility::MatchLpt(tracki)) continue;
150 
151  // make sure this track is not already accounted for
152  Bool_t trackExist = kFALSE;
153  Int_t loCircuiti = AliAnalysisMuonUtility::GetLoCircuit(tracki);
154  for (Int_t k = 0; k < nTrgTracks; ++k) {
155  if (loCircuiti == loCircuit[k]) {
156  trackExist = kTRUE;
157  break;
158  }
159  }
160  if (trackExist) continue;
161  loCircuit[nTrgTracks++] = loCircuiti;
162 
163  // fire single muon trigger(s)
164  offlineMSLKey = "msloff:yes";
165  if (AliAnalysisMuonUtility::MatchHpt(tracki)) offlineMSHKey = "mshoff:yes";
166 
167  Int_t trgDevSigni = TriggerDevSign(tracki, fDeltaDev);
168 
169  for (Int_t j = i+1; j < ntracks; ++j) {
170 
171  AliVParticle *trackj = AliAnalysisMuonUtility::GetTrack(j, evt);
172  if (!AliAnalysisMuonUtility::MatchLpt(trackj)) continue;
173 
174  // make sure this track is not already accounted for
175  trackExist = kFALSE;
176  Int_t loCircuitj = AliAnalysisMuonUtility::GetLoCircuit(trackj);
177  for (Int_t k = 0; k < nTrgTracks; ++k) {
178  if (loCircuitj == loCircuit[k]) {
179  trackExist = kTRUE;
180  break;
181  }
182  }
183  if (trackExist) continue;
184 
185  Int_t trgDevSignj = TriggerDevSign(trackj, fDeltaDev);
186 
187  // fire dimuon trigger(s)
188  Int_t trgSign = trgDevSigni * trgDevSignj;
189  if (trgSign <= 0) offlineMULKey = "muloff:yes";
190  if (trgSign >= 0) offlineMLLKey = "mlloff:yes";
191 
192  }
193  }
194  delete[] loCircuit;
195 
196  // Count
197  fTriggerCounters->Count(Form("run:%d/%s/cent:any/%s/%s/%s/%s/%s/%s/%s/%s",
198  fCurrentRunNumber, psKey.Data(),
199  onlineMULKey.Data(), onlineMLLKey.Data(), onlineMSLKey.Data(), onlineMSHKey.Data(),
200  offlineMULKey.Data(), offlineMLLKey.Data(), offlineMSLKey.Data(), offlineMSHKey.Data()));
201  if (!centKey.IsNull())
202  fTriggerCounters->Count(Form("run:%d/%s/%s/%s/%s/%s/%s/%s/%s/%s/%s",
203  fCurrentRunNumber, psKey.Data(), centKey.Data(),
204  onlineMULKey.Data(), onlineMLLKey.Data(), onlineMSLKey.Data(), onlineMSHKey.Data(),
205  offlineMULKey.Data(), offlineMLLKey.Data(), offlineMSLKey.Data(), offlineMSHKey.Data()));
206 
207  PostData(1, fTriggerCounters);
208 }
209 
210 //_____________________________________________________________________________
212 {
213  // Post-processing
214 
215  fTriggerCounters = dynamic_cast<AliCounterCollection*>(GetOutputData(1));
216  if (!fTriggerCounters) return;
217 
218  printf("\nwithout Physics Selection:\n\n");
219  PrintRates("","");
220 
221  printf("\nwith Physics Selection:\n\n");
222  PrintRates("ps:yes","");
223 
224  printf("\nwith Physics Selection in 0-90%%:\n\n");
225  PrintRates("ps:yes","cent:010,1020,2030,3040,4050,5060,6070,7080,8090");
226 
227 }
228 
229 //_____________________________________________________________________________
231 {
233 
234  for (Int_t iCent = 0; iCent < 10; ++iCent) {
235  fCentBinRange[iCent][0] = 10.*iCent;
236  fCentBinRange[iCent][1] = 10.*(iCent+1);
237  fCentBinName[iCent] = Form("%d%d", 10*iCent, 10*(iCent+1));
238  }
239 
240 }
241 
242 //_____________________________________________________________________________
243 Int_t AliAnalysisTaskTriggerRates::TriggerDevSign(AliVParticle *track, UInt_t deltaDev) const
244 {
246 
247  AliESDMuonTrack *esdTrack = dynamic_cast<AliESDMuonTrack*>(track);
248  if (!esdTrack) return 0;
249 
250  Int_t deviation = esdTrack->LoDev();
251  if (deviation > 15+((Int_t)deltaDev)) return 1;
252  else if (deviation < 15-((Int_t)deltaDev)) return -1;
253  else return 0;
254 
255 }
256 
257 //_____________________________________________________________________________
258 void AliAnalysisTaskTriggerRates::PrintRates(TString ps, TString cent) const
259 {
261 
262  if (!ps.IsNull()) ps += "/";
263  if (!cent.IsNull()) cent += "/";
264 
265  const char* sformat = "%12s";
266  const char* dformat = "%12ld";
267  const char* fformat = "%11.1f%%";
268 
269  // define online trigger selection (format = selectKey!rejectKey)
270  const Int_t ni = 8;
271  TString titlei[ni] = {"MUL", "MLL", "MUL|MLL", "MSL", "MSLonly", "MSH", "MUL|MSH", "MUL|MLL|MSH"};
272  TString selecti[ni] = {"mul:yes", "mll:yes", "!mul:no/mll:no", "msl:yes", "msl:yes/mul:no/mll:no/msh:no", "msh:yes", "!mul:no/msh:no", "!mul:no/mll:no/msh:no"};
273 
274  // define offline trigger selection (format = selectKey!rejectKey)
275  const Int_t nj = 12;
276  TString titlej[nj] = {"any", "MULonly", "MLLonly", "MUL&MLL", "MUL", "MLL", "MUL|MLL", "MSL", "MSLonly", "MSH", "MUL|MSH", "MUL|MLL|MSH"};
277  TString selectj[nj] = {"", "muloff:yes/mlloff:no", "muloff:no/mlloff:yes", "muloff:yes/mlloff:yes", "muloff:yes", "mlloff:yes", "!muloff:no/mlloff:no", "msloff:yes", "msloff:yes/muloff:no/mlloff:no/mshoff:no", "mshoff:yes", "!muloff:no/mshoff:no", "!muloff:no/mlloff:no/mshoff:no"};
278 
279  Long_t valij[ni][nj], rvali[ni][nj], rvalj[ni][nj], rvalij[ni][nj], val[ni][nj];
280 
281  printf(sformat,"");
282  for (Int_t j = 0; j < nj; ++j) printf(sformat,titlej[j].Data());
283  printf("\n");
284  for (Int_t i = 0; i < ni; ++i) {
285 
286  printf(sformat, titlei[i].Data());
287 
288  // build online selectKey and selectKey/rejectKey
289  TString si = selecti[i];
290  TString ri = "";
291  if (si.Contains("!")) {
292  ri = si;
293  ri.ReplaceAll("!","/");
294  ri.Remove(TString::kLeading,'/');
295  si.Remove(si.Index("!"));
296  }
297 
298  for (Int_t j = 0; j < nj; ++j) {
299 
300  // build offline selectKey and selectKey/rejectKey
301  TString sj = selectj[j];
302  TString rj = "";
303  if (sj.Contains("!")) {
304  rj = sj;
305  rj.ReplaceAll("!","/");
306  rj.Remove(TString::kLeading,'/');
307  sj.Remove(sj.Index("!"));
308  }
309 
310  // val = selectKeyi/selectKeyj/(any-rejectKeyi)/(any-rejectKeyj)
311  valij[i][j] = (Long_t)fTriggerCounters->GetSum(Form("%s%s%s/%s",ps.Data(),cent.Data(),si.Data(),sj.Data()));
312  rvali[i][j] = (!ri.IsNull()) ? (Long_t)fTriggerCounters->GetSum(Form("%s%s%s/%s",ps.Data(),cent.Data(),ri.Data(),sj.Data())) : 0;
313  rvalj[i][j] = (!rj.IsNull()) ? (Long_t)fTriggerCounters->GetSum(Form("%s%s%s/%s",ps.Data(),cent.Data(),si.Data(),rj.Data())) : 0;
314  rvalij[i][j] = (!ri.IsNull() && !rj.IsNull()) ? (Long_t)fTriggerCounters->GetSum(Form("%s%s%s/%s",ps.Data(),cent.Data(),ri.Data(),rj.Data())) : 0;
315  val[i][j] = valij[i][j]-rvali[i][j]-rvalj[i][j]+rvalij[i][j];
316 
317  if (fPrinfCounts) printf(dformat, val[i][j]);
318  else printf(fformat, ((Float_t)val[i][j])/((Float_t)val[i][0])*100.);
319 
320  }
321  printf("\n");
322 
323  }
324  printf("\n");
325 
326 }
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
TString fMSHPattern
MSL trigger class pattern.
task to study online/offline trigger combinations
TString fMSLPattern
MLL trigger class pattern.
TString fMLLPattern
MUL trigger class pattern.
Float_t fCentBinRange[10][2]
number of centrality bin used (< 10)
virtual void UserExec(Option_t *option)
Bool_t fPrinfCounts
MSH trigger class pattern.
Int_t TriggerDevSign(AliVParticle *track, UInt_t deltaDev) const
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
void PrintRates(TString ps, TString cent) const
TString fMULPattern
set trgSign = 0 for trigger track with dev = 15 ± fDeltaDev
TString fCentBinName[10]
centrality bin intervals
UInt_t fDeltaDev
centrality bin names