]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALJetMicroDst.cxx
Pyhtia comparison extended
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALJetMicroDst.cxx
CommitLineData
e8f1e037 1/**************************************************************************
2 * Copyright(c) 1998-2002, 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
803d1ab0 17/* $Id$ */
e8f1e037 18
19//*-- Authors: Aleksei Pavlinov (WSU)
af33fc68 20
e8f1e037 21//*
22
23#include "AliEMCALJetMicroDst.h"
24#include "AliRun.h"
25#include "AliHeader.h"
26#include "AliGenEventHeader.h"
27#include "AliGenHijingEventHeader.h"
28#include "AliEMCALJetFinder.h"
29#include <TVector3.h>
30#include <TROOT.h>
31#include <TBrowser.h>
32#include <TString.h>
33#include <TParticle.h>
5d12ce38 34#include "AliMC.h"
2f2f4d2b 35#include <TH2.h>
36#include <TH1F.h>
37
e8f1e037 38
39ClassImp(AliEMCALJetMicroDst)
40
1dc41dd9 41TString gAliNameTree("jetMDST"); // 7-feb-2002
e8f1e037 42
1dc41dd9 43//TH1F* fhPtPart, *fhNJet, *fhPtJet;
44//TH2F* fhEtaPhiPart, *fhEtaPhiJet;
45//TH1F* fhNcell, *fhCellId, *fhCellEt, *fhSumEt;
46//TH1F* fhNgrid, *fhGridId, *fhGridEt, *fhSumEtGrForJF;
6ec7dfce 47
48extern "C" void sgpdge_(Int_t &i, Int_t &pdggea);
e8f1e037 49
8e8eae84 50AliEMCALJetMicroDst::AliEMCALJetMicroDst(const char *name, const char *tit) : TNamed(name,tit)
e8f1e037 51{
2f2f4d2b 52 //constructor
e8f1e037 53 fFile = 0;
54 fTree = 0;
55 fDebug = 0;
e8f1e037 56
57// Don't add histos to the current directory
58// TH1::AddDirectory(0);
59 gROOT->cd();
1dc41dd9 60 fhPtPart = new TH1F("fhPtPart","P_{T} for partons", 300, 0., 300.);
6ec7dfce 61 // 16-jan-2002 - new limit fo phi
1dc41dd9 62 fhEtaPhiPart = new TH2F("fhEtaPhiPart","#eta #phi distr.for partons after HSc",
6e10fc78 63 28, -0.7, 0.7, 21, 0.0, (2.0/3.0)*TMath::Pi());
e8f1e037 64
1dc41dd9 65 fhNJet = new TH1F("fhNJet","number of jets", 11, -0.5, 10.5);
66 fhPtJet = new TH1F("fhPtJet","P_{T} for jets", 500, 0., 500.);
67 fhEtaPhiJet = new TH2F("fhEtaPhiJet","#eta #phi distr.for jets (W)",
6e10fc78 68 28, -0.7, 0.7, 21, 0.0, (2.0/3.0)*TMath::Pi());
6ec7dfce 69
1dc41dd9 70 fhNcell = new TH1F("fhNcell","#cell with de>0.0 for EMCAL", 1400, 0.0, 14000.);
71 fhCellId = new TH1F("fhCellId","cell ID with de>0.0 for EMCAL", 1400, 0.0, 14000.);
72 fhCellEt = new TH1F("fhCellEt","cell Et for EMCAL", 1000, 0.0, 10.);
73 fhSumEt = new TH1F("fhSumEt","sum Et for EMCAL", 1000, 0.0, 1000.);
6ec7dfce 74
1dc41dd9 75 fhNgrid = new TH1F("fhNgrid","#cell with de>0.0 in EMCAL grid for JF", 1400, 0.0, 14000.);
76 fhGridId = new TH1F("fhGridId","cell ID with de>0.0 in EMCAL grid for JF", 1400, 0.0, 14000.);
77 fhGridEt = new TH1F("fhGridEt","cell Et in EMCAL grid for JF", 1000, 0.0, 10.);
78 fhSumEtGrForJF = new TH1F("fhSumEtGrForJF","sum Et in EMCAL grid for JF", 1000, 0.0, 1000.);
6ec7dfce 79
e8f1e037 80 fListHist = MoveHistsToList("Hist For AliEMCALJetMicroDst", kFALSE);
81}
82
83AliEMCALJetMicroDst::~AliEMCALJetMicroDst()
84{
2f2f4d2b 85 //destructor
e8f1e037 86 if(fFile) fFile->Close();
87}
88
89Bool_t AliEMCALJetMicroDst::Create(TFile *file)
90{
1dc41dd9 91 // Creates the DST file
e8f1e037 92 if(!file) {
af33fc68 93 Error("Create", "define TFile for output\n");
e8f1e037 94 return kFALSE;
95 }
6ec7dfce 96 fFile = file;
97 fFileName = fFile->GetName();
e8f1e037 98 fFile->cd();
1dc41dd9 99 fTree = new TTree(gAliNameTree.Data(),"Temporary micro DST for jets analysis");
6ec7dfce 100 // for jet calibration - 4-mar-2003
2f2f4d2b 101 fTree->Branch("fdecone", &fdecone, "fdecone/F");
102 fTree->Branch("fptcone", &fptcone, "fptcone/F");
e8f1e037 103 // partons
2f2f4d2b 104 fTree->Branch("fnpart", &fnpart, "fnpart/I");
105 fTree->Branch("fxpt", fxpt, "fxpt[fnpart]/F");
106 fTree->Branch("fxeta", fxeta, "fxeta[fnpart]/F");
107 fTree->Branch("fxphi", fxphi, "fxphi[fnpart]/F");
e8f1e037 108 // jets
2f2f4d2b 109 fTree->Branch("fnjet", &fnjet, "fnjet/I");
110 fTree->Branch("fjet", fjet, "fjet[fnjet]/F");
111 fTree->Branch("fjetaw", fjetaw, "fjetaw[fnjet]/F");
112 fTree->Branch("fjphiw", fjphiw, "fjphiw[fnjet]/F");
113 fTree->Branch("fjetal", fjetal, "fjetal[fnjet]/F");
114 fTree->Branch("fjphil", fjphil, "fjphil[fnjet]/F");
6ec7dfce 115
116 // Et in EMCAL itself
2f2f4d2b 117 fTree->Branch("fncell", &fncell, "fncell/I");
118 fTree->Branch("fidcell", fidcell, "fidcell[fncell]/I");
119 fTree->Branch("fetcell", fetcell, "fetcell[fncell]/F");
6ec7dfce 120
121 // Et in EMCAL grid for JF
2f2f4d2b 122 fTree->Branch("fngrid", &fngrid, "fngrid/I");
123 fTree->Branch("fidgrid", fidgrid, "fidgrid[fngrid]/I");
124 fTree->Branch("fetgrid", fetgrid, "fetgrid[fngrid]/F");
6ec7dfce 125
126 // charge particle which hit to EMCAL
2f2f4d2b 127 fTree->Branch("fnchp", &fnchp, "fnchp/I");
128 fTree->Branch("fpid", fpid, "fpid[fnchp]/I");
129 fTree->Branch("fppt", fppt, "fppt[fnchp]/F");
130 fTree->Branch("fpeta", fpeta, "fpeta[fnchp]/F");
131 fTree->Branch("fpphi", fpphi, "fpphi[fnchp]/F");
6ec7dfce 132
e8f1e037 133 return kTRUE;
134}
135
136Bool_t AliEMCALJetMicroDst::Create(const char *fname)
137{
2f2f4d2b 138 // Create member
e8f1e037 139 TFile *file = new TFile(fname, "RECREATE");
140 if(file) {
6ec7dfce 141 // fNameFile = fname;
e8f1e037 142 return Create(file);
6ec7dfce 143 } else return kFALSE;
e8f1e037 144}
145
146Bool_t AliEMCALJetMicroDst::Open(const char *fname)
147{
2f2f4d2b 148 //Open member
e8f1e037 149 if(fFile && fFile->IsOpen()) fFile->Close();
150 if(strlen(fname)) fName = fname;
151 TFile *file = new TFile(fName.Data(), "READ");
152 if(file) {
6ec7dfce 153 Bool_t ini = Initialize(file);
af33fc68 154 Info("Open", "open file %s : initialize TTree %i",fName.Data(), Int_t(ini));
6ec7dfce 155 return ini;
e8f1e037 156 } else {
af33fc68 157 Error("Open", "can not open file %s",fName.Data());
e8f1e037 158 return kFALSE;
159 }
160}
161
09884213 162const Char_t* AliEMCALJetMicroDst::DefineName(Int_t mode)
6ec7dfce 163{
2f2f4d2b 164 //DefineName member
6ec7dfce 165 static TString dir, name;
166 // dir = "jetDST/"; // 24-jan-2003
167 dir = "/auto/alice/pavlinov/jet/microDST/"; // 24-jan-2003
168 switch (mode) {
169 case 1: // for characteristic of BG
170 name = dir + "mDst1_1.root"; // Bg 2000 - first version
171 SetTitle("Bg2000");
172 break;
173 case 2: // for characteristic of BG
174 name = dir + "mDst2_1.root"; // Bg 4000 - first version
175 SetTitle("Bg4000");
176 break;
177 case 3: // for characteristic of BG
178 name = dir + "mDst3_1.root"; // Bg 8000 - first version
179 SetTitle("Bg8000");
180 break;
181 case 4: // Central Hijing - 18-mar-2003
182 name = dir + "march/";
183 name += "jF_R0.50MinCell1.0PtCut0.0EtSeed4.0MinEt40.0BGSubtr0SF11.6Smear0Eff0HijingCentral.root";
184 SetTitle("HijingCentral");
185 break;
186 case 5: // Para Hijing (Dn/Dy=8000) - 21-mar-2003
187 name = dir + "march/";
188 name += "jF_R0.50MinCell1.0PtCut0.0EtSeed4.0MinEt40.0BGSubtr0SF11.6Smear0Eff0ParaHijing8000.root";
189 SetTitle("HIJINGparaDnDy8000");
190 break;
191 case 6: // Para Hijing (Dn/Dy=4000) - 21-mar-2003
192 name = dir + "march/";
193 name += "jF_R0.50MinCell1.0PtCut0.0EtSeed4.0MinEt40.0BGSubtr0SF11.6Smear0Eff0ParaHijing4000.root";
194 SetTitle("HIJINGparaDnDy4000");
195 break;
196 case 7: // Para Hijing (Dn/Dy=2000) - 21-mar-2003
197 name = dir + "march/";
198 name += "jF_R0.50MinCell1.0PtCut0.0EtSeed4.0MinEt40.0BGSubtr0SF11.6Smear0Eff0ParaHijing2000.root";
199 SetTitle("HIJINGparaDnDy2000");
200 break;
201 case 11: // pure PYTHIA with default value of parameters
202 name = dir + "jF_R0.50MinCell0.0PtCut0.0EtSeed8.0MinEt40.0BGSubtr0SF11.6.root";
203 break;
204 case 12: // 0 + background
205 name = dir + "jF_R0.50MinCell0.0PtCut0.0EtSeed8.0MinEt40.0BGSubtr0SF11.6kBackground2000.root";
206 break;
207 // calibration case
208 case 101:
209 name = dir + "march/";
210 name += "Pythia100_1.root";
211 SetTitle("Pythia100_1");
212 break;
213 case 102: // 2-apr-2003
214 name = dir + "march/";
215 name += "Pythia50_1.root";
216 SetTitle("Pythia50_1");
217 // name = "microDst3th.root"; // 101 + (smearing and eff) - 14-mar-2003
218 break;
219 case 103:// 4-apr-2003
220 name = dir + "march/";
221 name += "Pythia200_1.root";
222 SetTitle("Pythia200_1");
223 // name = "microDst4th.root"; // 102 + MinCell= 1.0
224 break;
225 default:
af33fc68 226 Fatal("DefineName", "NO D E F A U L T : mode %i\n", mode);
6ec7dfce 227 }
af33fc68 228 Info("DefineName", "mode %5i file : %s : Title %s\n", mode, name.Data(), GetTitle());
6ec7dfce 229 return name.Data();
230}
231
e8f1e037 232Bool_t AliEMCALJetMicroDst::Initialize(TFile *file)
233{
2f2f4d2b 234 // Initialize method
e8f1e037 235 if(file) fFile = file;
236 fFile->cd();
1dc41dd9 237 fTree = (TTree*)fFile->Get(gAliNameTree.Data());
e8f1e037 238 if(!fTree) return kFALSE;
6ec7dfce 239 // for jet calibration - 4-mar-2003
2f2f4d2b 240 fTree->SetBranchAddress("fdecone",&fdecone);
241 fTree->SetBranchAddress("fptcone",&fptcone);
e8f1e037 242 // partons
2f2f4d2b 243 fTree->SetBranchAddress("fnpart",&fnpart);
244 fTree->SetBranchAddress("fxpt", fxpt);
245 fTree->SetBranchAddress("fxeta", fxeta);
246 fTree->SetBranchAddress("fxphi", fxphi);
e8f1e037 247 // jets
2f2f4d2b 248 fTree->SetBranchAddress("fnjet", &fnjet);
249 fTree->SetBranchAddress("fjet", fjet);
250 fTree->SetBranchAddress("fjetaw", fjetaw);
251 fTree->SetBranchAddress("fjphiw", fjphiw);
252 fTree->SetBranchAddress("fjetal", fjetal);
253 fTree->SetBranchAddress("fjphil", fjphil);
6ec7dfce 254 // eT in EMCAL
2f2f4d2b 255 fTree->SetBranchAddress("fncell", &fncell);
256 fTree->SetBranchAddress("fidcell", fidcell);
257 fTree->SetBranchAddress("fetcell", fetcell);
6ec7dfce 258 // eT in EMCAL grid for JF
2f2f4d2b 259 fTree->SetBranchAddress("fngrid", &fngrid);
260 fTree->SetBranchAddress("fidgrid", fidgrid);
261 fTree->SetBranchAddress("fetgrid", fetgrid);
6ec7dfce 262 // 28-jan-2003
2f2f4d2b 263 fTree->SetBranchAddress("fnchp", &fnchp);
264 fTree->SetBranchAddress("fpid", fpid);
265 fTree->SetBranchAddress("fppt", fppt);
266 fTree->SetBranchAddress("fpeta", fpeta);
267 fTree->SetBranchAddress("fpphi", fpphi);
e8f1e037 268
269 return kTRUE;
270}
271
272void AliEMCALJetMicroDst::Print(Option_t* option) const
273{
2f2f4d2b 274 //
e8f1e037 275 if(option);
276 if(fFile) {
277 fFile->Print();
278 if(fTree) fTree->Print();
af33fc68 279 else Info("Print", "TRee is zero\n");
6ec7dfce 280 } else {
af33fc68 281 Info("Print", "File with TRee is closed \n Name of file %s(from fFileName", fFileName.Data());
e8f1e037 282 }
283
af33fc68 284 Info("Print", "******* Current(last) event *****");
2f2f4d2b 285 printf("#partons %2i \n", fnpart);
286 for(Int_t i=0; i<fnpart; i++){
6ec7dfce 287 printf(" %1i Pt %7.1f eta %7.4f phi %7.4f \n",
2f2f4d2b 288 i, fxpt[i],fxeta[i],fxphi[i]);
e8f1e037 289 }
2f2f4d2b 290 printf("#jets %2i \n", fnjet);
291 for(Int_t i=0; i<fnjet; i++){
6ec7dfce 292 printf(" %1i Et %7.1f etaw %7.4f phiw %7.4f \n",
2f2f4d2b 293 i,fjet[i],fjetaw[i],fjphiw[i]);
6ec7dfce 294 }
295 printf(" Title %s \n", GetTitle());
e8f1e037 296}
297
6ec7dfce 298void AliEMCALJetMicroDst::Fill(AliRun *run, AliEMCALJetFinder* jetFinder, Int_t modeFilling)
1dc41dd9 299{
300 // modeFilling >=1 - fill info for EMCAL grid
e8f1e037 301 if(!run) run = gAlice;
302 AliGenEventHeader* evHeader = run->GetHeader()->GenEventHeader();
303 TString tmp(evHeader->ClassName());
304 if(tmp.Contains("Hijing")) {
305 AliGenHijingEventHeader *hijEvHeader = (AliGenHijingEventHeader*)evHeader;
306 FillPartons(hijEvHeader);
307 } else if(tmp.Contains("Pythia")) {
308 FillPartons();
309 } else {
af33fc68 310 Error("Fill", "Wrong type of generator -> %s \n Info about partons will be absent",tmp.Data());
e8f1e037 311 }
312
313 FillJets(jetFinder);
6ec7dfce 314
315 if(modeFilling >= 1) {
316 FillEtForEMCAL(jetFinder);
317 FillEtForGrid(jetFinder);
318 FillChargeParticles(jetFinder);
319 } else {
2f2f4d2b 320 fncell = 0; // 27-jan-2003
321 fngrid = 0; // 27-jan-2003
322 fnchp = 0;
6ec7dfce 323 // negative - no signal
2f2f4d2b 324 fdecone = -1.;
325 fptcone = -1.;
6ec7dfce 326 }
327
328 FillJetsControl(); //24-jan-2003
329
e8f1e037 330 fTree->Fill();
331}
332
333void AliEMCALJetMicroDst::FillPartons(AliGenHijingEventHeader *header)
334{
1dc41dd9 335 //Make partons arrays
e8f1e037 336 TLorentzVector parton[4];
337 header->GetJets(parton[0], parton[1], parton[2], parton[3]);
338
2f2f4d2b 339 fnpart = 4; //
e8f1e037 340 for(Int_t i=0; i<4; i++){
2f2f4d2b 341 fxpt[i] = parton[i].Pt();
342 fxeta[i] = parton[i].Eta();
343 fxphi[i] = parton[i].Phi();
e8f1e037 344 }
345}
346
347void AliEMCALJetMicroDst::FillPartons()
1dc41dd9 348{
349 // for case of Pythia -> get info from full event record
e8f1e037 350
2f2f4d2b 351 fnpart = 2;
352 TParticle *mPart;
e8f1e037 353 Int_t ind;
354 for(Int_t i=6; i<8; i++){
2f2f4d2b 355 mPart = gAlice->GetMCApp()->Particle(i);
e8f1e037 356 ind = i-6;
2f2f4d2b 357 fxpt[ind] = mPart->Pt();
358 fxeta[ind] = mPart->Eta();
359 fxphi[ind] = mPart->Phi();
e8f1e037 360 }
361}
362
363void AliEMCALJetMicroDst::FillJets(AliEMCALJetFinder* jetFinder)
364{
1dc41dd9 365 // Fill Jets
2f2f4d2b 366 fnjet = 0;
af33fc68 367 if(fDebug>1) Info("FillJets", "Debug");
e8f1e037 368 if(!jetFinder) {
af33fc68 369 if(fDebug>1) Info("FillJets", "jetFinder is zero");
e8f1e037 370 return;
371 }
2f2f4d2b 372 fnjet = jetFinder->Njets();
373 if(fnjet>10) {
374 if(fDebug>1) Warning("FillJets", "wrong value of jetFinder->Njets() %i ", fnjet);
375 fnjet = 10;
e8f1e037 376 }
1dc41dd9 377 // fhNJet->Fill(njet);
2f2f4d2b 378 if(fDebug>1) Info("FillJets", "njet %i", fnjet);
379 if(fnjet){
380 for(Int_t i=0; i<fnjet; i++){
381 fjet[i] = jetFinder->JetEnergy(i);
382 fjetaw[i] = jetFinder->JetEtaW(i);
383 fjphiw[i] = jetFinder->JetPhiW(i);
384 fjetal[i] = jetFinder->JetEtaL(i);
385 fjphil[i] = jetFinder->JetPhiL(i);
e8f1e037 386 }
387 }
388}
389
6ec7dfce 390void AliEMCALJetMicroDst::FillEtForEMCAL(AliEMCALJetFinder* jetFinder)
391{
1dc41dd9 392 // Fill Et for EMCAL
2f2f4d2b 393 fncell = 0;
6ec7dfce 394 TH2F *hid = jetFinder->GetLegoEMCAL();
395 if(!hid) return;
396
397 Double_t de = 0.;
398 Int_t neta = hid->GetNbinsX(), nphi = hid->GetNbinsY();
399 for(Int_t ieta=1; ieta<=neta; ieta++) {
400 for(Int_t iphi=1; iphi<=nphi; iphi++) {
401 de = hid->GetBinContent(ieta,iphi);
402 if(de > 0.0) {
2f2f4d2b 403 fetcell[fncell] = Float_t(de);
404 fidcell[fncell] = nphi*(ieta-1) + iphi;
405 fncell++;
406 if(fncell >= 13824) break;
af33fc68 407 // Info("FillEtForEMCAL", " ncell %i6 id %i6 de %f \n", ncell, idcell[ncell], etcell[ncell]);
6ec7dfce 408 }
409 }
410 }
2f2f4d2b 411 if(fnjet == 1) {
6ec7dfce 412 // jet energy calculate around LP direction !!! - 10-mar-2003
2f2f4d2b 413 fdecone = jetFinder->EMCALConeEnergy(fjetal[0],fjphil[0]);
414 fptcone = jetFinder->TrackConeEnergy(fjetal[0],fjphil[0]); // get from lego plot fo ch.part
415 Info("FillEtForEMCAL", " njet %i Emcal in cone %f pt ch.part in cone %f\n", fnjet, fdecone, fptcone);
416 Info("FillEtForEMCAL", " jet - decone - ptcone : %9.2f\n", fjet[0]-fdecone-fptcone);
6ec7dfce 417 } else {
2f2f4d2b 418 fdecone = -1.;
419 fptcone = -1.;
6ec7dfce 420 }
421
af33fc68 422 Info("FillEtForEMCAL", "neta %3i nphi %3i # array size %i Sum.Et %f\n",
2f2f4d2b 423 neta,nphi, fncell, hid->Integral());
6ec7dfce 424}
425
426void AliEMCALJetMicroDst::FillEtForGrid(AliEMCALJetFinder* jetFinder)
427{
1dc41dd9 428 // Fill ET for Grid
6ec7dfce 429 TH2F *hid = jetFinder->GetLego();
430 if(!hid) return;
431
2f2f4d2b 432 FillArrays(hid, fngrid, fidgrid, fetgrid);
6ec7dfce 433}
434
435void AliEMCALJetMicroDst::FillArrays(TH2* hid, Int_t &n, Int_t *id, Float_t *et)
436{
1dc41dd9 437 // Fill arays
6ec7dfce 438 n = 0;
439 Double_t de = 0.;
440 Int_t neta = hid->GetNbinsX(), nphi = hid->GetNbinsY();
441 for(Int_t ieta=1; ieta<=neta; ieta++) {
442 for(Int_t iphi=1; iphi<=nphi; iphi++) {
443 de = hid->GetBinContent(ieta,iphi);
444 if(de > 0.0) {
445 et[n] = Float_t(de);
446 id[n] = nphi*(ieta-1) + iphi;
447 n++;
448 if(n >= 13824) break;
449 }
450 }
451 }
af33fc68 452 Info("FillArrays", "neta %3i nphi %3i # array size %i Sum.Et %f\n",
6ec7dfce 453 neta, nphi, n, hid->Integral());
454}
455
456void AliEMCALJetMicroDst::FillChargeParticles(AliEMCALJetFinder* jetFinder)
1dc41dd9 457{
458 // 28-jan-2003 for fullness ; 18-mar - sometimes
2f2f4d2b 459 fnchp = 0;
6ec7dfce 460 Int_t gid=0;
461 for(Int_t i=0; i<jetFinder->fNt; i++) {
462 // fPdgT[i];
463 if(jetFinder->fTrackList[i] >= 1) {
464 sgpdge_(jetFinder->fPdgT[i], gid);
2f2f4d2b 465 fpid[fnchp] = gid;
466 fppt[fnchp] = jetFinder->fPtT[i];
467 fpeta[fnchp] = jetFinder->fEtaT[i];
468 fpphi[fnchp] = jetFinder->fPhiT[i];
469 fnchp++;
6ec7dfce 470 }
471 }
2f2f4d2b 472 Info("FillChargedParticles", "fNtS %i : nchp %i -> %i\n", jetFinder->fNtS, fnchp, jetFinder->fNtS - fnchp);
6ec7dfce 473}
474
475void AliEMCALJetMicroDst::FillJetsControl()
1dc41dd9 476{
477 // see FillJets(AliEMCALJetFinder* jetFinder) and FillPartons
478 fhNJet->Fill(fnjet);
2f2f4d2b 479 for(Int_t i=0; i<fnjet; i++){
1dc41dd9 480 fhPtJet->Fill(fjet[i]);
481 fhEtaPhiJet->Fill(fjetaw[i],fjphiw[i]);
6ec7dfce 482 }
483
2f2f4d2b 484 for(Int_t i=0; i < fnpart; i++){
1dc41dd9 485 fhEtaPhiPart->Fill(fxeta[i], fxphi[i]);
486 fhPtPart->Fill(fxpt[i]);
6ec7dfce 487 }
488
489 Double_t sum = 0.0;
1dc41dd9 490 fhNcell->Fill(fncell);
2f2f4d2b 491 for(Int_t i=0; i < fncell; i++){
1dc41dd9 492 fhCellId->Fill(fidcell[i]);
493 fhCellEt->Fill(fetcell[i]);
2f2f4d2b 494 sum += Double_t(fetcell[i]);
6ec7dfce 495 }
1dc41dd9 496 fhSumEt->Fill(sum);
6ec7dfce 497
498 sum = 0.0;
1dc41dd9 499 fhNgrid->Fill(fngrid);
2f2f4d2b 500 for(Int_t i=0; i < fngrid; i++){
1dc41dd9 501 fhGridId->Fill(fidgrid[i]);
502 fhGridEt->Fill(fetgrid[i]);
2f2f4d2b 503 sum += Double_t(fetgrid[i]);
6ec7dfce 504 }
1dc41dd9 505 fhSumEtGrForJF->Fill(sum);
6ec7dfce 506}
507
e8f1e037 508Int_t AliEMCALJetMicroDst::GetEntry(Int_t entry)
1dc41dd9 509{
510 // Read contents of entry.
e8f1e037 511 if (!fTree) {
af33fc68 512 Error("GetEntry", "define TTree");
e8f1e037 513 return -1;
514 }
515 return fTree->GetEntry(entry);
516}
517
1dc41dd9 518Bool_t AliEMCALJetMicroDst::GetParton(Int_t i, Float_t& pt, Float_t& eta, Float_t& phi) const
e8f1e037 519{
1dc41dd9 520 // Get parton
2f2f4d2b 521 if(i>=0 && i<fnpart) {
522 pt = fxpt[i];
523 eta = fxeta[i];
524 phi = fxphi[i];
e8f1e037 525 return kTRUE;
526 } else return kFALSE;
527}
528
1dc41dd9 529Bool_t AliEMCALJetMicroDst::GetParton(Int_t i, TVector3& vec) const
e8f1e037 530{
1dc41dd9 531 // Get Parton
e8f1e037 532 static Float_t pt, eta, phi;
533
534 if(!GetParton(i, pt, eta, phi)) return kFALSE;
535
536 FillVector(pt, eta, phi, vec);
537 return kTRUE;
538}
539
1dc41dd9 540Bool_t AliEMCALJetMicroDst::GetJet(Int_t i,Int_t mode,Float_t& pt, Float_t& eta, Float_t& phi) const
541{
542 // mode=1(W) mode=any(L)
2f2f4d2b 543 if(i>=0 && i<fnjet) {
544 pt = fjet[i];
e8f1e037 545 if(mode==1) {
2f2f4d2b 546 eta = fjetaw[i];
547 phi = fjphiw[i];
e8f1e037 548 } else {
2f2f4d2b 549 eta = fjetal[i];
550 phi = fjphil[i];
e8f1e037 551 }
552 return kTRUE;
553 } else return kFALSE;
554}
555
1dc41dd9 556Bool_t AliEMCALJetMicroDst::GetJet(Int_t i, Int_t mode, TVector3& vec) const
e8f1e037 557{
1dc41dd9 558 // Get Jet
e8f1e037 559 static Float_t pt, eta, phi;
560
561 if(!GetJet(i, mode, pt, eta, phi)) return kFALSE;
562 FillVector(pt, eta, phi, vec);
563 return kTRUE;
564}
565
566void AliEMCALJetMicroDst::Test()
567{
1dc41dd9 568 // Test
e8f1e037 569 if(!fFile || !fTree ) {
af33fc68 570 Info("Test", "define file with proper TTree !");
e8f1e037 571 return;
572 }
573 Int_t nbytes=0, nb=0, nentries=Int_t(fTree->GetEntries());
574 for(Int_t i=0; i<nentries; i++){
575 nb = fTree->GetEntry(i);
576 nbytes += nb;
2f2f4d2b 577 for(Int_t j=0; j<fnpart; j++){
1dc41dd9 578 fhEtaPhiPart->Fill(fxeta[j], fxphi[j]);
579 fhPtPart->Fill(fxpt[j]);
e8f1e037 580 }
581
1dc41dd9 582 fhNJet->Fill(fnjet);
2f2f4d2b 583 if(fnjet){
584 for(Int_t j=0; j<fnjet; j++) {
1dc41dd9 585 fhPtJet->Fill(fjet[j]);
586 fhEtaPhiJet->Fill(fjetaw[j],fjphiw[j]);
e8f1e037 587 }
588 }
589 }
af33fc68 590 Info("Test", "Entries %5i Bytes %10i\n", nentries, nbytes);
e8f1e037 591}
592
593void AliEMCALJetMicroDst::FillVector(Float_t pt, Float_t eta, Float_t phi, TVector3& vec)
1dc41dd9 594{
595 // service function
e8f1e037 596 static Float_t px, py, pz;
597
598 px = pt*TMath::Cos(phi);
599 py = pt*TMath::Sin(phi);
600 pz = pt*TMath::SinH(eta); // sinh(eta) = cot(theta)
601
602 vec.SetXYZ(px, py, pz);
603}
604
1dc41dd9 605void AliEMCALJetMicroDst::GetEtaPhi(Int_t id, Double_t &eta, Double_t &phi) const
606{
607 // see AliEMCALGeometry
6ec7dfce 608 static Int_t ieta, iphi, nphi=144, neta=96;
6e10fc78 609 static Double_t phiMax=(2.0/3.0)*TMath::Pi(), phiMin=0.0;
6ec7dfce 610 static Double_t phiStep=(phiMax-phiMin)/nphi, phiBeg = phiMin + phiStep/2.;
611 static Double_t etaMax=0.7, etaMin=-etaMax;
612 static Double_t etaStep=(etaMax-etaMin)/neta, etaBeg = etaMin + etaStep/2.;
613
614 ieta = (id-1)/nphi + 1; // id = nphi*(ieta-1) + iphi
615 iphi = id - nphi*(ieta-1);
616 if(ieta<=0 || ieta>neta) {
af33fc68 617 Fatal("GetEtaPhi", "wrong id %i(ieta %i,iphi %i) : nphi %i neta %i", id,iphi,ieta, nphi,neta);
618
6ec7dfce 619 }
620
621 eta = etaBeg + etaStep*(ieta-1);
622 phi = phiBeg + phiStep*(iphi-1);
623}
624
1dc41dd9 625TVector3& AliEMCALJetMicroDst::GetCellVector(Int_t i) const
6ec7dfce 626{
1dc41dd9 627 // Get cell vector
6ec7dfce 628 static Double_t eta,phi;
629 static TVector3 vec;
630 vec.SetXYZ(0.,0.,0.);
2f2f4d2b 631 if(i>=0 && i<fncell) {
632 GetEtaPhi(fidcell[i], eta, phi);
633 vec.SetPtEtaPhi(Double_t(fetcell[i]),eta,phi);
6ec7dfce 634 }
635 return vec;
636}
637
1dc41dd9 638TVector3& AliEMCALJetMicroDst::GetGridVector(Int_t i) const
6ec7dfce 639{
1dc41dd9 640 // Get grid vector
6ec7dfce 641 static Double_t eta,phi;
642 static TVector3 vec;
643 vec.SetXYZ(0.,0.,0.);
2f2f4d2b 644 if(i>=0 && i<fngrid) {
645 GetEtaPhi(fidgrid[i], eta, phi);
646 vec.SetPtEtaPhi(Double_t(fetgrid[i]),eta,phi);
6ec7dfce 647 }
648 return vec;
649}
650
1dc41dd9 651Double_t AliEMCALJetMicroDst::GetSumInCone(TVector3 &jet,Int_t nc, Float_t *et,Float_t *eta,Float_t *phi, Double_t cellEtCut, Double_t rJet) const
6ec7dfce 652{
1dc41dd9 653 // Get Sum in cone
6ec7dfce 654 static Double_t sum=0.;
655 static TVector3 cell(0., 0., 0.);
656 if(nc<=0 || et==0 || eta==0 || phi==0) {
af33fc68 657 Error("GetSumInCone", "nc %d %f %f %f ", nc, et, eta, phi);
6ec7dfce 658 return -1.;
659 }
660
661 sum=0.;
662 // jet.SetPtEtaPhi(jet[0],jetaw[0],jphiw[0]); // must be one jet !!
2f2f4d2b 663 Info("GetSumInCone", "jet.Mag() %f : njet %i\n", jet.Mag(), fnjet);
6ec7dfce 664 for(Int_t i=0; i<nc; i++){
665 if(et[i] < cellEtCut) continue;
666 cell.SetPtEtaPhi(et[i], eta[i], phi[i]);
667 if(jet.DeltaR(cell) > rJet) continue;
668 sum += et[i];
669 }
af33fc68 670 Info("GetSumCone", "Sum %f \n", sum);
6ec7dfce 671 return sum;
672}
673
1dc41dd9 674Double_t AliEMCALJetMicroDst::GetEmcalEtInCone(TVector3 &jet, Double_t cellEtCut, Double_t rJet)
6ec7dfce 675{
1dc41dd9 676 // Get EMCAL Et in cone
2f2f4d2b 677 Int_t nc = fncell;
6ec7dfce 678 if(nc<=0) return 0.;
679
2f2f4d2b 680 Float_t *et=fetcell, *eta=new Float_t[nc], *phi=new Float_t[nc];
681 Double_t etaCell=0., phiCell=0., eTotal=0;
6ec7dfce 682
683 for(Int_t i=0; i<nc; i++) {
2f2f4d2b 684 GetEtaPhi(fidcell[i], etaCell, phiCell);
6ec7dfce 685 eta[i] = etaCell;
686 phi[i] = phiCell;
687 }
688
2f2f4d2b 689 eTotal = GetSumInCone(jet, nc, et,eta,phi, cellEtCut,rJet);
6ec7dfce 690 delete [] eta;
691 delete [] phi;
692
2f2f4d2b 693 return eTotal;
6ec7dfce 694}
695
1dc41dd9 696Double_t AliEMCALJetMicroDst::GetTpcPtInCone(TVector3 &jet,Double_t cellEtCut, Double_t rJet)
6ec7dfce 697{
1dc41dd9 698 // Get TPC PT in cone
2f2f4d2b 699 if(fnchp<=0) return 0.;
700 return GetSumInCone(jet, fnchp, fppt,fpeta,fpphi, cellEtCut,rJet);
6ec7dfce 701}
702
1dc41dd9 703Double_t AliEMCALJetMicroDst::GetSum(Int_t n, Float_t *ar, Double_t cut) const
704{
705 // 25-apr-2003
6ec7dfce 706 Double_t sum=0.0;
707 if(n<=0 || ar==0) return sum;
708 for(Int_t i=0; i<n; i++) {if(ar[i]>=cut) sum += Double_t(ar[i]);}
709 return sum;
710}
711
038b4fc0 712void AliEMCALJetMicroDst::Close()
e8f1e037 713{
1dc41dd9 714 // Close
e8f1e037 715 fFile->Write();
716 fTree->Print();
717 fFile->Close();
718 fFile = 0;
719 fTree = 0;
720}
721
1dc41dd9 722void AliEMCALJetMicroDst::Browse(TBrowser* b) const
e8f1e037 723{
1dc41dd9 724 // Browse
e8f1e037 725 if(fTree) b->Add((TObject*)fTree);
726 if(fListHist) b->Add((TObject*)fListHist);
727 // TObject::Browse(b);
728}
729
1dc41dd9 730Bool_t AliEMCALJetMicroDst::IsPythiaDst() const
6ec7dfce 731{
1dc41dd9 732 // Is Pythia DST
6ec7dfce 733 TString st(GetTitle());
734 if(st.Contains("py",TString::kIgnoreCase)||!st.Contains("hijing", TString::kIgnoreCase)) return kTRUE;
735 else return kFALSE;
736}
737
038b4fc0 738Bool_t AliEMCALJetMicroDst::IsFolder() const
e8f1e037 739{
1dc41dd9 740 // Is folder
e8f1e037 741 if(fTree || fListHist) return kTRUE;
742 else return kFALSE;
743}
744
8e8eae84 745TList* AliEMCALJetMicroDst::MoveHistsToList(const char* name, Bool_t putToBrowser)
e8f1e037 746{
1dc41dd9 747 // Move HIST to list
e8f1e037 748 gROOT->cd();
749 TIter nextHist(gDirectory->GetList());
750 TList *list = new TList;
751 list->SetName(name);
752 TObject *objHist;
753 while((objHist=nextHist())){
754 if (!objHist->InheritsFrom("TH1")) continue;
755 ((TH1*)objHist)->SetDirectory(0); // Remove from gROOT
756 list->Add(objHist);
757 }
758 if(putToBrowser) gROOT->GetListOfBrowsables()->Add((TObject*)list);
759 return list;
760}