]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG/muon/AliAnalysisTaskESDMuonFilter.cxx
AliErrors related to zero weight removed
[u/mrichter/AliRoot.git] / PWG / muon / AliAnalysisTaskESDMuonFilter.cxx
CommitLineData
1d1ea3ce 1/**************************************************************************
8dda6345 2 * Copyright(c) 1998-2013, ALICE Experiment at CERN, All rights reserved. *
1d1ea3ce 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
27de2dfb 16/* $Id$ */
17
8dda6345 18///
19/// Add the muon tracks to the generic AOD track branch during the
20/// filtering of the ESD.
21///
22///
23/// Note that we :
24///
25/// - completely disable all the branches that are not required by (most) the muon analyses,
26/// e.g. cascades, v0s, kinks, jets, etc...
27/// - filter severely the tracks (keep only muon tracks) and vertices (keep only primary -including
28/// pile-up - vertices) branches
29///
30/// \see AliAODMuonReplicator
31///
32/// (see AddFilteredAOD method)
33///
aba11173 34
1d1ea3ce 35#include "AliAnalysisTaskESDMuonFilter.h"
dcc1f876 36
8dda6345 37#include "AliAnalysisFilter.h"
38#include "AliAnalysisManager.h"
39#include "AliAnalysisNonMuonTrackCuts.h"
40#include "AliAnalysisNonPrimaryVertices.h"
dcc1f876 41#include "AliAODDimuon.h"
1d1ea3ce 42#include "AliAODEvent.h"
14d6fad5 43#include "AliAODExtension.h"
8dda6345 44#include "AliAODHandler.h"
dcc1f876 45#include "AliAODMCParticle.h"
46#include "AliAODMuonReplicator.h"
47#include "AliAODVertex.h"
dcc1f876 48#include "AliCodeTimer.h"
49#include "AliESDEvent.h"
50#include "AliESDInputHandler.h"
1d1ea3ce 51#include "AliESDMuonTrack.h"
dcc1f876 52#include "AliESDtrack.h"
f7cc8591 53#include "AliESDMuonGlobalTrack.h" // AU
8dda6345 54#include "AliESDVertex.h"
1d1ea3ce 55#include "AliLog.h"
fc3a4c45 56#include "AliMCEvent.h"
57#include "AliMCEventHandler.h"
dcc1f876 58#include "AliMultiplicity.h"
dcc1f876 59#include <TChain.h>
60#include <TFile.h>
61#include <TParticle.h>
1d1ea3ce 62
3a7af7bd 63using std::cout;
64using std::endl;
1d1ea3ce 65ClassImp(AliAnalysisTaskESDMuonFilter)
26ba01d4 66
8dda6345 67AliAnalysisTaskESDMuonFilter::AliAnalysisTaskESDMuonFilter(Bool_t onlyMuon, Bool_t keepAllEvents, Int_t mcMode, Bool_t withSPDtracklets):
aba11173 68 AliAnalysisTaskSE(),
f785fc59 69 fTrackFilter(0x0),
4a497116 70 fEnableMuonAOD(kFALSE),
26ba01d4 71 fEnableDimuonAOD(kFALSE),
72 fOnlyMuon(onlyMuon),
14d6fad5 73 fKeepAllEvents(keepAllEvents),
8dda6345 74 fMCMode(mcMode),
75 fWithSPDTracklets(withSPDtracklets)
1d1ea3ce 76{
8dda6345 77 /// Default constructor
1d1ea3ce 78}
79
8dda6345 80AliAnalysisTaskESDMuonFilter::AliAnalysisTaskESDMuonFilter(const char* name, Bool_t onlyMuon, Bool_t keepAllEvents, Int_t mcMode, Bool_t withSPDtracklets):
aba11173 81 AliAnalysisTaskSE(name),
f785fc59 82 fTrackFilter(0x0),
4a497116 83 fEnableMuonAOD(kFALSE),
26ba01d4 84 fEnableDimuonAOD(kFALSE),
85 fOnlyMuon(onlyMuon),
14d6fad5 86 fKeepAllEvents(keepAllEvents),
8dda6345 87 fMCMode(mcMode),
88 fWithSPDTracklets(withSPDtracklets)
1d1ea3ce 89{
8dda6345 90 /// Constructor
1d1ea3ce 91}
92
3d270be0 93//______________________________________________________________________________
1d1ea3ce 94void AliAnalysisTaskESDMuonFilter::UserCreateOutputObjects()
95{
8dda6345 96 /// Create the output container
aba11173 97 if (fTrackFilter) OutputTree()->GetUserInfo()->Add(fTrackFilter);
1d1ea3ce 98}
99
3d270be0 100//______________________________________________________________________________
101void AliAnalysisTaskESDMuonFilter::PrintTask(Option_t *option, Int_t indent) const
102{
8dda6345 103 /// Specify how we are configured
3d270be0 104
105 AliAnalysisTaskSE::PrintTask(option,indent);
106
107 TString spaces(' ',indent+3);
108
109 if ( fOnlyMuon )
110 {
111 cout << spaces.Data() << "Keep only muon information " << endl;
112 }
113 else
114 {
115 cout << spaces.Data() << "Keep all information from standard AOD" << endl;
116 }
117
118 if ( fKeepAllEvents )
119 {
120 cout << spaces.Data() << "Keep all events, regardless of number of muons" << endl;
121 }
122 else
123 {
124 cout << spaces.Data() << "Keep only events with at least one muon" << endl;
125 }
14d6fad5 126
127 if ( fMCMode > 0 )
128 {
129 cout << spaces.Data() << "Assuming work on MC data (i.e. will transmit MC branches)" << endl;
8dda6345 130 if ( fMCMode == 1 )
131 {
132 cout << spaces.Data() << " (will write MC information irrespective of whether or not we have reconstructed muons in the event)" << endl;
133 }
737c3d9e 134 else if ( fMCMode == 2 )
8dda6345 135 {
136 cout << spaces.Data() << " (will write MC information only if we have reconstructed muons in the event)" << endl;
737c3d9e 137 }
138 else {
139 cout << spaces.Data() << " (will write MC information for all muons in the event)" << endl;
8dda6345 140 }
141 }
142
143 if ( fWithSPDTracklets )
144 {
145 cout << spaces.Data() << "Will also keep SPD tracklets" << endl;
14d6fad5 146 }
3d270be0 147}
148
149//______________________________________________________________________________
26ba01d4 150void AliAnalysisTaskESDMuonFilter::AddFilteredAOD(const char* aodfilename, const char* title)
151{
8dda6345 152 /// Add an output filtered and replicated aod
26ba01d4 153
154 AliAODHandler *aodH = (AliAODHandler*)((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
155 if (!aodH) Fatal("UserCreateOutputObjects", "No AOD handler");
156
157 AliAODExtension* ext = aodH->AddFilteredAOD(aodfilename,title);
158
3d270be0 159 if (!ext) return;
160
161 if ( fOnlyMuon )
162 {
14d6fad5 163
164 AliAODMuonReplicator* murep = new AliAODMuonReplicator("MuonReplicator",
165 "remove non muon tracks and non primary or pileup vertices",
166 new AliAnalysisNonMuonTrackCuts,
167 new AliAnalysisNonPrimaryVertices,
8dda6345 168 fMCMode,
169 kFALSE,
170 fWithSPDTracklets);
dcc1f876 171
172 ext->DropUnspecifiedBranches(); // all branches not part of a FilterBranch call (below) will be dropped
173
26ba01d4 174 ext->FilterBranch("tracks",murep);
3d270be0 175 ext->FilterBranch("vertices",murep);
176 ext->FilterBranch("dimuons",murep);
5393f2c0 177 ext->FilterBranch("AliAODVZERO",murep);
3493cd3f 178 ext->FilterBranch("AliAODTZERO",murep);
8dda6345 179 ext->FilterBranch("AliAODZDC",murep);
180
181 if ( fWithSPDTracklets )
182 {
183 ext->FilterBranch("tracklets",murep);
184 }
5393f2c0 185
8dda6345 186 if ( fMCMode > 0 )
14d6fad5 187 {
188 // MC branches will be copied (if present), as they are, but only
189 // for events with at least one muon.
190 // For events w/o muon, mcparticles array will be empty and mcheader will be dummy
191 // (e.g. strlen(GetGeneratorName())==0)
192
193 ext->FilterBranch("mcparticles",murep);
194 ext->FilterBranch("mcHeader",murep);
195 }
26ba01d4 196 }
197}
198
3d270be0 199//______________________________________________________________________________
1d1ea3ce 200void AliAnalysisTaskESDMuonFilter::Init()
201{
8dda6345 202 /// Initialization
26ba01d4 203 if(fEnableMuonAOD) AddFilteredAOD("AliAOD.Muons.root", "MuonEvents");
204 if(fEnableDimuonAOD) AddFilteredAOD("AliAOD.Dimuons.root", "DimuonEvents");
1d1ea3ce 205}
206
207
3d270be0 208//______________________________________________________________________________
1d1ea3ce 209void AliAnalysisTaskESDMuonFilter::UserExec(Option_t */*option*/)
210{
8dda6345 211 /// Execute analysis for current event
26ba01d4 212
1d1ea3ce 213 Long64_t ientry = Entry();
edee4062 214 if(fDebug)printf("Muon Filter: Analysing event # %5d\n", (Int_t) ientry);
aba11173 215
1d1ea3ce 216 ConvertESDtoAOD();
217}
218
3d270be0 219//______________________________________________________________________________
1d1ea3ce 220void AliAnalysisTaskESDMuonFilter::ConvertESDtoAOD()
221{
8dda6345 222 /// ESD Muon Filter analysis task executed for each event
dcc1f876 223
224 AliCodeTimerAuto("",0);
225
1d1ea3ce 226 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
6fa3e5c7 227 if (!esd)
228 {
229 AliError("Could not get input ESD event");
230 return;
fc3a4c45 231 }
6fa3e5c7 232
233 AliMCEventHandler *mcH = static_cast<AliMCEventHandler*>((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
fc3a4c45 234
1d1ea3ce 235 // Define arrays for muons
236 Double_t pos[3];
237 Double_t p[3];
76b98553 238 // Double_t pid[10];
aba11173 239
240 // has to be changed once the muon pid is provided by the ESD
76b98553 241 // for (Int_t i = 0; i < 10; pid[i++] = 0.) {}
242 // pid[AliAODTrack::kMuon]=1.;
aba11173 243
0a918d8d 244 AliAODHeader* header = dynamic_cast<AliAODHeader*>(AODEvent()->GetHeader());
245 if(!header) AliFatal("Not a standard AOD");
1d1ea3ce 246 AliAODTrack *aodTrack = 0x0;
aba11173 247 AliESDMuonTrack *esdMuTrack = 0x0;
248
1d1ea3ce 249 // Access to the AOD container of tracks
250 TClonesArray &tracks = *(AODEvent()->GetTracks());
7eb06a7f 251 Int_t jTracks = tracks.GetEntriesFast();
1d1ea3ce 252
253 // Read primary vertex from AOD event
aba11173 254 AliAODVertex *primary = AODEvent()->GetPrimaryVertex();
6fa3e5c7 255 if (fDebug && primary) primary->Print();
aba11173 256
f7cc8591 257 // ----------------- MUON TRACKS -----------------------------------------------------
258
1d1ea3ce 259 // Loop on muon tracks to fill the AOD track branch
260 Int_t nMuTracks = esd->GetNumberOfMuonTracks();
866d8d78 261
daf100e1 262 for (Int_t iTrack=0; iTrack<nMuTracks; ++iTrack) esd->GetMuonTrack(iTrack)->SetESDEvent(esd);
aba11173 263
264 // Update number of positive and negative tracks from AOD event (M.G.)
7eb06a7f 265 Int_t nTracks = header->GetRefMultiplicity();
1d1ea3ce 266 Int_t nPosTracks = header->GetRefMultiplicityPos();
267 Int_t nNegTracks = header->GetRefMultiplicityNeg();
aba11173 268
866d8d78 269 // Access to the AOD container of dimuons
270 TClonesArray &dimuons = *(AODEvent()->GetDimuons());
866d8d78 271
866d8d78 272 Int_t nMuons=0;
29e7e51b 273 Int_t nDimuons=0;
866d8d78 274 Int_t jDimuons=0;
397081d5 275 Int_t nMuonTrack[100];
6fa3e5c7 276 UChar_t itsClusMap(0);
87ac315c 277
397081d5 278 for(int imuon=0;imuon<100;imuon++) nMuonTrack[imuon]=0;
26ba01d4 279
280 for (Int_t nMuTrack = 0; nMuTrack < nMuTracks; ++nMuTrack)
281 {
aba11173 282 esdMuTrack = esd->GetMuonTrack(nMuTrack);
283
284 if (!esdMuTrack->ContainTrackerData()) continue;
daf100e1 285
6fa3e5c7 286 UInt_t selectInfo(0);
287
aba11173 288 // Track selection
289 if (fTrackFilter) {
290 selectInfo = fTrackFilter->IsSelected(esdMuTrack);
291 if (!selectInfo) {
292 continue;
293 }
87ac315c 294 }
26ba01d4 295
aba11173 296 p[0] = esdMuTrack->Px();
297 p[1] = esdMuTrack->Py();
298 p[2] = esdMuTrack->Pz();
299
300 pos[0] = esdMuTrack->GetNonBendingCoor();
301 pos[1] = esdMuTrack->GetBendingCoor();
302 pos[2] = esdMuTrack->GetZ();
303
6fa3e5c7 304 if (mcH) mcH->SelectParticle(esdMuTrack->GetLabel()); // to insure that particle's ancestors will be in output MC branches
fc3a4c45 305
aba11173 306 aodTrack = new(tracks[jTracks++]) AliAODTrack(esdMuTrack->GetUniqueID(), // ID
26ba01d4 307 esdMuTrack->GetLabel(), // label
308 p, // momentum
309 kTRUE, // cartesian coordinate system
310 pos, // position
311 kFALSE, // isDCA
312 0x0, // covariance matrix
313 esdMuTrack->Charge(), // charge
6fa3e5c7 314 itsClusMap, // ITSClusterMap
76b98553 315 //pid, // pid
26ba01d4 316 primary, // primary vertex
317 kFALSE, // used for vertex fit?
318 kFALSE, // used for primary vertex fit?
319 AliAODTrack::kPrimary,// track type
320 selectInfo);
aba11173 321
76b98553 322 aodTrack->SetPIDForTracking(AliPID::kMuon);
aba11173 323 aodTrack->SetXYAtDCA(esdMuTrack->GetNonBendingCoorAtDCA(), esdMuTrack->GetBendingCoorAtDCA());
324 aodTrack->SetPxPyPzAtDCA(esdMuTrack->PxAtDCA(), esdMuTrack->PyAtDCA(), esdMuTrack->PzAtDCA());
f43586f0 325 aodTrack->SetRAtAbsorberEnd(esdMuTrack->GetRAtAbsorberEnd());
aba11173 326 aodTrack->ConvertAliPIDtoAODPID();
327 aodTrack->SetChi2perNDF(esdMuTrack->GetChi2() / (2.*esdMuTrack->GetNHit() - 5.));
328 aodTrack->SetChi2MatchTrigger(esdMuTrack->GetChi2MatchTrigger());
329 aodTrack->SetHitsPatternInTrigCh(esdMuTrack->GetHitsPatternInTrigCh());
0a2dcc83 330 UInt_t pattern = esdMuTrack->GetHitsPatternInTrigCh();
331 AliESDMuonTrack::AddEffInfo(pattern, 0, esdMuTrack->LoCircuit(), (AliESDMuonTrack::EAliTriggerChPatternFlag)0);
ad30e3df 332 esdMuTrack->AddMuonTrigDevSignInfo(pattern);
0a2dcc83 333 aodTrack->SetMUONtrigHitsMapTrg(pattern);
334 aodTrack->SetMUONtrigHitsMapTrk(esdMuTrack->GetHitsPatternInTrigChTrk());
aba11173 335 aodTrack->SetMuonClusterMap(esdMuTrack->GetMuonClusterMap());
336 aodTrack->SetMatchTrigger(esdMuTrack->GetMatchTrigger());
5c15a68b 337 aodTrack->Connected(esdMuTrack->IsConnected());
aba11173 338 primary->AddDaughter(aodTrack);
339
7eb06a7f 340 ++nTracks;
aba11173 341 if (esdMuTrack->Charge() > 0) nPosTracks++;
342 else nNegTracks++;
866d8d78 343
ca3ff602 344 nMuonTrack[nMuons]= jTracks-1;
26ba01d4 345 ++nMuons;
87ac315c 346 }
26ba01d4 347
348 if(nMuons>=2)
349 {
350 for(int i=0;i<nMuons;i++){
351 Int_t index0 = nMuonTrack[i];
352 for(int j=i+1;j<nMuons;j++){
353 Int_t index1 = nMuonTrack[j];
76b26647 354 new(dimuons[jDimuons++]) AliAODDimuon(tracks.At(index0),tracks.At(index1));
26ba01d4 355 ++nDimuons;
356 if (fDebug > 1){
357 AliAODDimuon *dimuon0 = (AliAODDimuon*)dimuons.At(jDimuons-1);
358 printf("Dimuon: mass = %f, px=%f, py=%f, pz=%f\n",dimuon0->M(),dimuon0->Px(),dimuon0->Py(),dimuon0->Pz());
359 AliAODTrack *mu0 = (AliAODTrack*) dimuon0->GetMu(0);
360 AliAODTrack *mu1 = (AliAODTrack*) dimuon0->GetMu(1);
361 printf("Muon0 px=%f py=%f pz=%f\n",mu0->Px(),mu0->Py(),mu0->Pz());
362 printf("Muon1 px=%f py=%f pz=%f\n",mu1->Px(),mu1->Py(),mu1->Pz());
363 }
87ac315c 364 }
866d8d78 365 }
26ba01d4 366 }
367
aba11173 368
7eb06a7f 369 header->SetRefMultiplicity(nTracks);
1d1ea3ce 370 header->SetRefMultiplicityPos(nPosTracks);
371 header->SetRefMultiplicityNeg(nNegTracks);
29e7e51b 372 header->SetNumberOfMuons(nMuons);
373 header->SetNumberOfDimuons(nDimuons);
866d8d78 374
f7cc8591 375 // ----------------- MFT + MUON TRACKS -----------------------------------------------------
376
377 AliESDMuonGlobalTrack *esdMuGlobalTrack = 0x0;
378
379 // Loop on muon global tracks to fill the AOD track branch.
380 // We won't update the number of total, pos and neg tracks in the event
381
382 Int_t nMuGlobalTracks = esd->GetNumberOfMuonGlobalTracks();
383
384 for (Int_t iTrack=0; iTrack<nMuGlobalTracks; ++iTrack) esd->GetMuonGlobalTrack(iTrack)->SetESDEvent(esd);
385
386 Int_t nGlobalMuons=0;
387 Int_t nGlobalDimuons=0;
388 Int_t jGlobalDimuons=0;
389 Int_t nMuonGlobalTrack[100];
390 itsClusMap = 0;
391
393f6a0d 392 for (Int_t iMuon=0; iMuon<100; iMuon++) nMuonGlobalTrack[iMuon]=0; // position of the i-th muon track in the tracks array of the AOD event
393
f7cc8591 394 for (Int_t nMuTrack=0; nMuTrack<nMuGlobalTracks; ++nMuTrack) {
395
396 esdMuGlobalTrack = esd->GetMuonGlobalTrack(nMuTrack);
397
398 if (!esdMuGlobalTrack->ContainTrackerData()) continue;
399
400 UInt_t selectInfo(0);
401
402 // Track selection
403 if (fTrackFilter) {
393f6a0d 404 selectInfo = fTrackFilter->IsSelected(esdMuGlobalTrack);
405 if (!selectInfo) {
406 continue;
407 }
f7cc8591 408 }
409
410 p[0] = esdMuGlobalTrack->Px();
411 p[1] = esdMuGlobalTrack->Py();
412 p[2] = esdMuGlobalTrack->Pz();
413
414 esdMuGlobalTrack -> GetFirstTrackingPoint(pos);
415
416 if (mcH) mcH->SelectParticle(esdMuGlobalTrack->GetLabel()); // to insure that particle's ancestors will be in output MC branches
9562d53c 417
418 Double_t covTr[21] = {0};
b3208446 419 ConvertCovMatrixMUON2AOD(esdMuGlobalTrack->GetCovariances(), covTr);
f7cc8591 420
421 aodTrack = new(tracks[jTracks++]) AliAODTrack(esdMuGlobalTrack->GetUniqueID(), // ID
422 esdMuGlobalTrack->GetLabel(), // label
423 p, // momentum
424 kTRUE, // cartesian coordinate system
425 pos, // position
426 kFALSE, // isDCA
9562d53c 427 covTr, // covariance matrix
f7cc8591 428 esdMuGlobalTrack->Charge(), // charge
429 itsClusMap, // ITSClusterMap
393f6a0d 430 primary, // origin vertex
f7cc8591 431 kFALSE, // used for vertex fit?
432 kFALSE, // used for primary vertex fit?
433 AliAODTrack::kPrimary, // track type
393f6a0d 434 selectInfo);
435
9562d53c 436
437 aodTrack->SetPIDForTracking(AliPID::kMuon);
438
f7cc8591 439 Double_t xyAtVertex[2] = {0};
440 esdMuGlobalTrack -> GetXYAtVertex(xyAtVertex);
441
442 aodTrack->SetIsMuonGlobalTrack(kTRUE);
443
393f6a0d 444 aodTrack->SetMFTClusterPattern(esdMuGlobalTrack->GetMFTClusterPattern());
f7cc8591 445 aodTrack->SetXYAtDCA(xyAtVertex[0], xyAtVertex[1]);
446 aodTrack->SetPxPyPzAtDCA(p[0], p[1], p[2]);
447 aodTrack->SetRAtAbsorberEnd(esdMuGlobalTrack->GetRAtAbsorberEnd());
448 aodTrack->ConvertAliPIDtoAODPID();
449 aodTrack->SetChi2perNDF(esdMuGlobalTrack->GetChi2OverNdf());
450 aodTrack->SetChi2MatchTrigger(esdMuGlobalTrack->GetChi2MatchTrigger());
451 aodTrack->SetHitsPatternInTrigCh(esdMuGlobalTrack->GetHitsPatternInTrigCh());
452 UInt_t pattern = esdMuGlobalTrack->GetHitsPatternInTrigCh();
453 AliESDMuonTrack::AddEffInfo(pattern, 0, esdMuGlobalTrack->GetLoCircuit(), (AliESDMuonTrack::EAliTriggerChPatternFlag)0);
ad30e3df 454// esdMuGlobalTrack->AddTrigDevSignInfo(pattern);
f7cc8591 455 aodTrack->SetMUONtrigHitsMapTrg(pattern);
456 aodTrack->SetMUONtrigHitsMapTrk(esdMuGlobalTrack->GetHitsPatternInTrigChTrk());
457 aodTrack->SetMuonClusterMap(esdMuGlobalTrack->GetMuonClusterMap());
458 aodTrack->SetMatchTrigger(esdMuGlobalTrack->GetMatchTrigger());
459 aodTrack->Connected(esdMuGlobalTrack->IsConnected());
460
461 printf("Added Muon Global Track %d of %d\n",nMuTrack,nMuGlobalTracks);
462 aodTrack->Print(); // to be removed!!!
463
464 primary->AddDaughter(aodTrack);
465
466 nMuonGlobalTrack[nGlobalMuons] = jTracks-1;
467 ++nGlobalMuons;
468 }
393f6a0d 469
f7cc8591 470 if (nGlobalMuons >= 2) {
471 for (Int_t i=0; i<nGlobalMuons; i++) {
472 Int_t index0 = nMuonGlobalTrack[i];
473 for (Int_t j=i+1; j<nGlobalMuons; j++) {
474 Int_t index1 = nMuonGlobalTrack[j];
475 new (dimuons[jGlobalDimuons++]) AliAODDimuon(tracks.At(index0), tracks.At(index1));
476 ++nDimuons;
477 if (fDebug > 1) {
478 AliAODDimuon *dimuon0 = (AliAODDimuon*)dimuons.At(jGlobalDimuons-1);
479 printf("Dimuon: mass = %f, px=%f, py=%f, pz=%f\n",dimuon0->M(),dimuon0->Px(),dimuon0->Py(),dimuon0->Pz());
480 AliAODTrack *mu0 = (AliAODTrack*) dimuon0->GetMu(0);
481 AliAODTrack *mu1 = (AliAODTrack*) dimuon0->GetMu(1);
482 printf("Muon0 px=%f py=%f pz=%f\n",mu0->Px(),mu0->Py(),mu0->Pz());
483 printf("Muon1 px=%f py=%f pz=%f\n",mu1->Px(),mu1->Py(),mu1->Pz());
484 }
485 }
486 }
487 }
488
489 header->SetNumberOfGlobalMuons(nGlobalMuons);
490 header->SetNumberOfGlobalDimuons(nGlobalDimuons);
491
492 // -----------------------------------------------------------------------
493
6fa3e5c7 494 AliAODHandler* handler = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
495
496 if ( handler && fEnableMuonAOD && ( (nMuons>0) || fKeepAllEvents ) )
26ba01d4 497 {
6fa3e5c7 498 AliAODExtension *extMuons = handler->GetFilteredAOD("AliAOD.Muons.root");
499 if ( extMuons ) extMuons->SelectEvent();
866d8d78 500 }
26ba01d4 501
6fa3e5c7 502 if ( handler && fEnableDimuonAOD && ( (nMuons>1) || fKeepAllEvents ) )
26ba01d4 503 {
6fa3e5c7 504 AliAODExtension *extDimuons = handler->GetFilteredAOD("AliAOD.Dimuons.root");
505 if ( extDimuons ) extDimuons->SelectEvent();
f785fc59 506 }
26ba01d4 507
1d1ea3ce 508}
b3208446 509
510//====================================================================================================================================================
511
512void AliAnalysisTaskESDMuonFilter::ConvertCovMatrixMUON2AOD(const TMatrixD& covMUON, Double_t covAOD[21]) {
513
514 // Converts the cov matrix from the MUON format (TMatrixD) to the AOD one (Double_t[21])
515 //
516 // Cov(x,x) ... : cv[0]
517 // Cov(x,slopeX) ... : cv[1] cv[2]
518 // Cov(x,y) ... : cv[3] cv[4] cv[5]
519 // Cov(x,slopeY) ... : cv[6] cv[7] cv[8] cv[9]
520 // Cov(x,invP_yz) ... : cv[10] cv[11] cv[12] cv[13] cv[14]
521 // not-used ... : cv[15] cv[16] cv[17] cv[18] cv[19] cv[20]
522
523 covAOD[0] = covMUON(0,0);
524
525 covAOD[1] = covMUON(1,0);
526 covAOD[2] = covMUON(1,1);
527
528 covAOD[3] = covMUON(2,0);
529 covAOD[4] = covMUON(2,1);
530 covAOD[5] = covMUON(2,2);
531
532 covAOD[6] = covMUON(3,0);
533 covAOD[7] = covMUON(3,1);
534 covAOD[8] = covMUON(3,2);
535 covAOD[9] = covMUON(3,3);
536
537 covAOD[10] = covMUON(4,0);
538 covAOD[11] = covMUON(4,1);
539 covAOD[12] = covMUON(4,2);
540 covAOD[13] = covMUON(4,3);
541 covAOD[14] = covMUON(4,4);
542
543 covAOD[15] = 0;
544 covAOD[16] = 0;
545 covAOD[17] = 0;
546 covAOD[18] = 0;
547 covAOD[19] = 0;
548 covAOD[20] = 0;
549
550}
551
552//====================================================================================================================================================