]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
ReaderInternal: Internal data format implementation
authorskowron <skowron@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 21 May 2002 23:45:35 +0000 (23:45 +0000)
committerskowron <skowron@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 21 May 2002 23:45:35 +0000 (23:45 +0000)
HBTAN/AliHBTReaderInternal.cxx [new file with mode: 0644]
HBTAN/AliHBTReaderInternal.h [new file with mode: 0644]
HBTAN/HBTAnalysisLinkDef.h
HBTAN/Makefile
HBTAN/hbtanalysis.C
HBTAN/libHBTAN.pkg

diff --git a/HBTAN/AliHBTReaderInternal.cxx b/HBTAN/AliHBTReaderInternal.cxx
new file mode 100644 (file)
index 0000000..fb72bd2
--- /dev/null
@@ -0,0 +1,363 @@
+#include "AliHBTReaderInternal.h"
+
+#include <iostream.h>
+//#include <fstream.h>
+#include <TTree.h>
+#include <TFile.h>
+#include <TParticle.h>
+
+#include <AliRun.h>
+#include <AliMagF.h>
+
+#include "AliHBTRun.h"
+#include "AliHBTEvent.h"
+#include "AliHBTParticle.h"
+#include "AliHBTParticleCut.h"
+
+
+AliHBTReaderInternal nnn;
+
+ClassImp(AliHBTReaderInternal)
+/********************************************************************/
+
+AliHBTReaderInternal::AliHBTReaderInternal()
+{
+  fParticles = 0x0; 
+  fTracks = 0x0;
+  fIsRead = kFALSE;
+}
+/********************************************************************/
+
+AliHBTReaderInternal::AliHBTReaderInternal(const char *filename):fFileName(filename)
+{ 
+ fParticles = new AliHBTRun();
+ fTracks    = new AliHBTRun();
+ fIsRead = kFALSE;
+}
+/********************************************************************/
+AliHBTReaderInternal::AliHBTReaderInternal(TObjArray* dirs, const char *filename):
+  AliHBTReader(dirs),fFileName(filename)
+{ 
+ fParticles = new AliHBTRun();
+ fTracks    = new AliHBTRun();
+ fIsRead = kFALSE;
+}
+AliHBTReaderInternal::~AliHBTReaderInternal()
+ {
+ //desctructor
+   delete fParticles;
+   delete fTracks;
+ }
+/********************************************************************/
+AliHBTEvent* AliHBTReaderInternal::GetParticleEvent(Int_t n)
+ {
+ //returns Nth event with simulated particles
+   if (!fIsRead) 
+    if(Read(fParticles,fTracks))
+     {
+       Error("GetParticleEvent","Error in reading");
+       return 0x0;
+     }
+   return fParticles->GetEvent(n);
+ }
+/********************************************************************/
+AliHBTEvent* AliHBTReaderInternal::GetTrackEvent(Int_t n)
+ {
+ //returns Nth event with reconstructed tracks
+   if (!fIsRead) 
+    if(Read(fParticles,fTracks))
+     {
+       Error("GetTrackEvent","Error in reading");
+       return 0x0;
+     }
+   return fTracks->GetEvent(n);
+ }
+/********************************************************************/
+
+Int_t AliHBTReaderInternal::GetNumberOfPartEvents()
+ {
+ //returns number of events of particles
+   if (!fIsRead) 
+    if ( Read(fParticles,fTracks))
+     {
+       Error("GetNumberOfPartEvents","Error in reading");
+       return 0;
+     }
+   return fParticles->GetNumberOfEvents();
+ }
+
+/********************************************************************/
+Int_t AliHBTReaderInternal::GetNumberOfTrackEvents()
+ {
+ //returns number of events of tracks
+  if (!fIsRead)
+    if(Read(fParticles,fTracks))
+     {
+       Error("GetNumberOfTrackEvents","Error in reading");
+       return 0;
+     }
+  return fTracks->GetNumberOfEvents();
+ }
+/********************************************************************/
+
+
+Int_t AliHBTReaderInternal::Read(AliHBTRun* particles, AliHBTRun *tracks)
+ {
+ //reads data and puts put to the particles and tracks objects
+ //reurns 0 if everything is OK
+ //
+  cout<<"AliHBTReaderInternal::Read()"<<endl;
+  Int_t i; //iterator and some temprary values
+  Int_t Nevents = 0;
+  TFile *aFile;//file with tracks
+  AliHBTParticle* p = 0x0;
+  
+  if (!particles) //check if an object is instatiated
+   {
+     Error("Read"," particles object must instatiated before passing it to the reader");
+   }
+  if (!tracks)  //check if an object is instatiated
+   {
+     Error("Read"," tracks object must instatiated before passing it to the reader");
+   }
+  particles->Reset();//clear runs == delete all old events
+  tracks->Reset();
+  Int_t currentdir = 0;
+
+  Int_t Ndirs;
+  if (fDirs) //if array with directories is supplied by user
+   {
+     Ndirs = fDirs->GetEntries(); //get the number if directories
+   }
+  else
+   {
+     Ndirs = 0; //if the array is not supplied read only from current directory
+   }
+
+  TClonesArray* pbuffer = new TClonesArray("AliHBTParticle",15000);
+  TClonesArray* tbuffer = new TClonesArray("AliHBTParticle",15000);
+
+  do  //do{}while; is OK even if 0 dirs specified. In that case we try to read from "./"
+   {
+    
+    if( (i=OpenFile(aFile, currentdir)) )
+     {
+       Error("Read","Exiting due to problems with opening files. Errorcode %d",i);
+       return i;
+     }
+   /***************************/
+   /***************************/
+   /***************************/
+    
+     TTree* tree = (TTree*)aFile->Get("data");
+     if (tree == 0x0)
+      {
+       Error("Read","Can not get the tree");
+       return 1;
+      }
+     
+     TBranch *trackbranch=tree->GetBranch("tracks");//get the branch with tracks
+     if (trackbranch == 0x0) ////check if we got the branch
+       {//if not return with error
+         Warning("Read","Can't find a branch with tracks !\n"); 
+       }
+     else
+      {
+        trackbranch->SetAddress(&tbuffer);
+      }
+
+     TBranch *partbranch=tree->GetBranch("particles");//get the branch with particles
+     if (partbranch == 0x0) ////check if we got the branch
+       {//if not return with error
+         Warning("Read","Can't find a branch with particles !\n"); 
+       }
+     else
+      {
+        partbranch->SetAddress(&pbuffer);
+      }
+     
+     Nevents = (Int_t)tree->GetEntries();
+     cout<<"________________________________________________________\n";
+     cout<<"Found "<<Nevents<<" event(s) in directory "<<GetDirName(currentdir)<<endl;
+     
+     for (Int_t currentEvent =0; currentEvent<Nevents;currentEvent++)
+       {
+         tree->GetEvent(currentEvent);
+         if (partbranch)
+          {
+            for(i = 0; i < pbuffer->GetEntries(); i++)
+             {
+               p = dynamic_cast<AliHBTParticle*>(pbuffer->At(i));
+               if(p == 0x0) continue; //if returned pointer is NULL
+               if(p->GetPDG() == 0x0) continue; //if particle has crezy PDG code (not known to our database)
+               if(Pass(p)) continue; //check if we are intersted with particles of this type 
+                                                   //if not take next partilce
+               AliHBTParticle* part = new AliHBTParticle(*p);
+               particles->AddParticle(currentEvent,part);//put track and particle on the run
+             }
+            cout<<"Read: "<<particles->GetNumberOfParticlesInEvent(currentEvent)<<" particles  ";
+          }
+         else cout<<"Read: 0 particles  ";
+         
+         if (trackbranch)
+          {
+            for(i = 0; i < tbuffer->GetEntries(); i++)
+             {
+               p = dynamic_cast<AliHBTParticle*>(tbuffer->At(i));
+               if(p == 0x0) continue; //if returned pointer is NULL
+               if(p->GetPDG() == 0x0) continue; //if particle has crezy PDG code (not known to our database)
+               if(Pass(p)) continue; //check if we are intersted with particles of this type 
+                                                   //if not take next partilce
+               AliHBTParticle* part = new AliHBTParticle(*p);
+               tracks->AddParticle(currentEvent,part);//put track and particle on the run
+             }
+            cout<<tracks->GetNumberOfParticlesInEvent(currentEvent)<<" tracks"<<endl;
+          }
+         else cout<<" 0 tracks"<<endl;
+
+         
+
+       }
+    
+
+   /***************************/
+   /***************************/
+   /***************************/
+   currentdir++;
+   aFile->Close();
+   aFile = 0x0;
+   }while(currentdir < Ndirs);
+
+  fIsRead = kTRUE;
+  return 0;
+}
+
+/********************************************************************/
+
+Int_t AliHBTReaderInternal::OpenFile(TFile*& aFile,Int_t event)
+{
+
+   const TString& dirname = GetDirName(event); 
+   if (dirname == "")
+    {
+      Error("OpenFile","Can not get directory name");
+      return 4;
+    }
+   
+   TString filename = dirname +"/"+ fFileName;
+   aFile = TFile::Open(filename.Data());
+   if ( aFile  == 0x0 ) 
+     {
+       Error("OpenFiles","Can't open file with tacks named %s",filename.Data());
+       return 1;
+     }
+   if (!aFile->IsOpen())
+     {
+       Error("OpenFiles","Can't open file with tacks named %s",filename.Data());
+       return 1;
+     }
+   return 0; 
+}
+
+
+
+
+Int_t AliHBTReaderInternal::Write(AliHBTReader* reader,const char* outfile)
+ {
+  //reads tracks from runs and writes them to file
+    Int_t i,j;
+  
+  
+  TFile *histoOutput = TFile::Open(outfile,"recreate");
+  
+  if (!histoOutput->IsOpen())
+   {
+     cout<<"File is not opened"<<endl;
+     return 1;
+   }
+    
+
+  TTree *tracktree = new TTree("data","Tree with tracks");
+
+  TClonesArray* pbuffer = new TClonesArray("AliHBTParticle",15000);
+  TClonesArray* tbuffer = new TClonesArray("AliHBTParticle",15000);
+  tbuffer->SetOwner();
+  pbuffer->SetOwner();
+
+  TClonesArray &particles = *pbuffer;
+  TClonesArray &tracks = *tbuffer;
+    
+  TString name("Tracks");
+  
+  Int_t NT = reader->GetNumberOfTrackEvents();
+  Int_t NP = reader->GetNumberOfPartEvents();
+  
+  Bool_t trck = (NT > 0) ? kTRUE : kFALSE;
+  Bool_t part = (NP > 0) ? kTRUE : kFALSE;
+
+  TBranch *trackbranch = 0x0, *partbranch = 0x0;
+  
+  
+  if (trck) trackbranch = tracktree->Branch("tracks","TClonesArray",&tbuffer);
+  if (part) partbranch = tracktree->Branch("particles","TClonesArray",&pbuffer);
+
+
+  
+  if ( (trck) && (part) && (NP != NT))
+   {
+     cerr<<"Warning number of track and particle events is different"<<endl;
+   }
+  
+  Int_t N;
+  if (NT >= NP ) N = NT; else N = NP;
+
+  for ( i =0;i< N; i++)
+    {
+      if (trck && (i<=NT))
+       {
+         AliHBTEvent* trackev = reader->GetTrackEvent(i);
+         for ( j = 0; j< trackev->GetNumberOfParticles();j++)
+          {
+            cout<<j<<"\r";
+           new (tracks[j]) AliHBTParticle(*(trackev->GetParticle(j)));
+          }
+
+       }
+      cout<<endl;
+      
+      if (part && (i<=NP))
+       {
+        cout<<"Jeszce zyje"<<endl;
+        AliHBTEvent* partev = reader->GetParticleEvent(i);
+        cout<<"Dupa 2"<<endl;
+        for ( j = 0; j< partev->GetNumberOfParticles();j++)
+         {
+           cout<<j<<"\r";
+           new (particles[j]) AliHBTParticle(*(partev->GetParticle(j)));
+         }
+       cout<<endl;
+       cout<<"Dupa 3"<<endl;
+       
+       }
+
+      cout<<"Dupa 4"<<endl;
+      histoOutput->cd();
+      tracktree->Fill();
+      cout<<"Dupa 40"<<endl;
+      tbuffer->Delete();
+      pbuffer->Delete();
+
+     }
+
+  
+  
+  histoOutput->cd();
+  cout<<"Dupa 5"<<endl;
+  tracktree->Write(0,TObject::kOverwrite);
+  cout<<"Dupa 6"<<endl;
+  histoOutput->Close();
+
+  return 0;
+ }
diff --git a/HBTAN/AliHBTReaderInternal.h b/HBTAN/AliHBTReaderInternal.h
new file mode 100644 (file)
index 0000000..448c520
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef ALIHBTREADERINTERNAL_H
+#define ALIHBTREADERINTERNAL_H
+
+#include "AliHBTReader.h"
+
+//Multi file reader for Internal Data Format
+//
+//This reader reads data created by
+//                  
+//Piotr.Skowronski@cern.ch
+//more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html
+
+
+#include <TString.h>
+class TFile;
+
+class AliHBTReaderInternal: public AliHBTReader
+{
+  public:
+    AliHBTReaderInternal();
+    AliHBTReaderInternal(const char *filename);
+    AliHBTReaderInternal(TObjArray* dirs, const char *filename);
+    virtual ~AliHBTReaderInternal();
+    
+    Int_t Read(AliHBTRun* particles, AliHBTRun *tracks);//reads tracks and particles and puts them in runs
+    static Int_t Write(AliHBTReader* reader,const char* outfile = "data.root");//reads tracks from runs and writes them to file
+    
+    AliHBTEvent* GetParticleEvent(Int_t);//returns pointer to event with particles
+    AliHBTEvent* GetTrackEvent(Int_t);//returns pointer to event with particles 
+    Int_t GetNumberOfPartEvents();//returns number of particle events
+    Int_t GetNumberOfTrackEvents();//returns number of track events
+    
+  protected:
+    AliHBTRun* fParticles; //!simulated particles
+    AliHBTRun* fTracks; //!reconstructed tracks (particles)
+    Bool_t     fIsRead;//!flag indicating if the data are already read    
+    TString    fFileName;//name of the file with tracks
+
+    Int_t OpenFile(TFile*& aFile,Int_t event);//opens file to be read for given event 
+
+ public:
+  ClassDef(AliHBTReaderInternal,1)
+};
+#endif 
index 4cc934cefac6e765dd9f0daf67232953ba41f30c..c558da8f2f9e28002c4ef9c5caa85cf6bc319ddf 100644 (file)
@@ -55,6 +55,7 @@
 #pragma link C++ class AliHBTReaderITSv2+;
 #pragma link C++ class AliHBTReaderPPprod+;
 #pragma link C++ class AliHBTReaderKineTree+;
