+ //
+ AliTPCCalPad *ceTmean=0;
+ AliTPCCalPad *ceTrms=0;
+ AliTPCCalPad *ceQmean=0;
+ TObjArray *rocTtime=0;
+ TObjArray *rocQtime=0;
+
+ TObjArray *ceObjects= new TObjArray;
+
+
+ Int_t nSectors = fROC->GetNSectors();
+
+ ceTmean = new AliTPCCalPad("CETmean","CETmean");
+ ceObjects->Add(ceTmean);
+
+ ceTrms = new AliTPCCalPad("CETrms","CETrms");
+ ceObjects->Add(ceTrms);
+
+ ceQmean = new AliTPCCalPad("CEQmean","CEQmean");
+ ceObjects->Add(ceQmean);
+
+ rocTtime = new TObjArray(nSectors+2); // also make room for A and C side average
+ rocTtime->SetName("rocTtime");
+ ceObjects->Add(rocTtime);
+
+ rocQtime = new TObjArray(nSectors);
+ rocQtime->SetName("rocQtime");
+ ceObjects->Add(rocQtime);
+
+ //=== new part
+ TObjArray *arrFitGraphs=new TObjArray;
+ arrFitGraphs->SetName("ceFitsDrift");
+ ceObjects->Add(arrFitGraphs);
+
+// Temperature maps
+
+ if (fTemp) {
+ AliTPCSensorTempArray *tempMap = new AliTPCSensorTempArray(*fTemp);
+ tempMap->SetNameTitle("TempMap","TempMap");
+ ceObjects->Add(tempMap);
+ }
+
+// Pressure maps
+
+ if (fPressure) {
+ AliDCSSensor *sensor=0, *sensorCopy=0;
+ for (Int_t isensor=0; isensor<kNumPressureSensors; ++isensor ) {
+ sensor = fPressure->GetSensor(kPressureSensorNames[isensor]);
+ if (sensor) {
+ sensorCopy = new AliDCSSensor(*sensor);
+ sensorCopy->SetNameTitle(kPressureSensorNames[isensor],kPressureSensorNames[isensor]);
+ ceObjects->Add(sensorCopy);
+ }
+ }
+ }
+
+ UInt_t result=0;
+
+ TList* list = GetFileSources(sourceFXS,"CE");
+
+ if (list && list->GetEntries()>0) {
+
+// loop through all files from LDCs
+
+ UInt_t index = 0;
+ while (list->At(index)!=NULL) {
+ TObjString* fileNameEntry = (TObjString*) list->At(index);
+ if (fileNameEntry!=NULL) {
+ TString fileName = GetFile(sourceFXS, "CE",
+ fileNameEntry->GetString().Data());
+ AliTPCCalibCE *calCE=AliTPCCalibCE::ReadFromFile(fileName.Data());
+
+ if (!calCE) {
+ Log ("No valid calibCE object.");
+ result=2;
+ break;
+ }
+ // replace entries for the sectors available in the present file
+
+ for (Int_t sector=0; sector<nSectors; sector++) {
+ AliTPCCalROC *rocTmean=calCE->GetCalRocT0(sector);
+ if ( rocTmean ) ceTmean->SetCalROC(rocTmean,sector);
+ AliTPCCalROC *rocTrms=calCE->GetCalRocRMS(sector);
+ if ( rocTrms ) ceTrms->SetCalROC(rocTrms,sector);
+ AliTPCCalROC *rocQmean=calCE->GetCalRocQ(sector);
+ if ( rocQmean ) ceQmean->SetCalROC(rocQmean,sector);
+ TGraph *grT=calCE->MakeGraphTimeCE(sector,0,2); // T time graph
+ if ( grT ) rocTtime->AddAt(grT,sector);
+ TGraph *grQ=calCE->MakeGraphTimeCE(sector,0,3); // Q time graph
+ if ( grQ ) rocQtime->AddAt(grQ,sector);
+ }
+
+ TGraph *grT=calCE->MakeGraphTimeCE(-1,0,2); // A side average
+ if ( grT ) {
+ rocTtime->AddAt(grT,nSectors);
+ } else {
+ result=10;
+ }
+ grT=calCE->MakeGraphTimeCE(-2,0,2); // C side average
+ if ( grT ) {
+ rocTtime->AddAt(grT,nSectors+1);
+ } else {
+ result=10;
+ }
+
+ delete calCE;
+ }
+ ++index;
+ } // while(list)
+//
+// Check number of calibrated sectors per side
+//
+ Int_t aside=0, cside=0;
+ for (Int_t ind=0; ind<nSectors/4; ind++ ) {
+ TGraph *grT=(TGraph*)rocTtime->At(ind);
+ if (grT) aside++;
+ grT=(TGraph*)rocTtime->At(ind+nSectors/2);
+ if (grT) aside++;
+ grT=(TGraph*)rocTtime->At(ind+nSectors/4);
+ if (grT) cside++;
+ grT=(TGraph*)rocTtime->At(ind+3*nSectors/4);
+ if (grT) cside++;
+ }
+ if ( (aside<kMinCESectors) && (cside<kMinCESectors) ) {
+ Log (Form("ExtractCE: Too few fitted sectors: Aside =%d, Cside=%d\n",
+ aside, cside)) ;
+ result=10;
+ }
+
+ //
+ //=== New CE part
+ // if it is validated this part needs to be modified again
+ // currently its only processed if there is a valid standard CE object
+ //
+ list = GetFileSources(sourceFXS,"CEnew");
+
+ if (result==0 && list && list->GetEntries()>0) {
+
+// loop through all files from LDCs
+
+ UInt_t index2 = 0;
+ while (list->At(index2)!=NULL) {
+ TObjString* fileNameEntry = (TObjString*) list->At(index2);
+ if (fileNameEntry!=NULL) {
+ TString fileName = GetFile(sourceFXS, "CEnew",
+ fileNameEntry->GetString().Data());
+ TFile *f = TFile::Open(fileName);
+ if (!f) {
+ Log ("Error opening new central electrode file.");
+// result =2;
+ break;
+ }
+ AliTPCCalibCE *calCE;
+ f->GetObject("tpcCalibCE",calCE);
+
+ if (!calCE) {
+ Log ("No valid new calibCE object.");
+// result=2;
+ break;
+ }
+
+ TIter nextObj(calCE->GetArrFitGraphs());
+ TObject *obj=0x0;
+ while ( (obj=nextObj()) ){
+ arrFitGraphs->Add(obj->Clone());
+ }
+ delete calCE;
+ f->Close();
+ }
+ ++index2;
+ }
+ }
+
+//
+// Store updated pedestal entry to OCDB
+//
+ AliCDBMetaData metaData;
+ metaData.SetBeamPeriod(0);
+ metaData.SetResponsible("Haavard Helstrup");
+ metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
+ metaData.SetComment("Preprocessor AliTPC data base entries.");
+
+ if ( result == 0 ) {
+ Bool_t storeOK = Store("Calib", "CE", ceObjects, &metaData, 0, kTRUE);
+ if ( !storeOK ) ++result;
+ } else {
+ Log ("Warning: Average time graphs not available - no OCDB entry written");
+ }
+ } else {
+ Log ("Error: no CE entries available from FXS!");
+ result = 1;
+ }
+
+ ceObjects->Delete();
+ delete ceObjects;
+
+ return result;
+}
+//______________________________________________________________________________________________
+
+UInt_t AliTPCPreprocessor::ExtractQA(Int_t sourceFXS)
+{
+ //
+ // Read Quality Assurance file from file exchage server
+ //
+
+ UInt_t result=0;
+
+ TList* list = GetFileSources(sourceFXS,"QA");
+
+ if (list && list->GetEntries()>0) {
+
+// only one QA objetc should be available!
+
+ AliTPCdataQA *calQA;
+
+ UInt_t nentries = list->GetEntries();
+ UInt_t index=0;
+ if ( nentries > 1) Log ( "More than one QA entry. First one processed");
+ TObjString* fileNameEntry = (TObjString*) list->At(index);
+ if (fileNameEntry!=NULL) {
+ TString fileName = GetFile(sourceFXS, "QA",
+ fileNameEntry->GetString().Data());
+ TFile *f = TFile::Open(fileName);
+ if (!f) {
+ Log ("Error opening QA file.");
+ result =2;
+ } else {
+ f->GetObject("tpcCalibQA",calQA);
+ if ( calQA ) {
+//
+// Store updated pedestal entry to OCDB
+//
+ AliCDBMetaData metaData;
+ metaData.SetBeamPeriod(0);
+ metaData.SetResponsible("Haavard Helstrup");
+ metaData.SetAliRootVersion(ALIROOT_SVN_BRANCH);
+ metaData.SetComment("Preprocessor AliTPC data base entries.");
+
+ Bool_t storeOK = Store("Calib", "QA", calQA, &metaData, 0, kFALSE);
+ if ( !storeOK ) ++result;
+
+ delete calQA;
+ }
+ }
+ } else {
+ Log ("Error: no QA files on FXS!");
+ result = 2;
+ }
+ } else {
+ Log ("Error: no QA entries in FXS list!");
+ result = 1;
+ }
+ return result;
+}
+
+//______________________________________________________________________________________________
+
+
+UInt_t AliTPCPreprocessor::ExtractAltro(Int_t sourceFXS, TMap* dcsMap)
+{
+ //
+ // Read Altro configuration file from file exchage server
+ // Keep original entry from OCDB in case no new pulser calibration is available
+ //
+ TObjArray *altroObjects=0;
+ AliTPCCalPad *acqStart=0;
+ AliTPCCalPad *zsThr=0;
+ AliTPCCalPad *acqStop=0;
+ AliTPCCalPad *FPED=0;
+ AliTPCCalPad *masked=0;
+ AliTPCCalPad *k1=0, *k2=0, *k3=0;
+ AliTPCCalPad *l1=0, *l2=0, *l3=0;
+ TMap *mapRCUconfig=0;
+
+ AliCDBEntry* entry = GetFromOCDB("Calib", "AltroConfig");
+ if (entry) altroObjects = (TObjArray*)entry->GetObject();
+ if ( altroObjects==NULL ) {
+ Log("AliTPCPreprocsessor: No previous TPC altro calibration entry available.\n");
+ altroObjects = new TObjArray;