]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDPreprocessor.cxx
Changes in order to modify also ITSonly tracks
[u/mrichter/AliRoot.git] / TRD / AliTRDPreprocessor.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 /* $Id$ */
17
18 ////////////////////////////////////////////////////////////////////////////
19 //                                                                        //
20 // This class is a first implementation for the TRD.                      //
21 // It takes data from HLT and computes the parameters                     //
22 // and stores both reference data and online calibration                  //
23 // parameters in the CDB                                                  //
24 // It alsotakes DCS data, does spline fits                                //
25 // and stores both reference data and spline fits results                 //
26 // in the CDB                                                             //
27 //                                                                        //
28 // Authors:                                                               //
29 //   R. Bailhache (R.Bailhache@gsi.de)                                    //
30 //   J. Book (jbook@ikf.uni-frankfurt.de)                                 //
31 //   W. Monange   (w.monange@gsi.de)                                      //
32 //   F. Kramer    (kramer@ikf.uni-frankfurt.de)                           //
33 //                                                                        //
34 ////////////////////////////////////////////////////////////////////////////
35
36 #include <fstream>
37
38 #include <TFile.h>
39 #include <TProfile2D.h>
40 #include <TObjString.h>
41 #include <TString.h>
42 #include <TList.h>
43 #include <TSAXParser.h>
44
45 #include "AliCDBMetaData.h"
46 #include "AliLog.h"
47
48 #include "AliTRDPreprocessor.h"
49 #include "AliTRDSensorArray.h"
50 #include "AliTRDCalibraFit.h"
51 #include "AliTRDCalibraMode.h"
52 #include "AliTRDCalibPadStatus.h"
53 #include "AliTRDSaxHandler.h"
54 #include "AliTRDgeometry.h"
55 #include "AliTRDCalibChamberStatus.h"
56 #include "Cal/AliTRDCalPad.h"
57 #include "Cal/AliTRDCalPadStatus.h"
58 #include "Cal/AliTRDCalDCS.h"
59 #include "Cal/AliTRDCalSingleChamberStatus.h"
60 #include "Cal/AliTRDCalChamberStatus.h"
61 #include "Cal/AliTRDCalROC.h"
62
63 ClassImp(AliTRDPreprocessor)
64
65 //______________________________________________________________________________________________
66 AliTRDPreprocessor::AliTRDPreprocessor(AliShuttleInterface *shuttle)
67   :AliPreprocessor("TRD", shuttle)
68   ,fCalDCSObjSOR(0)
69   ,fCalDCSObjEOR(0)
70   ,fVdriftHLT(0)
71 {
72   //
73   // Constructor
74   //
75
76
77   AddRunType("PHYSICS");
78   AddRunType("STANDALONE");
79   AddRunType("PEDESTAL");
80   AddRunType("DAQ");
81   
82   
83 }
84 //______________________________________________________________________________________________
85  AliTRDPreprocessor::AliTRDPreprocessor(const AliTRDPreprocessor&  ) :
86    AliPreprocessor("TRD",0),
87    fCalDCSObjSOR(0),
88    fCalDCSObjEOR(0),
89    fVdriftHLT(0)
90 {
91   
92   Fatal("AliTRDPreprocessor", "copy constructor not implemented");
93   
94 }
95 //______________________________________________________________________________________________
96 AliTRDPreprocessor::~AliTRDPreprocessor()
97 {
98   //
99   // Destructor
100   //
101
102   if (fCalDCSObjSOR != NULL) {
103     delete fCalDCSObjSOR;
104     fCalDCSObjSOR =0;
105   }
106   if (fCalDCSObjEOR != NULL) {
107     delete fCalDCSObjEOR;
108     fCalDCSObjEOR =0;
109   }
110
111 }
112 //______________________________________________________________________________________________
113 AliTRDPreprocessor& AliTRDPreprocessor::operator = (const AliTRDPreprocessor& )
114 {
115   Fatal("operator =", "assignment operator not implemented");
116   return *this;
117 }
118 //______________________________________________________________________________________________
119 void AliTRDPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
120 {
121   //
122   // Initialization routine for the TRD preprocessor
123   //
124
125   AliPreprocessor::Initialize(run,startTime,endTime);
126   
127 }
128
129 //______________________________________________________________________________________________
130 UInt_t AliTRDPreprocessor::Process(TMap* dcsAliasMap)
131 {
132   //
133   // Process DCS and calibration part for HLT
134   //
135
136   TString runType = GetRunType();
137   Log(Form("runtype %s\n",runType.Data()));
138   
139   // always process the configuration data
140   Int_t DCSConfigReturn = ProcessDCSConfigData();
141   if(DCSConfigReturn) return DCSConfigReturn; 
142
143   if (runType=="PEDESTAL"){
144     if(ExtractPedestals()) return 1;
145     return 0;
146   } 
147
148   if ((runType=="PHYSICS") || (runType=="STANDALONE") || (runType=="DAQ")){
149     // DCS
150     if(ProcessDCS(dcsAliasMap)) return 1;
151     if(runType=="PHYSICS"){
152       // HLT if On
153       //TString runPar = GetRunParameter("HLTStatus");
154       //if(runPar=="1") {
155       if(GetHLTStatus()) {
156         //if(ExtractHLT()) return 1; // for testing!
157         ExtractHLT();
158       } 
159       // DAQ if HLT failed
160       if(!fVdriftHLT) {
161         //if(ExtractDriftVelocityDAQ()) return 1; 
162         ExtractDriftVelocityDAQ(); // for testing!
163       }
164     }
165     //if((runType=="PHYSICS") || (runType=="STANDALONE")) {
166       //      if(ExtractHalfChamberStatusDAQ()) return 1;
167     //}
168   }
169   
170   return 0;  
171   
172 }
173 //______________________________________________________________________________
174 Bool_t AliTRDPreprocessor::ProcessDCS()
175 {
176   //
177   // Default process DCS method
178   //
179
180   TString runType = GetRunType();
181   if ((runType == "PHYSICS") || (runType == "STANDALONE")) {
182     return kTRUE;
183   }
184   return kFALSE;
185
186 }
187
188 //______________________________________________________________________________
189 Bool_t AliTRDPreprocessor::ProcessDCS(TMap *dcsAliasMap)
190 {
191   //
192   // Process DCS method
193   //
194
195   Bool_t error = kFALSE;
196
197   AliCDBMetaData metaData;
198   metaData.SetBeamPeriod(0);
199   metaData.SetResponsible("Wilfried Monange/Raphaelle Bailhache");
200   metaData.SetComment("TRD calib test");
201
202   Log("****** DCS ******\n");
203         
204   TObjArray * list=AliTRDSensorArray::GetList();
205         
206   if (list == 0x0) {
207     Log ("Error during AliTRDSensorArray::GetList");
208     Log ("DCS will not be processing");
209     return kTRUE;
210   }
211
212   Int_t nEntries = list->GetEntries ();
213   Log (Form ("%d alias loaded", nEntries));
214                 
215   Bool_t * results=new Bool_t [nEntries];
216   Int_t  * nGraph=new Int_t [nEntries];
217                 
218   for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
219                         
220     AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias);
221                         
222     oneTRDDCS->SetStartTime (TTimeStamp (fStartTime));
223     oneTRDDCS->SetEndTime (TTimeStamp (fEndTime));
224                         
225     Log(Form("Processing DCS : \"%s\"", oneTRDDCS->GetStoreName ().Data ()));
226                         
227     TMap * map;
228
229     map=oneTRDDCS->ExtractDCS (dcsAliasMap);
230                 
231     nGraph [iAlias] = map->GetEntries ();
232                 
233     if (nGraph [iAlias] == 0) {
234       Log("No TGraph for this dcsDatapointAlias : not stored");
235       results [iAlias] = kFALSE;
236       //error  = kTRUE;
237       continue;
238     }
239                 
240     oneTRDDCS->SetGraph(map);
241     results[iAlias]=Store("Calib", oneTRDDCS->GetStoreName().Data(), oneTRDDCS, &metaData, 0, kFALSE); 
242     delete map;         
243
244     //results [iAlias] = StoreReferenceData("Calib", oneTRDDCS->GetStoreName ().Data (), oneTRDDCS, &metaData); 
245
246     if (!results[iAlias]) {
247       AliError("Problem during StoreRef DCS");
248       //error=kTRUE;
249     }
250
251     //BEGIN TEST (should not be removed ...)
252     /*
253     oneTRDDCS->ClearGraph();
254     oneTRDDCS->ClearFit();
255     oneTRDDCS->SetDiffCut2 (0.1);
256     map=oneTRDDCS->ExtractDCS (dcsAliasMap);
257     oneTRDDCS->SetGraph (map);
258     Store("Calib", ("cut_"+oneTRDDCS->GetStoreName()).Data(), oneTRDDCS, &metaData, 0, kTRUE); 
259     delete map;
260
261
262     if(iAlias==1 || iAlias==19) continue;
263     
264     oneTRDDCS->ClearGraph();
265     oneTRDDCS->ClearFit();
266     oneTRDDCS->SetDiffCut2(0);
267     map=oneTRDDCS->ExtractDCS(dcsAliasMap);
268     oneTRDDCS->MakeSplineFit(map);
269     Store("Calib", ("fit_"+oneTRDDCS->GetStoreName()).Data() , oneTRDDCS, &metaData, 0, kTRUE); 
270     delete map;
271
272      
273     oneTRDDCS->ClearGraph(); 
274     oneTRDDCS->ClearFit();
275     oneTRDDCS->SetDiffCut2 (0.1);
276     map=oneTRDDCS->ExtractDCS (dcsAliasMap);
277     oneTRDDCS->MakeSplineFit(map);
278     Store("Calib", ("cutfit_"+oneTRDDCS->GetStoreName()).Data() , oneTRDDCS, &metaData, 0, kTRUE); 
279     delete map;
280     */    
281     //END TEST
282
283   }
284
285   // Check errors
286   Int_t nbCount = 0;
287   for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
288     if (results[iAlias]) {
289       nbCount++;
290     }
291   }
292   if(nbCount == 0) error = kTRUE;
293
294                 
295   Log ("         Summury of DCS :\n");
296   Log (Form("%30s %10s %10s", "dcsDatapointAlias", "Stored ?", "# graph"));
297   for (Int_t iAlias = 0; iAlias < nEntries; iAlias++) {
298     AliTRDSensorArray * oneTRDDCS = (AliTRDSensorArray *)list->At (iAlias);
299     Log (Form ("%30s %10s %4d", 
300                oneTRDDCS->GetStoreName ().Data (),
301                results[iAlias] ? "ok" : "X",
302                nGraph [iAlias]));
303   }
304   Log ("*********** End of DCS **********");
305   
306   delete [] results;
307   delete [] nGraph;
308
309   return error;
310
311 }
312 //______________________________________________________________________________________________
313 Bool_t AliTRDPreprocessor::ExtractHalfChamberStatusDAQ()
314 {
315   //
316   // Half chamber status algorithm running on DAQ
317   //
318
319   Bool_t error = kFALSE;
320
321   AliCDBMetaData metaData;
322   metaData.SetBeamPeriod(0);
323   metaData.SetResponsible("Raphaelle Bailhache");
324   metaData.SetComment("TRD calib test");
325   
326   // Take the output of the DA on DAQ
327   TList * listpad = GetFileSources(kDAQ,"HALFCHAMBERSTATUS");
328   if (!listpad) {
329     Log("No list found for the HalfChamberStatus");
330     return kTRUE;
331   }
332
333   AliTRDCalibChamberStatus *calPed = 0x0;
334     
335   // loop through all files (only one normally)
336   UInt_t index = 0;
337   while (listpad->At(index)!=NULL) {
338     TObjString* fileNameEntry = (TObjString*) listpad->At(index);
339     if (fileNameEntry != NULL)
340       {
341         TString fileName = GetFile(kDAQ, "HALFCHAMBERSTATUS",
342                                    fileNameEntry->GetString().Data());
343         if(fileName.Length() ==0){
344           Log(Form("Error by retrieving the file %d for the halfchamberstatus",(Int_t)index));
345           delete listpad;
346           return kTRUE;
347         }
348         
349         TFile *f = TFile::Open(fileName);
350         f->GetObject("calibchamberstatus",calPed);
351         
352         if(calPed) {
353           
354           // store as reference data
355           TString name("HalfChamberStatus");
356           if(!StoreReferenceData("DAQData",(const char *)name,(TObject *) calPed,&metaData)){
357             Log(Form("Error storing AliTRDCalibPadStatus object %d as reference data",(Int_t)index));
358             error = kTRUE;
359           }
360         } // calPed
361         else Log(Form("Error getting AliTRDCalibChamberStatus onject from file"));
362                  
363       } // fileNameEntry
364     ++index;
365   }// while (list)
366
367   Log(Form("%d elements found in the list for the halfchamberstatus",(Int_t)index));
368   if(index!=1){
369     delete listpad;
370     return kTRUE;
371   }
372
373   //
374   // Produce the AliTRDCalChamberStatus  name calHalfChamberStatus
375   //
376   AliTRDCalChamberStatus *calHalfChamberStatus = 0x0;
377   if(calPed) {
378     //calPed->AnalyseHisto();   // check number of events, create calHalfChamberStatus (done on DAQ)
379     if(fCalDCSObjEOR) {
380       calPed->CheckEORStatus((AliTRDCalDCS *)fCalDCSObjEOR);
381     }
382     calHalfChamberStatus=(AliTRDCalChamberStatus *)calPed->GetCalChamberStatus();
383   }
384
385   //
386   // Store  
387   //  
388
389   AliCDBMetaData md3; 
390   md3.SetObjectClassName("AliTRDCalChamberStatus");
391   md3.SetResponsible("Raphaelle Bailhache");
392   md3.SetBeamPeriod(1);
393   md3.SetComment("TRD calib test");
394   if(!Store("Calib","ChamberStatus"    ,(TObject *)calHalfChamberStatus, &md3, 0, kTRUE)){
395     Log("Error storing the pedestal");
396     delete listpad;
397     return kTRUE;
398   }
399   
400   delete listpad;
401   return error; 
402   
403 }
404 //______________________________________________________________________________________________
405 Bool_t AliTRDPreprocessor::ExtractPedestals()
406 {
407   //
408   // Pedestal running on LDCs at the DAQ
409   //
410
411   //
412   // The reference data are stored in:
413   // PadStatus1 for sm-00-01-02-09-10-11
414   // PadStatus2 for sm-03-04-05-12-13-14
415   // PadStatus3 for sm-06-07-08-15-16-17
416   // PadStatus0 if nothing found..means problems
417   //
418
419   Bool_t error = kFALSE;
420
421   // Init a AliTRDCalibPadStatus
422   AliTRDCalibPadStatus calPedSum = AliTRDCalibPadStatus();
423
424   AliCDBMetaData metaData;
425   metaData.SetBeamPeriod(0);
426   metaData.SetResponsible("Raphaelle Bailhache");
427   metaData.SetComment("TRD calib test");
428   
429   // Sum the contributions of the LDCs
430   TList * listpad = GetFileSources(kDAQ,"PADSTATUS");
431   if (!listpad) {
432     Log("No list found for the PEDESTRAL Run");
433     return kTRUE;
434   }
435   
436   // loop through all files from LDCs  
437   UInt_t index = 0;
438   while (listpad->At(index)!=NULL) {
439     TObjString* fileNameEntry = (TObjString*) listpad->At(index);
440     if (fileNameEntry != NULL)
441       {
442         TString fileName = GetFile(kDAQ, "PADSTATUS",
443                                    fileNameEntry->GetString().Data());
444         if(fileName.Length() ==0){
445           Log(Form("Error by retrieving the file %d for the pedestal",(Int_t)index));
446           delete listpad;
447           return kTRUE;
448         }
449         
450         TFile *f = TFile::Open(fileName);
451         AliTRDCalibPadStatus *calPed;
452         f->GetObject("calibpadstatus",calPed);
453         
454         if(calPed){
455           
456           Int_t ldc = 0; 
457
458           // analyse
459           //calPed->AnalyseHisto();
460                   
461           // Add to the calPedSum
462           for (Int_t idet=0; idet<540; idet++) {
463             AliTRDCalROC *rocMean  = calPed->GetCalRocMean(idet, kFALSE);
464             if ( rocMean )  {
465               calPedSum.SetCalRocMean(rocMean,idet);
466               ldc = (Int_t) (idet / 30);
467             }
468             AliTRDCalROC *rocRMS = calPed->GetCalRocRMS(idet, kFALSE);
469             if ( rocRMS )  {
470               calPedSum.SetCalRocRMS(rocRMS,idet);
471             }
472             AliTRDCalROC *rocMeand  = calPed->GetCalRocMeand(idet, kFALSE);
473             if ( rocMeand )  {
474               calPedSum.SetCalRocMeand(rocMeand,idet);
475             }
476             AliTRDCalROC *rocRMSd = calPed->GetCalRocRMSd(idet, kFALSE);
477             if ( rocRMSd )  {
478               calPedSum.SetCalRocRMSd(rocRMSd,idet);
479             }
480           }// det loop
481
482           if((ldc==0) || (ldc==1) || (ldc==2)) ldc = 1;
483           if((ldc==3) || (ldc==4) || (ldc==5)) ldc = 2;
484           if((ldc==6) || (ldc==7) || (ldc==8)) ldc = 3;
485           if((ldc==9) || (ldc==10) || (ldc==11)) ldc = 4;
486           if((ldc==12) || (ldc==13) || (ldc==14)) ldc = 5;
487           if((ldc==15) || (ldc==16) || (ldc==17)) ldc = 6;
488         
489           // store as reference data
490           TString name("PadStatus");
491           name += ldc;
492           if(!StoreReferenceData("DAQData",(const char *)name,(TObject *) calPed,&metaData)){
493             Log(Form("Error storing AliTRDCalibPadStatus object %d as reference data",(Int_t)index));
494             error = kTRUE;
495           }
496
497         } // calPed
498       } // fileNameEntry
499     ++index;
500   }// while (list)
501
502   Log(Form("%d elements found in the list for the pedestal",(Int_t)index));
503   if(index==0){
504     delete listpad;
505     return kTRUE;
506   }
507
508   //
509   // Create pedestal 
510   //
511     
512   // Create Pad Status
513   AliTRDCalPadStatus *calPadStatus = calPedSum.CreateCalPadStatus();
514   // Create Noise 
515   //Make the AliTRDCalPad
516   AliTRDCalPad *calPad2 = calPedSum.CreateCalPad();
517   //Make the AliTRDCalDet correspondant
518   AliTRDCalDet *calDet = calPedSum.CreateCalDet();
519  
520   //
521   // Take the noise and Pad status from the previous OCDB
522   //
523
524   AliTRDCalPad *calPadPrevious=0;
525   AliCDBEntry* entry = GetFromOCDB("Calib", "PadNoise");
526   if (entry) calPadPrevious = (AliTRDCalPad*)entry->GetObject();
527   if ( calPadPrevious==NULL ) {
528      Log("AliTRDPreprocsessor: No previous TRD pad noise entry available.\n");
529      calPadPrevious = new AliTRDCalPad("PadNoise", "PadNoise");
530   }
531
532   AliTRDCalPadStatus *calPadStatusPrevious=0;
533   entry = GetFromOCDB("Calib", "PadStatus");
534   if (entry) calPadStatusPrevious = (AliTRDCalPadStatus*)entry->GetObject();
535   if ( calPadStatusPrevious==NULL ) {
536     Log("AliTRDPreprocsessor: No previous TRD pad status entry available.\n");
537     calPadStatusPrevious = new AliTRDCalPadStatus("padstatus", "padstatus");
538     for (Int_t idet=0; idet<540; ++idet)
539       {
540         AliTRDCalSingleChamberStatus *calROC = calPadStatusPrevious->GetCalROC(idet);
541         for(Int_t k = 0; k < calROC->GetNchannels(); k++){
542           calROC->SetStatus(k,AliTRDCalPadStatus::kMasked);
543         }
544       }
545   }
546
547   
548   // Loop over detectors for check
549   for (Int_t det=0; det<AliTRDgeometry::kNdet; ++det)  {
550     
551     // noise
552     AliTRDCalROC *calROCPreviousNoise = calPadPrevious->GetCalROC(det);
553     AliTRDCalROC *calROCNoise         = calPad2->GetCalROC(det);
554
555     // padstatus
556     AliTRDCalSingleChamberStatus *calROCPreviousStatus = calPadStatusPrevious->GetCalROC(det);
557     AliTRDCalSingleChamberStatus *calROCStatus         = calPadStatus->GetCalROC(det);
558     
559     
560     // loop over first half and second half chamber
561     for(Int_t half = 0; half < 2; half++){
562
563       Bool_t data         = AreThereDataPedestal(calROCStatus,(Bool_t)half);
564       //printf("There are data for the detector %d the half %d: %d\n",det,half,data);
565       if(!data){
566         // look if data in the OCDB
567         Bool_t dataPrevious = AreThereDataPedestal(calROCPreviousStatus,(Bool_t)half);
568         // if no data at all, set to default value
569         if(!dataPrevious){
570           SetDefaultStatus(*calROCStatus,(Bool_t)half);
571           SetDefaultNoise(*calROCNoise,(Bool_t)half);
572         }
573         else{
574           // if data, set to previous value
575           SetStatus(*calROCStatus,calROCPreviousStatus,(Bool_t)half);
576           SetNoise(*calROCNoise,calROCPreviousNoise,(Bool_t)half);
577         }
578       }
579     }
580   }
581   
582   //
583   // Store  
584   //  
585
586   AliCDBMetaData md3; 
587   md3.SetObjectClassName("AliTRDCalPadStatus");
588   md3.SetResponsible("Raphaelle Bailhache");
589   md3.SetBeamPeriod(1);
590   md3.SetComment("TRD calib test");
591   if(!Store("Calib","PadStatus"    ,(TObject *)calPadStatus, &md3, 0, kTRUE)){
592     Log("Error storing the pedestal");
593     delete listpad;
594     return kTRUE;
595   }
596
597   AliCDBMetaData md4; 
598   md4.SetObjectClassName("AliTRDCalPad");
599   md4.SetResponsible("Raphaelle Bailhache");
600   md4.SetBeamPeriod(1);
601   md4.SetComment("TRD calib test");
602   if(!Store("Calib","PadNoise"    ,(TObject *)calPad2, &md4, 0, kTRUE)){
603     Log("Error storing the pedestal");
604     delete listpad;
605     return kTRUE;
606   }
607   
608   AliCDBMetaData md5; 
609   md5.SetObjectClassName("AliTRDCalDet");
610   md5.SetResponsible("Raphaelle Bailhache");
611   md5.SetBeamPeriod(1);
612   md5.SetComment("TRD calib test");
613   if(!Store("Calib","DetNoise"    ,(TObject *)calDet, &md5, 0, kTRUE)){
614     Log("Error storing the pedestal");
615     delete listpad;
616     return kTRUE;
617   }  
618
619   delete listpad;
620   return error; 
621   
622 }
623
624 //__________________________________________________________________
625 Bool_t AliTRDPreprocessor::AreThereDataPedestal(AliTRDCalSingleChamberStatus * const calROCStatus
626                                               , Bool_t second)
627 {
628
629   //
630   // Data for this half chamber
631   //
632
633   Bool_t data         = kFALSE;
634   Int_t nCols         = calROCStatus->GetNcols();
635   Int_t nCol0         = 0;
636   Int_t nColE         = (Int_t) nCols/2 - 2;
637   if(second) {
638     nCol0 = nColE + 4;
639     nColE = nCols;
640   }
641
642   Int_t totalnumberofpads = 0;
643   Int_t totalnumberofdata = 0; 
644
645   for(Int_t col = nCol0; col < nColE; col++){
646     for(Int_t row = 0; row < calROCStatus->GetNrows(); row++){
647       totalnumberofpads++;
648       //printf("ismasked %d\n",(Int_t)calROCStatus->IsMasked(col,row));
649       if(!calROCStatus->GetStatus(col,row)) {
650         data = kTRUE;
651         totalnumberofdata++;
652       }
653     }
654   }
655   if(totalnumberofdata < (Int_t)(totalnumberofpads/2)) data = kFALSE;
656
657   return data;
658   
659 }
660 //__________________________________________________________________
661 void AliTRDPreprocessor::SetDefaultStatus(AliTRDCalSingleChamberStatus &calROCStatus, Bool_t second){
662
663   //
664   // default status for this half chamber
665   //
666
667   Int_t nCols         = calROCStatus.GetNcols();
668   Int_t nCol0         = 0;
669   Int_t nColE         = (Int_t) nCols/2;
670   if(second) {
671     nCol0 = nColE;
672     nColE = nCols;
673   }
674   for(Int_t col = nCol0; col < nColE; col++){
675     for(Int_t row = 0; row < calROCStatus.GetNrows(); row++){
676       calROCStatus.SetStatus(col,row,0);
677     }
678   }
679 }
680 //__________________________________________________________________
681 void AliTRDPreprocessor::SetStatus(AliTRDCalSingleChamberStatus &calROCStatus, AliTRDCalSingleChamberStatus *calROCStatusPrevious,Bool_t second){
682
683   //
684   // previous status for this half chamber
685   //
686
687   Int_t nCols         = calROCStatus.GetNcols();
688   Int_t nCol0         = 0;
689   Int_t nColE         = (Int_t) nCols/2;
690   if(second) {
691     nCol0 = nColE;
692     nColE = nCols;
693   }
694   for(Int_t col = nCol0; col < nColE; col++){
695     for(Int_t row = 0; row < calROCStatus.GetNrows(); row++){
696       calROCStatus.SetStatus(col,row,calROCStatusPrevious->GetStatus(col,row));
697     }
698   }
699 }
700 //__________________________________________________________________
701 void AliTRDPreprocessor::SetDefaultNoise(AliTRDCalROC &calROCNoise, Bool_t second){
702
703   //
704   // default noise for this half chamber
705   //
706
707   Int_t nCols         = calROCNoise.GetNcols();
708   Int_t nCol0         = 0;
709   Int_t nColE         = (Int_t) nCols/2;
710   if(second) {
711     nCol0 = nColE;
712     nColE = nCols;
713   }
714   for(Int_t col = nCol0; col < nColE; col++){
715     for(Int_t row = 0; row < calROCNoise.GetNrows(); row++){
716       calROCNoise.SetValue(col,row,0.12);
717     }
718   }
719 }
720 //__________________________________________________________________
721 void AliTRDPreprocessor::SetNoise(AliTRDCalROC &calROCNoise, AliTRDCalROC *calROCNoisePrevious, Bool_t second){
722
723   //
724   // previous noise for this half chamber
725   //
726
727   Int_t nCols         = calROCNoise.GetNcols();
728   Int_t nCol0         = 0;
729   Int_t nColE         = (Int_t) nCols/2;
730   if(second) {
731     nCol0 = nColE;
732     nColE = nCols;
733   }
734   for(Int_t col = nCol0; col < nColE; col++){
735     for(Int_t row = 0; row < calROCNoise.GetNrows(); row++){
736       calROCNoise.SetValue(col,row,calROCNoisePrevious->GetValue(col,row));
737     }
738   }
739 }
740 //______________________________________________________________________________________________
741 Bool_t AliTRDPreprocessor::ExtractDriftVelocityDAQ()
742 {
743   //
744   // Drift velocity DA running on monitoring servers at the DAQ
745   //
746
747   Bool_t error = kFALSE; 
748
749   // Objects for HLT and DAQ zusammen
750   AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
751   AliCDBMetaData metaData;
752   metaData.SetBeamPeriod(0);
753   metaData.SetResponsible("Raphaelle Bailhache");
754   metaData.SetComment("TRD calib test");
755   // Store the infos for the detector
756   AliCDBMetaData md1; 
757   md1.SetObjectClassName("AliTRDCalDet");
758   md1.SetResponsible("Raphaelle Bailhache");
759   md1.SetBeamPeriod(0);
760   md1.SetComment("TRD calib test");
761   // Store the infos for the pads
762   AliCDBMetaData md2; 
763   md2.SetObjectClassName("AliTRDCalPad");
764   md2.SetResponsible("Raphaelle Bailhache");
765   md2.SetBeamPeriod(0);
766   md2.SetComment("TRD calib test");
767
768   // Take the file from the DAQ file exchange server
769   TList *listdaq = GetFileSources(kDAQ,"VDRIFT");
770   if (!listdaq) {
771     Log("No list found for vdrift (DAQ)");
772     return kTRUE;
773   }
774   
775   if(listdaq->GetSize() !=1){
776     Log(Form("Problem on the size of the list: %d (DAQ)",listdaq->GetSize()));
777     delete listdaq;
778     return kTRUE;
779   }
780   
781   TObjString* fileNameEntry = (TObjString*) listdaq->At(0);
782   if(fileNameEntry != NULL){
783     TString fileName = GetFile(kDAQ, "VDRIFT",
784                                fileNameEntry->GetString().Data());
785     if(fileName.Length() ==0){
786       Log("Error retrieving the file vdrift (DAQ)");
787       delete listdaq;
788       return kTRUE;
789     }
790     TFile *filedaq = TFile::Open(fileName);
791     TProfile2D *histodriftvelocity = (TProfile2D *) filedaq->Get("PH2d");
792     if (histodriftvelocity) {
793       
794       // store as reference data
795       if(!StoreReferenceData("DAQData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
796         Log("Error storing 2D Profile for vdrift from the DAQ");
797         error = kTRUE;
798       }
799       
800       // analyse
801       
802       Log("Take the PH reference data. Now we will try to fit\n");
803       calibra->SetMinEntries(2000); // If there is less than 2000
804       calibra->AnalysePH(histodriftvelocity);
805       
806       Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
807         + 6*  18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
808       Int_t nbfit        = calibra->GetNumberFit();
809       Int_t nbfitSuccess = calibra->GetNumberFitSuccess();
810       Int_t nbE        = calibra->GetNumberEnt();
811       
812       // if enough statistics store the results
813       if ((nbtg >                  0) && 
814           (nbfit        >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) {
815         // create the cal objects
816         calibra->RemoveOutliers(1,kTRUE);
817         calibra->PutMeanValueOtherVectorFit(1,kTRUE);
818         calibra->RemoveOutliers2(kTRUE);
819         calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
820         TObjArray object      = calibra->GetVectorFit();
821         AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
822         //      TObject *objdriftvelocitypad = calibra->CreatePadObjectVdrift();
823         object              = calibra->GetVectorFit2();
824         AliTRDCalDet *objtime0det         = calibra->CreateDetObjectT0(&object,kTRUE);
825         //      TObject *objtime0pad         = calibra->CreatePadObjectT0();
826         calibra->ResetVectorFit();
827         // store
828          if(!Store("Calib","ChamberVdrift"    ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){
829                   Log("Error storing the calibration object for the chamber vdrift (DAQ)");
830                   error = kTRUE;
831                 }
832                 if(!Store("Calib","ChamberT0"        ,(TObject *) objtime0det        ,&md1,0,kTRUE)){
833                   Log("Error storing the calibration object for the chamber t0 (DAQ)");
834                   error = kTRUE;
835                 }
836         //      if(!Store("Calib","LocalVdrift"      ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){
837         //        Log("Error storing the calibration object for the local drift velocity (DAQ)");
838         //        error = kTRUE;
839         //      }
840         //      if(!Store("Calib","LocalT0"          ,(TObject *) objtime0pad        ,&md2,0,kTRUE)){
841         //        Log("Error storing the calibration object for the local time0 (DAQ)");
842         //        error = kTRUE;
843         //      }
844       }
845       else{
846         Log("Not enough statistics for the average pulse height (DAQ)");
847       }
848     } // histo here
849   }// if fileNameEntry
850   
851   delete listdaq; 
852   return error; 
853   
854 }
855
856 //______________________________________________________________________________________________
857 Bool_t AliTRDPreprocessor::ExtractHLT()
858 {
859   //
860   // Gain, vdrift and PRF calibration running on HLT
861   // return kTRUE if NULL pointer to the list
862   //
863
864   Bool_t error = kFALSE;
865
866   // Objects for HLT and DAQ zusammen
867   AliTRDCalibraFit *calibra = AliTRDCalibraFit::Instance();
868   AliCDBMetaData metaData;
869   metaData.SetBeamPeriod(0);
870   metaData.SetResponsible("Raphaelle Bailhache");
871   metaData.SetComment("TRD calib test");
872   // Store the infos for the detector
873   AliCDBMetaData md1; 
874   md1.SetObjectClassName("AliTRDCalDet");
875   md1.SetResponsible("Raphaelle Bailhache");
876   md1.SetBeamPeriod(0);
877   md1.SetComment("TRD calib test");
878   // Store the infos for the pads
879   AliCDBMetaData md2; 
880   md2.SetObjectClassName("AliTRDCalPad");
881   md2.SetResponsible("Raphaelle Bailhache");
882   md2.SetBeamPeriod(0);
883   md2.SetComment("TRD calib test");
884   
885   // Take the file from the HLT file exchange server
886   TList *listhlt = GetFileSources(kHLT,"GAINDRIFTPRF");
887   if (!listhlt) {
888     Log("No list found for the HLT");
889     return kTRUE;
890   }
891
892   if(listhlt->GetSize() != 1) {
893     Log(Form("Problem on the size of the list: %d (HLT)",listhlt->GetSize()));
894     delete listhlt;
895     return kTRUE;
896   }
897   
898   TObjString* fileNameEntry = (TObjString*) listhlt->At(0);
899   if(fileNameEntry != NULL){
900     TString fileName = GetFile(kHLT, "GAINDRIFTPRF",
901                                fileNameEntry->GetString().Data());
902     if(fileName.Length() ==0){
903       Log("Error retrieving the file (HLT)");
904       delete listhlt;
905       return kTRUE;
906     }
907     // Take the file
908     TFile *filehlt = TFile::Open(fileName);
909     
910     // gain
911     TH2I *histogain = (TH2I *) filehlt->Get("CH2d");
912     if (histogain) {
913       histogain->SetDirectory(0);
914       // store the reference data
915       if(!StoreReferenceData("HLTData","Gain",(TObject *) histogain,&metaData)){
916         Log("Error storing 2D histos for gain");
917         error = kTRUE;
918       }
919       // analyse
920       Log("Take the CH reference data. Now we will try to fit\n");
921       calibra->SetMinEntries(800); // If there is less than 1000 entries in the histo: no fit
922       calibra->AnalyseCH(histogain);
923       Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(0))
924         + 6*  18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(0));
925       Int_t nbfit       = calibra->GetNumberFit();
926       Int_t nbE         = calibra->GetNumberEnt();
927       // enough statistics
928       if ((nbtg >                  0) && 
929           (nbfit        >= 0.5*nbE) && (nbE > 30)) {
930         // create the cal objects
931         calibra->PutMeanValueOtherVectorFit(1,kTRUE);
932         TObjArray object           = calibra->GetVectorFit();
933         AliTRDCalDet *objgaindet   = calibra->CreateDetObjectGain(&object);
934         //      TObject *objgainpad        = calibra->CreatePadObjectGain();
935         // store them
936         if(!Store("Calib","ChamberGainFactor",(TObject *) objgaindet         ,&md1,0,kTRUE)){
937           Log("Error storing the calibration object for the chamber gain");
938           error = kTRUE;
939         }
940         //      if(!Store("Calib","LocalGainFactor"  ,(TObject *) objgainpad         ,&md2,0,kTRUE)){
941         //        Log("Error storing the calibration object for the local gain factor");
942         //        error = kTRUE;
943         //      }
944       }
945       calibra->ResetVectorFit();
946     }// if histogain
947     
948     // vdrift
949     fVdriftHLT = kFALSE;
950     TProfile2D *histodriftvelocity = (TProfile2D *) filehlt->Get("PH2d");
951     if (histodriftvelocity) {
952       histodriftvelocity->SetDirectory(0);
953       // store the reference data
954       if(!StoreReferenceData("HLTData","VdriftT0",(TObject *) histodriftvelocity,&metaData)){
955         Log("Error storing 2D Profile for average pulse height (HLT)");
956         error = kTRUE;
957       }
958       // analyse
959       Log("Take the PH reference data. Now we will try to fit\n");
960       calibra->SetMinEntries(800*20); // If there is less than 20000
961       calibra->AnalysePH(histodriftvelocity);
962       Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
963         + 6*  18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
964       Int_t nbfit        = calibra->GetNumberFit();
965       Int_t nbfitSuccess = calibra->GetNumberFitSuccess();
966       Int_t nbE          = calibra->GetNumberEnt();
967       // enough statistics
968       if ((nbtg >                  0) && 
969           (nbfit        >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) {
970         // create the cal objects
971         calibra->RemoveOutliers(1,kTRUE);
972         calibra->PutMeanValueOtherVectorFit(1,kTRUE);
973         calibra->RemoveOutliers2(kTRUE);
974         calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
975         TObjArray object  = calibra->GetVectorFit();
976         AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
977         //      TObject *objdriftvelocitypad      = calibra->CreatePadObjectVdrift();
978         object              = calibra->GetVectorFit2();
979         AliTRDCalDet *objtime0det  = calibra->CreateDetObjectT0(&object,kTRUE);
980         //TObject *objtime0pad       = calibra->CreatePadObjectT0();
981         // store them
982         if(!Store("Calib","ChamberVdrift"    ,(TObject *) objdriftvelocitydet,&md1,0,kTRUE)){
983           Log("Error storing the calibration object for the chamber vdrift (HLT)");
984           error = kTRUE;                
985         }
986         if(!Store("Calib","ChamberT0"        ,(TObject *) objtime0det        ,&md1,0,kTRUE)){
987           Log("Error storing the calibration object for the chamber t0 (HLT)");
988           error = kTRUE;
989         }
990         // if(!Store("Calib","LocalVdrift"      ,(TObject *) objdriftvelocitypad,&md2,0,kTRUE)){
991         //        Log("Error storing the calibration object for the local drift velocity (HLT)");
992         //        error = kTRUE;
993         //      }
994         //      if(!Store("Calib","LocalT0"          ,(TObject *) objtime0pad        ,&md2,0,kTRUE)){
995         //        Log("Error storing the calibration object for the local time0 (HLT)");
996         //        error = kTRUE;
997         //      }
998         fVdriftHLT = kTRUE;
999       }
1000       calibra->ResetVectorFit();
1001     }// if TProfile2D
1002     
1003     // prf
1004     TProfile2D *histoprf = (TProfile2D *) filehlt->Get("PRF2d");
1005     if (histoprf) {
1006       histoprf->SetDirectory(0);    
1007       // store reference data
1008       if(!StoreReferenceData("HLTData","PRF",(TObject *) histoprf,&metaData)){
1009         Log("Error storing the 2D Profile for Pad Response Function");
1010         error = kTRUE;
1011       }
1012       // analyse
1013       Log("Take the PRF reference data. Now we will try to fit\n");
1014       calibra->SetMinEntries(600); // If there is less than 20000
1015       calibra->AnalysePRFMarianFit(histoprf);
1016       Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(2))
1017         + 6*  18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(2));
1018       Int_t nbfit        = calibra->GetNumberFit();
1019       Int_t nbE          = calibra->GetNumberEnt();
1020       // enough statistics
1021       if ((nbtg >                  0) && 
1022           (nbfit        >= 0.95*nbE) && (nbE > 30)) {
1023         // create cal pad objects 
1024         TObjArray object            = calibra->GetVectorFit();
1025         TObject *objPRFpad          = calibra->CreatePadObjectPRF(&object);
1026         // store them
1027         if(!Store("Calib","PRFWidth"         ,(TObject *) objPRFpad          ,&md2,0,kTRUE)){
1028           Log("Error storing the calibration object for the Pad Response Function");
1029           error = kTRUE;
1030         }
1031       }
1032       calibra->ResetVectorFit();
1033     }// if PRF
1034   }// if fileNameEntry
1035   
1036   delete listhlt;
1037   return error;
1038   
1039 }
1040
1041 //_____________________________________________________________________________
1042 UInt_t AliTRDPreprocessor::ProcessDCSConfigData()
1043 {
1044   // 
1045   // process the configuration of FEE, PTR and GTU
1046   // reteive XML filei(s) from the DCS FXS
1047   // parse it/them and store TObjArrays in the CDB
1048   //
1049   // return 0 for success, otherwise:
1050   //  5 : Could not get the (SOR and EOR) or SOR file from the FXS
1051   //  8 : Both files are not valid
1052   // 10 : SOR XML is not well-formed
1053   // 11 : EOR XML is not well-formed
1054   // 12 : ERROR in SOR XML SAX validation: something wrong with the content
1055   // 12 : ERROR in EOR XML SAX validation: something wrong with the content
1056   // 14 : ERROR while creating SOR calibration objects in the handler
1057   // 15 : ERROR while creating EOR calibration objects in the handler
1058   // 16 : ERROR while storing data in the CDB
1059   //
1060
1061   Log("Processing the DCS config summary files.");
1062
1063   // get the XML files
1064   Log("Requesting the 2 summaryfiles from the FXS..");
1065   TString xmlFileS = GetFile(kDCS,"CONFIGSUMMARYSOR","");
1066   TString xmlFileE = GetFile(kDCS,"CONFIGSUMMARYEOR","");
1067   // Request EOR and SOR files from the fxs, if both are not found exit
1068
1069   Bool_t fileExistE = kTRUE, fileExistS = kTRUE;
1070
1071   // check if the files are there
1072   if (xmlFileS.IsNull()) {
1073           Log(Form("Warning: SOR file %s not found!", xmlFileS.Data()));
1074     fileExistS = kFALSE;
1075   } else Log(Form("SOR file found: %s", xmlFileS.Data()));
1076
1077   if (xmlFileE.IsNull()) {
1078     Log(Form("Warning: EOR file %s not found!", xmlFileE.Data()));
1079     fileExistE = kFALSE;
1080   } else Log(Form("EOR file found: %s", xmlFileE.Data()));
1081
1082   if (fileExistS==0 && fileExistE==0) {
1083     Log(Form("ERROR: SOR and EOR files not found: %s and %s", xmlFileS.Data(), xmlFileE.Data()));
1084     return 5;
1085   }
1086
1087   // test the files
1088   if (fileExistS) {
1089     Log("Checking if SOR file is valid.");
1090     std::ifstream fileTestS;
1091     fileTestS.open(xmlFileS.Data(), std::ios_base::binary | std::ios_base::in);
1092     if (!fileTestS.good() || fileTestS.eof() || !fileTestS.is_open()) {
1093       Log(Form("Warning: File %s not valid!",xmlFileS.Data()));
1094       fileExistS = kFALSE;
1095       return 5;
1096     }
1097     Log("Checking if SOR file is not empty.");
1098     fileTestS.seekg(0, std::ios_base::end);
1099     if (static_cast<int>(fileTestS.tellg()) < 2) {
1100       Log(Form("Warning: File %s is empty!",xmlFileS.Data()));
1101       fileExistS = kFALSE;
1102       return 5;
1103     }
1104   }
1105
1106
1107   if (fileExistE) {
1108     Log("Checking if EOR file is valid.");
1109     std::ifstream fileTestE;
1110     fileTestE.open(xmlFileE.Data(), std::ios_base::binary | std::ios_base::in);
1111     if (!fileTestE.good() || fileTestE.eof() || !fileTestE.is_open()) {
1112       Log(Form("Warning: File %s not valid!",xmlFileE.Data()));
1113       fileExistE = kFALSE;
1114     }
1115     Log("Checking if EOR file is not empty.");
1116     fileTestE.seekg(0, std::ios_base::end);
1117     if (static_cast<int>(fileTestE.tellg()) < 2) {
1118       Log(Form("Warning: File %s is empty!",xmlFileE.Data()));
1119       fileExistE = kFALSE;
1120     }
1121   }
1122
1123   if (fileExistS==0 && fileExistE==0) {
1124     Log("ERROR: Both files (SOR/EOR) are not valid!");
1125     return 8;
1126   }
1127
1128   Log("One or both of the tested files are valid.");
1129
1130   // make a robust XML validation
1131   TSAXParser testParser;
1132   if (fileExistS && testParser.ParseFile(xmlFileS.Data()) < 0 ) {
1133     Log("ERROR: XML content (SOR) is not well-formed.");
1134     return 10;
1135   } else if (fileExistE && testParser.ParseFile(xmlFileE.Data()) < 0 ) {
1136     Log("ERROR: XML content (EOR) is not well-formed.");
1137     return 11;
1138   }
1139   Log("XML contents are well-formed.");
1140
1141   // create parser and parse
1142   TSAXParser saxParserS, saxParserE;
1143   AliTRDSaxHandler saxHandlerS, saxHandlerE;
1144   if (fileExistS) {
1145     saxParserS.ConnectToHandler("AliTRDSaxHandler", &saxHandlerS);
1146     saxParserS.ParseFile(xmlFileS.Data());
1147   }
1148   if (fileExistE) {
1149     saxParserE.ConnectToHandler("AliTRDSaxHandler", &saxHandlerE);
1150     saxParserE.ParseFile(xmlFileE.Data());
1151   }
1152   // report errors of the parser if present
1153   if (fileExistS && saxParserS.GetParseCode() != 0) {
1154     Log(Form("ERROR in XML file validation. SOR Parse Code: %d", saxParserS.GetParseCode()));
1155     return 12;
1156   }
1157   if (fileExistE && saxParserE.GetParseCode() != 0) {
1158     Log(Form("ERROR in XML file validation. EOR Parse Code: %d", saxParserE.GetParseCode()));
1159     return 13;
1160   }
1161   Log("XML file validation OK.");
1162   // report errors of the handler if present
1163   if (fileExistS && saxHandlerS.GetHandlerStatus() != 0) {
1164     Log(Form("ERROR while creating calibration objects. SOR Error code: %d", saxHandlerS.GetHandlerStatus()));
1165     return 14;  
1166   }
1167   if (fileExistE && saxHandlerE.GetHandlerStatus() != 0) {
1168     Log(Form("ERROR while creating calibration objects. EOR Error code: %d", saxHandlerE.GetHandlerStatus()));
1169     return 15;
1170   }
1171   Log("SAX handler reports no errors.");
1172
1173   // put both objects in one TObjArray to store them
1174   TObjArray* calObjArray = new TObjArray(2);
1175   calObjArray->SetOwner();
1176
1177   // get the calibration object storing the data from the handler
1178   if (fileExistS) {
1179     if(fCalDCSObjSOR) delete fCalDCSObjSOR;
1180     fCalDCSObjSOR = (AliTRDCalDCS *) saxHandlerS.GetCalDCSObj()->Clone();
1181     fCalDCSObjSOR->EvaluateGlobalParameters();
1182     fCalDCSObjSOR->SetRunType(GetRunType());
1183     fCalDCSObjSOR->SetStartTime(GetStartTimeDCSQuery());
1184     fCalDCSObjSOR->SetEndTime(GetEndTimeDCSQuery());
1185     calObjArray->AddAt(fCalDCSObjSOR,0);
1186     Log("TRDCalDCS object for SOR created.");
1187   }
1188
1189   if (fileExistE) {
1190     if(fCalDCSObjEOR) delete fCalDCSObjEOR;
1191     fCalDCSObjEOR = (AliTRDCalDCS *) saxHandlerE.GetCalDCSObj()->Clone();
1192     fCalDCSObjEOR->EvaluateGlobalParameters();
1193     fCalDCSObjEOR->SetRunType(GetRunType());
1194     fCalDCSObjEOR->SetStartTime(GetStartTimeDCSQuery());
1195     fCalDCSObjEOR->SetEndTime(GetEndTimeDCSQuery());
1196     calObjArray->AddAt(fCalDCSObjEOR,1);
1197     Log("TRDCalDCS object for EOR created.");
1198     //    printf("globalnumberoftimebins %d \n",fCalDCSObjEOR->GetGlobalNumberOfTimeBins());
1199   }
1200
1201
1202
1203   // store the DCS calib data in the CDB
1204   AliCDBMetaData metaData1;
1205   metaData1.SetBeamPeriod(0);
1206   metaData1.SetResponsible("Frederick Kramer");
1207   metaData1.SetComment("DCS configuration data in two AliTRDCalDCS objects in one TObjArray (0:SOR, 1:EOR).");
1208   if (!Store("Calib", "DCS", calObjArray, &metaData1, 0, kTRUE)) {
1209     Log("problems while storing DCS config data object");
1210     return 16;
1211   } else {
1212     Log("DCS config data object stored.");
1213   }
1214
1215   //delete calObjArray;
1216
1217   Log("SUCCESS: Processing of the DCS config summary file DONE.");  
1218   return 0;
1219 }
1220
1221
1222
1223