+#pragma link C++ class AliHBTReaderInternal+;
 
 #pragma link C++ class AliHBTQInvCorrelFctn+;
 
 #pragma link C++ class AliHBTTwoTrackEffFctn+;
 #pragma link C++ class AliHBTTwoTrackEffFctn3D+;
 
-//#pragma link C++ class Xqinv+;
-//#pragma link C++ class Xqout+;
-//#pragma link C++ class Xqside+;
-//#pragma link C++ class Xqlong+;
-//#pragma link C++ class XqinvDiff+;
-
 #endif
index f6407464df4b44b6927b7e8952bb13b822e0610e..10ce137ad3aa05e95e170a0a838985c5c4b37be4 100644 (file)
@@ -19,7 +19,7 @@ SRCS          = AliHBTAnalysis.cxx AliHBTFunction.cxx \
                 AliHBTReader.cxx AliHBTReaderTPC.cxx\
                 AliHBTQResolutionFctns.cxx AliHBTReaderPPprod.cxx\
                AliHBTReaderITSv1.cxx AliHBTReaderITSv2.cxx\
-               AliHBTReaderKineTree.cxx\
+               AliHBTReaderKineTree.cxx AliHBTReaderInternal.cxx\
                AliHBTTwoTrackEffFctn.cxx
 
 # Fortran sources
