1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 ////////////////////////////////////////////////////////////////////////////////
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 //
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. //
28 // Internal the AliTPCCalPads are stored in a TMap, they are retrieved by //
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".
36 // The data flow is as follows:
39 <img src="../TPC/doc/dataFlowCalibViewer.png">
44 ////////////////////////////////////////////////////////////////////////////////
53 #include "TObjArray.h"
54 #include "TObjString.h"
55 #include "TIterator.h"
61 #include "AliTPCCalPad.h"
62 #include "AliTPCCalROC.h"
63 #include "AliTPCCalibViewer.h"
64 #include "AliTPCPreprocessorOnline.h"
69 ClassImp(AliTPCPreprocessorOnline)
71 AliTPCPreprocessorOnline::AliTPCPreprocessorOnline():TObject(), fMap(0)
74 // Default constructor
80 //_____________________________________________________________________________
81 AliTPCPreprocessorOnline::AliTPCPreprocessorOnline(const AliTPCPreprocessorOnline &c):TObject(c), fMap(0)
84 // dummy AliTPCPreprocessorOnline copy constructor
88 printf("AliTPCPreprocessorOnline's copy constructor called, NOT WORKING!!!\n");
91 //_____________________________________________________________________________
92 AliTPCPreprocessorOnline::AliTPCPreprocessorOnline(TMap *map):TObject(), fMap(0)
95 // Constructor to "copy" the AliTPCPreprocessorOnline
101 //____________________________________________________________________________
102 AliTPCPreprocessorOnline & AliTPCPreprocessorOnline::operator =(const AliTPCPreprocessorOnline & param){
104 // assignment operator - dummy
105 // not yet working!!!
107 if (this == ¶m) return (*this);
110 std::cout << "AliTPCPreprocessorOnline's assignment operator called, NOT WORKING!!!" << std::endl;
115 //_____________________________________________________________________________
116 AliTPCPreprocessorOnline::~AliTPCPreprocessorOnline()
119 // AliTPCPreprocessorOnline destructor
121 printf("AliTPCPreprocessorOnline's destructor called. \n");
122 fMap->DeleteValues();
128 void AliTPCPreprocessorOnline::AddComponent(TObject *obj) {
130 // Add components form HLT or DAQ here
131 // The components are either AliTPCCalPads or AliTPCCalROCs
132 // other to be defined
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)
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"
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
151 // printf(" ****** AliTPCPreprocessorOnline::AddComponent ****** \n");
153 TString objName = obj->GetName();
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());
161 // current data not yet written to the list, write it to the list
162 fMap->Add(new TObjString(calPad->GetName()), calPad);
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);
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();
183 if (rocNumber.IsAlnum()) iroc = rocNumber.Atoi();
185 // Extract CalPad Name:
186 TString removeString("_ROC");
187 removeString += rocNumber;
188 objName.ReplaceAll(removeString, ""); // Remove "_ROC<number>" from the end
190 // objName is cleaned and can now be used to extract the coresponding CalPad from the list
191 TObject *listObj = fMap->GetValue(objName.Data());
192 AliTPCCalROC *calROC = (AliTPCCalROC*)obj;
193 if (iroc == -1) iroc = calROC->GetSector();
194 if (iroc != (Int_t)calROC->GetSector())
195 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);
196 calROC->SetNameTitle(objName.Data(), objName.Data());
198 // current data not yet written to the list, write it to the list
199 AliTPCCalPad *calPad = new AliTPCCalPad(objName.Data(), objName.Data());
200 calPad->SetCalROC(calROC, iroc);
201 fMap->Add(new TObjString(objName.Data()), calPad);
204 // current data already present
205 if (TString(listObj->ClassName()) != "AliTPCCalPad")
206 Error("AddComponent", "Mismatch in internal list: '%s' is no AliTPCCalPad \n", listObj->ClassName());
207 AliTPCCalPad *listCalPad = (AliTPCCalPad*)listObj;
208 listCalPad->SetCalROC(calROC, iroc);
214 Warning("AddComponent", "Unknown calibration object '%s', skipped.\n", obj->ClassName());
223 void AliTPCPreprocessorOnline::DumpToFile(const char* fileName){
225 // Function to dump the tree to file
226 // A TObjArray is created out of the TMap, which is passed to
227 // AliTPCCalibViewer::MakeTree(...)
230 printf("AliTPCPreprocessorOnline::DumpToFile\n");
231 TObjArray *listOfCalPads = new TObjArray();
232 TIterator *iterator = fMap->MakeIterator();
233 AliTPCCalPad *calPad = 0x0;
234 // while ((calibTracks = (AliTPCcalibTracks*)listIterator->Next()) ){
236 // while (( calPad = (AliTPCCalPad*)fMap->GetValue(iterator->Next()) )) {
237 while ( ( obj = iterator->Next()) ) {
238 calPad = (AliTPCCalPad*)fMap->GetValue(obj);
239 if (!calPad) continue;
240 calPad = (AliTPCCalPad*)calPad;
241 printf("adding the following element to the TObjList: %s \n", calPad->GetName());
242 printf("It's type:: %s \n", calPad->ClassName());
244 listOfCalPads->Add(calPad);
246 printf("writing the tree... \n");
247 // AliTPCCalibViewer::MakeTree(fileName, listOfCalPads, "$ALICE_ROOT/TPC/Calib/MapCalibrationObjects.root");
248 AliTPCCalibViewer::MakeTree(fileName, listOfCalPads, 0);