+
+
+
+Double_t AliTPCcalibDB::GetVDriftCorrectionTime(Int_t timeStamp, Int_t run, Int_t /*side*/, Int_t mode){
+ //
+ // Get time dependent drift velocity correction
+ // multiplication factor vd = vdnom *(1+vdriftcorr)
+ // Arguments:
+ // mode determines the algorith how to combine the Laser Track, LaserCE and physics tracks
+ // timestamp - timestamp
+ // run - run number
+ // side - the drift velocity per side (possible for laser and CE)
+ //
+ // Notice - Extrapolation outside of calibration range - using constant function
+ //
+ Double_t result=0;
+ // mode 1 automatic mode - according to the distance to the valid calibration
+ // -
+ Double_t deltaP=0, driftP=0, wP = 0.;
+ Double_t deltaITS=0,driftITS=0, wITS= 0.;
+ Double_t deltaLT=0, driftLT=0, wLT = 0.;
+ Double_t deltaCE=0, driftCE=0, wCE = 0.;
+ driftP = fDButil->GetVDriftTPC(deltaP,run,timeStamp);
+ driftITS= fDButil->GetVDriftTPCITS(deltaITS,run,timeStamp);
+ driftCE = fDButil->GetVDriftTPCCE(deltaCE, run,timeStamp,36000,2);
+ driftLT = fDButil->GetVDriftTPCLaserTracks(deltaLT,run,timeStamp,36000,2);
+ deltaITS = TMath::Abs(deltaITS);
+ deltaP = TMath::Abs(deltaP);
+ deltaLT = TMath::Abs(deltaLT);
+ deltaCE = TMath::Abs(deltaCE);
+ if (mode==1) {
+ const Double_t kEpsilon=0.00000000001;
+ const Double_t kdeltaT=360.; // 10 minutes
+ if(TMath::Abs(deltaITS) < 12*kdeltaT) {
+ result = driftITS;
+ } else {
+ wITS = 64.*kdeltaT/(deltaITS +kdeltaT);
+ wLT = 16.*kdeltaT/(deltaLT +kdeltaT);
+ wP = 0. *kdeltaT/(deltaP +kdeltaT);
+ wCE = 1. *kdeltaT/(deltaCE +kdeltaT);
+ //
+ //
+ if (TMath::Abs(driftP)<kEpsilon) wP=0; // invalid calibration
+ if (TMath::Abs(driftITS)<kEpsilon)wITS=0; // invalid calibration
+ if (TMath::Abs(driftLT)<kEpsilon) wLT=0; // invalid calibration
+ if (TMath::Abs(driftCE)<kEpsilon) wCE=0; // invalid calibration
+ if (wP+wITS+wLT+wCE<kEpsilon) return 0;
+ result = (driftP*wP+driftITS*wITS+driftLT*wLT+driftCE*wCE)/(wP+wITS+wLT+wCE);
+ }
+
+
+ }
+
+ return result;
+}
+
+Double_t AliTPCcalibDB::GetTime0CorrectionTime(Int_t timeStamp, Int_t run, Int_t /*side*/, Int_t mode){
+ //
+ // Get time dependent time 0 (trigger delay in cm) correction
+ // additive correction time0 = time0+ GetTime0CorrectionTime
+ // Value etracted combining the vdrift correction using laser tracks and CE and the physics track matchin
+ // Arguments:
+ // mode determines the algorith how to combine the Laser Track and physics tracks
+ // timestamp - timestamp
+ // run - run number
+ // side - the drift velocity per side (possible for laser and CE)
+ //
+ // Notice - Extrapolation outside of calibration range - using constant function
+ //
+ Double_t result=0;
+ if (mode==2) {
+ // TPC-TPC mode
+ result=fDButil->GetTriggerOffsetTPC(run,timeStamp);
+ result *=fParam->GetZLength();
+ }
+ if (mode==1){
+ // TPC-ITS mode
+ Double_t dist=0;
+ result= -fDButil->GetTime0TPCITS(dist, run, timeStamp)*fParam->GetDriftV()/1000000.;
+ }
+ return result;
+
+}
+
+
+
+
+Double_t AliTPCcalibDB::GetVDriftCorrectionGy(Int_t timeStamp, Int_t run, Int_t side, Int_t /*mode*/){
+ //
+ // Get global y correction drift velocity correction factor
+ // additive factor vd = vdnom*(1+GetVDriftCorrectionGy *gy)
+ // Value etracted combining the vdrift correction using laser tracks and CE or TPC-ITS
+ // Arguments:
+ // mode determines the algorith how to combine the Laser Track, LaserCE or TPC-ITS
+ // timestamp - timestamp
+ // run - run number
+ // side - the drift velocity gy correction per side (CE and Laser tracks)
+ //
+ // Notice - Extrapolation outside of calibration range - using constant function
+ //
+ if (run<=0 && fTransform) run = fTransform->GetCurrentRunNumber();
+ UpdateRunInformations(run,kFALSE);
+ TObjArray *array =AliTPCcalibDB::Instance()->GetTimeVdriftSplineRun(run);
+ if (!array) return 0;
+ Double_t result=0;
+
+ // use TPC-ITS if present
+ TGraphErrors *gr= (TGraphErrors*)array->FindObject("ALIGN_ITSB_TPC_VDGY");
+ if(gr) {
+ result = AliTPCcalibDButil::EvalGraphConst(gr,timeStamp);
+
+ // transform from [(cm/mus)/ m] to [1/cm]
+ result /= (fParam->GetDriftV()/1000000.);
+ result /= 100.;
+
+ //printf("result %e \n", result);
+ return result;
+ }
+
+ // use laser if ITS-TPC not present
+ TGraphErrors *laserA= (TGraphErrors*)array->FindObject("GRAPH_MEAN_GLOBALYGRADIENT_LASER_ALL_A");
+ TGraphErrors *laserC= (TGraphErrors*)array->FindObject("GRAPH_MEAN_GLOBALYGRADIENT_LASER_ALL_C");
+
+ if (laserA && laserC){
+ result= (laserA->Eval(timeStamp)+laserC->Eval(timeStamp))*0.5;
+ }
+ if (laserA && side==0){
+ result = (laserA->Eval(timeStamp));
+ }
+ if (laserC &&side==1){
+ result = (laserC->Eval(timeStamp));
+ }
+ //printf("laser result %e \n", -result/250.);
+
+ return -result/250.; //normalized before
+}
+
+AliTPCCalPad* AliTPCcalibDB::MakeDeadMap(Double_t notInMap, const char* nameMappingFile) {
+//
+// Read list of active DDLs from OCDB entry
+// Generate and return AliTPCCalPad containing 1 for all pads in active DDLs,
+// 0 for all pads in non-active DDLs.
+// For DDLs with missing status information (no DCS input point to Shuttle),
+// the value of the AliTPCCalPad entry is determined by the parameter
+// notInMap (default value 1)
+//
+ char chinfo[1000];
+
+ TFile *fileMapping = new TFile(nameMappingFile, "read");
+ AliTPCmapper *mapping = (AliTPCmapper*) fileMapping->Get("tpcMapping");
+ if (!mapping) {
+ snprintf(chinfo,1000,"Failed to get mapping object from %s. ...\n", nameMappingFile);
+ AliError (chinfo);
+ return 0;
+ }
+
+ AliTPCCalPad *deadMap = new AliTPCCalPad("deadMap","deadMap");
+ if (!deadMap) {
+ AliError("Failed to allocate dead map AliTPCCalPad");
+ return 0;
+ }
+
+ /// get list of active DDLs from OCDB entry
+ Int_t idDDL=0;
+ if (!fALTROConfigData ) {
+ AliError("No ALTRO config OCDB entry available");
+ return 0;
+ }
+ TMap *activeDDL = (TMap*)fALTROConfigData->FindObject("DDLArray");
+ TObjString *ddlArray=0;
+ if (activeDDL) {
+ ddlArray = (TObjString*)activeDDL->GetValue("DDLArray");
+ if (!ddlArray) {
+ AliError("Empty list of active DDLs in OCDB entry");
+ return 0;
+ }
+ } else {
+ AliError("List of active DDLs not available in OCDB entry");
+ return 0;
+ }
+ TString arrDDL=ddlArray->GetString();
+ Int_t offset = mapping->GetTpcDdlOffset();
+ Double_t active;
+ for (Int_t i=0; i<mapping->GetNumDdl(); i++) {
+ idDDL= i+offset;
+ if (idDDL<0) continue;
+ Int_t patch = mapping->GetPatchFromEquipmentID(idDDL);
+ if (patch<0) continue;
+ Int_t roc=mapping->GetRocFromEquipmentID(idDDL);
+ if (roc<0) continue;
+ AliTPCCalROC *calRoc=deadMap->GetCalROC(roc);
+ if (calRoc) {
+ for ( Int_t branch = 0; branch < 2; branch++ ) {
+ for ( Int_t fec = 0; fec < mapping->GetNfec(patch, branch); fec++ ) {
+ for ( Int_t altro = 0; altro < 8; altro++ ) {
+ for ( Int_t channel = 0; channel < 16; channel++ ) {
+ Int_t hwadd = mapping->CodeHWAddress(branch, fec, altro, channel);
+ Int_t row = mapping->GetPadRow(patch, hwadd); // row in a ROC (IROC or OROC)
+// Int_t globalrow = mapping.GetGlobalPadRow(patch, hwadd); // row in full sector (IROC plus OROC)
+ Int_t pad = mapping->GetPad(patch, hwadd);
+ if (!TString(arrDDL[i]).IsDigit()) {
+ active = notInMap;
+ } else {
+ active=TString(arrDDL[i]).Atof();
+ }
+ calRoc->SetValue(row,pad,active);
+ } // end channel for loop
+ } // end altro for loop
+ } // end fec for loop
+ } // end branch for loop
+ } // valid calROC
+ } // end loop on active DDLs
+ return deadMap;
+}
+
+
+
+AliTPCCorrection * AliTPCcalibDB::GetTPCComposedCorrection(Float_t field) const{
+ //
+ // GetComposed correction for given field setting
+ // If not specific correction for field used return correction for all field
+ // - Complication needed to gaurantee OCDB back compatibility
+ // - Not neeeded for the new space point correction
+ if (!fComposedCorrectionArray) return 0;
+ if (field>0.1 && fComposedCorrectionArray->At(1)) {
+ return (AliTPCCorrection *)fComposedCorrectionArray->At(1);
+ }
+ if (field<-0.1 &&fComposedCorrectionArray->At(2)) {
+ return (AliTPCCorrection *)fComposedCorrectionArray->At(2);
+ }
+ return (AliTPCCorrection *)fComposedCorrectionArray->At(0);
+
+}
+
+
+AliTPCCorrection * AliTPCcalibDB::GetTPCComposedCorrectionDelta() const{
+ //
+ // GetComposedCorrection delta
+ // Delta is time dependent - taken form the CalibTime OCDB entry
+ //
+ if (!fComposedCorrectionArray) return 0;
+ if (fRun<0) return 0;
+ if (fDriftCorrectionArray.GetEntriesFast()<=fRun) return 0;
+ if (fDriftCorrectionArray.At(fRun)==0) return 0;
+ if (fComposedCorrectionArray->GetEntriesFast()<=4) {
+ fComposedCorrectionArray->Expand(5);
+ TObjArray * timeArray =(TObjArray*)(fDriftCorrectionArray.At(fRun));
+ AliTPCCorrection * correctionTime = (AliTPCCorrection *)timeArray->FindObject("FitCorrectionTime");
+ if (correctionTime){
+ correctionTime->Init();
+ fComposedCorrectionArray->AddAt(correctionTime,4); //add time dependent c
+ }
+ }
+ return (AliTPCCorrection *)fComposedCorrectionArray->At(4); //
+}
+