Example macros for Kr cluster finding
authorkowal2 <kowal2@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 7 Feb 2008 11:38:02 +0000 (11:38 +0000)
committerkowal2 <kowal2@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 7 Feb 2008 11:38:02 +0000 (11:38 +0000)
TPC/FindKrClusters.C [new file with mode: 0644]
TPC/FindKrClustersRaw.C [new file with mode: 0644]

diff --git a/TPC/FindKrClusters.C b/TPC/FindKrClusters.C
new file mode 100644 (file)
index 0000000..6451dca
--- /dev/null
@@ -0,0 +1,125 @@
+/****************************************************************************
+ *           Origin: A.Matyja amatyja@cern.ch                               *
+ ****************************************************************************/
+
+/*
+
+  macro to create array of clusters from TPC digits
+  input files - galice.root 
+                digits.root - file with digits - usualy use link to galice.root
+                           - in splitted mode - neccesary to create link to proper file
+                           
+   output file - TPC.RecPoints.root
+
+
+//  Warning - if cluster file AliTPCclusters.root already exist - macro exit and don't produce anything
+              
+*/
+
+
+#ifndef __CINT__
+#include <iostream.h>
+#include "AliRun.h"
+#include "AliTPCv4.h"
+#include "AliTPCParam.h"
+#include "AliTPCclusterKr.h"
+#include "AliTPCclustererKr.h"
+#include "TFile.h"
+#include "TStopwatch.h"
+#include "TTree.h"
+#endif
+
+Int_t FindKrClusters(){
+
+  AliRunLoader* rl = AliRunLoader::Open("galice.root");
+  if (rl == 0x0) {
+    cerr<<"Can not open session"<<endl;
+    return 1;
+  }
+  
+  AliTPCLoader *tpcl = (AliTPCLoader*)rl->GetLoader("TPCLoader");
+  if (tpcl == 0x0) {
+    cerr<<"Can not get TPC Loader"<<endl;
+    return 1;
+  }
+
+  if (tpcl->LoadDigits()) {
+    cerr<<"Error occured while loading digits"<<endl;
+    return 1;
+  }
+
+  if (rl->LoadgAlice()) {
+    cerr<<"Error occured while LoadgAlice"<<endl;
+    return 1;
+  }
+  
+  gAlice=rl->GetAliRun();
+  if (!gAlice) {
+    cerr<<"Can't get gAlice !\n";
+    return 1;
+  }
+
+  TDirectory *cwd = gDirectory;
+
+  AliTPCv4 *tpc = (AliTPCv4*)gAlice->GetDetector("TPC");
+  Int_t ver = tpc->IsVersion(); 
+  cerr<<"TPC version "<<ver<<" has been found !\n";
+
+  rl->CdGAFile();
+  
+  AliTPCParam *param=(AliTPCParamSR *)gDirectory->Get("75x40_100x60_150x60");
+  if (!param) {cerr<<"TPC parameters have not been found !\n"; return 4;}
+  
+  AliTPCDigitsArray *digarr=new AliTPCDigitsArray;
+  digarr->Setup(param);
+
+  cerr<<"It has begun"<<endl;  
+  TStopwatch timer;
+  timer.Start();
+  cwd->cd();
+  
+  Int_t nevmax=rl->GetNumberOfEvents();//number of events in run
+  for(Int_t nev=0;nev<nevmax /*&& nev<1*/ ;nev++){
+    rl->GetEvent(nev);
+    
+    TTree* input_tree= tpcl->TreeD();//tree with digits
+    if (input_tree == 0x0){
+      cerr << "Can not get TreeD for event " <<nev<<endl;
+      continue;
+    }
+    
+    digarr->ConnectTree(input_tree);
+    
+    TTree *output_tree =tpcl->TreeR();
+    if(output_tree==0x0){
+      tpcl->MakeTree("R");
+      output_tree = tpcl->TreeR();
+      if (output_tree == 0x0){
+       cerr << "Problems with output tree (TreeR) for event "<<nev<<endl;
+       continue;
+      }
+    }
+    
+    cout<<"Processing event "<<nev<<endl;
+
+    //test
+    //cout<<"nentries"<<input_tree->GetEntries();
+
+    AliTPCclustererKr *clusters = new AliTPCclustererKr();
+    clusters->SetParam(param);
+    clusters->SetInput(input_tree);
+    clusters->SetOutput(output_tree);
+    clusters->SetDigArr(digarr);
+    clusters->finderIO();
+
+    tpcl->WriteRecPoints("OVERWRITE");
+  }
+  
+
+  timer.Stop(); timer.Print();
+  
+  delete rl;//cleans everything
+  
+  return 0;
+}
diff --git a/TPC/FindKrClustersRaw.C b/TPC/FindKrClustersRaw.C
new file mode 100644 (file)
index 0000000..7110bd4
--- /dev/null
@@ -0,0 +1,57 @@
+Int_t FindKrClustersRaw(const char *fileName="data.root"){
+
+  //define tree
+  TFile *hfile=new TFile("adc.root","RECREATE","ADC file");
+  // Create a ROOT Tree
+  TTree *mytree = new TTree("Kr","Krypton cluster tree");
+
+
+  AliRawReader *reader = new AliRawReaderRoot(fileName);
+  //AliRawReader *reader = new AliRawReaderDate(fileName);
+  reader->Reset();
+
+  TStopwatch timer;
+  timer.Start();
+
+  AliAltroRawStreamFast* stream = new AliAltroRawStreamFast(reader);
+  stream->SelectRawData("TPC");
+
+  //one general output
+  AliTPCclustererKr *clusters = new AliTPCclustererKr();
+  clusters->SetOutput(mytree);
+  clusters->SetRecoParam(0);
+
+  //only for geometry parameters loading - temporarly
+  AliRunLoader* rl = AliRunLoader::Open("galice.root");
+  AliTPCParam *param=(AliTPCParamSR *)gDirectory->Get("75x40_100x60_150x60");
+  //if (!param) {cerr<<"TPC parameters have not been found !\n"; return 4;}
+  clusters->SetParam(param);
+
+
+  Int_t evtnr=0;
+  while (reader->NextEvent()) {
+    //output for each event
+    //  AliTPCclustererKr *clusters = new AliTPCclustererKr();
+    //  clusters->SetOutput(mytree);
+
+    //if(evtnr++<35)continue;
+    cout<<"Evt = "<<evtnr<<endl;
+    clusters->finderIO(reader);
+    evtnr++;
+
+
+  }
+
+  //mytree->Print();//print rootuple summary 
+  // Save all objects in this file
+  hfile->Write();
+  // Close the file
+  hfile->Close();
+
+  timer.Stop();
+  timer.Print();
+
+  delete stream;
+
+  return 0;
+}