1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //*-- Authors: Andreas Morsch (CERN)
20 //* Aleksei Pavlinov (WSU)
26 #include <TBranchElement.h>
28 #include <TClonesArray.h>
35 #include <TParticle.h>
36 #include <TParticlePDG.h>
37 #include <TPaveText.h>
38 #include <TPythia6Calls.h>
46 #include "AliEMCALDigit.h"
47 #include "AliEMCALDigitizer.h"
48 #include "AliEMCALFast.h"
49 #include "AliEMCALGeometry.h"
50 #include "AliEMCALHadronCorrection.h"
51 #include "AliEMCALHit.h"
52 #include "AliEMCALJetFinder.h"
53 #include "AliEMCALJetMicroDst.h"
54 #include "AliHeader.h"
56 #include "AliMagFCM.h"
58 #include "AliGenerator.h"
59 #include "AliEMCALGetter.h"
60 // Interface to FORTRAN
64 ClassImp(AliEMCALJetFinder)
66 //____________________________________________________________________________
67 AliEMCALJetFinder::AliEMCALJetFinder()
69 // Default constructor
98 SetParametersForBgSubtraction();
101 AliEMCALJetFinder::AliEMCALJetFinder(const char* name, const char *title)
105 // Title is used in method GetFileNameForParameters();
107 fJets = new TClonesArray("AliEMCALJet",10000);
109 for (Int_t i = 0; i < 30000; i++)
131 fHadronCorrector = 0;
140 SetMomentumSmearing();
143 SetHadronCorrection();
147 SetParametersForBgSubtraction();
150 void AliEMCALJetFinder::SetParametersForBgSubtraction
151 (Int_t mode, Float_t minMove, Float_t maxMove, Float_t precBg)
153 // see file /home/pavlinov/cosmic/pythia/jetFinderParamData.inc
154 // at WSU Linux cluster - 11-feb-2002
155 // These parameters must be tuned more carefull !!!
162 //____________________________________________________________________________
163 AliEMCALJetFinder::~AliEMCALJetFinder()
175 delete fhLegoHadrCorr;
178 delete fhCellEMCALEt;
180 delete fhTrackPtBcut;
181 delete fhChPartMultInTpc;
189 delete[] fTrackListB;
197 # define jet_finder_ua1 jet_finder_ua1_
199 # define type_of_call
202 # define jet_finder_ua1 JET_FINDER_UA1
204 # define type_of_call _stdcall
207 extern "C" void type_of_call
208 jet_finder_ua1(Int_t& ncell, Int_t& ncell_tot,
209 Float_t etc[30000], Float_t etac[30000],
211 Float_t& min_move, Float_t& max_move, Int_t& mode,
212 Float_t& prec_bg, Int_t& ierror);
214 extern "C" void type_of_call hf1(Int_t& id, Float_t& x, Float_t& wgt);
217 void AliEMCALJetFinder::Init()
220 // Geometry and I/O initialization
224 // Get geometry parameters from EMCAL
228 //AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
229 // AliEMCALGeometry* geom =
230 // AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), "");
231 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
232 AliEMCALGeometry* geom = gime->EMCALGeometry() ;
234 // SetSamplingFraction(geom->GetSampling());
236 fNbinEta = geom->GetNZ();
237 fNbinPhi = geom->GetNPhi();
238 fPhiMin = geom->GetArm1PhiMin()*TMath::Pi()/180.;
239 fPhiMax = geom->GetArm1PhiMax()*TMath::Pi()/180.;
240 fEtaMin = geom->GetArm1EtaMin();
241 fEtaMax = geom->GetArm1EtaMax();
242 fDphi = (fPhiMax-fPhiMin)/fNbinPhi;
243 fDeta = (fEtaMax-fEtaMin)/fNbinEta;
244 fNtot = fNbinPhi*fNbinEta;
245 fWeightingMethod = kFALSE;
248 SetCellSize(fDeta, fDphi);
251 if (fOutFileName) fOutFile = new TFile(fOutFileName, "recreate");
256 void AliEMCALJetFinder::Find(Int_t ncell, Int_t ncell_tot, Float_t etc[30000],
257 Float_t etac[30000], Float_t phic[30000],
258 Float_t min_move, Float_t max_move, Int_t mode,
259 Float_t prec_bg, Int_t ierror)
261 // Wrapper for fortran coded jet finder
262 // Full argument list
263 jet_finder_ua1(ncell, ncell_tot, etc, etac, phic,
264 min_move, max_move, mode, prec_bg, ierror);
265 // Write result to output
266 if(fWrite) WriteJets();
270 void AliEMCALJetFinder::Find()
272 // Wrapper for fortran coded jet finder using member data for
275 Float_t min_move = fMinMove;
276 Float_t max_move = fMaxMove;
278 Float_t prec_bg = fPrecBg;
280 ResetJets(); // 4-feb-2002 by PAI
282 jet_finder_ua1(fNcell, fNtot, fEtCell, fEtaCell, fPhiCell,
283 min_move, max_move, mode, prec_bg, ierror);
285 // Write result to output
286 Int_t njet = Njets();
288 for (Int_t nj=0; nj<njet; nj++)
290 if (fWeightingMethod)
292 fJetT[nj] = new AliEMCALJet(WeightedJetEnergy( JetEtaW(nj),JetPhiW(nj) ),
298 fJetT[nj] = new AliEMCALJet(JetEnergy(nj),
302 fJetT[nj]->SetIsWeightedEnergy(fWeightingMethod);
303 fJetT[nj]->SetEMCALEnergy( EMCALConeEnergy(JetEtaW(nj),JetPhiW(nj)) );
304 fJetT[nj]->SetTrackEnergy(TrackConeEnergy( JetEtaW(nj),JetPhiW(nj) ));
305 fJetT[nj]->SetHCEnergy(HCConeEnergy( JetEtaW(nj),JetPhiW(nj) ));
309 FindTracksInJetCone();
310 if(fWrite) WriteJets();
315 Float_t AliEMCALJetFinder::EMCALConeEnergy(Float_t eta, Float_t phi)
317 Float_t newenergy = 0.0;
318 Float_t bineta,binphi;
319 TAxis *x = fhLegoEMCAL->GetXaxis();
320 TAxis *y = fhLegoEMCAL->GetYaxis();
321 for (Int_t i = 0 ; i < fNbinEta ; i++) // x coord
323 for (Int_t j = 0 ; j < fNbinPhi ; j++) // y coord
325 bineta = x->GetBinCenter(i);
326 binphi = y->GetBinCenter(j);
327 if ( (bineta-eta)*(bineta-eta) + (binphi-phi)*(binphi-phi) < fConeRadius*fConeRadius)
329 newenergy += fhLegoEMCAL->GetBinContent(i,j);
336 Float_t AliEMCALJetFinder::TrackConeEnergy(Float_t eta, Float_t phi)
338 Float_t newenergy = 0.0;
339 Float_t bineta,binphi;
340 TAxis *x = fhLegoTracks->GetXaxis();
341 TAxis *y = fhLegoTracks->GetYaxis();
342 for (Int_t i = 0 ; i < fNbinEta ; i++) // x coord
344 for (Int_t j = 0 ; j < fNbinPhi ; j++) // y coord
346 bineta = x->GetBinCenter(i);
347 binphi = y->GetBinCenter(j);
348 if ( (bineta-eta)*(bineta-eta) + (binphi-phi)*(binphi-phi) < fConeRadius*fConeRadius)
350 newenergy += fhLegoTracks->GetBinContent(i,j);
357 Float_t AliEMCALJetFinder::HCConeEnergy(Float_t eta, Float_t phi)
359 //Float_t newenergy = 0.0;
360 //Float_t bineta,binphi;
361 //TAxis *x = fhLegoTracks->GetXaxis();
362 //TAxis *y = fhLegoTracks->GetYaxis();
363 //for (Int_t i = 0 ; i < fNbinEta ; i++) // x coord
365 // for (Int_t j = 0 ; j < fNbinPhi ; j++) // y coord
367 // bineta = x->GetBinCenter(i);
368 // binphi = y->GetBinCenter(j);
369 // if ( (bineta-eta)*(bineta-eta) + (binphi-phi)*(binphi-phi) < fConeRadius*fConeRadius)
371 // newenergy += fhLegoTracks->GetBinContent(i,j);
383 Float_t AliEMCALJetFinder::WeightedJetEnergy(Float_t eta, Float_t phi)
387 Float_t newenergy = 0.0;
388 Float_t bineta,binphi;
389 TAxis *x = fhLegoEMCAL->GetXaxis();
390 TAxis *y = fhLegoEMCAL->GetYaxis();
393 for (Int_t i = 0 ; i < fNbinEta ; i++) // x coord
395 for (Int_t j = 0 ; j < fNbinPhi ; j++) // y coord
397 bineta = x->GetBinCenter(i);
398 binphi = y->GetBinCenter(j);
399 if ( (bineta-eta)*(bineta-eta) + (binphi-phi)*(binphi-phi) < fConeRadius*fConeRadius)
401 newenergy += (fEMCALWeight)* fhLegoEMCAL->GetBinContent(i,j) + (fTrackWeight)* fhLegoTracks->GetBinContent(i,j);
411 Int_t AliEMCALJetFinder::Njets()
413 // Get number of reconstructed jets
414 return EMCALJETS.njet;
417 Float_t AliEMCALJetFinder::JetEnergy(Int_t i)
419 // Get reconstructed jet energy
420 return EMCALJETS.etj[i];
423 Float_t AliEMCALJetFinder::JetPhiL(Int_t i)
425 // Get reconstructed jet phi from leading particle
426 return EMCALJETS.phij[0][i];
429 Float_t AliEMCALJetFinder::JetPhiW(Int_t i)
431 // Get reconstructed jet phi from weighting
432 return EMCALJETS.phij[1][i];
435 Float_t AliEMCALJetFinder::JetEtaL(Int_t i)
437 // Get reconstructed jet eta from leading particles
438 return EMCALJETS.etaj[0][i];
442 Float_t AliEMCALJetFinder::JetEtaW(Int_t i)
444 // Get reconstructed jet eta from weighting
445 return EMCALJETS.etaj[1][i];
448 void AliEMCALJetFinder::SetCellSize(Float_t eta, Float_t phi)
450 // Set grid cell size
451 EMCALCELLGEO.etaCellSize = eta;
452 EMCALCELLGEO.phiCellSize = phi;
455 void AliEMCALJetFinder::SetConeRadius(Float_t par)
457 // Set jet cone radius
458 EMCALJETPARAM.coneRad = par;
462 void AliEMCALJetFinder::SetEtSeed(Float_t par)
464 // Set et cut for seeds
465 EMCALJETPARAM.etSeed = par;
469 void AliEMCALJetFinder::SetMinJetEt(Float_t par)
471 // Set minimum jet et
472 EMCALJETPARAM.ejMin = par;
476 void AliEMCALJetFinder::SetMinCellEt(Float_t par)
478 // Set et cut per cell
479 EMCALJETPARAM.etMin = par;
483 void AliEMCALJetFinder::SetPtCut(Float_t par)
485 // Set pT cut on charged tracks
490 void AliEMCALJetFinder::Test()
493 // Test the finder call
495 const Int_t nmax = 30000;
497 Int_t ncell_tot = 100;
502 Float_t min_move = 0;
503 Float_t max_move = 0;
509 Find(ncell, ncell_tot, etc, etac, phic,
510 min_move, max_move, mode, prec_bg, ierror);
518 void AliEMCALJetFinder::AddJet(const AliEMCALJet& jet)
523 TClonesArray &lrawcl = *fJets;
524 new(lrawcl[fNjets++]) AliEMCALJet(jet);
527 void AliEMCALJetFinder::ResetJets()
536 void AliEMCALJetFinder::WriteJets()
539 // Add all jets to the list
541 const Int_t kBufferSize = 4000;
542 const char* file = 0;
544 Int_t njet = Njets();
546 for (Int_t nj = 0; nj < njet; nj++)
553 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
556 // output written to input file
558 AliEMCAL* pEMCAL = (AliEMCAL* )gAlice->GetModule("EMCAL");
559 TTree* pK = gAlice->TreeK();
560 file = (pK->GetCurrentFile())->GetName();
561 TBranch * jetBranch ;
563 printf("Make Branch - TreeR address %p %p\n",gAlice->TreeR(), pEMCAL);
564 //if (fJets && gAlice->TreeR()) {
565 if (fJets && gime->TreeR()) {
566 // pEMCAL->MakeBranchInTree(gAlice->TreeR(),
567 jetBranch = gime->TreeR()->Branch("EMCALJets", &fJets, kBufferSize, 0) ;
568 //pEMCAL->MakeBranchInTree(gime->TreeR(),
574 //Int_t nev = gAlice->GetHeader()->GetEvent();
575 //gAlice->TreeR()->Fill();
578 //sprintf(hname,"TreeR%d", nev);
579 //gAlice->TreeR()->Write(hname);
580 //gAlice->TreeR()->Reset();
581 gime->WriteRecPoints("OVERWRITE");
585 // Output written to user specified output file
587 //TTree* pK = gAlice->TreeK();
588 TTree* pK = gAlice->TreeK();
589 fInFile = pK->GetCurrentFile();
593 sprintf(hname,"TreeR%d", fEvent);
594 TTree* treeJ = new TTree(hname, "EMCALJets");
595 treeJ->Branch("EMCALJets", &fJets, kBufferSize);
603 void AliEMCALJetFinder::BookLego()
606 // Book histo for discretization
610 // Don't add histos to the current directory
611 if(fDebug) printf("\n AliEMCALJetFinder::BookLego() \n");
613 // TH2::AddDirectory(0); // hists wil be put to the list from gROOT
614 // TH1::AddDirectory(0);
618 fLego = new TH2F("legoH","eta-phi",
619 fNbinEta, fEtaMin, fEtaMax,
620 fNbinPhi, fPhiMin, fPhiMax);
623 fLegoB = new TH2F("legoB","eta-phi for BG event",
624 fNbinEta, fEtaMin, fEtaMax,
625 fNbinPhi, fPhiMin, fPhiMax);
628 fhLegoTracks = new TH2F("hLegoTracks","eta-phi for Tracks",
629 fNbinEta, fEtaMin, fEtaMax, fNbinPhi, fPhiMin, fPhiMax);
631 fhLegoEMCAL = new TH2F("hLegoEMCAL","eta-phi for EMCAL",
632 fNbinEta, fEtaMin, fEtaMax, fNbinPhi, fPhiMin, fPhiMax);
633 // Hadron correction map
634 fhLegoHadrCorr = new TH2F("hLegoHadrCorr","eta-phi for Hadron. Correction",
635 fNbinEta, fEtaMin, fEtaMax, fNbinPhi, fPhiMin, fPhiMax);
636 // Hists. for tuning jet finder
637 fhEff = new TH2F("hEff","#epsilon vs momentum ", 100,0.,20., 50,0.5,1.);
641 for(Int_t i=1; i<=1000; i++) eTmp[i] = 0.1*i; // step 100 mev
642 for(Int_t i=1001; i<=1100; i++) eTmp[i] = eTmp[1000] + 1.0*(i-1000); // step 1GeV
644 fhCellEt = new TH1F("hCellEt","Cell E_{T} from fLego",
645 eTmp.GetSize()-1, eTmp.GetArray());
646 fhCellEMCALEt = new TH1F("hCellEMCALEt","Cell E_{T} for EMCAL itself",
647 eTmp.GetSize()-1, eTmp.GetArray());
648 fhTrackPt = new TH1F("hTrackPt","Ch.particles P_{T} ",
649 eTmp.GetSize()-1, eTmp.GetArray());
650 fhTrackPtBcut = new TH1F("hTrackPtBcut","Ch.particles P_{T} + magnetic field cut",
651 eTmp.GetSize()-1, eTmp.GetArray());
653 fhChPartMultInTpc = new TH1F("hChPartMultInTpc",
654 "Charge partilcle multiplicity in |%eta|<0.9", 2000, 0, 20000);
656 fhSinTheta = new TH1F("fhSinTheta","sin(theta)", fNbinEta, fEtaMin, fEtaMax);
657 TAxis *xax = fhSinTheta->GetXaxis();
658 for(Int_t i=1; i<=fNbinEta; i++) {
659 Double_t eta = xax->GetBinCenter(i);
660 fhSinTheta->Fill(eta, 1./TMath::CosH(eta)); // cosh(eta) = 1./sin(theta)
663 //! first canvas for drawing
664 fHistsList=AliEMCALJetMicroDst::MoveHistsToList("Hists from AliEMCALJetFinder", kFALSE);
667 void AliEMCALJetFinder::DumpLego()
670 // Dump lego histo into array
673 TAxis* Xaxis = fLego->GetXaxis();
674 TAxis* Yaxis = fLego->GetYaxis();
675 // fhCellEt->Clear();
677 for (Int_t i = 1; i <= fNbinEta; i++) {
678 for (Int_t j = 1; j <= fNbinPhi; j++) {
680 e = fLego->GetBinContent(i,j);
682 if (gRandom->Rndm() < 0.5) {
683 Float_t ebg = 0.28 * TMath::Abs(gRandom->Gaus(0.,1.));
687 if (e > 0.0) e -= fMinCellEt;
689 Float_t eta = Xaxis->GetBinCenter(i);
690 Float_t phi = Yaxis->GetBinCenter(j);
692 fEtaCell[fNcell] = eta;
693 fPhiCell[fNcell] = phi;
697 eH = fhLegoEMCAL->GetBinContent(i,j);
698 if(eH > 0.0) fhCellEMCALEt->Fill(eH);
706 void AliEMCALJetFinder::ResetMap()
709 // Reset eta-phi array
711 for (Int_t i=0; i<30000; i++)
720 void AliEMCALJetFinder::FillFromTracks(Int_t flag, Int_t ich)
724 const char* name = gAlice->Generator()->GetName();
725 enum {kPythia, kHijing, kHijingPara};
728 if (!strcmp(name, "Hijing")){
730 } else if (!strcmp(name, "Pythia")) {
732 } else if (!strcmp(name, "HIJINGpara") ||!strcmp(name, "HIGINGpara")) {
733 genType = kHijingPara;
736 printf("Fill tracks generated by %s %d\n", name, genType);
740 // Fill Cells with track information
743 printf("\n AliEMCALJetFinder::FillFromTracks(%i,%i) ",flag,ich);
748 if (!fLego) BookLego();
750 if (flag == 0) fLego->Reset();
752 // Access particle information
753 Int_t npart = (gAlice->GetHeader())->GetNprimary();
754 Int_t ntr = (gAlice->GetHeader())->GetNtrack();
755 printf(" : #primary particles %i # tracks %i : (before) Sum.Et %f\n",
756 npart, ntr, fLego->Integral());
761 // 1: selected for jet finding
764 if (fTrackList) delete[] fTrackList;
765 if (fPtT) delete[] fPtT;
766 if (fEtaT) delete[] fEtaT;
767 if (fPhiT) delete[] fPhiT;
768 if (fPdgT) delete[] fPdgT;
770 fTrackList = new Int_t [npart];
771 fPtT = new Float_t[npart];
772 fEtaT = new Float_t[npart];
773 fPhiT = new Float_t[npart];
774 fPdgT = new Int_t[npart];
778 Float_t chTmp=0.0; // charge of current particle
781 // this is for Pythia ??
782 for (Int_t part = 0; part < npart; part++) {
783 TParticle *MPart = gAlice->Particle(part);
784 Int_t mpart = MPart->GetPdgCode();
785 Int_t child1 = MPart->GetFirstDaughter();
786 Float_t pT = MPart->Pt();
787 Float_t p = MPart->P();
788 Float_t phi = MPart->Phi();
790 if(pT > 0.001) eta = MPart->Eta();
791 Float_t theta = MPart->Theta();
792 if (fDebug>=2 && MPart->GetStatusCode()==1) {
793 printf("ind %7i part %7i -> child1 %5i child2 %5i Status %5i\n",
794 part, mpart, child1, MPart->GetLastDaughter(), MPart->GetStatusCode());
797 if (fDebug >= 2 && genType == kPythia) {
798 if (part == 6 || part == 7)
800 printf("\n Simulated Jet (pt, eta, phi): %d %f %f %f\n",
801 part-5, pT, eta, phi);
805 fTrackList[part] = 0;
806 fPtT[part] = pT; // must be change after correction for resolution !!!
811 // final state particles only
813 if (genType == kPythia) {
814 if (MPart->GetStatusCode() != 1) continue;
815 } else if (genType == kHijing) {
816 if (child1 >= 0 && child1 < npart) continue;
820 TParticlePDG* pdgP = 0;
821 // charged or neutral
822 pdgP = MPart->GetPDG();
823 chTmp = pdgP->Charge() / 3.; // 13-feb-2001!!
830 if (mpart != kNeutron &&
831 mpart != kNeutronBar &&
832 mpart != kK0Long) continue;
835 } else if (ich == 2) {
836 if (mpart == kNeutron ||
837 mpart == kNeutronBar ||
838 mpart == kK0Long) continue;
841 if (TMath::Abs(eta)<=0.9) fNChTpc++;
843 if (child1 >= 0 && child1 < npart) continue;
845 if (eta > fEtaMax || eta < fEtaMin) continue;
846 if (phi > fPhiMax || phi < fPhiMin ) continue;
849 printf("\n=>nsel:%5d mpart %5d child1 %5d eta %6.2f phi %6.2f pT %6.2f ch %3.0f ",
850 part, mpart, child1, eta, phi, pT, chTmp);
853 // Momentum smearing goes here ...
857 if (fSmear && TMath::Abs(chTmp)) {
858 pw = AliEMCALFast::SmearMomentum(1,p);
859 // p changed - take into account when calculate pT,
862 if(fDebug >= 4) printf("\n Smearing : p %8.4f change to %8.4f ", p, pw);
866 // Tracking Efficiency and TPC acceptance goes here ...
868 if (fEffic && TMath::Abs(chTmp)) {
869 eff = 0.9; // AliEMCALFast::Efficiency(2,p);
870 if(fhEff) fhEff->Fill(p, eff);
871 if (AliEMCALFast::RandomReject(eff)) {
872 if(fDebug >= 5) printf(" reject due to unefficiency ");
877 // Correction of Hadronic Energy goes here ...
880 // phi propagation for hadronic correction
882 Bool_t curls = kFALSE; // hit two the EMCAL (no curl)
883 Float_t phiHC=0.0, dpH=0.0, dphi=0.0, eTdpH=0;
884 if(TMath::Abs(chTmp)) {
885 // hadr. correction only for charge particle
886 dphi = PropagatePhi(pT, chTmp, curls);
889 printf("\n Delta phi %f pT %f ", dphi, pT);
890 if (curls) printf("\n !! Track is curling");
892 if(!curls) fhTrackPtBcut->Fill(pT);
894 if (fHCorrection && !curls) {
895 if (!fHadronCorrector)
896 Fatal("AliEMCALJetFinder",
897 "Hadronic energy correction required but not defined !");
899 dpH = fHadronCorrector->GetEnergy(p, eta, 7);
900 eTdpH = dpH*TMath::Sin(theta);
902 if (fDebug >= 7) printf(" phi %f phiHC %f eTcorr %f\n",
903 phi, phiHC, -eTdpH); // correction is negative
905 xbin = fLego->GetXaxis()->FindBin(eta);
906 ybin = fLego->GetYaxis()->FindBin(phiHC);
907 cout <<"Hadron Correction affected bin - contents before correction : "<<fLego->GetBinContent(xbin,ybin)<<endl;
908 fLego->Fill(eta, phi, -fSamplingF*eTdpH );
909 cout <<"Hadron Correction affected bin - contents after correction : "<<fLego->GetBinContent(xbin,ybin)<<endl;
910 fhLegoHadrCorr->Fill(eta, phi, fSamplingF*eTdpH);
914 // More to do ? Just think about it !
916 if (phi > fPhiMax || phi < fPhiMin ) continue;
918 if(TMath::Abs(chTmp) ) { // charge particle
919 if (pT > fPtCut && !curls) {
920 if (fDebug >= 8) printf("Charge : fLego->Fill(%5.2f, %5.2f, %6.2f, %d)\n",
921 eta , phi, pT, fNtS);
922 fLego->Fill(eta, phi, pT);
923 fhLegoTracks->Fill(eta, phi, pT); // 20-feb for checking
924 fTrackList[part] = 1;
927 } else if(ich > 0 || fK0N) {
928 // case of n, nbar and K0L
929 if (fDebug >= 9) printf("Neutral : fLego->Fill(%5.2f, %5.2f, %6.2f, %d)\n",
930 eta , phi, pT, fNtS);
931 fLego->Fill(eta, phi, pT);
932 fTrackList[part] = 1;
937 for(Int_t i=0; i<fLego->GetSize(); i++) {
938 Float_t etc = (*fLego)[i];
939 if (etc > fMinCellEt) etsum += etc;
942 printf("FillFromTracks: Sum above threshold %f -> %f (%f)\n", fMinCellEt, etsum, fLego->Integral());
943 printf(" Track selected(fNtS) %i \n", fNtS);
948 void AliEMCALJetFinder::FillFromHits(Int_t flag)
951 // Fill Cells with hit information
955 printf("\n AliEMCALJetFinder::FillFromHits(%i)\n",flag);
959 if (!fLego) BookLego();
960 // Reset eta-phi maps if needed
961 if (flag == 0) { // default behavior
963 fhLegoTracks->Reset();
964 fhLegoEMCAL->Reset();
965 fhLegoHadrCorr->Reset();
967 // Initialize from background event if available
969 // Access hit information
970 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
971 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
972 TTree *treeH = gime->TreeH();
973 Int_t ntracks = (Int_t) treeH->GetEntries();
978 // Double_t etH = 0.0;
980 for (Int_t track=0; track<ntracks;track++) {
982 nbytes += treeH->GetEvent(track);
986 for(AliEMCALHit* mHit=(AliEMCALHit*) pEMCAL->FirstHit(-1);
988 mHit=(AliEMCALHit*) pEMCAL->NextHit())
990 Float_t x = mHit->X(); // x-pos of hit
991 Float_t y = mHit->Y(); // y-pos
992 Float_t z = mHit->Z(); // z-pos
993 Float_t eloss = mHit->GetEnergy(); // deposited energy
995 Float_t r = TMath::Sqrt(x*x+y*y);
996 Float_t theta = TMath::ATan2(r,z);
997 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
998 Float_t phi = TMath::ATan2(y,x);
1000 if (fDebug >= 21) printf("\n Hit %f %f %f %f %f %f %f %f", x, y, z, eloss, r, eta, phi, fSamplingF);
1002 // etH = fSamplingF*eloss*TMath::Sin(theta);
1003 fLego->Fill(eta, phi, eloss);
1007 // Transition from deposit energy to eT (eT = de*SF*sin(theta))
1009 for(Int_t i=1; i<=fLego->GetNbinsX(); i++){ // eta
1010 Double_t sinTheta = fhSinTheta->GetBinContent(i), eT=0;
1011 for(Int_t j=1; j<=fLego->GetNbinsY(); j++){ // phi
1012 eT = fLego->GetBinContent(i,j)*fSamplingF*sinTheta;
1013 fLego->SetBinContent(i,j,eT);
1014 // copy content of fLego to fhLegoEMCAL (fLego and fhLegoEMCAL are identical)
1015 fhLegoEMCAL->SetBinContent(i,j,eT);
1016 if (eT > fMinCellEt) etsum += eT;
1020 // for(Int_t i=0; i<fLego->GetSize(); i++) {
1021 // (*fhLegoEMCAL)[i] = (*fLego)[i];
1022 // Float_t etc = (*fLego)[i];
1023 // if (etc > fMinCellEt) etsum += etc;
1026 printf("FillFromHits: Sum above threshold %f -> %f \n ", fMinCellEt, etsum);
1030 void AliEMCALJetFinder::FillFromDigits(Int_t flag)
1033 // Fill Cells with digit information
1038 if (!fLego) BookLego();
1039 if (flag == 0) fLego->Reset();
1046 TClonesArray* digs = new TClonesArray("AliEMCALDigit", 10000);
1047 TTree *treeD = gAlice->TreeD();
1048 TBranchElement* branchDg = (TBranchElement*)
1049 treeD->GetBranch("EMCAL");
1051 if (!branchDg) Fatal("AliEMCALJetFinder",
1052 "Reading digits requested but no digits in file !");
1054 branchDg->SetAddress(&digs);
1055 Int_t nent = (Int_t) branchDg->GetEntries();
1057 // Connect digitizer
1059 AliEMCALDigitizer* digr = new AliEMCALDigitizer();
1060 TBranchElement* branchDr = (TBranchElement*)
1061 treeD->GetBranch("AliEMCALDigitizer");
1062 branchDr->SetAddress(&digr);
1065 nbytes += branchDg->GetEntry(0);
1066 nbytes += branchDr->GetEntry(0);
1068 // Get digitizer parameters
1069 Float_t preADCped = digr->GetPREpedestal();
1070 Float_t preADCcha = digr->GetPREchannel();
1071 Float_t ecADCped = digr->GetECApedestal();
1072 Float_t ecADCcha = digr->GetECAchannel();
1073 Float_t hcADCped = digr->GetHCApedestal();
1074 Float_t hcADCcha = digr->GetHCAchannel();
1076 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
1077 AliEMCALGeometry* geom =
1078 AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), "");
1081 Int_t ndig = digs->GetEntries();
1082 Info("FillFromDigits","Number of Digits: %d %d\n Parameters: PRE : %f %f EC: %f %f HC: %f %f\n Geometry: %d %d",
1083 ndig, nent, preADCped, preADCcha, ecADCped, ecADCcha, hcADCped, hcADCcha, geom->GetNEta(), geom->GetNPhi());
1090 while ((sdg = (AliEMCALDigit*)(next())))
1092 Double_t pedestal = 0.;
1093 Double_t channel = 0.;
1094 if (geom->IsInPRE(sdg->GetId())) {
1095 pedestal = preADCped;
1096 channel = preADCcha;
1098 else if (geom->IsInECA(sdg->GetId())) {
1099 pedestal = ecADCped;
1102 else if (geom->IsInHCA(sdg->GetId())) {
1103 pedestal = hcADCped;
1107 Fatal("FillFromDigits", "unexpected digit is number!") ;
1109 Float_t eta = sdg->GetEta();
1110 Float_t phi = sdg->GetPhi() * TMath::Pi()/180.;
1111 Float_t amp = (Float_t) (channel*(sdg->GetAmp())-pedestal);
1114 Info("FillFromDigits", "Digit: eta %8.3f phi %8.3f amp %8.3f %8d",
1115 eta, phi, amp, sdg->GetAmp());
1117 fLego->Fill(eta, phi, fSamplingF*amp);
1125 void AliEMCALJetFinder::FillFromHitFlaggedTracks(Int_t flag)
1128 // Fill Cells with hit information
1133 if (!fLego) BookLego();
1135 if (flag == 0) fLego->Reset();
1137 // Flag charged tracks passing through TPC which
1138 // are associated to EMCAL Hits
1139 BuildTrackFlagTable();
1142 // Access particle information
1143 TTree *treeK = gAlice->TreeK();
1144 Int_t ntracks = (Int_t) treeK->GetEntries();
1146 if (fPtT) delete[] fPtT;
1147 if (fEtaT) delete[] fEtaT;
1148 if (fPhiT) delete[] fPhiT;
1149 if (fPdgT) delete[] fPdgT;
1151 fPtT = new Float_t[ntracks];
1152 fEtaT = new Float_t[ntracks];
1153 fPhiT = new Float_t[ntracks];
1154 fPdgT = new Int_t[ntracks];
1159 for (Int_t track = 0; track < ntracks; track++) {
1160 TParticle *MPart = gAlice->Particle(track);
1161 Float_t pT = MPart->Pt();
1162 Float_t phi = MPart->Phi();
1163 Float_t eta = MPart->Eta();
1165 if(fTrackList[track]) {
1169 fPdgT[track] = MPart->GetPdgCode();
1171 if (track < 2) continue; //Colliding particles?
1172 if (pT == 0 || pT < fPtCut) continue;
1174 fLego->Fill(eta, phi, pT);
1180 void AliEMCALJetFinder::FillFromParticles()
1182 // 26-feb-2002 PAI - for checking all chain
1183 // Work on particles level; accept all particle (not neutrino )
1185 Double_t PX=0, PY=0, PZ=0, E=0; // checking conservation law
1189 if (!fLego) BookLego();
1192 // Access particles information
1193 Int_t npart = (gAlice->GetHeader())->GetNprimary();
1194 if (fDebug >= 2 || npart<=0) {
1195 printf(" AliEMCALJetFinder::FillFromParticles : npart %i\n", npart);
1196 if(npart<=0) return;
1200 RearrangeParticlesMemory(npart);
1202 // Go through the particles
1203 Int_t mpart, child1, child2, geantPdg;
1204 Float_t pT, phi, eta, e=0, px=0, py=0, pz=0;
1206 for (Int_t part = 0; part < npart; part++) {
1208 fTrackList[part] = 0;
1210 MPart = gAlice->Particle(part);
1211 mpart = MPart->GetPdgCode();
1212 child1 = MPart->GetFirstDaughter();
1213 child2 = MPart->GetLastDaughter();
1221 e = MPart->Energy();
1223 // see pyedit in Pythia's text
1225 if (IsThisPartonsOrDiQuark(mpart)) continue;
1226 printf("%5i: %5i(%2i) px %5.1f py %5.1f pz %6.1f e %6.1f childs %5i,%5i \n",
1227 part, mpart, geantPdg, px, py, pz, e, child1, child2);
1229 // exclude partons (21 - gluon, 92 - string)
1232 // exclude neutrinous also ??
1233 if (fDebug >= 11 && pT>0.01)
1234 printf("\n part:%5d mpart %5d eta %9.2f phi %9.2f pT %9.2f ",
1235 part, mpart, eta, phi, pT);
1240 fPdgT[part] = mpart;
1244 if (child1 >= 0 && child1 < npart) continue;
1246 // printf("%4i -> %5i(%3i) px %6.1f py %6.1f pz %7.1f e %8.2f child1 %5i %s\n",
1247 // part, mpart, geantPdg, px, py, pz, e, child1, name.Data());
1254 if (TMath::Abs(eta) <= 0.9) fNChTpc++;
1256 if (eta > fEtaMax || eta < fEtaMin) continue;
1257 if (phi > fPhiMax || phi < fPhiMin ) continue;
1259 if(fK0N==0 ) { // exclude neutral hadrons
1260 if (mpart == kNeutron || mpart == kNeutronBar || mpart == kK0Long) continue;
1262 fTrackList[part] = 1;
1263 fLego->Fill(eta, phi, pT);
1266 printf("\n PX %8.2f PY %8.2f PZ %8.2f E %8.2f \n",
1269 if(fhChPartMultInTpc) fhChPartMultInTpc->Fill(fNChTpc);
1272 void AliEMCALJetFinder::FillFromPartons()
1274 // function under construction - 13-feb-2002 PAI
1277 printf("\n AliEMCALJetFinder::FillFromPartons()\n");
1281 if (!fLego) BookLego();
1284 // Access particle information
1285 Int_t npart = (gAlice->GetHeader())->GetNprimary();
1286 if (fDebug >= 2 || npart<=0)
1287 printf("\n AliEMCALJetFinder::FillFromPartons : npart %i\n", npart);
1288 fNt = 0; // for FindTracksInJetCone
1291 // Go through the partons
1293 for (Int_t part = 8; part < npart; part++) {
1294 TParticle *MPart = gAlice->Particle(part);
1295 Int_t mpart = MPart->GetPdgCode();
1296 // Int_t child1 = MPart->GetFirstDaughter();
1297 Float_t pT = MPart->Pt();
1298 // Float_t p = MPart->P();
1299 Float_t phi = MPart->Phi();
1300 Float_t eta = MPart->Eta();
1301 // Float_t theta = MPart->Theta();
1302 statusCode = MPart->GetStatusCode();
1304 // accept partons (21 - gluon, 92 - string)
1305 if (!(TMath::Abs(mpart) <= 6 || mpart == 21 ||mpart == 92)) continue;
1306 if (fDebug > 1 && pT>0.01)
1307 printf("\n part:%5d mpart %5d status %5d eta %8.2f phi %8.2f pT %8.2f ",
1308 part, mpart, statusCode, eta, phi, pT);
1309 // if (fDebug >= 3) MPart->Print();
1310 // accept partons before fragmentation - p.57 in Pythia manual
1311 // if(statusCode != 1) continue;
1313 if (eta > fEtaMax || eta < fEtaMin) continue;
1314 if (phi > fPhiMax || phi < fPhiMin ) continue;
1316 // if (child1 >= 0 && child1 < npart) continue;
1319 fLego->Fill(eta, phi, pT);
1325 void AliEMCALJetFinder::BuildTrackFlagTable() {
1327 // Method to generate a lookup table for TreeK particles
1328 // which are linked to hits in the EMCAL
1330 // --Author: J.L. Klay
1332 // Access hit information
1333 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
1335 TTree *TK = gAlice->TreeK(); // Get the number of entries in the kine tree
1336 Int_t nKTrks = (Int_t) TK->GetEntries(); // (Number of particles created somewhere)
1338 if(fTrackList) delete[] fTrackList; //Make sure we get rid of the old one
1339 fTrackList = new Int_t[nKTrks]; //before generating a new one
1341 for (Int_t i = 0; i < nKTrks; i++) { //Initialize members to 0
1345 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
1346 // TTree *treeH = gAlice->TreeH();
1347 TTree *treeH = gime->TreeH();
1348 Int_t ntracks = (Int_t) treeH->GetEntries();
1354 for (Int_t track=0; track<ntracks;track++) {
1355 gAlice->ResetHits();
1356 nbytes += treeH->GetEvent(track);
1362 for(AliEMCALHit* mHit=(AliEMCALHit*) pEMCAL->FirstHit(-1);
1364 mHit=(AliEMCALHit*) pEMCAL->NextHit())
1366 Int_t iTrk = mHit->Track(); // track number
1367 Int_t idprim = mHit->GetPrimary(); // primary particle
1369 //Determine the origin point of this particle - it made a hit in the EMCAL
1370 TParticle *trkPart = gAlice->Particle(iTrk);
1371 TParticlePDG *trkPdg = trkPart->GetPDG();
1372 Int_t trkCode = trkPart->GetPdgCode();
1374 if (trkCode < 10000) { //Big Ions cause problems for
1375 trkChg = trkPdg->Charge(); //this function. Since they aren't
1376 } else { //likely to make it very far, set
1377 trkChg = 0.0; //their charge to 0 for the Flag test
1379 Float_t vxTrk = trkPart->Vx();
1380 Float_t vyTrk = trkPart->Vy();
1381 Float_t vrTrk = TMath::Sqrt(vxTrk*vxTrk+vyTrk*vyTrk);
1382 fTrackList[iTrk] = SetTrackFlag(vrTrk,trkCode,trkChg);
1384 //Loop through the ancestry of the EMCAL entrance particles
1385 Int_t ancestor = trkPart->GetFirstMother(); //Get track's Mother
1386 while (ancestor != -1) {
1387 TParticle *ancPart = gAlice->Particle(ancestor); //get particle info on ancestor
1388 TParticlePDG *ancPdg = ancPart->GetPDG();
1389 Int_t ancCode = ancPart->GetPdgCode();
1391 if (ancCode < 10000) {
1392 ancChg = ancPdg->Charge();
1396 Float_t vxAnc = ancPart->Vx();
1397 Float_t vyAnc = ancPart->Vy();
1398 Float_t vrAnc = TMath::Sqrt(vxAnc*vxAnc+vyAnc*vyAnc);
1399 fTrackList[ancestor] = SetTrackFlag(vrAnc,ancCode,ancChg);
1400 ancestor = ancPart->GetFirstMother(); //Get the next ancestor
1403 //Determine the origin point of the primary particle associated with the hit
1404 TParticle *primPart = gAlice->Particle(idprim);
1405 TParticlePDG *primPdg = primPart->GetPDG();
1406 Int_t primCode = primPart->GetPdgCode();
1408 if (primCode < 10000) {
1409 primChg = primPdg->Charge();
1413 Float_t vxPrim = primPart->Vx();
1414 Float_t vyPrim = primPart->Vy();
1415 Float_t vrPrim = TMath::Sqrt(vxPrim*vxPrim+vyPrim*vyPrim);
1416 fTrackList[idprim] = SetTrackFlag(vrPrim,primCode,primChg);
1422 Int_t AliEMCALJetFinder
1423 ::SetTrackFlag(Float_t radius, Int_t code, Double_t charge) {
1429 if (charge == 0) neutral = 1;
1431 if (TMath::Abs(code) <= 6 ||
1433 code == 92) parton = 1;
1435 //It's not a parton, it's charged and it went through the TPC
1436 if (!parton && !neutral && radius <= 84.0) flag = 1;
1443 void AliEMCALJetFinder::SaveBackgroundEvent(Char_t *name)
1445 // Saves the eta-phi lego and the tracklist and name of file with BG events
1449 (*fLegoB) = (*fLegoB) + (*fLego);
1451 printf("\n AliEMCALJetFinder::SaveBackgroundEvent() (fLegoB) %f = %f(fLego) \n",
1452 fLegoB->Integral(), fLego->Integral());
1455 if (fPtB) delete[] fPtB;
1456 if (fEtaB) delete[] fEtaB;
1457 if (fPhiB) delete[] fPhiB;
1458 if (fPdgB) delete[] fPdgB;
1459 if (fTrackListB) delete[] fTrackListB;
1461 fPtB = new Float_t[fNtS];
1462 fEtaB = new Float_t[fNtS];
1463 fPhiB = new Float_t[fNtS];
1464 fPdgB = new Int_t [fNtS];
1465 fTrackListB = new Int_t [fNtS];
1469 for (Int_t i = 0; i < fNt; i++) {
1470 if (!fTrackList[i]) continue;
1471 fPtB [fNtB] = fPtT [i];
1472 fEtaB[fNtB] = fEtaT[i];
1473 fPhiB[fNtB] = fPhiT[i];
1474 fPdgB[fNtB] = fPdgT[i];
1475 fTrackListB[fNtB] = 1;
1479 printf(" fNtB %i => fNtS %i #particles %i \n", fNtB, fNtS, fNt);
1481 if(strlen(name) == 0) {
1482 TSeqCollection *li = gROOT->GetListOfFiles();
1484 for(Int_t i=0; i<li->GetSize(); i++) {
1485 nf = ((TFile*)li->At(i))->GetName();
1486 if(nf.Contains("backgorund")) break;
1492 printf("BG file name is \n %s\n", fBGFileName.Data());
1495 void AliEMCALJetFinder::InitFromBackground()
1499 if (fDebug) printf("\n AliEMCALJetFinder::InitFromBackground() ");
1503 (*fLego) = (*fLego) + (*fLegoB);
1505 printf("\n AliEMCALJetFinder::InitBackgroundEvent() (fLego) %f = %f(fLegoB) \n",
1506 fLego->Integral(), fLegoB->Integral());
1508 printf(" => fLego undefined \n");
1513 void AliEMCALJetFinder::FindTracksInJetCone()
1516 // Build list of tracks inside jet cone
1519 Int_t njet = Njets();
1520 for (Int_t nj = 0; nj < njet; nj++)
1522 Float_t etaj = JetEtaW(nj);
1523 Float_t phij = JetPhiW(nj);
1524 Int_t nT = 0; // number of associated tracks
1526 // Loop over particles in current event
1527 for (Int_t part = 0; part < fNt; part++) {
1528 if (!fTrackList[part]) continue;
1529 Float_t phi = fPhiT[part];
1530 Float_t eta = fEtaT[part];
1531 Float_t dr = TMath::Sqrt((etaj-eta)*(etaj-eta) +
1532 (phij-phi)*(phij-phi));
1533 if (dr < fConeRadius) {
1534 fTrackList[part] = nj+2;
1539 // Same for background event if available
1542 for (Int_t part = 0; part < fNtB; part++) {
1543 Float_t phi = fPhiB[part];
1544 Float_t eta = fEtaB[part];
1545 Float_t dr = TMath::Sqrt((etaj-eta)*(etaj-eta) +
1546 (phij-phi)*(phij-phi));
1547 fTrackListB[part] = 1;
1549 if (dr < fConeRadius) {
1550 fTrackListB[part] = nj+2;
1554 } // Background available ?
1556 Int_t nT0 = nT + nTB;
1557 printf("Total number of tracks %d\n", nT0);
1559 if (nT0 > 1000) nT0 = 1000;
1561 Float_t* ptT = new Float_t[nT0];
1562 Float_t* etaT = new Float_t[nT0];
1563 Float_t* phiT = new Float_t[nT0];
1564 Int_t* pdgT = new Int_t[nT0];
1569 for (Int_t part = 0; part < fNt; part++) {
1570 if (fTrackList[part] == nj+2) {
1572 for (j=iT-1; j>=0; j--) {
1573 if (fPtT[part] > ptT[j]) {
1578 for (j=iT-1; j>=index; j--) {
1579 ptT [j+1] = ptT [j];
1580 etaT[j+1] = etaT[j];
1581 phiT[j+1] = phiT[j];
1582 pdgT[j+1] = pdgT[j];
1584 ptT [index] = fPtT [part];
1585 etaT[index] = fEtaT[part];
1586 phiT[index] = fPhiT[part];
1587 pdgT[index] = fPdgT[part];
1589 } // particle associated
1590 if (iT > nT0) break;
1594 for (Int_t part = 0; part < fNtB; part++) {
1595 if (fTrackListB[part] == nj+2) {
1597 for (j=iT-1; j>=0; j--) {
1598 if (fPtB[part] > ptT[j]) {
1604 for (j=iT-1; j>=index; j--) {
1605 ptT [j+1] = ptT [j];
1606 etaT[j+1] = etaT[j];
1607 phiT[j+1] = phiT[j];
1608 pdgT[j+1] = pdgT[j];
1610 ptT [index] = fPtB [part];
1611 etaT[index] = fEtaB[part];
1612 phiT[index] = fPhiB[part];
1613 pdgT[index] = fPdgB[part];
1615 } // particle associated
1616 if (iT > nT0) break;
1618 } // Background available ?
1620 fJetT[nj]->SetTrackList(nT0, ptT, etaT, phiT, pdgT);
1629 Float_t AliEMCALJetFinder::PropagatePhi(Float_t pt, Float_t charge, Bool_t& curls)
1631 // Propagates phi angle to EMCAL radius
1633 static Float_t b = 0.0, rEMCAL = -1.0;
1635 b = gAlice->Field()->SolenoidField();
1636 // Get EMCAL radius in cm
1637 rEMCAL = AliEMCALGeometry::GetInstance()->GetIPDistance();
1645 Float_t rB = 3335.6 * pt / b; // [cm] (case of |charge|=1)
1647 // check if particle is curling below EMCAL
1648 if (2.*rB < rEMCAL) {
1653 // if not calculate delta phi
1654 Float_t phi = TMath::ACos(1.-rEMCAL*rEMCAL/(2.*rB*rB));
1655 dPhi = TMath::ATan2(1.-TMath::Cos(phi), TMath::Sin(phi));
1656 dPhi = -TMath::Sign(dPhi, charge);
1661 void hf1(Int_t& id, Float_t& x, Float_t& wgt)
1663 // dummy for hbook calls
1667 void AliEMCALJetFinder::DrawLego(Char_t *opt)
1668 {if(fLego) fLego->Draw(opt);}
1670 void AliEMCALJetFinder::DrawLegoBackground(Char_t *opt)
1671 {if(fLegoB) fLegoB->Draw(opt);}
1673 void AliEMCALJetFinder::DrawLegoEMCAL(Char_t *opt)
1674 {if(fhLegoEMCAL) fhLegoEMCAL->Draw(opt);}
1676 void AliEMCALJetFinder::DrawHistsForTuning(Int_t mode)
1678 static TPaveText *varLabel=0;
1680 fC1 = new TCanvas("C1","Hists. for tunning", 0,25,600,800);
1690 fhCellEMCALEt->Draw();
1695 fhTrackPtBcut->SetLineColor(2);
1696 fhTrackPtBcut->Draw("same");
1701 varLabel = new TPaveText(0.05,0.5,0.95,0.95,"NDC");
1702 varLabel->SetTextAlign(12);
1703 varLabel->SetFillColor(19); // see TAttFill
1704 TString tmp(GetTitle());
1705 varLabel->ReadFile(GetFileNameForParameters());
1709 if(mode) { // for saving picture to the file
1710 TString stmp(GetFileNameForParameters());
1711 stmp.ReplaceAll("_Par.txt",".ps");
1712 fC1->Print(stmp.Data());
1716 void AliEMCALJetFinder::PrintParameters(Int_t mode)
1719 if(mode==0) file = stdout; // output to terminal
1721 file = fopen(GetFileNameForParameters(),"w");
1722 if(file==0) file = stdout;
1724 fprintf(file,"==== Filling lego ==== \n");
1725 fprintf(file,"Sampling fraction %6.3f ", fSamplingF);
1726 fprintf(file,"Smearing %6i ", fSmear);
1727 fprintf(file,"Efficiency %6i\n", fEffic);
1728 fprintf(file,"Hadr.Correct. %6i ", fHCorrection);
1729 fprintf(file,"P_{T} Cut of ch.par. %6.2f\n", fPtCut);
1730 fprintf(file,"==== Jet finding ==== \n");
1731 fprintf(file,"Cone radius %6.2f ", fConeRadius);
1732 fprintf(file,"Seed E_{T} %6.1f\n", fEtSeed);
1733 fprintf(file,"Min E_{T} of cell %6.1f ", fMinCellEt);
1734 fprintf(file,"Min E_{T} of jet %6.1f\n", fMinJetEt);
1736 fprintf(file,"==== Bg subtraction ==== \n");
1737 fprintf(file,"BG subtraction %6i ", fMode);
1738 fprintf(file,"Min cone move %6.2f\n", fMinMove);
1739 fprintf(file,"Max cone move %6.2f ", fMaxMove);
1740 fprintf(file,"%% change for BG %6.4f\n", fPrecBg);
1742 fprintf(file,"==== No Bg subtraction ==== \n");
1744 printf("BG file name is %s \n", fBGFileName.Data());
1745 if(file != stdout) fclose(file);
1748 void AliEMCALJetFinder::DrawLegos()
1751 fC1 = new TCanvas("C1","Hists. for tunning", 0,25,600,800);
1755 gStyle->SetOptStat(111111);
1757 Int_t nent1, nent2, nent3, nent4;
1758 Double_t int1, int2, int3, int4;
1759 nent1 = (Int_t)fLego->GetEntries();
1760 int1 = fLego->Integral();
1762 if(int1) fLego->Draw("lego");
1764 nent2 = (Int_t)fhLegoTracks->GetEntries();
1765 int2 = fhLegoTracks->Integral();
1767 if(int2) fhLegoTracks->Draw("lego");
1769 nent3 = (Int_t)fhLegoEMCAL->GetEntries();
1770 int3 = fhLegoEMCAL->Integral();
1772 if(int3) fhLegoEMCAL->Draw("lego");
1774 nent4 = (Int_t)fhLegoHadrCorr->GetEntries();
1775 int4 = fhLegoHadrCorr->Integral();
1777 if(int4) fhLegoHadrCorr->Draw("lego");
1779 // just for checking
1780 printf(" Integrals \n");
1781 printf("lego %10.3f \ntrack %10.3f \nhits %10.3f \nHCorr %10.3f\n-- %10.3f(must be 0)\n",
1782 int1, int2, int3, int4, int1 - (int2 + int3 - int4));
1785 const Char_t* AliEMCALJetFinder::GetFileNameForParameters(Char_t* dir)
1788 if(strlen(dir)) tmp = dir;
1794 void AliEMCALJetFinder::RearrangeParticlesMemory(Int_t npart)
1795 { // See FillFromTracks() - npart must be positive
1796 if (fTrackList) delete[] fTrackList;
1797 if (fPtT) delete[] fPtT;
1798 if (fEtaT) delete[] fEtaT;
1799 if (fPhiT) delete[] fPhiT;
1800 if (fPdgT) delete[] fPdgT;
1803 fTrackList = new Int_t [npart];
1804 fPtT = new Float_t[npart];
1805 fEtaT = new Float_t[npart];
1806 fPhiT = new Float_t[npart];
1807 fPdgT = new Int_t[npart];
1809 printf("AliEMCALJetFinder::RearrangeParticlesMemory : npart = %d\n", npart);
1813 Bool_t AliEMCALJetFinder::IsThisPartonsOrDiQuark(Int_t pdg)
1815 Int_t absPdg = TMath::Abs(pdg);
1816 if(absPdg<=6) return kTRUE; // quarks
1817 if(pdg == 21) return kTRUE; // gluon
1818 if(pdg == 92) return kTRUE; // string
1820 // see p.51 of Pythia Manual
1821 // Not include diquarks with c and b quark - 4-mar-2002
1822 // ud_0,sd_0,su_0; dd_1,ud_1,uu_1; sd_1,su_1,ss_1
1823 static Int_t diquark[9]={2101,3101,3201, 1103,2103,2203, 3103,3203,3303};
1824 for(Int_t i=0; i<9; i++) if(absPdg == diquark[i]) return kTRUE; // diquarks
1829 void AliEMCALJetFinder::FindChargedJet()
1832 // Find jet from charged particle information only
1847 for (part = 0; part < fNt; part++) {
1848 if (!fTrackList[part]) continue;
1849 if (fPtT[part] > fEtSeed) nseed++;
1851 printf("\nThere are %d seeds (%d)\n", nseed, fNtS);
1852 Int_t* iSeeds = new Int_t[nseed];
1855 for (part = 0; part < fNt; part++) {
1856 if (!fTrackList[part]) continue;
1857 if (fPtT[part] > fEtSeed) iSeeds[nseed++] = part;
1868 // Find seed with highest pt
1870 Float_t ptmax = -1.;
1873 for (seed = 0; seed < nseed; seed++) {
1874 if ((pt = fPtT[iSeeds[seed]]) > ptmax && iSeeds[seed] != -1) {
1879 if (ptmax < 0.) break;
1880 jndex = iSeeds[index];
1882 // Remove from the list
1884 printf("\n Next Seed %d %f", jndex, ptmax);
1886 // Find tracks in cone around seed
1888 Float_t phiSeed = fPhiT[jndex];
1889 Float_t etaSeed = fEtaT[jndex];
1895 for (part = 0; part < fNt; part++) {
1896 if (!fTrackList[part]) continue;
1897 Float_t deta = fEtaT[part] - etaSeed;
1898 Float_t dphi = fPhiT[part] - phiSeed;
1899 Float_t dR = TMath::Sqrt(deta * deta + dphi * dphi);
1900 if (dR < fConeRadius) {
1902 Float_t theta = 2. * TMath::ATan(TMath::Exp(-fEtaT[part]));
1903 Float_t px = fPtT[part] * TMath::Cos(fPhiT[part]);
1904 Float_t py = fPtT[part] * TMath::Sin(fPhiT[part]);
1905 Float_t pz = fPtT[part] / TMath::Tan(theta);
1910 // if seed, remove it
1912 for (seed = 0; seed < nseed; seed++) {
1913 if (part == iSeeds[seed]) iSeeds[seed] = -1;
1919 // Estimate of jet direction
1920 Float_t phiJ = TMath::ATan2(pyJ, pxJ);
1921 Float_t thetaJ = TMath::ATan2(TMath::Sqrt(pxJ * pxJ + pyJ * pyJ), pzJ);
1922 Float_t etaJ = TMath::Log(TMath::Tan(thetaJ / 2.));
1923 // Float_t ptJ = TMath::Sqrt(pxJ * pxJ + pyJ * pyJ);
1926 // Sum up all energy
1928 Int_t iPhi0 = Int_t((phiJ - fPhiMin) / fDphi);
1929 Int_t iEta0 = Int_t((etaJ - fEtaMin) / fDeta);
1930 Int_t dIphi = Int_t(fConeRadius / fDphi);
1931 Int_t dIeta = Int_t(fConeRadius / fDeta);
1934 for (iPhi = iPhi0 -dIphi; iPhi < iPhi0 + dIphi; iPhi++) {
1935 for (iEta = iEta0 - dIeta; iEta < iEta0 + dIeta; iEta++) {
1936 if (iPhi < 0 || iEta < 0) continue;
1937 Float_t dPhi = fPhiMin + iPhi * fDphi;
1938 Float_t dEta = fEtaMin + iEta * fDeta;
1939 if (TMath::Sqrt(dPhi * dPhi + dEta * dEta) < fConeRadius) continue;
1940 sumE += fLego->GetBinContent(iEta, iPhi);
1946 fJetT[njets++] = new AliEMCALJet(sumE, phiJ, etaJ);
1947 FindTracksInJetCone();
1948 printf("\n Jet Energy %f %f %f %f %d\n", eT, sumE, fPtT[6], fPtT[7], njets);
1949 printf("\n Jet Phi %f %f %f \n", phiJ, fPhiT[6], fPhiT[7]);
1950 printf("\n Jet Eta %f %f %f \n", etaJ, fEtaT[6], fEtaT[7]);
1952 EMCALJETS.njet = njets;
1953 if (fWrite) WriteJets();
1956 // 16-jan-2003 - just for convenience
1957 void AliEMCALJetFinder::Browse(TBrowser* b)
1959 if(fHistsList) b->Add((TObject*)fHistsList);
1962 Bool_t AliEMCALJetFinder::IsFolder() const
1964 if(fHistsList) return kTRUE;
1968 const Char_t* AliEMCALJetFinder::GetNameOfVariant()
1969 {// generate the literal string with info about jet finder
1971 sprintf(name, "jF_R%3.2fMinCell%4.1fPtCut%4.1fEtSeed%4.1fMinEt%4.1fBGSubtr%iSF%4.1f",
1972 fConeRadius,fMinCellEt,fPtCut,fEtSeed,fMinJetEt, fMode, fSamplingF);
1974 nt.ReplaceAll(" ","");
1975 if(fBGFileName.Length()) {
1976 Int_t i1 = fBGFileName.Index("kBackground");
1977 Int_t i2 = fBGFileName.Index("/0000") - 1;
1978 if(i1>=0 && i2>=0) {
1979 TString bg(fBGFileName(i1,i2-i1+1));
1983 printf("<I> Name of variant %s \n", nt.Data());