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
65 ClassImp(AliEMCALJetFinder)
67 //____________________________________________________________________________
68 AliEMCALJetFinder::AliEMCALJetFinder()
70 // Default constructor
99 SetParametersForBgSubtraction();
102 AliEMCALJetFinder::AliEMCALJetFinder(const char* name, const char *title)
106 // Title is used in method GetFileNameForParameters();
108 fJets = new TClonesArray("AliEMCALJet",10000);
110 for (Int_t i = 0; i < 30000; i++)
132 fHadronCorrector = 0;
141 SetMomentumSmearing();
144 SetHadronCorrection();
148 SetParametersForBgSubtraction();
151 void AliEMCALJetFinder::SetParametersForBgSubtraction
152 (Int_t mode, Float_t minMove, Float_t maxMove, Float_t precBg)
154 // see file /home/pavlinov/cosmic/pythia/jetFinderParamData.inc
155 // at WSU Linux cluster - 11-feb-2002
156 // These parameters must be tuned more carefull !!!
163 //____________________________________________________________________________
164 AliEMCALJetFinder::~AliEMCALJetFinder()
176 delete fhLegoHadrCorr;
179 delete fhCellEMCALEt;
181 delete fhTrackPtBcut;
182 delete fhChPartMultInTpc;
190 delete[] fTrackListB;
198 # define jet_finder_ua1 jet_finder_ua1_
200 # define type_of_call
203 # define jet_finder_ua1 JET_FINDER_UA1
205 # define type_of_call _stdcall
208 extern "C" void type_of_call
209 jet_finder_ua1(Int_t& ncell, Int_t& ncell_tot,
210 Float_t etc[30000], Float_t etac[30000],
212 Float_t& min_move, Float_t& max_move, Int_t& mode,
213 Float_t& prec_bg, Int_t& ierror);
215 extern "C" void type_of_call hf1(Int_t& id, Float_t& x, Float_t& wgt);
218 void AliEMCALJetFinder::Init()
221 // Geometry and I/O initialization
225 // Get geometry parameters from EMCAL
229 //AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
230 // AliEMCALGeometry* geom =
231 // AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), "");
232 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
233 AliEMCALGeometry* geom = gime->EMCALGeometry() ;
235 // SetSamplingFraction(geom->GetSampling());
237 fNbinEta = geom->GetNZ();
238 fNbinPhi = geom->GetNPhi();
239 fPhiMin = geom->GetArm1PhiMin()*TMath::Pi()/180.;
240 fPhiMax = geom->GetArm1PhiMax()*TMath::Pi()/180.;
241 fEtaMin = geom->GetArm1EtaMin();
242 fEtaMax = geom->GetArm1EtaMax();
243 fDphi = (fPhiMax-fPhiMin)/fNbinPhi;
244 fDeta = (fEtaMax-fEtaMin)/fNbinEta;
245 fNtot = fNbinPhi*fNbinEta;
246 fWeightingMethod = kFALSE;
249 SetCellSize(fDeta, fDphi);
252 if (fOutFileName) fOutFile = new TFile(fOutFileName, "recreate");
257 void AliEMCALJetFinder::Find(Int_t ncell, Int_t ncell_tot, Float_t etc[30000],
258 Float_t etac[30000], Float_t phic[30000],
259 Float_t min_move, Float_t max_move, Int_t mode,
260 Float_t prec_bg, Int_t ierror)
262 // Wrapper for fortran coded jet finder
263 // Full argument list
264 jet_finder_ua1(ncell, ncell_tot, etc, etac, phic,
265 min_move, max_move, mode, prec_bg, ierror);
266 // Write result to output
267 if(fWrite) WriteJets();
271 void AliEMCALJetFinder::Find()
273 // Wrapper for fortran coded jet finder using member data for
276 Float_t min_move = fMinMove;
277 Float_t max_move = fMaxMove;
279 Float_t prec_bg = fPrecBg;
281 ResetJets(); // 4-feb-2002 by PAI
283 jet_finder_ua1(fNcell, fNtot, fEtCell, fEtaCell, fPhiCell,
284 min_move, max_move, mode, prec_bg, ierror);
286 // Write result to output
287 Int_t njet = Njets();
289 for (Int_t nj=0; nj<njet; nj++)
291 if (fWeightingMethod)
293 fJetT[nj] = new AliEMCALJet(WeightedJetEnergy( JetEtaW(nj),JetPhiW(nj) ),
299 fJetT[nj] = new AliEMCALJet(JetEnergy(nj),
303 fJetT[nj]->SetIsWeightedEnergy(fWeightingMethod);
304 fJetT[nj]->SetEMCALEnergy( EMCALConeEnergy(JetEtaW(nj),JetPhiW(nj)) );
305 fJetT[nj]->SetTrackEnergy(TrackConeEnergy( JetEtaW(nj),JetPhiW(nj) ));
306 fJetT[nj]->SetHCEnergy(HCConeEnergy( JetEtaW(nj),JetPhiW(nj) ));
310 FindTracksInJetCone();
311 if(fWrite) WriteJets();
316 Float_t AliEMCALJetFinder::EMCALConeEnergy(Float_t eta, Float_t phi)
318 Float_t newenergy = 0.0;
319 Float_t bineta,binphi;
320 TAxis *x = fhLegoEMCAL->GetXaxis();
321 TAxis *y = fhLegoEMCAL->GetYaxis();
322 for (Int_t i = 0 ; i < fNbinEta ; i++) // x coord
324 for (Int_t j = 0 ; j < fNbinPhi ; j++) // y coord
326 bineta = x->GetBinCenter(i);
327 binphi = y->GetBinCenter(j);
328 if ( (bineta-eta)*(bineta-eta) + (binphi-phi)*(binphi-phi) < fConeRadius*fConeRadius)
330 newenergy += fhLegoEMCAL->GetBinContent(i,j);
337 Float_t AliEMCALJetFinder::TrackConeEnergy(Float_t eta, Float_t phi)
339 Float_t newenergy = 0.0;
340 Float_t bineta,binphi;
341 TAxis *x = fhLegoTracks->GetXaxis();
342 TAxis *y = fhLegoTracks->GetYaxis();
343 for (Int_t i = 0 ; i < fNbinEta ; i++) // x coord
345 for (Int_t j = 0 ; j < fNbinPhi ; j++) // y coord
347 bineta = x->GetBinCenter(i);
348 binphi = y->GetBinCenter(j);
349 if ( (bineta-eta)*(bineta-eta) + (binphi-phi)*(binphi-phi) < fConeRadius*fConeRadius)
351 newenergy += fhLegoTracks->GetBinContent(i,j);
358 Float_t AliEMCALJetFinder::HCConeEnergy(Float_t eta, Float_t phi)
360 //Float_t newenergy = 0.0;
361 //Float_t bineta,binphi;
362 //TAxis *x = fhLegoTracks->GetXaxis();
363 //TAxis *y = fhLegoTracks->GetYaxis();
364 //for (Int_t i = 0 ; i < fNbinEta ; i++) // x coord
366 // for (Int_t j = 0 ; j < fNbinPhi ; j++) // y coord
368 // bineta = x->GetBinCenter(i);
369 // binphi = y->GetBinCenter(j);
370 // if ( (bineta-eta)*(bineta-eta) + (binphi-phi)*(binphi-phi) < fConeRadius*fConeRadius)
372 // newenergy += fhLegoTracks->GetBinContent(i,j);
384 Float_t AliEMCALJetFinder::WeightedJetEnergy(Float_t eta, Float_t phi)
388 Float_t newenergy = 0.0;
389 Float_t bineta,binphi;
390 TAxis *x = fhLegoEMCAL->GetXaxis();
391 TAxis *y = fhLegoEMCAL->GetYaxis();
394 for (Int_t i = 0 ; i < fNbinEta ; i++) // x coord
396 for (Int_t j = 0 ; j < fNbinPhi ; j++) // y coord
398 bineta = x->GetBinCenter(i);
399 binphi = y->GetBinCenter(j);
400 if ( (bineta-eta)*(bineta-eta) + (binphi-phi)*(binphi-phi) < fConeRadius*fConeRadius)
402 newenergy += (fEMCALWeight)* fhLegoEMCAL->GetBinContent(i,j) + (fTrackWeight)* fhLegoTracks->GetBinContent(i,j);
412 Int_t AliEMCALJetFinder::Njets()
414 // Get number of reconstructed jets
415 return EMCALJETS.njet;
418 Float_t AliEMCALJetFinder::JetEnergy(Int_t i)
420 // Get reconstructed jet energy
421 return EMCALJETS.etj[i];
424 Float_t AliEMCALJetFinder::JetPhiL(Int_t i)
426 // Get reconstructed jet phi from leading particle
427 return EMCALJETS.phij[0][i];
430 Float_t AliEMCALJetFinder::JetPhiW(Int_t i)
432 // Get reconstructed jet phi from weighting
433 return EMCALJETS.phij[1][i];
436 Float_t AliEMCALJetFinder::JetEtaL(Int_t i)
438 // Get reconstructed jet eta from leading particles
439 return EMCALJETS.etaj[0][i];
443 Float_t AliEMCALJetFinder::JetEtaW(Int_t i)
445 // Get reconstructed jet eta from weighting
446 return EMCALJETS.etaj[1][i];
449 void AliEMCALJetFinder::SetCellSize(Float_t eta, Float_t phi)
451 // Set grid cell size
452 EMCALCELLGEO.etaCellSize = eta;
453 EMCALCELLGEO.phiCellSize = phi;
456 void AliEMCALJetFinder::SetConeRadius(Float_t par)
458 // Set jet cone radius
459 EMCALJETPARAM.coneRad = par;
463 void AliEMCALJetFinder::SetEtSeed(Float_t par)
465 // Set et cut for seeds
466 EMCALJETPARAM.etSeed = par;
470 void AliEMCALJetFinder::SetMinJetEt(Float_t par)
472 // Set minimum jet et
473 EMCALJETPARAM.ejMin = par;
477 void AliEMCALJetFinder::SetMinCellEt(Float_t par)
479 // Set et cut per cell
480 EMCALJETPARAM.etMin = par;
484 void AliEMCALJetFinder::SetPtCut(Float_t par)
486 // Set pT cut on charged tracks
491 void AliEMCALJetFinder::Test()
494 // Test the finder call
496 const Int_t nmax = 30000;
498 Int_t ncell_tot = 100;
503 Float_t min_move = 0;
504 Float_t max_move = 0;
510 Find(ncell, ncell_tot, etc, etac, phic,
511 min_move, max_move, mode, prec_bg, ierror);
519 void AliEMCALJetFinder::AddJet(const AliEMCALJet& jet)
524 TClonesArray &lrawcl = *fJets;
525 new(lrawcl[fNjets++]) AliEMCALJet(jet);
528 void AliEMCALJetFinder::ResetJets()
537 void AliEMCALJetFinder::WriteJets()
540 // Add all jets to the list
542 const Int_t kBufferSize = 4000;
543 const char* file = 0;
545 Int_t njet = Njets();
547 for (Int_t nj = 0; nj < njet; nj++)
554 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
557 // output written to input file
559 AliEMCAL* pEMCAL = (AliEMCAL* )gAlice->GetModule("EMCAL");
560 TTree* pK = gAlice->TreeK();
561 file = (pK->GetCurrentFile())->GetName();
562 TBranch * jetBranch ;
564 printf("Make Branch - TreeR address %p %p\n",gAlice->TreeR(), pEMCAL);
565 //if (fJets && gAlice->TreeR()) {
566 if (fJets && gime->TreeR()) {
567 // pEMCAL->MakeBranchInTree(gAlice->TreeR(),
568 jetBranch = gime->TreeR()->Branch("EMCALJets", &fJets, kBufferSize, 0) ;
569 //pEMCAL->MakeBranchInTree(gime->TreeR(),
575 //Int_t nev = gAlice->GetHeader()->GetEvent();
576 //gAlice->TreeR()->Fill();
579 //sprintf(hname,"TreeR%d", nev);
580 //gAlice->TreeR()->Write(hname);
581 //gAlice->TreeR()->Reset();
582 gime->WriteRecPoints("OVERWRITE");
586 // Output written to user specified output file
588 //TTree* pK = gAlice->TreeK();
589 TTree* pK = gAlice->TreeK();
590 fInFile = pK->GetCurrentFile();
594 sprintf(hname,"TreeR%d", fEvent);
595 TTree* treeJ = new TTree(hname, "EMCALJets");
596 treeJ->Branch("EMCALJets", &fJets, kBufferSize);
604 void AliEMCALJetFinder::BookLego()
607 // Book histo for discretization
611 // Don't add histos to the current directory
612 if(fDebug) printf("\n AliEMCALJetFinder::BookLego() \n");
614 // TH2::AddDirectory(0); // hists wil be put to the list from gROOT
615 // TH1::AddDirectory(0);
619 fLego = new TH2F("legoH","eta-phi",
620 fNbinEta, fEtaMin, fEtaMax,
621 fNbinPhi, fPhiMin, fPhiMax);
624 fLegoB = new TH2F("legoB","eta-phi for BG event",
625 fNbinEta, fEtaMin, fEtaMax,
626 fNbinPhi, fPhiMin, fPhiMax);
629 fhLegoTracks = new TH2F("hLegoTracks","eta-phi for Tracks",
630 fNbinEta, fEtaMin, fEtaMax, fNbinPhi, fPhiMin, fPhiMax);
632 fhLegoEMCAL = new TH2F("hLegoEMCAL","eta-phi for EMCAL",
633 fNbinEta, fEtaMin, fEtaMax, fNbinPhi, fPhiMin, fPhiMax);
634 // Hadron correction map
635 fhLegoHadrCorr = new TH2F("hLegoHadrCorr","eta-phi for Hadron. Correction",
636 fNbinEta, fEtaMin, fEtaMax, fNbinPhi, fPhiMin, fPhiMax);
637 // Hists. for tuning jet finder
638 fhEff = new TH2F("hEff","#epsilon vs momentum ", 100,0.,20., 50,0.5,1.);
642 for(Int_t i=1; i<=1000; i++) eTmp[i] = 0.1*i; // step 100 mev
643 for(Int_t i=1001; i<=1100; i++) eTmp[i] = eTmp[1000] + 1.0*(i-1000); // step 1GeV
645 fhCellEt = new TH1F("hCellEt","Cell E_{T} from fLego",
646 eTmp.GetSize()-1, eTmp.GetArray());
647 fhCellEMCALEt = new TH1F("hCellEMCALEt","Cell E_{T} for EMCAL itself",
648 eTmp.GetSize()-1, eTmp.GetArray());
649 fhTrackPt = new TH1F("hTrackPt","Ch.particles P_{T} ",
650 eTmp.GetSize()-1, eTmp.GetArray());
651 fhTrackPtBcut = new TH1F("hTrackPtBcut","Ch.particles P_{T} + magnetic field cut",
652 eTmp.GetSize()-1, eTmp.GetArray());
654 fhChPartMultInTpc = new TH1F("hChPartMultInTpc",
655 "Charge partilcle multiplicity in |%eta|<0.9", 2000, 0, 20000);
657 fhSinTheta = new TH1F("fhSinTheta","sin(theta)", fNbinEta, fEtaMin, fEtaMax);
658 TAxis *xax = fhSinTheta->GetXaxis();
659 for(Int_t i=1; i<=fNbinEta; i++) {
660 Double_t eta = xax->GetBinCenter(i);
661 fhSinTheta->Fill(eta, 1./TMath::CosH(eta)); // cosh(eta) = 1./sin(theta)
664 //! first canvas for drawing
665 fHistsList=AliEMCALJetMicroDst::MoveHistsToList("Hists from AliEMCALJetFinder", kFALSE);
668 void AliEMCALJetFinder::DumpLego()
671 // Dump lego histo into array
674 TAxis* Xaxis = fLego->GetXaxis();
675 TAxis* Yaxis = fLego->GetYaxis();
676 // fhCellEt->Clear();
678 for (Int_t i = 1; i <= fNbinEta; i++) {
679 for (Int_t j = 1; j <= fNbinPhi; j++) {
681 e = fLego->GetBinContent(i,j);
683 if (gRandom->Rndm() < 0.5) {
684 Float_t ebg = 0.28 * TMath::Abs(gRandom->Gaus(0.,1.));
688 if (e > 0.0) e -= fMinCellEt;
690 Float_t eta = Xaxis->GetBinCenter(i);
691 Float_t phi = Yaxis->GetBinCenter(j);
693 fEtaCell[fNcell] = eta;
694 fPhiCell[fNcell] = phi;
698 eH = fhLegoEMCAL->GetBinContent(i,j);
699 if(eH > 0.0) fhCellEMCALEt->Fill(eH);
707 void AliEMCALJetFinder::ResetMap()
710 // Reset eta-phi array
712 for (Int_t i=0; i<30000; i++)
721 void AliEMCALJetFinder::FillFromTracks(Int_t flag, Int_t ich)
725 const char* name = gAlice->Generator()->GetName();
726 enum {kPythia, kHijing, kHijingPara};
729 if (!strcmp(name, "Hijing")){
731 } else if (!strcmp(name, "Pythia")) {
733 } else if (!strcmp(name, "HIJINGpara") ||!strcmp(name, "HIGINGpara")) {
734 genType = kHijingPara;
737 printf("Fill tracks generated by %s %d\n", name, genType);
741 // Fill Cells with track information
744 printf("\n AliEMCALJetFinder::FillFromTracks(%i,%i) ",flag,ich);
749 if (!fLego) BookLego();
751 if (flag == 0) fLego->Reset();
753 // Access particle information
754 Int_t npart = (gAlice->GetHeader())->GetNprimary();
755 Int_t ntr = (gAlice->GetHeader())->GetNtrack();
756 printf(" : #primary particles %i # tracks %i : (before) Sum.Et %f\n",
757 npart, ntr, fLego->Integral());
762 // 1: selected for jet finding
765 if (fTrackList) delete[] fTrackList;
766 if (fPtT) delete[] fPtT;
767 if (fEtaT) delete[] fEtaT;
768 if (fPhiT) delete[] fPhiT;
769 if (fPdgT) delete[] fPdgT;
771 fTrackList = new Int_t [npart];
772 fPtT = new Float_t[npart];
773 fEtaT = new Float_t[npart];
774 fPhiT = new Float_t[npart];
775 fPdgT = new Int_t[npart];
779 Float_t chTmp=0.0; // charge of current particle
782 // this is for Pythia ??
783 for (Int_t part = 0; part < npart; part++) {
784 TParticle *MPart = gAlice->GetMCApp()->Particle(part);
785 Int_t mpart = MPart->GetPdgCode();
786 Int_t child1 = MPart->GetFirstDaughter();
787 Float_t pT = MPart->Pt();
788 Float_t p = MPart->P();
789 Float_t phi = MPart->Phi();
791 if(pT > 0.001) eta = MPart->Eta();
792 Float_t theta = MPart->Theta();
793 if (fDebug>=2 && MPart->GetStatusCode()==1) {
794 printf("ind %7i part %7i -> child1 %5i child2 %5i Status %5i\n",
795 part, mpart, child1, MPart->GetLastDaughter(), MPart->GetStatusCode());
798 if (fDebug >= 2 && genType == kPythia) {
799 if (part == 6 || part == 7)
801 printf("\n Simulated Jet (pt, eta, phi): %d %f %f %f\n",
802 part-5, pT, eta, phi);
806 fTrackList[part] = 0;
807 fPtT[part] = pT; // must be change after correction for resolution !!!
812 // final state particles only
814 if (genType == kPythia) {
815 if (MPart->GetStatusCode() != 1) continue;
816 } else if (genType == kHijing) {
817 if (child1 >= 0 && child1 < npart) continue;
821 TParticlePDG* pdgP = 0;
822 // charged or neutral
823 pdgP = MPart->GetPDG();
824 chTmp = pdgP->Charge() / 3.; // 13-feb-2001!!
831 if (mpart != kNeutron &&
832 mpart != kNeutronBar &&
833 mpart != kK0Long) continue;
836 } else if (ich == 2) {
837 if (mpart == kNeutron ||
838 mpart == kNeutronBar ||
839 mpart == kK0Long) continue;
842 if (TMath::Abs(eta)<=0.9) fNChTpc++;
844 if (child1 >= 0 && child1 < npart) continue;
846 if (eta > fEtaMax || eta < fEtaMin) continue;
847 if (phi > fPhiMax || phi < fPhiMin ) continue;
850 printf("\n=>nsel:%5d mpart %5d child1 %5d eta %6.2f phi %6.2f pT %6.2f ch %3.0f ",
851 part, mpart, child1, eta, phi, pT, chTmp);
854 // Momentum smearing goes here ...
858 if (fSmear && TMath::Abs(chTmp)) {
859 pw = AliEMCALFast::SmearMomentum(1,p);
860 // p changed - take into account when calculate pT,
863 if(fDebug >= 4) printf("\n Smearing : p %8.4f change to %8.4f ", p, pw);
867 // Tracking Efficiency and TPC acceptance goes here ...
869 if (fEffic && TMath::Abs(chTmp)) {
870 eff = 0.9; // AliEMCALFast::Efficiency(2,p);
871 if(fhEff) fhEff->Fill(p, eff);
872 if (AliEMCALFast::RandomReject(eff)) {
873 if(fDebug >= 5) printf(" reject due to unefficiency ");
878 // Correction of Hadronic Energy goes here ...
881 // phi propagation for hadronic correction
883 Bool_t curls = kFALSE; // hit two the EMCAL (no curl)
884 Float_t phiHC=0.0, dpH=0.0, dphi=0.0, eTdpH=0;
885 if(TMath::Abs(chTmp)) {
886 // hadr. correction only for charge particle
887 dphi = PropagatePhi(pT, chTmp, curls);
890 printf("\n Delta phi %f pT %f ", dphi, pT);
891 if (curls) printf("\n !! Track is curling");
893 if(!curls) fhTrackPtBcut->Fill(pT);
895 if (fHCorrection && !curls) {
896 if (!fHadronCorrector)
897 Fatal("AliEMCALJetFinder",
898 "Hadronic energy correction required but not defined !");
900 dpH = fHadronCorrector->GetEnergy(p, eta, 7);
901 eTdpH = dpH*TMath::Sin(theta);
903 if (fDebug >= 7) printf(" phi %f phiHC %f eTcorr %f\n",
904 phi, phiHC, -eTdpH); // correction is negative
906 xbin = fLego->GetXaxis()->FindBin(eta);
907 ybin = fLego->GetYaxis()->FindBin(phiHC);
908 cout <<"Hadron Correction affected bin - contents before correction : "<<fLego->GetBinContent(xbin,ybin)<<endl;
909 fLego->Fill(eta, phi, -fSamplingF*eTdpH );
910 cout <<"Hadron Correction affected bin - contents after correction : "<<fLego->GetBinContent(xbin,ybin)<<endl;
911 fhLegoHadrCorr->Fill(eta, phi, fSamplingF*eTdpH);
915 // More to do ? Just think about it !
917 if (phi > fPhiMax || phi < fPhiMin ) continue;
919 if(TMath::Abs(chTmp) ) { // charge particle
920 if (pT > fPtCut && !curls) {
921 if (fDebug >= 8) printf("Charge : fLego->Fill(%5.2f, %5.2f, %6.2f, %d)\n",
922 eta , phi, pT, fNtS);
923 fLego->Fill(eta, phi, pT);
924 fhLegoTracks->Fill(eta, phi, pT); // 20-feb for checking
925 fTrackList[part] = 1;
928 } else if(ich > 0 || fK0N) {
929 // case of n, nbar and K0L
930 if (fDebug >= 9) printf("Neutral : fLego->Fill(%5.2f, %5.2f, %6.2f, %d)\n",
931 eta , phi, pT, fNtS);
932 fLego->Fill(eta, phi, pT);
933 fTrackList[part] = 1;
938 for(Int_t i=0; i<fLego->GetSize(); i++) {
939 Float_t etc = (*fLego)[i];
940 if (etc > fMinCellEt) etsum += etc;
943 printf("FillFromTracks: Sum above threshold %f -> %f (%f)\n", fMinCellEt, etsum, fLego->Integral());
944 printf(" Track selected(fNtS) %i \n", fNtS);
949 void AliEMCALJetFinder::FillFromHits(Int_t flag)
952 // Fill Cells with hit information
956 printf("\n AliEMCALJetFinder::FillFromHits(%i)\n",flag);
960 if (!fLego) BookLego();
961 // Reset eta-phi maps if needed
962 if (flag == 0) { // default behavior
964 fhLegoTracks->Reset();
965 fhLegoEMCAL->Reset();
966 fhLegoHadrCorr->Reset();
968 // Initialize from background event if available
970 // Access hit information
971 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
972 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
973 TTree *treeH = gime->TreeH();
974 Int_t ntracks = (Int_t) treeH->GetEntries();
979 // Double_t etH = 0.0;
981 for (Int_t track=0; track<ntracks;track++) {
983 nbytes += treeH->GetEvent(track);
987 for(AliEMCALHit* mHit=(AliEMCALHit*) pEMCAL->FirstHit(-1);
989 mHit=(AliEMCALHit*) pEMCAL->NextHit())
991 Float_t x = mHit->X(); // x-pos of hit
992 Float_t y = mHit->Y(); // y-pos
993 Float_t z = mHit->Z(); // z-pos
994 Float_t eloss = mHit->GetEnergy(); // deposited energy
996 Float_t r = TMath::Sqrt(x*x+y*y);
997 Float_t theta = TMath::ATan2(r,z);
998 Float_t eta = -TMath::Log(TMath::Tan(theta/2.));
999 Float_t phi = TMath::ATan2(y,x);
1001 if (fDebug >= 21) printf("\n Hit %f %f %f %f %f %f %f %f", x, y, z, eloss, r, eta, phi, fSamplingF);
1003 // etH = fSamplingF*eloss*TMath::Sin(theta);
1004 fLego->Fill(eta, phi, eloss);
1008 // Transition from deposit energy to eT (eT = de*SF*sin(theta))
1010 for(Int_t i=1; i<=fLego->GetNbinsX(); i++){ // eta
1011 Double_t sinTheta = fhSinTheta->GetBinContent(i), eT=0;
1012 for(Int_t j=1; j<=fLego->GetNbinsY(); j++){ // phi
1013 eT = fLego->GetBinContent(i,j)*fSamplingF*sinTheta;
1014 fLego->SetBinContent(i,j,eT);
1015 // copy content of fLego to fhLegoEMCAL (fLego and fhLegoEMCAL are identical)
1016 fhLegoEMCAL->SetBinContent(i,j,eT);
1017 if (eT > fMinCellEt) etsum += eT;
1021 // for(Int_t i=0; i<fLego->GetSize(); i++) {
1022 // (*fhLegoEMCAL)[i] = (*fLego)[i];
1023 // Float_t etc = (*fLego)[i];
1024 // if (etc > fMinCellEt) etsum += etc;
1027 printf("FillFromHits: Sum above threshold %f -> %f \n ", fMinCellEt, etsum);
1031 void AliEMCALJetFinder::FillFromDigits(Int_t flag)
1034 // Fill Cells with digit information
1039 if (!fLego) BookLego();
1040 if (flag == 0) fLego->Reset();
1047 TClonesArray* digs = new TClonesArray("AliEMCALDigit", 10000);
1048 TTree *treeD = gAlice->TreeD();
1049 TBranchElement* branchDg = (TBranchElement*)
1050 treeD->GetBranch("EMCAL");
1052 if (!branchDg) Fatal("AliEMCALJetFinder",
1053 "Reading digits requested but no digits in file !");
1055 branchDg->SetAddress(&digs);
1056 Int_t nent = (Int_t) branchDg->GetEntries();
1058 // Connect digitizer
1060 AliEMCALDigitizer* digr = new AliEMCALDigitizer();
1061 TBranchElement* branchDr = (TBranchElement*)
1062 treeD->GetBranch("AliEMCALDigitizer");
1063 branchDr->SetAddress(&digr);
1066 nbytes += branchDg->GetEntry(0);
1067 nbytes += branchDr->GetEntry(0);
1069 // Get digitizer parameters
1070 Float_t preADCped = digr->GetPREpedestal();
1071 Float_t preADCcha = digr->GetPREchannel();
1072 Float_t ecADCped = digr->GetECApedestal();
1073 Float_t ecADCcha = digr->GetECAchannel();
1074 Float_t hcADCped = digr->GetHCApedestal();
1075 Float_t hcADCcha = digr->GetHCAchannel();
1077 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
1078 AliEMCALGeometry* geom =
1079 AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), "");
1082 Int_t ndig = digs->GetEntries();
1083 Info("FillFromDigits","Number of Digits: %d %d\n Parameters: PRE : %f %f EC: %f %f HC: %f %f\n Geometry: %d %d",
1084 ndig, nent, preADCped, preADCcha, ecADCped, ecADCcha, hcADCped, hcADCcha, geom->GetNEta(), geom->GetNPhi());
1091 while ((sdg = (AliEMCALDigit*)(next())))
1093 Double_t pedestal = 0.;
1094 Double_t channel = 0.;
1095 if (geom->IsInPRE(sdg->GetId())) {
1096 pedestal = preADCped;
1097 channel = preADCcha;
1099 else if (geom->IsInECA(sdg->GetId())) {
1100 pedestal = ecADCped;
1103 else if (geom->IsInHCA(sdg->GetId())) {
1104 pedestal = hcADCped;
1108 Fatal("FillFromDigits", "unexpected digit is number!") ;
1110 Float_t eta = sdg->GetEta();
1111 Float_t phi = sdg->GetPhi() * TMath::Pi()/180.;
1112 Float_t amp = (Float_t) (channel*(sdg->GetAmp())-pedestal);
1115 Info("FillFromDigits", "Digit: eta %8.3f phi %8.3f amp %8.3f %8d",
1116 eta, phi, amp, sdg->GetAmp());
1118 fLego->Fill(eta, phi, fSamplingF*amp);
1126 void AliEMCALJetFinder::FillFromHitFlaggedTracks(Int_t flag)
1129 // Fill Cells with hit information
1134 if (!fLego) BookLego();
1136 if (flag == 0) fLego->Reset();
1138 // Flag charged tracks passing through TPC which
1139 // are associated to EMCAL Hits
1140 BuildTrackFlagTable();
1143 // Access particle information
1144 TTree *treeK = gAlice->TreeK();
1145 Int_t ntracks = (Int_t) treeK->GetEntries();
1147 if (fPtT) delete[] fPtT;
1148 if (fEtaT) delete[] fEtaT;
1149 if (fPhiT) delete[] fPhiT;
1150 if (fPdgT) delete[] fPdgT;
1152 fPtT = new Float_t[ntracks];
1153 fEtaT = new Float_t[ntracks];
1154 fPhiT = new Float_t[ntracks];
1155 fPdgT = new Int_t[ntracks];
1160 for (Int_t track = 0; track < ntracks; track++) {
1161 TParticle *MPart = gAlice->GetMCApp()->Particle(track);
1162 Float_t pT = MPart->Pt();
1163 Float_t phi = MPart->Phi();
1164 Float_t eta = MPart->Eta();
1166 if(fTrackList[track]) {
1170 fPdgT[track] = MPart->GetPdgCode();
1172 if (track < 2) continue; //Colliding particles?
1173 if (pT == 0 || pT < fPtCut) continue;
1175 fLego->Fill(eta, phi, pT);
1181 void AliEMCALJetFinder::FillFromParticles()
1183 // 26-feb-2002 PAI - for checking all chain
1184 // Work on particles level; accept all particle (not neutrino )
1186 Double_t PX=0, PY=0, PZ=0, E=0; // checking conservation law
1190 if (!fLego) BookLego();
1193 // Access particles information
1194 Int_t npart = (gAlice->GetHeader())->GetNprimary();
1195 if (fDebug >= 2 || npart<=0) {
1196 printf(" AliEMCALJetFinder::FillFromParticles : npart %i\n", npart);
1197 if(npart<=0) return;
1201 RearrangeParticlesMemory(npart);
1203 // Go through the particles
1204 Int_t mpart, child1, child2, geantPdg;
1205 Float_t pT, phi, eta, e=0, px=0, py=0, pz=0;
1207 for (Int_t part = 0; part < npart; part++) {
1209 fTrackList[part] = 0;
1211 MPart = gAlice->GetMCApp()->Particle(part);
1212 mpart = MPart->GetPdgCode();
1213 child1 = MPart->GetFirstDaughter();
1214 child2 = MPart->GetLastDaughter();
1222 e = MPart->Energy();
1224 // see pyedit in Pythia's text
1226 if (IsThisPartonsOrDiQuark(mpart)) continue;
1227 printf("%5i: %5i(%2i) px %5.1f py %5.1f pz %6.1f e %6.1f childs %5i,%5i \n",
1228 part, mpart, geantPdg, px, py, pz, e, child1, child2);
1230 // exclude partons (21 - gluon, 92 - string)
1233 // exclude neutrinous also ??
1234 if (fDebug >= 11 && pT>0.01)
1235 printf("\n part:%5d mpart %5d eta %9.2f phi %9.2f pT %9.2f ",
1236 part, mpart, eta, phi, pT);
1241 fPdgT[part] = mpart;
1245 if (child1 >= 0 && child1 < npart) continue;
1247 // printf("%4i -> %5i(%3i) px %6.1f py %6.1f pz %7.1f e %8.2f child1 %5i %s\n",
1248 // part, mpart, geantPdg, px, py, pz, e, child1, name.Data());
1255 if (TMath::Abs(eta) <= 0.9) fNChTpc++;
1257 if (eta > fEtaMax || eta < fEtaMin) continue;
1258 if (phi > fPhiMax || phi < fPhiMin ) continue;
1260 if(fK0N==0 ) { // exclude neutral hadrons
1261 if (mpart == kNeutron || mpart == kNeutronBar || mpart == kK0Long) continue;
1263 fTrackList[part] = 1;
1264 fLego->Fill(eta, phi, pT);
1267 printf("\n PX %8.2f PY %8.2f PZ %8.2f E %8.2f \n",
1270 if(fhChPartMultInTpc) fhChPartMultInTpc->Fill(fNChTpc);
1273 void AliEMCALJetFinder::FillFromPartons()
1275 // function under construction - 13-feb-2002 PAI
1278 printf("\n AliEMCALJetFinder::FillFromPartons()\n");
1282 if (!fLego) BookLego();
1285 // Access particle information
1286 Int_t npart = (gAlice->GetHeader())->GetNprimary();
1287 if (fDebug >= 2 || npart<=0)
1288 printf("\n AliEMCALJetFinder::FillFromPartons : npart %i\n", npart);
1289 fNt = 0; // for FindTracksInJetCone
1292 // Go through the partons
1294 for (Int_t part = 8; part < npart; part++) {
1295 TParticle *MPart = gAlice->GetMCApp()->Particle(part);
1296 Int_t mpart = MPart->GetPdgCode();
1297 // Int_t child1 = MPart->GetFirstDaughter();
1298 Float_t pT = MPart->Pt();
1299 // Float_t p = MPart->P();
1300 Float_t phi = MPart->Phi();
1301 Float_t eta = MPart->Eta();
1302 // Float_t theta = MPart->Theta();
1303 statusCode = MPart->GetStatusCode();
1305 // accept partons (21 - gluon, 92 - string)
1306 if (!(TMath::Abs(mpart) <= 6 || mpart == 21 ||mpart == 92)) continue;
1307 if (fDebug > 1 && pT>0.01)
1308 printf("\n part:%5d mpart %5d status %5d eta %8.2f phi %8.2f pT %8.2f ",
1309 part, mpart, statusCode, eta, phi, pT);
1310 // if (fDebug >= 3) MPart->Print();
1311 // accept partons before fragmentation - p.57 in Pythia manual
1312 // if(statusCode != 1) continue;
1314 if (eta > fEtaMax || eta < fEtaMin) continue;
1315 if (phi > fPhiMax || phi < fPhiMin ) continue;
1317 // if (child1 >= 0 && child1 < npart) continue;
1320 fLego->Fill(eta, phi, pT);
1326 void AliEMCALJetFinder::BuildTrackFlagTable() {
1328 // Method to generate a lookup table for TreeK particles
1329 // which are linked to hits in the EMCAL
1331 // --Author: J.L. Klay
1333 // Access hit information
1334 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
1336 TTree *TK = gAlice->TreeK(); // Get the number of entries in the kine tree
1337 Int_t nKTrks = (Int_t) TK->GetEntries(); // (Number of particles created somewhere)
1339 if(fTrackList) delete[] fTrackList; //Make sure we get rid of the old one
1340 fTrackList = new Int_t[nKTrks]; //before generating a new one
1342 for (Int_t i = 0; i < nKTrks; i++) { //Initialize members to 0
1346 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
1347 // TTree *treeH = gAlice->TreeH();
1348 TTree *treeH = gime->TreeH();
1349 Int_t ntracks = (Int_t) treeH->GetEntries();
1355 for (Int_t track=0; track<ntracks;track++) {
1356 gAlice->ResetHits();
1357 nbytes += treeH->GetEvent(track);
1363 for(AliEMCALHit* mHit=(AliEMCALHit*) pEMCAL->FirstHit(-1);
1365 mHit=(AliEMCALHit*) pEMCAL->NextHit())
1367 Int_t iTrk = mHit->Track(); // track number
1368 Int_t idprim = mHit->GetPrimary(); // primary particle
1370 //Determine the origin point of this particle - it made a hit in the EMCAL
1371 TParticle *trkPart = gAlice->GetMCApp()->Particle(iTrk);
1372 TParticlePDG *trkPdg = trkPart->GetPDG();
1373 Int_t trkCode = trkPart->GetPdgCode();
1375 if (trkCode < 10000) { //Big Ions cause problems for
1376 trkChg = trkPdg->Charge(); //this function. Since they aren't
1377 } else { //likely to make it very far, set
1378 trkChg = 0.0; //their charge to 0 for the Flag test
1380 Float_t vxTrk = trkPart->Vx();
1381 Float_t vyTrk = trkPart->Vy();
1382 Float_t vrTrk = TMath::Sqrt(vxTrk*vxTrk+vyTrk*vyTrk);
1383 fTrackList[iTrk] = SetTrackFlag(vrTrk,trkCode,trkChg);
1385 //Loop through the ancestry of the EMCAL entrance particles
1386 Int_t ancestor = trkPart->GetFirstMother(); //Get track's Mother
1387 while (ancestor != -1) {
1388 TParticle *ancPart = gAlice->GetMCApp()->Particle(ancestor); //get particle info on ancestor
1389 TParticlePDG *ancPdg = ancPart->GetPDG();
1390 Int_t ancCode = ancPart->GetPdgCode();
1392 if (ancCode < 10000) {
1393 ancChg = ancPdg->Charge();
1397 Float_t vxAnc = ancPart->Vx();
1398 Float_t vyAnc = ancPart->Vy();
1399 Float_t vrAnc = TMath::Sqrt(vxAnc*vxAnc+vyAnc*vyAnc);
1400 fTrackList[ancestor] = SetTrackFlag(vrAnc,ancCode,ancChg);
1401 ancestor = ancPart->GetFirstMother(); //Get the next ancestor
1404 //Determine the origin point of the primary particle associated with the hit
1405 TParticle *primPart = gAlice->GetMCApp()->Particle(idprim);
1406 TParticlePDG *primPdg = primPart->GetPDG();
1407 Int_t primCode = primPart->GetPdgCode();
1409 if (primCode < 10000) {
1410 primChg = primPdg->Charge();
1414 Float_t vxPrim = primPart->Vx();
1415 Float_t vyPrim = primPart->Vy();
1416 Float_t vrPrim = TMath::Sqrt(vxPrim*vxPrim+vyPrim*vyPrim);
1417 fTrackList[idprim] = SetTrackFlag(vrPrim,primCode,primChg);
1423 Int_t AliEMCALJetFinder
1424 ::SetTrackFlag(Float_t radius, Int_t code, Double_t charge) {
1430 if (charge == 0) neutral = 1;
1432 if (TMath::Abs(code) <= 6 ||
1434 code == 92) parton = 1;
1436 //It's not a parton, it's charged and it went through the TPC
1437 if (!parton && !neutral && radius <= 84.0) flag = 1;
1444 void AliEMCALJetFinder::SaveBackgroundEvent(Char_t *name)
1446 // Saves the eta-phi lego and the tracklist and name of file with BG events
1450 (*fLegoB) = (*fLegoB) + (*fLego);
1452 printf("\n AliEMCALJetFinder::SaveBackgroundEvent() (fLegoB) %f = %f(fLego) \n",
1453 fLegoB->Integral(), fLego->Integral());
1456 if (fPtB) delete[] fPtB;
1457 if (fEtaB) delete[] fEtaB;
1458 if (fPhiB) delete[] fPhiB;
1459 if (fPdgB) delete[] fPdgB;
1460 if (fTrackListB) delete[] fTrackListB;
1462 fPtB = new Float_t[fNtS];
1463 fEtaB = new Float_t[fNtS];
1464 fPhiB = new Float_t[fNtS];
1465 fPdgB = new Int_t [fNtS];
1466 fTrackListB = new Int_t [fNtS];
1470 for (Int_t i = 0; i < fNt; i++) {
1471 if (!fTrackList[i]) continue;
1472 fPtB [fNtB] = fPtT [i];
1473 fEtaB[fNtB] = fEtaT[i];
1474 fPhiB[fNtB] = fPhiT[i];
1475 fPdgB[fNtB] = fPdgT[i];
1476 fTrackListB[fNtB] = 1;
1480 printf(" fNtB %i => fNtS %i #particles %i \n", fNtB, fNtS, fNt);
1482 if(strlen(name) == 0) {
1483 TSeqCollection *li = gROOT->GetListOfFiles();
1485 for(Int_t i=0; i<li->GetSize(); i++) {
1486 nf = ((TFile*)li->At(i))->GetName();
1487 if(nf.Contains("backgorund")) break;
1493 printf("BG file name is \n %s\n", fBGFileName.Data());
1496 void AliEMCALJetFinder::InitFromBackground()
1500 if (fDebug) printf("\n AliEMCALJetFinder::InitFromBackground() ");
1504 (*fLego) = (*fLego) + (*fLegoB);
1506 printf("\n AliEMCALJetFinder::InitBackgroundEvent() (fLego) %f = %f(fLegoB) \n",
1507 fLego->Integral(), fLegoB->Integral());
1509 printf(" => fLego undefined \n");
1514 void AliEMCALJetFinder::FindTracksInJetCone()
1517 // Build list of tracks inside jet cone
1520 Int_t njet = Njets();
1521 for (Int_t nj = 0; nj < njet; nj++)
1523 Float_t etaj = JetEtaW(nj);
1524 Float_t phij = JetPhiW(nj);
1525 Int_t nT = 0; // number of associated tracks
1527 // Loop over particles in current event
1528 for (Int_t part = 0; part < fNt; part++) {
1529 if (!fTrackList[part]) continue;
1530 Float_t phi = fPhiT[part];
1531 Float_t eta = fEtaT[part];
1532 Float_t dr = TMath::Sqrt((etaj-eta)*(etaj-eta) +
1533 (phij-phi)*(phij-phi));
1534 if (dr < fConeRadius) {
1535 fTrackList[part] = nj+2;
1540 // Same for background event if available
1543 for (Int_t part = 0; part < fNtB; part++) {
1544 Float_t phi = fPhiB[part];
1545 Float_t eta = fEtaB[part];
1546 Float_t dr = TMath::Sqrt((etaj-eta)*(etaj-eta) +
1547 (phij-phi)*(phij-phi));
1548 fTrackListB[part] = 1;
1550 if (dr < fConeRadius) {
1551 fTrackListB[part] = nj+2;
1555 } // Background available ?
1557 Int_t nT0 = nT + nTB;
1558 printf("Total number of tracks %d\n", nT0);
1560 if (nT0 > 1000) nT0 = 1000;
1562 Float_t* ptT = new Float_t[nT0];
1563 Float_t* etaT = new Float_t[nT0];
1564 Float_t* phiT = new Float_t[nT0];
1565 Int_t* pdgT = new Int_t[nT0];
1570 for (Int_t part = 0; part < fNt; part++) {
1571 if (fTrackList[part] == nj+2) {
1573 for (j=iT-1; j>=0; j--) {
1574 if (fPtT[part] > ptT[j]) {
1579 for (j=iT-1; j>=index; j--) {
1580 ptT [j+1] = ptT [j];
1581 etaT[j+1] = etaT[j];
1582 phiT[j+1] = phiT[j];
1583 pdgT[j+1] = pdgT[j];
1585 ptT [index] = fPtT [part];
1586 etaT[index] = fEtaT[part];
1587 phiT[index] = fPhiT[part];
1588 pdgT[index] = fPdgT[part];
1590 } // particle associated
1591 if (iT > nT0) break;
1595 for (Int_t part = 0; part < fNtB; part++) {
1596 if (fTrackListB[part] == nj+2) {
1598 for (j=iT-1; j>=0; j--) {
1599 if (fPtB[part] > ptT[j]) {
1605 for (j=iT-1; j>=index; j--) {
1606 ptT [j+1] = ptT [j];
1607 etaT[j+1] = etaT[j];
1608 phiT[j+1] = phiT[j];
1609 pdgT[j+1] = pdgT[j];
1611 ptT [index] = fPtB [part];
1612 etaT[index] = fEtaB[part];
1613 phiT[index] = fPhiB[part];
1614 pdgT[index] = fPdgB[part];
1616 } // particle associated
1617 if (iT > nT0) break;
1619 } // Background available ?
1621 fJetT[nj]->SetTrackList(nT0, ptT, etaT, phiT, pdgT);
1630 Float_t AliEMCALJetFinder::PropagatePhi(Float_t pt, Float_t charge, Bool_t& curls)
1632 // Propagates phi angle to EMCAL radius
1634 static Float_t b = 0.0, rEMCAL = -1.0;
1636 b = gAlice->Field()->SolenoidField();
1637 // Get EMCAL radius in cm
1638 rEMCAL = AliEMCALGeometry::GetInstance()->GetIPDistance();
1646 Float_t rB = 3335.6 * pt / b; // [cm] (case of |charge|=1)
1648 // check if particle is curling below EMCAL
1649 if (2.*rB < rEMCAL) {
1654 // if not calculate delta phi
1655 Float_t phi = TMath::ACos(1.-rEMCAL*rEMCAL/(2.*rB*rB));
1656 dPhi = TMath::ATan2(1.-TMath::Cos(phi), TMath::Sin(phi));
1657 dPhi = -TMath::Sign(dPhi, charge);
1662 void hf1(Int_t& , Float_t& , Float_t& )
1664 // dummy for hbook calls
1668 void AliEMCALJetFinder::DrawLego(Char_t *opt)
1669 {if(fLego) fLego->Draw(opt);}
1671 void AliEMCALJetFinder::DrawLegoBackground(Char_t *opt)
1672 {if(fLegoB) fLegoB->Draw(opt);}
1674 void AliEMCALJetFinder::DrawLegoEMCAL(Char_t *opt)
1675 {if(fhLegoEMCAL) fhLegoEMCAL->Draw(opt);}
1677 void AliEMCALJetFinder::DrawHistsForTuning(Int_t mode)
1679 static TPaveText *varLabel=0;
1681 fC1 = new TCanvas("C1","Hists. for tunning", 0,25,600,800);
1691 fhCellEMCALEt->Draw();
1696 fhTrackPtBcut->SetLineColor(2);
1697 fhTrackPtBcut->Draw("same");
1702 varLabel = new TPaveText(0.05,0.5,0.95,0.95,"NDC");
1703 varLabel->SetTextAlign(12);
1704 varLabel->SetFillColor(19); // see TAttFill
1705 TString tmp(GetTitle());
1706 varLabel->ReadFile(GetFileNameForParameters());
1710 if(mode) { // for saving picture to the file
1711 TString stmp(GetFileNameForParameters());
1712 stmp.ReplaceAll("_Par.txt",".ps");
1713 fC1->Print(stmp.Data());
1717 void AliEMCALJetFinder::PrintParameters(Int_t mode)
1720 if(mode==0) file = stdout; // output to terminal
1722 file = fopen(GetFileNameForParameters(),"w");
1723 if(file==0) file = stdout;
1725 fprintf(file,"==== Filling lego ==== \n");
1726 fprintf(file,"Sampling fraction %6.3f ", fSamplingF);
1727 fprintf(file,"Smearing %6i ", fSmear);
1728 fprintf(file,"Efficiency %6i\n", fEffic);
1729 fprintf(file,"Hadr.Correct. %6i ", fHCorrection);
1730 fprintf(file,"P_{T} Cut of ch.par. %6.2f\n", fPtCut);
1731 fprintf(file,"==== Jet finding ==== \n");
1732 fprintf(file,"Cone radius %6.2f ", fConeRadius);
1733 fprintf(file,"Seed E_{T} %6.1f\n", fEtSeed);
1734 fprintf(file,"Min E_{T} of cell %6.1f ", fMinCellEt);
1735 fprintf(file,"Min E_{T} of jet %6.1f\n", fMinJetEt);
1737 fprintf(file,"==== Bg subtraction ==== \n");
1738 fprintf(file,"BG subtraction %6i ", fMode);
1739 fprintf(file,"Min cone move %6.2f\n", fMinMove);
1740 fprintf(file,"Max cone move %6.2f ", fMaxMove);
1741 fprintf(file,"%% change for BG %6.4f\n", fPrecBg);
1743 fprintf(file,"==== No Bg subtraction ==== \n");
1745 printf("BG file name is %s \n", fBGFileName.Data());
1746 if(file != stdout) fclose(file);
1749 void AliEMCALJetFinder::DrawLegos()
1752 fC1 = new TCanvas("C1","Hists. for tunning", 0,25,600,800);
1756 gStyle->SetOptStat(111111);
1758 Int_t nent1, nent2, nent3, nent4;
1759 Double_t int1, int2, int3, int4;
1760 nent1 = (Int_t)fLego->GetEntries();
1761 int1 = fLego->Integral();
1763 if(int1) fLego->Draw("lego");
1765 nent2 = (Int_t)fhLegoTracks->GetEntries();
1766 int2 = fhLegoTracks->Integral();
1768 if(int2) fhLegoTracks->Draw("lego");
1770 nent3 = (Int_t)fhLegoEMCAL->GetEntries();
1771 int3 = fhLegoEMCAL->Integral();
1773 if(int3) fhLegoEMCAL->Draw("lego");
1775 nent4 = (Int_t)fhLegoHadrCorr->GetEntries();
1776 int4 = fhLegoHadrCorr->Integral();
1778 if(int4) fhLegoHadrCorr->Draw("lego");
1780 // just for checking
1781 printf(" Integrals \n");
1782 printf("lego %10.3f \ntrack %10.3f \nhits %10.3f \nHCorr %10.3f\n-- %10.3f(must be 0)\n",
1783 int1, int2, int3, int4, int1 - (int2 + int3 - int4));
1786 const Char_t* AliEMCALJetFinder::GetFileNameForParameters(Char_t* dir)
1789 if(strlen(dir)) tmp = dir;
1795 void AliEMCALJetFinder::RearrangeParticlesMemory(Int_t npart)
1796 { // See FillFromTracks() - npart must be positive
1797 if (fTrackList) delete[] fTrackList;
1798 if (fPtT) delete[] fPtT;
1799 if (fEtaT) delete[] fEtaT;
1800 if (fPhiT) delete[] fPhiT;
1801 if (fPdgT) delete[] fPdgT;
1804 fTrackList = new Int_t [npart];
1805 fPtT = new Float_t[npart];
1806 fEtaT = new Float_t[npart];
1807 fPhiT = new Float_t[npart];
1808 fPdgT = new Int_t[npart];
1810 printf("AliEMCALJetFinder::RearrangeParticlesMemory : npart = %d\n", npart);
1814 Bool_t AliEMCALJetFinder::IsThisPartonsOrDiQuark(Int_t pdg)
1816 Int_t absPdg = TMath::Abs(pdg);
1817 if(absPdg<=6) return kTRUE; // quarks
1818 if(pdg == 21) return kTRUE; // gluon
1819 if(pdg == 92) return kTRUE; // string
1821 // see p.51 of Pythia Manual
1822 // Not include diquarks with c and b quark - 4-mar-2002
1823 // ud_0,sd_0,su_0; dd_1,ud_1,uu_1; sd_1,su_1,ss_1
1824 static Int_t diquark[9]={2101,3101,3201, 1103,2103,2203, 3103,3203,3303};
1825 for(Int_t i=0; i<9; i++) if(absPdg == diquark[i]) return kTRUE; // diquarks
1830 void AliEMCALJetFinder::FindChargedJet()
1833 // Find jet from charged particle information only
1848 for (part = 0; part < fNt; part++) {
1849 if (!fTrackList[part]) continue;
1850 if (fPtT[part] > fEtSeed) nseed++;
1852 printf("\nThere are %d seeds (%d)\n", nseed, fNtS);
1853 Int_t* iSeeds = new Int_t[nseed];
1856 for (part = 0; part < fNt; part++) {
1857 if (!fTrackList[part]) continue;
1858 if (fPtT[part] > fEtSeed) iSeeds[nseed++] = part;
1869 // Find seed with highest pt
1871 Float_t ptmax = -1.;
1874 for (seed = 0; seed < nseed; seed++) {
1875 if ((pt = fPtT[iSeeds[seed]]) > ptmax && iSeeds[seed] != -1) {
1880 if (ptmax < 0.) break;
1881 jndex = iSeeds[index];
1883 // Remove from the list
1885 printf("\n Next Seed %d %f", jndex, ptmax);
1887 // Find tracks in cone around seed
1889 Float_t phiSeed = fPhiT[jndex];
1890 Float_t etaSeed = fEtaT[jndex];
1896 for (part = 0; part < fNt; part++) {
1897 if (!fTrackList[part]) continue;
1898 Float_t deta = fEtaT[part] - etaSeed;
1899 Float_t dphi = fPhiT[part] - phiSeed;
1900 Float_t dR = TMath::Sqrt(deta * deta + dphi * dphi);
1901 if (dR < fConeRadius) {
1903 Float_t theta = 2. * TMath::ATan(TMath::Exp(-fEtaT[part]));
1904 Float_t px = fPtT[part] * TMath::Cos(fPhiT[part]);
1905 Float_t py = fPtT[part] * TMath::Sin(fPhiT[part]);
1906 Float_t pz = fPtT[part] / TMath::Tan(theta);
1911 // if seed, remove it
1913 for (seed = 0; seed < nseed; seed++) {
1914 if (part == iSeeds[seed]) iSeeds[seed] = -1;
1920 // Estimate of jet direction
1921 Float_t phiJ = TMath::ATan2(pyJ, pxJ);
1922 Float_t thetaJ = TMath::ATan2(TMath::Sqrt(pxJ * pxJ + pyJ * pyJ), pzJ);
1923 Float_t etaJ = TMath::Log(TMath::Tan(thetaJ / 2.));
1924 // Float_t ptJ = TMath::Sqrt(pxJ * pxJ + pyJ * pyJ);
1927 // Sum up all energy
1929 Int_t iPhi0 = Int_t((phiJ - fPhiMin) / fDphi);
1930 Int_t iEta0 = Int_t((etaJ - fEtaMin) / fDeta);
1931 Int_t dIphi = Int_t(fConeRadius / fDphi);
1932 Int_t dIeta = Int_t(fConeRadius / fDeta);
1935 for (iPhi = iPhi0 -dIphi; iPhi < iPhi0 + dIphi; iPhi++) {
1936 for (iEta = iEta0 - dIeta; iEta < iEta0 + dIeta; iEta++) {
1937 if (iPhi < 0 || iEta < 0) continue;
1938 Float_t dPhi = fPhiMin + iPhi * fDphi;
1939 Float_t dEta = fEtaMin + iEta * fDeta;
1940 if (TMath::Sqrt(dPhi * dPhi + dEta * dEta) < fConeRadius) continue;
1941 sumE += fLego->GetBinContent(iEta, iPhi);
1947 fJetT[njets++] = new AliEMCALJet(sumE, phiJ, etaJ);
1948 FindTracksInJetCone();
1949 printf("\n Jet Energy %f %f %f %f %d\n", eT, sumE, fPtT[6], fPtT[7], njets);
1950 printf("\n Jet Phi %f %f %f \n", phiJ, fPhiT[6], fPhiT[7]);
1951 printf("\n Jet Eta %f %f %f \n", etaJ, fEtaT[6], fEtaT[7]);
1953 EMCALJETS.njet = njets;
1954 if (fWrite) WriteJets();
1957 // 16-jan-2003 - just for convenience
1958 void AliEMCALJetFinder::Browse(TBrowser* b)
1960 if(fHistsList) b->Add((TObject*)fHistsList);
1963 Bool_t AliEMCALJetFinder::IsFolder() const
1965 if(fHistsList) return kTRUE;
1969 const Char_t* AliEMCALJetFinder::GetNameOfVariant()
1970 {// generate the literal string with info about jet finder
1972 sprintf(name, "jF_R%3.2fMinCell%4.1fPtCut%4.1fEtSeed%4.1fMinEt%4.1fBGSubtr%iSF%4.1f",
1973 fConeRadius,fMinCellEt,fPtCut,fEtSeed,fMinJetEt, fMode, fSamplingF);
1975 nt.ReplaceAll(" ","");
1976 if(fBGFileName.Length()) {
1977 Int_t i1 = fBGFileName.Index("kBackground");
1978 Int_t i2 = fBGFileName.Index("/0000") - 1;
1979 if(i1>=0 && i2>=0) {
1980 TString bg(fBGFileName(i1,i2-i1+1));
1984 printf("<I> Name of variant %s \n", nt.Data());