LCOV - code coverage report
Current view: top level - EVGEN - AliGenReaderEcalJets.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 119 0.8 %
Date: 2016-06-14 17:26:59 Functions: 1 10 10.0 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : //
      18             : // Realisation of AliGenReader to be used with AliGenExtFile
      19             : // It reads Pythia Jet events from a ntuple like event structure.
      20             : // The event format is defined in Init()
      21             : // NextEvent() is used to loop over events and NextParticle() to loop over particles.  
      22             : // Author: andreas.morsch@cern.ch
      23             : //
      24             : #include <TFile.h>
      25             : #include <TParticle.h>
      26             : #include <TDatabasePDG.h>
      27             : #include <TTree.h>
      28             : 
      29             : #include "AliGenReaderEcalJets.h"
      30             : 
      31           6 : ClassImp(AliGenReaderEcalJets)
      32             : 
      33             : 
      34           0 : AliGenReaderEcalJets::AliGenReaderEcalJets():
      35           0 :     fNcurrent(0),
      36           0 :     fNparticle(0),
      37           0 :     fNev(0),
      38           0 :     fNpart(0),
      39           0 :     fNjet(0),     
      40           0 :     fNsjet(0),
      41           0 :     fNpjet(0),
      42           0 :     fTreeNtuple(0) 
      43           0 : {
      44             : // Default constructor
      45           0 :     for (Int_t i = 0; i < 200; i++) {
      46           0 :         if (i < 2) {
      47           0 :             fX[i]     = 0.;    
      48           0 :             fXtyp[i]  = 0; 
      49           0 :         } else if (i < 10) {
      50           0 :             fJet[i]   = 0.;  
      51           0 :             fJeta[i]  = 0.; 
      52           0 :             fJphi[i]  = 0.; 
      53           0 :             fJset[i]  = 0.; 
      54           0 :             fJseta[i] = 0.;
      55           0 :             fJsphi[i] = 0.;
      56           0 :             fJpet[i]  = 0.; 
      57           0 :             fJpeta[i] = 0.;
      58           0 :             fJpphi[i] = 0.;
      59           0 :         } else {
      60           0 :             fXpt[i]  = 0.;
      61           0 :             fXeta[i] = 0.;
      62           0 :             fXphi[i] = 0.;
      63           0 :             fXid[i]  = 0; 
      64             :         }
      65             :     }
      66           0 : }
      67             : 
      68             :  AliGenReaderEcalJets::AliGenReaderEcalJets(const AliGenReaderEcalJets &reader)
      69           0 :      :AliGenReader(reader),
      70           0 :       fNcurrent(0),
      71           0 :       fNparticle(0),
      72           0 :       fNev(0),
      73           0 :       fNpart(0),
      74           0 :       fNjet(0),     
      75           0 :       fNsjet(0),
      76           0 :       fNpjet(0),
      77           0 :       fTreeNtuple(0) 
      78           0 : {
      79           0 :     for (Int_t i = 0; i < 200; i++) {
      80           0 :         if (i < 2) {
      81           0 :             fX[i]     = 0.;    
      82           0 :             fXtyp[i]  = 0; 
      83           0 :         } else if (i < 10) {
      84           0 :             fJet[i]   = 0.;  
      85           0 :             fJeta[i]  = 0.; 
      86           0 :             fJphi[i]  = 0.; 
      87           0 :             fJset[i]  = 0.; 
      88           0 :             fJseta[i] = 0.;
      89           0 :             fJsphi[i] = 0.;
      90           0 :             fJpet[i]  = 0.; 
      91           0 :             fJpeta[i] = 0.;
      92           0 :             fJpphi[i] = 0.;
      93           0 :         } else {
      94           0 :             fXpt[i]  = 0.;
      95           0 :             fXeta[i] = 0.;
      96           0 :             fXphi[i] = 0.;
      97           0 :             fXid[i]  = 0; 
      98             :         }
      99             :     }
     100             : 
     101             :     // Copy Constructor
     102           0 :     reader.Copy(*this);
     103           0 : }
     104             : 
     105             : void AliGenReaderEcalJets::Init() 
     106             : {
     107             : //
     108             : // reset the existing file environment and open a new root file if
     109             : // the pointer to the Fluka tree is null
     110             :     
     111             :     TFile *pFile=0;
     112           0 :     if (!pFile) {
     113           0 :         pFile = new TFile(fFileName);
     114           0 :         pFile->cd();
     115           0 :         printf("\n I have opened %s file \n", fFileName);
     116           0 :     }
     117             : // get the tree address in the Fluka boundary source file
     118           0 :     fTreeNtuple = (TTree*)gDirectory->Get("h1");
     119             :     TTree *h1=fTreeNtuple;
     120           0 :     h1->SetMakeClass(1);
     121             : //Set branch addresses
     122           0 :     h1->SetBranchAddress("nev",   &fNev);
     123           0 :     h1->SetBranchAddress("x",      fX);
     124           0 :     h1->SetBranchAddress("xtyp",   fXtyp);
     125           0 :     h1->SetBranchAddress("npart", &fNpart);
     126           0 :     h1->SetBranchAddress("xpt",    fXpt);
     127           0 :     h1->SetBranchAddress("xeta",   fXeta);
     128           0 :     h1->SetBranchAddress("xphi",   fXphi);
     129           0 :     h1->SetBranchAddress("xid",    fXid);
     130           0 :     h1->SetBranchAddress("njet",  &fNjet);
     131           0 :     h1->SetBranchAddress("jet",    fJet);
     132           0 :     h1->SetBranchAddress("jeta",   fJeta);
     133           0 :     h1->SetBranchAddress("jphi",   fJphi);
     134           0 :     h1->SetBranchAddress("nsjet", &fNsjet);
     135           0 :     h1->SetBranchAddress("jset",   fJset);
     136           0 :     h1->SetBranchAddress("jseta",  fJseta);
     137           0 :     h1->SetBranchAddress("jsphi",  fJsphi);
     138           0 :     h1->SetBranchAddress("npjet", &fNpjet);
     139           0 :     h1->SetBranchAddress("jpet",   fJpet);
     140           0 :     h1->SetBranchAddress("jpeta",  fJpeta);
     141           0 :     h1->SetBranchAddress("jpphi",  fJpphi);
     142           0 : }
     143             : 
     144             : Int_t AliGenReaderEcalJets::NextEvent() 
     145             : {
     146             : // Read the next event  
     147             :     Int_t nTracks=0, nread=0;
     148             :     
     149           0 :     TFile* pFile = fTreeNtuple->GetCurrentFile();
     150           0 :     pFile->cd();
     151             : 
     152           0 :     Int_t nentries = (Int_t) fTreeNtuple->GetEntries();
     153           0 :     if (fNcurrent < nentries) {
     154           0 :         Int_t nb = (Int_t)fTreeNtuple->GetEvent(fNcurrent);
     155             :         nread += nb;
     156           0 :         fNcurrent++;
     157           0 :         printf("\n Next event contains %d tracks! \n", fNpjet);
     158           0 :         nTracks    = fNpjet;
     159           0 :         fNparticle = 0;
     160             :         return nTracks;
     161             :     }
     162           0 :     return 0;
     163           0 : }
     164             : 
     165             : TParticle* AliGenReaderEcalJets::NextParticle() 
     166             : {
     167             : // Read the next particle
     168             : 
     169             :     Float_t p[4];
     170           0 :     Int_t    ipart  = fXid[fNparticle];
     171           0 :     Float_t  pt     = fXpt[fNparticle];
     172           0 :     Float_t  eta    = fXeta[fNparticle];
     173           0 :     Float_t  phi    = fXphi[fNparticle];
     174           0 :     Float_t  theta  = 2.*TMath::ATan(TMath::Exp(-eta));
     175           0 :     Double_t amass  = TDatabasePDG::Instance()->GetParticle(ipart)->Mass();
     176             : 
     177           0 :     p[0] = pt*TMath::Sin(phi);
     178           0 :     p[1] = pt*TMath::Cos(phi);      
     179           0 :     p[2] = pt/TMath::Cos(theta);
     180           0 :     p[3] = TMath::Sqrt(pt*pt+p[2]*p[2]+amass*amass);
     181             :     
     182             : 
     183             :     TParticle* particle = 
     184           0 :         new TParticle(ipart, 0, -1, -1, -1, -1, p[0], p[1], p[2], p[3], 
     185             :                       0., 0., 0., 0.);
     186           0 :     fNparticle++;
     187           0 :     return particle;
     188           0 : }
     189             : 
     190             : 
     191             : 
     192             : AliGenReaderEcalJets& AliGenReaderEcalJets::operator=(const  AliGenReaderEcalJets& rhs)
     193             : {
     194             : // Assignment operator
     195           0 :     rhs.Copy(*this);
     196           0 :     return (*this);
     197             : }
     198             : 
     199             : void AliGenReaderEcalJets::Copy(TObject&) const
     200             : {
     201             :     //
     202             :     // Copy 
     203             :     //
     204           0 :     Fatal("Copy","Not implemented!\n");
     205           0 : }
     206             : 
     207             : 
     208             : 
     209             : 
     210             : 
     211             : 
     212             : 

Generated by: LCOV version 1.11