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