]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EMCAL/AliEMCALJetFinder.cxx
Size of data member arrays corrected
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALJetFinder.cxx
CommitLineData
471f69dc 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
803d1ab0 16/* $Id$ */
d594b22e 17
0c207dbc 18//*-- Authors: Andreas Morsch (CERN)
19//* J.L. Klay (LBL)
20//* Aleksei Pavlinov (WSU)
910ac8c6 21//--
22//--
3fb730f8 23//
0c207dbc 24
c44ecd4c 25#include <stdio.h>
d594b22e 26// From root ...
116cbefd 27#include <TArrayF.h>
28#include <TAxis.h>
d594b22e 29#include <TBranchElement.h>
116cbefd 30#include <TCanvas.h>
31#include <TClonesArray.h>
471f69dc 32#include <TFile.h>
c44ecd4c 33#include <TH1.h>
471f69dc 34#include <TH2.h>
b561574c 35#include <TList.h>
116cbefd 36#include <TPDGCode.h>
c44ecd4c 37#include <TPad.h>
471f69dc 38#include <TParticle.h>
39#include <TParticlePDG.h>
116cbefd 40#include <TPaveText.h>
b561574c 41#include <TPythia6Calls.h>
116cbefd 42#include <TROOT.h>
43#include <TStyle.h>
44#include <TTree.h>
f6ada3ae 45#include <TBrowser.h>
d594b22e 46
47// From AliRoot ...
5dee926e 48#include "AliEMCALJetFinder.h"
49#include "AliHeader.h"
50#include "AliMagF.h"
51#include "AliMagFCM.h"
52#include "AliRun.h"
53#include "AliGenerator.h"
54#include "AliRunLoader.h"
116cbefd 55#include "AliEMCAL.h"
5dee926e 56#include "AliEMCALLoader.h"
d594b22e 57#include "AliEMCALDigit.h"
58#include "AliEMCALDigitizer.h"
116cbefd 59#include "AliEMCALFast.h"
60#include "AliEMCALGeometry.h"
d594b22e 61#include "AliEMCALHadronCorrection.h"
116cbefd 62#include "AliEMCALHit.h"
b561574c 63#include "AliEMCALJetMicroDst.h"
5dee926e 64
ff114de3 65// Interface to FORTRAN
66#include "Ecommon.h"
5d12ce38 67#include "AliMC.h"
ff114de3 68
69
471f69dc 70ClassImp(AliEMCALJetFinder)
71
72//____________________________________________________________________________
73AliEMCALJetFinder::AliEMCALJetFinder()
74{
75// Default constructor
d594b22e 76 fJets = 0;
77 fNjets = 0;
78 fLego = 0;
ff114de3 79 fLegoB = 0;
b561574c 80
d594b22e 81 fTrackList = 0;
82 fPtT = 0;
83 fEtaT = 0;
84 fPhiT = 0;
975127ed 85 fPdgT = 0;
86
b561574c 87 fTrackListB = 0;
ff114de3 88 fPtB = 0;
89 fEtaB = 0;
90 fPhiB = 0;
975127ed 91 fPdgB = 0;
b561574c 92
b7a73953 93 fHCorrection = 0;
d594b22e 94 fHadronCorrector = 0;
b7a73953 95
c44ecd4c 96 fWrite = 0;
08a3fb06 97 fOutFileName = 0;
98 fOutFile = 0;
99 fInFile = 0;
100 fEvent = 0;
b7a73953 101
220d7b7b 102 fRandomBg = 0;
103
b7a73953 104 SetParametersForBgSubtraction();
471f69dc 105}
106
107AliEMCALJetFinder::AliEMCALJetFinder(const char* name, const char *title)
108 : TTask(name, title)
109{
110// Constructor
c44ecd4c 111// Title is used in method GetFileNameForParameters();
112//
471f69dc 113 fJets = new TClonesArray("AliEMCALJet",10000);
114 fNjets = 0;
d594b22e 115 for (Int_t i = 0; i < 30000; i++)
471f69dc 116 {
117 fEtCell[i] = 0.;
118 fEtaCell[i] = 0.;
119 fPhiCell[i] = 0.;
120 }
b561574c 121 fLego = 0;
122 fLegoB = 0;
123
ff114de3 124 fTrackList = 0;
125 fPtT = 0;
126 fEtaT = 0;
127 fPhiT = 0;
975127ed 128 fPdgT = 0;
b561574c 129
130 fTrackListB = 0;
ff114de3 131 fPtB = 0;
132 fEtaB = 0;
133 fPhiB = 0;
975127ed 134 fPdgB = 0;
b561574c 135
b7a73953 136 fHCorrection = 0;
137 fHadronCorrector = 0;
138 fBackground = 0;
c44ecd4c 139 fWrite = 0;
08a3fb06 140 fOutFileName = 0;
141 fOutFile = 0;
142 fInFile = 0;
143 fEvent = 0;
0c207dbc 144//
d594b22e 145 SetPtCut();
146 SetMomentumSmearing();
147 SetEfficiencySim();
148 SetDebug();
149 SetHadronCorrection();
d53b7b0b 150 SetIncludeK0andN();
471f69dc 151
220d7b7b 152 fRandomBg = 0;
b7a73953 153 SetParametersForBgSubtraction();
154}
471f69dc 155
b7a73953 156void AliEMCALJetFinder::SetParametersForBgSubtraction
157(Int_t mode, Float_t minMove, Float_t maxMove, Float_t precBg)
158{
159// see file /home/pavlinov/cosmic/pythia/jetFinderParamData.inc
160// at WSU Linux cluster - 11-feb-2002
161// These parameters must be tuned more carefull !!!
162 SetMode(mode);
163 SetMinMove(minMove);
164 SetMaxMove(maxMove);
165 SetPrecBg(precBg);
166}
471f69dc 167
168//____________________________________________________________________________
169AliEMCALJetFinder::~AliEMCALJetFinder()
170{
171// Destructor
172//
173 if (fJets){
174 fJets->Delete();
175 delete fJets;
176 }
759ae494 177 delete fLego;
178 delete fLegoB;
179 delete fhLegoTracks;
180 delete fhLegoEMCAL;
181 delete fhLegoHadrCorr;
182 delete fhEff;
183 delete fhCellEt;
184 delete fhCellEMCALEt;
185 delete fhTrackPt;
186 delete fhTrackPtBcut;
187 delete fhChPartMultInTpc;
188
189 delete[] fTrackList;
190 delete[] fPtT;
191 delete[] fEtaT;
192 delete[] fPhiT;
193 delete[] fPdgT;
194
195 delete[] fTrackListB;
196 delete[] fPtB;
197 delete[] fEtaB;
198 delete[] fPhiB;
199 delete[] fPdgB;
471f69dc 200}
201
471f69dc 202#ifndef WIN32
203# define jet_finder_ua1 jet_finder_ua1_
204# define hf1 hf1_
205# define type_of_call
206
207#else
975127ed 208# define jet_finder_ua1 JET_FINDER_UA1
471f69dc 209# define hf1 HF1
210# define type_of_call _stdcall
211#endif
212
213extern "C" void type_of_call
214jet_finder_ua1(Int_t& ncell, Int_t& ncell_tot,
215 Float_t etc[30000], Float_t etac[30000],
216 Float_t phic[30000],
217 Float_t& min_move, Float_t& max_move, Int_t& mode,
218 Float_t& prec_bg, Int_t& ierror);
219
220extern "C" void type_of_call hf1(Int_t& id, Float_t& x, Float_t& wgt);
975127ed 221
471f69dc 222
08a3fb06 223void AliEMCALJetFinder::Init()
224{
225//
226// Geometry and I/O initialization
227//
228//
229//
230// Get geometry parameters from EMCAL
231//
232//
5dee926e 233// Geometry
234 //AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
235 AliEMCALGeometry* geom = AliEMCALGeometry::GetInstance();
5649a778 236
02e079d4 237// SetSamplingFraction(geom->GetSampling());
5649a778 238
08a3fb06 239 fNbinEta = geom->GetNZ();
240 fNbinPhi = geom->GetNPhi();
241 fPhiMin = geom->GetArm1PhiMin()*TMath::Pi()/180.;
242 fPhiMax = geom->GetArm1PhiMax()*TMath::Pi()/180.;
243 fEtaMin = geom->GetArm1EtaMin();
244 fEtaMax = geom->GetArm1EtaMax();
6fe407f0 245 fDphi = (fPhiMax-fPhiMin)/fNbinPhi;
08a3fb06 246 fDeta = (fEtaMax-fEtaMin)/fNbinEta;
247 fNtot = fNbinPhi*fNbinEta;
7deee4ae 248 fWeightingMethod = kFALSE;
249
08a3fb06 250//
251 SetCellSize(fDeta, fDphi);
252//
253// I/O
254 if (fOutFileName) fOutFile = new TFile(fOutFileName, "recreate");
220d7b7b 255//
256//
08a3fb06 257}
471f69dc 258
910ac8c6 259void AliEMCALJetFinder::Find(Int_t ncell, Int_t ncelltot, Float_t etc[30000],
471f69dc 260 Float_t etac[30000], Float_t phic[30000],
910ac8c6 261 Float_t minmove, Float_t maxmove, Int_t mode,
262 Float_t precbg, Int_t ierror)
471f69dc 263{
264// Wrapper for fortran coded jet finder
265// Full argument list
910ac8c6 266 jet_finder_ua1(ncell, ncelltot, etc, etac, phic,
267 minmove, maxmove, mode, precbg, ierror);
471f69dc 268 // Write result to output
b7a73953 269 if(fWrite) WriteJets();
270 fEvent++;
471f69dc 271}
272
273void AliEMCALJetFinder::Find()
274{
275// Wrapper for fortran coded jet finder using member data for
276// argument list
277
910ac8c6 278 Float_t minmove = fMinMove;
279 Float_t maxmove = fMaxMove;
b7a73953 280 Int_t mode = fMode;
910ac8c6 281 Float_t precbg = fPrecBg;
b7a73953 282 Int_t ierror;
b7a73953 283 ResetJets(); // 4-feb-2002 by PAI
471f69dc 284
285 jet_finder_ua1(fNcell, fNtot, fEtCell, fEtaCell, fPhiCell,
910ac8c6 286 minmove, maxmove, mode, precbg, ierror);
b7a73953 287 fError = ierror;
471f69dc 288 // Write result to output
3bc109a9 289 Int_t njet = Njets();
d594b22e 290
3bc109a9 291 for (Int_t nj=0; nj<njet; nj++)
292 {
7deee4ae 293 if (fWeightingMethod)
294 {
295 fJetT[nj] = new AliEMCALJet(WeightedJetEnergy( JetEtaW(nj),JetPhiW(nj) ),
296 JetPhiW(nj),
297 JetEtaW(nj));
298
299 }else{
300
3bc109a9 301 fJetT[nj] = new AliEMCALJet(JetEnergy(nj),
302 JetPhiW(nj),
303 JetEtaW(nj));
7deee4ae 304 }
305 fJetT[nj]->SetIsWeightedEnergy(fWeightingMethod);
306 fJetT[nj]->SetEMCALEnergy( EMCALConeEnergy(JetEtaW(nj),JetPhiW(nj)) );
307 fJetT[nj]->SetTrackEnergy(TrackConeEnergy( JetEtaW(nj),JetPhiW(nj) ));
7deee4ae 308
3bc109a9 309 }
b7a73953 310
c44ecd4c 311 FindTracksInJetCone();
b7a73953 312 if(fWrite) WriteJets();
08a3fb06 313 fEvent++;
471f69dc 314}
315
7deee4ae 316
317Float_t AliEMCALJetFinder::EMCALConeEnergy(Float_t eta, Float_t phi)
318{
3fb730f8 319// Calculate the energy in the cone
7deee4ae 320Float_t newenergy = 0.0;
321Float_t bineta,binphi;
322TAxis *x = fhLegoEMCAL->GetXaxis();
323TAxis *y = fhLegoEMCAL->GetYaxis();
324for (Int_t i = 0 ; i < fNbinEta ; i++) // x coord
325 {
326 for (Int_t j = 0 ; j < fNbinPhi ; j++) // y coord
327 {
328 bineta = x->GetBinCenter(i);
329 binphi = y->GetBinCenter(j);
330 if ( (bineta-eta)*(bineta-eta) + (binphi-phi)*(binphi-phi) < fConeRadius*fConeRadius)
331 {
332 newenergy += fhLegoEMCAL->GetBinContent(i,j);
333 }
334 }
335}
336return newenergy;
337}
338
339Float_t AliEMCALJetFinder::TrackConeEnergy(Float_t eta, Float_t phi)
340{
3fb730f8 341// Calculate the track energy in the cone
7deee4ae 342Float_t newenergy = 0.0;
343Float_t bineta,binphi;
344TAxis *x = fhLegoTracks->GetXaxis();
345TAxis *y = fhLegoTracks->GetYaxis();
346for (Int_t i = 0 ; i < fNbinEta ; i++) // x coord
347 {
348 for (Int_t j = 0 ; j < fNbinPhi ; j++) // y coord
349 {
350 bineta = x->GetBinCenter(i);
351 binphi = y->GetBinCenter(j);
352 if ( (bineta-eta)*(bineta-eta) + (binphi-phi)*(binphi-phi) < fConeRadius*fConeRadius)
353 {
354 newenergy += fhLegoTracks->GetBinContent(i,j);
355 }
356 }
357}
358return newenergy;
359}
360
7deee4ae 361
362Float_t AliEMCALJetFinder::WeightedJetEnergy(Float_t eta, Float_t phi)
363{
3fb730f8 364// Calculate the weighted jet energy
365
7deee4ae 366Float_t newenergy = 0.0;
367Float_t bineta,binphi;
368TAxis *x = fhLegoEMCAL->GetXaxis();
369TAxis *y = fhLegoEMCAL->GetYaxis();
370
371
372for (Int_t i = 0 ; i < fNbinEta ; i++) // x coord
373{
374 for (Int_t j = 0 ; j < fNbinPhi ; j++) // y coord
375 {
376 bineta = x->GetBinCenter(i);
377 binphi = y->GetBinCenter(j);
378 if ( (bineta-eta)*(bineta-eta) + (binphi-phi)*(binphi-phi) < fConeRadius*fConeRadius)
379 {
380 newenergy += (fEMCALWeight)* fhLegoEMCAL->GetBinContent(i,j) + (fTrackWeight)* fhLegoTracks->GetBinContent(i,j);
381 }
382 }
383}
384
385return newenergy;
386
387}
388
389
3fb730f8 390Int_t AliEMCALJetFinder::Njets() const
471f69dc 391{
392// Get number of reconstructed jets
393 return EMCALJETS.njet;
394}
395
910ac8c6 396Float_t AliEMCALJetFinder::JetEnergy(Int_t i) const
471f69dc 397{
398// Get reconstructed jet energy
399 return EMCALJETS.etj[i];
400}
401
910ac8c6 402Float_t AliEMCALJetFinder::JetPhiL(Int_t i) const
471f69dc 403{
404// Get reconstructed jet phi from leading particle
405 return EMCALJETS.phij[0][i];
406}
407
910ac8c6 408Float_t AliEMCALJetFinder::JetPhiW(Int_t i) const
471f69dc 409{
410// Get reconstructed jet phi from weighting
411 return EMCALJETS.phij[1][i];
412}
413
910ac8c6 414Float_t AliEMCALJetFinder::JetEtaL(Int_t i) const
471f69dc 415{
416// Get reconstructed jet eta from leading particles
417 return EMCALJETS.etaj[0][i];
418}
419
420
910ac8c6 421Float_t AliEMCALJetFinder::JetEtaW(Int_t i) const
471f69dc 422{
423// Get reconstructed jet eta from weighting
424 return EMCALJETS.etaj[1][i];
425}
426
427void AliEMCALJetFinder::SetCellSize(Float_t eta, Float_t phi)
428{
429// Set grid cell size
430 EMCALCELLGEO.etaCellSize = eta;
431 EMCALCELLGEO.phiCellSize = phi;
432}
433
434void AliEMCALJetFinder::SetConeRadius(Float_t par)
435{
436// Set jet cone radius
437 EMCALJETPARAM.coneRad = par;
3bc109a9 438 fConeRadius = par;
471f69dc 439}
440
441void AliEMCALJetFinder::SetEtSeed(Float_t par)
442{
443// Set et cut for seeds
444 EMCALJETPARAM.etSeed = par;
d594b22e 445 fEtSeed = par;
471f69dc 446}
447
448void AliEMCALJetFinder::SetMinJetEt(Float_t par)
449{
450// Set minimum jet et
451 EMCALJETPARAM.ejMin = par;
d594b22e 452 fMinJetEt = par;
471f69dc 453}
454
455void AliEMCALJetFinder::SetMinCellEt(Float_t par)
456{
457// Set et cut per cell
458 EMCALJETPARAM.etMin = par;
d594b22e 459 fMinCellEt = par;
471f69dc 460}
461
3bc109a9 462void AliEMCALJetFinder::SetPtCut(Float_t par)
463{
464// Set pT cut on charged tracks
465 fPtCut = par;
466}
467
471f69dc 468
469void AliEMCALJetFinder::Test()
470{
471//
472// Test the finder call
473//
910ac8c6 474 const Int_t knmax = 30000;
471f69dc 475 Int_t ncell = 10;
910ac8c6 476 Int_t ncelltot = 100;
471f69dc 477
910ac8c6 478 Float_t etc[knmax];
479 Float_t etac[knmax];
480 Float_t phic[knmax];
481 Float_t minmove = 0;
482 Float_t maxmove = 0;
471f69dc 483 Int_t mode = 0;
910ac8c6 484 Float_t precbg = 0;
471f69dc 485 Int_t ierror = 0;
486
487
910ac8c6 488 Find(ncell, ncelltot, etc, etac, phic,
489 minmove, maxmove, mode, precbg, ierror);
471f69dc 490
491}
492
493//
494// I/O
495//
496
497void AliEMCALJetFinder::AddJet(const AliEMCALJet& jet)
498{
499 //
500 // Add a jet
501 //
502 TClonesArray &lrawcl = *fJets;
503 new(lrawcl[fNjets++]) AliEMCALJet(jet);
504}
505
506void AliEMCALJetFinder::ResetJets()
507{
508 //
509 // Reset Jet List
510 //
511 fJets->Clear();
512 fNjets = 0;
513}
514
515void AliEMCALJetFinder::WriteJets()
516{
517//
518// Add all jets to the list
519//
520 const Int_t kBufferSize = 4000;
08a3fb06 521 const char* file = 0;
522
471f69dc 523 Int_t njet = Njets();
08a3fb06 524
3bc109a9 525 for (Int_t nj = 0; nj < njet; nj++)
471f69dc 526 {
3bc109a9 527 AddJet(*fJetT[nj]);
528 delete fJetT[nj];
471f69dc 529 }
3bc109a9 530
08a3fb06 531// I/O
5dee926e 532 AliRunLoader *rl = AliRunLoader::GetRunLoader();
533 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
534
08a3fb06 535 if (!fOutFileName) {
536//
537// output written to input file
538//
88cb7938 539 AliEMCAL* pEMCAL = (AliEMCAL* )gAlice->GetModule("EMCAL");
5dee926e 540 TTree* pK = rl->TreeK();
88cb7938 541 file = (pK->GetCurrentFile())->GetName();
542 TBranch * jetBranch ;
08a3fb06 543 if (fDebug > 1)
e81f4d4f 544 printf("Make Branch - TreeR address %p %p\n",(void*)gAlice->TreeR(), (void*)pEMCAL);
88cb7938 545 //if (fJets && gAlice->TreeR()) {
5dee926e 546 if (fJets && emcalLoader->TreeR()) {
88cb7938 547 // pEMCAL->MakeBranchInTree(gAlice->TreeR(),
5dee926e 548 jetBranch = emcalLoader->TreeR()->Branch("EMCALJets", &fJets, kBufferSize, 0) ;
88cb7938 549 //pEMCAL->MakeBranchInTree(gime->TreeR(),
550 // "EMCALJets",
551 // &fJets,
552 // kBufferSize,
553 // file);
554
555 //Int_t nev = gAlice->GetHeader()->GetEvent();
556 //gAlice->TreeR()->Fill();
557 jetBranch->Fill();
558 //char hname[30];
559 //sprintf(hname,"TreeR%d", nev);
560 //gAlice->TreeR()->Write(hname);
561 //gAlice->TreeR()->Reset();
5dee926e 562 //gime->WriteRecPoints("OVERWRITE");
563 emcalLoader->WriteRecPoints("OVERWRITE");
08a3fb06 564 }
08a3fb06 565 } else {
566//
567// Output written to user specified output file
568//
88cb7938 569 //TTree* pK = gAlice->TreeK();
5dee926e 570 TTree* pK = rl->TreeK();
88cb7938 571 fInFile = pK->GetCurrentFile();
572
573 fOutFile->cd();
574 char hname[30];
575 sprintf(hname,"TreeR%d", fEvent);
576 TTree* treeJ = new TTree(hname, "EMCALJets");
577 treeJ->Branch("EMCALJets", &fJets, kBufferSize);
578 treeJ->Fill();
579 treeJ->Write(hname);
580 fInFile->cd();
08a3fb06 581 }
471f69dc 582 ResetJets();
583}
584
585void AliEMCALJetFinder::BookLego()
586{
587//
f6ada3ae 588// Book histo for discretization
471f69dc 589//
be9787fe 590
610f27c9 591//
592// Don't add histos to the current directory
b561574c 593 if(fDebug) printf("\n AliEMCALJetFinder::BookLego() \n");
594
f6ada3ae 595 // TH2::AddDirectory(0); // hists wil be put to the list from gROOT
596 // TH1::AddDirectory(0);
b561574c 597 gROOT->cd();
471f69dc 598//
46955412 599// Signal map
471f69dc 600 fLego = new TH2F("legoH","eta-phi",
be9787fe 601 fNbinEta, fEtaMin, fEtaMax,
602 fNbinPhi, fPhiMin, fPhiMax);
46955412 603//
604// Background map
b561574c 605 fLegoB = new TH2F("legoB","eta-phi for BG event",
be9787fe 606 fNbinEta, fEtaMin, fEtaMax,
607 fNbinPhi, fPhiMin, fPhiMax);
c44ecd4c 608
609// Tracks map
610 fhLegoTracks = new TH2F("hLegoTracks","eta-phi for Tracks",
611 fNbinEta, fEtaMin, fEtaMax, fNbinPhi, fPhiMin, fPhiMax);
612// EMCAL map
613 fhLegoEMCAL = new TH2F("hLegoEMCAL","eta-phi for EMCAL",
614 fNbinEta, fEtaMin, fEtaMax, fNbinPhi, fPhiMin, fPhiMax);
615// Hadron correction map
616 fhLegoHadrCorr = new TH2F("hLegoHadrCorr","eta-phi for Hadron. Correction",
617 fNbinEta, fEtaMin, fEtaMax, fNbinPhi, fPhiMin, fPhiMax);
618// Hists. for tuning jet finder
619 fhEff = new TH2F("hEff","#epsilon vs momentum ", 100,0.,20., 50,0.5,1.);
620
621 TArrayF eTmp(1101);
622 eTmp[0] = 0.0;
623 for(Int_t i=1; i<=1000; i++) eTmp[i] = 0.1*i; // step 100 mev
624 for(Int_t i=1001; i<=1100; i++) eTmp[i] = eTmp[1000] + 1.0*(i-1000); // step 1GeV
625
626 fhCellEt = new TH1F("hCellEt","Cell E_{T} from fLego",
627 eTmp.GetSize()-1, eTmp.GetArray());
628 fhCellEMCALEt = new TH1F("hCellEMCALEt","Cell E_{T} for EMCAL itself",
629 eTmp.GetSize()-1, eTmp.GetArray());
630 fhTrackPt = new TH1F("hTrackPt","Ch.particles P_{T} ",
631 eTmp.GetSize()-1, eTmp.GetArray());
632 fhTrackPtBcut = new TH1F("hTrackPtBcut","Ch.particles P_{T} + magnetic field cut",
633 eTmp.GetSize()-1, eTmp.GetArray());
b561574c 634
635 fhChPartMultInTpc = new TH1F("hChPartMultInTpc",
636 "Charge partilcle multiplicity in |%eta|<0.9", 2000, 0, 20000);
637
f6ada3ae 638 fhSinTheta = new TH1F("fhSinTheta","sin(theta)", fNbinEta, fEtaMin, fEtaMax);
639 TAxis *xax = fhSinTheta->GetXaxis();
640 for(Int_t i=1; i<=fNbinEta; i++) {
641 Double_t eta = xax->GetBinCenter(i);
642 fhSinTheta->Fill(eta, 1./TMath::CosH(eta)); // cosh(eta) = 1./sin(theta)
643 }
644
645 //! first canvas for drawing
646 fHistsList=AliEMCALJetMicroDst::MoveHistsToList("Hists from AliEMCALJetFinder", kFALSE);
471f69dc 647}
648
649void AliEMCALJetFinder::DumpLego()
650{
651//
652// Dump lego histo into array
653//
654 fNcell = 0;
3fb730f8 655 TAxis* xaxis = fLego->GetXaxis();
656 TAxis* yaxis = fLego->GetYaxis();
c44ecd4c 657 // fhCellEt->Clear();
658 Float_t e, eH;
659 for (Int_t i = 1; i <= fNbinEta; i++) {
660 for (Int_t j = 1; j <= fNbinPhi; j++) {
220d7b7b 661
c44ecd4c 662 e = fLego->GetBinContent(i,j);
220d7b7b 663 if (fRandomBg) {
664 if (gRandom->Rndm() < 0.5) {
665 Float_t ebg = 0.28 * TMath::Abs(gRandom->Gaus(0.,1.));
666 e += ebg;
667 }
668 }
669 if (e > 0.0) e -= fMinCellEt;
670 if (e < 0.0) e = 0.;
3fb730f8 671 Float_t eta = xaxis->GetBinCenter(i);
672 Float_t phi = yaxis->GetBinCenter(j);
220d7b7b 673 fEtCell[fNcell] = e;
674 fEtaCell[fNcell] = eta;
675 fPhiCell[fNcell] = phi;
676 fNcell++;
677 fhCellEt->Fill(e);
c44ecd4c 678 if(fhLegoEMCAL) {
679 eH = fhLegoEMCAL->GetBinContent(i,j);
680 if(eH > 0.0) fhCellEMCALEt->Fill(eH);
681 }
471f69dc 682 } // phi
683 } // eta
02e079d4 684// today
685// fNcell--;
471f69dc 686}
687
688void AliEMCALJetFinder::ResetMap()
689{
690//
691// Reset eta-phi array
692
693 for (Int_t i=0; i<30000; i++)
694 {
695 fEtCell[i] = 0.;
696 fEtaCell[i] = 0.;
697 fPhiCell[i] = 0.;
698 }
699}
700
701
702void AliEMCALJetFinder::FillFromTracks(Int_t flag, Int_t ich)
703{
220d7b7b 704// Which generator
705//
706 const char* name = gAlice->Generator()->GetName();
707 enum {kPythia, kHijing, kHijingPara};
708 Int_t genType = 0;
709
710 if (!strcmp(name, "Hijing")){
711 genType = kHijing;
712 } else if (!strcmp(name, "Pythia")) {
713 genType = kPythia;
714 } else if (!strcmp(name, "HIJINGpara") ||!strcmp(name, "HIGINGpara")) {
715 genType = kHijingPara;
716 }
717 if (fDebug>=2)
718 printf("Fill tracks generated by %s %d\n", name, genType);
719
720
471f69dc 721//
d594b22e 722// Fill Cells with track information
471f69dc 723//
b7a73953 724 if (fDebug >= 2)
725 printf("\n AliEMCALJetFinder::FillFromTracks(%i,%i) ",flag,ich);
b561574c 726 fNChTpc = 0;
b7a73953 727
471f69dc 728 ResetMap();
729
730 if (!fLego) BookLego();
731// Reset
732 if (flag == 0) fLego->Reset();
733//
734// Access particle information
735 Int_t npart = (gAlice->GetHeader())->GetNprimary();
b561574c 736 Int_t ntr = (gAlice->GetHeader())->GetNtrack();
f6ada3ae 737 printf(" : #primary particles %i # tracks %i : (before) Sum.Et %f\n",
738 npart, ntr, fLego->Integral());
b7a73953 739
3bc109a9 740// Create track list
741//
742// 0: not selected
743// 1: selected for jet finding
744// 2: inside jet
745// ....
746 if (fTrackList) delete[] fTrackList;
747 if (fPtT) delete[] fPtT;
748 if (fEtaT) delete[] fEtaT;
749 if (fPhiT) delete[] fPhiT;
975127ed 750 if (fPdgT) delete[] fPdgT;
3bc109a9 751
752 fTrackList = new Int_t [npart];
753 fPtT = new Float_t[npart];
754 fEtaT = new Float_t[npart];
755 fPhiT = new Float_t[npart];
975127ed 756 fPdgT = new Int_t[npart];
ff114de3 757
b561574c 758 fNt = npart;
ff114de3 759 fNtS = 0;
b7a73953 760 Float_t chTmp=0.0; // charge of current particle
b561574c 761 // Int_t idGeant;
ff114de3 762
b561574c 763 // this is for Pythia ??
c44ecd4c 764 for (Int_t part = 0; part < npart; part++) {
910ac8c6 765 TParticle *mPart = gAlice->GetMCApp()->Particle(part);
766 Int_t mpart = mPart->GetPdgCode();
767 Int_t child1 = mPart->GetFirstDaughter();
768 Float_t pT = mPart->Pt();
769 Float_t p = mPart->P();
770 Float_t phi = mPart->Phi();
c44ecd4c 771 Float_t eta = -100.;
910ac8c6 772 if(pT > 0.001) eta = mPart->Eta();
773 Float_t theta = mPart->Theta();
774 if (fDebug>=2 && mPart->GetStatusCode()==1) {
b561574c 775 printf("ind %7i part %7i -> child1 %5i child2 %5i Status %5i\n",
910ac8c6 776 part, mpart, child1, mPart->GetLastDaughter(), mPart->GetStatusCode());
b561574c 777 }
46955412 778
220d7b7b 779 if (fDebug >= 2 && genType == kPythia) {
d594b22e 780 if (part == 6 || part == 7)
781 {
610f27c9 782 printf("\n Simulated Jet (pt, eta, phi): %d %f %f %f\n",
d594b22e 783 part-5, pT, eta, phi);
784 }
d594b22e 785 }
786
b7a73953 787 fTrackList[part] = 0;
788 fPtT[part] = pT; // must be change after correction for resolution !!!
3bc109a9 789 fEtaT[part] = eta;
790 fPhiT[part] = phi;
975127ed 791 fPdgT[part] = mpart;
792
220d7b7b 793// final state particles only
794
795 if (genType == kPythia) {
910ac8c6 796 if (mPart->GetStatusCode() != 1) continue;
220d7b7b 797 } else if (genType == kHijing) {
798 if (child1 >= 0 && child1 < npart) continue;
799 }
800
3dc5be1a 801
26dadf3a 802 TParticlePDG* pdgP = 0;
471f69dc 803// charged or neutral
910ac8c6 804 pdgP = mPart->GetPDG();
b7a73953 805 chTmp = pdgP->Charge() / 3.; // 13-feb-2001!!
759ae494 806
471f69dc 807 if (ich == 0) {
b7a73953 808 if (chTmp == 0) {
809 if (!fK0N) {
d53b7b0b 810 continue;
811 } else {
812 if (mpart != kNeutron &&
813 mpart != kNeutronBar &&
814 mpart != kK0Long) continue;
815 }
816 }
7deee4ae 817 } else if (ich == 2) {
818 if (mpart == kNeutron ||
819 mpart == kNeutronBar ||
820 mpart == kK0Long) continue;
b7a73953 821 }
7deee4ae 822
b561574c 823 if (TMath::Abs(eta)<=0.9) fNChTpc++;
824// final state only
825 if (child1 >= 0 && child1 < npart) continue;
471f69dc 826// acceptance cut
759ae494 827 if (eta > fEtaMax || eta < fEtaMin) continue;
828 if (phi > fPhiMax || phi < fPhiMin ) continue;
d594b22e 829//
b561574c 830 if (fDebug >= 3)
b7a73953 831 printf("\n=>nsel:%5d mpart %5d child1 %5d eta %6.2f phi %6.2f pT %6.2f ch %3.0f ",
832 part, mpart, child1, eta, phi, pT, chTmp);
26dadf3a 833//
26dadf3a 834//
d594b22e 835// Momentum smearing goes here ...
836//
c44ecd4c 837 fhTrackPt->Fill(pT);
b7a73953 838 Float_t pw;
839 if (fSmear && TMath::Abs(chTmp)) {
840 pw = AliEMCALFast::SmearMomentum(1,p);
3dc5be1a 841 // p changed - take into account when calculate pT,
842 // pz and so on .. ?
b7a73953 843 pT = (pw/p) * pT;
b561574c 844 if(fDebug >= 4) printf("\n Smearing : p %8.4f change to %8.4f ", p, pw);
b7a73953 845 p = pw;
d594b22e 846 }
847//
848// Tracking Efficiency and TPC acceptance goes here ...
c44ecd4c 849 Float_t eff;
b7a73953 850 if (fEffic && TMath::Abs(chTmp)) {
7deee4ae 851 eff = 0.9; // AliEMCALFast::Efficiency(2,p);
c44ecd4c 852 if(fhEff) fhEff->Fill(p, eff);
b7a73953 853 if (AliEMCALFast::RandomReject(eff)) {
3dc5be1a 854 if(fDebug >= 5) printf(" reject due to unefficiency ");
855 continue;
b7a73953 856 }
d594b22e 857 }
858//
859// Correction of Hadronic Energy goes here ...
860//
b7a73953 861//
862// phi propagation for hadronic correction
863
864 Bool_t curls = kFALSE; // hit two the EMCAL (no curl)
c44ecd4c 865 Float_t phiHC=0.0, dpH=0.0, dphi=0.0, eTdpH=0;
b7a73953 866 if(TMath::Abs(chTmp)) {
3dc5be1a 867 // hadr. correction only for charge particle
868 dphi = PropagatePhi(pT, chTmp, curls);
869 phiHC = phi + dphi;
870 if (fDebug >= 6) {
871 printf("\n Delta phi %f pT %f ", dphi, pT);
872 if (curls) printf("\n !! Track is curling");
873 }
874 if(!curls) fhTrackPtBcut->Fill(pT);
875
876 if (fHCorrection && !curls) {
877 if (!fHadronCorrector)
878 Fatal("AliEMCALJetFinder",
879 "Hadronic energy correction required but not defined !");
880
881 dpH = fHadronCorrector->GetEnergy(p, eta, 7);
882 eTdpH = dpH*TMath::Sin(theta);
883
884 if (fDebug >= 7) printf(" phi %f phiHC %f eTcorr %f\n",
885 phi, phiHC, -eTdpH); // correction is negative
7deee4ae 886 Int_t xbin,ybin;
887 xbin = fLego->GetXaxis()->FindBin(eta);
888 ybin = fLego->GetYaxis()->FindBin(phiHC);
889 cout <<"Hadron Correction affected bin - contents before correction : "<<fLego->GetBinContent(xbin,ybin)<<endl;
890 fLego->Fill(eta, phi, -fSamplingF*eTdpH );
891 cout <<"Hadron Correction affected bin - contents after correction : "<<fLego->GetBinContent(xbin,ybin)<<endl;
892 fhLegoHadrCorr->Fill(eta, phi, fSamplingF*eTdpH);
3dc5be1a 893 }
b7a73953 894 }
d594b22e 895//
896// More to do ? Just think about it !
897//
759ae494 898 if (phi > fPhiMax || phi < fPhiMin ) continue;
b7a73953 899
900 if(TMath::Abs(chTmp) ) { // charge particle
3dc5be1a 901 if (pT > fPtCut && !curls) {
902 if (fDebug >= 8) printf("Charge : fLego->Fill(%5.2f, %5.2f, %6.2f, %d)\n",
903 eta , phi, pT, fNtS);
904 fLego->Fill(eta, phi, pT);
905 fhLegoTracks->Fill(eta, phi, pT); // 20-feb for checking
906 fTrackList[part] = 1;
907 fNtS++;
908 }
7deee4ae 909 } else if(ich > 0 || fK0N) {
3dc5be1a 910 // case of n, nbar and K0L
911 if (fDebug >= 9) printf("Neutral : fLego->Fill(%5.2f, %5.2f, %6.2f, %d)\n",
912 eta , phi, pT, fNtS);
b7a73953 913 fLego->Fill(eta, phi, pT);
914 fTrackList[part] = 1;
915 fNtS++;
916 }
c44ecd4c 917 } // primary loop
02e079d4 918 Float_t etsum = 0.;
919 for(Int_t i=0; i<fLego->GetSize(); i++) {
920 Float_t etc = (*fLego)[i];
921 if (etc > fMinCellEt) etsum += etc;
922 }
923
f6ada3ae 924 printf("FillFromTracks: Sum above threshold %f -> %f (%f)\n", fMinCellEt, etsum, fLego->Integral());
925 printf(" Track selected(fNtS) %i \n", fNtS);
02e079d4 926
471f69dc 927 DumpLego();
928}
929
930void AliEMCALJetFinder::FillFromHits(Int_t flag)
931{
932//
d594b22e 933// Fill Cells with hit information
471f69dc 934//
935//
b7a73953 936 if (fDebug >= 2)
937 printf("\n AliEMCALJetFinder::FillFromHits(%i)\n",flag);
938
471f69dc 939 ResetMap();
940
941 if (!fLego) BookLego();
c44ecd4c 942// Reset eta-phi maps if needed
943 if (flag == 0) { // default behavior
944 fLego->Reset();
945 fhLegoTracks->Reset();
946 fhLegoEMCAL->Reset();
947 fhLegoHadrCorr->Reset();
948 }
ff114de3 949// Initialize from background event if available
471f69dc 950//
951// Access hit information
952 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
5dee926e 953 AliLoader *emcalLoader = AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL");
954 TTree *treeH = emcalLoader->TreeH();
471f69dc 955 Int_t ntracks = (Int_t) treeH->GetEntries();
956//
957// Loop over tracks
958//
959 Int_t nbytes = 0;
f6ada3ae 960 // Double_t etH = 0.0;
471f69dc 961
471f69dc 962 for (Int_t track=0; track<ntracks;track++) {
963 gAlice->ResetHits();
964 nbytes += treeH->GetEvent(track);
965//
966// Loop over hits
967//
968 for(AliEMCALHit* mHit=(AliEMCALHit*) pEMCAL->FirstHit(-1);
969 mHit;
970 mHit=(AliEMCALHit*) pEMCAL->NextHit())
971 {
972 Float_t x = mHit->X(); // x-pos of hit
973 Float_t y = mHit->Y(); // y-pos
974 Float_t z = mHit->Z(); // z-pos
975 Float_t eloss = mHit->GetEnergy(); // deposited energy
d594b22e 976
977 Float_t r = TMath::Sqrt(x*x+y*y);
978 Float_t theta = TMath::ATan2(r,z);
979 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
980 Float_t phi = TMath::ATan2(y,x);
610f27c9 981
f6ada3ae 982 if (fDebug >= 21) printf("\n Hit %f %f %f %f %f %f %f %f", x, y, z, eloss, r, eta, phi, fSamplingF);
610f27c9 983
f6ada3ae 984 // etH = fSamplingF*eloss*TMath::Sin(theta);
985 fLego->Fill(eta, phi, eloss);
471f69dc 986 } // Hit Loop
987 } // Track Loop
f6ada3ae 988
989 // Transition from deposit energy to eT (eT = de*SF*sin(theta))
990 Double_t etsum = 0;
991 for(Int_t i=1; i<=fLego->GetNbinsX(); i++){ // eta
992 Double_t sinTheta = fhSinTheta->GetBinContent(i), eT=0;
993 for(Int_t j=1; j<=fLego->GetNbinsY(); j++){ // phi
994 eT = fLego->GetBinContent(i,j)*fSamplingF*sinTheta;
995 fLego->SetBinContent(i,j,eT);
996 // copy content of fLego to fhLegoEMCAL (fLego and fhLegoEMCAL are identical)
997 fhLegoEMCAL->SetBinContent(i,j,eT);
998 if (eT > fMinCellEt) etsum += eT;
999 }
02e079d4 1000 }
f6ada3ae 1001
1002 // for(Int_t i=0; i<fLego->GetSize(); i++) {
1003 // (*fhLegoEMCAL)[i] = (*fLego)[i];
1004 // Float_t etc = (*fLego)[i];
1005 // if (etc > fMinCellEt) etsum += etc;
1006 // }
02e079d4 1007
f6ada3ae 1008 printf("FillFromHits: Sum above threshold %f -> %f \n ", fMinCellEt, etsum);
c44ecd4c 1009 // DumpLego(); ??
471f69dc 1010}
1011
d594b22e 1012void AliEMCALJetFinder::FillFromDigits(Int_t flag)
1013{
1014//
1015// Fill Cells with digit information
1016//
1017//
1018 ResetMap();
1019
1020 if (!fLego) BookLego();
1021 if (flag == 0) fLego->Reset();
0798b21e 1022 Int_t nbytes=0;
d594b22e 1023
1024
1025//
1026// Connect digits
1027//
1028 TClonesArray* digs = new TClonesArray("AliEMCALDigit", 10000);
1029 TTree *treeD = gAlice->TreeD();
1030 TBranchElement* branchDg = (TBranchElement*)
1031 treeD->GetBranch("EMCAL");
1032
1033 if (!branchDg) Fatal("AliEMCALJetFinder",
1034 "Reading digits requested but no digits in file !");
1035
1036 branchDg->SetAddress(&digs);
1037 Int_t nent = (Int_t) branchDg->GetEntries();
1038//
1039// Connect digitizer
1040//
1041 AliEMCALDigitizer* digr = new AliEMCALDigitizer();
1042 TBranchElement* branchDr = (TBranchElement*)
1043 treeD->GetBranch("AliEMCALDigitizer");
1044 branchDr->SetAddress(&digr);
1045//
1046//
1047 nbytes += branchDg->GetEntry(0);
1048 nbytes += branchDr->GetEntry(0);
1049//
1050// Get digitizer parameters
88cb7938 1051 Float_t ecADCped = digr->GetECApedestal();
1052 Float_t ecADCcha = digr->GetECAchannel();
d594b22e 1053
1054 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
1055 AliEMCALGeometry* geom =
1056 AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), "");
1057
1058 if (fDebug) {
1059 Int_t ndig = digs->GetEntries();
fdebddeb 1060 Info("FillFromDigits","Number of Digits: %d %d\n Parameters: EC: %f %f\n Geometry: %d %d",
1061 ndig, nent, ecADCped, ecADCcha, geom->GetNEta(), geom->GetNPhi());
d594b22e 1062 }
1063
1064//
1065// Loop over digits
1066 AliEMCALDigit* sdg;
1067 TIter next(digs);
1068 while ((sdg = (AliEMCALDigit*)(next())))
1069 {
8a19c971 1070 Double_t pedestal = 0.;
1071 Double_t channel = 0.;
fdebddeb 1072 if (geom->IsInECA(sdg->GetId())) {
8a19c971 1073 pedestal = ecADCped;
1074 channel = ecADCcha;
fdebddeb 1075 }
8a19c971 1076 else
1077 Fatal("FillFromDigits", "unexpected digit is number!") ;
d594b22e 1078
1079 Float_t eta = sdg->GetEta();
1080 Float_t phi = sdg->GetPhi() * TMath::Pi()/180.;
1081 Float_t amp = (Float_t) (channel*(sdg->GetAmp())-pedestal);
1082
8a19c971 1083 if (fDebug > 1)
1084 Info("FillFromDigits", "Digit: eta %8.3f phi %8.3f amp %8.3f %8d",
d594b22e 1085 eta, phi, amp, sdg->GetAmp());
1086
1087 fLego->Fill(eta, phi, fSamplingF*amp);
1088 } // digit loop
1089//
1090// Dump lego hist
1091 DumpLego();
1092}
1093
1094
1095void AliEMCALJetFinder::FillFromHitFlaggedTracks(Int_t flag)
1096{
1097//
1098// Fill Cells with hit information
1099//
1100//
1101 ResetMap();
1102
1103 if (!fLego) BookLego();
1104// Reset
1105 if (flag == 0) fLego->Reset();
1106
ff114de3 1107// Flag charged tracks passing through TPC which
1108// are associated to EMCAL Hits
d594b22e 1109 BuildTrackFlagTable();
1110
1111//
1112// Access particle information
ff8fdf97 1113 TTree *treeK = gAlice->TreeK();
1114 Int_t ntracks = (Int_t) treeK->GetEntries();
d594b22e 1115
ff114de3 1116 if (fPtT) delete[] fPtT;
1117 if (fEtaT) delete[] fEtaT;
1118 if (fPhiT) delete[] fPhiT;
975127ed 1119 if (fPdgT) delete[] fPdgT;
ff114de3 1120
d594b22e 1121 fPtT = new Float_t[ntracks];
1122 fEtaT = new Float_t[ntracks];
1123 fPhiT = new Float_t[ntracks];
975127ed 1124 fPdgT = new Int_t[ntracks];
d594b22e 1125
ff114de3 1126 fNt = ntracks;
1127 fNtS = 0;
1128
d594b22e 1129 for (Int_t track = 0; track < ntracks; track++) {
3fb730f8 1130 TParticle *mPart = gAlice->GetMCApp()->Particle(track);
1131 Float_t pT = mPart->Pt();
1132 Float_t phi = mPart->Phi();
1133 Float_t eta = mPart->Eta();
d594b22e 1134
1135 if(fTrackList[track]) {
1136 fPtT[track] = pT;
1137 fEtaT[track] = eta;
1138 fPhiT[track] = phi;
3fb730f8 1139 fPdgT[track] = mPart->GetPdgCode();
975127ed 1140
d594b22e 1141 if (track < 2) continue; //Colliding particles?
1142 if (pT == 0 || pT < fPtCut) continue;
ff114de3 1143 fNtS++;
d594b22e 1144 fLego->Fill(eta, phi, pT);
1145 }
1146 } // track loop
1147 DumpLego();
1148}
1149
c44ecd4c 1150void AliEMCALJetFinder::FillFromParticles()
1151{
1152// 26-feb-2002 PAI - for checking all chain
1153// Work on particles level; accept all particle (not neutrino )
1154
3fb730f8 1155 Double_t pX=0, pY=0, pZ=0, energy=0; // checking conservation law
b561574c 1156 fNChTpc = 0;
c44ecd4c 1157
1158 ResetMap();
1159 if (!fLego) BookLego();
1160 fLego->Reset();
1161//
1162// Access particles information
1163 Int_t npart = (gAlice->GetHeader())->GetNprimary();
1164 if (fDebug >= 2 || npart<=0) {
b561574c 1165 printf(" AliEMCALJetFinder::FillFromParticles : npart %i\n", npart);
1166 if(npart<=0) return;
c44ecd4c 1167 }
1168 fNt = npart;
1169 fNtS = 0;
1170 RearrangeParticlesMemory(npart);
1171
1172// Go through the particles
b561574c 1173 Int_t mpart, child1, child2, geantPdg;
1174 Float_t pT, phi, eta, e=0, px=0, py=0, pz=0;
3fb730f8 1175 TParticle *mPart=0;
c44ecd4c 1176 for (Int_t part = 0; part < npart; part++) {
1177
1178 fTrackList[part] = 0;
c44ecd4c 1179
3fb730f8 1180 mPart = gAlice->GetMCApp()->Particle(part);
1181 mpart = mPart->GetPdgCode();
1182 child1 = mPart->GetFirstDaughter();
1183 child2 = mPart->GetLastDaughter();
1184 pT = mPart->Pt();
1185 phi = mPart->Phi();
1186 eta = mPart->Eta();
b561574c 1187
3fb730f8 1188 px = mPart->Px();
1189 py = mPart->Py();
1190 pz = mPart->Pz();
1191 e = mPart->Energy();
b561574c 1192
1193// see pyedit in Pythia's text
975127ed 1194 geantPdg = mpart;
975127ed 1195 if (IsThisPartonsOrDiQuark(mpart)) continue;
1196 printf("%5i: %5i(%2i) px %5.1f py %5.1f pz %6.1f e %6.1f childs %5i,%5i \n",
1197 part, mpart, geantPdg, px, py, pz, e, child1, child2);
c44ecd4c 1198
1199// exclude partons (21 - gluon, 92 - string)
975127ed 1200
1201
c44ecd4c 1202// exclude neutrinous also ??
b561574c 1203 if (fDebug >= 11 && pT>0.01)
1204 printf("\n part:%5d mpart %5d eta %9.2f phi %9.2f pT %9.2f ",
c44ecd4c 1205 part, mpart, eta, phi, pT);
1206
1207 fPtT[part] = pT;
1208 fEtaT[part] = eta;
1209 fPhiT[part] = phi;
975127ed 1210 fPdgT[part] = mpart;
759ae494 1211 fNtS++;
975127ed 1212
b561574c 1213// final state only
1214 if (child1 >= 0 && child1 < npart) continue;
1215
1216 // printf("%4i -> %5i(%3i) px %6.1f py %6.1f pz %7.1f e %8.2f child1 %5i %s\n",
1217 // part, mpart, geantPdg, px, py, pz, e, child1, name.Data());
3fb730f8 1218 pX += px;
1219 pY += py;
1220 pZ += pz;
1221 energy += e;
b561574c 1222
1223
1224 if (TMath::Abs(eta) <= 0.9) fNChTpc++;
c44ecd4c 1225// acceptance cut
759ae494 1226 if (eta > fEtaMax || eta < fEtaMin) continue;
1227 if (phi > fPhiMax || phi < fPhiMin ) continue;
c44ecd4c 1228//
1229 if(fK0N==0 ) { // exclude neutral hadrons
1230 if (mpart == kNeutron || mpart == kNeutronBar || mpart == kK0Long) continue;
1231 }
1232 fTrackList[part] = 1;
1233 fLego->Fill(eta, phi, pT);
1234
1235 } // primary loop
b561574c 1236 printf("\n PX %8.2f PY %8.2f PZ %8.2f E %8.2f \n",
3fb730f8 1237 pX, pY, pZ, energy);
c44ecd4c 1238 DumpLego();
b561574c 1239 if(fhChPartMultInTpc) fhChPartMultInTpc->Fill(fNChTpc);
c44ecd4c 1240}
1241
b7a73953 1242void AliEMCALJetFinder::FillFromPartons()
1243{
1244// function under construction - 13-feb-2002 PAI
1245
1246 if (fDebug >= 2)
1247 printf("\n AliEMCALJetFinder::FillFromPartons()\n");
1248 //
1249
1250 ResetMap();
1251 if (!fLego) BookLego();
1252 fLego->Reset();
1253//
1254// Access particle information
1255 Int_t npart = (gAlice->GetHeader())->GetNprimary();
1256 if (fDebug >= 2 || npart<=0)
1257 printf("\n AliEMCALJetFinder::FillFromPartons : npart %i\n", npart);
1258 fNt = 0; // for FindTracksInJetCone
1259 fNtS = 0;
1260
1261// Go through the partons
1262 Int_t statusCode=0;
1263 for (Int_t part = 8; part < npart; part++) {
3fb730f8 1264 TParticle *mPart = gAlice->GetMCApp()->Particle(part);
1265 Int_t mpart = mPart->GetPdgCode();
b7a73953 1266 // Int_t child1 = MPart->GetFirstDaughter();
3fb730f8 1267 Float_t pT = mPart->Pt();
b7a73953 1268 // Float_t p = MPart->P();
3fb730f8 1269 Float_t phi = mPart->Phi();
1270 Float_t eta = mPart->Eta();
b7a73953 1271 // Float_t theta = MPart->Theta();
3fb730f8 1272 statusCode = mPart->GetStatusCode();
b7a73953 1273
1274// accept partons (21 - gluon, 92 - string)
1275 if (!(TMath::Abs(mpart) <= 6 || mpart == 21 ||mpart == 92)) continue;
1276 if (fDebug > 1 && pT>0.01)
1277 printf("\n part:%5d mpart %5d status %5d eta %8.2f phi %8.2f pT %8.2f ",
1278 part, mpart, statusCode, eta, phi, pT);
1279 // if (fDebug >= 3) MPart->Print();
1280// accept partons before fragmentation - p.57 in Pythia manual
1281// if(statusCode != 1) continue;
1282// acceptance cut
759ae494 1283 if (eta > fEtaMax || eta < fEtaMin) continue;
1284 if (phi > fPhiMax || phi < fPhiMin ) continue;
b7a73953 1285// final state only
1286// if (child1 >= 0 && child1 < npart) continue;
1287//
1288//
1289 fLego->Fill(eta, phi, pT);
1290
1291 } // primary loop
1292 DumpLego();
1293}
1294
d594b22e 1295void AliEMCALJetFinder::BuildTrackFlagTable() {
1296
1297// Method to generate a lookup table for TreeK particles
1298// which are linked to hits in the EMCAL
1299//
1300// --Author: J.L. Klay
1301//
d594b22e 1302// Access hit information
1303 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
1304
3fb730f8 1305 TTree *treeK = gAlice->TreeK(); // Get the number of entries in the kine tree
1306 Int_t nKTrks = (Int_t) treeK->GetEntries(); // (Number of particles created somewhere)
d594b22e 1307
1308 if(fTrackList) delete[] fTrackList; //Make sure we get rid of the old one
1309 fTrackList = new Int_t[nKTrks]; //before generating a new one
1310
1311 for (Int_t i = 0; i < nKTrks; i++) { //Initialize members to 0
1312 fTrackList[i] = 0;
1313 }
5dee926e 1314
1315 AliLoader *emcalLoader = AliRunLoader::GetRunLoader()->GetDetectorLoader("EMCAL");
1316 //AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
88cb7938 1317 // TTree *treeH = gAlice->TreeH();
5dee926e 1318 TTree *treeH = emcalLoader->TreeH();
88cb7938 1319 Int_t ntracks = (Int_t) treeH->GetEntries();
d594b22e 1320//
1321// Loop over tracks
1322//
1323 Int_t nbytes = 0;
1324
1325 for (Int_t track=0; track<ntracks;track++) {
1326 gAlice->ResetHits();
1327 nbytes += treeH->GetEvent(track);
1328 if (pEMCAL) {
1329
1330//
1331// Loop over hits
1332//
1333 for(AliEMCALHit* mHit=(AliEMCALHit*) pEMCAL->FirstHit(-1);
1334 mHit;
1335 mHit=(AliEMCALHit*) pEMCAL->NextHit())
1336 {
1337 Int_t iTrk = mHit->Track(); // track number
1338 Int_t idprim = mHit->GetPrimary(); // primary particle
1339
1340 //Determine the origin point of this particle - it made a hit in the EMCAL
5d12ce38 1341 TParticle *trkPart = gAlice->GetMCApp()->Particle(iTrk);
d594b22e 1342 TParticlePDG *trkPdg = trkPart->GetPDG();
1343 Int_t trkCode = trkPart->GetPdgCode();
1344 Double_t trkChg;
1345 if (trkCode < 10000) { //Big Ions cause problems for
1346 trkChg = trkPdg->Charge(); //this function. Since they aren't
1347 } else { //likely to make it very far, set
1348 trkChg = 0.0; //their charge to 0 for the Flag test
1349 }
1350 Float_t vxTrk = trkPart->Vx();
1351 Float_t vyTrk = trkPart->Vy();
1352 Float_t vrTrk = TMath::Sqrt(vxTrk*vxTrk+vyTrk*vyTrk);
1353 fTrackList[iTrk] = SetTrackFlag(vrTrk,trkCode,trkChg);
1354
1355 //Loop through the ancestry of the EMCAL entrance particles
1356 Int_t ancestor = trkPart->GetFirstMother(); //Get track's Mother
1357 while (ancestor != -1) {
5d12ce38 1358 TParticle *ancPart = gAlice->GetMCApp()->Particle(ancestor); //get particle info on ancestor
d594b22e 1359 TParticlePDG *ancPdg = ancPart->GetPDG();
1360 Int_t ancCode = ancPart->GetPdgCode();
1361 Double_t ancChg;
1362 if (ancCode < 10000) {
1363 ancChg = ancPdg->Charge();
1364 } else {
1365 ancChg = 0.0;
1366 }
1367 Float_t vxAnc = ancPart->Vx();
1368 Float_t vyAnc = ancPart->Vy();
1369 Float_t vrAnc = TMath::Sqrt(vxAnc*vxAnc+vyAnc*vyAnc);
1370 fTrackList[ancestor] = SetTrackFlag(vrAnc,ancCode,ancChg);
1371 ancestor = ancPart->GetFirstMother(); //Get the next ancestor
1372 }
1373
1374 //Determine the origin point of the primary particle associated with the hit
5d12ce38 1375 TParticle *primPart = gAlice->GetMCApp()->Particle(idprim);
d594b22e 1376 TParticlePDG *primPdg = primPart->GetPDG();
1377 Int_t primCode = primPart->GetPdgCode();
1378 Double_t primChg;
1379 if (primCode < 10000) {
1380 primChg = primPdg->Charge();
1381 } else {
1382 primChg = 0.0;
1383 }
1384 Float_t vxPrim = primPart->Vx();
1385 Float_t vyPrim = primPart->Vy();
1386 Float_t vrPrim = TMath::Sqrt(vxPrim*vxPrim+vyPrim*vyPrim);
1387 fTrackList[idprim] = SetTrackFlag(vrPrim,primCode,primChg);
1388 } // Hit Loop
1389 } //if (pEMCAL)
1390 } // Track Loop
1391}
1392
1393Int_t AliEMCALJetFinder
1394::SetTrackFlag(Float_t radius, Int_t code, Double_t charge) {
3fb730f8 1395// Set the flag for the track
ff114de3 1396 Int_t flag = 0;
1397 Int_t parton = 0;
d594b22e 1398 Int_t neutral = 0;
1399
1400 if (charge == 0) neutral = 1;
1401
1402 if (TMath::Abs(code) <= 6 ||
1403 code == 21 ||
1404 code == 92) parton = 1;
1405
1406 //It's not a parton, it's charged and it went through the TPC
1407 if (!parton && !neutral && radius <= 84.0) flag = 1;
1408
1409 return flag;
1410}
1411
ff114de3 1412
1413
8e8eae84 1414void AliEMCALJetFinder::SaveBackgroundEvent(const char *name)
ff114de3 1415{
f6ada3ae 1416// Saves the eta-phi lego and the tracklist and name of file with BG events
ff114de3 1417//
b561574c 1418 if (fLegoB) {
1419 fLegoB->Reset();
1420 (*fLegoB) = (*fLegoB) + (*fLego);
f6ada3ae 1421 // if(fDebug)
b561574c 1422 printf("\n AliEMCALJetFinder::SaveBackgroundEvent() (fLegoB) %f = %f(fLego) \n",
1423 fLegoB->Integral(), fLego->Integral());
1424 }
ff114de3 1425
1426 if (fPtB) delete[] fPtB;
1427 if (fEtaB) delete[] fEtaB;
1428 if (fPhiB) delete[] fPhiB;
975127ed 1429 if (fPdgB) delete[] fPdgB;
ff114de3 1430 if (fTrackListB) delete[] fTrackListB;
1431
1432 fPtB = new Float_t[fNtS];
1433 fEtaB = new Float_t[fNtS];
1434 fPhiB = new Float_t[fNtS];
975127ed 1435 fPdgB = new Int_t [fNtS];
ff114de3 1436 fTrackListB = new Int_t [fNtS];
46955412 1437
1438 fNtB = 0;
1439
ff114de3 1440 for (Int_t i = 0; i < fNt; i++) {
1441 if (!fTrackList[i]) continue;
610f27c9 1442 fPtB [fNtB] = fPtT [i];
1443 fEtaB[fNtB] = fEtaT[i];
1444 fPhiB[fNtB] = fPhiT[i];
975127ed 1445 fPdgB[fNtB] = fPdgT[i];
46955412 1446 fTrackListB[fNtB] = 1;
ff114de3 1447 fNtB++;
1448 }
610f27c9 1449 fBackground = 1;
f6ada3ae 1450 printf(" fNtB %i => fNtS %i #particles %i \n", fNtB, fNtS, fNt);
1451
1452 if(strlen(name) == 0) {
1453 TSeqCollection *li = gROOT->GetListOfFiles();
1454 TString nf;
1455 for(Int_t i=0; i<li->GetSize(); i++) {
1456 nf = ((TFile*)li->At(i))->GetName();
1457 if(nf.Contains("backgorund")) break;
1458 }
1459 fBGFileName = nf;
1460 } else {
1461 fBGFileName = name;
1462 }
1463 printf("BG file name is \n %s\n", fBGFileName.Data());
ff114de3 1464}
1465
1466void AliEMCALJetFinder::InitFromBackground()
1467{
1468//
1469//
b561574c 1470 if (fDebug) printf("\n AliEMCALJetFinder::InitFromBackground() ");
46955412 1471
b561574c 1472 if (fLego) {
396840bb 1473 fLego->Reset();
1474 (*fLego) = (*fLego) + (*fLegoB);
1475 if(fDebug)
f6ada3ae 1476 printf("\n AliEMCALJetFinder::InitBackgroundEvent() (fLego) %f = %f(fLegoB) \n",
396840bb 1477 fLego->Integral(), fLegoB->Integral());
b561574c 1478 } else {
396840bb 1479 printf(" => fLego undefined \n");
b561574c 1480 }
ff114de3 1481}
1482
ff114de3 1483
3bc109a9 1484void AliEMCALJetFinder::FindTracksInJetCone()
1485{
1486//
1487// Build list of tracks inside jet cone
1488//
1489// Loop over jets
1490 Int_t njet = Njets();
1491 for (Int_t nj = 0; nj < njet; nj++)
1492 {
1493 Float_t etaj = JetEtaW(nj);
1494 Float_t phij = JetPhiW(nj);
1495 Int_t nT = 0; // number of associated tracks
1496
ff114de3 1497// Loop over particles in current event
3bc109a9 1498 for (Int_t part = 0; part < fNt; part++) {
1499 if (!fTrackList[part]) continue;
1500 Float_t phi = fPhiT[part];
1501 Float_t eta = fEtaT[part];
1502 Float_t dr = TMath::Sqrt((etaj-eta)*(etaj-eta) +
1503 (phij-phi)*(phij-phi));
1504 if (dr < fConeRadius) {
1505 fTrackList[part] = nj+2;
1506 nT++;
1507 } // < ConeRadius ?
1508 } // particle loop
d594b22e 1509
ff114de3 1510// Same for background event if available
1511 Int_t nTB = 0;
1512 if (fBackground) {
1513 for (Int_t part = 0; part < fNtB; part++) {
1514 Float_t phi = fPhiB[part];
1515 Float_t eta = fEtaB[part];
1516 Float_t dr = TMath::Sqrt((etaj-eta)*(etaj-eta) +
1517 (phij-phi)*(phij-phi));
610f27c9 1518 fTrackListB[part] = 1;
1519
ff114de3 1520 if (dr < fConeRadius) {
610f27c9 1521 fTrackListB[part] = nj+2;
ff114de3 1522 nTB++;
1523 } // < ConeRadius ?
1524 } // particle loop
1525 } // Background available ?
1526
1527 Int_t nT0 = nT + nTB;
759ae494 1528 printf("Total number of tracks %d\n", nT0);
ff114de3 1529
8eba3b34 1530 if (nT0 > 1000) nT0 = 1000;
d594b22e 1531
610f27c9 1532 Float_t* ptT = new Float_t[nT0];
1533 Float_t* etaT = new Float_t[nT0];
1534 Float_t* phiT = new Float_t[nT0];
975127ed 1535 Int_t* pdgT = new Int_t[nT0];
1536
d594b22e 1537 Int_t iT = 0;
1538 Int_t j;
1539
3bc109a9 1540 for (Int_t part = 0; part < fNt; part++) {
1541 if (fTrackList[part] == nj+2) {
d594b22e 1542 Int_t index = 0;
1543 for (j=iT-1; j>=0; j--) {
1544 if (fPtT[part] > ptT[j]) {
1545 index = j+1;
1546 break;
1547 }
1548 }
1549 for (j=iT-1; j>=index; j--) {
1550 ptT [j+1] = ptT [j];
1551 etaT[j+1] = etaT[j];
1552 phiT[j+1] = phiT[j];
975127ed 1553 pdgT[j+1] = pdgT[j];
d594b22e 1554 }
1555 ptT [index] = fPtT [part];
1556 etaT[index] = fEtaT[part];
1557 phiT[index] = fPhiT[part];
975127ed 1558 pdgT[index] = fPdgT[part];
ff114de3 1559 iT++;
3bc109a9 1560 } // particle associated
ff114de3 1561 if (iT > nT0) break;
3bc109a9 1562 } // particle loop
d594b22e 1563
ff114de3 1564 if (fBackground) {
1565 for (Int_t part = 0; part < fNtB; part++) {
610f27c9 1566 if (fTrackListB[part] == nj+2) {
ff114de3 1567 Int_t index = 0;
1568 for (j=iT-1; j>=0; j--) {
1569 if (fPtB[part] > ptT[j]) {
1570 index = j+1;
610f27c9 1571
ff114de3 1572 break;
1573 }
1574 }
1575 for (j=iT-1; j>=index; j--) {
1576 ptT [j+1] = ptT [j];
1577 etaT[j+1] = etaT[j];
1578 phiT[j+1] = phiT[j];
975127ed 1579 pdgT[j+1] = pdgT[j];
ff114de3 1580 }
1581 ptT [index] = fPtB [part];
1582 etaT[index] = fEtaB[part];
1583 phiT[index] = fPhiB[part];
975127ed 1584 pdgT[index] = fPdgB[part];
ff114de3 1585 iT++;
1586 } // particle associated
1587 if (iT > nT0) break;
1588 } // particle loop
1589 } // Background available ?
1590
975127ed 1591 fJetT[nj]->SetTrackList(nT0, ptT, etaT, phiT, pdgT);
3bc109a9 1592 delete[] ptT;
1593 delete[] etaT;
1594 delete[] phiT;
975127ed 1595 delete[] pdgT;
1596
3bc109a9 1597 } // jet loop loop
1598}
1599
26dadf3a 1600Float_t AliEMCALJetFinder::PropagatePhi(Float_t pt, Float_t charge, Bool_t& curls)
1601{
1602// Propagates phi angle to EMCAL radius
1603//
b7a73953 1604 static Float_t b = 0.0, rEMCAL = -1.0;
b7a73953 1605// Get field in kGS
7deee4ae 1606 b = gAlice->Field()->SolenoidField();
b7a73953 1607// Get EMCAL radius in cm
02e079d4 1608 rEMCAL = AliEMCALGeometry::GetInstance()->GetIPDistance();
1609 Float_t dPhi = 0.;
26dadf3a 1610//
1611//
1612// bending radies
db5026bf 1613// pt [Gev]
1614// B [kG]
1615//
b7a73953 1616 Float_t rB = 3335.6 * pt / b; // [cm] (case of |charge|=1)
26dadf3a 1617//
1618// check if particle is curling below EMCAL
1619 if (2.*rB < rEMCAL) {
1620 curls = kTRUE;
1621 return dPhi;
1622 }
1623//
1624// if not calculate delta phi
1625 Float_t phi = TMath::ACos(1.-rEMCAL*rEMCAL/(2.*rB*rB));
1626 dPhi = TMath::ATan2(1.-TMath::Cos(phi), TMath::Sin(phi));
f8f69f71 1627 dPhi = -TMath::Sign(dPhi, charge);
26dadf3a 1628//
1629 return dPhi;
26dadf3a 1630}
1631
9e5d2067 1632void hf1(Int_t& , Float_t& , Float_t& )
471f69dc 1633{
1634// dummy for hbook calls
1635 ;
1636}
1637
8e8eae84 1638void AliEMCALJetFinder::DrawLego(const char *opt)
3fb730f8 1639{
1640// Draw lego
1641 if(fLego) fLego->Draw(opt);
1642}
f6ada3ae 1643
8e8eae84 1644void AliEMCALJetFinder::DrawLegoBackground(const char *opt)
3fb730f8 1645{
1646// Draw background lego
1647 if(fLegoB) fLegoB->Draw(opt);
1648}
471f69dc 1649
8e8eae84 1650void AliEMCALJetFinder::DrawLegoEMCAL(const char *opt)
3fb730f8 1651{
1652// Draw EMCAL Lego
1653 if(fhLegoEMCAL) fhLegoEMCAL->Draw(opt);
1654}
d594b22e 1655
c44ecd4c 1656void AliEMCALJetFinder::DrawHistsForTuning(Int_t mode)
1657{
3fb730f8 1658// Draw all hists
c44ecd4c 1659 static TPaveText *varLabel=0;
1660 if(!fC1) {
1661 fC1 = new TCanvas("C1","Hists. for tunning", 0,25,600,800);
1662 }
1663 fC1->Clear();
1664 fC1->Divide(2,2);
1665 fC1->cd(1);
1666 gPad->SetLogy(1);
1667 fhCellEt->Draw();
1668
1669 fC1->cd(2);
1670 gPad->SetLogy(1);
1671 fhCellEMCALEt->Draw();
1672
1673 fC1->cd(3);
1674 gPad->SetLogy(1);
1675 fhTrackPt->Draw();
1676 fhTrackPtBcut->SetLineColor(2);
1677 fhTrackPtBcut->Draw("same");
1678
1679 fC1->cd(4);
1680 if(!varLabel) {
1681 PrintParameters(1);
1682 varLabel = new TPaveText(0.05,0.5,0.95,0.95,"NDC");
1683 varLabel->SetTextAlign(12);
1684 varLabel->SetFillColor(19); // see TAttFill
1685 TString tmp(GetTitle());
1686 varLabel->ReadFile(GetFileNameForParameters());
1687 }
1688 varLabel->Draw();
1689 fC1->Update();
1690 if(mode) { // for saving picture to the file
1691 TString stmp(GetFileNameForParameters());
1692 stmp.ReplaceAll("_Par.txt",".ps");
1693 fC1->Print(stmp.Data());
1694 }
1695}
d594b22e 1696
c44ecd4c 1697void AliEMCALJetFinder::PrintParameters(Int_t mode)
1698{
3fb730f8 1699// Print all parameters out
1700
c44ecd4c 1701 FILE *file=0;
1702 if(mode==0) file = stdout; // output to terminal
1703 else {
1704 file = fopen(GetFileNameForParameters(),"w");
1705 if(file==0) file = stdout;
1706 }
1707 fprintf(file,"==== Filling lego ==== \n");
f6ada3ae 1708 fprintf(file,"Sampling fraction %6.3f ", fSamplingF);
c44ecd4c 1709 fprintf(file,"Smearing %6i ", fSmear);
1710 fprintf(file,"Efficiency %6i\n", fEffic);
1711 fprintf(file,"Hadr.Correct. %6i ", fHCorrection);
1712 fprintf(file,"P_{T} Cut of ch.par. %6.2f\n", fPtCut);
1713 fprintf(file,"==== Jet finding ==== \n");
1714 fprintf(file,"Cone radius %6.2f ", fConeRadius);
1715 fprintf(file,"Seed E_{T} %6.1f\n", fEtSeed);
1716 fprintf(file,"Min E_{T} of cell %6.1f ", fMinCellEt);
1717 fprintf(file,"Min E_{T} of jet %6.1f\n", fMinJetEt);
1718 if(fMode) {
1719 fprintf(file,"==== Bg subtraction ==== \n");
1720 fprintf(file,"BG subtraction %6i ", fMode);
1721 fprintf(file,"Min cone move %6.2f\n", fMinMove);
1722 fprintf(file,"Max cone move %6.2f ", fMaxMove);
1723 fprintf(file,"%% change for BG %6.4f\n", fPrecBg);
1724 } else
1725 fprintf(file,"==== No Bg subtraction ==== \n");
f6ada3ae 1726 //
1727 printf("BG file name is %s \n", fBGFileName.Data());
c44ecd4c 1728 if(file != stdout) fclose(file);
1729}
d594b22e 1730
c44ecd4c 1731void AliEMCALJetFinder::DrawLegos()
1732{
3fb730f8 1733// Draw all legos
c44ecd4c 1734 if(!fC1) {
1735 fC1 = new TCanvas("C1","Hists. for tunning", 0,25,600,800);
1736 }
1737 fC1->Clear();
1738 fC1->Divide(2,2);
1739 gStyle->SetOptStat(111111);
1740
1741 Int_t nent1, nent2, nent3, nent4;
1742 Double_t int1, int2, int3, int4;
1743 nent1 = (Int_t)fLego->GetEntries();
1744 int1 = fLego->Integral();
1745 fC1->cd(1);
1746 if(int1) fLego->Draw("lego");
1747
1748 nent2 = (Int_t)fhLegoTracks->GetEntries();
1749 int2 = fhLegoTracks->Integral();
1750 fC1->cd(2);
1751 if(int2) fhLegoTracks->Draw("lego");
1752
1753 nent3 = (Int_t)fhLegoEMCAL->GetEntries();
1754 int3 = fhLegoEMCAL->Integral();
1755 fC1->cd(3);
1756 if(int3) fhLegoEMCAL->Draw("lego");
1757
1758 nent4 = (Int_t)fhLegoHadrCorr->GetEntries();
1759 int4 = fhLegoHadrCorr->Integral();
1760 fC1->cd(4);
1761 if(int4) fhLegoHadrCorr->Draw("lego");
1762
1763 // just for checking
1764 printf(" Integrals \n");
1765 printf("lego %10.3f \ntrack %10.3f \nhits %10.3f \nHCorr %10.3f\n-- %10.3f(must be 0)\n",
1766 int1, int2, int3, int4, int1 - (int2 + int3 - int4));
1767}
d594b22e 1768
8e8eae84 1769const Char_t* AliEMCALJetFinder::GetFileNameForParameters(const char* dir)
c44ecd4c 1770{
3fb730f8 1771// Get paramters from a file
c44ecd4c 1772 static TString tmp;
1773 if(strlen(dir)) tmp = dir;
1774 tmp += GetTitle();
1775 tmp += "_Par.txt";
1776 return tmp.Data();
1777}
d594b22e 1778
c44ecd4c 1779void AliEMCALJetFinder::RearrangeParticlesMemory(Int_t npart)
910ac8c6 1780{
1781 // See FillFromTracks() - npart must be positive
c44ecd4c 1782 if (fTrackList) delete[] fTrackList;
1783 if (fPtT) delete[] fPtT;
1784 if (fEtaT) delete[] fEtaT;
1785 if (fPhiT) delete[] fPhiT;
975127ed 1786 if (fPdgT) delete[] fPdgT;
c44ecd4c 1787
1788 if(npart>0) {
1789 fTrackList = new Int_t [npart];
1790 fPtT = new Float_t[npart];
1791 fEtaT = new Float_t[npart];
1792 fPhiT = new Float_t[npart];
975127ed 1793 fPdgT = new Int_t[npart];
c44ecd4c 1794 } else {
1795 printf("AliEMCALJetFinder::RearrangeParticlesMemory : npart = %d\n", npart);
1796 }
1797}
b561574c 1798
1799Bool_t AliEMCALJetFinder::IsThisPartonsOrDiQuark(Int_t pdg)
1800{
3fb730f8 1801// Return quark info
b561574c 1802 Int_t absPdg = TMath::Abs(pdg);
1803 if(absPdg<=6) return kTRUE; // quarks
1804 if(pdg == 21) return kTRUE; // gluon
1805 if(pdg == 92) return kTRUE; // string
1806
1807 // see p.51 of Pythia Manual
1808 // Not include diquarks with c and b quark - 4-mar-2002
1809 // ud_0,sd_0,su_0; dd_1,ud_1,uu_1; sd_1,su_1,ss_1
1810 static Int_t diquark[9]={2101,3101,3201, 1103,2103,2203, 3103,3203,3303};
1811 for(Int_t i=0; i<9; i++) if(absPdg == diquark[i]) return kTRUE; // diquarks
1812
1813 return kFALSE;
1814}
1815
759ae494 1816void AliEMCALJetFinder::FindChargedJet()
1817{
1818//
1819// Find jet from charged particle information only
1820//
1821
1822//
1823// Look for seeds
1824//
1825 Int_t njets = 0;
1826 Int_t part = 0;
1827 Int_t nseed = 0;
1828
1829//
1830//
1831 ResetJets();
1832
1833//
1834 for (part = 0; part < fNt; part++) {
1835 if (!fTrackList[part]) continue;
1836 if (fPtT[part] > fEtSeed) nseed++;
1837 }
1838 printf("\nThere are %d seeds (%d)\n", nseed, fNtS);
1839 Int_t* iSeeds = new Int_t[nseed];
1840 nseed = 0;
1841
1842 for (part = 0; part < fNt; part++) {
1843 if (!fTrackList[part]) continue;
1844 if (fPtT[part] > fEtSeed) iSeeds[nseed++] = part;
1845 }
1846
1847//
1848// Loop over seeds
1849//
1850 Int_t seed = 0;
1851 Float_t pt;
1852
1853 while(1){
1854//
1855// Find seed with highest pt
1856//
1857 Float_t ptmax = -1.;
1858 Int_t index = -1;
1859 Int_t jndex = -1;
1860 for (seed = 0; seed < nseed; seed++) {
1861 if ((pt = fPtT[iSeeds[seed]]) > ptmax && iSeeds[seed] != -1) {
1862 ptmax = pt;
1863 index = seed;
1864 } // ptmax ?
1865 } // seeds
1866 if (ptmax < 0.) break;
1867 jndex = iSeeds[index];
1868//
1869// Remove from the list
1870 iSeeds[index] = -1;
1871 printf("\n Next Seed %d %f", jndex, ptmax);
1872//
1873// Find tracks in cone around seed
1874//
1875 Float_t phiSeed = fPhiT[jndex];
1876 Float_t etaSeed = fEtaT[jndex];
1877 Float_t eT = 0.;
1878 Float_t pxJ = 0.;
1879 Float_t pyJ = 0.;
1880 Float_t pzJ = 0.;
1881
1882 for (part = 0; part < fNt; part++) {
1883 if (!fTrackList[part]) continue;
1884 Float_t deta = fEtaT[part] - etaSeed;
1885 Float_t dphi = fPhiT[part] - phiSeed;
1886 Float_t dR = TMath::Sqrt(deta * deta + dphi * dphi);
1887 if (dR < fConeRadius) {
1888 eT += fPtT[part];
1889 Float_t theta = 2. * TMath::ATan(TMath::Exp(-fEtaT[part]));
1890 Float_t px = fPtT[part] * TMath::Cos(fPhiT[part]);
1891 Float_t py = fPtT[part] * TMath::Sin(fPhiT[part]);
1892 Float_t pz = fPtT[part] / TMath::Tan(theta);
1893 pxJ += px;
1894 pyJ += py;
1895 pzJ += pz;
1896 //
1897 // if seed, remove it
1898 //
1899 for (seed = 0; seed < nseed; seed++) {
1900 if (part == iSeeds[seed]) iSeeds[seed] = -1;
1901 } // seed ?
1902 } // < cone radius
1903 } // particle loop
1904
1905//
1906// Estimate of jet direction
1907 Float_t phiJ = TMath::ATan2(pyJ, pxJ);
1908 Float_t thetaJ = TMath::ATan2(TMath::Sqrt(pxJ * pxJ + pyJ * pyJ), pzJ);
1909 Float_t etaJ = TMath::Log(TMath::Tan(thetaJ / 2.));
8eba3b34 1910// Float_t ptJ = TMath::Sqrt(pxJ * pxJ + pyJ * pyJ);
759ae494 1911
1912//
1913// Sum up all energy
1914//
1915 Int_t iPhi0 = Int_t((phiJ - fPhiMin) / fDphi);
1916 Int_t iEta0 = Int_t((etaJ - fEtaMin) / fDeta);
1917 Int_t dIphi = Int_t(fConeRadius / fDphi);
1918 Int_t dIeta = Int_t(fConeRadius / fDeta);
1919 Int_t iPhi, iEta;
1920 Float_t sumE = 0;
1921 for (iPhi = iPhi0 -dIphi; iPhi < iPhi0 + dIphi; iPhi++) {
1922 for (iEta = iEta0 - dIeta; iEta < iEta0 + dIeta; iEta++) {
1923 if (iPhi < 0 || iEta < 0) continue;
1924 Float_t dPhi = fPhiMin + iPhi * fDphi;
1925 Float_t dEta = fEtaMin + iEta * fDeta;
1926 if (TMath::Sqrt(dPhi * dPhi + dEta * dEta) < fConeRadius) continue;
1927 sumE += fLego->GetBinContent(iEta, iPhi);
1928 } // eta
1929 } // phi
1930//
1931//
1932//
1933 fJetT[njets++] = new AliEMCALJet(sumE, phiJ, etaJ);
1934 FindTracksInJetCone();
1935 printf("\n Jet Energy %f %f %f %f %d\n", eT, sumE, fPtT[6], fPtT[7], njets);
1936 printf("\n Jet Phi %f %f %f \n", phiJ, fPhiT[6], fPhiT[7]);
1937 printf("\n Jet Eta %f %f %f \n", etaJ, fEtaT[6], fEtaT[7]);
1938 } // while(1)
1939 EMCALJETS.njet = njets;
1940 if (fWrite) WriteJets();
1941 fEvent++;
1942}
f6ada3ae 1943// 16-jan-2003 - just for convenience
1944void AliEMCALJetFinder::Browse(TBrowser* b)
1945{
3fb730f8 1946// Add to browser
f6ada3ae 1947 if(fHistsList) b->Add((TObject*)fHistsList);
1948}
1949
1950Bool_t AliEMCALJetFinder::IsFolder() const
1951{
3fb730f8 1952// Return folder status
f6ada3ae 1953 if(fHistsList) return kTRUE;
1954 else return kFALSE;
1955}
1956
1957const Char_t* AliEMCALJetFinder::GetNameOfVariant()
910ac8c6 1958{
1959 // generate the literal string with info about jet finder
f6ada3ae 1960 Char_t name[200];
1961 sprintf(name, "jF_R%3.2fMinCell%4.1fPtCut%4.1fEtSeed%4.1fMinEt%4.1fBGSubtr%iSF%4.1f",
1962 fConeRadius,fMinCellEt,fPtCut,fEtSeed,fMinJetEt, fMode, fSamplingF);
1963 TString nt(name);
1964 nt.ReplaceAll(" ","");
1965 if(fBGFileName.Length()) {
1966 Int_t i1 = fBGFileName.Index("kBackground");
1967 Int_t i2 = fBGFileName.Index("/0000") - 1;
1968 if(i1>=0 && i2>=0) {
1969 TString bg(fBGFileName(i1,i2-i1+1));
1970 nt += bg;
1971 }
1972 }
1973 printf("<I> Name of variant %s \n", nt.Data());
1974 return nt.Data();
1975}