AliRoot Core  3dc7879 (3dc7879)
AliAnalysisTaskSE.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, 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 #include <TROOT.h>
17 #include <TSystem.h>
18 #include <TInterpreter.h>
19 #include <TChain.h>
20 #include <TFile.h>
21 #include <TList.h>
22 
23 #include "AliAnalysisTaskSE.h"
24 #include "AliAnalysisManager.h"
25 #include "AliAnalysisCuts.h"
26 #include "AliAnalysisDataSlot.h"
28 
29 
30 #include "AliVfriendEvent.h"
31 #include "AliVEventHandler.h"
32 #include "AliESDEvent.h"
33 #include "AliESDfriend.h"
34 #include "AliESD.h"
35 #include "AliAODEvent.h"
36 #include "AliAODHeader.h"
37 #include "AliAODVZERO.h"
38 #include "AliTOFHeader.h"
39 #include "AliAODTracklets.h"
40 #include "AliAODCaloCells.h"
41 #include "AliAODCaloTrigger.h"
42 #include "AliAODMCParticle.h"
43 #include "AliVEvent.h"
44 #include "AliAODHandler.h"
45 #include "AliAODInputHandler.h"
46 #include "AliMCEventHandler.h"
47 #include "AliInputEventHandler.h"
49 #include "AliESDInputHandler.h"
50 #include "AliMCEvent.h"
51 #include "AliStack.h"
53 #include "AliVTrackSelection.h"
54 #include "AliLog.h"
55 #include "AliAODDimuon.h"
56 
57 
58 ClassImp(AliAnalysisTaskSE)
59 
60 
62 AliAODHeader* AliAnalysisTaskSE::fgAODHeader = NULL;
63 AliTOFHeader* AliAnalysisTaskSE::fgTOFHeader = NULL;
64 AliAODVZERO* AliAnalysisTaskSE::fgAODVZERO = NULL;
65 TClonesArray* AliAnalysisTaskSE::fgAODTracks = NULL;
66 TClonesArray* AliAnalysisTaskSE::fgAODVertices = NULL;
67 TClonesArray* AliAnalysisTaskSE::fgAODV0s = NULL;
68 TClonesArray* AliAnalysisTaskSE::fgAODPMDClusters = NULL;
69 TClonesArray* AliAnalysisTaskSE::fgAODJets = NULL;
70 TClonesArray* AliAnalysisTaskSE::fgAODFMDClusters = NULL;
71 TClonesArray* AliAnalysisTaskSE::fgAODCaloClusters = NULL;
72 TClonesArray* AliAnalysisTaskSE::fgAODMCParticles = NULL;
73 AliAODTracklets* AliAnalysisTaskSE::fgAODTracklets = NULL;
74 AliAODCaloCells* AliAnalysisTaskSE::fgAODEmcalCells = NULL;
75 AliAODCaloCells* AliAnalysisTaskSE::fgAODPhosCells = NULL;
76 AliAODCaloTrigger* AliAnalysisTaskSE::fgAODEMCALTrigger = NULL;
77 AliAODCaloTrigger* AliAnalysisTaskSE::fgAODPHOSTrigger = NULL;
78 TClonesArray* AliAnalysisTaskSE::fgAODDimuons = NULL;
79 TClonesArray* AliAnalysisTaskSE::fgAODHmpidRings = NULL;
80 
83  fDebug(0),
84  fEntry(0),
85  fInputEvent(0x0),
86  fESDfriend(0x0),
87  fInputHandler(0x0),
88  fOutputAOD(0x0),
89  fMCEvent(0x0),
90  fTreeA(0x0),
91  fCurrentRunNumber(-1),
92  fHistosQA(0x0),
93  fOfflineTriggerMask(0),
94  fMultiInputHandler(0),
95  fMCEventHandler(0),
96  fTrackSelectionFactory(0),
97  fTrackSelection(0)
98 {
100 
101 }
102 
104  AliAnalysisTask(name, "AnalysisTaskSE"),
105  fDebug(0),
106  fEntry(0),
107  fInputEvent(0x0),
108  fESDfriend(0x0),
109  fInputHandler(0x0),
110  fOutputAOD(0x0),
111  fMCEvent(0x0),
112  fTreeA(0x0),
113  fCurrentRunNumber(-1),
114  fHistosQA(0x0),
115  fOfflineTriggerMask(0),
116  fMultiInputHandler(0),
117  fMCEventHandler(0),
118  fTrackSelectionFactory(0),
119  fTrackSelection(0)
120 {
122 
123  DefineInput (0, TChain::Class());
124  DefineOutput(0, TTree::Class());
125 }
126 
128  AliAnalysisTask(obj),
129  fDebug(0),
130  fEntry(0),
131  fInputEvent(0x0),
132  fESDfriend(0x0),
133  fInputHandler(0x0),
134  fOutputAOD(0x0),
135  fMCEvent(0x0),
136  fTreeA(0x0),
137  fCurrentRunNumber(-1),
138  fHistosQA(0x0),
144 {
146 
147  fDebug = obj.fDebug;
148  fEntry = obj.fEntry;
149  fInputEvent = obj.fInputEvent;
150  fESDfriend = obj.fESDfriend;
152  fOutputAOD = obj.fOutputAOD;
153  fMCEvent = obj.fMCEvent;
154  fTreeA = obj.fTreeA;
156  fHistosQA = obj.fHistosQA;
157 
158 }
159 
160 
162 {
164 
165  if(&other == this) return *this;
167 
169  fDebug = other.fDebug;
170  fEntry = other.fEntry;
171  fInputEvent = other.fInputEvent;
172  fESDfriend = other.fESDfriend;
174  fOutputAOD = other.fOutputAOD;
175  fMCEvent = other.fMCEvent;
176  fTreeA = other.fTreeA;
178  fHistosQA = other.fHistosQA;
184  return *this;
185 }
186 
187 //______________________________________________________________________________
188 void AliAnalysisTaskSE::ConnectInputData(Option_t* /*option*/)
189 {
191 
192  if (fDebug > 1) printf("AnalysisTaskSE::ConnectInputData() \n");
193 
194  // Connect input handlers (multi input handler is handled)
196  AliInfo(Form("fInputHandler: %p",fInputHandler));
197  if (fInputHandler && fInputHandler->GetTree()) {
198  if (fInputHandler->GetTree()->GetBranch("ESDfriend.")) {
199  fESDfriend = ((AliESDInputHandler*)fInputHandler)->GetESDfriend();
200  }
201 
203  } else if( fMCEvent ) {
204  AliWarning("No Input Event Handler connected, only MC Truth Event Handler") ;
205  } else {
206  AliError("No Input Event Handler connected") ;
207  return ;
208  }
209  // Disconnect multi handler
211 }
212 
214 {
218 
219  if (fDebug > 1) printf("AnalysisTaskSE::CreateOutPutData() \n");
220 
221  AliAODHandler* handler = dynamic_cast<AliAODHandler*>
222  ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
223 
224  Bool_t merging = kFALSE;
225  AliAODInputHandler* aodIH = static_cast<AliAODInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
226  if (aodIH) {
227  if (aodIH->GetMergeEvents()) merging = kTRUE;
228  }
229 
230  // Check if AOD replication has been required
231  if (handler) {
232  fOutputAOD = handler->GetAOD();
233  fTreeA = handler->GetTree();
234  if (fOutputAOD && !(handler->IsStandard())) {
235  if ((handler->NeedsHeaderReplication() || merging) && !(fgAODHeader))
236  {
237  if (fDebug > 1) AliInfo("Replicating header");
239  handler->AddBranch("AliAODHeader", &fgAODHeader);
240  }
241  if ((handler->NeedsTOFHeaderReplication() || merging) && !(fgTOFHeader))
242  {
243  if (fDebug > 1) AliInfo("Replicating TOFheader");
245  handler->AddBranch("AliTOFHeader", &fgTOFHeader);
246  }
247  if ((handler->NeedsVZEROReplication() || merging) && !(fgAODVZERO))
248  {
249  if (fDebug > 1) AliInfo("Replicating VZERO");
250  fgAODVZERO = new AliAODVZERO;
251  handler->AddBranch("AliAODVZERO", &fgAODVZERO);
252  }
253 
254  if ((handler->NeedsTracksBranchReplication() || merging) && !(fgAODTracks))
255  {
256  if (fDebug > 1) AliInfo("Replicating track branch\n");
257  fgAODTracks = new TClonesArray("AliAODTrack",500);
258  fgAODTracks->SetName("tracks");
259  handler->AddBranch("TClonesArray", &fgAODTracks);
260  }
261  if ((handler->NeedsVerticesBranchReplication() || merging) && !(fgAODVertices))
262  {
263  if (fDebug > 1) AliInfo("Replicating vertices branch\n");
264  fgAODVertices = new TClonesArray("AliAODVertex",500);
265  fgAODVertices->SetName("vertices");
266  handler->AddBranch("TClonesArray", &fgAODVertices);
267  }
268  if ((handler->NeedsV0sBranchReplication()) && !(fgAODV0s))
269  {
270  if (fDebug > 1) AliInfo("Replicating V0s branch\n");
271  fgAODV0s = new TClonesArray("AliAODv0",500);
272  fgAODV0s->SetName("v0s");
273  handler->AddBranch("TClonesArray", &fgAODV0s);
274  }
275  if ((handler->NeedsTrackletsBranchReplication()) && !(fgAODTracklets))
276  {
277  if (fDebug > 1) AliInfo("Replicating Tracklets branch\n");
278  fgAODTracklets = new AliAODTracklets("tracklets","tracklets");
279  handler->AddBranch("AliAODTracklets", &fgAODTracklets);
280  }
281  if ((handler->NeedsPMDClustersBranchReplication()) && !(fgAODPMDClusters))
282  {
283  if (fDebug > 1) AliInfo("Replicating PMDClusters branch\n");
284  fgAODPMDClusters = new TClonesArray("AliAODPmdCluster",500);
285  fgAODPMDClusters->SetName("pmdClusters");
286  handler->AddBranch("TClonesArray", &fgAODPMDClusters);
287  }
288  if ((handler->NeedsJetsBranchReplication() || merging) && !(fgAODJets))
289  {
290  if (fDebug > 1) AliInfo("Replicating Jets branch\n");
291  fgAODJets = new TClonesArray("AliAODJet",500);
292  fgAODJets->SetName("jets");
293  handler->AddBranch("TClonesArray", &fgAODJets);
294  }
295  if ((handler->NeedsFMDClustersBranchReplication()) && !(fgAODFMDClusters))
296  {
297  AliInfo("Replicating FMDClusters branch\n");
298  fgAODFMDClusters = new TClonesArray("AliAODFmdCluster",500);
299  fgAODFMDClusters->SetName("fmdClusters");
300  handler->AddBranch("TClonesArray", &fgAODFMDClusters);
301  }
302  if ((handler->NeedsCaloClustersBranchReplication() || merging) && !(fgAODCaloClusters))
303  {
304  if (fDebug > 1) AliInfo("Replicating CaloClusters branch\n");
305  fgAODCaloClusters = new TClonesArray("AliAODCaloCluster",500);
306  fgAODCaloClusters->SetName("caloClusters");
307  handler->AddBranch("TClonesArray", &fgAODCaloClusters);
308 
309  fgAODEmcalCells = new AliAODCaloCells("emcalCells","emcalCells",AliVCaloCells::kEMCALCell);
310  handler->AddBranch("AliAODCaloCells", &fgAODEmcalCells);
311 
312  fgAODPhosCells = new AliAODCaloCells("phosCells","phosCells",AliVCaloCells::kPHOSCell);
313  handler->AddBranch("AliAODCaloCells", &fgAODPhosCells);
314  }
315  if ((handler->NeedsCaloTriggerBranchReplication() || merging) && !(fgAODEMCALTrigger))
316  {
317  if (fDebug > 1) AliInfo("Replicating EMCAL Calo Trigger branches\n");
318  fgAODEMCALTrigger = new AliAODCaloTrigger("emcalTrigger","emcalTrigger");
319  handler->AddBranch("AliAODCaloTrigger", &fgAODEMCALTrigger);
320  }
321  if ((handler->NeedsCaloTriggerBranchReplication() || merging) && !(fgAODPHOSTrigger))
322  {
323  if (fDebug > 1) AliInfo("Replicating PHOS Calo Trigger branches\n");
324  fgAODPHOSTrigger = new AliAODCaloTrigger("phosTrigger","phosTrigger");
325  handler->AddBranch("AliAODCaloTrigger", &fgAODPHOSTrigger);
326  }
327  if ((handler->NeedsMCParticlesBranchReplication() || merging) && !(fgAODMCParticles))
328  {
329  if (fDebug > 1) AliInfo("Replicating MCParticles branch\n");
330  fgAODMCParticles = new TClonesArray("AliAODMCParticle",500);
331  fgAODMCParticles->SetName("mcparticles");
332  handler->AddBranch("TClonesArray", &fgAODMCParticles);
333  }
334  if ((handler->NeedsDimuonsBranchReplication() || merging) && !(fgAODDimuons))
335  {
336  if (fDebug > 1) AliInfo("Replicating dimuon branch\n");
337  fgAODDimuons = new TClonesArray("AliAODDimuon",0);
338  fgAODDimuons->SetName("dimuons");
339  handler->AddBranch("TClonesArray", &fgAODDimuons);
340  }
341  if ((handler->NeedsHMPIDBranchReplication() || merging) && !(fgAODHmpidRings))
342  {
343  if (fDebug > 1) AliInfo("Replicating HMPID branch\n");
344  fgAODHmpidRings = new TClonesArray("AliAODHMPIDrings",0);
345  fgAODHmpidRings->SetName("hmpidRings");
346  handler->AddBranch("TClonesArray", &fgAODHmpidRings);
347  }
348 
349 
350  // cache the pointerd in the AODEvent
352  }
353  }
354 
357  AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()->IsA() == AliAODInputHandler::Class() ?
360  );
364 }
365 
366 void AliAnalysisTaskSE::Exec(Option_t* option)
367 {
369 
372  if (mgr->GetDebugLevel() > 1) {
373  if (!mgr->GetTopTasks()->FindObject(this))
374  printf(" -> Executing sub-task %s\n", GetName());
375  }
376  if ( fDebug >= 10)
377  printf("Task is active %5d\n", IsActive());
378 
379  if (fDebug > 1) AliInfo("AliAnalysisTaskSE::Exec() \n");
380 //
381  AliAODHandler* handler = dynamic_cast<AliAODHandler*>(mgr->GetOutputEventHandler());
382 
383  AliAODInputHandler* aodH = dynamic_cast<AliAODInputHandler*>(fInputHandler);
384 //
385 // Was event selected ? If no event selection mechanism, the event SHOULD be selected (AG)
386  UInt_t isSelected = AliVEvent::kAny;
387  if( fInputHandler ) {
388  TObject* tmp = fInputHandler->GetEventSelection();
389  if( tmp || aodH) {
390  // Get the actual offline trigger mask for the event and AND it with the
391  // requested mask. If no mask requested select by default the event.
394  }
395  }
396 // Functionality below moved in the filter tasks (AG)
397 // if (handler) handler->SetFillAOD(isSelected);
398 
399  if( fInputHandler ) {
402  }
403 
404 
405  // Notify the change of run number
406  if (InputEvent() && (InputEvent()->GetRunNumber() != fCurrentRunNumber)) {
408  NotifyRun();
409  } else if( fMCEvent )
410  fEntry = fMCEvent->Header()->GetEvent();
411 
412  if ( !((Entry()-1)%100) && fDebug > 0)
413  AliInfo(Form("%s ----> Processing event # %lld", CurrentFileName(), Entry()));
414 
415  if (aodH) fMCEvent = aodH->MCEvent();
416 
417  if (handler && aodH) {
418  Bool_t merging = aodH->GetMergeEvents();
419  // Do not analyze merged events if last embedded file has less events than normal event,
420  // skip analysis after last embeded event
421  if(merging){
422  if(aodH->GetReadEntry() + aodH->GetMergeOffset() >= aodH->GetTreeToMerge()->GetEntriesFast()){
423  // Do I need to add the lines before the return?
424  // Added protection in case the derived task is not an AOD producer.
426  if (out0 && out0->IsConnected()) PostData(0, fTreeA);
428  return;
429  }
430  }
431 
432  AliAODEvent* aod = dynamic_cast<AliAODEvent*>(InputEvent());
433 
434  if (aod && !(handler->IsStandard()) && !(handler->AODIsReplicated())) {
435  if ((handler->NeedsHeaderReplication() || merging) && (fgAODHeader))
436  {
437  // copy the contents by assigment
438  *fgAODHeader = *((AliAODHeader*)aod->GetHeader());
439  }
440  if ((handler->NeedsTOFHeaderReplication() || merging) && (fgTOFHeader))
441  {
442  if (aod->GetTOFHeader()) *fgTOFHeader = *(aod->GetTOFHeader());
443  }
444  if ((handler->NeedsVZEROReplication() || merging) && (fgAODVZERO) && aod->GetVZEROData())
445  {
446  *fgAODVZERO = *(aod->GetVZEROData());
447  }
448 
449  if ((handler->NeedsTracksBranchReplication() || (merging && aodH->GetMergeTracks())) && (fgAODTracks))
450  {
451  TClonesArray* tracks = aod->GetTracks();
452  new (fgAODTracks) TClonesArray(*tracks);
453  }
454  if ((handler->NeedsVerticesBranchReplication() || merging) && (fgAODVertices))
455  {
456  TClonesArray* vertices = aod->GetVertices();
457  new (fgAODVertices) TClonesArray(*vertices);
458  }
459  if ((handler->NeedsV0sBranchReplication()) && (fgAODV0s))
460  {
461  TClonesArray* v0s = aod->GetV0s();
462  new (fgAODV0s) TClonesArray(*v0s);
463  }
464  if ((handler->NeedsTrackletsBranchReplication()) && (fgAODTracklets))
465  {
466  *fgAODTracklets = *aod->GetTracklets();
467  }
469  {
470  TClonesArray* pmdClusters = aod->GetPmdClusters();
471  new (fgAODPMDClusters) TClonesArray(*pmdClusters);
472  }
473  if ((handler->NeedsJetsBranchReplication() || (merging &&aodH->GetMergeTracks())) && (fgAODJets))
474  {
475  TClonesArray* jets = aod->GetJets();
476  new (fgAODJets) TClonesArray(*jets);
477  }
479  {
480  TClonesArray* fmdClusters = aod->GetFmdClusters();
481  new (fgAODFMDClusters) TClonesArray(*fmdClusters);
482  }
483  if ((handler->NeedsCaloClustersBranchReplication() ||
484  (merging && (aodH->GetMergeEMCALClusters() || aodH->GetMergePHOSClusters())))
485  && (fgAODCaloClusters))
486  {
487  TClonesArray* caloClusters = aod->GetCaloClusters();
488  new (fgAODCaloClusters) TClonesArray(*caloClusters);
489  }
490 
491  if ((handler->NeedsMCParticlesBranchReplication() || merging) && (fgAODMCParticles))
492  {
493  TClonesArray* mcParticles = (TClonesArray*) (aod->FindListObject("mcparticles"));
494  if( mcParticles )
495  new (fgAODMCParticles) TClonesArray(*mcParticles);
496  }
497 
498  if ((handler->NeedsDimuonsBranchReplication() || (merging && aodH->GetMergeTracks())) && (fgAODDimuons))
499  {
500  fgAODDimuons->Clear();
501  TClonesArray& dimuons = *fgAODDimuons;
502  TClonesArray& tracksnew = *fgAODTracks;
503 
504  Int_t nMuonTrack[100];
505  for(Int_t imuon = 0; imuon < 100; imuon++) nMuonTrack[imuon] = 0;
506  Int_t nMuons=0;
507  for(Int_t ii=0; ii < fgAODTracks->GetEntries(); ii++){
509  if(track->IsMuonTrack()) {
510  nMuonTrack[nMuons]= ii;
511  nMuons++;
512  }
513  }
514  Int_t jDimuons=0;
515  if(nMuons >= 2){
516  for(Int_t i = 0; i < nMuons; i++){
517  Int_t index0 = nMuonTrack[i];
518  for(Int_t j = i+1; j < nMuons; j++){
519  Int_t index1 = nMuonTrack[j];
520  tracksnew.At(index0)->ResetBit(kIsReferenced);
521  tracksnew.At(index0)->SetUniqueID(0);
522  tracksnew.At(index1)->ResetBit(kIsReferenced);
523  tracksnew.At(index1)->SetUniqueID(0);
524  new(dimuons[jDimuons++]) AliAODDimuon(tracksnew.At(index0),tracksnew.At(index1));
525  }
526  }
527  }
528  }
529  if ((handler->NeedsHMPIDBranchReplication()) && (fgAODHmpidRings))
530  {
531  TClonesArray* hmpidRings = aod->GetHMPIDrings();
532  new (fgAODHmpidRings) TClonesArray(*hmpidRings);
533  }
534 
535 
536 
537  // Additional merging if needed
538  if (merging) {
539  Int_t nc;
540 
541  // mcParticles
542  TClonesArray* mcparticles = (TClonesArray*) ((aodH->GetEventToMerge())->FindListObject("mcparticles"));
543  if( mcparticles ){
544  Int_t npart = mcparticles->GetEntries();
545  nc = fgAODMCParticles->GetEntries();
546 
547  for (Int_t i = 0; i < npart; i++) {
548  AliAODMCParticle* particle = (AliAODMCParticle*) mcparticles->At(i);
549  new((*fgAODMCParticles)[nc++]) AliAODMCParticle(*particle);
550  }
551  }
552 
553  // tracks
554  TClonesArray* tracks = aodH->GetEventToMerge()->GetTracks();
555  if(tracks && aodH->GetMergeTracks()){
556  Int_t ntr = tracks->GetEntries();
557  nc = fgAODTracks->GetEntries();
558  for (Int_t i = 0; i < ntr; i++) {
559  AliAODTrack* track = (AliAODTrack*) tracks->At(i);
560  AliAODTrack* newtrack = new((*fgAODTracks)[nc++]) AliAODTrack(*track);
561  newtrack->SetLabel(newtrack->GetLabel() + fgAODMCParticles->GetEntries());
562  }
563 
564  for (Int_t i = 0; i < nc; i++)
565  {
567  track->ResetBit(kIsReferenced);
568  track->SetUniqueID(0);
569  }
570  }
571 
572  // clusters
573  TClonesArray* clusters = aodH->GetEventToMerge()->GetCaloClusters();
574  if( clusters && (aodH->GetMergeEMCALClusters() || aodH->GetMergePHOSClusters())) {
575  Int_t ncl = clusters->GetEntries();
576  nc = fgAODCaloClusters->GetEntries();
577  for (Int_t i = 0; i < ncl; i++) {
578  AliAODCaloCluster* cluster = (AliAODCaloCluster*) clusters->At(i);
579  if(cluster->IsEMCAL() && !aodH->GetMergeEMCALClusters() ) continue;
580  if(cluster->IsPHOS() && !aodH->GetMergePHOSClusters() ) continue;
581  new((*fgAODCaloClusters)[nc++]) AliAODCaloCluster(*cluster);
582  }
583  }
584 
585  // EMCAL cells
586  //*fgAODEmcalCells = *(aod->GetEMCALCells()); // This will be valid after 10.Mar.2011.
587  if(aodH->GetMergeEMCALCells())
588  {
589  AliAODCaloCells* copycells = aod->GetEMCALCells();
591  nc = copycells->GetNumberOfCells();
592 
593  while( nc-- ){ fgAODEmcalCells->SetCell(nc,copycells->GetCellNumber(nc),copycells->GetAmplitude(nc),
594  copycells->GetTime(nc),copycells->GetMCLabel(nc),copycells->GetEFraction(nc)); }
595 
596  AliAODCaloCells* cellsA = aodH->GetEventToMerge()->GetEMCALCells();
597  if( cellsA )
598  {
599  Int_t ncells = cellsA->GetNumberOfCells();
601 
602  for (Int_t i = 0; i < ncells; i++)
603  {
604  Int_t cn = cellsA->GetCellNumber(i);
605  Int_t pos = fgAODEmcalCells->GetCellPosition(cn);
606 
607  if (pos >= 0)
608  {
609  Double_t amp = cellsA->GetAmplitude(i) + fgAODEmcalCells->GetAmplitude(pos);
610 
611  //Check if it is MC, depending on that assing the mc lable, time and e fraction
612 // Double_t time = 0;
613  Int_t mclabel =-1;
614  Double_t efrac = 0;
615  if(cellsA->GetMCLabel(i) >= 0 && fgAODEmcalCells->GetMCLabel(pos) < 0)
616  {
617  mclabel = cellsA->GetMCLabel(i) ;
618 // time = fgAODEmcalCells->GetTime(pos) ; // Time from data
619  if(amp > 0) efrac = cellsA->GetAmplitude(i) / amp;
620  }
621  else if(fgAODEmcalCells->GetMCLabel(pos) >= 0 && cellsA->GetMCLabel(i) < 0)
622  {
623  mclabel = fgAODEmcalCells->GetMCLabel(pos) ;
624 // time = cellsA->GetTime(i) ; // Time from data
625  if(amp > 0) efrac = fgAODEmcalCells->GetAmplitude(pos) / amp;
626  }
627  else
628  { // take all from input
629  mclabel = cellsA->GetMCLabel(i) ;
630 // time = cellsA->GetTime(i) ;
631  if(amp > 0) efrac = cellsA->GetAmplitude(i) / amp;
632  }
633 
634  fgAODEmcalCells->SetCell(pos, cn, amp,cellsA->GetTime(i),mclabel,efrac);
635 
636  } else
637  {
638  AliAODCaloCells* copycells1 = new AliAODCaloCells(*fgAODEmcalCells);
640  Int_t nn = copycells1->GetNumberOfCells();
641 
642  while( nn-- ){ fgAODEmcalCells->SetCell(nn,copycells1->GetCellNumber(nn),copycells1->GetAmplitude(nn),
643  copycells1->GetTime(nn),copycells1->GetMCLabel(nn),copycells1->GetEFraction(nn)); }
644 
645  fgAODEmcalCells->SetCell(nc++,cn,cellsA->GetAmplitude(i),cellsA->GetTime(i), cellsA->GetMCLabel(i),1.);
646 
647  delete copycells1;
648  }
649  }
651  }
652  } // merge emcal cells
653 
654 
655  // PHOS cells
656  //*fgAODPhosCells = *(aod->GetPHOSCells()); // This will be valid after 10.Mar.2011.
657  if(aodH->GetMergePHOSCells())
658  {
659  AliAODCaloCells* copycells = aod->GetPHOSCells();
661  nc = copycells->GetNumberOfCells();
662 
663  while( nc-- ){ fgAODPhosCells->SetCell(nc,copycells->GetCellNumber(nc),copycells->GetAmplitude(nc),
664  copycells->GetTime(nc),copycells->GetMCLabel(nc),copycells->GetEFraction(nc)); }
665 
666  AliAODCaloCells* cellsP = aodH->GetEventToMerge()->GetPHOSCells();
667  if( cellsP )
668  {
669  Int_t ncellsP = cellsP->GetNumberOfCells();
671 
672  for (Int_t i = 0; i < ncellsP; i++)
673  {
674  Int_t cn = cellsP->GetCellNumber(i);
675  Int_t pos = fgAODPhosCells->GetCellPosition(cn);
676 
677  if (pos >= 0)
678  {
679  Double_t amp = cellsP->GetAmplitude(i) + fgAODPhosCells->GetAmplitude(pos);
680 
681  //Check if it is MC, depending on that assing the mc lable, time and e fraction
682 // Double_t time = 0;
683  Int_t mclabel =-1;
684  Double_t efrac = 0;
685  if(cellsP->GetMCLabel(i) >= 0 && fgAODPhosCells->GetMCLabel(pos) < 0)
686  {
687  mclabel = cellsP->GetMCLabel(i) ;
688 // time = fgAODPhosCells->GetTime(pos) ; // Time from data
689  if(amp > 0) efrac = cellsP->GetAmplitude(i) / amp;
690  }
691  else if(fgAODPhosCells->GetMCLabel(pos) >= 0 && cellsP->GetMCLabel(i) < 0)
692  {
693  mclabel = fgAODPhosCells->GetMCLabel(pos) ;
694 // time = cellsP->GetTime(i) ; // Time from data
695  if(amp > 0) efrac = fgAODPhosCells->GetAmplitude(pos) / amp;
696  }
697  else
698  { // take all from input
699  mclabel = cellsP->GetMCLabel(i) ;
700 // time = cellsP->GetTime(i) ;
701  if(amp > 0) efrac = cellsP->GetAmplitude(i) / amp;
702  }
703 
704  fgAODPhosCells->SetCell(pos, cn, amp,cellsP->GetTime(i),mclabel,efrac);
705 
706  } else
707  {
708  AliAODCaloCells* copycells1 = new AliAODCaloCells(*fgAODPhosCells);
710  Int_t nn = copycells1->GetNumberOfCells();
711 
712  while( nn-- ){ fgAODPhosCells->SetCell(nn,copycells1->GetCellNumber(nn),copycells1->GetAmplitude(nn),
713  copycells1->GetTime(nn),copycells1->GetMCLabel(nn),copycells1->GetEFraction(nn)); }
714 
715  fgAODPhosCells->SetCell(nc++,cn,cellsP->GetAmplitude(i),cellsP->GetTime(i), cellsP->GetMCLabel(i),1.);
716 
717  delete copycells1;
718  }
719  }
720  fgAODPhosCells->Sort();
721  }
722  } // Merge PHOS Cells
723 
724  if (aodH->GetMergeEMCALTrigger() && aod->GetCaloTrigger("EMCAL"))
725  {
726  Int_t tsEMCAL[48][64], px, py, ts;
727  Float_t foEMCAL[48][64], am;
728 
729  for (Int_t i = 0; i < 48; i++) for (Int_t j = 0; j < 64; j++)
730  {
731  tsEMCAL[i][j] = 0;
732  foEMCAL[i][j] = 0.;
733  }
734 
735  AliAODCaloTrigger& trg0 = *(aod->GetCaloTrigger("EMCAL"));
736  trg0.Reset();
737  while (trg0.Next())
738  {
739  trg0.GetPosition(px, py);
740 
741  if (px > -1 && py > -1)
742  {
743  trg0.GetL1TimeSum(ts);
744  if (ts > -1) tsEMCAL[px][py] += ts;
745 
746  trg0.GetAmplitude(am);
747  if (am > -1) foEMCAL[px][py] += am;
748  }
749  }
750 
751  AliAODCaloTrigger& trg1 = *((aodH->GetEventToMerge())->GetCaloTrigger("EMCAL"));
752 
753  trg1.Reset();
754  while (trg1.Next())
755  {
756  trg1.GetPosition(px, py);
757 
758  if (px > -1 && py > -1)
759  {
760  trg1.GetL1TimeSum(ts);
761  if (ts > -1) tsEMCAL[px][py] += ts;
762 
763  trg1.GetAmplitude(am);
764  if (am > -1) foEMCAL[px][py] += am;
765  }
766  }
767 
768  int nEntries = 0;
769  for (Int_t i = 0; i < 48; i++)
770  for (Int_t j = 0; j < 64; j++)
771  if (tsEMCAL[i][j] || foEMCAL[i][j]) nEntries++;
772 
773  fgAODEMCALTrigger->Allocate(nEntries);
774  Int_t timesL0[10]; for (int i = 0; i < 10; i++) timesL0[i] = -1;
775 
776  for (Int_t i = 0; i < 48; i++)
777  for (Int_t j = 0; j < 64; j++)
778  if (tsEMCAL[i][j] || foEMCAL[i][j])
779  fgAODEMCALTrigger->Add(i, j, foEMCAL[i][j], -1., timesL0, 0, tsEMCAL[i][j], 0);
780  }
781 
782  if (aodH->GetMergePHOSTrigger())
783  {
784  // To be implemented by PHOS
785  }
786  } // merging
787 
788  handler->SetAODIsReplicated();
789  }
790  }
791 
792 
793 // Call the user analysis
794  if (isSelected) UserExec(option);
795 
796 // Added protection in case the derived task is not an AOD producer.
798  if (out0 && out0->IsConnected()) PostData(0, fTreeA);
799 
801 }
802 
804 {
806 
807  if( fInputHandler )
808  return fInputHandler->GetTree()->GetCurrentFile()->GetName();
809  else if( fMCEvent )
810  return ((AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler()))->TreeK()->GetCurrentFile()->GetName();
811  else return "";
812 }
813 
814 void AliAnalysisTaskSE::AddAODBranch(const char* cname, void* addobj, const char *fname)
815 {
817 
818  AliAODHandler* handler = dynamic_cast<AliAODHandler*>
819  ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
820  if (handler) {
821  handler->AddBranch(cname, addobj, fname);
822  }
823 }
824 
826 {
829 
830  AliAODHandler* handler = dynamic_cast<AliAODHandler*>
831  ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
832  if (!handler) {
833  Error("IsStandardAOD", "No AOD handler. Please use AODEvent() to check this first");
834  return kTRUE;
835  }
836  return handler->IsStandard();
837 }
838 
840 {
841  return (UserNotify());
842 }
843 
845 {
847 
848  if (!fInputHandler) {
849  Error("EventTag", "Input handler not yet available. Call this in UserExec");
850  return NULL;
851  }
852  return fInputHandler->GetEventTag();
853 }
854 
856 {
859 
860  if (!fInputHandler) {
861  Error("LoadBranches", "Input handler not available yet. Call this in UserExec");
862  return;
863  }
865  if (mgr->GetAutoBranchLoading()) return;
866  TString taskbranches;
867  GetBranches(fInputHandler->GetDataType(), taskbranches);
868  if (taskbranches.IsNull()) return;
869  TObjArray *arr = taskbranches.Tokenize(",");
870  TIter next(arr);
871  TObject *obj;
872  while ((obj=next())) mgr->LoadBranch(obj->GetName());
873  delete arr;
874 }
875 
876 
877 //_________________________________________________________________________________________________
879 {
881 
882  fInputHandler = (AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler();
884  if (fMultiInputHandler) {
887  } else {
888  fMCEventHandler = dynamic_cast<AliInputEventHandler *>((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
889  }
891 }
892 
893 //_________________________________________________________________________________________________
895 {
897 
899 }
900 
906  TObjArray *result = NULL;
908  return result;
909 }
const AliTOFHeader * GetTOFHeader() const
Definition: AliAODEvent.h:158
AliAnalysysTask - Class representing a basic analysis task. Any user-defined task should derive from...
virtual const AliEventTag * GetEventTag() const
Class for calorimeter cluster, EMCal and PHOS, data handling.
Bool_t AODIsReplicated() const
Bool_t NeedsTOFHeaderReplication() const
Definition: AliAODHandler.h:90
Int_t GetMergeOffset() const
AliAODCaloTrigger * GetCaloTrigger(TString calo) const
Definition: AliAODEvent.h:227
TObjArray * GetTopTasks() const
virtual Long64_t GetReadEntry() const
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
Implementation of the Event Handler Interface for AOD.
Definition: AliAODHandler.h:27
TClonesArray * GetJets() const
Definition: AliAODEvent.h:263
Bool_t IsMuonTrack() const
Definition: AliAODTrack.h:438
Bool_t NeedsTrackletsBranchReplication() const
Definition: AliAODHandler.h:96
virtual const char * CurrentFileName()
TTree * fTreeA
AOD output Tree.
AliInputEventHandler * fMCEventHandler
! pointer to MCEventHandler
virtual const AliEventTag * EventTag() const
virtual void UserExec(Option_t *)
virtual TTree * GetTree() const
Definition: AliAODHandler.h:73
Bool_t GetMergePHOSClusters() const
Bool_t GetMergePHOSCells() const
virtual UInt_t IsEventSelected()
static TClonesArray * fgAODV0s
! V0s for replication
Bool_t NeedsTracksBranchReplication() const
Definition: AliAODHandler.h:92
AliHeader * Header()
Definition: AliMCEvent.h:115
#define TObjArray
Double_t GetAmplitude(Short_t pos) const
TTree * GetTreeToMerge() const
virtual void SetAODIsReplicated()
Definition: AliAODHandler.h:69
void GetPosition(Int_t &col, Int_t &row) const
Access to position of the current fastor channel.
Class for calorimeter cell AOD data handling.
Bool_t IsConnected() const
static AliAnalysisManager * GetAnalysisManager()
AliAnalysysManager Manager analysis class. Allows creation of several analysis tasks and data contain...
virtual Bool_t Notify()
static AliAODCaloCells * fgAODEmcalCells
! Emcal Cell replication
void LoadBranches() const
Bool_t IsEMCAL() const
Definition: AliAODCluster.h:76
virtual Bool_t Next()
Forward to next trigger entry (fastor / L0 patch)
AliMCEventHandler * GetFirstMCEventHandler()
virtual AliVfriendEvent * GetVfriendEvent() const
Bool_t GetMergePHOSTrigger() const
Container with calorimeter trigger information in the AOD event.
TClonesArray * GetHMPIDrings() const
Definition: AliAODEvent.h:253
Bool_t PostData(Int_t iout, TObject *data, Option_t *option="")
Bool_t Add(Int_t col, Int_t row, Float_t amp, Float_t time, Int_t trgtimes[], Int_t ntrgtimes, Int_t trgts, Int_t trgbits)
Bool_t NeedsVZEROReplication() const
Definition: AliAODHandler.h:91
AliAODTracklets * GetTracklets() const
Definition: AliAODEvent.h:270
TClonesArray * GetTracks() const
Definition: AliAODEvent.h:165
AliAODVZERO * GetVZEROData() const
Definition: AliAODEvent.h:333
static AliAODCaloTrigger * fgAODPHOSTrigger
! Phos Trigger for replication
virtual AliMCEvent * MCEvent() const
void DefineInput(Int_t islot, TClass *type)
AliAnalysisTask & operator=(const AliAnalysisTask &task)
Bool_t NeedsCaloTriggerBranchReplication() const
AliVHeader * GetHeader() const
Definition: AliAODEvent.h:92
virtual void Reset()
Double_t GetTime(Short_t pos) const
Class AliMultiInputEventHandler Multi input event handler.
AliTPCfastTrack * track
UInt_t GetDebugLevel() const
Int_t GetMCLabel(Short_t pos) const
Bool_t NeedsHeaderReplication() const
Definition: AliAODHandler.h:89
virtual AliVEvent * InputEvent() const
static AliAODCaloCells * fgAODPhosCells
! Phos Cell replication
Bool_t GetMergeEvents() const
static AliTOFHeader * fgTOFHeader
! TOFHeader for replication
#define AliWarning(message)
Definition: AliLog.h:541
Short_t GetCellNumber(Short_t pos) const
Int_t fEntry
Current entry in the chain.
AliVParticle realisation for MC Particles in the AOD.
Int_t GetLabel() const
Definition: AliAODTrack.h:197
AliVfriendEvent * fESDfriend
! ESD friend
static TClonesArray * fgAODFMDClusters
! FMDClusters for replication
static TClonesArray * fgAODPMDClusters
! PMDClusters for replication
static TClonesArray * fgAODTracks
! Tracks for replication
AOD class to store tracklets.
Int_t fDebug
Debug flag.
virtual Option_t * GetDataType() const
Bool_t GetMergeEMCALCells() const
Bool_t IsStandard() const
Definition: AliAODHandler.h:86
Short_t GetCellPosition(Short_t cellNumber)
virtual void CreateOutputObjects()
static TClonesArray * fgAODDimuons
! Dimuons replication
Bool_t NeedsPMDClustersBranchReplication() const
Definition: AliAODHandler.h:97
TClonesArray * GetV0s() const
Definition: AliAODEvent.h:201
Bool_t NeedsFMDClustersBranchReplication() const
Definition: AliAODHandler.h:99
virtual void AddAODBranch(const char *cname, void *addobj, const char *fname="")
virtual TTree * GetTree() const
Bool_t NeedsV0sBranchReplication() const
Definition: AliAODHandler.h:94
Bool_t NeedsHMPIDBranchReplication() const
AOD event base class.
Definition: AliAODHeader.h:27
TList * fHistosQA
! Output histos for QA
static TClonesArray * fgAODHmpidRings
! HMPID replication
void CreateContainer(Short_t nCells)
AliAnalysysDataSlot Class representing a data slot of an analysis task. An analysis slot enforces a c...
Double_t GetEFraction(Short_t pos) const
Bool_t NeedsJetsBranchReplication() const
Definition: AliAODHandler.h:98
#define AliInfo(message)
Definition: AliLog.h:484
virtual void Exec(Option_t *option)
void GetAmplitude(Float_t &amp) const
Access to L0-amplitude of the current fastor channel.
TObject * FindListObject(const char *objName) const
void SetLabel(Int_t label)
Definition: AliAODTrack.h:382
Bool_t NeedsCaloClustersBranchReplication() const
static TClonesArray * fgAODCaloClusters
! CaloClusters for replication
AliAODCaloCells * GetPHOSCells() const
Definition: AliAODEvent.h:274
Int_t fCurrentRunNumber
! Current run number
Bool_t IsPHOS() const
Definition: AliAODCluster.h:79
AliAnalysisDataSlot * GetOutputSlot(Int_t islot) const
static TClonesArray * fgAODVertices
! Vertices for replication
TObjArray * GetAcceptedTracks(const TClonesArray *const tracks)
AliMultiInputEventHandler * fMultiInputHandler
! pointer to multihandler
Short_t GetNumberOfCells() const
AliAODEvent * fOutputAOD
! AOD out
AliVEvent * fInputEvent
! VEvent Input
AliVEventHandler * GetOutputEventHandler() const
Bool_t GetMergeTracks() const
virtual Long64_t GetReadEntry() const
virtual AliVCuts * GetEventSelection() const =0
TObjArray * GetAcceptedTracks()
AliMCEvent * MCEvent() const
TClonesArray * GetPmdClusters() const
Definition: AliAODEvent.h:246
static AliAODTracklets * fgAODTracklets
! Tracklets for replication
static AliAODCaloTrigger * fgAODEMCALTrigger
! Emcal Trigger for replication
UInt_t fOfflineTriggerMask
Task processes collision candidates only.
AOD base class.
Definition: AliAODEvent.h:48
void GetBranches(const char *type, TString &result) const
Bool_t SetCell(Short_t pos, Short_t cellNumber, Double_t amplitude, Double_t time, Int_t mclabel=-1, Double_t efrac=0., Bool_t isHG=kFALSE)
mgr
Definition: runKineProof.C:24
virtual Int_t GetRunNumber() const =0
TClonesArray * GetFmdClusters() const
Definition: AliAODEvent.h:239
AliAODEvent * GetAOD()
Definition: AliAODHandler.h:72
Bool_t GetMergeEMCALTrigger() const
AliAODDimuon: a class for AODs for the MUON Arm of the ALICE Experiment.
Definition: AliAODDimuon.h:33
TClonesArray * GetCaloClusters() const
Definition: AliAODEvent.h:222
static AliAODVZERO * fgAODVZERO
! VZERO for replication
virtual Bool_t UserNotify()
void AddBranch(const char *cname, void *addobj, const char *fname="")
static TClonesArray * fgAODMCParticles
! MC Particles for replicatio
AliMCEvent * fMCEvent
! MC
static AliAODHeader * fgAODHeader
! Header for replication
AliVTrackSelection * fTrackSelection
track selection
Bool_t NeedsMCParticlesBranchReplication() const
static TClonesArray * fgAODJets
! Jets for replication
void LoadBranch(const char *n)
AliAODCaloCells * GetEMCALCells() const
Definition: AliAODEvent.h:273
Container class for AOD VZERO data.
Definition: AliAODVZERO.h:13
Bool_t GetAutoBranchLoading() const
AliAODEvent * GetEventToMerge()
AliInputEventHandler * GetFirstInputEventHandler()
#define AliError(message)
Definition: AliLog.h:591
void DefineOutput(Int_t islot, TClass *type)
void GetStdContent()
virtual void UserCreateOutputObjects()
Bool_t NeedsVerticesBranchReplication() const
Definition: AliAODHandler.h:93
virtual AliVEvent * GetEvent() const
AliVEventHandler * fInputHandler
! Input Handler
virtual Bool_t IsStandardAOD() const
TClonesArray * GetVertices() const
Definition: AliAODEvent.h:176
void GetL1TimeSum(Int_t &timesum) const
Get the L1 time sums (L1 ADC values) for the current fastor.
char * fname
virtual Long64_t Entry() const
AliTrackSelectionFactory * fTrackSelectionFactory
track selection factory
void Allocate(Int_t size)
AOD track implementation of AliVTrack.
Definition: AliAODTrack.h:29
AliAnalysisTaskSE & operator=(const AliAnalysisTaskSE &other)
virtual void NotifyRun()
virtual AliVTrackSelection * CreateTrackCuts(DataType_t datatype) const =0
virtual Int_t GetEvent() const
Definition: AliHeader.h:48
Bool_t GetMergeEMCALClusters() const
Bool_t NeedsDimuonsBranchReplication() const
AOD Input Handler realisation of the AliVEventHandler interface.
virtual void ConnectInputData(Option_t *option="")