LCOV - code coverage report
Current view: top level - EVGEN - AliGenEposReader.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 156 0.6 %
Date: 2016-06-14 17:26:59 Functions: 1 16 6.2 %

          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 the AliGenReader interface to be used with AliGenExFile.
      19             : // NextEvent() loops over events
      20             : // and NextParticle() loops over particles.
      21             : // This implementation reads EPOS v3.111 output format (from ROOT trees)
      22             : // Author: Igor Lakomov <Igor.Lakomov@cern.ch>
      23             : 
      24             : #include "AliGenEposReader.h"
      25             : #include "AliGenEpos3EventHeader.h"
      26             : 
      27             : using namespace std;
      28             : 
      29             : // Arrays for PDG codes
      30             : // EPOS codes-->PDG
      31             : // a=269
      32             :  const Int_t a=269;
      33             :  Int_t eposid[a]={1, 2, 3, 4, 5, 6, 10, 9, 12, -12, 11, -11, 14, -14, 13, -13, 16, 15, 110, 120, -120, 220, 130, -130, 230, -230, 20, -20, 330, 111, 121, -121, 221, 131, -131, 231, -231, 331, -140, 240, 1120, 1220, 2130, 1130, 1230, 2230, 1330, 2330, 1111, 1121, 1221, 2221, 1131, 2231, 1331, 2331, 3331, 2140, 17, 18, 19, 0, 99, 1112, 1113, 1114, 2222, 2223, 2224, 2224, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1132, 1133, 1134, 2232, 2233, 2234, 90, 80, 81, 85, 86, 82, 83, 84, 1200, 2300, 1300, 2400, 1400, 3400, 2500, 1500, 3500, 4500, 2200, 1200, 2300, 1300, 3300, 2400, 1400, 3400, 4400, 2500, 1500, 3500, 4500, 5500, 800000091, 800000092, 800000093, 800000094, -340, 340, -241, 241, -141, 141, -341, 341, 250, 150, 350, 450, 251, 151, 351, 451, 440, 441, 550, 551, 2240, 1240, 1140, 2241, 1241, 3240, 2340, 3140, 1340, 3340, 2341, 1341, 3341, 2440, 2441, 1440, 1441, 3440, 3441, 4441, 2250, 2150, 3250, 4250, 1250, 1150, 3150, 4150, 2350, 1350, 3350, 4350, 2450, 1450, 3450, 4450, 2550, 1550, 3550, 2251, 1151, 2351, 1351, 3351, 2451, 1451, 3451, 4451, 2551, 1551, 3551, 4551, 5551, 123, 122, 233, 232, 133, 132, 143, 132, 243, 242, 343, 342, 223, 222, 113, 112, 333, 332, 443, 442, 444, 253, 252, 153, 152, 353, 352, 453, 452, 553, 552, 124, 125, 234, 235, 134, 135, 144, 135, 244, 245, 344, 345, 224, 225, 114, 115, 334, 335, 444, 445, 254, 255, 154, 155, 354, 355, 454, 455, 554, 555, 11099, 12099, 22099, 33099, 44099, 112099, 122099, 800000110, 800000990};
      34             :  Int_t pdgid[a]={2, 1, 3, 4, 5, 6, 22, 21, 11, -11, 12, -12, 13, -13, 14, -14, 15, 16, 111, 211, -211, 221, 321, -321, 311, -311, 310, -310, 331, 113, 213, -213, 223, 323, -323, 313, -313, 333, 421, -411, 2212, 2112, 3122, 3222, 3212, 3112, 3322, 3312, 2224, 2214, 2114, 1114, 3224, 3114, 3324, 3314, 3334, 4122, 99, 99, 99, 99, 99, 32224, 12224, 12222, 31114, 11114, 11112, 21114, 12212, 2124, 32214, 2216, 12214, 22124, 11212, 13122, 3124, 23122, 13212, 23212, 53122, 13216, 13222, 23222, 13226, 13112, 23112, 13116, 23, 24, 25, 32, 33, 35, 36, 37, 2101, 3101, 3201, 4101, 4201, 4301, 5101, 5201, 5301, 5401, 1103, 1103, 3103, 3203, 3303, 4103, 4203, 4303, 4403, 5103, 5203, 5303, 5403, 5503, 91, 92, 93, 94, 431, -431, 413, -413, 423, -423, 433, -433, 511, 521, 531, 541, 513, 523, 533, 543, 441, 443, 551, 553, 4112, 4212, 4222, 4114, 4224, 4132, 4312, 4232, 4322, 4332, 4314, 4324, 4334, 4412, 4414, 4422, 4424, 4432, 4434, 4444, 5112, 5122, 5132, 5142, 5212, 5222, 5232, 5242, 5312, 5322, 5332, 5342, 5412, 5422, 5432, 5442, 5512, 5522, 5532, 5114, 5224, 5314, 5324, 5334, 5414, 5424, 5434, 5444, 5524, 5524, 5534, 5544, 5554, 10213, 10211, 10313, 10311, 10323, 10321, 10423, 10421, 10413, 10411, 10433, 10431, 10113, 10111, 10223, 10221, 10333, 10331, 10443, 10441, 10443, 10513, 10511, 10523, 10521, 10533, 10531, 10543, 10541, 10553, 10551, 20213, 215, 20313, 315, 20323, 325, 20423, 425, 20413, 415, 20433, 435, 20113, 115, 20223, 225, 20333, 335, 20443, 445, 20513, 515, 20523, 525, 20533, 535, 20543, 545, 20553, 555, 9900110, 9900210, 9900220, 9900330, 9900440, 9902210, 9902110, 110, 990};
      35             :         
      36           6 : ClassImp(AliGenEposReader)
      37             : 
      38           0 : AliGenEposReader::AliGenEposReader():
      39           0 :   AliGenReader(),
      40           0 :   fNcurrent(0),
      41           0 :   fNparticle(0),
      42           0 :   fTreeNtuple(0),
      43           0 :   fTreeHeader(0),
      44           0 :   fFile(0),
      45           0 :   fCurrentEvent(0),
      46           0 :   fCurrentParticle(0),
      47           0 :   fGenEventHeader(0),
      48           0 :   fIversn(0),
      49           0 :   fLaproj(0),
      50           0 :   fMaproj(0),
      51           0 :   fLatarg(0),
      52           0 :   fMatarg(0),
      53           0 :   fEngy(0.),
      54           0 :   fNfull(0),
      55           0 :   fNfreeze(0),
      56           0 :   bim(0)
      57             :    
      58           0 : {
      59             :   //default constructor
      60           0 : }
      61             :     
      62           0 : AliGenEposReader::AliGenEposReader(const AliGenEposReader &reader):
      63           0 :   AliGenReader(reader),
      64           0 :   fNcurrent(0),
      65           0 :   fNparticle(0),
      66           0 :   fTreeNtuple(0),
      67           0 :   fTreeHeader(0),
      68           0 :   fFile(0),
      69           0 :   fCurrentEvent(0),
      70           0 :   fCurrentParticle(0),
      71           0 :   fGenEventHeader(0),
      72           0 :   fIversn(0),
      73           0 :   fLaproj(0),
      74           0 :   fMaproj(0),
      75           0 :   fLatarg(0),
      76           0 :   fMatarg(0),
      77           0 :   fEngy(0.),
      78           0 :   fNfull(0),
      79           0 :   fNfreeze(0),
      80           0 :   bim(0)
      81             :   
      82           0 : {
      83           0 :   reader.Copy(*this);
      84           0 : }
      85             :     
      86           0 : AliGenEposReader::~AliGenEposReader(){ delete fTreeNtuple; delete fFile;}
      87             : 
      88             : void AliGenEposReader::Init()
      89             : {
      90             :   //reset file and open a new root file
      91           0 :   if (!fFile) {
      92           0 :     fFile = new TFile(fFileName);
      93           0 :     AliInfo(Form("File %s opened", fFileName));
      94           0 :     fFile->cd();
      95           0 :   }
      96             :   else {
      97           0 :     AliError(Form("Couldn't open input file: %s", fFileName));
      98             :   }
      99             :  
     100             :   // Initialization
     101           0 :   fTreeHeader = (TTree*)gDirectory->Get("teposhead");
     102           0 :   fTreeHeader->SetMakeClass(1);
     103           0 :   fTreeHeader->SetBranchAddress("iversn",&fIversn);
     104           0 :   fTreeHeader->SetBranchAddress("laproj",&fLaproj);
     105           0 :   fTreeHeader->SetBranchAddress("maproj",&fMaproj);
     106           0 :   fTreeHeader->SetBranchAddress("latarg",&fLatarg);
     107           0 :   fTreeHeader->SetBranchAddress("matarg",&fMatarg);
     108           0 :   fTreeHeader->SetBranchAddress("engy",&fEngy);
     109           0 :   fTreeHeader->SetBranchAddress("nfull",&fNfull);
     110           0 :   fTreeHeader->SetBranchAddress("nfreeze",&fNfull);
     111           0 :   fTreeHeader->GetEvent(0);
     112             : 
     113           0 :   fTreeNtuple = (TTree*)gDirectory->Get("teposevent");
     114           0 :   fTreeNtuple->SetMakeClass(1);
     115           0 :   const Int_t maxnp=fTreeNtuple->GetMaximum("np");
     116           0 :   zus.resize(maxnp);
     117           0 :   px.resize(maxnp);
     118           0 :   py.resize(maxnp);
     119           0 :   pz.resize(maxnp);
     120           0 :   e.resize(maxnp);
     121           0 :   x.resize(maxnp);
     122           0 :   y.resize(maxnp);
     123           0 :   z.resize(maxnp);
     124           0 :   t.resize(maxnp);
     125           0 :   id.resize(maxnp);
     126           0 :   ist.resize(maxnp);
     127           0 :   ity.resize(maxnp);
     128           0 :   ior.resize(maxnp);
     129           0 :   jor.resize(maxnp);
     130           0 :   fTreeNtuple->SetBranchAddress("np",&np);
     131           0 :   fTreeNtuple->SetBranchAddress("bim",&bim);
     132           0 :   fTreeNtuple->SetBranchAddress("zus",&zus[0]);
     133           0 :   fTreeNtuple->SetBranchAddress("px",&px[0]);
     134           0 :   fTreeNtuple->SetBranchAddress("py",&py[0]);
     135           0 :   fTreeNtuple->SetBranchAddress("pz",&pz[0]);
     136           0 :   fTreeNtuple->SetBranchAddress("e",&e[0]);
     137           0 :   fTreeNtuple->SetBranchAddress("x",&x[0]);
     138           0 :   fTreeNtuple->SetBranchAddress("y",&y[0]);
     139           0 :   fTreeNtuple->SetBranchAddress("z",&z[0]);
     140           0 :   fTreeNtuple->SetBranchAddress("t",&t[0]);
     141           0 :   fTreeNtuple->SetBranchAddress("id",&id[0]);
     142           0 :   fTreeNtuple->SetBranchAddress("ist",&ist[0]);
     143           0 :   fTreeNtuple->SetBranchAddress("ity",&ity[0]);
     144           0 :   fTreeNtuple->SetBranchAddress("ior",&ior[0]);
     145           0 :   fTreeNtuple->SetBranchAddress("jor",&jor[0]);
     146           0 : }
     147             : 
     148             : Int_t  AliGenEposReader::NextEvent()
     149             : {       
     150           0 :   fCurrentParticle = 0;
     151           0 :   fMothersMap.clear();
     152           0 :   Int_t nentries = (Int_t) fTreeNtuple->GetEntries();
     153           0 :   if(fCurrentEvent < nentries){
     154           0 :         fTreeNtuple->GetEvent(fCurrentEvent);
     155           0 :         if (np>(Int_t)zus.size()) AliFatal("Current event has more particles than expected. Something went wrong!");
     156           0 :         fGenEventHeader = new AliGenEpos3EventHeader();
     157           0 :         ((AliGenEpos3EventHeader*)fGenEventHeader)->SetIversn(fIversn);
     158           0 :         ((AliGenEpos3EventHeader*)fGenEventHeader)->SetLaproj(fLaproj);
     159           0 :         ((AliGenEpos3EventHeader*)fGenEventHeader)->SetMaproj(fMaproj);
     160           0 :         ((AliGenEpos3EventHeader*)fGenEventHeader)->SetLatarg(fLatarg);
     161           0 :         ((AliGenEpos3EventHeader*)fGenEventHeader)->SetMatarg(fMatarg);
     162           0 :         ((AliGenEpos3EventHeader*)fGenEventHeader)->SetEngy(fEngy);
     163           0 :         ((AliGenEpos3EventHeader*)fGenEventHeader)->SetNfull(fNfull);
     164           0 :         ((AliGenEpos3EventHeader*)fGenEventHeader)->SetNfreeze(fNfull);
     165           0 :         ((AliGenEpos3EventHeader*)fGenEventHeader)->SetBim(bim);
     166           0 :         for (Int_t i=0; i<np; i++) fMothersMap.insert( std::pair<Int_t,Int_t>((zus[i]>0&&ior[i]!=i&&ior[i]>=0)?ior[i]:-1,i));
     167           0 :         fCurrentEvent++;
     168           0 :         return np;
     169             :   }     
     170           0 :   AliError("No more events in the file.");
     171           0 :   return 0;
     172           0 : }
     173             : 
     174             : TParticle*  AliGenEposReader::NextParticle()
     175             : {
     176           0 :   std::pair <std::multimap<Int_t,Int_t>::iterator, std::multimap<Int_t,Int_t>::iterator> ret = fMothersMap.equal_range(fCurrentParticle);
     177             :   TParticle* particle =
     178           0 :      new TParticle(EposToPdg(id[fCurrentParticle]),
     179           0 :                    (ist[fCurrentParticle]==0) ? 1 : 0,
     180           0 :                    (zus[fCurrentParticle]>0&&ior[fCurrentParticle]!=fCurrentParticle) ? ior[fCurrentParticle] : -1,
     181             :                    -1,
     182           0 :                    ret.first->second,
     183           0 :                    ret.first->second+fMothersMap.count(fCurrentParticle)-1,
     184           0 :                    px[fCurrentParticle],
     185           0 :                    py[fCurrentParticle],
     186           0 :                    pz[fCurrentParticle],
     187           0 :                    e[fCurrentParticle],
     188           0 :                    x[fCurrentParticle],
     189           0 :                    y[fCurrentParticle],
     190           0 :                    z[fCurrentParticle],
     191           0 :                    t[fCurrentParticle]);
     192             :     
     193           0 :   if (particle && particle->GetStatusCode()==1) {
     194           0 :       particle->SetBit(kTransportBit);
     195           0 :   }
     196           0 :   fCurrentParticle++;
     197           0 :   return particle;
     198           0 : }
     199             : 
     200             : Int_t AliGenEposReader::EposToPdg(Int_t code)
     201             : {
     202           0 :   for(Int_t i=0;i<a;i++) {
     203           0 :     if (eposid[i]==code) return pdgid[i];
     204             :   }
     205             : //  cout<<"Particle id cannot be find in PDG! return 0; \n";
     206           0 :   return 0;     
     207           0 : }
     208             : 
     209             : void  AliGenEposReader::RewindEvent()
     210             : {
     211           0 :   fCurrentParticle = 0; 
     212           0 : }
     213             : 
     214             : void  AliGenEposReader::ChangeFile(const Text_t *fNewFileName)
     215             : { 
     216           0 :   if(fFile && fFile->IsOpen()) fFile->Close();
     217           0 :   AliInfo(Form("File %s closed", fFileName));
     218           0 :   fFileName = fNewFileName;
     219           0 :   fFile=0;
     220           0 :   fCurrentEvent=0;
     221           0 :   Init();
     222           0 :   RewindEvent();
     223           0 : }
     224             : 
     225             : AliGenEposReader&  AliGenEposReader::operator=(const  AliGenEposReader& rhs)
     226             : {
     227           0 :   rhs.Copy(*this);
     228           0 :   return(*this);
     229             : }
     230             : 
     231             : void AliGenEposReader::Copy(TObject&) const
     232             : {
     233           0 :   Fatal("Copy","Not implemented!\n");
     234           0 : }

Generated by: LCOV version 1.11