AliPhysics  e59a9ba (e59a9ba)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends 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 <TGrid.h>
17 #include <THashList.h>
18 #include <THistManager.h>
19 #include <TObjArray.h>
20 #include <TParameter.h>
21 
22 #include "AliEMCALTriggerBitConfig.h"
23 #include "AliEMCALTriggerPatchInfo.h"
26 #include "AliLog.h"
27 #include "AliOADBContainer.h"
28 
29 #include <bitset>
30 #include <sstream>
31 #include <string>
32 
36 
39  fTriggerMaker(NULL),
40  fV0(NULL),
41  fCaloTriggersOutName("EmcalTriggers"),
42  fV0InName("AliAODVZERO"),
43  fBadFEEChannelOADB(""),
44  fUseL0Amplitudes(kFALSE),
45  fCaloTriggersOut(0),
46  fDoQA(kFALSE),
47  fQAHistos(NULL)
48 {
49 
50 }
51 
53  AliAnalysisTaskEmcal("AliEmcalTriggerMakerTask", doQA),
54  fTriggerMaker(NULL),
55  fV0(NULL),
56  fCaloTriggersOutName("EmcalTriggers"),
57  fV0InName("AliAODVZERO"),
58  fBadFEEChannelOADB(""),
59  fUseL0Amplitudes(kFALSE),
60  fCaloTriggersOut(NULL),
61  fDoQA(doQA),
62  fQAHistos(NULL)
63 {
65 }
66 
68  if(fTriggerMaker) delete fTriggerMaker;
69 }
70 
76  const TString kTriggerTypeNames[3] = {"EJE", "EGA", "EL0"},
77  kPatchTypes[3] = {"Online", "Offline", "Recalc"};
78 
79  if(fDoQA && fOutput){
80  fQAHistos = new THistManager("TriggerQA");
81 
82  for(const TString *triggertype = kTriggerTypeNames; triggertype < kTriggerTypeNames + sizeof(kTriggerTypeNames)/sizeof(TString); triggertype++){
83  for(const TString *patchtype = kPatchTypes; patchtype < kPatchTypes + sizeof(kPatchTypes)/sizeof(TString); ++patchtype){
85  Form("RCPos%s%s", triggertype->Data(), patchtype->Data()),
86  Form("Lower edge position of %s %s patches (col-row);iEta;iPhi", patchtype->Data(), triggertype->Data()),
87  48, -0.5, 47.5, 104, -0.5, 103.5
88  );
90  Form("EPCentPos%s%s", triggertype->Data(), patchtype->Data()),
91  Form("Center position of the %s %s trigger patches;#eta;#phi", patchtype->Data(), triggertype->Data()),
92  20, -0.8, 0.8, 700, 0., 7.
93  );
95  Form("PatchADCvsE%s%s", triggertype->Data(), patchtype->Data()),
96  Form("Patch ADC value for trigger type %s %s;Trigger ADC;FEE patch energy (GeV)", patchtype->Data(), triggertype->Data()),
97  2000, 0., 2000, 200, 0., 200
98  );
100  Form("PatchADCOffvsE%s%s", triggertype->Data(), patchtype->Data()),
101  Form("Patch offline ADC value for trigger type %s %s;Trigger ADC;FEE patch energy (GeV)", patchtype->Data(), triggertype->Data()),
102  2000, 0., 2000, 200, 0., 200
103  );
104  }
105  }
106  fQAHistos->CreateTH1("triggerBitsAll", "Trigger bits for all incoming patches;bit nr", 64, -0.5, 63.5);
107  fQAHistos->CreateTH1("triggerBitsSel", "Trigger bits for reconstructed patches;bit nr", 64, -0.5, 63.5);
109  PostData(1, fOutput);
110  }
111 }
112 
114 {
115  AliEMCALTriggerBitConfig *triggerBitConfig(NULL);
116  switch(bitConfig){
117  case kNewConfig:
118  triggerBitConfig = new AliEMCALTriggerBitConfigNew();
119  break;
120  case kOldConfig:
121  triggerBitConfig = new AliEMCALTriggerBitConfigOld();
122  break;
123  }
124  fTriggerMaker->SetTriggerBitConfig(triggerBitConfig);
125 }
126 
132 
133  if (!fInitialized) return;
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 
206 }
207 
210  if(fBadFEEChannelOADB.Contains("alien://") && !gGrid) TGrid::Connect("alien://");
211  AliOADBContainer badchannelDB("EmcalBadChannelsAdditional");
212  badchannelDB.InitFromFile(fBadFEEChannelOADB.Data(), "EmcalBadChannelsAdditional");
213  TObjArray *badchannelmap = static_cast<TObjArray *>(badchannelDB.GetObject(InputEvent()->GetRunNumber()));
214  if(!badchannelmap || !badchannelmap->GetEntries()) return;
215  for(TIter citer = TIter(badchannelmap).Begin(); citer != TIter::End(); ++citer){
216  TParameter<int> *channelID = static_cast<TParameter<int> *>(*citer);
217  fTriggerMaker->AddOfflineBadChannel(channelID->GetVal());
218  }
219 }
220 
221 void AliEmcalTriggerMakerTask::FillQAHistos(const TString &patchtype, const AliEMCALTriggerPatchInfo &recpatch){
222  fQAHistos->FillTH2(Form("RCPos%s", patchtype.Data()), recpatch.GetColStart(), recpatch.GetRowStart());
223  fQAHistos->FillTH2(Form("EPCentPos%s", patchtype.Data()), recpatch.GetEtaGeo(), recpatch.GetPhiGeo());
224  fQAHistos->FillTH2(Form("PatchADCvsE%s", patchtype.Data()), recpatch.GetADCAmp(), recpatch.GetPatchE());
225  fQAHistos->FillTH2(Form("PatchADCOffvsE%s", patchtype.Data()), recpatch.GetADCOfflineAmp(), recpatch.GetPatchE());
226 }
AliVVZERO * fV0
! VZERO data
New configuration, distiction between high and low threshold.
Base task in the EMCAL framework.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
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) ...
void ReadTriggerData(AliVCaloTrigger *trigger)
TString fV0InName
name of output track array
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
Old configuration, no distinction between high and low threshold.
THashList * GetListOfHistograms() const
Definition: THistManager.h:504
AliEMCALGeometry * fGeom
!emcal geometry
void SetUseTriggerBitConfig(TriggerMakerBitConfig_t bitConfig)
AliEmcalTriggerMakerKernel * fTriggerMaker
The actual trigger maker kernel.
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
EMCAL trigger maker taskThe EMCAL trigger maker task steers the process building trigger patches...
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
AliVCaloCells * fCaloCells
!cells
void BuildL1ThresholdsOffline(const AliVVZERO *vzdata)
AliEmcalList * fOutput
!output list
void SetGeometry(const AliEMCALGeometry *const geo)
void FillQAHistos(const TString &patchtype, const AliEMCALTriggerPatchInfo &recpatch)
TString fBadFEEChannelOADB
name of the OADB container containing channels to be masked inside the trigger maker ...
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
TString fCaloTriggersOutName
name of output track array
TClonesArray * fCaloTriggersOut
! trigger array out
Container class for histograms for the high- charged particle analysis.
Definition: THistManager.h:43
Kernel of the EMCAL trigger patch makerThe trigger maker kernel contains the core functionality of th...
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235
AliVCaloTrigger * fCaloTriggers
!calo triggers
Bool_t fInitialized
whether or not the task has been already initialized
THistManager * fQAHistos
! Histograms for QA
Bool_t fDoQA
Fill QA histograms.
void ReadCellData(AliVCaloCells *cells)