]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG3/muondep/AliAnalysisTaskMuonResolution.h
Coverity
[u/mrichter/AliRoot.git] / PWG3 / muondep / AliAnalysisTaskMuonResolution.h
CommitLineData
7cbb1928 1#ifndef ALIANALYSISTASKMUONRESOLUTION_H
2#define ALIANALYSISTASKMUONRESOLUTION_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6/// \ingroup muondep
7/// \class AliAnalysisTaskMuonResolution
8/// \brief Muon spectrometer resolution
9//Author: Philippe Pillot - SUBATECH Nantes
10
11#include <TString.h>
12#include <TMatrixD.h>
00612ffc 13#include <TF1.h>
7cbb1928 14#include "AliMUONConstants.h"
00612ffc 15#include "AliAnalysisTaskSE.h"
7cbb1928 16
17class TH1;
18class TH2;
19class TGraphErrors;
20class TObjArray;
00612ffc 21class TList;
7cbb1928 22class AliMUONTrack;
23class AliMUONTrackParam;
24class AliMUONGeometryTransformer;
25
26class AliAnalysisTaskMuonResolution : public AliAnalysisTaskSE {
27public:
28
29 AliAnalysisTaskMuonResolution();
30 AliAnalysisTaskMuonResolution(const char *name);
31 virtual ~AliAnalysisTaskMuonResolution();
32
00612ffc 33 /// Set location of the default OCDB storage (if not set use "raw://")
34 void SetDefaultStorage(const char* ocdbPath) { fDefaultStorage = ocdbPath; }
35
7cbb1928 36 void SetStartingResolution(Int_t chId, Double_t valNB, Double_t valB);
37 void SetStartingResolution(Double_t valNB[10], Double_t valB[10]);
f4d9245c 38 void GetStartingResolution(Double_t valNB[10], Double_t valB[10]) const;
7cbb1928 39
40 /// set the minimum momentum value of the tracks used to compute the resolution
41 void SetMinMomentum(Double_t val) { fMinMomentum = val; }
42
43 /// set the flag to use only tracks passing the physics selection
44 void SelectPhysics(Bool_t flag = kTRUE) {fSelectPhysics = flag;}
45
46 /// set the flag to use only tracks matched with trigger or not
47 void MatchTrigger(Bool_t flag = kTRUE) { fMatchTrig = flag; }
48
00612ffc 49 /// set the flag to use only tracks passing the acceptance cuts (Rabs, eta)
50 void ApplyAccCut(Bool_t flag = kTRUE) { fApplyAccCut = flag; }
51
52 /// Select events belonging to at least one of the trigger classes selected by the mask to fill histograms:
53 /// - if the physics selection is used, apply the mask to the trigger word returned by the physics selection
54 /// - if not, apply the mask to the trigger word built by looking for triggers listed in "fSelectTriggerClass"
55 void SelectTrigger(Bool_t flag = kTRUE, UInt_t mask = AliVEvent::kMUON) {fSelectTrigger = flag; fTriggerMask = mask;}
56
7cbb1928 57 /// set the extrapolation mode to get the track parameters and covariances at a given cluster:
58 /// 0 = extrapolate from the closest cluster; 1 = extrapolate from the previous cluster except between stations 2-3-4
59 void SetExtrapMode(Int_t val) { fExtrapMode = val; }
60
61 /// set the flag to add or not the systematic shifts of the residuals to the resolution
62 void CorrectForSystematics(Bool_t flag = kTRUE) { fCorrectForSystematics = flag; }
63
64 void ReAlign(const char* oldAlignStorage = 0x0, const char* newAlignStorage = "");
65
66 /// return the list of summary canvases
67 TObjArray* GetCanvases() {return fCanvases;}
68
00612ffc 69 /// set the flag to show the progression bar
70 void ShowProgressBar(Bool_t flag = kTRUE) {fShowProgressBar = flag;}
71
72 /// set the flag to print the cluster resolution per chamber/DE
73 void PrintClusterRes(Bool_t perCh = kTRUE, Bool_t perDE = kFALSE) {fPrintClResPerCh = perCh; fPrintClResPerDE = perDE;}
74
75 void FitResiduals(Bool_t flag = kTRUE);
76
7cbb1928 77 virtual void UserCreateOutputObjects();
78 virtual void UserExec(Option_t *);
79 virtual void NotifyRun();
80 virtual void Terminate(Option_t *);
81
82private:
83
84 /// Not implemented
85 AliAnalysisTaskMuonResolution(const AliAnalysisTaskMuonResolution& rhs);
86 /// Not implemented
87 AliAnalysisTaskMuonResolution& operator = (const AliAnalysisTaskMuonResolution& rhs);
88
89 void ModifyClusters(AliMUONTrack& track);
90 void Zoom(TH1* h, Double_t fractionCut = 0.01);
91 void ZoomLeft(TH1* h, Double_t fractionCut = 0.02);
92 void ZoomRight(TH1* h, Double_t fractionCut = 0.02);
00612ffc 93 void GetMean(TH1* h, Double_t& mean, Double_t& meanErr, TGraphErrors* g = 0x0, Int_t i = 0, Double_t x = 0, Bool_t zoom = kTRUE, Bool_t enableFit = kTRUE);
7cbb1928 94 void GetRMS(TH1* h, Double_t& rms, Double_t& rmsErr, TGraphErrors* g = 0x0, Int_t i = 0, Double_t x = 0, Bool_t zoom = kTRUE);
f4d9245c 95 void FillSigmaClusterVsP(const TH2* hIn, const TH2* hOut, TGraphErrors* g, Bool_t zoom = kTRUE);
7cbb1928 96 void Cov2CovP(const AliMUONTrackParam &param, TMatrixD &covP);
f4d9245c 97 UInt_t BuildTriggerWord(const TString& FiredTriggerClasses);
7cbb1928 98
99private:
100
00612ffc 101 enum eResiduals {
f4d9245c 102 kResidualPerChClusterIn = 0, ///< cluster-track residual-X/Y distribution per chamber (cluster attached to the track)
103 kResidualPerChClusterOut = 2, ///< cluster-track residual-X/Y distribution per chamber (cluster not attached to the track)
7cbb1928 104 kTrackResPerCh = 4, ///< track resolution-X/Y per chamber
105 kMCSPerCh = 6, ///< MCS X/Y-dispersion of extrapolated track per chamber
106 kClusterRes2PerCh = 8, ///< cluster X/Y-resolution per chamber
f4d9245c 107 kResidualPerDEClusterIn = 10, ///< cluster-track residual-X/Y distribution per DE (cluster attached to the track)
108 kResidualPerDEClusterOut = 12, ///< cluster-track residual-X/Y distribution per DE (cluster not attached to the track)
00612ffc 109 kTrackResPerDE = 14, ///< track resolution-X/Y per DE
110 kMCSPerDE = 16, ///< MCS X/Y-dispersion of extrapolated track per DE
f4d9245c 111 kResidualPerHalfChClusterIn = 18, ///< cluster-track residual-X/Y distribution per half chamber (cluster attached to the track)
112 kResidualPerHalfChClusterOut = 20, ///< cluster-track residual-X/Y distribution per half chamber (cluster not attached to the track)
00612ffc 113 kTrackResPerHalfCh = 22, ///< track resolution-X/Y per half chamber
114 kMCSPerHalfCh = 24, ///< MCS X/Y-dispersion of extrapolated track per half chamber
115 kLocalChi2PerCh = 26, ///< local chi2-X/Y/total distribution per chamber
116 kLocalChi2PerDE = 29 ///< local chi2-X/Y/total distribution per DE
117 };
118
119 enum eResidualsVsP {
f4d9245c 120 kResidualInChVsPClusterIn = 0, ///< cluster-track residual-X/Y distribution in chamber i versus momentum (cluster attached to the track)
121 kResidualInChVsPClusterOut = 20 ///< cluster-track residual-X/Y distribution in chamber i versus momentum (cluster not attached to the track)
00612ffc 122 };
123
124 enum eLocalChi2 {
125 kLocalChi2PerChMean = 0, ///< local chi2-X/Y/total per chamber: mean
126 kLocalChi2PerDEMean = 3 ///< local chi2-X/Y/total per DE: mean
127 };
128
129 enum eChamberRes {
f4d9245c 130 kResidualPerChMeanClusterIn = 0, ///< cluster-track residual-X/Y per chamber: mean (cluster in)
131 kResidualPerChMeanClusterOut = 2, ///< cluster-track residual-X/Y per chamber: mean (cluster out)
132 kResidualPerChSigmaClusterIn = 4, ///< cluster-track residual-X/Y per chamber: sigma (cluster in)
133 kResidualPerChSigmaClusterOut = 6, ///< cluster-track residual-X/Y per chamber: sigma (cluster out)
134 kResidualPerChDispersionClusterOut = 8, ///< cluster-track residual-X/Y per chamber: dispersion (cluster out)
00612ffc 135 kCombinedResidualPerChSigma = 10, ///< combined cluster-track residual-X/Y per chamber
136 kCombinedResidualSigmaVsP = 12, ///< cluster X/Y-resolution per chamber versus momentum
137 kTrackResPerChMean = 14, ///< track X/Y-resolution per chamber
138 kMCSPerChMean = 16, ///< MCS X/Y-dispersion of extrapolated track per chamber
139 kClusterResPerCh = 18, ///< cluster X/Y-resolution per chamber
140 kCalcClusterResPerCh = 20, ///< calculated cluster X/Y-resolution per chamber
f4d9245c 141 kResidualPerDEMeanClusterIn = 22, ///< cluster-track residual-X/Y per DE: mean (cluster in)
142 kResidualPerDEMeanClusterOut = 24, ///< cluster-track residual-X/Y per DE: mean (cluster out)
00612ffc 143 kCombinedResidualPerDESigma = 26, ///< combined cluster-track residual-X/Y per DE
144 kClusterResPerDE = 28, ///< cluster X/Y-resolution per DE
f4d9245c 145 kResidualPerHalfChMeanClusterIn = 30, ///< cluster-track residual-X/Y per half chamber: mean (cluster in)
146 kResidualPerHalfChMeanClusterOut = 32, ///< cluster-track residual-X/Y per half chamber: mean (cluster out)
00612ffc 147 kCombinedResidualPerHalfChSigma = 34, ///< combined cluster-track residual-X/Y per half chamber
148 kClusterResPerHalfCh = 36 ///< cluster X/Y-resolution per half chamber
149 };
150
151 enum eTrackRes {
152 kUncorrPRes = 0, ///< muon momentum reconstructed resolution at first cluster vs p
153 kPRes = 1, ///< muon momentum reconstructed resolution at vertex vs p
154 kUncorrPtRes = 2, ///< muon transverse momentum reconstructed resolution at first cluster vs p
155 kPtRes = 3, ///< muon transverse momentum reconstructed resolution at vertex vs p
156 kUncorrSlopeRes = 4, ///< muon slope-X/Y reconstructed resolution at first cluster vs p
157 kSlopeRes = 6 ///< muon slope-X/Y reconstructed resolution at vertex vs p
158 };
159
160 enum eCanvases {
161 kResPerCh = 0, ///< summary canvas
162 kResPerChVsP = 1, ///< summary canvas
163 kResPerDE = 2, ///< summary canvas
164 kResPerHalfCh = 3 ///< summary canvas
7cbb1928 165 };
166
167 static const Int_t fgkMinEntries; ///< minimum number of entries needed to compute resolution
168
169 TObjArray* fResiduals; //!< List of residual histos
170 TObjArray* fResidualsVsP; //!< List of residual vs. p histos
171 TObjArray* fLocalChi2; //!< List of plots related to local chi2 per chamber/DE
172 TObjArray* fChamberRes; //!< List of plots related to chamber/DE resolution
173 TObjArray* fTrackRes; //!< List of plots related to track resolution (p, pT, ...)
00612ffc 174 TObjArray* fCanvases; //!< List of canvases summarizing the results
7cbb1928 175
176 Double_t fClusterResNB[10]; ///< cluster resolution in non-bending direction
177 Double_t fClusterResB[10]; ///< cluster resolution in bending direction
178
00612ffc 179 TString fDefaultStorage; ///< location of the default OCDB storage
7cbb1928 180 Int_t fNEvents; //!< number of processed events
00612ffc 181 Bool_t fShowProgressBar; ///< show the progression bar
182 Bool_t fPrintClResPerCh; ///< print the cluster resolution per chamber
183 Bool_t fPrintClResPerDE; ///< print the cluster resolution per DE
184 TF1* fGaus; ///< gaussian function to fit the residuals
7cbb1928 185 Double_t fMinMomentum; ///< use only tracks with momentum higher than this value
186 Bool_t fSelectPhysics; ///< use only tracks passing the physics selection
187 Bool_t fMatchTrig; ///< use only tracks matched with trigger
00612ffc 188 Bool_t fApplyAccCut; ///< use only tracks passing the acceptance cuts (Rabs, eta)
189 Bool_t fSelectTrigger; ///< use only tracks passing the trigger selection
190 UInt_t fTriggerMask; ///< trigger mask to be used when selecting tracks
f4d9245c 191 Int_t fExtrapMode; ///< extrapolation mode to get the track parameters and covariances at a given cluster
7cbb1928 192 Bool_t fCorrectForSystematics; ///< add or not the systematic shifts of the residuals to the resolution
193 Bool_t fOCDBLoaded; //!< flag telling if the OCDB has been properly loaded or not
194 Int_t fNDE; //!< total number of DE
195 Int_t fDEIndices[1100]; //!< index of DE in histograms refered by ID
196 Int_t fDEIds[200]; //!< ID of DE refered by index in histograms
197 Bool_t fReAlign; ///< flag telling wether to re-align the spectrometer or not before computing resolution
198 TString fOldAlignStorage; ///< location of the OCDB storage where to find old MUON/Align/Data (use the default one if empty)
199 TString fNewAlignStorage; ///< location of the OCDB storage where to find new MUON/Align/Data (use the default one if empty)
200 AliMUONGeometryTransformer* fOldGeoTransformer; //!< geometry transformer used to recontruct the present data
201 AliMUONGeometryTransformer* fNewGeoTransformer; //!< new geometry transformer containing the new alignment to be applied
202
00612ffc 203 TList* fSelectTriggerClass; //!< list of trigger class that can be selected to fill histograms
204
205 ClassDef(AliAnalysisTaskMuonResolution, 2); // chamber resolution analysis
7cbb1928 206};
207
208//________________________________________________________________________
209inline void AliAnalysisTaskMuonResolution::SetStartingResolution(Int_t chId, Double_t valNB, Double_t valB)
210{
211 /// set chamber non-bending and bending resolutions
212 if (chId < 0 || chId >= AliMUONConstants::NTrackingCh()) return;
213 fClusterResNB[chId] = valNB;
214 fClusterResB[chId] = valB;
215}
216
217//________________________________________________________________________
218inline void AliAnalysisTaskMuonResolution::SetStartingResolution(Double_t valNB[10], Double_t valB[10])
219{
220 /// set chambers non-bending and bending resolutions
221 for (Int_t i = 0; i < AliMUONConstants::NTrackingCh(); i++) {
222 fClusterResNB[i] = valNB[i];
223 fClusterResB[i] = valB[i];
224 }
225}
226
227//________________________________________________________________________
f4d9245c 228inline void AliAnalysisTaskMuonResolution::GetStartingResolution(Double_t valNB[10], Double_t valB[10]) const
7cbb1928 229{
230 /// set chambers non-bending and bending resolutions
231 for (Int_t i = 0; i < AliMUONConstants::NTrackingCh(); i++) {
232 valNB[i] = fClusterResNB[i];
233 valB[i] = fClusterResB[i];
234 }
235}
236
237//________________________________________________________________________
238inline void AliAnalysisTaskMuonResolution::ReAlign(const char* oldAlignStorage, const char* newAlignStorage)
239{
240 /// Set the flag to activate the re-alignment and the specific storage where to find the old/new alignment data.
241 /// If oldAlignStorage = 0x0 we assume the spectrometer was not aligned before (default geometry)
242 /// If old(new)AlignStorage = "" we assume the old(new) alignment data are in the default storage
243 if (oldAlignStorage) fOldAlignStorage = oldAlignStorage;
244 else fOldAlignStorage = "none";
245 fNewAlignStorage = newAlignStorage;
246 fReAlign = kTRUE;
247}
248
00612ffc 249//________________________________________________________________________
250inline void AliAnalysisTaskMuonResolution::FitResiduals(Bool_t flag)
251{
252 /// set gaussian function to fit the residual distribution to extract the mean and the dispersion.
253 /// if not set: take the mean and the RMS of the distribution
254 if (fGaus) delete fGaus;
255 if (flag) fGaus = new TF1("fGaus","gaus");
256 else fGaus = NULL;
257}
258
7cbb1928 259#endif
260