AliPhysics  de71be2 (de71be2)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
AliEmcalTriggerMakerTask.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2013, 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 <TClonesArray.h>
16 #include <THashList.h>
17 #include <THistManager.h>
18 #include <TObjArray.h>
19 
20 #include "AliEMCALTriggerBitConfig.h"
21 #include "AliEMCALTriggerPatchInfo.h"
24 #include "AliLog.h"
25 
26 #include <bitset>
27 #include <sstream>
28 #include <string>
29 
33 
36  fTriggerMaker(NULL),
37  fCaloTriggersOutName("EmcalTriggers"),
38  fV0InName("AliAODVZERO"),
39  fV0(NULL),
40  fUseTriggerBitConfig(kNewConfig),
41  fJetPatchsize(16),
42  fUseL0Amplitudes(kFALSE),
43  fCaloTriggersOut(0),
44  fDoQA(kFALSE),
45  fQAHistos(NULL)
46 {
47 
48 }
49 
51  AliAnalysisTaskEmcal("AliEmcalTriggerMakerTask", doQA),
52  fTriggerMaker(NULL),
53  fCaloTriggersOutName("EmcalTriggers"),
54  fV0InName("AliAODVZERO"),
55  fV0(NULL),
56  fUseTriggerBitConfig(kNewConfig),
57  fJetPatchsize(16),
58  fUseL0Amplitudes(kFALSE),
59  fCaloTriggersOut(NULL),
60  fDoQA(doQA),
61  fQAHistos(NULL)
62 {
64 }
65 
67  if(fTriggerMaker) delete fTriggerMaker;
68 }
69 
75  const TString kTriggerTypeNames[3] = {"EJE", "EGA", "EL0"},
76  kPatchTypes[3] = {"Online", "Offline", "Recalc"};
77 
78  if(fDoQA && fOutput){
79  fQAHistos = new THistManager("TriggerQA");
80 
81  for(const TString *triggertype = kTriggerTypeNames; triggertype < kTriggerTypeNames + sizeof(kTriggerTypeNames)/sizeof(TString); triggertype++){
82  for(const TString *patchtype = kPatchTypes; patchtype < kPatchTypes + sizeof(kPatchTypes)/sizeof(TString); ++patchtype){
83  fQAHistos->CreateTH2(
84  Form("RCPos%s%s", triggertype->Data(), patchtype->Data()),
85  Form("Lower edge position of %s %s patches (col-row);iEta;iPhi", patchtype->Data(), triggertype->Data()),
86  48, -0.5, 47.5, 104, -0.5, 103.5
87  );
88  fQAHistos->CreateTH2(
89  Form("EPCentPos%s%s", triggertype->Data(), patchtype->Data()),
90  Form("Center position of the %s %s trigger patches;#eta;#phi", patchtype->Data(), triggertype->Data()),
91  20, -0.8, 0.8, 700, 0., 7.
92  );
93  fQAHistos->CreateTH2(
94  Form("PatchADCvsE%s%s", triggertype->Data(), patchtype->Data()),
95  Form("Patch ADC value for trigger type %s %s;Trigger ADC;FEE patch energy (GeV)", patchtype->Data(), triggertype->Data()),
96  2000, 0., 2000, 200, 0., 200
97  );
98  fQAHistos->CreateTH2(
99  Form("PatchADCOffvsE%s%s", triggertype->Data(), patchtype->Data()),
100  Form("Patch offline ADC value for trigger type %s %s;Trigger ADC;FEE patch energy (GeV)", patchtype->Data(), triggertype->Data()),
101  2000, 0., 2000, 200, 0., 200
102  );
103  }
104  }
105  fQAHistos->CreateTH1("triggerBitsAll", "Trigger bits for all incoming patches;bit nr", 64, -0.5, 63.5);
106  fQAHistos->CreateTH1("triggerBitsSel", "Trigger bits for reconstructed patches;bit nr", 64, -0.5, 63.5);
107  fOutput->Add(fQAHistos->GetListOfHistograms());
108  PostData(1, fOutput);
109  }
110 }
111 
117 
118  if (!fInitialized)
119  return;
120 
121  AliEMCALTriggerBitConfig *triggerBitConfig(NULL);
122  if(!triggerBitConfig){
123  switch(fUseTriggerBitConfig){
124  case kNewConfig:
125  triggerBitConfig = new AliEMCALTriggerBitConfigNew();
126  break;
127  case kOldConfig:
128  triggerBitConfig = new AliEMCALTriggerBitConfigOld();
129  break;
130  }
131  }
133  fTriggerMaker->SetTriggerBitConfig(triggerBitConfig);
134 
135  if (!fCaloTriggersOutName.IsNull()) {
136  fCaloTriggersOut = new TClonesArray("AliEMCALTriggerPatchInfo");
138 
139  if (!(InputEvent()->FindListObject(fCaloTriggersOutName))) {
140  InputEvent()->AddObject(fCaloTriggersOut);
141  }
142  else {
143  fInitialized = kFALSE;
144  AliFatal(Form("%s: Container with same name %s already present. Aborting", GetName(), fCaloTriggersOutName.Data()));
145  return;
146  }
147  }
148 
149  if ( ! fV0InName.IsNull()) {
150  fV0 = (AliVVZERO*)InputEvent()->FindListObject(fV0InName);
151  }
152 
154  fTriggerMaker->Init();
155 }
156 
164  fCaloTriggersOut->Clear();
165  // prepare trigger maker
166  fTriggerMaker->Reset();
170  fTriggerMaker->SetIsMC(MCEvent());
171  TObjArray *patches = fTriggerMaker->CreateTriggerPatches(InputEvent(), fUseL0Amplitudes);
172  AliEMCALTriggerPatchInfo *recpatch = NULL;
173  Int_t patchcounter = 0;
174  TString triggerstring;
175  AliDebug(2,Form("Trigger maker - Found %d patches\n", patches->GetEntries()));
176  for(TIter patchIter = TIter(patches).Begin(); patchIter != TIter::End(); ++patchIter){
177  recpatch = dynamic_cast<AliEMCALTriggerPatchInfo *>(*patchIter);
178  if(fDoQA){
179  std::bitset<32> triggerbits = recpatch->GetTriggerBits();
180  std::stringstream triggerbitstring;
181  AliDebug(1, Form("Trigger maker - next patch: size %d, trigger bits %s", recpatch->GetPatchSize(), triggerbitstring.str().c_str()));
182  // Handle types different - online - offline - re
183  if(recpatch->IsJetHigh() || recpatch->IsJetLow()) FillQAHistos("EJEOnline", *recpatch);
184  if(recpatch->IsGammaHigh() || recpatch->IsGammaLow()) FillQAHistos("EGAOnline", *recpatch);
185  if(recpatch->IsJetHighSimple() || recpatch->IsJetLowSimple()) FillQAHistos("EJEOffline", *recpatch);
186  if(recpatch->IsGammaHighSimple() || recpatch->IsGammaLowSimple()) FillQAHistos("EGAOffline", *recpatch);
187  if(recpatch->IsLevel0()) FillQAHistos("EL0Online", *recpatch);
188  if(recpatch->IsRecalcJet()) FillQAHistos("EJERecalc", *recpatch);
189  if(recpatch->IsRecalcGamma()) FillQAHistos("EGARecalc", *recpatch);
190  // Redo checking of found trigger bits after masking of unwanted triggers
191  int tBits = recpatch->GetTriggerBits();
192  for(unsigned int ibit = 0; ibit < sizeof(tBits)*8; ibit++) {
193  if(tBits & (1 << ibit)){
194  fQAHistos->FillTH1("triggerBitsSel", ibit);
195  }
196  }
197  }
198  new((*fCaloTriggersOut)[patchcounter++]) AliEMCALTriggerPatchInfo(*recpatch);
199  }
200  if(patches) delete patches;
201  return true;
202 }
203 
204 void AliEmcalTriggerMakerTask::FillQAHistos(const TString &patchtype, const AliEMCALTriggerPatchInfo &recpatch){
205  fQAHistos->FillTH2(Form("RCPos%s", patchtype.Data()), recpatch.GetColStart(), recpatch.GetRowStart());
206  fQAHistos->FillTH2(Form("EPCentPos%s", patchtype.Data()), recpatch.GetEtaGeo(), recpatch.GetPhiGeo());
207  fQAHistos->FillTH2(Form("PatchADCvsE%s", patchtype.Data()), recpatch.GetADCAmp(), recpatch.GetPatchE());
208  fQAHistos->FillTH2(Form("PatchADCOffvsE%s", patchtype.Data()), recpatch.GetADCOfflineAmp(), recpatch.GetPatchE());
209 }
AliVVZERO * fV0
! VZERO data
New configuration, distiction between high and low threshold.
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
TriggerMakerBitConfig_t fUseTriggerBitConfig
type of trigger config
TObjArray * CreateTriggerPatches(const AliVEvent *inputevent, Bool_t useL0amp=kFALSE)
void SetTriggerBitConfig(const AliEMCALTriggerBitConfig *const config)
Bool_t fUseL0Amplitudes
Use L0 amplitudes instead of L1 time sum (useful for runs where STU was not read) ...
TList * fOutput
event parton info
void ReadTriggerData(AliVCaloTrigger *trigger)
TString fV0InName
name of output track array
Old configuration, no distinction between high and low threshold.
AliEMCALGeometry * fGeom
whether it's an ESD analysis
AliEmcalTriggerMakerKernel * fTriggerMaker
The actual trigger maker kernel.
EMCAL trigger maker taskThe EMCAL trigger maker task steers the process building trigger patches...
AliVCaloCells * fCaloCells
clusters
void BuildL1ThresholdsOffline(const AliVVZERO *vzdata)
void SetGeometry(const AliEMCALGeometry *const geo)
void FillQAHistos(const TString &patchtype, const AliEMCALTriggerPatchInfo &recpatch)
TString fCaloTriggersOutName
name of output track array
TClonesArray * fCaloTriggersOut
! trigger array out
Kernel of the EMCAL trigger patch makerThe trigger maker kernel contains the core functionality of th...
AliVCaloTrigger * fCaloTriggers
cells
THistManager * fQAHistos
! Histograms for QA
Bool_t fDoQA
Fill QA histograms.
Int_t fJetPatchsize
Size of a jet patch.
void ReadCellData(AliVCaloCells *cells)