]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG4/PartCorrBase/AliCaloTrackAODReader.cxx
coverity
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / 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
29 // --- ROOT system ---
30 //#include "Riostream.h"
31
32 //---- ANALYSIS system ----
33 #include "AliCaloTrackAODReader.h" 
34 #include "AliAODInputHandler.h"
35 #include "AliMultiEventInputHandler.h"
36 #include "AliAnalysisManager.h"
37 #include "AliMixedEvent.h"
38
39 ClassImp(AliCaloTrackAODReader)
40
41 //____________________________________________________________________________
42 AliCaloTrackAODReader::AliCaloTrackAODReader() : 
43   AliCaloTrackReader(), fOrgInputEvent(0x0)
44 {
45   //Default Ctor
46   
47   //Initialize parameters
48   fDataType=kAOD;
49   fReadStack          = kTRUE;
50   fReadAODMCParticles = kFALSE;
51  
52 }
53
54 //____________________________________________________________________________
55 //void AliCaloTrackAODReader::GetSecondInputAODVertex(Double_t  v[3]) const {
56 //      //Return vertex position of second AOD input
57 //      
58 //      fSecondInputAODEvent->GetPrimaryVertex()->GetXYZ(v);
59 //
60 //}
61
62 //____________________________________________________________________________
63 AliCentrality* AliCaloTrackAODReader::GetCentrality() const {
64   // recover centrality object.
65   AliAODEvent* event    = dynamic_cast<AliAODEvent*> (fInputEvent);
66   AliAODEvent* orgevent = dynamic_cast<AliAODEvent*> (fOrgInputEvent);
67
68   if(event && !fSelectEmbeddedClusters) {
69     //Normal AOD event
70     return event->GetHeader()->GetCentralityP() ;
71   }
72   else if(fSelectEmbeddedClusters && orgevent) {
73     // centrality in AOD from input, not in embedded event
74     // temporary fix until this object is copied to the output event in embedding analysis
75     return orgevent->GetHeader()->GetCentralityP();
76   }
77   else {
78     return 0x0 ; 
79   }
80 }
81
82
83 //____________________________________________________________________________
84 void AliCaloTrackAODReader::SetInputOutputMCEvent(AliVEvent* input, AliAODEvent* aod, AliMCEvent* mc) {
85   // Connect the data pointers
86   // If input is AOD, do analysis with input, if not, do analysis with the output aod.
87
88   //printf("AODInputHandler %p, MergeEvents %d \n",aodIH, aodIH->GetMergeEvents());
89
90   Bool_t tesd = kFALSE ; 
91   Bool_t taod = kTRUE ; 
92   if ( strcmp(input->GetName(), "AliMixedEvent") == 0 ) {
93     AliMultiEventInputHandler* multiEH = dynamic_cast<AliMultiEventInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
94     if(multiEH){
95       if (multiEH->GetFormat() == 0 ) {
96         tesd = kTRUE ; 
97       } else if (multiEH->GetFormat() == 1) {
98         taod = kTRUE ; 
99       }
100     }
101     else{
102       printf("AliCaloTrackAODReader::SetInputOutputMCEvent() - MultiEventHandler is NULL");
103       abort();
104     }
105   }
106   if (strcmp(input->GetName(),"AliESDEvent") == 0) {
107     tesd = kTRUE ; 
108   } else if (strcmp(input->GetName(),"AliAODEvent") == 0) {
109     taod = kTRUE ; 
110   }
111   
112
113   if(tesd)   {
114     SetInputEvent(aod);
115     SetOutputEvent(aod);
116     fOrgInputEvent = input;
117   }
118   else if(taod){
119     AliAODInputHandler* aodIH = dynamic_cast<AliAODInputHandler*>((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
120           if (aodIH && aodIH->GetMergeEvents()) {
121                   //Merged events, use output AOD.
122                   SetInputEvent(aod);
123                   SetOutputEvent(aod);
124       fOrgInputEvent = input;
125           }
126           else{
127                   SetInputEvent(input);
128                   SetOutputEvent(aod);
129           }
130   }
131   else{ 
132     AliFatal(Form("AliCaloTrackAODReader::SetInputOutputMCEvent() - STOP : Wrong data format: %s\n",input->GetName()));
133   }
134   
135   SetMC(mc);
136   
137 }
138