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!!!
108 std::cout << "AliTPCPreprocessorOnline's assignment operator called, NOT WORKING!!!" << std::endl;
113 //_____________________________________________________________________________
114 AliTPCPreprocessorOnline::~AliTPCPreprocessorOnline()
117 // AliTPCPreprocessorOnline destructor
119 printf("AliTPCPreprocessorOnline's destructor called. \n");
120 fMap->DeleteValues();
126 void AliTPCPreprocessorOnline::AddComponent(TObject *obj) {
128 // Add components form HLT or DAQ here
129 // The components are either AliTPCCalPads or AliTPCCalROCs
130 // other to be defined
132 // As from HLT they will come ROC wise, they have to be set together to one AliTPCCalPad here
133 // Then they are added to the Calibration Tree
134 // This calibration tree will be written by AliTPCCalibViewer::MakeTree, once you call ::DumpToFile(fileName)
136 // To distinguish, what kind of component is added, there is a Naming-Convention:
137 // The normal, already definded naming-Convention for AliTPCCalPads <PadName>
138 // <padName>_ROC<ROC_Number> for example: "CEQmean_ROC34"
142 // Check, if it ends with "_ROC<Int_t>" / check, if it contains "ROC"
143 // If it contains "ROC", find out, to which calibration CalPad it belongs -> Parse first part of the name
144 // Get the corsponding AliTPCCalPad / Make a new AliTPCCalPad
145 // Set "_ROC<Int_t>" to zero /? delete it -> Set the new values, out of obj
149 // printf(" ****** AliTPCPreprocessorOnline::AddComponent ****** \n");
151 TString objName = obj->GetName();
153 // Add a whole AliTPCCalPad to the list
154 if (TString(obj->ClassName()) == "AliTPCCalPad") {
155 // printf("AliTPCCalPad found\n");
156 AliTPCCalPad *calPad = (AliTPCCalPad*)obj;
157 TObject *listObj = fMap->GetValue(calPad->GetName());
159 // current data not yet written to the list, write it to the list
160 fMap->Add(new TObjString(calPad->GetName()), calPad);
163 // current data already present
164 if (TString(listObj->ClassName()) != "AliTPCCalPad")
165 Error("AddComponent", "Mismatch in internal list: '%s' is no AliTPCCalPad. \n", listObj->ClassName());
166 AliTPCCalPad *listCalPad = (AliTPCCalPad*)listObj;
167 listCalPad->Add(listCalPad, -1); // reset the current CalPad
168 listCalPad->Add(calPad);
172 if (TString(obj->ClassName()) == "AliTPCCalROC") {
173 // printf("AliTPCCalROC found\n");
174 if (! objName.Contains("_ROC"))
175 Warning("AddComponent", "Uncomplete object name: '%s' is missing _ROC<ROC_number>\n", objName.Data());
176 TObjArray *stokens = objName.Tokenize("_ROC");
177 TString rocNumber("");
178 if (stokens->GetEntriesFast()>1) rocNumber = ((TObjString*)stokens->At(1))->GetString();
180 if (rocNumber.IsAlnum()) iroc = rocNumber.Atoi();
182 // Extract CalPad Name:
183 TString removeString("_ROC");
184 removeString += rocNumber;
185 objName.ReplaceAll(removeString, ""); // Remove "_ROC<number>" from the end
187 // objName is cleaned and can now be used to extract the coresponding CalPad from the list
188 TObject *listObj = fMap->GetValue(objName.Data());
189 AliTPCCalROC *calROC = (AliTPCCalROC*)obj;
190 if (iroc == -1) iroc = calROC->GetSector();
191 if (iroc != (Int_t)calROC->GetSector())
192 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);
193 calROC->SetNameTitle(objName.Data(), objName.Data());
195 // current data not yet written to the list, write it to the list
196 AliTPCCalPad *calPad = new AliTPCCalPad(objName.Data(), objName.Data());
197 calPad->SetCalROC(calROC, iroc);
198 fMap->Add(new TObjString(objName.Data()), calPad);
201 // current data already present
202 if (TString(listObj->ClassName()) != "AliTPCCalPad")
203 Error("AddComponent", "Mismatch in internal list: '%s' is no AliTPCCalPad \n", listObj->ClassName());
204 AliTPCCalPad *listCalPad = (AliTPCCalPad*)listObj;
205 listCalPad->SetCalROC(calROC, iroc);
211 Warning("AddComponent", "Unknown calibration object '%s', skipped.\n", obj->ClassName());
220 void AliTPCPreprocessorOnline::DumpToFile(const char* fileName){
222 // Function to dump the tree to file
223 // A TObjArray is created out of the TMap, which is passed to
224 // AliTPCCalibViewer::MakeTree(...)
227 printf("AliTPCPreprocessorOnline::DumpToFile\n");
228 TObjArray *listOfCalPads = new TObjArray();
229 TIterator *iterator = fMap->MakeIterator();
230 AliTPCCalPad *calPad = 0x0;
231 // while ((calibTracks = (AliTPCcalibTracks*)listIterator->Next()) ){
233 // while (( calPad = (AliTPCCalPad*)fMap->GetValue(iterator->Next()) )) {
234 while ( ( obj = iterator->Next()) ) {
235 calPad = (AliTPCCalPad*)fMap->GetValue(obj);
236 if (!calPad) continue;
237 calPad = (AliTPCCalPad*)calPad;
238 printf("adding the following element to the TObjList: %s \n", calPad->GetName());
239 printf("It's type:: %s \n", calPad->ClassName());
241 listOfCalPads->Add(calPad);
243 printf("writing the tree... \n");
244 // AliTPCCalibViewer::MakeTree(fileName, listOfCalPads, "$ALICE_ROOT/TPC/Calib/MapCalibrationObjects.root");
245 AliTPCCalibViewer::MakeTree(fileName, listOfCalPads, 0);