index 15e1eb59e8aee5f30608211d8a54b15a7c3b6b86..6e3ae1887f856fca3f5023c0099be6ebbfad6f4e 100644 (file)
@@ -47,7 +47,8 @@ void hbtanalysis(Option_t* datatype, Option_t* processopt="TracksAndParticles",
   Int_t TPC = strcmp(datatype,"TPC");
   Int_t ITSv1 = strcmp(datatype,"ITSv1");
   Int_t ITSv2 = strcmp(datatype,"ITSv2");
-
+  Int_t intern = strcmp(datatype,"Intern");
+  
   if(!kine)
    {
     reader = new AliHBTReaderKineTree();
@@ -65,6 +66,10 @@ void hbtanalysis(Option_t* datatype, Option_t* processopt="TracksAndParticles",
    {
     reader = new AliHBTReaderITSv2();
    }
+  else if(!intern)
+   {
+    reader = new AliHBTReaderInternal("Kine.sum.root");
+   }
   else
    {
     cerr<<"Option "<<datatype<<"  not recognized. Exiting"<<endl;
@@ -78,7 +83,6 @@ void hbtanalysis(Option_t* datatype, Option_t* processopt="TracksAndParticles",
      dirs = new TObjArray(last-first+1);
      for (Int_t i = first; i<=last; i++)
       {
-       if(i == 24) continue;
         sprintf(buff,"%s/%s/%s/%d",basedir,field,serie,i);
         TObjString *odir= new TObjString(buff);
         dirs->Add(odir);
@@ -107,11 +111,59 @@ void hbtanalysis(Option_t* datatype, Option_t* processopt="TracksAndParticles",
   analysis->AddTrackFunction(qinvcfT);
   analysis->AddParticleFunction(qinvcfP);
   
-  analysis->Process(processopt);
   
   qinvcfP->Rename("qinvcfP","Particle (simulated) Qinv CF \\pi^{+} \\pi^{+}");
   qinvcfT->Rename("qinvcfT","Track (recontructed) Qinv CF \\pi^{+} \\pi^{+}");
+  
+  AliHBTQOutCMSLCCorrelFctn* qoutP = new AliHBTQOutCMSLCCorrelFctn();
+  qoutP->Rename("qoutP","Particle (simulated) Q_{out} CF \\pi^{+} \\pi^{+}");
+  AliHBTQOutCMSLCCorrelFctn* qoutT = new AliHBTQOutCMSLCCorrelFctn(); 
+  qoutT->Rename("qoutT","Track (recontructed) Q_{out} CF \\pi^{+} \\pi^{+}");
+
+  AliHBTPairCut *outPairCut = new AliHBTPairCut();
+  outPairCut->SetQOutCMSLRange(0.0,0.15);
+  outPairCut->SetQSideCMSLRange(0.0,0.02);
+  outPairCut->SetQLongCMSLRange(0.0,0.02);
+  qoutP->SetPairCut(outPairCut);
+  qoutT->SetPairCut(outPairCut);
+  
+  AliHBTQSideCMSLCCorrelFctn* qsideP = new AliHBTQSideCMSLCCorrelFctn(); 
+  qsideP->Rename("qsideP","Particle (simulated) Q_{side} CF \\pi^{+} \\pi^{+}");
+  AliHBTQSideCMSLCCorrelFctn* qsideT = new AliHBTQSideCMSLCCorrelFctn(); 
+  qsideT->Rename("qsideT","Track (recontructed) Q_{side} CF \\pi^{+} \\pi^{+}");
+
+  AliHBTPairCut *sidePairCut = new AliHBTPairCut();
+  sidePairCut->SetQOutCMSLRange(0.0,0.02);
+  sidePairCut->SetQSideCMSLRange(0.0,0.15);
+  sidePairCut->SetQLongCMSLRange(0.0,0.02);
+  qsideP->SetPairCut(sidePairCut);
+  qsideT->SetPairCut(sidePairCut);
 
+    
+  AliHBTQLongCMSLCCorrelFctn* qlongP = new AliHBTQLongCMSLCCorrelFctn(); 
+  qlongP->Rename("qlongP","Particle (simulated) Q_{long} CF \\pi^{+} \\pi^{+}");
+  AliHBTQLongCMSLCCorrelFctn* qlongT = new AliHBTQLongCMSLCCorrelFctn(); 
+  qlongT->Rename("qlongT","Track (recontructed) Q_{long} CF \\pi^{+} \\pi^{+}");
+
+  AliHBTPairCut *longPairCut = new AliHBTPairCut();
+  longPairCut->SetQOutCMSLRange(0.0,0.02);
+  longPairCut->SetQSideCMSLRange(0.0,0.02);
+  longPairCut->SetQLongCMSLRange(0.0,0.15);
+  qlongP->SetPairCut(longPairCut);
+  qlongT->SetPairCut(longPairCut);
+
+  analysis->AddTrackFunction(qoutP);
+  analysis->AddParticleFunction(qoutT);
+  
+  analysis->AddTrackFunction(qsideP);
+  analysis->AddParticleFunction(qsideT);
+  
+  analysis->AddTrackFunction(qlongT);
+  analysis->AddParticleFunction(qlongT);
+  
+
+  analysis->Process(processopt);
+  
   TFile histoOutput(outfile,"recreate"); 
   analysis->WriteFunctions();
   histoOutput.Close();
index eeae41c79fdda6febcf0b438e27c5f276416619e..fff76be219c2672c96068ad3828ecbeca745e830 100644 (file)
@@ -4,8 +4,9 @@ AliHBTCorrelFctn.cxx  AliHBTPairCut.cxx      AliHBTReader.cxx            AliHBTR
 AliHBTEvent.cxx       AliHBTParticle.cxx     AliHBTRun.cxx\
 AliHBTFunction.cxx    AliHBTParticleCut.cxx  \
 AliHBTReaderITSv1.cxx AliHBTReaderITSv2.cxx AliHBTReaderKineTree.cxx\
-AliHBTTwoTrackEffFctn.cxx
+AliHBTTwoTrackEffFctn.cxx AliHBTReaderInternal.cxx
 
+FSRCS   = FsiTools.F  FsiWeightLednicky2.F
 
 HDRS:= $(SRCS:.cxx=.h)