1 /**************************************************************************
2 * Copyright(c) 1998-2002, 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 **************************************************************************/
19 //*-- Authors: Aleksei Pavlinov (WSU)
22 #include "AliEMCALJetMicroDst.h"
24 #include "AliHeader.h"
25 #include "AliGenEventHeader.h"
26 #include "AliGenHijingEventHeader.h"
27 #include "AliEMCALJetFinder.h"
32 #include <TParticle.h>
34 ClassImp(AliEMCALJetMicroDst)
36 TString nameTree("jetMDST"); // 7-feb-2002
38 TH1F* hPtPart, *hNJet, *hPtJet;
39 TH2F* hEtaPhiPart, *hEtaPhiJet;
41 AliEMCALJetMicroDst::AliEMCALJetMicroDst(char *name, char *tit) : TNamed(name,tit)
46 fName = "dstTest.root"; // default name
48 // Don't add histos to the current directory
49 // TH1::AddDirectory(0);
51 hPtPart = new TH1F("hPtPart","P_{T} for partons", 300, 0., 300.);
52 hEtaPhiPart = new TH2F("hEtaPhiPart","#eta #phi distr.for partons after HSc",
53 28, -0.7, 0.7, 21, 0.0, TMath::Pi()*2./3.);
55 hNJet = new TH1F("hNJet","number of jets", 11, -0.5, 10.5);
56 hPtJet = new TH1F("hPtJet","P_{T} for jets", 300, 0., 300.);
57 hEtaPhiJet = new TH2F("hEtaPhiJet","#eta #phi distr.for jets (W)",
58 28, -0.7, 0.7, 21, 0.0, TMath::Pi()*2./3.);
59 fListHist = MoveHistsToList("Hist For AliEMCALJetMicroDst", kFALSE);
62 AliEMCALJetMicroDst::~AliEMCALJetMicroDst()
64 if(fFile) fFile->Close();
67 Bool_t AliEMCALJetMicroDst::Create(TFile *file)
70 printf("<E> AliEMCALJetMicroDst::create -> define TFile for output\n");
75 fTree = new TTree(nameTree.Data(),"Temporary micro DST for jets analysis");
77 fTree->Branch("npart", &fNpart, "npart/I");
78 fTree->Branch("xpt", fXpt, "xpt[npart]/F");
79 fTree->Branch("xeta", fXeta, "xeta[npart]/F");
80 fTree->Branch("xphi", fXphi, "xphi[npart]/F");
82 fTree->Branch("njet", &fNjet, "njet/I");
83 fTree->Branch("jet", fJet, "jet[njet]/F");
84 fTree->Branch("jetaw", fJetaW, "jetaw[njet]/F");
85 fTree->Branch("jphiw", fJphiW, "jphiw[njet]/F");
86 fTree->Branch("jetal", fJetaL, "jetal[njet]/F");
87 fTree->Branch("jphil", fJphiL, "jphil[njet]/F");
91 Bool_t AliEMCALJetMicroDst::Create(const char *fname)
93 TFile *file = new TFile(fname, "RECREATE");
100 Bool_t AliEMCALJetMicroDst::Open(const char *fname)
102 if(fFile && fFile->IsOpen()) fFile->Close();
103 if(strlen(fname)) fName = fname;
104 TFile *file = new TFile(fName.Data(), "READ");
106 printf("<I> open file %s \n",fName.Data());
107 return Initialize(file);
109 printf("<E> can not open file %s \n",fName.Data());
114 Bool_t AliEMCALJetMicroDst::Initialize(TFile *file)
116 if(file) fFile = file;
118 fTree = (TTree*)fFile->Get(nameTree.Data());
119 if(!fTree) return kFALSE;
121 fTree->SetBranchAddress("npart",&fNpart);
122 fTree->SetBranchAddress("xpt", fXpt);
123 fTree->SetBranchAddress("xeta", fXeta);
124 fTree->SetBranchAddress("xphi", fXphi);
126 fTree->SetBranchAddress("njet", &fNjet);
127 fTree->SetBranchAddress("jet", fJet);
128 fTree->SetBranchAddress("jetaw", fJetaW);
129 fTree->SetBranchAddress("jphiw", fJphiW);
130 fTree->SetBranchAddress("jetal", fJetaL);
131 fTree->SetBranchAddress("jphil", fJphiL);
136 void AliEMCALJetMicroDst::Print(Option_t* option) const
141 if(fTree) fTree->Print();
142 else printf("<I> TRee is zero\n");
143 } else printf("<I> File with TRee is zero\n");
144 printf("Default name of file %s\n", fName.Data());
146 printf("\n #partons %2i ", fNpart);
147 for(Int_t i=0; i<fNpart; i++){
148 printf("\n %1i Pt %7.1f eta %f7.4 phi %f7.4 ",
149 i, fXpt[i],fXeta[i],fXphi[i]);
152 printf("\n #jets %2i ", fNjet);
153 for(Int_t i=0; i<fNjet; i++){
154 printf("\n %1i Et %7.1f etaW %f7.4 phiW %f7.4 ",
155 i,fJet[i],fJetaW[i],fJphiW[i]);
159 void AliEMCALJetMicroDst::Fill(AliRun *run, AliEMCALJetFinder* jetFinder)
161 if(!run) run = gAlice;
162 AliGenEventHeader* evHeader = run->GetHeader()->GenEventHeader();
163 TString tmp(evHeader->ClassName());
164 if(tmp.Contains("Hijing")) {
165 AliGenHijingEventHeader *hijEvHeader = (AliGenHijingEventHeader*)evHeader;
166 FillPartons(hijEvHeader);
167 } else if(tmp.Contains("Pythia")) {
170 printf("\n <E> Wrong type of generator -> %s ",tmp.Data());
171 printf("\n Inof about partons will be absent ");
178 void AliEMCALJetMicroDst::FillPartons(AliGenHijingEventHeader *header)
180 TLorentzVector parton[4];
181 header->GetJets(parton[0], parton[1], parton[2], parton[3]);
184 for(Int_t i=0; i<4; i++){
185 fXpt[i] = parton[i].Pt();
186 fXeta[i] = parton[i].Eta();
187 fXphi[i] = parton[i].Phi();
189 hEtaPhiPart->Fill(parton[i].Eta(), parton[i].Phi());
190 hPtPart->Fill(parton[i].Pt());
195 void AliEMCALJetMicroDst::FillPartons()
196 {// for case of Pythia -> get info from full event record
201 for(Int_t i=6; i<8; i++){
202 MPart = gAlice->Particle(i);
204 fXpt[ind] = MPart->Pt();
205 fXeta[ind] = MPart->Eta();
206 fXphi[ind] = MPart->Phi();
208 hEtaPhiPart->Fill(fXeta[ind], fXphi[ind]);
209 hPtPart->Fill(fXpt[ind]);
213 void AliEMCALJetMicroDst::FillJets(AliEMCALJetFinder* jetFinder)
216 if(fDebug>1) printf("\n<I> AliEMCALJetMicroDst::FillJets");
218 if(fDebug>1) printf("\n : jetFinder is zero");
221 fNjet = jetFinder->Njets();
223 if(fDebug>1) printf("\n <W> wrong value of jetFinder->Njets() %i ", fNjet);
227 if(fDebug>1) printf("\n <I> fNjet %i", fNjet);
229 for(Int_t i=0; i<fNjet; i++){
230 fJet[i] = jetFinder->JetEnergy(i);
231 fJetaW[i] = jetFinder->JetEtaW(i);
232 fJphiW[i] = jetFinder->JetPhiW(i);
233 fJetaL[i] = jetFinder->JetEtaL(i);
234 fJphiL[i] = jetFinder->JetPhiL(i);
235 hPtJet->Fill(fJet[i]);
236 hEtaPhiJet->Fill(fJetaW[i],fJphiW[i]);
241 Int_t AliEMCALJetMicroDst::GetEntry(Int_t entry)
242 { // Read contents of entry.
244 printf("\n<E> AliEMCALJetMicroDst::GetEntry() -> define TTree \n");
247 return fTree->GetEntry(entry);
250 Bool_t AliEMCALJetMicroDst::GetParton(Int_t i, Float_t& pt, Float_t& eta, Float_t& phi)
252 if(i>=0 && i<fNpart) {
257 } else return kFALSE;
260 Bool_t AliEMCALJetMicroDst::GetParton(Int_t i, TVector3& vec)
262 static Float_t pt, eta, phi;
264 if(!GetParton(i, pt, eta, phi)) return kFALSE;
266 FillVector(pt, eta, phi, vec);
270 Bool_t AliEMCALJetMicroDst::GetJet(Int_t i,Int_t mode,Float_t& pt, Float_t& eta, Float_t& phi)
271 {// mode=1(W) mode=any(L)
272 if(i>=0 && i<fNjet) {
282 } else return kFALSE;
285 Bool_t AliEMCALJetMicroDst::GetJet(Int_t i, Int_t mode, TVector3& vec)
287 static Float_t pt, eta, phi;
289 if(!GetJet(i, mode, pt, eta, phi)) return kFALSE;
290 FillVector(pt, eta, phi, vec);
294 void AliEMCALJetMicroDst::Test()
296 if(!fFile || !fTree ) {
297 printf("\n<I> AliEMCALJetMicroDst::Test() -> define file with proper TTree !");
300 Int_t nbytes=0, nb=0, nentries=Int_t(fTree->GetEntries());
301 for(Int_t i=0; i<nentries; i++){
302 nb = fTree->GetEntry(i);
304 for(Int_t j=0; j<fNpart; j++){
305 hEtaPhiPart->Fill(fXeta[j], fXphi[j]);
306 hPtPart->Fill(fXpt[j]);
311 for(Int_t j=0; j<fNjet; j++) {
312 hPtJet->Fill(fJet[j]);
313 hEtaPhiJet->Fill(fJetaW[j],fJphiW[j]);
317 printf("\n<I> AliEMCALJetMicroDst::Test() -> Entries %5i Bytes %10i\n", nentries, nb);
320 void AliEMCALJetMicroDst::FillVector(Float_t pt, Float_t eta, Float_t phi, TVector3& vec)
321 { // service function
322 static Float_t px, py, pz;
324 px = pt*TMath::Cos(phi);
325 py = pt*TMath::Sin(phi);
326 pz = pt*TMath::SinH(eta); // sinh(eta) = cot(theta)
328 vec.SetXYZ(px, py, pz);
331 void AliEMCALJetMicroDst::Close()
340 void AliEMCALJetMicroDst::Browse(TBrowser* b)
342 if(fTree) b->Add((TObject*)fTree);
343 if(fListHist) b->Add((TObject*)fListHist);
344 // TObject::Browse(b);
347 Bool_t AliEMCALJetMicroDst::IsFolder() const
349 if(fTree || fListHist) return kTRUE;
353 TList* AliEMCALJetMicroDst::MoveHistsToList(char* name, Bool_t putToBrowser)
356 TIter nextHist(gDirectory->GetList());
357 TList *list = new TList;
360 while((objHist=nextHist())){
361 if (!objHist->InheritsFrom("TH1")) continue;
362 ((TH1*)objHist)->SetDirectory(0); // Remove from gROOT
365 if(putToBrowser) gROOT->GetListOfBrowsables()->Add((TObject*)list);