AliPhysics  ec707b8 (ec707b8)
 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  fL0MinTime(7),
44  fL0MaxTime(10),
45  fCaloTriggersOut(0),
46  fDoQA(kFALSE),
47  fQAHistos(NULL)
48 {
49 
50 }
51 
53  AliAnalysisTaskEmcal("AliEmcalTriggerMakerTask", doQA),
54  fTriggerMaker(NULL),
55  fCaloTriggersOutName("EmcalTriggers"),
56  fV0InName("AliAODVZERO"),
57  fV0(NULL),
58  fUseTriggerBitConfig(kNewConfig),
59  fJetPatchsize(16),
60  fUseL0Amplitudes(kFALSE),
61  fL0MinTime(7),
62  fL0MaxTime(10),
63  fCaloTriggersOut(NULL),
64  fDoQA(doQA),
65  fQAHistos(NULL)
66 {
68 }
69 
71  if(fTriggerMaker) delete fTriggerMaker;
72 }
73 
79  const TString kTriggerTypeNames[3] = {"EJE", "EGA", "EL0"},
80  kPatchTypes[3] = {"Online", "Offline", "Recalc"};
81 
82  if(fDoQA && fOutput){
83  fQAHistos = new THistManager("TriggerQA");
84 
85  for(const TString *triggertype = kTriggerTypeNames; triggertype < kTriggerTypeNames + sizeof(kTriggerTypeNames)/sizeof(TString); triggertype++){
86  for(const TString *patchtype = kPatchTypes; patchtype < kPatchTypes + sizeof(kPatchTypes)/sizeof(TString); ++patchtype){
87  fQAHistos->CreateTH2(
88  Form("RCPos%s%s", triggertype->Data(), patchtype->Data()),
89  Form("Lower edge position of %s %s patches (col-row);iEta;iPhi", patchtype->Data(), triggertype->Data()),
90  48, -0.5, 47.5, 104, -0.5, 103.5
91  );
92  fQAHistos->CreateTH2(
93  Form("EPCentPos%s%s", triggertype->Data(), patchtype->Data()),
94  Form("Center position of the %s %s trigger patches;#eta;#phi", patchtype->Data(), triggertype->Data()),
95  20, -0.8, 0.8, 700, 0., 7.
96  );
97  fQAHistos->CreateTH2(
98  Form("PatchADCvsE%s%s", triggertype->Data(), patchtype->Data()),
99  Form("Patch ADC value for trigger type %s %s;Trigger ADC;FEE patch energy (GeV)", patchtype->Data(), triggertype->Data()),
100  2000, 0., 2000, 200, 0., 200
101  );
102  fQAHistos->CreateTH2(
103  Form("PatchADCOffvsE%s%s", triggertype->Data(), patchtype->Data()),
104  Form("Patch offline ADC value for trigger type %s %s;Trigger ADC;FEE patch energy (GeV)", patchtype->Data(), triggertype->Data()),
105  2000, 0., 2000, 200, 0., 200
106  );
107  }
108  }
109  fQAHistos->CreateTH1("triggerBitsAll", "Trigger bits for all incoming patches;bit nr", 64, -0.5, 63.5);
110  fQAHistos->CreateTH1("triggerBitsSel", "Trigger bits for reconstructed patches;bit nr", 64, -0.5, 63.5);
111  fOutput->Add(fQAHistos->GetListOfHistograms());
112  PostData(1, fOutput);
113  }
114 }
115 
121 
122  if (!fInitialized)
123  return;
124 
125  AliEMCALTriggerBitConfig *triggerBitConfig(NULL);
126  if(!triggerBitConfig){
127  switch(fUseTriggerBitConfig){
128  case kNewConfig:
129  triggerBitConfig = new AliEMCALTriggerBitConfigNew();
130  break;
131  case kOldConfig:
132  triggerBitConfig = new AliEMCALTriggerBitConfigOld();
133  break;
134  }
135  }
137  fTriggerMaker->SetTriggerBitConfig(triggerBitConfig);
139 
140  if (!fCaloTriggersOutName.IsNull()) {
141  fCaloTriggersOut = new TClonesArray("AliEMCALTriggerPatchInfo");
143 
144  if (!(InputEvent()->FindListObject(fCaloTriggersOutName))) {
145  InputEvent()->AddObject(fCaloTriggersOut);
146  }
147  else {
148  fInitialized = kFALSE;
149  AliFatal(Form("%s: Container with same name %s already present. Aborting", GetName(), fCaloTriggersOutName.Data()));
150  return;
151  }
152  }
153 
154  if ( ! fV0InName.IsNull()) {
155  fV0 = (AliVVZERO*)InputEvent()->FindListObject(fV0InName);
156  }
157 
159  fTriggerMaker->Init();
160 }
161 
169  fCaloTriggersOut->Clear();
170  // prepare trigger maker
171  fTriggerMaker->Reset();
175  fTriggerMaker->SetIsMC(MCEvent());
176  TObjArray *patches = fTriggerMaker->CreateTriggerPatches(InputEvent(), fUseL0Amplitudes);
177  AliEMCALTriggerPatchInfo *recpatch = NULL;
178  Int_t patchcounter = 0;
179  TString triggerstring;
180  AliDebug(2,Form("Trigger maker - Found %d patches\n", patches->GetEntries()));
181  for(TIter patchIter = TIter(patches).Begin(); patchIter != TIter::End(); ++patchIter){
182  recpatch = dynamic_cast<AliEMCALTriggerPatchInfo *>(*patchIter);
183  if(fDoQA){
184  std::bitset<32> triggerbits = recpatch->GetTriggerBits();
185  std::stringstream triggerbitstring;
186  AliDebug(1, Form("Trigger maker - next patch: size %d, trigger bits %s", recpatch->GetPatchSize(), triggerbitstring.str().c_str()));
187  // Handle types different - online - offline - re
188  if(recpatch->IsJetHigh() || recpatch->IsJetLow()) FillQAHistos("EJEOnline", *recpatch);
189  if(recpatch->IsGammaHigh() || recpatch->IsGammaLow()) FillQAHistos("EGAOnline", *recpatch);
190  if(recpatch->IsJetHighSimple() || recpatch->IsJetLowSimple()) FillQAHistos("EJEOffline", *recpatch);
191  if(recpatch->IsGammaHighSimple() || recpatch->IsGammaLowSimple()) FillQAHistos("EGAOffline", *recpatch);
192  if(recpatch->IsLevel0()) FillQAHistos("EL0Online", *recpatch);
193  if(recpatch->IsRecalcJet()) FillQAHistos("EJERecalc", *recpatch);
194  if(recpatch->IsRecalcGamma()) FillQAHistos("EGARecalc", *recpatch);
195  // Redo checking of found trigger bits after masking of unwanted triggers
196  int tBits = recpatch->GetTriggerBits();
197  for(unsigned int ibit = 0; ibit < sizeof(tBits)*8; ibit++) {
198  if(tBits & (1 << ibit)){
199  fQAHistos->FillTH1("triggerBitsSel", ibit);
200  }
201  }
202  }
203  new((*fCaloTriggersOut)[patchcounter++]) AliEMCALTriggerPatchInfo(*recpatch);
204  }
205  if(patches) delete patches;
206  return true;
207 }
208 
209 void AliEmcalTriggerMakerTask::FillQAHistos(const TString &patchtype, const AliEMCALTriggerPatchInfo &recpatch){
210  fQAHistos->FillTH2(Form("RCPos%s", patchtype.Data()), recpatch.GetColStart(), recpatch.GetRowStart());
211  fQAHistos->FillTH2(Form("EPCentPos%s", patchtype.Data()), recpatch.GetEtaGeo(), recpatch.GetPhiGeo());
212  fQAHistos->FillTH2(Form("PatchADCvsE%s", patchtype.Data()), recpatch.GetADCAmp(), recpatch.GetPatchE());
213  fQAHistos->FillTH2(Form("PatchADCOffvsE%s", patchtype.Data()), recpatch.GetADCOfflineAmp(), recpatch.GetPatchE());
214 }
AliVVZERO * fV0
! VZERO data
New configuration, distiction between high and low threshold.
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
TriggerMakerBitConfig_t fUseTriggerBitConfig
type of trigger config
Base task in the EMCAL framework.
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
!output list
Int_t fL0MaxTime
Maximum L0 time.
void ReadTriggerData(AliVCaloTrigger *trigger)
TString fV0InName
name of output track array
Old configuration, no distinction between high and low threshold.
AliEMCALGeometry * fGeom
!emcal geometry
AliEmcalTriggerMakerKernel * fTriggerMaker
The actual trigger maker kernel.
EMCAL trigger maker taskThe EMCAL trigger maker task steers the process building trigger patches...
AliVCaloCells * fCaloCells
!cells
void SetL0TimeRange(Int_t min, Int_t max)
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
Int_t fL0MinTime
Minimum L0 time.
Kernel of the EMCAL trigger patch makerThe trigger maker kernel contains the core functionality of th...
AliVCaloTrigger * fCaloTriggers
!calo triggers
Bool_t fInitialized
whether or not it should fill some general histograms
THistManager * fQAHistos
! Histograms for QA
Bool_t fDoQA
Fill QA histograms.
Int_t fJetPatchsize
Size of a jet patch.
void ReadCellData(AliVCaloCells *cells)