/************************************************************************** * Copyright(c) 1998-2002, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ /* $Log$ Revision 1.1 2002/02/14 09:15:15 morsch ALiEMCALJetMicroDst first commit. */ //*-- Authors: Aleksei Pavlinov (WSU) //* #include "AliEMCALJetMicroDst.h" #include "AliRun.h" #include "AliHeader.h" #include "AliGenEventHeader.h" #include "AliGenHijingEventHeader.h" #include "AliEMCALJetFinder.h" #include #include #include #include #include ClassImp(AliEMCALJetMicroDst) TString nameTree("jetMDST"); // 7-feb-2002 TH1F* hPtPart, *hNJet, *hPtJet; TH2F* hEtaPhiPart, *hEtaPhiJet; AliEMCALJetMicroDst::AliEMCALJetMicroDst(char *name, char *tit) : TNamed(name,tit) { fFile = 0; fTree = 0; fDebug = 0; fName = "dstTest.root"; // default name // Don't add histos to the current directory // TH1::AddDirectory(0); gROOT->cd(); hPtPart = new TH1F("hPtPart","P_{T} for partons", 300, 0., 300.); hEtaPhiPart = new TH2F("hEtaPhiPart","#eta #phi distr.for partons after HSc", 28, -0.7, 0.7, 21, 0.0, TMath::Pi()*2./3.); hNJet = new TH1F("hNJet","number of jets", 11, -0.5, 10.5); hPtJet = new TH1F("hPtJet","P_{T} for jets", 300, 0., 300.); hEtaPhiJet = new TH2F("hEtaPhiJet","#eta #phi distr.for jets (W)", 28, -0.7, 0.7, 21, 0.0, TMath::Pi()*2./3.); fListHist = MoveHistsToList("Hist For AliEMCALJetMicroDst", kFALSE); } AliEMCALJetMicroDst::~AliEMCALJetMicroDst() { if(fFile) fFile->Close(); } Bool_t AliEMCALJetMicroDst::Create(TFile *file) { if(!file) { printf(" AliEMCALJetMicroDst::create -> define TFile for output\n"); return kFALSE; } fFile = file; fFile->cd(); fTree = new TTree(nameTree.Data(),"Temporary micro DST for jets analysis"); // partons fTree->Branch("npart", &fNpart, "npart/I"); fTree->Branch("xpt", fXpt, "xpt[npart]/F"); fTree->Branch("xeta", fXeta, "xeta[npart]/F"); fTree->Branch("xphi", fXphi, "xphi[npart]/F"); // jets fTree->Branch("njet", &fNjet, "njet/I"); fTree->Branch("jet", fJet, "jet[njet]/F"); fTree->Branch("jetaw", fJetaW, "jetaw[njet]/F"); fTree->Branch("jphiw", fJphiW, "jphiw[njet]/F"); fTree->Branch("jetal", fJetaL, "jetal[njet]/F"); fTree->Branch("jphil", fJphiL, "jphil[njet]/F"); return kTRUE; } Bool_t AliEMCALJetMicroDst::Create(const char *fname) { TFile *file = new TFile(fname, "RECREATE"); if(file) { fName = fname; return Create(file); } else return kFALSE; } Bool_t AliEMCALJetMicroDst::Open(const char *fname) { if(fFile && fFile->IsOpen()) fFile->Close(); if(strlen(fname)) fName = fname; TFile *file = new TFile(fName.Data(), "READ"); if(file) { printf(" open file %s \n",fName.Data()); return Initialize(file); } else { printf(" can not open file %s \n",fName.Data()); return kFALSE; } } Bool_t AliEMCALJetMicroDst::Initialize(TFile *file) { if(file) fFile = file; fFile->cd(); fTree = (TTree*)fFile->Get(nameTree.Data()); if(!fTree) return kFALSE; // partons fTree->SetBranchAddress("npart",&fNpart); fTree->SetBranchAddress("xpt", fXpt); fTree->SetBranchAddress("xeta", fXeta); fTree->SetBranchAddress("xphi", fXphi); // jets fTree->SetBranchAddress("njet", &fNjet); fTree->SetBranchAddress("jet", fJet); fTree->SetBranchAddress("jetaw", fJetaW); fTree->SetBranchAddress("jphiw", fJphiW); fTree->SetBranchAddress("jetal", fJetaL); fTree->SetBranchAddress("jphil", fJphiL); return kTRUE; } void AliEMCALJetMicroDst::Print(Option_t* option) const { if(option); if(fFile) { fFile->Print(); if(fTree) fTree->Print(); else printf(" TRee is zero\n"); } else printf(" File with TRee is zero\n"); printf("Default name of file %s\n", fName.Data()); printf("\n #partons %2i ", fNpart); for(Int_t i=0; iGetHeader()->GenEventHeader(); TString tmp(evHeader->ClassName()); if(tmp.Contains("Hijing")) { AliGenHijingEventHeader *hijEvHeader = (AliGenHijingEventHeader*)evHeader; FillPartons(hijEvHeader); } else if(tmp.Contains("Pythia")) { FillPartons(); } else { printf("\n Wrong type of generator -> %s ",tmp.Data()); printf("\n Inof about partons will be absent "); } FillJets(jetFinder); fTree->Fill(); } void AliEMCALJetMicroDst::FillPartons(AliGenHijingEventHeader *header) { TLorentzVector parton[4]; header->GetJets(parton[0], parton[1], parton[2], parton[3]); fNpart = 4; // for(Int_t i=0; i<4; i++){ fXpt[i] = parton[i].Pt(); fXeta[i] = parton[i].Eta(); fXphi[i] = parton[i].Phi(); if(i>1) { hEtaPhiPart->Fill(parton[i].Eta(), parton[i].Phi()); hPtPart->Fill(parton[i].Pt()); } } } void AliEMCALJetMicroDst::FillPartons() {// for case of Pythia -> get info from full event record fNpart = 2; TParticle *MPart; Int_t ind; for(Int_t i=6; i<8; i++){ MPart = gAlice->Particle(i); ind = i-6; fXpt[ind] = MPart->Pt(); fXeta[ind] = MPart->Eta(); fXphi[ind] = MPart->Phi(); hEtaPhiPart->Fill(fXeta[ind], fXphi[ind]); hPtPart->Fill(fXpt[ind]); } } void AliEMCALJetMicroDst::FillJets(AliEMCALJetFinder* jetFinder) { fNjet = 0; if(fDebug>1) printf("\n AliEMCALJetMicroDst::FillJets"); if(!jetFinder) { if(fDebug>1) printf("\n : jetFinder is zero"); return; } fNjet = jetFinder->Njets(); if(fNjet>10) { if(fDebug>1) printf("\n wrong value of jetFinder->Njets() %i ", fNjet); fNjet = 10; } hNJet->Fill(fNjet); if(fDebug>1) printf("\n fNjet %i", fNjet); if(fNjet){ for(Int_t i=0; iJetEnergy(i); fJetaW[i] = jetFinder->JetEtaW(i); fJphiW[i] = jetFinder->JetPhiW(i); fJetaL[i] = jetFinder->JetEtaL(i); fJphiL[i] = jetFinder->JetPhiL(i); hPtJet->Fill(fJet[i]); hEtaPhiJet->Fill(fJetaW[i],fJphiW[i]); } } } Int_t AliEMCALJetMicroDst::GetEntry(Int_t entry) { // Read contents of entry. if (!fTree) { printf("\n AliEMCALJetMicroDst::GetEntry() -> define TTree \n"); return -1; } return fTree->GetEntry(entry); } Bool_t AliEMCALJetMicroDst::GetParton(Int_t i, Float_t& pt, Float_t& eta, Float_t& phi) { if(i>=0 && i=0 && i AliEMCALJetMicroDst::Test() -> define file with proper TTree !"); return; } Int_t nbytes=0, nb=0, nentries=Int_t(fTree->GetEntries()); for(Int_t i=0; iGetEntry(i); nbytes += nb; for(Int_t j=0; jFill(fXeta[j], fXphi[j]); hPtPart->Fill(fXpt[j]); } hNJet->Fill(fNjet); if(fNjet){ for(Int_t j=0; jFill(fJet[j]); hEtaPhiJet->Fill(fJetaW[j],fJphiW[j]); } } } printf("\n AliEMCALJetMicroDst::Test() -> Entries %5i Bytes %10i\n", nentries, nb); } void AliEMCALJetMicroDst::FillVector(Float_t pt, Float_t eta, Float_t phi, TVector3& vec) { // service function static Float_t px, py, pz; px = pt*TMath::Cos(phi); py = pt*TMath::Sin(phi); pz = pt*TMath::SinH(eta); // sinh(eta) = cot(theta) vec.SetXYZ(px, py, pz); } void AliEMCALJetMicroDst::Close() { fFile->Write(); fTree->Print(); fFile->Close(); fFile = 0; fTree = 0; } void AliEMCALJetMicroDst::Browse(TBrowser* b) { if(fTree) b->Add((TObject*)fTree); if(fListHist) b->Add((TObject*)fListHist); // TObject::Browse(b); } Bool_t AliEMCALJetMicroDst::IsFolder() const { if(fTree || fListHist) return kTRUE; else return kFALSE; } TList* AliEMCALJetMicroDst::MoveHistsToList(char* name, Bool_t putToBrowser) { gROOT->cd(); TIter nextHist(gDirectory->GetList()); TList *list = new TList; list->SetName(name); TObject *objHist; while((objHist=nextHist())){ if (!objHist->InheritsFrom("TH1")) continue; ((TH1*)objHist)->SetDirectory(0); // Remove from gROOT list->Add(objHist); } if(putToBrowser) gROOT->GetListOfBrowsables()->Add((TObject*)list); return list; }