.so cleanup: removed from gSystem->Load()
[u/mrichter/AliRoot.git] / HLT / TPCLib / macros / dumpTPCDigits.C
CommitLineData
c5123824 1// $Id$
2
3//**************************************************************************
4//* This file is property of and copyright by the ALICE HLT Project *
5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
7//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8//* for The ALICE HLT Project. *
9//* *
10//* Permission to use, copy, modify and distribute this software and its *
11//* documentation strictly for non-commercial purposes is hereby granted *
12//* without fee, provided that the above copyright notice appears in all *
13//* copies and that both the copyright notice and this permission notice *
14//* appear in the supporting documentation. The authors make no claims *
15//* about the suitability of this software for any purpose. It is *
16//* provided "as is" without express or implied warranty. *
17//**************************************************************************
18
19/**
20 * @file dumpTPCDigits.C
21 * @author Matthias.Richter@ift.uib.no
22 * @date
23 * @brief Convert TPC digit info to ascii and print to stdout.
24 *
25 * The macro reads the simulated TPC digits from the RunLoader and
26 * prints the digit info to stout.
27 *
28 * aliroot -b -q dumpTPCDigits.C | tee digits.log
29 *
30 * The macro asumes the data to be already simulated.
31 */
32
33#ifndef __CINT__
34#include "TSystem.h"
35#include "TTree.h"
36#include "AliRunLoader.h"
37#include "AliSimDigits.h"
38#endif //__CINT__
39
40int dumpDigits(AliRunLoader* runloader, int event);
41
42int dumpTPCDigits()
43{
44 const char* galice_file="galice.root";
45 TString param=galice_file;
46 param+="?filetype=raw";
47 TFile file(param);
48 if (file.IsZombie()) {
49 cerr << "can not open file " << galice_name << ", skipping test" << endl;
50 return 0;
51 }
52
53 AliRunLoader* rl=AliRunLoader::Open(galice_file);
54 if (!rl) {
55 cerr << "can not open RunLoader" << endl;
56 return -1;
57 }
58
4070f709 59 gSystem->Load("libAliHLTTPC");
c5123824 60
61 dumpDigits(rl, 0);
62
63 return 0;
64}
65
66int dumpDigits(AliRunLoader* runloader, int event)
67{
68 int iResult=0;
69 AliLoader* tpcLoader = runloader->GetLoader("TPCLoader");
70 if(!tpcLoader){
71 cerr << "error: can not get TPC loader" << endl;
72 return -1;
73 }
74
75 runloader->GetEvent(event);
76 tpcLoader->LoadDigits();
77
78 TTree *digitsTree = tpcLoader->TreeD();
79 if(!digitsTree) {
80 cerr << "error: can not get digits tree for event no " << event << endl;
81 return -1;
82 }
83
84 AliSimDigits *digits;
85 digitsTree->GetBranch("Segment")->SetAddress(&digits);
86
87 AliTPCParam *tpcParam;
88 runloader->CdGAFile();
89 tpcParam = (AliTPCParam*)gFile->Get("75x40_100x60_150x60");
90 if(!tpcParam){
91 cerr << "error: can not retrieve parameters" << endl;
92 }
93
94 Int_t iPrintedSlice=-1;
95 Int_t iPrintedPart=-1;
96
97 for(Int_t n=0; n<digitsTree->GetEntries(); n++) {
98 Int_t sector, row; // coordinates of the simualted data
99 Int_t lslice,lrow; // local coordinates
100 digitsTree->GetEvent(n);
101 tpcParam->AdjustSectorRow(digits->GetID(),sector,row);
102 if(!AliHLTTPCTransform::Sector2Slice(lslice,lrow,sector,row)){
103 cerr << "error: conversion of coordinates sector/row " << sector << "/" << row << "failed" << endl;
104 return -1;
105 }
106
107 Int_t part=AliHLTTPCTransform::GetPatch(lrow);
108
109 if (iPrintedSlice!=lslice || iPrintedPart!=part) {
110 iPrintedSlice=lslice;
111 iPrintedPart=part;
112 cout << "====================================================================" << endl;
113 cout << " Slice: " << iPrintedSlice << " Partition: " << iPrintedPart << " digit tree entry " << n << endl;
114 }
115
116 cout << "--------------------------------------------------------------------" << endl;
117 cout << "Row: " << lrow << endl;
118
119 digits->First();
120 Int_t lasttime=-1;
121 Int_t lastpad=-1;
122 do {
123 Int_t time=digits->CurrentRow();
124 Int_t pad=digits->CurrentColumn();
125 Int_t dig = digits->GetDigit(time,pad);
126 if (lastpad!=pad) {
127 if (lastpad!=-1) cout << " -> " << lasttime << endl;
128 lastpad=pad;
129 cout << "Row: " << lrow << " Pad: " << lastpad << endl;
130 lasttime=-1;
131 }
132 if (lasttime!=time+1 && lasttime!=time-1 ) {
133 if (lasttime!=-1) cout << " -> " << lasttime << endl;
134 cout << " Time " << time << ": ";
135 }
136 lasttime=time;
137 cout << " " << dig;
138 } while (digits->Next());
139 if (lasttime) cout << " -> " << lasttime << endl;
140 }
141}