Making AliLog true instanton (Jimmy)
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDAnalysisTask.cxx
CommitLineData
9a8aafa5 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#ifndef AliHMPIDAnalysisTASK_CXX
17#define AliHMPIDAnalysisTASK_CXX
18
38b8c336 19
20#include "TH1.h"
21#include "TH2.h"
9a8aafa5 22#include "AliAnalysisManager.h"
38b8c336 23#include "AliESDInputHandler.h"
9a8aafa5 24#include "AliESDtrack.h"
25#include "AliLog.h"
38b8c336 26#include "AliHMPIDAnalysisTask.h"
9a8aafa5 27
28ClassImp(AliHMPIDAnalysisTask)
29
30//__________________________________________________________________________
31AliHMPIDAnalysisTask::AliHMPIDAnalysisTask() :
38b8c336 32 fESD(0x0),fHmpHistList(0x0),
9a8aafa5 33 fNevts(0),
34 fTrigNevts(0),
38b8c336 35 fTrigger(0),
36 fHmpInner(0x0),fHmpPesdPhmp(0x0),fHmpCkovPesd(0x0),fHmpCkovPhmp(0x0),
37 fHmpMipTrkDist(0x0),fHmpMipTrkDistX(0x0),fHmpMipTrkDistY(0x0),fHmpMipCharge3cm(0x0),fHmpMipCharge1cm(0x0),fHmpNumPhots(0x0),
38 fHmpTrkFlags(0x0)
9a8aafa5 39{
40 //
41 //Default ctor
42 //
38b8c336 43
9a8aafa5 44}
45//___________________________________________________________________________
46AliHMPIDAnalysisTask::AliHMPIDAnalysisTask(const Char_t* name) :
47 AliAnalysisTaskSE(name),
38b8c336 48 fESD(0),fHmpHistList(0x0), fNevts(0),
9a8aafa5 49 fTrigNevts(0),
38b8c336 50 fTrigger(0),
51 fHmpInner(0x0),fHmpPesdPhmp(0x0),fHmpCkovPesd(0x0),fHmpCkovPhmp(0x0),
52 fHmpMipTrkDist(0x0),fHmpMipTrkDistX(0x0),fHmpMipTrkDistY(0x0),fHmpMipCharge3cm(0x0),fHmpMipCharge1cm(0x0),fHmpNumPhots(0x0),
53 fHmpTrkFlags(0x0)
9a8aafa5 54{
55 //
56 // Constructor. Initialization of Inputs and Outputs
57 //
38b8c336 58
59 DefineOutput(0,TList::Class());
60 }
9a8aafa5 61//___________________________________________________________________________
62AliHMPIDAnalysisTask::~AliHMPIDAnalysisTask() {
63 //
64 //destructor
65 //
66 Info("~AliHMPIDAnalysisask","Calling Destructor");
38b8c336 67 if (fHmpHistList) {fHmpHistList->Clear(); delete fHmpHistList;}
9a8aafa5 68}
38b8c336 69//___________________________________________________________________________
70void AliHMPIDAnalysisTask::ConnectInputData(Option_t *)
71{
72 // Connect ESD here
73
74 AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
75 if (!esdH) {
76 AliDebug(2,Form("ERROR: Could not get ESDInputHandler"));
77 } else
78 fESD = esdH->GetEvent();
79 }
9a8aafa5 80//_________________________________________________
38b8c336 81void AliHMPIDAnalysisTask::Exec(Option_t *)
9a8aafa5 82{
83 //
84 // Main loop function, executed on Event basis
85 //
9a8aafa5 86 for (Int_t iTrack = 0; iTrack<fESD->GetNumberOfTracks(); iTrack++) {
87
88 AliESDtrack* track = fESD->GetTrack(iTrack);
89 if(!track) continue;
90 Double_t rin[3], rout[3];
91 track->GetInnerXYZ(rin);
92 track->GetOuterXYZ(rout);
38b8c336 93 /*
94 ((TH2F *)fHmpHistList->At(22))->Fill(rin[0],rin[1]);
95 ((TH2F *)fHmpHistList->At(23))->Fill(rout[0],rout[1]);
96*/
97
98 if(track->GetHMPIDsignal() == -20) fHmpTrkFlags->Fill(0);
99 else if(track->GetHMPIDsignal() == -9) fHmpTrkFlags->Fill(1);
100 else if(track->GetHMPIDsignal() == -5) fHmpTrkFlags->Fill(2);
101 else if(track->GetHMPIDsignal() == -11) fHmpTrkFlags->Fill(3);
102 else if(track->GetHMPIDsignal() == -22) fHmpTrkFlags->Fill(4);
103 else fHmpTrkFlags->Fill(4);
9a8aafa5 104
38b8c336 105 if(track->GetHMPIDsignal()== -20) continue;
106 if(track->GetHMPIDcluIdx() < 0) continue;
107
9a8aafa5 108 Int_t ch = track->GetHMPIDcluIdx()/1000000;
9a8aafa5 109 Float_t x, y; Int_t q, nph;
9a8aafa5 110 Float_t xpc, ypc, th, ph;
38b8c336 111
112 track->GetHMPIDmip(x,y,q,nph);
113 track->GetHMPIDtrk(xpc,ypc,th,ph);
114
115 if(x==0 && y==0 && xpc == 0 && ypc == 0) continue;
116 //Printf("%s %s Good track is found",(char*)__FILE__,__LINE__);
117
9a8aafa5 118 Double_t dist = TMath::Sqrt( (xpc-x)*(xpc-x) + (ypc - y)*(ypc - y));
38b8c336 119 fHmpMipTrkDist->Fill(dist);
120 fHmpMipTrkDistX->Fill(xpc-x);
121 fHmpMipTrkDistY->Fill(ypc - y);
122 if(dist<=3.0) fHmpMipCharge3cm->Fill(q);
123
124 if(track->GetHMPIDsignal() > 0 )
125 {
126 Printf("EvtNumInFile: %d HMPID ThetaC: %lf x: %lf xpc: %lf y: %lf ypx: %lf Q: %d nPh: %d IncTheta; %lf IncPhi: %lf",fESD->GetEventNumberInFile(),track->GetHMPIDsignal(),x,xpc,y,ypc,q,nph,th,ph);
127 Double_t pHmp[3] = {0},pmod = 0;if(track->GetOuterHmpPxPyPz(pHmp)) pmod = TMath::Sqrt(pHmp[0]*pHmp[0]+pHmp[1]*pHmp[1]+pHmp[2]*pHmp[2]);
128 fHmpPesdPhmp->Fill(track->P(),pmod);
129 if(dist<=1.0) fHmpMipCharge1cm->Fill(q);
130 fHmpNumPhots->Fill(nph);
131 fHmpCkovPesd->Fill(track->P(),track->GetHMPIDsignal());
132 fHmpCkovPesd->Fill(pmod,track->GetHMPIDsignal());
133 }//there is signal
134
9a8aafa5 135 }//track loop
9a8aafa5 136
137 /* PostData(0) is taken care of by AliAnalysisTaskSE */
38b8c336 138 PostData(0,fHmpHistList) ;
9a8aafa5 139}
140
141
142//___________________________________________________________________________
143void AliHMPIDAnalysisTask::Terminate(Option_t*)
144{
145 // The Terminate() function is the last function to be called during
146 // a query. It always runs on the client, it can be used to present
147 // the results graphically or save the results to file.
148
149 Info("Terminate","");
150 AliAnalysisTaskSE::Terminate();
151
152}
153
154
155//___________________________________________________________________________
38b8c336 156void AliHMPIDAnalysisTask::CreateOutputObjects() {
9a8aafa5 157 //
158 //HERE ONE CAN CREATE OUTPUT OBJECTS
159 //TO BE SET BEFORE THE EXECUTION OF THE TASK
160 //
9a8aafa5 161
162 //slot #1
38b8c336 163 OpenFile(0);
164 fHmpHistList = new TList();
165 fHmpInner =new TH2F("fHmpInner","HMPID: Inner track XY;X (cm);Y(cm)",800,-400,400,800,-400,400);
166 fHmpHistList->Add(fHmpInner);
167
168 fHmpPesdPhmp = new TH2F("fHmpPesdPhmp","HMPID: ESD p - running p;HMP p (GeV/c);ESD p (Gev/c)",100,0,10,100,0,10);
169 fHmpHistList->Add(fHmpPesdPhmp);
170
171 fHmpCkovPesd = new TH2F("fHmpCkovPesd","HMPID: ThetaCherenkov vs P;p_esd (GeV/c);#Theta_C;Entries",100,0,10,110,0,1.1);
172 fHmpHistList->Add(fHmpCkovPesd);
173
174 fHmpCkovPhmp = new TH2F("fHmpCkovPhmp","HMPID: ThetaCherenkov vs P;p_hmp (GeV/c);#Theta_C;Entries",100,0,10,110,0,1.1);
175 fHmpHistList->Add(fHmpCkovPhmp);
9a8aafa5 176
38b8c336 177 fHmpMipTrkDist = new TH1F("fHmpMipTrkDist","HMPID MIP-Track distance;distance (cm);Entries",800,-20,20);
178 fHmpHistList->Add(fHmpMipTrkDist);
179 fHmpMipTrkDistX = new TH1F("fHmpMipTrkDistX","HMPID MIP-Track distance in local X;distance (cm);Entries",800,-20,20);
180 fHmpHistList->Add(fHmpMipTrkDistX);
181 fHmpMipTrkDistY = new TH1F("fHmpMipTrkDistY","HMPID MIP-Track distance in local Y;distance (cm);Entries",800,-20,20);
182 fHmpHistList->Add(fHmpMipTrkDistY);
183
184 fHmpMipCharge3cm = new TH1F("fHmpMipCharge3cm","HMPID MIP Charge;MIP Charge (ADC);Entries",5001,-0.5,5000.5);
185 fHmpHistList->Add(fHmpMipCharge3cm);
186
187 fHmpMipCharge1cm = new TH1F("fHmpMipCharge1cm","HMPID MIP Charge;MIP Charge (ADC);Entries",5001,-0.5,5000.5);
188 fHmpHistList->Add(fHmpMipCharge1cm);
189
190 fHmpNumPhots = new TH1F("fHmpNumPhots","HMPID Number of photon clusters on ring;#photon clus.;Entries",51,-0.5,50.5);
191 fHmpHistList->Add(fHmpNumPhots);
192
193 fHmpTrkFlags = new TH1F("fHmpTrkFlags","HMPID track flags",6,0,6);
194 TString summary[6] = {"NotPerformed","MipDistCut", "MipQdcCut", "NoPhotAccept", "kNoRad", "other"};
195 for(Int_t ibin = 0; ibin < 6; ibin++) fHmpTrkFlags->GetXaxis()->SetBinLabel(ibin+1,Form("%i %s",ibin+1,summary[ibin].Data()));
196 fHmpHistList->Add(fHmpTrkFlags);
197 /*
9a8aafa5 198 //0
199 TH1F *trkH = new TH1F("trkH","signal flags in HMPID",6,0,6);
200 TString summary[6] = {"NotPerformed","MipDistCut", "MipQdcCut", "NoPhotAccept", "kNoRad", "other"};
201 for(Int_t ibin = 0; ibin < 6; ibin++) trkH->GetXaxis()->SetBinLabel(ibin+1,Form("%i %s",ibin+1,summary[ibin].Data()));
38b8c336 202 fHmpHistList->Add(trkH);
9a8aafa5 203
204
205 TH2F *mod[7], *dq[7];
206 TH1F *q[7];
207
208 //1-7
209 for(Int_t i=0; i< 7 ; i++) {// to preserve the histo sorting
210 mod[i] = new TH2F(Form("mod%i",i),Form("MIP position in chamber %i",i),180,0,180,180,0,180);
211 mod[i]->SetMarkerStyle(8);
212 mod[i]->SetMarkerColor(2);
38b8c336 213 fHmpHistList->Add(mod[i]);
9a8aafa5 214 }
215 //8-14
216 for(Int_t i=0; i< 7 ; i++) {//to reserve the histo sorting
217 q[i] = new TH1F(Form("q%i",i),Form("MIP charge distribution in chamber %i",i),5000,0,5000);
218 q[i]->SetMarkerColor(2);
38b8c336 219 fHmpHistList->Add(q[i]);
9a8aafa5 220 }
221 //15-21
222 for(Int_t i=0; i< 7 ; i++) {//to reserve the histo sorting
223 dq[i] = new TH2F(Form("dq%i",i),Form("#Delta(mip-track) vs Q_{mip} in chamber %i",i),1000,0,100,5000,0,5000),
224 dq[i]->SetMarkerStyle(6);
38b8c336 225 fHmpHistList->Add(dq[i]);
9a8aafa5 226 }
227 //22
228 TH2F *inner = new TH2F("inner","inner track XY",800,-400,400,800,-400,400);
229 inner->SetMarkerStyle(6);
230 inner->SetXTitle("X cm");
231 inner->SetYTitle("Y cm");
38b8c336 232 fHmpHistList->Add(inner);
9a8aafa5 233 //23
234 TH2F *outer = new TH2F("outer","outer track XY",800,-400,400,800,-400,400);
235 outer->SetMarkerStyle(6);
236 outer->SetXTitle("X cm");
237 outer->SetYTitle("Y cm");
38b8c336 238 fHmpHistList->Add(outer);
239*/
9a8aafa5 240}
241
242#endif