]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/TPCbase/AliTPCPreprocessorOnline.cxx
doxy: TPC/TPCbase converted
[u/mrichter/AliRoot.git] / TPC / TPCbase / 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
7d855b04 17/// \class AliTPCPreprocessorOnline
18/// \brief Preprocessor class for HLT and DAQ
19///
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//
37// ROOT includes
7b1c94fc 38//
39#include <TObject.h>
40#include <iostream>
41#include <TString.h>
42#include "TMap.h"
43#include "TObjArray.h"
44#include "TObjString.h"
45#include "TIterator.h"
46
47
48//
49// AliRoot includes
50//
51#include "AliTPCCalPad.h"
52#include "AliTPCCalROC.h"
53#include "AliTPCCalibViewer.h"
54#include "AliTPCPreprocessorOnline.h"
55#include <fstream>
56
57
58
7d855b04 59/// \cond CLASSIMP
7b1c94fc 60ClassImp(AliTPCPreprocessorOnline)
7d855b04 61/// \endcond
7b1c94fc 62
63AliTPCPreprocessorOnline::AliTPCPreprocessorOnline():TObject(), fMap(0)
64{
65 //
66 // Default constructor
67 //
68 fMap = new TMap();
69
70}
71
72//_____________________________________________________________________________
73AliTPCPreprocessorOnline::AliTPCPreprocessorOnline(const AliTPCPreprocessorOnline &c):TObject(c), fMap(0)
74{
7d855b04 75 /// dummy AliTPCPreprocessorOnline copy constructor
76 /// not yet working!!!
77
7b1c94fc 78 fMap = c.fMap;
79 printf("AliTPCPreprocessorOnline's copy constructor called, NOT WORKING!!!\n");
80}
81
82//_____________________________________________________________________________
83AliTPCPreprocessorOnline::AliTPCPreprocessorOnline(TMap *map):TObject(), fMap(0)
84{
7d855b04 85 /// Constructor to "copy" the AliTPCPreprocessorOnline
86
7b1c94fc 87 fMap = map;
88}
89
90
91//____________________________________________________________________________
92AliTPCPreprocessorOnline & AliTPCPreprocessorOnline::operator =(const AliTPCPreprocessorOnline & param){
7d855b04 93 /// assignment operator - dummy
94 /// not yet working!!!
95
04420071 96 if (this == &param) return (*this);
97
7b1c94fc 98 fMap = param.fMap;
99 std::cout << "AliTPCPreprocessorOnline's assignment operator called, NOT WORKING!!!" << std::endl;
100 return (*this);
101}
102
103
104//_____________________________________________________________________________
105AliTPCPreprocessorOnline::~AliTPCPreprocessorOnline()
106{
7d855b04 107 /// AliTPCPreprocessorOnline destructor
108
7b1c94fc 109 printf("AliTPCPreprocessorOnline's destructor called. \n");
110 fMap->DeleteValues();
111 delete fMap;
112}
113
114
115
116void AliTPCPreprocessorOnline::AddComponent(TObject *obj) {
7d855b04 117 /// Add components form HLT or DAQ here
118 /// The components are either AliTPCCalPads or AliTPCCalROCs
119 /// other to be defined
120 ///
121 /// As from HLT they will come ROC wise, they have to be set together to one AliTPCCalPad here
122 /// Then they are added to the Calibration Tree
123 /// This calibration tree will be written by AliTPCCalibViewer::MakeTree, once you call ::DumpToFile(fileName)
124 ///
125 /// To distinguish, what kind of component is added, there is a Naming-Convention:
126 /// The normal, already definded naming-Convention for AliTPCCalPads <PadName>
127 /// <padName>_ROC<ROC_Number> for example: "CEQmean_ROC34"
128 ///
129 /// Get name of obj
130 /// Check, if it ends with "_ROC<Int_t>" / check, if it contains "ROC"
131 /// If it contains "ROC", find out, to which calibration CalPad it belongs -> Parse first part of the name
132 /// Get the corsponding AliTPCCalPad / Make a new AliTPCCalPad
133 /// Set "_ROC<Int_t>" to zero /? delete it -> Set the new values, out of obj
134
135
7b1c94fc 136 // printf(" ****** AliTPCPreprocessorOnline::AddComponent ****** \n");
5426880e 137 if (!obj) return;
7b1c94fc 138 TString objName = obj->GetName();
7d855b04 139
7b1c94fc 140 // Add a whole AliTPCCalPad to the list
141 if (TString(obj->ClassName()) == "AliTPCCalPad") {
142 // printf("AliTPCCalPad found\n");
143 AliTPCCalPad *calPad = (AliTPCCalPad*)obj;
144 TObject *listObj = fMap->GetValue(calPad->GetName());
145 if (listObj == 0) {
146 // current data not yet written to the list, write it to the list
147 fMap->Add(new TObjString(calPad->GetName()), calPad);
148 return;
149 }
150 // current data already present
7d855b04 151 if (TString(listObj->ClassName()) != "AliTPCCalPad")
7b1c94fc 152 Error("AddComponent", "Mismatch in internal list: '%s' is no AliTPCCalPad. \n", listObj->ClassName());
153 AliTPCCalPad *listCalPad = (AliTPCCalPad*)listObj;
154 listCalPad->Add(listCalPad, -1); // reset the current CalPad
155 listCalPad->Add(calPad);
156 return;
157 }
7d855b04 158
7b1c94fc 159 if (TString(obj->ClassName()) == "AliTPCCalROC") {
160 // printf("AliTPCCalROC found\n");
161 if (! objName.Contains("_ROC"))
162 Warning("AddComponent", "Uncomplete object name: '%s' is missing _ROC<ROC_number>\n", objName.Data());
163 TObjArray *stokens = objName.Tokenize("_ROC");
7d855b04 164 TString rocNumber("");
7b1c94fc 165 if (stokens->GetEntriesFast()>1) rocNumber = ((TObjString*)stokens->At(1))->GetString();
09d5920f 166 delete stokens;
7b1c94fc 167 Int_t iroc = -1;
168 if (rocNumber.IsAlnum()) iroc = rocNumber.Atoi();
7d855b04 169
7b1c94fc 170 // Extract CalPad Name:
171 TString removeString("_ROC");
172 removeString += rocNumber;
173 objName.ReplaceAll(removeString, ""); // Remove "_ROC<number>" from the end
7d855b04 174
7b1c94fc 175 // objName is cleaned and can now be used to extract the coresponding CalPad from the list
176 TObject *listObj = fMap->GetValue(objName.Data());
177 AliTPCCalROC *calROC = (AliTPCCalROC*)obj;
178 if (iroc == -1) iroc = calROC->GetSector();
7d855b04 179 if (iroc != (Int_t)calROC->GetSector())
7b1c94fc 180 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);
181 calROC->SetNameTitle(objName.Data(), objName.Data());
182 if (listObj == 0) {
183 // current data not yet written to the list, write it to the list
184 AliTPCCalPad *calPad = new AliTPCCalPad(objName.Data(), objName.Data());
185 calPad->SetCalROC(calROC, iroc);
186 fMap->Add(new TObjString(objName.Data()), calPad);
187 return;
188 }
189 // current data already present
7d855b04 190 if (TString(listObj->ClassName()) != "AliTPCCalPad")
7b1c94fc 191 Error("AddComponent", "Mismatch in internal list: '%s' is no AliTPCCalPad \n", listObj->ClassName());
192 AliTPCCalPad *listCalPad = (AliTPCCalPad*)listObj;
193 listCalPad->SetCalROC(calROC, iroc);
194 return;
7d855b04 195
196
7b1c94fc 197 }
7d855b04 198
7b1c94fc 199 Warning("AddComponent", "Unknown calibration object '%s', skipped.\n", obj->ClassName());
7d855b04 200
7b1c94fc 201 return;
7d855b04 202
203
7b1c94fc 204}
205
206
207
208void AliTPCPreprocessorOnline::DumpToFile(const char* fileName){
7d855b04 209 /// Function to dump the tree to file
210 /// A TObjArray is created out of the TMap, which is passed to
211 /// AliTPCCalibViewer::MakeTree(...)
212
7b1c94fc 213 printf("AliTPCPreprocessorOnline::DumpToFile\n");
214 TObjArray *listOfCalPads = new TObjArray();
215 TIterator *iterator = fMap->MakeIterator();
216 AliTPCCalPad *calPad = 0x0;
217// while ((calibTracks = (AliTPCcalibTracks*)listIterator->Next()) ){
f3a5d03b 218 TObject * obj=0;
219 // while (( calPad = (AliTPCCalPad*)fMap->GetValue(iterator->Next()) )) {
220 while ( ( obj = iterator->Next()) ) {
221 calPad = (AliTPCCalPad*)fMap->GetValue(obj);
7b1c94fc 222 if (!calPad) continue;
223 calPad = (AliTPCCalPad*)calPad;
224 printf("adding the following element to the TObjList: %s \n", calPad->GetName());
225 printf("It's type:: %s \n", calPad->ClassName());
226 calPad->Print();
227 listOfCalPads->Add(calPad);
228 }
229 printf("writing the tree... \n");
258cd111 230 // AliTPCCalibViewer::MakeTree(fileName, listOfCalPads, "$ALICE_ROOT/TPC/Calib/MapCalibrationObjects.root");
231 AliTPCCalibViewer::MakeTree(fileName, listOfCalPads, 0);
7d855b04 232
7b1c94fc 233}
234