AliRoot Core  3dc7879 (3dc7879)
AliTPCPreprocessorOnline.cxx
Go to the documentation of this file.
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 
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"
55 #include <fstream>
56 
57 
58 
62 
64 {
65  //
66  // Default constructor
67  //
68  fMap = new TMap();
69 
70 }
71 
72 //_____________________________________________________________________________
74 {
77 
78  fMap = c.fMap;
79  printf("AliTPCPreprocessorOnline's copy constructor called, NOT WORKING!!!\n");
80 }
81 
82 //_____________________________________________________________________________
84 {
86 
87  fMap = map;
88 }
89 
90 
91 //____________________________________________________________________________
95 
96  if (this == &param) return (*this);
97 
98  fMap = param.fMap;
99  std::cout << "AliTPCPreprocessorOnline's assignment operator called, NOT WORKING!!!" << std::endl;
100  return (*this);
101 }
102 
103 
104 //_____________________________________________________________________________
106 {
108 
109  printf("AliTPCPreprocessorOnline's destructor called. \n");
110  fMap->DeleteValues();
111  delete fMap;
112 }
113 
114 
115 
134 
135 
136  // printf(" ****** AliTPCPreprocessorOnline::AddComponent ****** \n");
137  if (!obj) return;
138  TString objName = obj->GetName();
139 
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
151  if (TString(listObj->ClassName()) != "AliTPCCalPad")
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  }
158 
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");
164  TString rocNumber("");
165  if (stokens->GetEntriesFast()>1) rocNumber = ((TObjString*)stokens->At(1))->GetString();
166  delete stokens;
167  Int_t iroc = -1;
168  if (rocNumber.IsAlnum()) iroc = rocNumber.Atoi();
169 
170  // Extract CalPad Name:
171  TString removeString("_ROC");
172  removeString += rocNumber;
173  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  TObject *listObj = fMap->GetValue(objName.Data());
177  AliTPCCalROC *calROC = (AliTPCCalROC*)obj;
178  if (iroc == -1) iroc = calROC->GetSector();
179  if (iroc != (Int_t)calROC->GetSector())
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
190  if (TString(listObj->ClassName()) != "AliTPCCalPad")
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;
195 
196 
197  }
198 
199  Warning("AddComponent", "Unknown calibration object '%s', skipped.\n", obj->ClassName());
200 
201  return;
202 
203 
204 }
205 
206 
207 
212 
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()) ){
218  TObject * obj=0;
219  // while (( calPad = (AliTPCCalPad*)fMap->GetValue(iterator->Next()) )) {
220  while ( ( obj = iterator->Next()) ) {
221  calPad = (AliTPCCalPad*)fMap->GetValue(obj);
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");
230  // AliTPCCalibViewer::MakeTree(fileName, listOfCalPads, "$ALICE_ROOT/TPC/Calib/MapCalibrationObjects.root");
231  AliTPCCalibViewer::MakeTree(fileName, listOfCalPads, 0);
232 
233 }
234 
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
#define TObjArray
void SetCalROC(AliTPCCalROC *roc, Int_t sector=-1)
TString fileName(const char *dir, int runNumber, const char *da, int i, const char *type)
void Add(Float_t c1)
TPC calibration base class for one ROC.
Definition: AliTPCCalROC.h:20
static void MakeTree(const char *fileName, TObjArray *array, const char *mapFileName=0, AliTPCCalPad *const outlierPad=0, Float_t ltmFraction=0.9)
AliTPCPreprocessorOnline & operator=(const AliTPCPreprocessorOnline &param)
UInt_t GetSector() const
Definition: AliTPCCalROC.h:32
virtual void Print(Option_t *option="") const
void DumpToFile(const char *fileName)
Preprocessor class for HLT and DAQ.
TMap * fMap
Map of the AliTPCCalPads.