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 */
9 /// \class AliAnalysisTaskMuonResolution
10 /// \brief Muon spectrometer resolution
11 //Author: Philippe Pillot - SUBATECH Nantes
16 #include "AliAnalysisTaskSE.h"
24 class AliMUONTrackParam;
25 class AliMUONGeometryTransformer;
26 class AliMUONVCluster;
28 class AliAnalysisTaskMuonResolution : public AliAnalysisTaskSE {
31 AliAnalysisTaskMuonResolution();
32 AliAnalysisTaskMuonResolution(const char *name);
33 virtual ~AliAnalysisTaskMuonResolution();
35 /// Set location of the default OCDB storage (if not set use "raw://")
36 void SetDefaultStorage(const char* ocdbPath) { fDefaultStorage = ocdbPath; }
38 void SetStartingResolution(Int_t chId, Double_t valNB, Double_t valB);
39 void SetStartingResolution(Double_t valNB[10], Double_t valB[10]);
40 void GetStartingResolution(Double_t valNB[10], Double_t valB[10]) const;
42 /// set the minimum momentum value of the tracks used to compute the resolution
43 void SetMinMomentum(Double_t val) { fMinMomentum = val; }
45 /// set the flag to use only tracks passing the physics selection
46 void SelectPhysics(Bool_t flag = kTRUE) {fSelectPhysics = flag;}
48 /// set the flag to use only tracks matched with trigger or not
49 void MatchTrigger(Bool_t flag = kTRUE) { fMatchTrig = flag; }
51 /// set the flag to use only tracks passing the acceptance cuts (Rabs, eta)
52 void ApplyAccCut(Bool_t flag = kTRUE) { fApplyAccCut = flag; }
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;}
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; }
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; }
66 void ReAlign(const char* oldAlignStorage = 0x0, const char* newAlignStorage = "");
68 /// return the list of summary canvases
69 TObjArray* GetCanvases() {return fCanvases;}
71 /// set the flag to show the progression bar
72 void ShowProgressBar(Bool_t flag = kTRUE) {fShowProgressBar = flag;}
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;}
77 void FitResiduals(Bool_t flag = kTRUE);
79 /// set the flag to remove mono-cathod clusters (either considering all the pads or only the ones directly below)
80 void RemoveMonoCathodClusters(Bool_t flag = kTRUE, Bool_t checkAllPads = kTRUE) {fRemoveMonoCathCl = flag; fCheckAllPads = checkAllPads;}
82 virtual void UserCreateOutputObjects();
83 virtual void UserExec(Option_t *);
84 virtual void NotifyRun();
85 virtual void Terminate(Option_t *);
90 AliAnalysisTaskMuonResolution(const AliAnalysisTaskMuonResolution& rhs);
92 AliAnalysisTaskMuonResolution& operator = (const AliAnalysisTaskMuonResolution& rhs);
94 void ModifyClusters(AliMUONTrack& track);
95 void Zoom(TH1* h, Double_t fractionCut = 0.01);
96 void ZoomLeft(TH1* h, Double_t fractionCut = 0.02);
97 void ZoomRight(TH1* h, Double_t fractionCut = 0.02);
98 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);
99 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);
100 void FillSigmaClusterVsP(const TH2* hIn, const TH2* hOut, TGraphErrors* g, Bool_t zoom = kTRUE);
101 void FillSigmaClusterVsCent(const TH2* hIn, const TH2* hOut, TGraphErrors* g, Bool_t zoom = kTRUE);
102 void Cov2CovP(const AliMUONTrackParam ¶m, TMatrixD &covP);
103 UInt_t BuildTriggerWord(const TString& FiredTriggerClasses);
104 void CheckPads(AliMUONVCluster *cl, Bool_t &hasBending, Bool_t &hasNonBending) const;
105 void CheckPadsBelow(AliMUONVCluster *cl, Bool_t &hasBending, Bool_t &hasNonBending) const;
110 kResidualPerChClusterIn = 0, ///< cluster-track residual-X/Y distribution per chamber (cluster attached to the track)
111 kResidualPerChClusterOut = 2, ///< cluster-track residual-X/Y distribution per chamber (cluster not attached to the track)
112 kTrackResPerCh = 4, ///< track resolution-X/Y per chamber
113 kMCSPerCh = 6, ///< MCS X/Y-dispersion of extrapolated track per chamber
114 kClusterRes2PerCh = 8, ///< cluster X/Y-resolution per chamber
115 kResidualPerDEClusterIn = 10, ///< cluster-track residual-X/Y distribution per DE (cluster attached to the track)
116 kResidualPerDEClusterOut = 12, ///< cluster-track residual-X/Y distribution per DE (cluster not attached to the track)
117 kTrackResPerDE = 14, ///< track resolution-X/Y per DE
118 kMCSPerDE = 16, ///< MCS X/Y-dispersion of extrapolated track per DE
119 kResidualPerHalfChClusterIn = 18, ///< cluster-track residual-X/Y distribution per half chamber (cluster attached to the track)
120 kResidualPerHalfChClusterOut = 20, ///< cluster-track residual-X/Y distribution per half chamber (cluster not attached to the track)
121 kTrackResPerHalfCh = 22, ///< track resolution-X/Y per half chamber
122 kMCSPerHalfCh = 24, ///< MCS X/Y-dispersion of extrapolated track per half chamber
123 kLocalChi2PerCh = 26, ///< local chi2-X/Y/total distribution per chamber
124 kLocalChi2PerDE = 29 ///< local chi2-X/Y/total distribution per DE
128 kResidualInChVsPClusterIn = 0, ///< cluster-track residual-X/Y distribution in chamber i versus momentum (cluster attached to the track)
129 kResidualInChVsPClusterOut = 20, ///< cluster-track residual-X/Y distribution in chamber i versus momentum (cluster not attached to the track)
130 kResidualVsPClusterIn = 40, ///< cluster-track residual-X/Y distribution integrated over chambers versus momentum (cluster attached to the track)
131 kResidualVsPClusterOut = 42 ///< cluster-track residual-X/Y distribution integrated over chambers versus momentum (cluster not attached to the track)
134 enum eResidualsVsCent {
135 kResidualInChVsCentClusterIn = 0, ///< cluster-track residual-X/Y distribution in chamber i versus centrality (cluster attached to the track)
136 kResidualInChVsCentClusterOut = 20, ///< cluster-track residual-X/Y distribution in chamber i versus centrality (cluster not attached to the track)
137 kResidualVsCentClusterIn = 40, ///< cluster-track residual-X/Y distribution integrated over chambers versus centrality (cluster attached to the track)
138 kResidualVsCentClusterOut = 42 ///< cluster-track residual-X/Y distribution integrated over chambers versus centrality (cluster not attached to the track)
142 kLocalChi2PerChMean = 0, ///< local chi2-X/Y/total per chamber: mean
143 kLocalChi2PerDEMean = 3 ///< local chi2-X/Y/total per DE: mean
147 kResidualPerChMeanClusterIn = 0, ///< cluster-track residual-X/Y per chamber: mean (cluster in)
148 kResidualPerChMeanClusterOut = 2, ///< cluster-track residual-X/Y per chamber: mean (cluster out)
149 kResidualPerChSigmaClusterIn = 4, ///< cluster-track residual-X/Y per chamber: sigma (cluster in)
150 kResidualPerChSigmaClusterOut = 6, ///< cluster-track residual-X/Y per chamber: sigma (cluster out)
151 kResidualPerChDispersionClusterOut = 8, ///< cluster-track residual-X/Y per chamber: dispersion (cluster out)
152 kCombinedResidualPerChSigma = 10, ///< combined cluster-track residual-X/Y per chamber
153 kCombinedResidualSigmaVsP = 12, ///< cluster X/Y-resolution per chamber versus momentum
154 kTrackResPerChMean = 14, ///< track X/Y-resolution per chamber
155 kMCSPerChMean = 16, ///< MCS X/Y-dispersion of extrapolated track per chamber
156 kClusterResPerCh = 18, ///< cluster X/Y-resolution per chamber
157 kCalcClusterResPerCh = 20, ///< calculated cluster X/Y-resolution per chamber
158 kResidualPerDEMeanClusterIn = 22, ///< cluster-track residual-X/Y per DE: mean (cluster in)
159 kResidualPerDEMeanClusterOut = 24, ///< cluster-track residual-X/Y per DE: mean (cluster out)
160 kCombinedResidualPerDESigma = 26, ///< combined cluster-track residual-X/Y per DE
161 kClusterResPerDE = 28, ///< cluster X/Y-resolution per DE
162 kResidualPerHalfChMeanClusterIn = 30, ///< cluster-track residual-X/Y per half chamber: mean (cluster in)
163 kResidualPerHalfChMeanClusterOut = 32, ///< cluster-track residual-X/Y per half chamber: mean (cluster out)
164 kCombinedResidualPerHalfChSigma = 34, ///< combined cluster-track residual-X/Y per half chamber
165 kClusterResPerHalfCh = 36, ///< cluster X/Y-resolution per half chamber
166 kCombinedResidualSigmaVsCent = 38, ///< cluster X/Y-resolution per chamber versus centrality
167 kCombinedResidualAllChSigmaVsP = 40, ///< cluster X/Y-resolution integrated over chambers versus momentum
168 kCombinedResidualAllChSigmaVsCent = 42 ///< cluster X/Y-resolution integrated over chambers versus centrality
172 kUncorrPRes = 0, ///< muon momentum reconstructed resolution at first cluster vs p
173 kPRes = 1, ///< muon momentum reconstructed resolution at vertex vs p
174 kUncorrPtRes = 2, ///< muon transverse momentum reconstructed resolution at first cluster vs p
175 kPtRes = 3, ///< muon transverse momentum reconstructed resolution at vertex vs p
176 kUncorrSlopeRes = 4, ///< muon slope-X/Y reconstructed resolution at first cluster vs p
177 kSlopeRes = 6 ///< muon slope-X/Y reconstructed resolution at vertex vs p
181 kResPerCh = 0, ///< summary canvas
182 kResPerChVsP = 1, ///< summary canvas
183 kResPerDE = 2, ///< summary canvas
184 kResPerHalfCh = 3, ///< summary canvas
185 kResPerChVsCent = 4 ///< summary canvas
188 static const Int_t fgkMinEntries; ///< minimum number of entries needed to compute resolution
190 TObjArray* fResiduals; //!< List of residual histos
191 TObjArray* fResidualsVsP; //!< List of residual vs. p histos
192 TObjArray* fResidualsVsCent; //!< List of residual vs. centrality histos
193 TObjArray* fLocalChi2; //!< List of plots related to local chi2 per chamber/DE
194 TObjArray* fChamberRes; //!< List of plots related to chamber/DE resolution
195 TObjArray* fTrackRes; //!< List of plots related to track resolution (p, pT, ...)
196 TObjArray* fCanvases; //!< List of canvases summarizing the results
198 Double_t fClusterResNB[10]; ///< cluster resolution in non-bending direction
199 Double_t fClusterResB[10]; ///< cluster resolution in bending direction
201 TString fDefaultStorage; ///< location of the default OCDB storage
202 Int_t fNEvents; //!< number of processed events
203 Bool_t fShowProgressBar; ///< show the progression bar
204 Bool_t fPrintClResPerCh; ///< print the cluster resolution per chamber
205 Bool_t fPrintClResPerDE; ///< print the cluster resolution per DE
206 TF1* fGaus; ///< gaussian function to fit the residuals
207 Double_t fMinMomentum; ///< use only tracks with momentum higher than this value
208 Bool_t fSelectPhysics; ///< use only tracks passing the physics selection
209 Bool_t fMatchTrig; ///< use only tracks matched with trigger
210 Bool_t fApplyAccCut; ///< use only tracks passing the acceptance cuts (Rabs, eta)
211 Bool_t fSelectTrigger; ///< use only tracks passing the trigger selection
212 UInt_t fTriggerMask; ///< trigger mask to be used when selecting tracks
213 Int_t fExtrapMode; ///< extrapolation mode to get the track parameters and covariances at a given cluster
214 Bool_t fCorrectForSystematics; ///< add or not the systematic shifts of the residuals to the resolution
215 Bool_t fRemoveMonoCathCl; ///< remove or not the mono-cathod clusters
216 Bool_t fCheckAllPads; ///< use all pads or only the ones directly below the cluster to look for mono-cathods
217 Bool_t fOCDBLoaded; //!< flag telling if the OCDB has been properly loaded or not
218 Int_t fNDE; //!< total number of DE
219 Int_t fDEIndices[1100]; //!< index of DE in histograms refered by ID
220 Int_t fDEIds[200]; //!< ID of DE refered by index in histograms
221 Bool_t fReAlign; ///< flag telling wether to re-align the spectrometer or not before computing resolution
222 TString fOldAlignStorage; ///< location of the OCDB storage where to find old MUON/Align/Data (use the default one if empty)
223 TString fNewAlignStorage; ///< location of the OCDB storage where to find new MUON/Align/Data (use the default one if empty)
224 AliMUONGeometryTransformer* fOldGeoTransformer; //!< geometry transformer used to recontruct the present data
225 AliMUONGeometryTransformer* fNewGeoTransformer; //!< new geometry transformer containing the new alignment to be applied
227 TList* fSelectTriggerClass; //!< list of trigger class that can be selected to fill histograms
229 ClassDef(AliAnalysisTaskMuonResolution, 3); // chamber resolution analysis
232 //________________________________________________________________________
233 inline void AliAnalysisTaskMuonResolution::SetStartingResolution(Int_t chId, Double_t valNB, Double_t valB)
235 /// set chamber non-bending and bending resolutions
236 if (chId < 0 || chId >= 10) return;
237 fClusterResNB[chId] = valNB;
238 fClusterResB[chId] = valB;
241 //________________________________________________________________________
242 inline void AliAnalysisTaskMuonResolution::SetStartingResolution(Double_t valNB[10], Double_t valB[10])
244 /// set chambers non-bending and bending resolutions
245 for (Int_t i = 0; i < 10; i++) {
246 fClusterResNB[i] = valNB[i];
247 fClusterResB[i] = valB[i];
251 //________________________________________________________________________
252 inline void AliAnalysisTaskMuonResolution::GetStartingResolution(Double_t valNB[10], Double_t valB[10]) const
254 /// set chambers non-bending and bending resolutions
255 for (Int_t i = 0; i < 10; i++) {
256 valNB[i] = fClusterResNB[i];
257 valB[i] = fClusterResB[i];
261 //________________________________________________________________________
262 inline void AliAnalysisTaskMuonResolution::ReAlign(const char* oldAlignStorage, const char* newAlignStorage)
264 /// Set the flag to activate the re-alignment and the specific storage where to find the old/new alignment data.
265 /// If oldAlignStorage = 0x0 we assume the spectrometer was not aligned before (default geometry)
266 /// If old(new)AlignStorage = "" we assume the old(new) alignment data are in the default storage
267 if (oldAlignStorage) fOldAlignStorage = oldAlignStorage;
268 else fOldAlignStorage = "none";
269 fNewAlignStorage = newAlignStorage;
273 //________________________________________________________________________
274 inline void AliAnalysisTaskMuonResolution::FitResiduals(Bool_t flag)
276 /// set gaussian function to fit the residual distribution to extract the mean and the dispersion.
277 /// if not set: take the mean and the RMS of the distribution
279 if (flag) fGaus = new TF1("fGaus","gaus");