AliPhysics  cdeda5a (cdeda5a)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliEmcalFastOrMonitorTask.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2016, 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 <algorithm>
16 #include <vector>
17 #include <THashList.h>
18 #include <THistManager.h>
19 #include <TLorentzVector.h>
20 #include <TMath.h>
21 #include <TVector3.h>
22 
24 #include "AliEMCALGeometry.h"
25 #include "AliInputEventHandler.h"
26 #include "AliVCaloTrigger.h"
27 #include "AliVEvent.h"
28 #include "AliVVertex.h"
29 
33 
36  fHistos(nullptr),
37  fGeom(nullptr),
38  fLocalInitialized(false),
39  fOldRun(-1),
40  fRequestTrigger(AliVEvent::kAny),
41  fTriggerPattern("")
42 {
43 
44 }
45 
47  AliAnalysisTaskSE(name),
48  fHistos(nullptr),
49  fGeom(nullptr),
50  fLocalInitialized(false),
51  fOldRun(-1),
52  fRequestTrigger(AliVEvent::kAny),
53  fTriggerPattern("")
54 {
55  DefineOutput(1, TList::Class());
56 }
57 
59 
60 }
61 
63  fHistos = new THistManager("fastOrHistos");
64 
65  const int kMaxCol = 48, kMaxRow = 104, kMaxFastOr = kMaxRow * kMaxCol;
66 
67  fHistos->CreateTH1("hEvents", "Number of events", 1, 0.5, 1.5);
68  fHistos->CreateTH1("hFastOrFrequencyL0", "FastOr frequency at Level0", kMaxFastOr, -0.5, kMaxFastOr - 0.5);
69  fHistos->CreateTH1("hFastOrFrequencyL1", "FastOr frequency at Level1", kMaxFastOr, -0.5, kMaxFastOr - 0.5);
70  fHistos->CreateTH2("hFastOrAmplitude", "FastOr amplitudes", kMaxFastOr, -0.5, kMaxFastOr - 0.5, 513, -0.5, 512.5);
71  fHistos->CreateTH2("hFastOrTimeSum", "FastOr time sum", kMaxFastOr, -0.5, kMaxFastOr - 0.5, 2049, -0.5, 2048.5);
72  fHistos->CreateTH2("hFastOrTransverseTimeSum", "FastOr transverse time sum", kMaxFastOr, -0.5, kMaxFastOr - 0.5, 2049, -0.5, 2048.5);
73  fHistos->CreateTH2("hFastOrNL0Times", "FastOr Number of L0 times", kMaxFastOr, -0.5, kMaxFastOr - 0.5, 16, -0.5, 15.5);
74  fHistos->CreateTH2("hFastOrColRowFrequencyL0", "FastOr Frequency (col-row) at Level1", kMaxCol, -0.5, kMaxCol - 0.5, kMaxRow, -0.5, kMaxRow - 0.5);
75  fHistos->CreateTH2("hFastOrColRowFrequencyL1", "FastOr Frequency (col-row) at Level0", kMaxCol, -0.5, kMaxCol - 0.5, kMaxRow, -0.5, kMaxRow - 0.5);
76 
77  PostData(1, fHistos->GetListOfHistograms());
78 }
79 
81  fGeom = AliEMCALGeometry::GetInstanceFromRunNumber(InputEvent()->GetRunNumber());
82 }
83 
85 
86 }
87 
89  if(!fLocalInitialized){
90  ExecOnce();
91  fLocalInitialized = true;
92  }
93 
94  // Run change
95  if(InputEvent()->GetRunNumber() != fOldRun){
96  RunChanged();
97  fOldRun = InputEvent()->GetRunNumber();
98  }
99 
100  // Check trigger
101  if(!(fInputHandler->IsEventSelected() & fRequestTrigger)) return;
102  if(fTriggerPattern.Length()){
103  if(!TString(InputEvent()->GetFiredTriggerClasses()).Contains(fTriggerPattern)) return;
104  }
105 
106  const AliVVertex *vtx = fInputEvent->GetPrimaryVertex();
107  Double_t vtxpos[3];
108  vtx->GetXYZ(vtxpos);
109 
110  fHistos->FillTH1("hEvents", 1);
111 
112  AliVCaloTrigger *triggerdata = InputEvent()->GetCaloTrigger("EMCAL");
113  triggerdata->Reset();
114  Int_t nl0times, l1timesum, fastOrID, globCol, globRow;
115  Float_t amp;
116  while(triggerdata->Next()){
117  triggerdata->GetAmplitude(amp);
118  triggerdata->GetNL0Times(nl0times);
119  triggerdata->GetL1TimeSum(l1timesum);
120  triggerdata->GetPosition(globCol, globRow);
121  fGeom->GetTriggerMapping()->GetAbsFastORIndexFromPositionInEMCAL(globCol, globRow, fastOrID);
122  if(amp > 1e-5){
123  fHistos->FillTH2("hFastOrColRowFrequencyL0", globCol, globRow);
124  fHistos->FillTH1("hFastOrFrequencyL0", fastOrID);
125  }
126  if(l1timesum){
127  fHistos->FillTH2("hFastOrColRowFrequencyL1", globCol, globRow);
128  fHistos->FillTH1("hFastOrFrequencyL1", fastOrID);
129  }
130  if(std::find(fMaskedFastors.begin(), fMaskedFastors.end(), fastOrID) == fMaskedFastors.end()){
131  fHistos->FillTH2("hFastOrAmplitude", fastOrID, amp);
132  fHistos->FillTH2("hFastOrTimeSum", fastOrID, l1timesum);
133  fHistos->FillTH2("hFastOrNL0Times", fastOrID, nl0times);
134  fHistos->FillTH2("hFastOrTransverseTimeSum", fastOrID, GetTransverseTimeSum(fastOrID, l1timesum, vtxpos));
135  }
136  }
137 
138  PostData(1, fHistos->GetListOfHistograms());
139 }
140 
142  Int_t cellIDs[4];
143  fGeom->GetTriggerMapping()->GetCellIndexFromFastORIndex(fastorAbsID, cellIDs);
144  std::vector<double> eta, phi;
145  for(int i = 0l; i < 4; i++){
146  double etatmp, phitmp;
147  fGeom->EtaPhiFromIndex(cellIDs[i], etatmp, phitmp);
148  eta.push_back(etatmp);
149  phi.push_back(phitmp);
150  }
151 
152  // Calculate FastOR position: for the approximation take mean eta and phi
153  // Radius is taken from the geometry
154  TVector3 fastorPos, vertexPos(vertex[0], vertex[1], vertex[2]);
155  fastorPos.SetPtEtaPhi(fGeom->GetIPDistance(), TMath::Mean(eta.begin(), eta.end()), TMath::Mean(phi.begin(), phi.end()));
156  fastorPos -= vertexPos;
157 
158  TLorentzVector evec(fastorPos, adc);
159  return evec.Et();
160 }
double Double_t
Definition: External.C:58
Int_t fOldRun
Old Run (for RunChanged())
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
int Int_t
Definition: External.C:63
ULong_t fRequestTrigger
Trigger selection bits.
THashList * GetListOfHistograms() const
Definition: THistManager.h:504
float Float_t
Definition: External.C:68
Double_t GetTransverseTimeSum(Int_t fastorAbsID, Double_t adc, const Double_t *vtx) const
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
AliEMCALGeometry * fGeom
! EMCAL Geometry object
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Bool_t fLocalInitialized
Switch whether task is initialized (for ExecOnce)
std::vector< int > fMaskedFastors
List of masked fastors.
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
TString fTriggerPattern
Trigger string pattern used in addition to the trigger selection bits.
Container class for histograms.
Definition: THistManager.h:43
Int_t GetRunNumber(TString)
Definition: PlotMuonQA.C:2235
const char Option_t
Definition: External.C:48
virtual void UserExec(Option_t *)
THistManager * fHistos
! Histogram handler
Simlple monitoring of EMCAL FastOr quantities.