]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCFindClustersMI.C
Updated a bit with:
[u/mrichter/AliRoot.git] / TPC / AliTPCFindClustersMI.C
CommitLineData
1c53abe2 1/****************************************************************************
2 * Origin: M.Ivanov marian.ivanov@cern.ch *
3 ****************************************************************************/
4
5/*
6
7 macro to create array of clusters from TPC digits
8 input files - galice.root
9 digits.root - file with digits - usualy use link to galice.root
10 - in splitted mode - neccesary to create link to proper file
11
12 output file - AliTPCclusters.root
13 - to be used by AliTPCTrackFinderMI.C
14
15 Warning - if cluster file AliTPCclusters.root already exist - macro exit and don't produce anything
16
17
18*/
19
20
21#ifndef __CINT__
22#include <iostream.h>
23#include "AliRun.h"
24#include "AliTPCv1.h"
25#include "AliTPCv2.h"
26#include "AliTPCParam.h"
27#include "AliTPCclustererMI.h"
28#include "TFile.h"
29#include "TStopwatch.h"
30#include "TTree.h"
31#endif
32
33Int_t AliTPCFindClustersMI(Int_t n=1) {
34 TFile *out=TFile::Open("AliTPCclusters.root","new");
35 if (!out->IsOpen()) {cerr<<"Delete old AliTPCclusters.root !\n"; return 1;}
36 TFile *in=TFile::Open("rfio:galice.root");
37 if (!in->IsOpen()) {cerr<<"Can't open galice.root !\n"; return 2;}
38
39 TFile *ind=TFile::Open("rfio:digits.root");
40 if (!ind->IsOpen()) {cerr<<"Can't open digits file !\n"; return 2;}
41
42
43 if (!(gAlice=(AliRun*)in->Get("gAlice"))) {
44 cerr<<"gAlice have not been found on galice.root !\n";
45 return 3;
46 }
47
48 TDirectory *cwd = gDirectory;
49
50 AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");
51 Int_t ver = TPC->IsVersion();
52 cerr<<"TPC version "<<ver<<" has been found !\n";
53
54 AliTPCParam *dig=(AliTPCParam *)in->Get("75x40_100x60_150x60");
55 if (!dig) {cerr<<"TPC parameters have not been found !\n"; return 4;}
56
57 TStopwatch timer;
58
59 switch (ver) {
60 case 1:
61 cerr<<"Making clusters...\n";
62 {
63 AliTPCv1 &tpc=*((AliTPCv1*)TPC);
64 tpc.SetParam(dig); timer.Start(); cwd->cd();
65 for(Int_t i=0;i<n;i++){
66 printf("Processing event %d\n",i);
67 gAlice->GetEvent(i);
68 tpc.Hits2Clusters(out,i);
69 }
70 }
71 break;
72 case 2:
73 cerr<<"Looking for clusters...\n";
74 {
75 // delete gAlice; gAlice=0;
76 AliTPCv2 tpc;
77 tpc.SetParam(dig); timer.Start(); cwd->cd();
78
79
80 for (Int_t i=0;i<n;i++){
81 AliTPCclustererMI clusterer;
82 char dname[100];
83 char cname[100];
84 sprintf(dname,"TreeD_75x40_100x60_150x60_%d",i);
85 sprintf(cname,"TreeC_TPC_%d",i);
86 TTree * input = (TTree*)ind->Get(dname);
87 out->cd();
88 TTree * output = new TTree(cname,cname);
89
90 printf("Processing event %d\n",i);
91 clusterer.SetInput(input);
92 clusterer.SetOutput(output);
93 clusterer.Digits2Clusters(dig, i);
94 //tpc.Digits2Clusters(out,i);
95 // AliTPCclusterer::Digits2Clusters(dig, out, i);
96 }
97 }
98 break;
99 default:
100 cerr<<"Invalid TPC version !\n";
101 return 5;
102 }
103
104 timer.Stop(); timer.Print();
105
106 delete gAlice; gAlice=0;
107
108 out->Close();
109
110 in->Close();
111
112 return 0;
113}