]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/CaloTrackCorrBase/AliCaloTrackAODReader.cxx
Transition PWG4 --> PWGGA
[u/mrichter/AliRoot.git] / PWG / CaloTrackCorrBase / AliCaloTrackAODReader.cxx
1
2 /**************************************************************************
3  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4  *                                                                        *
5  * Author: The ALICE Off-line Project.                                    *
6  * Contributors are mentioned in the code where appropriate.              *
7  *                                                                        *
8  * Permission to use, copy, modify and distribute this software and its   *
9  * documentation strictly for non-commercial purposes is hereby granted   *
10  * without fee, provided that the above copyright notice appears in all   *
11  * copies and that both the copyright notice and this permission notice   *
12  * appear in the supporting documentation. The authors make no claims     *
13  * about the suitability of this software for any purpose. It is          *
14  * provided "as is" without express or implied warranty.                  *
15  **************************************************************************/
16 /* $Id: $ */
17
18 //_________________________________________________________________________
19 // Class for reading data (AODs) in order to do prompt gamma
20 //  or other particle identification and correlations.
21 // This part is commented: Mixing analysis can be done, input AOD with events
22 // is opened in the AliCaloTrackReader::Init()
23 // 
24 //
25 //*-- Author: Gustavo Conesa (LNF-INFN) 
26 //////////////////////////////////////////////////////////////////////////////
27
28 //---- ANALYSIS system ----
29 #include "AliCaloTrackAODReader.h" 
30 #include "AliAODInputHandler.h"
31 #include "AliMultiEventInputHandler.h"
32 #include "AliAnalysisManager.h"
33 #include "AliMixedEvent.h"
34 #include "AliAODEvent.h"
35
36 ClassImp(AliCaloTrackAODReader)
37
38 //____________________________________________________________________________
39 AliCaloTrackAODReader::AliCaloTrackAODReader() : 
40   AliCaloTrackReader(), fOrgInputEvent(0x0)
41 {
42   //Default Ctor
43   
44   //Initialize parameters
45   fDataType=kAOD;
46   fReadStack          = kTRUE;
47   fReadAODMCParticles = kFALSE;
48  
49 }
50
51
52 //_________________________________________________________
53 AliCentrality* AliCaloTrackAODReader::GetCentrality() const 
54 {
55   // recover centrality object.
56   AliAODEvent* event    = dynamic_cast<AliAODEvent*> (fInputEvent);
57   AliAODEvent* orgevent = dynamic_cast<AliAODEvent*> (fOrgInputEvent);
58   
59   if(event && !fSelectEmbeddedClusters) {
60     //Normal AOD event
61     return event->GetHeader()->GetCentralityP() ;
62   }
63   else if(fSelectEmbeddedClusters && orgevent) {
64     // centrality in AOD from input, not in embedded event
65     // temporary fix until this object is copied to the output event in embedding analysis
66     return orgevent->GetHeader()->GetCentralityP();
67   }
68   else {
69     return 0x0 ; 
70   }
71 }
72
73 //_________________________________________________________________
74 void AliCaloTrackAODReader::SetInputOutputMCEvent(AliVEvent* input, 
75                                                   AliAODEvent* aod, 
76                                                   AliMCEvent* mc) 
77 {
78   // Connect the data pointers
79   // If input is AOD, do analysis with input, if not, do analysis with the output aod.
80   
81   //printf("AODInputHandler %p, MergeEvents %d \n",aodIH, aodIH->GetMergeEvents());
82   
83   Bool_t tesd = kFALSE ; 
84   Bool_t taod = kTRUE ; 
85   if ( strcmp(input->GetName(), "AliMixedEvent") == 0 ) {
86     AliMultiEventInputHandler* multiEH = dynamic_cast<AliMultiEventInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
87     if(multiEH){
88       if (multiEH->GetFormat() == 0 ) {
89         tesd = kTRUE ; 
90       } else if (multiEH->GetFormat() == 1) {
91         taod = kTRUE ; 
92       }
93     }
94     else{
95       printf("AliCaloTrackAODReader::SetInputOutputMCEvent() - MultiEventHandler is NULL");
96       abort();
97     }
98   }
99   if (strcmp(input->GetName(),"AliESDEvent") == 0) {
100     tesd = kTRUE ; 
101   } else if (strcmp(input->GetName(),"AliAODEvent") == 0) {
102     taod = kTRUE ; 
103   }
104   
105   
106   if(tesd)   {
107     SetInputEvent(aod);
108     SetOutputEvent(aod);
109     fOrgInputEvent = input;
110   }
111   else if(taod){
112     AliAODInputHandler* aodIH = dynamic_cast<AliAODInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
113           if (aodIH && aodIH->GetMergeEvents()) {
114                   //Merged events, use output AOD.
115                   SetInputEvent(aod);
116                   SetOutputEvent(aod);
117       fOrgInputEvent = input;
118           }
119           else{
120                   SetInputEvent(input);
121                   SetOutputEvent(aod);
122           }
123   }
124   else{ 
125     AliFatal(Form("AliCaloTrackAODReader::SetInputOutputMCEvent() - STOP : Wrong data format: %s\n",input->GetName()));
126   }
127   
128   SetMC(mc);
129   
130 }
131