]>
Commit | Line | Data |
---|---|---|
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> | |
13 | #include <TF1.h> | |
14 | #include "AliMUONConstants.h" | |
15 | #include "AliAnalysisTaskSE.h" | |
16 | ||
17 | class TH1; | |
18 | class TH2; | |
19 | class TGraphErrors; | |
20 | class TObjArray; | |
21 | class TList; | |
22 | class AliMUONTrack; | |
23 | class AliMUONTrackParam; | |
24 | class AliMUONGeometryTransformer; | |
25 | ||
26 | class AliAnalysisTaskMuonResolution : public AliAnalysisTaskSE { | |
27 | public: | |
28 | ||
29 | AliAnalysisTaskMuonResolution(); | |
30 | AliAnalysisTaskMuonResolution(const char *name); | |
31 | virtual ~AliAnalysisTaskMuonResolution(); | |
32 | ||
33 | /// Set location of the default OCDB storage (if not set use "raw://") | |
34 | void SetDefaultStorage(const char* ocdbPath) { fDefaultStorage = ocdbPath; } | |
35 | ||
36 | void SetStartingResolution(Int_t chId, Double_t valNB, Double_t valB); | |
37 | void SetStartingResolution(Double_t valNB[10], Double_t valB[10]); | |
38 | void GetStartingResolution(Double_t valNB[10], Double_t valB[10]) const; | |
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 | ||
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 | ||
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 | ||
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 | ||
77 | virtual void UserCreateOutputObjects(); | |
78 | virtual void UserExec(Option_t *); | |
79 | virtual void NotifyRun(); | |
80 | virtual void Terminate(Option_t *); | |
81 | ||
82 | private: | |
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); | |
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); | |
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); | |
95 | void FillSigmaClusterVsP(const TH2* hIn, const TH2* hOut, TGraphErrors* g, Bool_t zoom = kTRUE); | |
96 | void Cov2CovP(const AliMUONTrackParam ¶m, TMatrixD &covP); | |
97 | UInt_t BuildTriggerWord(const TString& FiredTriggerClasses); | |
98 | ||
99 | private: | |
100 | ||
101 | enum eResiduals { | |
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) | |
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 | |
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) | |
109 | kTrackResPerDE = 14, ///< track resolution-X/Y per DE | |
110 | kMCSPerDE = 16, ///< MCS X/Y-dispersion of extrapolated track per DE | |
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) | |
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 { | |
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) | |
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 { | |
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) | |
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 | |
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) | |
143 | kCombinedResidualPerDESigma = 26, ///< combined cluster-track residual-X/Y per DE | |
144 | kClusterResPerDE = 28, ///< cluster X/Y-resolution per DE | |
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) | |
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 | |
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, ...) | |
174 | TObjArray* fCanvases; //!< List of canvases summarizing the results | |
175 | ||
176 | Double_t fClusterResNB[10]; ///< cluster resolution in non-bending direction | |
177 | Double_t fClusterResB[10]; ///< cluster resolution in bending direction | |
178 | ||
179 | TString fDefaultStorage; ///< location of the default OCDB storage | |
180 | Int_t fNEvents; //!< number of processed events | |
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 | |
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 | |
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 | |
191 | Int_t fExtrapMode; ///< extrapolation mode to get the track parameters and covariances at a given cluster | |
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 | ||
203 | TList* fSelectTriggerClass; //!< list of trigger class that can be selected to fill histograms | |
204 | ||
205 | ClassDef(AliAnalysisTaskMuonResolution, 2); // chamber resolution analysis | |
206 | }; | |
207 | ||
208 | //________________________________________________________________________ | |
209 | inline 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 | //________________________________________________________________________ | |
218 | inline 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 | //________________________________________________________________________ | |
228 | inline void AliAnalysisTaskMuonResolution::GetStartingResolution(Double_t valNB[10], Double_t valB[10]) const | |
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 | //________________________________________________________________________ | |
238 | inline 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 | ||
249 | //________________________________________________________________________ | |
250 | inline 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 | ||
259 | #endif | |
260 |