]>
Commit | Line | Data |
---|---|---|
f8b94231 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | /* $Id: AliAnalysisMuonUtility.cxx 47782 2011-02-24 18:37:31Z martinez $ */ | |
17 | ||
18 | //----------------------------------------------------------------------------- | |
19 | /// \class AliAnalysisMuonUtility | |
20 | /// Static tilities for muon analysis | |
21 | /// The class allows to treat AODs and ESDs | |
22 | /// as well as MC AODs and MC in a transparent way | |
23 | /// | |
24 | /// \author Diego Stocco | |
25 | //----------------------------------------------------------------------------- | |
26 | ||
27 | #include "AliAnalysisMuonUtility.h" | |
28 | ||
29 | // ROOT includes | |
30 | #include "TAxis.h" | |
31 | #include "TMath.h" | |
32 | #include "TLorentzVector.h" | |
68e9b988 | 33 | #include "TFile.h" |
f8b94231 | 34 | |
35 | // STEER includes | |
68e9b988 | 36 | #include "AliInputEventHandler.h" |
37 | #include "AliAODHeader.h" | |
f8b94231 | 38 | #include "AliAODEvent.h" |
39 | #include "AliAODTrack.h" | |
68e9b988 | 40 | #include "AliAODMCHeader.h" |
f8b94231 | 41 | #include "AliAODMCParticle.h" |
42 | #include "AliMCEvent.h" | |
43 | #include "AliMCParticle.h" | |
44 | #include "AliESDEvent.h" | |
45 | #include "AliESDMuonTrack.h" | |
46 | #include "AliVVertex.h" | |
f8b94231 | 47 | #include "AliLog.h" |
48 | ||
49 | // CORRFW includes | |
50 | #include "AliCFGridSparse.h" | |
51 | ||
52 | /// \cond CLASSIMP | |
53 | ClassImp(AliAnalysisMuonUtility) // Class implementation in ROOT context | |
54 | /// \endcond | |
55 | ||
56 | ||
57 | //________________________________________________________________________ | |
58 | Bool_t AliAnalysisMuonUtility::IsAODEvent ( const AliVEvent* event ) | |
59 | { | |
60 | /// Check if event is from ESD or AOD | |
61 | return ( event->IsA() == AliAODEvent::Class() ); | |
62 | } | |
63 | ||
64 | //________________________________________________________________________ | |
65 | Bool_t AliAnalysisMuonUtility::IsAODTrack ( const AliVParticle* track ) | |
66 | { | |
67 | /// Check if track is from ESD or AOD | |
68 | return ( track->IsA() == AliAODTrack::Class() ); | |
69 | } | |
70 | ||
71 | //________________________________________________________________________ | |
72 | Bool_t AliAnalysisMuonUtility::IsMuonTrack ( const AliVParticle* track ) | |
73 | { | |
74 | /// Check if track has muon tracker info | |
75 | return ( IsAODTrack(track) ) ? static_cast<const AliAODTrack*>(track)->IsMuonTrack() : static_cast<const AliESDMuonTrack*>(track)->ContainTrackerData(); | |
76 | } | |
77 | ||
78 | //________________________________________________________________________ | |
79 | Bool_t AliAnalysisMuonUtility::IsMuonGhost ( const AliVParticle* track ) | |
80 | { | |
81 | /// Check if track has trigger info | |
82 | return ( IsAODTrack(track) ) ? kFALSE : ( ! static_cast<const AliESDMuonTrack*>(track)->ContainTrackerData() ); | |
83 | } | |
84 | ||
85 | //________________________________________________________________________ | |
86 | Double_t AliAnalysisMuonUtility::GetRabs ( const AliVParticle* track ) | |
87 | { | |
88 | /// Get Rabs | |
89 | return ( IsAODTrack(track) ) ? static_cast<const AliAODTrack*>(track)->GetRAtAbsorberEnd() : static_cast<const AliESDMuonTrack*>(track)->GetRAtAbsorberEnd(); | |
90 | } | |
91 | ||
92 | //________________________________________________________________________ | |
93 | Double_t AliAnalysisMuonUtility::GetThetaAbsDeg ( const AliVParticle* track ) | |
94 | { | |
95 | /// Get Theta at absorber end (in deg) | |
96 | return TMath::ATan( GetRabs(track) / 505. ) * TMath::RadToDeg(); | |
97 | } | |
98 | ||
99 | //________________________________________________________________________ | |
100 | Int_t AliAnalysisMuonUtility::GetMatchTrigger ( const AliVParticle* track ) | |
101 | { | |
102 | /// Get match trigger | |
103 | return IsAODTrack(track) ? static_cast<const AliAODTrack*>(track)->GetMatchTrigger() : static_cast<const AliESDMuonTrack*>(track)->GetMatchTrigger(); | |
104 | } | |
105 | ||
106 | //________________________________________________________________________ | |
107 | Double_t AliAnalysisMuonUtility::GetChi2perNDFtracker ( const AliVParticle* track ) | |
108 | { | |
e6bc9bbf | 109 | /// Get the normalized chi2 of the tracker track |
f8b94231 | 110 | return IsAODTrack(track) ? static_cast<const AliAODTrack*>(track)->Chi2perNDF() : static_cast<const AliESDMuonTrack*>(track)->GetNormalizedChi2(); |
111 | } | |
112 | ||
e6bc9bbf | 113 | //________________________________________________________________________ |
114 | Double_t AliAnalysisMuonUtility::GetChi2MatchTrigger ( const AliVParticle* track ) | |
115 | { | |
116 | /// Get the normalized chi2 of the tracker-trigger track matching | |
117 | return IsAODTrack(track) ? static_cast<const AliAODTrack*>(track)->GetChi2MatchTrigger() : static_cast<const AliESDMuonTrack*>(track)->GetChi2MatchTrigger(); | |
118 | } | |
119 | ||
f8b94231 | 120 | //________________________________________________________________________ |
121 | Double_t AliAnalysisMuonUtility::GetXatVertex ( const AliVParticle* track ) | |
122 | { | |
123 | /// Get X at vertex | |
124 | Double_t coor = 0.; | |
125 | if ( IsAODTrack(track) ) { | |
126 | Double_t vtxPos[3]; | |
127 | static_cast<const AliAODTrack*>(track)->GetXYZ(vtxPos); | |
128 | coor = vtxPos[0]; | |
129 | } | |
130 | else coor = static_cast<const AliESDMuonTrack*>(track)->GetNonBendingCoor(); | |
131 | ||
132 | return coor; | |
133 | } | |
134 | ||
135 | //________________________________________________________________________ | |
136 | Double_t AliAnalysisMuonUtility::GetYatVertex ( const AliVParticle* track ) | |
137 | { | |
138 | /// Get Y at vertex | |
139 | Double_t coor = 0.; | |
140 | if ( IsAODTrack(track) ) { | |
141 | Double_t vtxPos[3]; | |
142 | static_cast<const AliAODTrack*>(track)->GetXYZ(vtxPos); | |
143 | coor = vtxPos[1]; | |
144 | } | |
145 | else coor = static_cast<const AliESDMuonTrack*>(track)->GetBendingCoor(); | |
146 | ||
147 | return coor; | |
148 | } | |
149 | ||
150 | //________________________________________________________________________ | |
151 | Double_t AliAnalysisMuonUtility::GetZatVertex ( const AliVParticle* track ) | |
152 | { | |
153 | /// Get Z at vertex | |
154 | Double_t coor = 0.; | |
155 | if ( IsAODTrack(track) ) { | |
156 | Double_t vtxPos[3]; | |
157 | static_cast<const AliAODTrack*>(track)->GetXYZ(vtxPos); | |
158 | coor = vtxPos[2]; | |
159 | } | |
160 | else coor = static_cast<const AliESDMuonTrack*>(track)->GetZ(); | |
161 | ||
162 | return coor; | |
163 | } | |
164 | ||
165 | //________________________________________________________________________ | |
166 | Double_t AliAnalysisMuonUtility::GetXatDCA ( const AliVParticle* track ) | |
167 | { | |
168 | /// Get X at DCA | |
169 | return IsAODTrack(track) ? static_cast<const AliAODTrack*>(track)->XAtDCA() : static_cast<const AliESDMuonTrack*>(track)->GetNonBendingCoorAtDCA(); | |
170 | } | |
171 | ||
172 | //________________________________________________________________________ | |
173 | Double_t AliAnalysisMuonUtility::GetYatDCA ( const AliVParticle* track ) | |
174 | { | |
175 | /// Get Y at DCA | |
176 | return IsAODTrack(track) ? static_cast<const AliAODTrack*>(track)->YAtDCA() : static_cast<const AliESDMuonTrack*>(track)->GetBendingCoorAtDCA(); | |
177 | } | |
178 | ||
e6bc9bbf | 179 | //________________________________________________________________________ |
180 | Bool_t AliAnalysisMuonUtility::IsTrkChamberHit( Int_t chamber, const AliVParticle* track ) | |
181 | { | |
182 | /// Check if the given tracking chamber has been fired | |
183 | if (chamber < 0 || chamber > 9) return kFALSE; | |
184 | return IsAODTrack(track) ? static_cast<const AliAODTrack*>(track)->HitsMuonChamber(chamber) : static_cast<const AliESDMuonTrack*>(track)->IsInMuonClusterMap(chamber); | |
185 | } | |
186 | ||
f8b94231 | 187 | //________________________________________________________________________ |
188 | UInt_t AliAnalysisMuonUtility::GetMUONTrigHitsMapTrk ( const AliVParticle* track ) | |
189 | { | |
190 | /// Get hit pattern in trigger chambers from tracker track extrapolation | |
191 | return ( IsAODTrack(track) ) ? const_cast<AliAODTrack*>(static_cast<const AliAODTrack*>(track))->GetMUONTrigHitsMapTrk() : static_cast<const AliESDMuonTrack*>(track)->GetHitsPatternInTrigChTrk(); | |
192 | } | |
193 | ||
194 | //________________________________________________________________________ | |
195 | UInt_t AliAnalysisMuonUtility::GetMUONTrigHitsMapTrg ( const AliVParticle* track ) | |
196 | { | |
197 | /// Get hit pattern in trigger chambers from tracker track extrapolation | |
198 | return ( IsAODTrack(track) ) ? const_cast<AliAODTrack*>(static_cast<const AliAODTrack*>(track))->GetMUONTrigHitsMapTrg() : static_cast<const AliESDMuonTrack*>(track)->GetHitsPatternInTrigCh(); | |
199 | } | |
200 | ||
2feea167 | 201 | //________________________________________________________________________ |
202 | Int_t AliAnalysisMuonUtility::GetLoCircuit ( const AliVParticle* track ) | |
203 | { | |
204 | /// Get local board | |
205 | Int_t loCircuit = 0; | |
206 | if ( IsAODTrack (track) ) { | |
207 | UInt_t pattern = const_cast<AliAODTrack*>(static_cast<const AliAODTrack*>(track))->GetMUONTrigHitsMapTrg(); | |
208 | loCircuit = AliESDMuonTrack::GetCrossedBoard(pattern); | |
209 | } | |
210 | else loCircuit = static_cast<const AliESDMuonTrack*>(track)->LoCircuit(); | |
211 | ||
212 | return loCircuit; | |
213 | } | |
214 | ||
f8b94231 | 215 | //________________________________________________________________________ |
216 | TString AliAnalysisMuonUtility::GetFiredTriggerClasses ( const AliVEvent* event ) | |
217 | { | |
218 | /// Check if track is from ESD or AOD | |
219 | return ( IsAODEvent(event) ) ? static_cast<const AliAODEvent*>(event)->GetFiredTriggerClasses() : static_cast<const AliESDEvent*>(event)->GetFiredTriggerClasses(); | |
220 | } | |
221 | ||
222 | //________________________________________________________________________ | |
223 | Int_t AliAnalysisMuonUtility::GetNTracks ( const AliVEvent* event ) | |
224 | { | |
225 | // | |
226 | /// Return the number of tracks in event | |
227 | // | |
228 | return ( IsAODEvent(event) ) ? static_cast<const AliAODEvent*>(event)->GetNTracks() : static_cast<const AliESDEvent*>(event)->GetNumberOfMuonTracks(); | |
229 | } | |
230 | ||
af8a23d3 | 231 | //________________________________________________________________________ |
232 | UInt_t AliAnalysisMuonUtility::GetL0TriggerInputs ( const AliVEvent* event ) | |
233 | { | |
234 | // | |
235 | /// Return the L0 trigger inputs | |
236 | // | |
237 | return ( IsAODEvent(event) ) ? static_cast<const AliAODEvent*>(event)->GetHeader()->GetL0TriggerInputs() : static_cast<const AliESDEvent*>(event)->GetHeader()->GetL0TriggerInputs(); | |
238 | } | |
239 | ||
240 | //________________________________________________________________________ | |
241 | UInt_t AliAnalysisMuonUtility::GetL1TriggerInputs ( const AliVEvent* event ) | |
242 | { | |
243 | // | |
244 | /// Return the L1 trigger inputs | |
245 | // | |
246 | return ( IsAODEvent(event) ) ? static_cast<const AliAODEvent*>(event)->GetHeader()->GetL1TriggerInputs() : static_cast<const AliESDEvent*>(event)->GetHeader()->GetL1TriggerInputs(); | |
247 | } | |
248 | ||
249 | //________________________________________________________________________ | |
250 | UInt_t AliAnalysisMuonUtility::GetL2TriggerInputs ( const AliVEvent* event ) | |
251 | { | |
252 | // | |
253 | /// Return the L2 trigger inputs | |
254 | // | |
255 | return ( IsAODEvent(event) ) ? static_cast<const AliAODEvent*>(event)->GetHeader()->GetL2TriggerInputs() : static_cast<const AliESDEvent*>(event)->GetHeader()->GetL2TriggerInputs(); | |
256 | } | |
f8b94231 | 257 | |
258 | //________________________________________________________________________ | |
259 | AliVParticle* AliAnalysisMuonUtility::GetTrack ( Int_t itrack, const AliVEvent* event ) | |
260 | { | |
261 | // | |
262 | /// Get the current track | |
263 | // | |
264 | AliVParticle* track = 0x0; | |
265 | if ( IsAODEvent(event) ) track = static_cast<const AliAODEvent*>(event)->GetTrack(itrack); | |
266 | else { | |
267 | AliESDEvent* esdEvent = const_cast<AliESDEvent*>(static_cast<const AliESDEvent*> (event)); | |
268 | track = esdEvent->GetMuonTrack(itrack); | |
269 | } | |
270 | return track; | |
271 | } | |
272 | ||
273 | //________________________________________________________________________ | |
274 | Double_t AliAnalysisMuonUtility::MuonMass2() | |
275 | { | |
276 | /// A usefull constant | |
277 | return 1.11636129640000012e-02; | |
278 | } | |
279 | ||
280 | //________________________________________________________________________ | |
281 | TLorentzVector AliAnalysisMuonUtility::GetTrackPair ( const AliVParticle* track1, const AliVParticle* track2 ) | |
282 | { | |
283 | // | |
284 | /// Get track pair | |
285 | // | |
286 | const AliVParticle* tracks[2] = {track1, track2}; | |
287 | ||
288 | TLorentzVector vec[2]; | |
289 | for ( Int_t itrack=0; itrack<2; ++itrack ) { | |
290 | Double_t trackP = tracks[itrack]->P(); | |
291 | Double_t energy = TMath::Sqrt(trackP*trackP + MuonMass2()); | |
292 | vec[itrack].SetPxPyPzE(tracks[itrack]->Px(), tracks[itrack]->Py(), tracks[itrack]->Pz(), energy); | |
293 | } | |
294 | ||
295 | TLorentzVector vecPair = vec[0] + vec[1]; | |
296 | return vecPair; | |
297 | } | |
298 | ||
f8b94231 | 299 | |
300 | //________________________________________________________________________ | |
301 | Bool_t AliAnalysisMuonUtility::IsAODMCTrack( const AliVParticle* mcParticle ) | |
302 | { | |
303 | /// Check if track is from AOD MC | |
304 | return ( mcParticle->IsA() == AliAODMCParticle::Class() ); | |
305 | } | |
306 | ||
307 | ||
f8b94231 | 308 | //________________________________________________________________________ |
309 | Double_t AliAnalysisMuonUtility::GetMCVertexZ ( const AliVEvent* event, const AliMCEvent* mcEvent ) | |
310 | { | |
311 | /// Get MC vertex Z | |
312 | Double_t vz = 0.; | |
ac2e110b | 313 | if ( IsAODEvent(event) ) { |
f8b94231 | 314 | AliAODMCHeader* aodMCHeader = static_cast<AliAODMCHeader*> (static_cast<const AliAODEvent*>(event)->FindListObject(AliAODMCHeader::StdBranchName())); |
315 | vz = aodMCHeader->GetVtxZ(); | |
316 | } | |
ac2e110b | 317 | else if ( mcEvent ) vz = mcEvent->GetPrimaryVertex()->GetZ(); |
f8b94231 | 318 | else AliErrorClass("No MC event found"); |
319 | return vz; | |
320 | } | |
321 | ||
322 | //________________________________________________________________________ | |
323 | Int_t AliAnalysisMuonUtility::GetMotherIndex ( const AliVParticle* mcParticle ) | |
324 | { | |
325 | // | |
326 | /// Return the mother index | |
327 | // | |
328 | return ( IsAODMCTrack(mcParticle) ) ? static_cast<const AliAODMCParticle*>(mcParticle)->GetMother() : static_cast<const AliMCParticle*>(mcParticle)->GetMother(); | |
329 | } | |
330 | ||
331 | //________________________________________________________________________ | |
332 | Int_t AliAnalysisMuonUtility::GetDaughterIndex ( const AliVParticle* mcParticle, Int_t idaughter ) | |
333 | { | |
334 | // | |
335 | /// Return the daughter index | |
336 | /// idaughter can be: | |
337 | /// 0 -> first daughter | |
338 | /// 1 -> last daughter | |
339 | // | |
340 | if ( idaughter < 0 || idaughter > 1 ) { | |
341 | AliErrorClass(Form("Requested daughter %i Daughter index can be either 0 (first) or 1 (last)", idaughter)); | |
342 | return -1; | |
343 | } | |
344 | ||
345 | if ( IsAODMCTrack(mcParticle) ) return static_cast<const AliAODMCParticle*>(mcParticle)->GetDaughter(idaughter); | |
346 | ||
347 | if ( idaughter == 0 ) return static_cast<const AliMCParticle*>(mcParticle)->GetFirstDaughter(); | |
348 | else return static_cast<const AliMCParticle*>(mcParticle)->GetLastDaughter(); | |
349 | } | |
350 | ||
351 | //________________________________________________________________________ | |
352 | Bool_t AliAnalysisMuonUtility::IsPrimary ( const AliVParticle* mcParticle, const AliMCEvent* mcEvent ) | |
353 | { | |
354 | /// Check if the particle is primary | |
355 | ||
356 | Bool_t isPrimary = kFALSE; | |
ac2e110b | 357 | if ( IsAODMCTrack(mcParticle) ) isPrimary = static_cast<const AliAODMCParticle*>(mcParticle)->IsPrimary(); |
358 | else if ( mcEvent ) { | |
f8b94231 | 359 | // First get the index of the current particle in the stack. |
360 | // For this: get the mother, and get its daughter. | |
361 | // Since the mother can have many daughters, you can come up to a "sister" | |
362 | // of the particle. Nevertheless, if it is primary, then also the particle itself should be. | |
363 | Int_t imother = static_cast<const AliMCParticle*> (mcParticle)->GetMother(); | |
364 | if ( imother < 0 ) isPrimary = kTRUE; | |
365 | else if ( static_cast<const AliMCParticle*>(mcEvent->GetTrack(imother))->GetFirstDaughter() < const_cast<AliMCEvent*>(mcEvent)->GetNumberOfPrimaries() ) isPrimary = kTRUE; | |
366 | } | |
ac2e110b | 367 | else AliWarningClass("There is no MC info"); |
f8b94231 | 368 | return isPrimary; |
369 | } | |
370 | ||
371 | ||
372 | //________________________________________________________________________ | |
373 | AliVVertex* AliAnalysisMuonUtility::GetVertexSPD ( const AliVEvent* event ) | |
374 | { | |
375 | // | |
376 | /// Get vertex SPD | |
377 | // | |
378 | ||
379 | AliVVertex* primaryVertex = ( IsAODEvent(event) ) ? (AliVVertex*)static_cast<const AliAODEvent*>(event)->GetPrimaryVertexSPD() : (AliVVertex*)static_cast<const AliESDEvent*>(event)->GetPrimaryVertexSPD(); | |
380 | return primaryVertex; | |
381 | } | |
382 | ||
383 | ||
68e9b988 | 384 | //________________________________________________________________________ |
b7e84a9b | 385 | TString AliAnalysisMuonUtility::GetPassName ( const AliInputEventHandler* eventHandler ) |
68e9b988 | 386 | { |
b7e84a9b | 387 | /// Get pass name from event |
388 | ||
389 | // At present there is no straightforward way to get the pass name. | |
390 | // The pass name is usually written in the path to the ESDs/AODs | |
68e9b988 | 391 | // but this won't work for: |
392 | // - MC data (no pass info available) | |
393 | // - local ESDs/AODs | |
394 | ||
395 | TString filePath = ""; | |
b7e84a9b | 396 | const AliVEvent* event = eventHandler->GetEvent(); |
68e9b988 | 397 | if ( IsAODEvent(event) ) { |
398 | // In AODs, the header contains the path to the input ESD event | |
399 | // However, sometimes there is not the FULL path of the ESDs. | |
400 | // In that case we cannot extract the pass number. | |
401 | // To increase the possibility of getting the pass number, | |
402 | // try first to find the info in the AOD header | |
403 | // (which is a priori safer because it works even on local copies of AODs) | |
404 | // and if it does not work, directly check the path to the AOD | |
405 | filePath = static_cast<const AliAODEvent*> (event)->GetHeader()->GetESDFileName(); | |
b7e84a9b | 406 | TString passName = GetPassName(filePath.Data()); |
407 | if ( passName.IsNull() ) AliWarningClass("Check again with the AOD path"); | |
408 | else return passName; | |
68e9b988 | 409 | } |
410 | ||
411 | filePath = eventHandler->GetTree()->GetCurrentFile()->GetName(); | |
b7e84a9b | 412 | return GetPassName(filePath.Data()); |
413 | } | |
414 | ||
415 | ||
416 | //________________________________________________________________________ | |
417 | Int_t AliAnalysisMuonUtility::GetPassNumber ( const AliInputEventHandler* eventHandler ) | |
418 | { | |
419 | /// Get pass number from event | |
420 | ||
421 | // At present there is no straightforward way to get the pass number. | |
422 | // The pass number is usually written in the path to the ESDs/AODs | |
423 | // but this won't work for: | |
424 | // - MC data (no pass info available) | |
425 | // - local ESDs/AODs | |
426 | ||
427 | TString passName = GetPassName(eventHandler); | |
428 | return GetPassNumber(passName); | |
68e9b988 | 429 | } |
430 | ||
431 | ||
b7e84a9b | 432 | //________________________________________________________________________ |
433 | TString AliAnalysisMuonUtility::GetPassName ( const char* str ) | |
434 | { | |
435 | // | |
436 | /// Get pass name from string | |
437 | // | |
438 | ||
439 | TString currName(str); | |
440 | TObjArray* array = currName.Tokenize("/"); | |
441 | ||
442 | TString passName = ""; | |
443 | for ( Int_t ientry=0; ientry<array->GetEntries(); ientry++ ) { | |
444 | TString currToken = static_cast<TObjString*>(array->At(ientry))->GetString(); | |
445 | TString checkToken(currToken); | |
446 | checkToken.ToUpper(); | |
447 | if ( checkToken.Contains("PASS") || checkToken.Contains("MUON_CALO") ) { | |
448 | passName = currToken; | |
449 | break; | |
450 | } | |
451 | } | |
452 | ||
453 | delete array; | |
454 | ||
455 | if ( passName.IsNull() ) AliWarningClass(Form("Cannot find pass name in: %s", str)); | |
456 | ||
457 | return passName; | |
458 | } | |
459 | ||
68e9b988 | 460 | //________________________________________________________________________ |
461 | Int_t AliAnalysisMuonUtility::GetPassNumber ( const char* str ) | |
462 | { | |
463 | // | |
464 | /// Get pass number from string | |
465 | // | |
466 | ||
467 | TString currName(str); | |
468 | currName.ToUpper(); | |
469 | Int_t idx = currName.Index("PASS"); | |
470 | if ( idx >= 0 ) { | |
471 | // Remove all of the words before PASS (and remove the word PASS itself) | |
472 | currName.Remove(0,idx+4); | |
473 | // Cut the word from the end untill only the digits are left | |
474 | // (In this way we can extract the pass number even if it has more than one digit) | |
475 | while ( ! currName.IsDigit() && currName.Length() > 0 ) { | |
476 | currName.Remove(currName.Length()-1); | |
477 | } | |
478 | ||
479 | if ( currName.Length() > 0 ) return currName.Atoi(); | |
480 | } | |
481 | ||
482 | AliWarningClass(Form("Cannot find pass number in: %s", str)); | |
483 | return -1; | |
484 | } | |
485 | ||
486 | ||
f8b94231 | 487 | //_______________________________________________________________________ |
488 | Bool_t AliAnalysisMuonUtility::SetSparseRange(AliCFGridSparse* gridSparse, | |
489 | Int_t ivar, TString labelName, | |
490 | Double_t varMin, Double_t varMax, | |
491 | TString option) | |
492 | { | |
493 | // | |
494 | /// Set range in a smart way. | |
495 | /// Allows to select a bin from the label. | |
496 | /// Check the bin limits. | |
497 | // | |
498 | ||
499 | option.ToUpper(); | |
500 | Int_t minVarBin = -1, maxVarBin = -1; | |
501 | TAxis* axis = gridSparse->GetAxis(ivar); | |
502 | ||
503 | if ( ! axis ) { | |
504 | printf("Warning: Axis %i not found in %s", ivar, gridSparse->GetName()); | |
505 | return kFALSE; | |
506 | } | |
507 | ||
508 | if ( ! labelName.IsNull() ) { | |
509 | minVarBin = axis->FindBin(labelName.Data()); | |
510 | maxVarBin = minVarBin; | |
511 | if ( minVarBin < 1 ) { | |
512 | printf("Warning: %s: label %s not found. Nothing done", gridSparse->GetName(), labelName.Data()); | |
513 | return kFALSE; | |
514 | } | |
515 | } | |
516 | else if ( option.Contains( "USEBIN" ) ) { | |
517 | minVarBin = (Int_t)varMin; | |
518 | maxVarBin = (Int_t)varMax; | |
519 | } | |
520 | else { | |
521 | minVarBin = axis->FindBin(varMin); | |
522 | maxVarBin = axis->FindBin(varMax); | |
523 | } | |
524 | ||
525 | if ( axis->GetFirst() == minVarBin && axis->GetLast() == maxVarBin ) return kFALSE; | |
526 | ||
527 | gridSparse->SetRangeUser(ivar, axis->GetBinCenter(minVarBin), axis->GetBinCenter(maxVarBin)); | |
528 | ||
529 | return kTRUE; | |
530 | } |