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 "AliMUONConstants.h"
17 #include "AliAnalysisTaskSE.h"
25 class AliMUONTrackParam;
26 class AliMUONGeometryTransformer;
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 virtual void UserCreateOutputObjects();
80 virtual void UserExec(Option_t *);
81 virtual void NotifyRun();
82 virtual void Terminate(Option_t *);
87 AliAnalysisTaskMuonResolution(const AliAnalysisTaskMuonResolution& rhs);
89 AliAnalysisTaskMuonResolution& operator = (const AliAnalysisTaskMuonResolution& rhs);
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);
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);
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);
97 void FillSigmaClusterVsP(const TH2* hIn, const TH2* hOut, TGraphErrors* g, Bool_t zoom = kTRUE);
98 void Cov2CovP(const AliMUONTrackParam ¶m, TMatrixD &covP);
99 UInt_t BuildTriggerWord(const TString& FiredTriggerClasses);
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)
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
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)
111 kTrackResPerDE = 14, ///< track resolution-X/Y per DE
112 kMCSPerDE = 16, ///< MCS X/Y-dispersion of extrapolated track per DE
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)
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
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)
127 kLocalChi2PerChMean = 0, ///< local chi2-X/Y/total per chamber: mean
128 kLocalChi2PerDEMean = 3 ///< local chi2-X/Y/total per DE: mean
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)
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
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)
145 kCombinedResidualPerDESigma = 26, ///< combined cluster-track residual-X/Y per DE
146 kClusterResPerDE = 28, ///< cluster X/Y-resolution per DE
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)
149 kCombinedResidualPerHalfChSigma = 34, ///< combined cluster-track residual-X/Y per half chamber
150 kClusterResPerHalfCh = 36 ///< cluster X/Y-resolution per half chamber
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
163 kResPerCh = 0, ///< summary canvas
164 kResPerChVsP = 1, ///< summary canvas
165 kResPerDE = 2, ///< summary canvas
166 kResPerHalfCh = 3 ///< summary canvas
169 static const Int_t fgkMinEntries; ///< minimum number of entries needed to compute resolution
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, ...)
176 TObjArray* fCanvases; //!< List of canvases summarizing the results
178 Double_t fClusterResNB[10]; ///< cluster resolution in non-bending direction
179 Double_t fClusterResB[10]; ///< cluster resolution in bending direction
181 TString fDefaultStorage; ///< location of the default OCDB storage
182 Int_t fNEvents; //!< number of processed events
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
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
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
193 Int_t fExtrapMode; ///< extrapolation mode to get the track parameters and covariances at a given cluster
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
205 TList* fSelectTriggerClass; //!< list of trigger class that can be selected to fill histograms
207 ClassDef(AliAnalysisTaskMuonResolution, 2); // chamber resolution analysis
210 //________________________________________________________________________
211 inline void AliAnalysisTaskMuonResolution::SetStartingResolution(Int_t chId, Double_t valNB, Double_t valB)
213 /// set chamber non-bending and bending resolutions
214 if (chId < 0 || chId >= AliMUONConstants::NTrackingCh()) return;
215 fClusterResNB[chId] = valNB;
216 fClusterResB[chId] = valB;
219 //________________________________________________________________________
220 inline void AliAnalysisTaskMuonResolution::SetStartingResolution(Double_t valNB[10], Double_t valB[10])
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];
229 //________________________________________________________________________
230 inline void AliAnalysisTaskMuonResolution::GetStartingResolution(Double_t valNB[10], Double_t valB[10]) const
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];
239 //________________________________________________________________________
240 inline void AliAnalysisTaskMuonResolution::ReAlign(const char* oldAlignStorage, const char* newAlignStorage)
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;
251 //________________________________________________________________________
252 inline void AliAnalysisTaskMuonResolution::FitResiduals(Bool_t flag)
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");