]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCPreprocessorOnline.cxx
Assign track label pi to the raw digits, to be consitent with other detectors.
[u/mrichter/AliRoot.git] / TPC / AliTPCPreprocessorOnline.cxx
CommitLineData
7b1c94fc 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16
17////////////////////////////////////////////////////////////////////////////////
18// //
19// Preprocessor class for HLT and DAQ //
20// Possible usage: preprocess TPC calibration data //
21// to form needed for online viewing/visualizing TPC calibration data //
22// //
23// On HLT or DAQ AliTPCPreprocessorOnline::AddComponent(...) is called, //
24// whereas ... is either an AliTPCCalPad, or an AliTPCCalROC. //
25// Their names have to be acording the naming convention for AliTPCCalPads //
26// Special for CalROCs: Add '_ROC<ROC_Number>' to the name. //
27// //
28// Internal the AliTPCCalPads are stored in a TMap, they are retrieved by //
29// their name. //
30// //
31// Once enough values are accumulated, call ::DumpToFile(fileName). //
32// A TObjArray is created out of the TMap, which is passed to //
33// AliTPCCalibViewer::MakeTree(...) and the calibratioTree is written //
34// is written to "filenName".
35//
36// The data flow is as follows:
37/*
38Begin_Html
39 <img src="../TPC/doc/dataFlowCalibViewer.png">
40End_Html
41*/
42// //
43// //
44////////////////////////////////////////////////////////////////////////////////
45
46//
47// ROOT includes
48//
49#include <TObject.h>
50#include <iostream>
51#include <TString.h>
52#include "TMap.h"
53#include "TObjArray.h"
54#include "TObjString.h"
55#include "TIterator.h"
56
57
58//
59// AliRoot includes
60//
61#include "AliTPCCalPad.h"
62#include "AliTPCCalROC.h"
63#include "AliTPCCalibViewer.h"
64#include "AliTPCPreprocessorOnline.h"
65#include <fstream>
66
67
68
69ClassImp(AliTPCPreprocessorOnline)
70
71AliTPCPreprocessorOnline::AliTPCPreprocessorOnline():TObject(), fMap(0)
72{
73 //
74 // Default constructor
75 //
76 fMap = new TMap();
77
78}
79
80//_____________________________________________________________________________
81AliTPCPreprocessorOnline::AliTPCPreprocessorOnline(const AliTPCPreprocessorOnline &c):TObject(c), fMap(0)
82{
83 //
84 // dummy AliTPCPreprocessorOnline copy constructor
85 // not yet working!!!
86 //
87 fMap = c.fMap;
88 printf("AliTPCPreprocessorOnline's copy constructor called, NOT WORKING!!!\n");
89}
90
91//_____________________________________________________________________________
92AliTPCPreprocessorOnline::AliTPCPreprocessorOnline(TMap *map):TObject(), fMap(0)
93{
94 //
95 // Constructor to "copy" the AliTPCPreprocessorOnline
96 //
97 fMap = map;
98}
99
100
101//____________________________________________________________________________
102AliTPCPreprocessorOnline & AliTPCPreprocessorOnline::operator =(const AliTPCPreprocessorOnline & param){
103 //
104 // assignment operator - dummy
105 // not yet working!!!
106 //
04420071 107 if (this == &param) return (*this);
108
7b1c94fc 109 fMap = param.fMap;
110 std::cout << "AliTPCPreprocessorOnline's assignment operator called, NOT WORKING!!!" << std::endl;
111 return (*this);
112}
113
114
115//_____________________________________________________________________________
116AliTPCPreprocessorOnline::~AliTPCPreprocessorOnline()
117{
118 //
119 // AliTPCPreprocessorOnline destructor
120 //
121 printf("AliTPCPreprocessorOnline's destructor called. \n");
122 fMap->DeleteValues();
123 delete fMap;
124}
125
126
127
128void AliTPCPreprocessorOnline::AddComponent(TObject *obj) {
129 //
130 // Add components form HLT or DAQ here
131 // The components are either AliTPCCalPads or AliTPCCalROCs
132 // other to be defined
133 //
134 // As from HLT they will come ROC wise, they have to be set together to one AliTPCCalPad here
135 // Then they are added to the Calibration Tree
136 // This calibration tree will be written by AliTPCCalibViewer::MakeTree, once you call ::DumpToFile(fileName)
137 //
138 // To distinguish, what kind of component is added, there is a Naming-Convention:
139 // The normal, already definded naming-Convention for AliTPCCalPads <PadName>
140 // <padName>_ROC<ROC_Number> for example: "CEQmean_ROC34"
141 //
142 //
143 // Get name of obj
144 // Check, if it ends with "_ROC<Int_t>" / check, if it contains "ROC"
145 // If it contains "ROC", find out, to which calibration CalPad it belongs -> Parse first part of the name
146 // Get the corsponding AliTPCCalPad / Make a new AliTPCCalPad
147 // Set "_ROC<Int_t>" to zero /? delete it -> Set the new values, out of obj
148 //
149
150
151 // printf(" ****** AliTPCPreprocessorOnline::AddComponent ****** \n");
5426880e 152 if (!obj) return;
7b1c94fc 153 TString objName = obj->GetName();
154
155 // Add a whole AliTPCCalPad to the list
156 if (TString(obj->ClassName()) == "AliTPCCalPad") {
157 // printf("AliTPCCalPad found\n");
158 AliTPCCalPad *calPad = (AliTPCCalPad*)obj;
159 TObject *listObj = fMap->GetValue(calPad->GetName());
160 if (listObj == 0) {
161 // current data not yet written to the list, write it to the list
162 fMap->Add(new TObjString(calPad->GetName()), calPad);
163 return;
164 }
165 // current data already present
166 if (TString(listObj->ClassName()) != "AliTPCCalPad")
167 Error("AddComponent", "Mismatch in internal list: '%s' is no AliTPCCalPad. \n", listObj->ClassName());
168 AliTPCCalPad *listCalPad = (AliTPCCalPad*)listObj;
169 listCalPad->Add(listCalPad, -1); // reset the current CalPad
170 listCalPad->Add(calPad);
171 return;
172 }
173
174 if (TString(obj->ClassName()) == "AliTPCCalROC") {
175 // printf("AliTPCCalROC found\n");
176 if (! objName.Contains("_ROC"))
177 Warning("AddComponent", "Uncomplete object name: '%s' is missing _ROC<ROC_number>\n", objName.Data());
178 TObjArray *stokens = objName.Tokenize("_ROC");
179 TString rocNumber("");
180 if (stokens->GetEntriesFast()>1) rocNumber = ((TObjString*)stokens->At(1))->GetString();
181 Int_t iroc = -1;
182 if (rocNumber.IsAlnum()) iroc = rocNumber.Atoi();
183
184 // Extract CalPad Name:
185 TString removeString("_ROC");
186 removeString += rocNumber;
187 objName.ReplaceAll(removeString, ""); // Remove "_ROC<number>" from the end
188
189 // objName is cleaned and can now be used to extract the coresponding CalPad from the list
190 TObject *listObj = fMap->GetValue(objName.Data());
191 AliTPCCalROC *calROC = (AliTPCCalROC*)obj;
192 if (iroc == -1) iroc = calROC->GetSector();
193 if (iroc != (Int_t)calROC->GetSector())
194 Warning("AddComponent","Mismatch in ROC_number: ROC has number %i, in its name %i was specified. Treating now as %i. \n", calROC->GetSector(), iroc, iroc);
195 calROC->SetNameTitle(objName.Data(), objName.Data());
196 if (listObj == 0) {
197 // current data not yet written to the list, write it to the list
198 AliTPCCalPad *calPad = new AliTPCCalPad(objName.Data(), objName.Data());
199 calPad->SetCalROC(calROC, iroc);
200 fMap->Add(new TObjString(objName.Data()), calPad);
201 return;
202 }
203 // current data already present
204 if (TString(listObj->ClassName()) != "AliTPCCalPad")
205 Error("AddComponent", "Mismatch in internal list: '%s' is no AliTPCCalPad \n", listObj->ClassName());
206 AliTPCCalPad *listCalPad = (AliTPCCalPad*)listObj;
207 listCalPad->SetCalROC(calROC, iroc);
208 return;
209
210
211 }
212
213 Warning("AddComponent", "Unknown calibration object '%s', skipped.\n", obj->ClassName());
214
215 return;
216
217
218}
219
220
221
222void AliTPCPreprocessorOnline::DumpToFile(const char* fileName){
223 //
224 // Function to dump the tree to file
225 // A TObjArray is created out of the TMap, which is passed to
226 // AliTPCCalibViewer::MakeTree(...)
227 //
228
229 printf("AliTPCPreprocessorOnline::DumpToFile\n");
230 TObjArray *listOfCalPads = new TObjArray();
231 TIterator *iterator = fMap->MakeIterator();
232 AliTPCCalPad *calPad = 0x0;
233// while ((calibTracks = (AliTPCcalibTracks*)listIterator->Next()) ){
f3a5d03b 234 TObject * obj=0;
235 // while (( calPad = (AliTPCCalPad*)fMap->GetValue(iterator->Next()) )) {
236 while ( ( obj = iterator->Next()) ) {
237 calPad = (AliTPCCalPad*)fMap->GetValue(obj);
7b1c94fc 238 if (!calPad) continue;
239 calPad = (AliTPCCalPad*)calPad;
240 printf("adding the following element to the TObjList: %s \n", calPad->GetName());
241 printf("It's type:: %s \n", calPad->ClassName());
242 calPad->Print();
243 listOfCalPads->Add(calPad);
244 }
245 printf("writing the tree... \n");
258cd111 246 // AliTPCCalibViewer::MakeTree(fileName, listOfCalPads, "$ALICE_ROOT/TPC/Calib/MapCalibrationObjects.root");
247 AliTPCCalibViewer::MakeTree(fileName, listOfCalPads, 0);
7b1c94fc 248
249}
250