]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCFindClusters.C
Restored backward compatibility to use the hits from Dec. 2000 production.
[u/mrichter/AliRoot.git] / TPC / AliTPCFindClusters.C
1 #ifndef __CINT__
2   #include <iostream.h>
3   #include "AliRun.h"
4   #include "AliTPCv1.h"
5   #include "AliTPCv2.h"
6   #include "AliTPCParam.h"
7
8   #include "TFile.h"
9   #include "TStopwatch.h"
10 #endif
11
12 Int_t AliTPCFindClusters(Int_t n=1) {
13    TFile *out=TFile::Open("AliTPCclusters.root","new");
14    if (!out->IsOpen()) {cerr<<"Delete old AliTPCclusters.root !\n"; return 1;}
15    TFile *in=TFile::Open("rfio:galice.root");
16    if (!in->IsOpen()) {cerr<<"Can't open galice.root !\n"; return 2;}
17
18    if (!(gAlice=(AliRun*)in->Get("gAlice"))) {
19      cerr<<"gAlice have not been found on galice.root !\n";
20      return 3;
21    }
22
23    TDirectory *cwd = gDirectory;
24
25    AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC"); 
26    Int_t ver = TPC->IsVersion(); 
27    cerr<<"TPC version "<<ver<<" has been found !\n";
28
29    AliTPCParamSR *dig=(AliTPCParamSR *)in->Get("75x40_100x60");
30    if(dig){
31      cerr<<"2 pad-length geom hits with 3 pad-lengths geom digits\n";
32      delete dig;
33      dig = new AliTPCParamSR();
34    }
35    else
36    {
37      dig=(AliTPCParamSR *)gDirectory->Get("75x40_100x60_150x60");
38    }
39    if (!dig) {cerr<<"TPC parameters have not been found !\n"; return 4;}
40
41    TStopwatch timer;
42
43    switch (ver) {
44    case 1:
45       cerr<<"Making clusters...\n";
46       {
47        AliTPCv1 &tpc=*((AliTPCv1*)TPC);
48        tpc.SetParam(dig); timer.Start(); cwd->cd(); 
49        for(Int_t i=0;i<n;i++){
50          printf("Processing event %d\n",i);
51          gAlice->GetEvent(i);
52          tpc.Hits2Clusters(out,i);
53        } 
54       }
55       break;
56    case 2:
57       cerr<<"Looking for clusters...\n";
58       {
59         // delete gAlice; gAlice=0;
60        AliTPCv2 tpc; 
61        tpc.SetParam(dig); timer.Start(); cwd->cd();  
62        for (Int_t i=0;i<n;i++){
63          printf("Processing event %d\n",i);
64          tpc.Digits2Clusters(out,i);
65          //      AliTPCclusterer::Digits2Clusters(dig, out, i);
66        }
67       }
68       break;
69    default:
70       cerr<<"Invalid TPC version !\n";
71       return 5;
72    }
73
74    timer.Stop(); timer.Print();
75
76    delete gAlice; gAlice=0;
77
78    out->Close();
79
80    in->Close();
81
82    return 0;
83 }