Line data Source code
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 : /// \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
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 :
59 : /// \cond CLASSIMP
60 24 : ClassImp(AliTPCPreprocessorOnline)
61 : /// \endcond
62 :
63 0 : AliTPCPreprocessorOnline::AliTPCPreprocessorOnline():TObject(), fMap(0)
64 0 : {
65 : //
66 : // Default constructor
67 : //
68 0 : fMap = new TMap();
69 :
70 0 : }
71 :
72 : //_____________________________________________________________________________
73 0 : AliTPCPreprocessorOnline::AliTPCPreprocessorOnline(const AliTPCPreprocessorOnline &c):TObject(c), fMap(0)
74 0 : {
75 : /// dummy AliTPCPreprocessorOnline copy constructor
76 : /// not yet working!!!
77 :
78 0 : fMap = c.fMap;
79 0 : printf("AliTPCPreprocessorOnline's copy constructor called, NOT WORKING!!!\n");
80 0 : }
81 :
82 : //_____________________________________________________________________________
83 0 : AliTPCPreprocessorOnline::AliTPCPreprocessorOnline(TMap *map):TObject(), fMap(0)
84 0 : {
85 : /// Constructor to "copy" the AliTPCPreprocessorOnline
86 :
87 0 : fMap = map;
88 0 : }
89 :
90 :
91 : //____________________________________________________________________________
92 : AliTPCPreprocessorOnline & AliTPCPreprocessorOnline::operator =(const AliTPCPreprocessorOnline & param){
93 : /// assignment operator - dummy
94 : /// not yet working!!!
95 :
96 0 : if (this == ¶m) return (*this);
97 :
98 0 : fMap = param.fMap;
99 0 : std::cout << "AliTPCPreprocessorOnline's assignment operator called, NOT WORKING!!!" << std::endl;
100 0 : return (*this);
101 0 : }
102 :
103 :
104 : //_____________________________________________________________________________
105 : AliTPCPreprocessorOnline::~AliTPCPreprocessorOnline()
106 0 : {
107 : /// AliTPCPreprocessorOnline destructor
108 :
109 0 : printf("AliTPCPreprocessorOnline's destructor called. \n");
110 0 : fMap->DeleteValues();
111 0 : delete fMap;
112 0 : }
113 :
114 :
115 :
116 : void AliTPCPreprocessorOnline::AddComponent(TObject *obj) {
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 :
136 : // printf(" ****** AliTPCPreprocessorOnline::AddComponent ****** \n");
137 0 : if (!obj) return;
138 0 : TString objName = obj->GetName();
139 :
140 : // Add a whole AliTPCCalPad to the list
141 0 : if (TString(obj->ClassName()) == "AliTPCCalPad") {
142 : // printf("AliTPCCalPad found\n");
143 0 : AliTPCCalPad *calPad = (AliTPCCalPad*)obj;
144 0 : TObject *listObj = fMap->GetValue(calPad->GetName());
145 0 : if (listObj == 0) {
146 : // current data not yet written to the list, write it to the list
147 0 : fMap->Add(new TObjString(calPad->GetName()), calPad);
148 0 : return;
149 : }
150 : // current data already present
151 0 : if (TString(listObj->ClassName()) != "AliTPCCalPad")
152 0 : Error("AddComponent", "Mismatch in internal list: '%s' is no AliTPCCalPad. \n", listObj->ClassName());
153 0 : AliTPCCalPad *listCalPad = (AliTPCCalPad*)listObj;
154 0 : listCalPad->Add(listCalPad, -1); // reset the current CalPad
155 0 : listCalPad->Add(calPad);
156 : return;
157 : }
158 :
159 0 : if (TString(obj->ClassName()) == "AliTPCCalROC") {
160 : // printf("AliTPCCalROC found\n");
161 0 : if (! objName.Contains("_ROC"))
162 0 : Warning("AddComponent", "Uncomplete object name: '%s' is missing _ROC<ROC_number>\n", objName.Data());
163 0 : TObjArray *stokens = objName.Tokenize("_ROC");
164 0 : TString rocNumber("");
165 0 : if (stokens->GetEntriesFast()>1) rocNumber = ((TObjString*)stokens->At(1))->GetString();
166 0 : delete stokens;
167 : Int_t iroc = -1;
168 0 : if (rocNumber.IsAlnum()) iroc = rocNumber.Atoi();
169 :
170 : // Extract CalPad Name:
171 0 : TString removeString("_ROC");
172 0 : removeString += rocNumber;
173 0 : objName.ReplaceAll(removeString, ""); // Remove "_ROC<number>" from the end
174 :
175 : // objName is cleaned and can now be used to extract the coresponding CalPad from the list
176 0 : TObject *listObj = fMap->GetValue(objName.Data());
177 0 : AliTPCCalROC *calROC = (AliTPCCalROC*)obj;
178 0 : if (iroc == -1) iroc = calROC->GetSector();
179 0 : if (iroc != (Int_t)calROC->GetSector())
180 0 : 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 0 : calROC->SetNameTitle(objName.Data(), objName.Data());
182 0 : if (listObj == 0) {
183 : // current data not yet written to the list, write it to the list
184 0 : AliTPCCalPad *calPad = new AliTPCCalPad(objName.Data(), objName.Data());
185 0 : calPad->SetCalROC(calROC, iroc);
186 0 : fMap->Add(new TObjString(objName.Data()), calPad);
187 : return;
188 : }
189 : // current data already present
190 0 : if (TString(listObj->ClassName()) != "AliTPCCalPad")
191 0 : Error("AddComponent", "Mismatch in internal list: '%s' is no AliTPCCalPad \n", listObj->ClassName());
192 0 : AliTPCCalPad *listCalPad = (AliTPCCalPad*)listObj;
193 0 : listCalPad->SetCalROC(calROC, iroc);
194 : return;
195 :
196 :
197 0 : }
198 :
199 0 : Warning("AddComponent", "Unknown calibration object '%s', skipped.\n", obj->ClassName());
200 :
201 0 : return;
202 :
203 :
204 0 : }
205 :
206 :
207 :
208 : void AliTPCPreprocessorOnline::DumpToFile(const char* fileName){
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 :
213 0 : printf("AliTPCPreprocessorOnline::DumpToFile\n");
214 0 : TObjArray *listOfCalPads = new TObjArray();
215 0 : TIterator *iterator = fMap->MakeIterator();
216 : AliTPCCalPad *calPad = 0x0;
217 : // while ((calibTracks = (AliTPCcalibTracks*)listIterator->Next()) ){
218 : TObject * obj=0;
219 : // while (( calPad = (AliTPCCalPad*)fMap->GetValue(iterator->Next()) )) {
220 0 : while ( ( obj = iterator->Next()) ) {
221 0 : calPad = (AliTPCCalPad*)fMap->GetValue(obj);
222 0 : if (!calPad) continue;
223 : calPad = (AliTPCCalPad*)calPad;
224 0 : printf("adding the following element to the TObjList: %s \n", calPad->GetName());
225 0 : printf("It's type:: %s \n", calPad->ClassName());
226 0 : calPad->Print();
227 0 : listOfCalPads->Add(calPad);
228 : }
229 0 : printf("writing the tree... \n");
230 : // AliTPCCalibViewer::MakeTree(fileName, listOfCalPads, "$ALICE_ROOT/TPC/Calib/MapCalibrationObjects.root");
231 0 : AliTPCCalibViewer::MakeTree(fileName, listOfCalPads, 0);
232 :
233 0 : }
234 :
|