fLblValueX->SetTextJustify(kTextLeft);
fContValues->AddFrame(fLblValueX, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
//value x
- fLblValueXVal = new TGLabel(fContValues, "00000.000");
+ fLblValueXVal = new TGLabel(fContValues, "00.000e+00");
fLblValueXVal->SetTextJustify(kTextRight);
fContValues->AddFrame(fLblValueXVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
//value label y
fLblValueY->SetTextJustify(kTextLeft);
fContValues->AddFrame(fLblValueY, new TGLayoutHints(kLHintsNormal, 0, 0, 0, 0));
//value y
- fLblValueYVal = new TGLabel(fContValues, "00000.000");
+ fLblValueYVal = new TGLabel(fContValues, "00.000e+00");
fLblValueYVal->SetTextJustify(kTextRight);
fContValues->AddFrame(fLblValueYVal, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 0, 0, 0, 0));
// draw button
//
// retrieve tree from file
//
- // TString s=gSystem->GetFromPipe(Form("ls %s",fileName));
- TString s=fileName;
+ //TString s=gSystem->GetFromPipe(Form("ls %s",fileName));
+ TString s(fileName);
TObjArray *arr=s.Tokenize("\n");
TIter next(arr);
TObject *o=0;
//test if branch is active
active=fConfigParser->GetValue(branchName.Data(),kBranchOnOff);
id=(*fConfigParser)()->IndexOf(key);
- branchTitle=fConfigParser->GetData(key,kBranchTitle);
+// branchTitle=fConfigParser->GetData(key,kBranchTitle);
calibType=fConfigParser->GetData(key,kCalibType);
}
else{
if (fCurrentGraph) {
delete fCurrentGraph;
fCurrentGraph=0x0;
- //fCurrentHist in case of graph is the internal histogram,
- // which is deletet by the graph itself.
+ //fCurrentHist in case of graph is the interrnal histogram,
+ // which is deleted by the graph itself.
+ fCurrentHist=0x0;
+ }
+ if (fCurrentHist) {
+ delete fCurrentHist;
fCurrentHist=0x0;
}
- if (fCurrentHist) delete fCurrentHist;
//select data
fTree->Draw(drawString.Data(),cutString.Data(),optString.Data());
if (fTree->GetSelectedRows()==-1) return;
title=Form("%s:Time;Time;%s",fDrawString.Data(),yname.Data());
} else {
drawGraph=kFALSE;
+ title=Form("%s:%s",fDrawString.Data(),yname.Data());
}
}
//create graph according to selection
} else {
fCurrentGraph=0x0;
Float_t add=TMath::Abs(fValuesY.Min()*.05);
- fCurrentHist=new TH1D("hist",Form("%s;%s",fDrawString.Data(),fDrawString.Data()),100,fValuesY.Min()-add,fValuesY.Max()+add);
+ fCurrentHist=new TH1D("hist",title.Data(),100,fValuesY.Min()-add,fValuesY.Max()+add);
fCurrentHist->FillN(fValuesY.GetNrows(),fValuesY.GetMatrixArray(),0);
fCurrentHist->Draw();
}
if (!fCurrentGraph) {
fLblRunNumberVal->SetText(Form("%05u",run));
fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u:%02u:%02u",dd,mm,yy,HH,MM,SS));
- fLblValueXVal->SetText(Form("%.3f", valx));
- fLblValueYVal->SetText(Form("%.3f", valy));
+ fLblValueXVal->SetText(Form("%.3e", valx));
+ fLblValueYVal->SetText(Form("%.3e", valy));
return;
}
TVirtualPad *padsave=gPad;
fLblRunNumberVal->SetText(Form("%05u",run));
fLblRunTimeVal->SetText(Form("%02u.%02u.%04u\n%02u.%02u.%02u",dd,mm,yy,HH,MM,SS));
if (fIsCustomDraw){
- fLblValueXVal->SetText(Form("%.3f", valx));
+ fLblValueXVal->SetText(Form("%.3e", valx));
}else{
if (fRadioXrun->GetState()==kButtonDown){
fLblValueXVal->SetText("Run");
fLblValueXVal->SetText("Time");
}
}
- fLblValueYVal->SetText(Form("%.3f", valy));
+ fLblValueYVal->SetText(Form("%.3e", valy));
padsave->cd();
if (run==0) return;
if (event == kButton1Double ){
void HandleButtonsDrawSel(Int_t id = -1);
void MouseMove(Int_t event, Int_t x, Int_t y, TObject */*selected*/);
-// private:
+private:
TFile* fFile; //file that keeps the tree
TChain* fTree; //internal tree
AliTPCCalibViewerGUI *fCalibViewerGUI; //calib viewer gui used to display verbose information for one run
void FillCalibTypes();
void SetInitialValues();
const char* SubstituteUnderscores(const char* in);
-
-private:
+
AliTPCCalibViewerGUItime(const AliTPCCalibViewerGUItime &v);
AliTPCCalibViewerGUItime &operator = (const AliTPCCalibViewerGUItime &v); // assignment operator
return vdrift;
}
+Float_t AliTPCcalibDB::GetCEdriftTime(Int_t run, Int_t sector, Double_t timeStamp, Int_t *entries)
+{
+ //
+ // GetCE drift time information for 'sector'
+ // sector 72 is the mean drift time of the A-Side
+ // sector 73 is the mean drift time of the C-Side
+ // it timestamp==-1 return mean value
+ //
+ AliTPCcalibDB::Instance()->SetRun(run);
+ TGraph *gr=AliTPCcalibDB::Instance()->GetCErocTgraph(sector);
+ if (!gr||sector<0||sector>73) {
+ if (entries) *entries=0;
+ return 0.;
+ }
+ Float_t val=0.;
+ if (timeStamp==-1.){
+ val=gr->GetMean(2);
+ }else{
+ for (Int_t ipoint=0;ipoint<gr->GetN();++ipoint){
+ Double_t x,y;
+ gr->GetPoint(ipoint,x,y);
+ if (x<timeStamp) continue;
+ val=y;
+ break;
+ }
+ }
+ return val;
+}
+
+Float_t AliTPCcalibDB::GetCEchargeTime(Int_t run, Int_t sector, Double_t timeStamp, Int_t *entries)
+{
+ //
+ // GetCE mean charge for 'sector'
+ // it timestamp==-1 return mean value
+ //
+ AliTPCcalibDB::Instance()->SetRun(run);
+ TGraph *gr=AliTPCcalibDB::Instance()->GetCErocQgraph(sector);
+ if (!gr||sector<0||sector>71) {
+ if (entries) *entries=0;
+ return 0.;
+ }
+ Float_t val=0.;
+ if (timeStamp==-1.){
+ val=gr->GetMean(2);
+ }else{
+ for (Int_t ipoint=0;ipoint<gr->GetN();++ipoint){
+ Double_t x,y;
+ gr->GetPoint(ipoint,x,y);
+ if (x<timeStamp) continue;
+ val=y;
+ break;
+ }
+ }
+ return val;
+}
+
Float_t AliTPCcalibDB::GetDCSSensorValue(AliDCSSensorArray *arr, Int_t timeStamp, const char * sensorName, Int_t sigDigits)
{
//
const TString sensorNameString(sensorName);
AliDCSSensor *sensor = arr->GetSensor(sensorNameString);
if (!sensor) return val;
- val=sensor->GetValue(timeStamp);
+ //use the dcs graph if possible
+ TGraph *gr=sensor->GetGraph();
+ if (gr){
+ for (Int_t ipoint=0;ipoint<gr->GetN();++ipoint){
+ Double_t x,y;
+ gr->GetPoint(ipoint,x,y);
+ Int_t time=sensor->GetStartTime()+x*3600; //time in graph is hours
+ if (time<timeStamp) continue;
+ val=y;
+ break;
+ }
+ //if val is still 0, test if if the requested time if within 5min of the first/last
+ //data point. If this is the case return the firs/last entry
+ //the timestamps might not be syncronised for all calibration types, sometimes a 'pre'
+ //and 'pos' period is requested. Especially to the HV this is not the case!
+ //first point
+ if (val==0 ){
+ Double_t x,y;
+ gr->GetPoint(0,x,y);
+ Int_t time=sensor->GetStartTime()+x*3600; //time in graph is hours
+ if ((time-timeStamp)<5*60) val=y;
+ }
+ //last point
+ if (val==0 ){
+ Double_t x,y;
+ gr->GetPoint(gr->GetN()-1,x,y);
+ Int_t time=sensor->GetStartTime()+x*3600; //time in graph is hours
+ if ((timeStamp-time)<5*60) val=y;
+ }
+ } else {
+ val=sensor->GetValue(timeStamp);
+ }
if (sigDigits>=0){
val=(Float_t)TMath::Floor(val * TMath::Power(10., sigDigits) + .5) / TMath::Power(10., sigDigits);
}
const TString sensorNameString(sensorName);
AliDCSSensor *sensor = arr->GetSensor(sensorNameString);
if (!sensor) return val;
-
- //current hack until the spline fit problem is solved
- if (!sensor->GetFit()) return val;
- Int_t nKnots=sensor->GetFit()->GetKnots();
- Double_t tMid=(sensor->GetEndTime()-sensor->GetStartTime())/2.;
- for (Int_t iKnot=0;iKnot<nKnots;++iKnot){
- if (sensor->GetFit()->GetX()[iKnot]>tMid/3600.) break;
- val=(Float_t)sensor->GetFit()->GetY0()[iKnot];
+
+ //use dcs graph if it exists
+ TGraph *gr=sensor->GetGraph();
+ if (gr){
+ val=gr->GetMean(2);
+ } else {
+ //if we don't have the dcs graph, try to get some meaningful information
+ if (!sensor->GetFit()) return val;
+ Int_t nKnots=sensor->GetFit()->GetKnots();
+ Double_t tMid=(sensor->GetEndTime()-sensor->GetStartTime())/2.;
+ for (Int_t iKnot=0;iKnot<nKnots;++iKnot){
+ if (sensor->GetFit()->GetX()[iKnot]>tMid/3600.) break;
+ val=(Float_t)sensor->GetFit()->GetY0()[iKnot];
+ }
}
-/*
- TGraph *gr=sensor->MakeGraph();
- if (gr) val=(Float_t)gr->GetMean(2);
- delete gr;
- */
if (sigDigits>=0){
val/=10;
val=(Float_t)TMath::Floor(val * TMath::Power(10., sigDigits) + .5) / TMath::Power(10., sigDigits);
return vdrift->GetPTRelative(timeSec,side);
}
-
-void AliTPCcalibDB::ProcessEnv(const char * runList){
- //
- // Example test function - how to use the environment variables
- // runList - ascii file with run numbers
- // output - dcsTime.root file with tree
-
- ifstream in;
- in.open(runList);
- Int_t irun=0;
- TTreeSRedirector *pcstream = new TTreeSRedirector("dcsTime.root");
- while(in.good()) {
- in >> irun;
- if (irun==0) continue;
- printf("Processing run %d\n",irun);
- AliDCSSensor * sensorPressure = AliTPCcalibDB::Instance()->GetPressureSensor(irun);
- if (!sensorPressure) continue;
- AliTPCSensorTempArray * tempArray = AliTPCcalibDB::Instance()->GetTemperatureSensor(irun);
- AliTPCTempMap * tempMap = new AliTPCTempMap(tempArray);
- AliDCSSensorArray* goofieArray = AliTPCcalibDB::Instance()->GetGoofieSensors(irun);
- //
- Int_t startTime = sensorPressure->GetStartTime();
- Int_t endTime = sensorPressure->GetEndTime();
- Int_t dtime = TMath::Max((endTime-startTime)/20,10*60);
- for (Int_t itime=startTime; itime<endTime; itime+=dtime){
- //
- TTimeStamp tstamp(itime);
- Float_t valuePressure = sensorPressure->GetValue(tstamp);
-
- TLinearFitter * fitter = 0;
- TVectorD vecTemp[10];
- if (itime<tempArray->GetStartTime().GetSec() || itime>tempArray->GetEndTime().GetSec()){
- }else{
- for (Int_t itype=0; itype<5; itype++)
- for (Int_t iside=0; iside<2; iside++){
- fitter= tempMap->GetLinearFitter(itype,iside,tstamp);
- if (!fitter) continue;
- fitter->Eval(); fitter->GetParameters(vecTemp[itype+iside*5]);
- delete fitter;
- }
- }
-
- TVectorD vecGoofie, vecEntries, vecMean, vecMedian,vecRMS;
- if (goofieArray){
- vecGoofie.ResizeTo(goofieArray->NumSensors());
- ProcessGoofie(goofieArray, vecEntries ,vecMedian, vecMean, vecRMS);
- //
- for (Int_t isensor=0; isensor<goofieArray->NumSensors();isensor++){
- AliDCSSensor *gsensor = goofieArray->GetSensor(isensor);
- if (gsensor){
- vecGoofie[isensor] = gsensor->GetValue(tstamp);
- }
- }
- }
-
-
- //tempMap->GetLinearFitter(0,0,itime);
- (*pcstream)<<"dcs"<<
- "run="<<irun<<
- "time="<<itime<<
- "goofie.="<<&vecGoofie<<
- "goofieE.="<<&vecEntries<<
- "goofieMean.="<<&vecMean<<
- "goofieMedian.="<<&vecMedian<<
- "goofieRMS.="<<&vecRMS<<
- "press="<<valuePressure<<
- "temp00.="<<&vecTemp[0]<<
- "temp10.="<<&vecTemp[1]<<
- "temp20.="<<&vecTemp[2]<<
- "temp30.="<<&vecTemp[3]<<
- "temp40.="<<&vecTemp[4]<<
- "temp01.="<<&vecTemp[5]<<
- "temp11.="<<&vecTemp[6]<<
- "temp21.="<<&vecTemp[7]<<
- "temp31.="<<&vecTemp[8]<<
- "temp41.="<<&vecTemp[9]<<
- "\n";
- }
- }
- delete pcstream;
-}
-
-
-void AliTPCcalibDB::ProcessGoofie( AliDCSSensorArray* goofieArray, TVectorD & vecEntries, TVectorD & vecMedian, TVectorD &vecMean, TVectorD &vecRMS){
- /*
-
- 1 TPC_ANODE_I_A00_STAT
- 2 TPC_DVM_CO2
- 3 TPC_DVM_DriftVelocity
- 4 TPC_DVM_FCageHV
- 5 TPC_DVM_GainFar
- 6 TPC_DVM_GainNear
- 7 TPC_DVM_N2
- 8 TPC_DVM_NumberOfSparks
- 9 TPC_DVM_PeakAreaFar
- 10 TPC_DVM_PeakAreaNear
- 11 TPC_DVM_PeakPosFar
- 12 TPC_DVM_PeakPosNear
- 13 TPC_DVM_PickupHV
- 14 TPC_DVM_Pressure
- 15 TPC_DVM_T1_Over_P
- 16 TPC_DVM_T2_Over_P
- 17 TPC_DVM_T_Over_P
- 18 TPC_DVM_TemperatureS1
- */
- //
- //
- // TVectorD vecMedian; TVectorD vecEntries; TVectorD vecMean; TVectorD vecRMS;
- Double_t kEpsilon=0.0000000001;
- Double_t kBig=100000000000.;
- Int_t nsensors = goofieArray->NumSensors();
- vecEntries.ResizeTo(nsensors);
- vecMedian.ResizeTo(nsensors);
- vecMean.ResizeTo(nsensors);
- vecRMS.ResizeTo(nsensors);
- TVectorF values;
- for (Int_t isensor=0; isensor<goofieArray->NumSensors();isensor++){
- AliDCSSensor *gsensor = goofieArray->GetSensor(isensor);
- if (gsensor && gsensor->GetGraph()){
- Int_t npoints = gsensor->GetGraph()->GetN();
- // filter zeroes
- values.ResizeTo(npoints);
- Int_t nused =0;
- for (Int_t ipoint=0; ipoint<npoints; ipoint++){
- if (TMath::Abs(gsensor->GetGraph()->GetY()[ipoint])>kEpsilon &&
- TMath::Abs(gsensor->GetGraph()->GetY()[ipoint])<kBig ){
- values[nused]=gsensor->GetGraph()->GetY()[ipoint];
- nused++;
- }
- }
- //
- vecEntries[isensor]= nused;
- if (nused>1){
- vecMedian[isensor] = TMath::Median(nused,values.GetMatrixArray());
- vecMean[isensor] = TMath::Mean(nused,values.GetMatrixArray());
- vecRMS[isensor] = TMath::RMS(nused,values.GetMatrixArray());
- }
- }
- }
-}
-
-
-
AliGRPObject * AliTPCcalibDB::MakeGRPObjectFromMap(TMap *map){
//
// Function to covert old GRP run information from TMap to GRPObject
TObjArray* GetCErocQtime() const {return fCEData?static_cast<TObjArray*>(fCEData->FindObject("rocQtime")):0;}
TGraph* GetCErocTgraph(const Int_t roc)const {return GetCErocTtime()?static_cast<TGraph*>(GetCErocTtime()->At(roc)):0;}
TGraph* GetCErocQgraph(const Int_t roc)const {return GetCErocQtime()?static_cast<TGraph*>(GetCErocQtime()->At(roc)):0;}
+ static Float_t GetCEdriftTime(Int_t run, Int_t sector, Double_t timeStamp=-1., Int_t *entries=0);
+ static Float_t GetCEchargeTime(Int_t run, Int_t sector, Double_t timeStamp=-1., Int_t *entries=0);
//
AliTPCSensorTempArray* GetTemperature() {return fTemperature;}
AliTPCParam* GetParameters(){return fParam;}
static void RegisterExB(Int_t index, Float_t bz, Bool_t bdelete);
//
//
- static void ProcessGoofie( AliDCSSensorArray* goofieArray, TVectorD & vecEntries, TVectorD & vecMedian, TVectorD &vecMean, TVectorD &vecRMS);
- static void ProcessEnv(const char * runList);
AliGRPObject * MakeGRPObjectFromMap(TMap *map);
//Create a tree suited for diplaying with the AliTPCCalibViewerGUI
--- /dev/null
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice *
+ * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+
+///////////////////////////////////////////////////////////////////////////////
+// //
+// Class providing the calculation of derived quantities (mean,rms,fits,...) //
+// of calibration entries //
+/*
+
+
+*/
+////////////////////////////////////////////////////////////////////////////////
+
+#include <TMath.h>
+#include <TVectorT.h>
+#include <TObjArray.h>
+#include <TGraph.h>
+
+#include <AliDCSSensorArray.h>
+#include <AliDCSSensor.h>
+#include "AliTPCcalibDB.h"
+#include "AliTPCCalPad.h"
+#include "AliTPCCalROC.h"
+#include "AliTPCROC.h"
+#include "AliTPCmapper.h"
+#include "AliTPCParam.h"
+
+#include "AliTPCcalibDButil.h"
+
+ClassImp(AliTPCcalibDButil)
+AliTPCcalibDButil::AliTPCcalibDButil() :
+ TObject(),
+ fCalibDB(AliTPCcalibDB::Instance()),
+ fPadNoise(0x0),
+ fPedestals(0x0),
+ fPulserTmean(0x0),
+ fPulserTrms(0x0),
+ fPulserQmean(0x0),
+ fPulserOutlier(new AliTPCCalPad("PulserOutliers","PulserOutliers")),
+ fCETmean(0x0),
+ fCETrms(0x0),
+ fCEQmean(0x0),
+ fALTROMasked(0x0),
+ fGoofieArray(0x0),
+ fMapper(new AliTPCmapper(0x0)),
+ fNpulserOutliers(-1),
+ fIrocTimeOffset(.2),
+ fCETmaxLimitAbs(1.5),
+ fPulTmaxLimitAbs(1.5),
+ fPulQmaxLimitAbs(5),
+ fPulQminLimit(11)
+{
+ //
+ // Default ctor
+ //
+}
+//_____________________________________________________________________________________
+AliTPCcalibDButil::~AliTPCcalibDButil()
+{
+ //
+ // dtor
+ //
+ delete fPulserOutlier;
+ delete fMapper;
+}
+//_____________________________________________________________________________________
+void AliTPCcalibDButil::UpdateFromCalibDB()
+{
+ //
+ // Update pointers from calibDB
+ //
+ fPadNoise=fCalibDB->GetPadNoise();
+ fPedestals=fCalibDB->GetPedestals();
+ fPulserTmean=fCalibDB->GetPulserTmean();
+ fPulserTrms=fCalibDB->GetPulserTrms();
+ fPulserQmean=fCalibDB->GetPulserQmean();
+ fCETmean=fCalibDB->GetCETmean();
+ fCETrms=fCalibDB->GetCETrms();
+ fCEQmean=fCalibDB->GetCEQmean();
+ fALTROMasked=fCalibDB->GetALTROMasked();
+ fGoofieArray=fCalibDB->GetGoofieSensors(fCalibDB->GetRun());
+ UpdatePulserOutlierMap();
+}
+//_____________________________________________________________________________________
+void AliTPCcalibDButil::ProcessCEdata(const char* fitFormula, TVectorD &fitResultsA, TVectorD &fitResultsC, Int_t &noutliersCE)
+{
+ //
+ // Process the CE data for this run
+ // the return TVectorD arrays contian the results of the fit
+ // noutliersCE contains the number of pads marked as outliers,
+ // not including masked and edge pads
+ //
+
+ //retrieve CE and ALTRO data
+ if (!fCETmean){
+ TString fitString(fitFormula);
+ fitString.ReplaceAll("++","#");
+ Int_t ndim=fitString.CountChar('#')+2;
+ fitResultsA.ResizeTo(ndim);
+ fitResultsC.ResizeTo(ndim);
+ fitResultsA.Zero();
+ fitResultsC.Zero();
+ noutliersCE=-1;
+ return;
+ }
+ noutliersCE=0;
+ //create outlier map
+ AliTPCCalPad out("out","out");
+ AliTPCCalROC *rocMasked=0x0;
+ //loop over all channels
+ for (UInt_t iroc=0;iroc<fCETmean->kNsec;++iroc){
+ AliTPCCalROC *rocData=fCETmean->GetCalROC(iroc);
+ if (fALTROMasked) rocMasked=fALTROMasked->GetCalROC(iroc);
+ AliTPCCalROC *rocOut=out.GetCalROC(iroc);
+ if (!rocData) continue;
+ //add time offset to IROCs
+ if (iroc<AliTPCROC::Instance()->GetNInnerSector())
+ rocData->Add(fIrocTimeOffset);
+ //select outliers
+ UInt_t nrows=rocData->GetNrows();
+ for (UInt_t irow=0;irow<nrows;++irow){
+ UInt_t npads=rocData->GetNPads(irow);
+ for (UInt_t ipad=0;ipad<npads;++ipad){
+ //exclude masked pads
+ if (rocMasked && rocMasked->GetValue(irow,ipad)) {
+ rocOut->SetValue(iroc,ipad,1);
+ continue;
+ }
+ //exclude edge pads
+ if (ipad==0||ipad==npads-1) rocOut->SetValue(iroc,ipad,1);
+ Float_t valTmean=rocData->GetValue(iroc,ipad);
+ //exclude values that are exactly 0
+ if (valTmean==0) {
+ rocOut->SetValue(iroc,ipad,1);
+ ++noutliersCE;
+ }
+ // exclude channels with too large variations
+ if (TMath::Abs(valTmean)>fCETmaxLimitAbs) {
+ rocOut->SetValue(iroc,ipad,1);
+ ++noutliersCE;
+ }
+ }
+ }
+ }
+ //perform fit
+ TMatrixD dummy;
+ Float_t chi2A,chi2C;
+ fCETmean->GlobalSidesFit(&out,fitFormula,fitResultsA,fitResultsC,dummy,dummy,chi2A,chi2C);
+}
+//_____________________________________________________________________________________
+void AliTPCcalibDButil::ProcessCEgraphs(TVectorD &vecTEntries, TVectorD &vecTMean, TVectorD &vecTRMS, TVectorD &vecTMedian,
+ TVectorD &vecQEntries, TVectorD &vecQMean, TVectorD &vecQRMS, TVectorD &vecQMedian,
+ Float_t &driftTimeA, Float_t &driftTimeC )
+{
+ //
+ // Calculate statistical information from the CE graphs for drift time and charge
+ //
+
+ //reset arrays
+ vecTEntries.ResizeTo(72);
+ vecTMean.ResizeTo(72);
+ vecTRMS.ResizeTo(72);
+ vecTMedian.ResizeTo(72);
+ vecQEntries.ResizeTo(72);
+ vecQMean.ResizeTo(72);
+ vecQRMS.ResizeTo(72);
+ vecQMedian.ResizeTo(72);
+ vecTEntries.Zero();
+ vecTMean.Zero();
+ vecTRMS.Zero();
+ vecTMedian.Zero();
+ vecQEntries.Zero();
+ vecQMean.Zero();
+ vecQRMS.Zero();
+ vecQMedian.Zero();
+ driftTimeA=0;
+ driftTimeC=0;
+ TObjArray *arrT=fCalibDB->GetCErocTtime();
+ TObjArray *arrQ=fCalibDB->GetCErocQtime();
+ if (arrT){
+ for (Int_t isec=0;isec<74;++isec){
+ TGraph *gr=(TGraph*)arrT->At(isec);
+ if (!gr) continue;
+ TVectorD values;
+ Int_t npoints = gr->GetN();
+ values.ResizeTo(npoints);
+ Int_t nused =0;
+ for (Int_t ipoint=0; ipoint<npoints; ipoint++){
+ if (gr->GetY()[ipoint]>500 && gr->GetY()[ipoint]<1000 ){
+ values[nused]=gr->GetY()[ipoint];
+ nused++;
+ }
+ }
+ //
+ if (isec<72) vecTEntries[isec]= nused;
+ if (nused>1){
+ if (isec<72){
+ vecTMedian[isec] = TMath::Median(nused,values.GetMatrixArray());
+ vecTMean[isec] = TMath::Mean(nused,values.GetMatrixArray());
+ vecTRMS[isec] = TMath::RMS(nused,values.GetMatrixArray());
+ } else if (isec==72){
+ driftTimeA=TMath::Median(nused,values.GetMatrixArray());
+ } else if (isec==73){
+ driftTimeC=TMath::Median(nused,values.GetMatrixArray());
+ }
+ }
+ }
+ }
+ if (arrQ){
+ for (Int_t isec=0;isec<72;++isec){
+ TGraph *gr=(TGraph*)arrQ->At(isec);
+ if (!gr) continue;
+ TVectorD values;
+ Int_t npoints = gr->GetN();
+ values.ResizeTo(npoints);
+ Int_t nused =0;
+ for (Int_t ipoint=0; ipoint<npoints; ipoint++){
+ if (gr->GetY()[ipoint]>500 && gr->GetY()[ipoint]<1000 ){
+ values[nused]=gr->GetY()[ipoint];
+ nused++;
+ }
+ }
+ //
+ vecTEntries[isec]= nused;
+ if (nused>1){
+ vecQMedian[isec] = TMath::Median(nused,values.GetMatrixArray());
+ vecQMean[isec] = TMath::Mean(nused,values.GetMatrixArray());
+ vecQRMS[isec] = TMath::RMS(nused,values.GetMatrixArray());
+ }
+ }
+ }
+}
+
+//_____________________________________________________________________________________
+void AliTPCcalibDButil::ProcessNoiseData(TVectorD &vNoiseMean, TVectorD &vNoiseMeanSenRegions,
+ TVectorD &vNoiseRMS, TVectorD &vNoiseRMSSenRegions,
+ Int_t &nonMaskedZero)
+{
+ //
+ // process noise data
+ // vNoiseMean/RMS contains the Mean/RMS noise of the complete TPC [0], IROCs only [1],
+ // OROCs small pads [2] and OROCs large pads [3]
+ // vNoiseMean/RMSsenRegions constains the same information, but only for the sensitive regions (edge pads, corners, IROC spot)
+ // nonMaskedZero contains the number of pads which show zero noise and were not masked. This might indicate an error
+ //
+
+ //set proper size and reset
+ const UInt_t infoSize=4;
+ vNoiseMean.ResizeTo(infoSize);
+ vNoiseMeanSenRegions.ResizeTo(infoSize);
+ vNoiseRMS.ResizeTo(infoSize);
+ vNoiseRMSSenRegions.ResizeTo(infoSize);
+ vNoiseMean.Zero();
+ vNoiseMeanSenRegions.Zero();
+ vNoiseRMS.Zero();
+ vNoiseRMSSenRegions.Zero();
+ nonMaskedZero=0;
+ //counters
+ TVectorD c(infoSize);
+ TVectorD cs(infoSize);
+ //tpc parameters
+ AliTPCParam par;
+ par.Update();
+ //retrieve noise and ALTRO data
+ if (!fPadNoise) return;
+ AliTPCCalROC *rocMasked=0x0;
+ //create IROC, OROC1, OROC2 and sensitive region masks
+ for (UInt_t isec=0;isec<AliTPCCalPad::kNsec;++isec){
+ AliTPCCalROC *noiseROC=fPadNoise->GetCalROC(isec);
+ if (fALTROMasked) rocMasked=fALTROMasked->GetCalROC(isec);
+ UInt_t nrows=noiseROC->GetNrows();
+ for (UInt_t irow=0;irow<nrows;++irow){
+ UInt_t npads=noiseROC->GetNPads(irow);
+ for (UInt_t ipad=0;ipad<npads;++ipad){
+ //don't use masked channels;
+ if (rocMasked && rocMasked->GetValue(irow,ipad)) continue;
+ Float_t noiseVal=noiseROC->GetValue(irow,ipad);
+ //check if noise==0
+ if (noiseVal==0) {
+ ++nonMaskedZero;
+ continue;
+ }
+ //check for nan
+ if ( !(noiseVal<10000000) ){
+ printf ("Warning: nan detected in (sec,row,pad - val): %02d,%02d,%03d - %.1f\n",isec,irow,ipad,noiseVal);
+ continue;
+ }
+ Int_t cpad=(Int_t)ipad-(Int_t)npads/2;
+ Int_t masksen=1; // sensitive pards are not masked (0)
+ if (ipad<2||npads-ipad-1<2) masksen=0; //don't mask edge pads (sensitive)
+ if (isec<AliTPCROC::Instance()->GetNInnerSector()){
+ //IROCs
+ if (irow>19&&irow<46){
+ if (TMath::Abs(cpad)<7) masksen=0; //IROC spot
+ }
+ Int_t type=1;
+ vNoiseMean[type]+=noiseVal;
+ vNoiseRMS[type]+=noiseVal*noiseVal;
+ ++c[type];
+ if (!masksen){
+ vNoiseMeanSenRegions[type]+=noiseVal;
+ vNoiseRMSSenRegions[type]+=noiseVal*noiseVal;
+ ++cs[type];
+ }
+ } else {
+ //OROCs
+ //define sensive regions
+ if ((nrows-irow-1)<3) masksen=0; //last three rows in OROCs are sensitive
+ if ( irow>75 ){
+ Int_t padEdge=(Int_t)TMath::Min(ipad,npads-ipad);
+ if (padEdge<((((Int_t)irow-76)/4+1))*2) masksen=0; //OROC outer corners are sensitive
+ }
+ if ((Int_t)irow<par.GetNRowUp1()){
+ //OROC1
+ Int_t type=2;
+ vNoiseMean[type]+=noiseVal;
+ vNoiseRMS[type]+=noiseVal*noiseVal;
+ ++c[type];
+ if (!masksen){
+ vNoiseMeanSenRegions[type]+=noiseVal;
+ vNoiseRMSSenRegions[type]+=noiseVal*noiseVal;
+ ++cs[type];
+ }
+ }else{
+ //OROC2
+ Int_t type=3;
+ vNoiseMean[type]+=noiseVal;
+ vNoiseRMS[type]+=noiseVal*noiseVal;
+ ++c[type];
+ if (!masksen){
+ vNoiseMeanSenRegions[type]+=noiseVal;
+ vNoiseRMSSenRegions[type]+=noiseVal*noiseVal;
+ ++cs[type];
+ }
+ }
+ }
+ //whole tpc
+ Int_t type=0;
+ vNoiseMean[type]+=noiseVal;
+ vNoiseRMS[type]+=noiseVal*noiseVal;
+ ++c[type];
+ if (!masksen){
+ vNoiseMeanSenRegions[type]+=noiseVal;
+ vNoiseRMSSenRegions[type]+=noiseVal*noiseVal;
+ ++cs[type];
+ }
+ }//end loop pads
+ }//end loop rows
+ }//end loop sectors (rocs)
+
+ //calculate mean and RMS
+ const Double_t verySmall=0.0000000001;
+ for (UInt_t i=0;i<infoSize;++i){
+ Double_t mean=0;
+ Double_t rms=0;
+ Double_t meanSen=0;
+ Double_t rmsSen=0;
+
+ if (c[i]>verySmall){
+// printf ("i: %d - m: %.3f, c: %.0f, r: %.3f\n",i,vNoiseMean[i],c[i],vNoiseRMS[i]);
+ mean=vNoiseMean[i]/c[i];
+ rms=vNoiseRMS[i];
+ rms=TMath::Sqrt(TMath::Abs(rms/c[i]-mean*mean));
+ }
+ vNoiseMean[i]=mean;
+ vNoiseRMS[i]=rms;
+
+ if (cs[i]>verySmall){
+ meanSen=vNoiseMeanSenRegions[i]/cs[i];
+ rmsSen=vNoiseRMSSenRegions[i];
+ rmsSen=TMath::Sqrt(TMath::Abs(rmsSen/cs[i]-meanSen*meanSen));
+ }
+ vNoiseMeanSenRegions[i]=meanSen;
+ vNoiseRMSSenRegions[i]=rmsSen;
+ }
+}
+
+//_____________________________________________________________________________________
+void AliTPCcalibDButil::ProcessPulser(TVectorD &vMeanTime)
+{
+ //
+ // Process the Pulser information
+ // vMeanTime: pulser mean time position in IROC-A, IROC-C, OROC-A, OROC-C
+ //
+
+ const UInt_t infoSize=4;
+ //reset counters to error number
+ vMeanTime.ResizeTo(infoSize);
+ vMeanTime.Zero();
+ //counter
+ TVectorD c(infoSize);
+ //retrieve pulser and ALTRO data
+ if (!fPulserTmean) return;
+ //
+ //get Outliers
+ AliTPCCalROC *rocOut=0x0;
+ for (UInt_t isec=0;isec<AliTPCCalPad::kNsec;++isec){
+ AliTPCCalROC *tmeanROC=fPulserTmean->GetCalROC(isec);
+ if (!tmeanROC) continue;
+ rocOut=fPulserOutlier->GetCalROC(isec);
+ UInt_t nchannels=tmeanROC->GetNchannels();
+ for (UInt_t ichannel=0;ichannel<nchannels;++ichannel){
+ if (rocOut && rocOut->GetValue(ichannel)) continue;
+ Float_t val=tmeanROC->GetValue(ichannel);
+ Int_t type=isec/18;
+ vMeanTime[type]+=val;
+ ++c[type];
+ }
+ }
+ //calculate mean
+ for (UInt_t itype=0; itype<infoSize; ++itype){
+ if (c[itype]>0) vMeanTime[itype]/=c[itype];
+ else vMeanTime[itype]=0;
+ }
+}
+//_____________________________________________________________________________________
+void AliTPCcalibDButil::ProcessALTROConfig(Int_t &nMasked)
+{
+ //
+ // Get Values from ALTRO configuration data
+ //
+ nMasked=-1;
+ if (!fALTROMasked) return;
+ nMasked=0;
+ for (Int_t isec=0;isec<fALTROMasked->kNsec; ++isec){
+ AliTPCCalROC *rocMasked=fALTROMasked->GetCalROC(isec);
+ for (UInt_t ichannel=0; ichannel<rocMasked->GetNchannels();++ichannel){
+ if (rocMasked->GetValue(ichannel)) ++nMasked;
+ }
+ }
+}
+//_____________________________________________________________________________________
+void AliTPCcalibDButil::ProcessGoofie(TVectorD & vecEntries, TVectorD & vecMedian, TVectorD &vecMean, TVectorD &vecRMS)
+{
+ //
+ // Proces Goofie values, return statistical information of the currently set goofieArray
+ // The meaning of the entries are given below
+ /*
+ 1 TPC_ANODE_I_A00_STAT
+ 2 TPC_DVM_CO2
+ 3 TPC_DVM_DriftVelocity
+ 4 TPC_DVM_FCageHV
+ 5 TPC_DVM_GainFar
+ 6 TPC_DVM_GainNear
+ 7 TPC_DVM_N2
+ 8 TPC_DVM_NumberOfSparks
+ 9 TPC_DVM_PeakAreaFar
+ 10 TPC_DVM_PeakAreaNear
+ 11 TPC_DVM_PeakPosFar
+ 12 TPC_DVM_PeakPosNear
+ 13 TPC_DVM_PickupHV
+ 14 TPC_DVM_Pressure
+ 15 TPC_DVM_T1_Over_P
+ 16 TPC_DVM_T2_Over_P
+ 17 TPC_DVM_T_Over_P
+ 18 TPC_DVM_TemperatureS1
+ */
+ if (!fGoofieArray){
+ Int_t nsensors=19;
+ vecEntries.ResizeTo(nsensors);
+ vecMedian.ResizeTo(nsensors);
+ vecMean.ResizeTo(nsensors);
+ vecRMS.ResizeTo(nsensors);
+ vecEntries.Zero();
+ vecMedian.Zero();
+ vecMean.Zero();
+ vecRMS.Zero();
+ return;
+ }
+ Double_t kEpsilon=0.0000000001;
+ Double_t kBig=100000000000.;
+ Int_t nsensors = fGoofieArray->NumSensors();
+ vecEntries.ResizeTo(nsensors);
+ vecMedian.ResizeTo(nsensors);
+ vecMean.ResizeTo(nsensors);
+ vecRMS.ResizeTo(nsensors);
+ TVectorF values;
+ for (Int_t isensor=0; isensor<fGoofieArray->NumSensors();isensor++){
+ AliDCSSensor *gsensor = fGoofieArray->GetSensor(isensor);
+ if (gsensor && gsensor->GetGraph()){
+ Int_t npoints = gsensor->GetGraph()->GetN();
+ // filter zeroes
+ values.ResizeTo(npoints);
+ Int_t nused =0;
+ for (Int_t ipoint=0; ipoint<npoints; ipoint++){
+ if (TMath::Abs(gsensor->GetGraph()->GetY()[ipoint])>kEpsilon &&
+ TMath::Abs(gsensor->GetGraph()->GetY()[ipoint])<kBig ){
+ values[nused]=gsensor->GetGraph()->GetY()[ipoint];
+ nused++;
+ }
+ }
+ //
+ vecEntries[isensor]= nused;
+ if (nused>1){
+ vecMedian[isensor] = TMath::Median(nused,values.GetMatrixArray());
+ vecMean[isensor] = TMath::Mean(nused,values.GetMatrixArray());
+ vecRMS[isensor] = TMath::RMS(nused,values.GetMatrixArray());
+ }
+ }
+ }
+}
+
+//_____________________________________________________________________________________
+void AliTPCcalibDButil::UpdatePulserOutlierMap()
+{
+ //
+ // Create a map that contains outliers from the Pulser calibration data.
+ // The outliers include masked channels, edge pads and pads with
+ // too large timing and charge variations.
+ // nonMaskedZero is the number of outliers in the Pulser calibration data.
+ // those do not contain masked and edge pads
+ //
+ if (!fPulserTmean||!fPulserQmean) {
+ //reset map
+ fPulserOutlier->Multiply(0.);
+ fNpulserOutliers=-1;
+ return;
+ }
+ AliTPCCalROC *rocMasked=0x0;
+ fNpulserOutliers=0;
+
+ //Create Outlier Map
+ for (UInt_t isec=0;isec<AliTPCCalPad::kNsec;++isec){
+ AliTPCCalROC *tmeanROC=fPulserTmean->GetCalROC(isec);
+ AliTPCCalROC *qmeanROC=fPulserQmean->GetCalROC(isec);
+ AliTPCCalROC *outROC=fPulserOutlier->GetCalROC(isec);
+ if (!tmeanROC||!qmeanROC) {
+ //reset outliers in this ROC
+ outROC->Multiply(0.);
+ continue;
+ }
+ if (fALTROMasked) rocMasked=fALTROMasked->GetCalROC(isec);
+// Double_t dummy=0;
+// Float_t qmedian=qmeanROC->GetLTM(&dummy,.5);
+// Float_t tmedian=tmeanROC->GetLTM(&dummy,.5);
+ UInt_t nrows=tmeanROC->GetNrows();
+ for (UInt_t irow=0;irow<nrows;++irow){
+ UInt_t npads=tmeanROC->GetNPads(irow);
+ for (UInt_t ipad=0;ipad<npads;++ipad){
+ Int_t outlier=0,masked=0;
+ Float_t q=qmeanROC->GetValue(irow,ipad);
+ Float_t t=tmeanROC->GetValue(irow,ipad);
+ //masked channels are outliers
+ if (rocMasked && rocMasked->GetValue(irow,ipad)) masked=1;
+ //edge pads are outliers
+ if (ipad==0||ipad==npads-1) masked=1;
+ //channels with too large charge or timing deviation from the meadian are outliers
+// if (TMath::Abs(q-qmedian)>fPulQmaxLimitAbs || TMath::Abs(t-tmedian)>fPulTmaxLimitAbs) outlier=1;
+ if (q<fPulQminLimit && !masked) outlier=1;
+ //check for nan
+ if ( !(q<10000000) || !(t<10000000)) outlier=1;
+ outROC->SetValue(irow,ipad,outlier+masked);
+ fNpulserOutliers+=outlier;
+ }
+ }
+ }
+}
+//_____________________________________________________________________________________
+AliTPCCalPad* AliTPCcalibDButil::CreatePadTime0(Int_t model)
+{
+ //
+ // Create pad time0 object from pulser and/or CE data, depending on the selected model
+ // Model 0: normalise each readout chamber to its mean, outlier cutted, only Pulser
+ // Model 1: normalise IROCs/OROCs of each readout side to its mean, only Pulser
+ //
+ //
+
+ AliTPCCalPad *padTime0=new AliTPCCalPad("PadTime0",Form("PadTime0-Model_%d",model));
+ // decide between different models
+ if (model==0||model==1){
+ TVectorD vMean;
+ if (model==1) ProcessPulser(vMean);
+ for (UInt_t isec=0;isec<AliTPCCalPad::kNsec;++isec){
+ AliTPCCalROC *rocPulTmean=fPulserTmean->GetCalROC(isec);
+ if (!rocPulTmean) continue;
+ AliTPCCalROC *rocTime0=padTime0->GetCalROC(isec);
+ AliTPCCalROC *rocOut=fPulserOutlier->GetCalROC(isec);
+ Float_t mean=rocPulTmean->GetMean(rocOut);
+ //treat case where a whole partition is masked
+ if (mean==0) mean=rocPulTmean->GetMean();
+ if (model==1) {
+ Int_t type=isec/18;
+ mean=vMean[type];
+ }
+ UInt_t nrows=rocTime0->GetNrows();
+ for (UInt_t irow=0;irow<nrows;++irow){
+ UInt_t npads=rocTime0->GetNPads(irow);
+ for (UInt_t ipad=0;ipad<npads;++ipad){
+ Float_t time=rocPulTmean->GetValue(irow,ipad);
+ //in case of an outlier pad use the mean of the altro values.
+ //This should be the most precise guess in that case.
+ if (rocOut->GetValue(irow,ipad)) {
+ time=GetMeanAltro(rocPulTmean,irow,ipad,rocOut);
+ if (time==0) time=mean;
+ }
+ Float_t val=time-mean;
+ rocTime0->SetValue(irow,ipad,val);
+ }
+ }
+ }
+ }
+
+
+
+ return padTime0;
+}
+//_____________________________________________________________________________________
+Float_t AliTPCcalibDButil::GetMeanAltro(const AliTPCCalROC *roc, const Int_t row, const Int_t pad, AliTPCCalROC *rocOut)
+{
+ if (roc==0) return 0.;
+ const Int_t sector=roc->GetSector();
+ AliTPCROC *tpcRoc=AliTPCROC::Instance();
+ const UInt_t altroRoc=fMapper->GetFEC(sector,row,pad)*8+fMapper->GetChip(sector,row,pad);
+ Float_t mean=0;
+ Int_t n=0;
+
+ //loop over a small range around the requested pad (+-10 rows/pads)
+ for (Int_t irow=row-10;irow<row+10;++irow){
+ if (irow<0||irow>(Int_t)tpcRoc->GetNRows(sector)-1) continue;
+ for (Int_t ipad=pad-10; ipad<pad+10;++ipad){
+ if (ipad<0||ipad>(Int_t)tpcRoc->GetNPads(sector,irow)-1) continue;
+ const UInt_t altroCurr=fMapper->GetFEC(sector,irow,ipad)*8+fMapper->GetChip(sector,irow,ipad);
+ if (altroRoc!=altroCurr) continue;
+ if ( rocOut && rocOut->GetValue(irow,ipad) ) continue;
+ Float_t val=roc->GetValue(irow,ipad);
+ mean+=val;
+ ++n;
+ }
+ }
+ if (n>0) mean/=n;
+ return mean;
+}
--- /dev/null
+#ifndef AliTPCcalibDButil_H
+#define AliTPCcalibDButil_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice */
+
+///////////////////////////////////////////////////////////////////////////////
+// //
+// Class providing the calculation of derived quantities (mean,rms,fits,...) //
+// of calibration entries //
+// //
+///////////////////////////////////////////////////////////////////////////////
+
+#include <TObject.h>
+
+class AliDCSSensorArray;
+class AliTPCcalibDB;
+class AliTPCCalPad;
+class AliTPCmapper;
+
+class AliTPCcalibDButil : public TObject
+{
+public:
+ AliTPCcalibDButil();
+ virtual ~AliTPCcalibDButil();
+
+ void UpdateFromCalibDB();
+ //data processing functions
+ void ProcessCEdata(const char* fitFormula, TVectorD &fitResultsA, TVectorD &fitResultsC, Int_t &noutliersCE);
+ void ProcessCEgraphs(TVectorD &vecTEntries, TVectorD &vecTMean, TVectorD &vecTRMS, TVectorD &vecTMedian,
+ TVectorD &vecQEntries, TVectorD &vecQMean, TVectorD &vecQRMS, TVectorD &vecQMedian,
+ Float_t &driftTimeA, Float_t &driftTimeC );
+ void ProcessNoiseData(TVectorD &vNoiseMean, TVectorD &vNoiseMeanSenRegions,
+ TVectorD &vNoiseRMS, TVectorD &vNoiseRMSSenRegions,
+ Int_t &nonMaskedZero);
+ void ProcessPulser(TVectorD &vMeanTime);
+ void ProcessALTROConfig(Int_t &nMasked);
+ void ProcessGoofie(TVectorD & vecEntries, TVectorD & vecMedian, TVectorD &vecMean, TVectorD &vecRMS);
+ //getter preprocess information
+ Int_t GetNPulserOutliers() const {return fNpulserOutliers;}
+ Float_t GetMeanAltro(const AliTPCCalROC *roc, const Int_t row, const Int_t pad, AliTPCCalROC *rocOut=0x0);
+ AliTPCCalPad *GetPulserOutlierMap() const {return fPulserOutlier;}
+ //setters for pad by pad information
+ void SetPulserData(AliTPCCalPad *tmean, AliTPCCalPad *trms=0x0, AliTPCCalPad *qmean=0x0)
+ {fPulserTmean=tmean; fPulserTrms=trms; fPulserQmean=qmean;}
+ void SetCEData(AliTPCCalPad *tmean, AliTPCCalPad *trms=0x0, AliTPCCalPad *qmean=0x0)
+ {fCETmean=tmean; fCETrms=trms; fCEQmean=qmean;}
+ void SetNoisePedestal(AliTPCCalPad *noise, AliTPCCalPad *pedestal=0x0)
+ {fPadNoise=noise; fPedestals=pedestal;}
+ void SetALTROData(AliTPCCalPad *masked)
+ {fALTROMasked=masked;}
+ void SetGoofieArray(AliDCSSensorArray *arr) {fGoofieArray=arr;}
+ //creation of derived pad by pad calibration data
+ AliTPCCalPad *CreatePadTime0(Int_t model=0);
+ //
+ void UpdatePulserOutlierMap();
+private:
+ AliTPCcalibDB *fCalibDB; //pointer to calibDB object
+ AliTPCCalPad *fPadNoise; //noise information
+ AliTPCCalPad *fPedestals; //pedestal information
+ AliTPCCalPad *fPulserTmean; //pulser mean time information
+ AliTPCCalPad *fPulserTrms; //pulser rms time information
+ AliTPCCalPad *fPulserQmean; //pulser mean q information
+ AliTPCCalPad *fPulserOutlier; //pulser outlier map
+ AliTPCCalPad *fCETmean; //central electrode mean time information
+ AliTPCCalPad *fCETrms; //central electrode rms time information
+ AliTPCCalPad *fCEQmean; //central electrode mean q information
+ AliTPCCalPad *fALTROMasked; //ALTRO masked channels information
+ //
+ AliDCSSensorArray* fGoofieArray; //Goofie Data
+ //
+ AliTPCmapper *fMapper; //TPC mapping handler
+ Int_t fNpulserOutliers; //number of outliers from Pulser calibration
+
+ Float_t fIrocTimeOffset; //timing offset between IROC and OROC in timebins
+ Float_t fCETmaxLimitAbs; //maximum variation in CE data before pads will be treated as outliers
+ Float_t fPulTmaxLimitAbs; //maximum variation of Pulser Signals (time) before pads will be treated as outliers
+ Float_t fPulQmaxLimitAbs; //maximum variation of Pulser Signals (charge) before pads will be treated as outliers
+ Float_t fPulQminLimit; //minimum charge value for Pulser Signals before pads will be treated as outliers
+
+ AliTPCcalibDButil (const AliTPCcalibDButil& );
+ AliTPCcalibDButil& operator= (const AliTPCcalibDButil& );
+
+
+ ClassDef(AliTPCcalibDButil,0)
+};
+
+
+#endif
#include <AliLog.h>
#include <AliMagF.h>
#include "AliTPCcalibDB.h"
+#include "AliTPCcalibDButil.h"
#include "AliTPCAltroMapping.h"
#include "AliTPCExB.h"
#include "AliTPCCalROC.h"
TTree * dcsTree=0;
-void ProcessGoofie( AliDCSSensorArray* goofieArray, TVectorD & vecEntries, TVectorD & vecMedian, TVectorD &vecMean, TVectorD &vecRMS);
-void ProcessCEdata(const char* fitFormula, TVectorD &fitResultsA, TVectorD &fitResultsC);
-void ProcessNoiseData(TVectorD &vNoiseMean, TVectorD &vNoiseMeanSenRegions,
- TVectorD &vNoiseRMS, TVectorD &vNoiseRMSSenRegions,
- Int_t &nonMaskedZero);
-void ProcessPulser(Int_t &nMasked, Int_t &nonMaskedZero);
void GetProductionInfo(Int_t run, Int_t &nalien, Int_t &nRawAlien, Int_t &nlocal, Int_t &nRawLocal);
void Init(){
in.open(runList);
Int_t irun=0;
TTreeSRedirector *pcstream = new TTreeSRedirector("dcsTime.root");
+ AliTPCcalibDButil dbutil;
// for (Int_t irun=startRun; irun<stopRun; irun++){
while(in.good()) {
in >> irun;
if (irun==0) continue;
printf("Processing run %d ...\n",irun);
AliTPCcalibDB::Instance()->SetRun(irun);
+ dbutil.UpdateFromCalibDB();
AliDCSSensor * sensorPressure = AliTPCcalibDB::Instance()->GetPressureSensor(irun);
if (!sensorPressure) continue;
AliTPCSensorTempArray * tempArray = AliTPCcalibDB::Instance()->GetTemperatureSensor(irun);
Int_t startTimeGRP = AliTPCcalibDB::GetGRP(irun)->GetTimeStart();
Int_t stopTimeGRP = AliTPCcalibDB::GetGRP(irun)->GetTimeEnd();
Int_t dtime = TMath::Max((endTime-startTime)/20,10*60);
+ //Goofie statistical data
+ TVectorD vecEntries, vecMean, vecMedian,vecRMS;
+ dbutil.ProcessGoofie(vecEntries ,vecMedian, vecMean, vecRMS);
//CE data processing - see ProcessCEdata function for description of the results
TVectorD fitResultsA, fitResultsC;
- ProcessCEdata("gx++gy++lx++lx**2",fitResultsA,fitResultsC);
+ Int_t nmaskedCE;
+ dbutil.ProcessCEdata("gx++gy++lx++lx**2",fitResultsA,fitResultsC,nmaskedCE);
+ TVectorD vecTEntries, vecTMean, vecTRMS, vecTMedian, vecQEntries, vecQMean, vecQRMS, vecQMedian;
+ Float_t driftTimeA, driftTimeC;
+ dbutil.ProcessCEgraphs(vecTEntries, vecTMean, vecTRMS, vecTMedian,
+ vecQEntries, vecQMean, vecQRMS, vecQMedian,
+ driftTimeA, driftTimeC );
//noise data Processing - see ProcessNoiseData function for description of the results
TVectorD vNoiseMean, vNoiseMeanSenRegions, vNoiseRMS, vNoiseRMSSenRegions;
Int_t nonMaskedZero=0;
- ProcessNoiseData(vNoiseMean, vNoiseMeanSenRegions, vNoiseRMS, vNoiseRMSSenRegions, nonMaskedZero);
+ dbutil.ProcessNoiseData(vNoiseMean, vNoiseMeanSenRegions, vNoiseRMS, vNoiseRMSSenRegions, nonMaskedZero);
//L3 data
Float_t bz=AliTPCcalibDB::GetBz(irun);
Char_t l3pol=AliTPCcalibDB::GetL3Polarity(irun);
//calibration Pulser data processing
- Int_t nMasked=0;
Int_t nOffChannels=0;
- ProcessPulser(nMasked,nOffChannels);
+ TVectorD vTimePulser;
+ nOffChannels=dbutil.GetNPulserOutliers();
+ dbutil.ProcessPulser(vTimePulser);
+ //ALTRO data
+ Int_t nMasked=0;
+ dbutil.ProcessALTROConfig(nMasked);
//production information
Int_t nalien=0,nRawAlien=0,nlocal=0,nRawLocal=0;
// GetProductionInfo(irun, nalien, nRawAlien, nlocal,nRawLocal);
else
vecSkirtTempC[senTemp->GetSector()]=val;
}
-
- TVectorD vecGoofie, vecEntries, vecMean, vecMedian,vecRMS;
+ //goofie data
+ TVectorD vecGoofie;
if (goofieArray){
vecGoofie.ResizeTo(goofieArray->NumSensors());
- ProcessGoofie(goofieArray, vecEntries ,vecMedian, vecMean, vecRMS);
- //
for (Int_t isensor=0; isensor<goofieArray->NumSensors();isensor++){
AliDCSSensor *gsensor = goofieArray->GetSensor(isensor);
if (gsensor){
vecGoofie[isensor] = gsensor->GetValue(tstamp);
}
}
+ } else {
+ vecGoofie.ResizeTo(19);
}
- Double_t ptrelative0 = AliTPCcalibDB::GetPTRelative(tstamp,irun,0);
- Double_t ptrelative1 = AliTPCcalibDB::GetPTRelative(tstamp,irun,1);
+ Double_t ptrelative0 = AliTPCcalibDB::GetPTRelative((UInt_t)itime,irun,0);
+ Double_t ptrelative1 = AliTPCcalibDB::GetPTRelative((UInt_t)itime,irun,1);
//
TVectorD voltagesIROC(36);
TVectorD voltagesOROC(36);
- for(Int_t j=1; j<36; j++) voltagesIROC[j-1] = AliTPCcalibDB::Instance()->GetChamberHighVoltage(irun, j,tstamp);
- for(Int_t j=36; j<72; j++) voltagesOROC[j-36] = AliTPCcalibDB::Instance()->GetChamberHighVoltage(irun, j,tstamp);
+ for(Int_t j=1; j<36; j++) voltagesIROC[j-1] = AliTPCcalibDB::Instance()->GetChamberHighVoltage(irun, j,itime);
+ for(Int_t j=36; j<72; j++) voltagesOROC[j-36] = AliTPCcalibDB::Instance()->GetChamberHighVoltage(irun, j,itime);
Double_t voltIROC = TMath::Median(36, voltagesIROC.GetMatrixArray());
Double_t voltOROC = TMath::Median(36, voltagesOROC.GetMatrixArray());
//
"rmsNoiseSen.="<<&vNoiseRMSSenRegions<<
"zeroNoise="<<nonMaskedZero<<
//pulser data
- "nMasked="<<nMasked<< //should perhaps go to altro data
+ "timePulser.=" << &vTimePulser <<
"nOffPulser="<<nOffChannels<<
+ //altro data
+ "nMasked="<<nMasked<<
//ce data
"CEfitA.="<<&fitResultsA<<
"CEfitC.="<<&fitResultsC<<
+ "nmaskedCE="<<nmaskedCE<<
+ //ce graph data
+ "CEgrTEntries.="<<&vecTEntries<<
+ "CEgrTMean.="<<&vecTMean<<
+ "CEgrTRMS.="<<&vecTRMS<<
+ "CEgrTMedian.="<<&vecTMedian<<
+ "CEgrQEntries.="<<&vecQEntries<<
+ "CEgrQMean.="<<&vecQMean<<
+ "CEgrQRMS.="<<&vecQRMS<<
+ "CEgrQMedian.="<<&vecQMedian<<
+ "CEgrTEntries.="<<&vecTEntries<<
+ "CEgrTMean.="<<&vecTMean<<
+ "CEgrTRMS.="<<&vecTRMS<<
+ "CEgrTMedian.="<<&vecTMedian<<
+ "CEgrQEntries.="<<&vecQEntries<<
+ "CEgrQMean.="<<&vecQMean<<
+ "CEgrQRMS.="<<&vecQRMS<<
+ "CEgrQMedian.="<<&vecQMedian<<
+ "CEgrDriftA="<<driftTimeA<<
+ "CEgrDriftC="<<driftTimeC<<
// b field
"Bz="<< bz <<
"L3polarity="<<l3pol<<
}
-void ProcessGoofie( AliDCSSensorArray* goofieArray, TVectorD & vecEntries, TVectorD & vecMedian, TVectorD &vecMean, TVectorD &vecRMS){
- /*
-
- 1 TPC_ANODE_I_A00_STAT
- 2 TPC_DVM_CO2
- 3 TPC_DVM_DriftVelocity
- 4 TPC_DVM_FCageHV
- 5 TPC_DVM_GainFar
- 6 TPC_DVM_GainNear
- 7 TPC_DVM_N2
- 8 TPC_DVM_NumberOfSparks
- 9 TPC_DVM_PeakAreaFar
- 10 TPC_DVM_PeakAreaNear
- 11 TPC_DVM_PeakPosFar
- 12 TPC_DVM_PeakPosNear
- 13 TPC_DVM_PickupHV
- 14 TPC_DVM_Pressure
- 15 TPC_DVM_T1_Over_P
- 16 TPC_DVM_T2_Over_P
- 17 TPC_DVM_T_Over_P
- 18 TPC_DVM_TemperatureS1
- */
- //
- //
- // TVectorD vecMedian; TVectorD vecEntries; TVectorD vecMean; TVectorD vecRMS;
- Double_t kEpsilon=0.0000000001;
- Double_t kBig=100000000000.;
- Int_t nsensors = goofieArray->NumSensors();
- vecEntries.ResizeTo(nsensors);
- vecMedian.ResizeTo(nsensors);
- vecMean.ResizeTo(nsensors);
- vecRMS.ResizeTo(nsensors);
- TVectorF values;
- for (Int_t isensor=0; isensor<goofieArray->NumSensors();isensor++){
- AliDCSSensor *gsensor = goofieArray->GetSensor(isensor);
- if (gsensor && gsensor->GetGraph()){
- Int_t npoints = gsensor->GetGraph()->GetN();
- // filter zeroes
- values.ResizeTo(npoints);
- Int_t nused =0;
- for (Int_t ipoint=0; ipoint<npoints; ipoint++){
- if (TMath::Abs(gsensor->GetGraph()->GetY()[ipoint])>kEpsilon &&
- TMath::Abs(gsensor->GetGraph()->GetY()[ipoint])<kBig ){
- values[nused]=gsensor->GetGraph()->GetY()[ipoint];
- nused++;
- }
- }
- //
- vecEntries[isensor]= nused;
- if (nused>1){
- vecMedian[isensor] = TMath::Median(nused,values.GetMatrixArray());
- vecMean[isensor] = TMath::Mean(nused,values.GetMatrixArray());
- vecRMS[isensor] = TMath::RMS(nused,values.GetMatrixArray());
- }
- }
- }
-}
-void ProcessCEdata(const char* fitFormula, TVectorD &fitResultsA, TVectorD &fitResultsC)
-{
- //
- // Process the CE data for this run
- // the return TVectorD arrays contian the results of the fit
- //
- const Float_t irocToffset=0.2;
- const Float_t tMaxLimit=1.5;
- //retrieve CE and ALTRO data
- AliTPCCalPad *cet0=AliTPCcalibDB::Instance()->GetCETmean();
- if (!cet0){
- TString fitString(fitFormula);
- fitString.ReplaceAll("++","#");
- Int_t ndim=fitString.CountChar('#')+1;
- fitResultsA.ResizeTo(ndim);
- fitResultsC.ResizeTo(ndim);
- return;
- }
- AliTPCCalPad padT0(*cet0);
- AliTPCCalPad *padMasked=AliTPCcalibDB::Instance()->GetALTROMasked();
- //create outlier map
- AliTPCCalPad out("out","out");
- //loop over all channels
- for (UInt_t iroc=0;iroc<padT0.kNsec;++iroc){
- AliTPCCalROC *rocData=padT0.GetCalROC(iroc);
- AliTPCCalROC *rocMasked=padMasked->GetCalROC(iroc);
- AliTPCCalROC *rocOut=out.GetCalROC(iroc);
- if (!rocData) continue;
- //add time offset to IROCs
- if (iroc<AliTPCROC::Instance()->GetNInnerSector())
- rocData->Add(irocToffset);
- //select outliers
- for (UInt_t ichannel=0;ichannel<rocData->GetNchannels();++ichannel){
- if (rocMasked && rocMasked->GetValue(ichannel)) rocOut->SetValue(ichannel,1);
- Float_t valTmean=rocData->GetValue(ichannel);
- if (valTmean==0) rocOut->SetValue(ichannel,1); //exclude values that are exactly 0
- if (TMath::Abs(valTmean)>tMaxLimit) rocOut->SetValue(ichannel,1); // exclude channels with too large variations
- }
- }
- //perform fit
- TMatrixD dummy;
- Float_t chi2A,chi2C;
- padT0.GlobalSidesFit(&out,fitFormula,fitResultsA,fitResultsC,dummy,dummy,chi2A,chi2C);
-}
-
-void ProcessNoiseData(TVectorD &vNoiseMean, TVectorD &vNoiseMeanSenRegions,
- TVectorD &vNoiseRMS, TVectorD &vNoiseRMSSenRegions,
- Int_t &nonMaskedZero)
-{
- //
- // process noise data
- // vNoiseMean/RMS contains the Mean/RMS noise of the complete TPC [0], IROCs only [1],
- // OROCs small pads [2] and OROCs large pads [3]
- // vNoiseMean/RMSsenRegions constains the same information, but only for the sensitive regions (edge pads, corners, IROC spot)
- //
-
- //set proper size and reset
- const UInt_t infoSize=4;
- vNoiseMean.ResizeTo(infoSize);
- vNoiseMeanSenRegions.ResizeTo(infoSize);
- vNoiseRMS.ResizeTo(infoSize);
- vNoiseRMSSenRegions.ResizeTo(infoSize);
- vNoiseMean.Zero();
- vNoiseMeanSenRegions.Zero();
- vNoiseRMS.Zero();
- vNoiseRMSSenRegions.Zero();
- //counters
- TVectorD c(infoSize);
- TVectorD cs(infoSize);
- //tpc parameters
- AliTPCParam par;
- par.Update();
- //retrieve noise and ALTRO data
- AliTPCCalPad *noise=AliTPCcalibDB::Instance()->GetPadNoise();
- if (!noise) return;
- AliTPCCalPad *padMasked=AliTPCcalibDB::Instance()->GetALTROMasked();
- //create IROC, OROC1, OROC2 and sensitive region masks
- for (UInt_t isec=0;isec<AliTPCCalPad::kNsec;++isec){
- AliTPCCalROC *noiseROC=noise->GetCalROC(isec);
- UInt_t nrows=noiseROC->GetNrows();
- for (UInt_t irow=0;irow<nrows;++irow){
- UInt_t npads=noiseROC->GetNPads(irow);
- for (UInt_t ipad=0;ipad<npads;++ipad){
- Int_t masked=(Int_t)padMasked->GetCalROC(isec)->GetValue(irow,ipad);
- Float_t noiseVal=noiseROC->GetValue(irow,ipad);
- if (masked) {
-// printf("masked\n");
- continue; // don't use inactive pads
- }
- //check if noise==0
- if (noiseVal==0) {
- ++nonMaskedZero;
- continue;
- }
- //check for nan
- if ( !(noiseVal<100000000000) ){
- printf ("Warning: nan detected in (sec,row,pad - val): %02d,%02d,%03d - %.1f\n",isec,irow,ipad,noiseVal);
- continue;
- }
- Int_t cpad=(Int_t)ipad-(Int_t)npads/2;
- Int_t masksen=1; // sensitive pards are not masked (0)
- if (ipad<2||npads-ipad-1<2) masksen=0; //don't mask edge pads (sensitive)
- if (isec<AliTPCROC::Instance()->GetNInnerSector()){
- //IROCs
- if (irow>19&&irow<46){
- if (TMath::Abs(cpad)<7) masksen=0; //IROC spot
- }
- Int_t type=1;
- vNoiseMean[type]+=noiseVal;
- vNoiseRMS[type]+=noiseVal*noiseVal;
- ++c[type];
- if (!masksen){
- vNoiseMeanSenRegions[type]+=noiseVal;
- vNoiseRMSSenRegions[type]+=noiseVal*noiseVal;
- ++cs[type];
- }
- } else {
- //OROCs
- //define sensive regions
- if ((nrows-irow-1)<3) masksen=0; //last three rows in OROCs are sensitive
- if ( irow>75 ){
- Int_t padEdge=(Int_t)TMath::Min(ipad,npads-ipad);
- if (padEdge<((((Int_t)irow-76)/4+1))*2) masksen=0; //OROC outer corners are sensitive
- }
- if ((Int_t)irow<par.GetNRowUp1()){
- //OROC1
- Int_t type=2;
- vNoiseMean[type]+=noiseVal;
- vNoiseRMS[type]+=noiseVal*noiseVal;
- ++c[type];
- if (!masksen){
- vNoiseMeanSenRegions[type]+=noiseVal;
- vNoiseRMSSenRegions[type]+=noiseVal*noiseVal;
- ++cs[type];
- }
- }else{
- //OROC2
- Int_t type=3;
- vNoiseMean[type]+=noiseVal;
- vNoiseRMS[type]+=noiseVal*noiseVal;
- ++c[type];
- if (!masksen){
- vNoiseMeanSenRegions[type]+=noiseVal;
- vNoiseRMSSenRegions[type]+=noiseVal*noiseVal;
- ++cs[type];
- }
- }
- }
- //whole tpc
- Int_t type=0;
- vNoiseMean[type]+=noiseVal;
- vNoiseRMS[type]+=noiseVal*noiseVal;
- ++c[type];
- if (!masksen){
- vNoiseMeanSenRegions[type]+=noiseVal;
- vNoiseRMSSenRegions[type]+=noiseVal*noiseVal;
- ++cs[type];
- }
- }//end loop pads
- }//end loop rows
- }//end loop sectors (rocs)
-
- //calculate mean and RMS
- const Double_t verySmall=0.0000000001;
- for (UInt_t i=0;i<infoSize;++i){
- Double_t mean=0;
- Double_t rms=0;
- Double_t meanSen=0;
- Double_t rmsSen=0;
-
- if (c[i]>verySmall){
-// printf ("i: %d - m: %.3f, c: %.0f, r: %.3f\n",i,vNoiseMean[i],c[i],vNoiseRMS[i]);
- mean=vNoiseMean[i]/c[i];
- rms=vNoiseRMS[i];
- rms=TMath::Sqrt(TMath::Abs(rms/c[i]-mean*mean));
- }
- vNoiseMean[i]=mean;
- vNoiseRMS[i]=rms;
-
- if (cs[i]>verySmall){
- meanSen=vNoiseMeanSenRegions[i]/cs[i];
- rmsSen=vNoiseRMSSenRegions[i];
- rmsSen=TMath::Sqrt(TMath::Abs(rmsSen/cs[i]-meanSen*meanSen));
- }
- vNoiseMeanSenRegions[i]=meanSen;
- vNoiseRMSSenRegions[i]=rmsSen;
- }
-}
-
-void ProcessPulser(Int_t &nMasked, Int_t &nonMaskedZero)
-{
- //
- // Process the Pulser information
- //
-
- //reset counters to error number
- nonMaskedZero=-100;
- nMasked=-100;
- //retrieve pulser and ALTRO data
- AliTPCCalPad *pulserTmean=AliTPCcalibDB::Instance()->GetPulserTmean();
- if (!pulserTmean) return;
- //reset counters
- nonMaskedZero=0;
- nMasked=0;
-// AliTPCCalPad *pulserTrms=AliTPCcalibDB::Instance()->GetPulserTrms();
-// AliTPCCalPad *pulserQmean=AliTPCcalibDB::Instance()->GetPulserQmean();
- AliTPCCalPad *padMasked=AliTPCcalibDB::Instance()->GetALTROMasked();
- //create IROC, OROC1, OROC2 and sensitive region masks
- for (UInt_t isec=0;isec<AliTPCCalPad::kNsec;++isec){
- AliTPCCalROC *tmeanROC=pulserTmean->GetCalROC(isec);
- if (!tmeanROC) continue;
-// AliTPCCalROC *trmsROC=pulserTrms->GetCalROC(isec);
-// AliTPCCalROC *qmeanROC=pulserQmean->GetCalROC(isec);
- Float_t tmeanMedian=tmeanROC->GetMedian();
- UInt_t nrows=tmeanROC->GetNrows();
- for (UInt_t irow=0;irow<nrows;++irow){
- UInt_t npads=tmeanROC->GetNPads(irow);
- for (UInt_t ipad=0;ipad<npads;++ipad){
- Int_t masked=(Int_t)padMasked->GetCalROC(isec)->GetValue(irow,ipad);
- Float_t tmeanVal=tmeanROC->GetValue(irow,ipad);
-// Float_t trmsVal =trmsROC->GetValue(irow,ipad);
-// Float_t qmeanVal=qmeanROC->GetValue(irow,ipad);
- if (masked){
- ++nMasked;
- continue; // don't use inactive pads
- }
- if ( TMath::Abs(tmeanVal-tmeanMedian)>1.5 ) ++nonMaskedZero;
- }
- }
- }
-}
void GetProductionInfo(Int_t run, Int_t &nalien, Int_t &nRawAlien, Int_t &nlocal, Int_t &nRawLocal){
//
nlocal=0;
nRawLocal=0;
TString sNlines;
- FILE *pipe = 0x0;
//find number of ESDs in alien
TString command="alien_find /alice/data/2009 ";
command += Form("%09d",run);
#pragma link C++ class AliTPCCalPad+;
#pragma link C++ class AliTPCCalDet+;
#pragma link C++ class AliTPCcalibDB+;
+#pragma link C++ class AliTPCcalibDButil+;
#pragma link C++ class AliTPCLaserTracks+;
#pragma link C++ class AliTPCSensorTemp+;
#pragma link C++ class AliTPCSensorTempArray+;
AliSimDigits.cxx AliDigitsArray.cxx AliTPCDigitsArray.cxx \
AliTPCmapper.cxx \
AliTPCROC.cxx AliTPCCalROC.cxx AliTPCCalPad.cxx AliTPCCalDet.cxx \
- AliTPCcalibDB.cxx \
+ AliTPCcalibDB.cxx AliTPCcalibDButil.cxx \
AliTPCAltroMapping.cxx AliTPCRawStream.cxx AliTPCRawStreamFast.cxx AliTPCRawStreamV3.cxx \
AliTPCLaserTracks.cxx AliTPCSensorTemp.cxx AliTPCSensorTempArray.cxx \
AliTPCCalibRawBase.cxx AliTPCCalibPedestal.cxx AliTPCCalibPulser.cxx AliTPCCalibCE.cxx \