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