]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCcalibDB.cxx
Adding gain for the dEdx maesurement (Marian)
[u/mrichter/AliRoot.git] / TPC / AliTPCcalibDB.cxx
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 ///////////////////////////////////////////////////////////////////////////////
18 //                                                                           //
19 // Class providing the calibration parameters by accessing the CDB           //
20 //                                                                           //
21 // Request an instance with AliTPCcalibDB::Instance()                        //
22 // If a new event is processed set the event number with SetRun              //
23 // Then request the calibration data                                         ////
24 //
25 //
26 // Calibration data:
27 // 0.)  Altro mapping
28 //          Simulation      - not yet 
29 //          Reconstruction  - AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader)
30 //
31 // 1.)  pad by pad calibration -  AliTPCCalPad
32 //      
33 //      a.) fPadGainFactor
34 //          Simulation: AliTPCDigitizer::ExecFast - Multiply by gain
35 //          Reconstruction : AliTPCclustererMI::Digits2Clusters - Divide by gain  
36 //
37 //      b.) fPadNoise -
38 //          Simulation:        AliTPCDigitizer::ExecFast
39 //          Reconstruction:    AliTPCclustererMI::FindClusters(AliTPCCalROC * noiseROC)
40 //                             Noise depending cut on clusters charge (n sigma)
41 //      c.) fPedestal:
42 //          Simulation:     Not used yet - To be impleneted - Rounding to the nearest integer
43 //          Reconstruction: Used in AliTPCclustererMI::Digits2Clusters(AliRawReader* rawReader) 
44 //                          if data taken without zero suppression  
45 //                          Currently switch in  fRecoParam->GetCalcPedestal();
46 //      
47 //      d.) fPadTime0
48 //          Simulation:      applied in the AliTPC::MakeSector - adding offset
49 //          Reconstruction:  AliTPCTransform::Transform() - remove offset
50 //                           AliTPCTransform::Transform() - to be called
51 //                           in AliTPCtracker::Transform()      
52 //
53 // 
54 // 2.)  Space points transformation:
55 //
56 //      a.) General coordinate tranformation - AliTPCtransform (see $ALICE_ROOT/TPC/AliTPCtransform.cxx)
57 //          Created on fly - use the other calibration components
58 //                 Unisochronity  - (substract time0 - pad by pad)
59 //                 Drift velocity - Currently common drift velocity - functionality of AliTPCParam
60 //                 ExB effect    
61 //          Simulation     - Not used directly (the effects are applied one by one (see AliTPC::MakeSector)
62 //          Reconstruction - 
63 //                           AliTPCclustererMI::AddCluster
64 //                           AliTPCtrackerMI::Transform
65 //      b.) ExB effect calibration - 
66 //             classes (base class AliTPCExB, implementation- AliTPCExBExact.h  AliTPCExBFirst.h)
67 //             a.a) Simulation:   applied in the AliTPC::MakeSector - 
68 //                                calib->GetExB()->CorrectInverse(dxyz0,dxyz1);
69 //             a.b) Reconstruction -  
70 //                  
71 //                  in AliTPCtransform::Correct() - called calib->GetExB()->Correct(dxyz0,dxyz1)
72 //
73 //  3.)   cluster error, shape and Q parameterization
74 //
75 //
76 //
77 ///////////////////////////////////////////////////////////////////////////////
78
79 #include <iostream>
80 #include <fstream>
81
82
83 #include <AliCDBManager.h>
84 #include <AliCDBEntry.h>
85 #include <AliLog.h>
86
87 #include "AliTPCcalibDB.h"
88 #include "AliTPCAltroMapping.h"
89 #include "AliTPCExB.h"
90
91 #include "AliTPCCalROC.h"
92 #include "AliTPCCalPad.h"
93 #include "AliTPCSensorTempArray.h"
94 #include "AliTPCTransform.h"
95
96 class AliCDBStorage;
97 class AliTPCCalDet;
98 //
99 //
100
101 #include "TFile.h"
102 #include "TKey.h"
103
104 #include "TObjArray.h"
105 #include "TObjString.h"
106 #include "TString.h"
107 #include "AliTPCCalPad.h"
108 #include "AliTPCCalibPulser.h"
109 #include "AliTPCCalibPedestal.h"
110 #include "AliTPCCalibCE.h"
111
112
113
114
115
116 ClassImp(AliTPCcalibDB)
117
118 AliTPCcalibDB* AliTPCcalibDB::fgInstance = 0;
119 Bool_t AliTPCcalibDB::fgTerminated = kFALSE;
120
121
122 //_ singleton implementation __________________________________________________
123 AliTPCcalibDB* AliTPCcalibDB::Instance()
124 {
125   //
126   // Singleton implementation
127   // Returns an instance of this class, it is created if neccessary
128   //
129   
130   if (fgTerminated != kFALSE)
131     return 0;
132
133   if (fgInstance == 0)
134     fgInstance = new AliTPCcalibDB();
135   
136   return fgInstance;
137 }
138
139 void AliTPCcalibDB::Terminate()
140 {
141   //
142   // Singleton implementation
143   // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore
144   // This function can be called several times.
145   //
146   
147   fgTerminated = kTRUE;
148   
149   if (fgInstance != 0)
150   {
151     delete fgInstance;
152     fgInstance = 0;
153   }
154 }
155
156 //_____________________________________________________________________________
157 AliTPCcalibDB::AliTPCcalibDB():
158   TObject(),
159   fRun(-1),
160   fTransform(0),
161   fExB(0),
162   fPadGainFactor(0),
163   fDedxGainFactor(0),
164   fPadTime0(0),
165   fPadNoise(0),
166   fPedestals(0),
167   fTemperature(0),
168   fMapping(0),
169   fParam(0),
170   fClusterParam(0)
171 {
172   //
173   // constructor
174   //  
175   //
176   Update();    // temporary
177 }
178
179 AliTPCcalibDB::AliTPCcalibDB(const AliTPCcalibDB& ):
180   TObject(),
181   fRun(-1),
182   fTransform(0),
183   fExB(0),
184   fPadGainFactor(0),
185   fDedxGainFactor(0),
186   fPadTime0(0),
187   fPadNoise(0),
188   fPedestals(0),
189   fTemperature(0),
190   fMapping(0),
191   fParam(0),
192   fClusterParam(0)
193
194 {
195   //
196   // Copy constructor invalid -- singleton implementation
197   //
198    Error("copy constructor","invalid -- singleton implementation");
199 }
200
201 AliTPCcalibDB& AliTPCcalibDB::operator= (const AliTPCcalibDB& )
202 {
203 //
204 // Singleton implementation - no assignment operator
205 //
206   Error("operator =", "assignment operator not implemented");
207   return *this;
208 }
209
210
211
212 //_____________________________________________________________________________
213 AliTPCcalibDB::~AliTPCcalibDB() 
214 {
215   //
216   // destructor
217   //
218   
219   // don't delete anything, CDB cache is active!
220   //if (fPadGainFactor) delete fPadGainFactor;
221   //if (fPadTime0) delete fPadTime0;
222   //if (fPadNoise) delete fPadNoise;
223 }
224
225
226 //_____________________________________________________________________________
227 AliCDBEntry* AliTPCcalibDB::GetCDBEntry(const char* cdbPath)
228 {
229   // 
230   // Retrieves an entry with path <cdbPath> from the CDB.
231   //
232   char chinfo[1000];
233     
234   AliCDBEntry* entry = AliCDBManager::Instance()->Get(cdbPath, fRun); 
235   if (!entry) 
236   { 
237     sprintf(chinfo,"AliTPCcalibDB: Failed to get entry:\t%s ", cdbPath);
238     AliError(chinfo); 
239     return 0; 
240   }
241   return entry;
242 }
243
244
245 //_____________________________________________________________________________
246 void AliTPCcalibDB::SetRun(Long64_t run)
247 {
248   //
249   // Sets current run number. Calibration data is read from the corresponding file. 
250   //  
251   if (fRun == run)
252     return;  
253   fRun = run;
254   Update();
255 }
256   
257
258
259 void AliTPCcalibDB::Update(){
260   //
261   AliCDBEntry * entry=0;
262   
263   Bool_t cdbCache = AliCDBManager::Instance()->GetCacheFlag(); // save cache status
264   AliCDBManager::Instance()->SetCacheFlag(kTRUE); // activate CDB cache
265   
266   //
267   entry          = GetCDBEntry("TPC/Calib/PadGainFactor");
268   if (entry){
269     //if (fPadGainFactor) delete fPadGainFactor;
270     entry->SetOwner(kTRUE);
271     fPadGainFactor = (AliTPCCalPad*)entry->GetObject();
272   }
273   //
274   entry          = GetCDBEntry("TPC/Calib/GainFactorDedx");
275   if (entry){
276     entry->SetOwner(kTRUE);
277     fDedxGainFactor = (AliTPCCalPad*)entry->GetObject();
278   }
279   //
280   entry          = GetCDBEntry("TPC/Calib/PadTime0");
281   if (entry){
282     //if (fPadTime0) delete fPadTime0;
283     entry->SetOwner(kTRUE);
284     fPadTime0 = (AliTPCCalPad*)entry->GetObject();
285   }
286   //
287   //
288   entry          = GetCDBEntry("TPC/Calib/PadNoise");
289   if (entry){
290     //if (fPadNoise) delete fPadNoise;
291     entry->SetOwner(kTRUE);
292     fPadNoise = (AliTPCCalPad*)entry->GetObject();
293   }
294
295   entry          = GetCDBEntry("TPC/Calib/Pedestals");
296   if (entry){
297     //if (fPedestals) delete fPedestals;
298     entry->SetOwner(kTRUE);
299     fPedestals = (AliTPCCalPad*)entry->GetObject();
300   }
301
302   entry          = GetCDBEntry("TPC/Calib/Temperature");
303   if (entry){
304     //if (fTemperature) delete fTemperature;
305     entry->SetOwner(kTRUE);
306     fTemperature = (AliTPCSensorTempArray*)entry->GetObject();
307   }
308
309   entry          = GetCDBEntry("TPC/Calib/Parameters");
310   if (entry){
311     //if (fPadNoise) delete fPadNoise;
312     entry->SetOwner(kTRUE);
313     fParam = (AliTPCParam*)(entry->GetObject()->Clone());
314   }
315
316   entry          = GetCDBEntry("TPC/Calib/ClusterParam");
317   if (entry){
318     //if (fPadNoise) delete fPadNoise;
319     entry->SetOwner(kTRUE);
320     fClusterParam = (AliTPCClusterParam*)(entry->GetObject()->Clone());
321   }
322
323   entry          = GetCDBEntry("TPC/Calib/Mapping");
324   if (entry){
325     //if (fPadNoise) delete fPadNoise;
326     entry->SetOwner(kTRUE);
327     TObjArray * array = dynamic_cast<TObjArray*>(entry->GetObject());
328     if (array && array->GetEntriesFast()==6){
329       fMapping = new AliTPCAltroMapping*[6];
330       for (Int_t i=0; i<6; i++){
331         fMapping[i] =  dynamic_cast<AliTPCAltroMapping*>(array->At(i));
332       }
333     }
334   }
335
336
337
338   entry          = GetCDBEntry("TPC/Calib/ExB");
339   if (entry) {
340     entry->SetOwner(kTRUE);
341     fExB=dynamic_cast<AliTPCExB*>(entry->GetObject()->Clone());
342   }
343
344   if (!fTransform) {
345     fTransform=new AliTPCTransform(); 
346   }
347
348   //
349   AliCDBManager::Instance()->SetCacheFlag(cdbCache); // reset original CDB cache
350   
351 }
352
353
354
355 void AliTPCcalibDB::CreateObjectList(const Char_t *filename, TObjArray *calibObjects)
356 {
357 //
358 // Create calibration objects and read contents from OCDB
359 //
360    if ( calibObjects == 0x0 ) return;
361    ifstream in;
362    in.open(filename);
363    if ( !in.is_open() ){
364       fprintf(stderr,"Error: cannot open list file '%s'", filename);
365       return;
366    }
367    
368    AliTPCCalPad *calPad=0x0;
369    
370    TString sFile;
371    sFile.ReadFile(in);
372    in.close();
373    
374    TObjArray *arrFileLine = sFile.Tokenize("\n");
375    
376    TIter nextLine(arrFileLine);
377    
378    TObjString *sObjLine=0x0;
379    while ( (sObjLine = (TObjString*)nextLine()) ){
380       TString sLine(sObjLine->GetString());
381       
382       TObjArray *arrNextCol = sLine.Tokenize("\t");
383       
384       TObjString *sObjType     = (TObjString*)(arrNextCol->At(0));
385       TObjString *sObjFileName = (TObjString*)(arrNextCol->At(1));
386       
387       if ( !sObjType || ! sObjFileName ) continue;
388       TString sType(sObjType->GetString());
389       TString sFileName(sObjFileName->GetString());
390       printf("%s\t%s\n",sType.Data(),sFileName.Data());
391       
392       TFile *fIn = TFile::Open(sFileName);
393       if ( !fIn ){
394          fprintf(stderr,"File not found: '%s'", sFileName.Data());
395          continue;
396       }
397       
398       if ( sType == "CE" ){
399          AliTPCCalibCE *ce = (AliTPCCalibCE*)fIn->Get("AliTPCCalibCE");
400          
401          calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadT0());         
402          calPad->SetNameTitle("CETmean","CETmean");
403          calibObjects->Add(calPad);
404          
405          calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadQ());         
406          calPad->SetNameTitle("CEQmean","CEQmean");
407          calibObjects->Add(calPad);        
408          
409          calPad = new AliTPCCalPad((TObjArray*)ce->GetCalPadRMS());
410          calPad->SetNameTitle("CETrms","CETrms");
411          calibObjects->Add(calPad);         
412                   
413       } else if ( sType == "Pulser") {
414          AliTPCCalibPulser *sig = (AliTPCCalibPulser*)fIn->Get("AliTPCCalibPulser");
415          
416          calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadT0());         
417          calPad->SetNameTitle("PulserTmean","PulserTmean");
418          calibObjects->Add(calPad);
419          
420          calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadQ());         
421          calPad->SetNameTitle("PulserQmean","PulserQmean");
422          calibObjects->Add(calPad);        
423          
424          calPad = new AliTPCCalPad((TObjArray*)sig->GetCalPadRMS());
425          calPad->SetNameTitle("PulserTrms","PulserTrms");
426          calibObjects->Add(calPad);         
427       
428       } else if ( sType == "Pedestals") {
429          AliTPCCalibPedestal *ped = (AliTPCCalibPedestal*)fIn->Get("AliTPCCalibPedestal");
430          
431          calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadPedestal());         
432          calPad->SetNameTitle("Pedestals","Pedestals");
433          calibObjects->Add(calPad);
434          
435          calPad = new AliTPCCalPad((TObjArray*)ped->GetCalPadRMS());         
436          calPad->SetNameTitle("Noise","Noise");
437          calibObjects->Add(calPad);        
438      
439       } else {
440          fprintf(stderr,"Undefined Type: '%s'",sType.Data());
441          
442       }
443       delete fIn;
444    }
445 }
446
447
448
449 void AliTPCcalibDB::MakeTree(const char * fileName, TObjArray * array, const char * mapFileName, AliTPCCalPad* outlierPad, Float_t ltmFraction) {
450   //
451   // Write a tree with all available information
452   // if mapFileName is specified, the Map information are also written to the tree
453   // pads specified in outlierPad are not used for calculating statistics
454   //  - the same function as AliTPCCalPad::MakeTree - 
455   //
456    AliTPCROC* tpcROCinstance = AliTPCROC::Instance();
457
458    TObjArray* mapIROCs = 0;
459    TObjArray* mapOROCs = 0;
460    TVectorF *mapIROCArray = 0;
461    TVectorF *mapOROCArray = 0;
462    Int_t mapEntries = 0;
463    TString* mapNames = 0;
464    
465    if (mapFileName) {
466       TFile mapFile(mapFileName, "read");
467       
468       TList* listOfROCs = mapFile.GetListOfKeys();
469       mapEntries = listOfROCs->GetEntries()/2;
470       mapIROCs = new TObjArray(mapEntries*2);
471       mapOROCs = new TObjArray(mapEntries*2);
472       mapIROCArray = new TVectorF[mapEntries];
473       mapOROCArray = new TVectorF[mapEntries];
474       
475       mapNames = new TString[mapEntries];
476       for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
477         TString nameROC(((TKey*)(listOfROCs->At(ivalue*2)))->GetName());
478          nameROC.Remove(nameROC.Length()-4, 4);
479          mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "IROC").Data()), ivalue);
480          mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((nameROC + "OROC").Data()), ivalue);
481          mapNames[ivalue].Append(nameROC);
482       }
483       
484       for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
485          mapIROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(0));
486          mapOROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(36));
487       
488          for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(0); ichannel++)
489             (mapIROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapIROCs->At(ivalue)))->GetValue(ichannel);
490          for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(36); ichannel++)
491             (mapOROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapOROCs->At(ivalue)))->GetValue(ichannel);
492       }
493
494    } //  if (mapFileName)
495   
496    TTreeSRedirector cstream(fileName);
497    Int_t arrayEntries = array->GetEntries();
498    
499    TString* names = new TString[arrayEntries];
500    for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
501       names[ivalue].Append(((AliTPCCalPad*)array->At(ivalue))->GetName());
502
503    for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) {
504       //
505       // get statistic for given sector
506       //
507       TVectorF median(arrayEntries);
508       TVectorF mean(arrayEntries);
509       TVectorF rms(arrayEntries);
510       TVectorF ltm(arrayEntries);
511       TVectorF ltmrms(arrayEntries);
512       TVectorF medianWithOut(arrayEntries);
513       TVectorF meanWithOut(arrayEntries);
514       TVectorF rmsWithOut(arrayEntries);
515       TVectorF ltmWithOut(arrayEntries);
516       TVectorF ltmrmsWithOut(arrayEntries);
517       
518       TVectorF *vectorArray = new TVectorF[arrayEntries];
519       for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
520          vectorArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
521       
522       for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
523          AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
524          AliTPCCalROC* calROC = calPad->GetCalROC(isector);
525          AliTPCCalROC* outlierROC = 0;
526          if (outlierPad) outlierROC = outlierPad->GetCalROC(isector);
527          if (calROC) {
528             median[ivalue] = calROC->GetMedian();
529             mean[ivalue] = calROC->GetMean();
530             rms[ivalue] = calROC->GetRMS();
531             Double_t ltmrmsValue = 0;
532             ltm[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction);
533             ltmrms[ivalue] = ltmrmsValue;
534             if (outlierROC) {
535                medianWithOut[ivalue] = calROC->GetMedian(outlierROC);
536                meanWithOut[ivalue] = calROC->GetMean(outlierROC);
537                rmsWithOut[ivalue] = calROC->GetRMS(outlierROC);
538                ltmrmsValue = 0;
539                ltmWithOut[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction, outlierROC);
540                ltmrmsWithOut[ivalue] = ltmrmsValue;
541             }
542          }
543          else {
544             median[ivalue] = 0.;
545             mean[ivalue] = 0.;
546             rms[ivalue] = 0.;
547             ltm[ivalue] = 0.;
548             ltmrms[ivalue] = 0.;
549             medianWithOut[ivalue] = 0.;
550             meanWithOut[ivalue] = 0.;
551             rmsWithOut[ivalue] = 0.;
552             ltmWithOut[ivalue] = 0.;
553             ltmrmsWithOut[ivalue] = 0.;
554          }
555       }
556       
557       //
558       // fill vectors of variable per pad
559       //
560       TVectorF *posArray = new TVectorF[8];
561       for (Int_t ivalue = 0; ivalue < 8; ivalue++)
562          posArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
563
564       Float_t posG[3] = {0};
565       Float_t posL[3] = {0};
566       Int_t ichannel = 0;
567       for (UInt_t irow = 0; irow < tpcROCinstance->GetNRows(isector); irow++) {
568          for (UInt_t ipad = 0; ipad < tpcROCinstance->GetNPads(isector, irow); ipad++) {
569             tpcROCinstance->GetPositionLocal(isector, irow, ipad, posL);
570             tpcROCinstance->GetPositionGlobal(isector, irow, ipad, posG);
571             posArray[0][ichannel] = irow;
572             posArray[1][ichannel] = ipad;
573             posArray[2][ichannel] = posL[0];
574             posArray[3][ichannel] = posL[1];
575             posArray[4][ichannel] = posG[0];
576             posArray[5][ichannel] = posG[1];
577             posArray[6][ichannel] = (Int_t)(ipad - (Double_t)(tpcROCinstance->GetNPads(isector, irow))/2);
578             posArray[7][ichannel] = ichannel;
579             
580             // loop over array containing AliTPCCalPads
581             for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
582                AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
583                AliTPCCalROC* calROC = calPad->GetCalROC(isector);
584                if (calROC)
585                   (vectorArray[ivalue])[ichannel] = calROC->GetValue(irow, ipad);
586                else
587                   (vectorArray[ivalue])[ichannel] = 0;
588             }
589             ichannel++;
590          }
591       }
592       
593       cstream << "calPads" <<
594          "sector=" << isector;
595       
596       for  (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
597          cstream << "calPads" <<
598             (Char_t*)((names[ivalue] + "_Median=").Data()) << median[ivalue] <<
599             (Char_t*)((names[ivalue] + "_Mean=").Data()) << mean[ivalue] <<
600             (Char_t*)((names[ivalue] + "_RMS=").Data()) << rms[ivalue] <<
601             (Char_t*)((names[ivalue] + "_LTM=").Data()) << ltm[ivalue] <<
602             (Char_t*)((names[ivalue] + "_RMS_LTM=").Data()) << ltmrms[ivalue];
603          if (outlierPad) {
604             cstream << "calPads" <<
605                (Char_t*)((names[ivalue] + "_Median_OutlierCutted=").Data()) << medianWithOut[ivalue] <<
606                (Char_t*)((names[ivalue] + "_Mean_OutlierCutted=").Data()) << meanWithOut[ivalue] <<
607                (Char_t*)((names[ivalue] + "_RMS_OutlierCutted=").Data()) << rmsWithOut[ivalue] <<
608                (Char_t*)((names[ivalue] + "_LTM_OutlierCutted=").Data()) << ltmWithOut[ivalue] <<
609                (Char_t*)((names[ivalue] + "_RMS_LTM_OutlierCutted=").Data()) << ltmrmsWithOut[ivalue];
610          }
611       }
612
613       for  (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
614          cstream << "calPads" <<
615             (Char_t*)((names[ivalue] + ".=").Data()) << &vectorArray[ivalue];
616       }
617
618       if (mapFileName) {
619          for  (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
620             if (isector < 36)
621                cstream << "calPads" <<
622                   (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapIROCArray[ivalue];
623             else
624                cstream << "calPads" <<
625                   (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapOROCArray[ivalue];
626          }
627       }
628
629       cstream << "calPads" <<
630          "row.=" << &posArray[0] <<
631          "pad.=" << &posArray[1] <<
632          "lx.=" << &posArray[2] <<
633          "ly.=" << &posArray[3] <<
634          "gx.=" << &posArray[4] <<
635          "gy.=" << &posArray[5] <<
636          "rpad.=" << &posArray[6] <<
637          "channel.=" << &posArray[7];
638          
639       cstream << "calPads" <<
640          "\n";
641
642       delete[] posArray;
643       delete[] vectorArray;
644    }
645    
646
647    delete[] names;
648    if (mapFileName) {
649       delete mapIROCs;
650       delete mapOROCs;
651       delete[] mapIROCArray;
652       delete[] mapOROCArray;
653       delete[] mapNames;
654    }
655 }