AliT0CalibSeasonTimeShift::AliT0CalibSeasonTimeShift():TNamed()
{
//
-
+ for (Int_t i=0; i<4; i++)
+ fMeanPar[i] = fSigmaPar[i] = 0;
}
//________________________________________________________________
TString namst = "Calib_";
namst += name;
SetName(namst.Data());
- SetTitle(namst.Data());
+ SetTitle(namst.Data());
+
+ for (Int_t i=0; i<4; i++)
+ fMeanPar[i] = fSigmaPar[i] = 0;
+
}
//________________________________________________________________
// copy constructor
SetName(calibda.GetName());
SetTitle(calibda.GetName());
+ ((AliT0CalibSeasonTimeShift &) calibda).Copy(*this);
}
// assignment operator
SetName(calibda.GetName());
SetTitle(calibda.GetName());
+ if (this != &calibda) ((AliT0CalibSeasonTimeShift &) calibda).Copy(*this);
return *this;
}
}
//________________________________________________________________
-Bool_t AliT0CalibSeasonTimeShift::SetT0Par(const char* filePhys)
+Int_t AliT0CalibSeasonTimeShift::SetT0Par(const char* filePhys, Float_t *cdbtime)
{
- // compute online equalized time
+ // compute shifts fo T0A, T0C, T0AC and resolution
+ //Status : writeok:
+ // 0 OK
+ // 2000 - no data file
+ // 300 no one histogram or it is empty
+ //-100 peak is very narrow
+
Float_t mean, sigma;
- Bool_t ok=false;
+ Int_t ok = 0;
+ TH1F *cfd = NULL;
+ TObjArray * tzeroObj = NULL;
gFile = TFile::Open(filePhys);
if(!gFile) {
AliError("No input PHYS data found ");
+ ok = 2000;
}
- else
- {
- gFile->ls();
- TDirectory *dr = (TDirectory*) gFile->Get("T0Calib");
- if (!dr) {
- AliWarning(Form("no Tzero Directory in file collected "));
- return ok;
- }
- TObjArray * TzeroObj = (TObjArray*) dr->Get("fTzeroObject");
- if(!TzeroObj) {
- AliWarning(Form("no Tzero Object in file collected "));
- return ok;
- }
+ else {
+ // gFile->ls();
+ // TDirectory *dr = (TDirectory*) gFile->Get("T0Calib");
+ tzeroObj = dynamic_cast<TObjArray*>(gFile->Get("T0Calib"));
TString histname[4]={"fTzeroORAplusORC", "fTzeroORA", "fTzeroORC", "fResolution"};
for (Int_t i=0; i<4; i++)
- {
- TH1F *cfd = (TH1F*)TzeroObj->FindObject( histname[i].Data());
- gFile->Get(histname[i].Data());
- if(!cfd) AliWarning(Form("no histograms collected for %s", histname[i].Data()));
- if(cfd) {
- // printf(" T0s: %i %s mean %f rms %f \n", i, histname[i].Data(),cfd->GetMean , cfd ->GetRMS() );
+ {
+ if(cfd) cfd->Reset();
+ if(tzeroObj)
+ cfd = (TH1F*)tzeroObj->FindObject( histname[i].Data());
+ else
+ cfd = (TH1F*)gFile ->Get(histname[i].Data());
+
+ if(!cfd) {
+ ok=300;
+ AliError(Form("no histograms collected for %s", histname[i].Data()));
+ return ok;
+ }
+ if(cfd) {
+ if( cfd->GetEntries() == 0) {
+ ok=300;
+ AliError(Form("%s histogram is empty", histname[i].Data()));
+ return ok;
+ }
GetMeanAndSigma(cfd, mean, sigma);
- if (sigma == 0 || sigma > 500) ok = false;
- else
+ if (sigma == 0 || sigma > 500 || cfd->GetEntries()<200 ){
+ ok = -100;
+ fMeanPar[i] = cdbtime[i];
+ fSigmaPar[i] = -1;
+ }
+ if ( sigma > 0 && sigma < 500 && cfd->GetEntries()>200)
{
- fMeanPar[i] = mean;
+ fMeanPar[i] = mean;
fSigmaPar[i] = sigma;
- printf(" T0s: %i %s %f %f \n", i, histname[i].Data(), fMeanPar[i],fSigmaPar[i] );
- ok=true;
}
}
- }
-
- gFile->Close();
- delete gFile;
-
- }
+ }
+ }
+ gFile->Close();
+ delete gFile;
return ok;
}
//________________________________________________________________________
void AliT0CalibSeasonTimeShift::GetMeanAndSigma(TH1F* hist, Float_t &mean, Float_t &sigma) {
- const double window = 5.; //fit window
+ const double window =3.; //fit window
double meanEstimate, sigmaEstimate;
int maxBin;
sigmaEstimate = hist->GetRMS();
TF1* fit= new TF1("fit","gaus", meanEstimate - window*sigmaEstimate, meanEstimate + window*sigmaEstimate);
fit->SetParameters(hist->GetBinContent(maxBin), meanEstimate, sigmaEstimate);
- hist->Fit("fit","R");
+ hist->Fit("fit","R","");
mean = (Float_t) fit->GetParameter(1);
sigma = (Float_t) fit->GetParameter(2);