#include <Riostream.h>
#include <TClass.h>
#include <TH1F.h>
+#include <TF1.h>
+#include <TFitResultPtr.h>
#include <TH2.h>
#include <TIterator.h>
#include <TKey.h>
#include <TFile.h>
#include <TMath.h>
#include <TString.h>
+#include <TPaveText.h>
// --- Standard library ---
#include "AliT0QAChecker.h"
ClassImp(AliT0QAChecker)
+//____________________________________________________________________________
+AliT0QAChecker::AliT0QAChecker() :
+AliQACheckerBase("T0","T0 Quality Assurance Checker")
+{
+ // Standard constructor
+
+}
//____________________________________________________________________________
-Double_t * AliT0QAChecker::Check(AliQAv1::ALITASK_t /*index*/)
+AliT0QAChecker::AliT0QAChecker(const AliT0QAChecker& qac):
+ AliQACheckerBase(qac.GetName(), qac.GetTitle())
{
- Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ;
- for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
- rv[specie] = 0.0 ;
- return rv ;
+ // copy constructor
+ AliError("Copy should not be used with this class\n");
+}
+//____________________________________________________________________________
+AliT0QAChecker& AliT0QAChecker::operator=(const AliT0QAChecker& qac){
+ // assignment operator
+ this->~AliT0QAChecker();
+ new(this)AliT0QAChecker(qac);
+ return *this;
+}
+
+
+//____________________________________________________________________________
+AliT0QAChecker::~AliT0QAChecker(){
+ // destructor
+
}
//__________________________________________________________________
-Double_t * AliT0QAChecker::Check(AliQAv1::ALITASK_t index,TObjArray ** list)
+void AliT0QAChecker::Check(Double_t * test, AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/)
{
// Super-basic check on the QA histograms on the input list:
// look whether they are empty!
-
- Double_t * test = new Double_t[AliRecoParam::kNSpecies] ;
- /*
- char * detOCDBDir = Form("T0/%s/%s", AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName()) ;
+
+ char * detOCDBDir = Form("T0/%s/%s", AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName()) ;
+
AliCDBEntry *QARefRec = AliQAManager::QAManager()->Get(detOCDBDir);
// QARefRec->Dump();
if( !QARefRec){
AliInfo("QA reference data NOT retrieved for Reconstruction check. No T0 reference distribution");
}
- */
- for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
+
+ for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++)
test[specie] = 10.0 ;
- Double_t nent[500];
- TString hname[500];
- const char *cname;
- memset(nent,0,500*sizeof(Double_t));
- Double_t w[500];
- memset(w,1,500*sizeof(Double_t));
- TH2 *fhRecDiff[3];
- TH1 *fhRawEff[500];
- TH1 *fhESD[2];
-
for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
// TString dataType = AliQAv1::GetAliTaskName(index);
if (list[specie]->GetEntries() == 0){
test[specie] = 1. ; // nothing to check
}
else {
- TIter next(list[specie]) ;
- TH1 * hdata ;
- TH2 * h ;
- // AliDebug(AliQAv1::GetQADebugLevel(), Form(" data type %i %s nentries %i\n",
- // index,dataType.Data(),list->GetEntries()));
- for (Int_t ir=0; ir<list[specie]->GetEntries(); ir++) {
- //raw
- if(index==0 ){
- if(ir > 204 && ir<208 ) {
- // else{
- hdata = (TH1*) list[specie]->UncheckedAt(ir);
- AliDebug(AliQAv1::GetQADebugLevel(), Form(" index %i ir %i \n", index,ir));
- if(hdata) {
- cname = hdata->GetName();
- hname[ir] = cname;
- AliDebug(AliQAv1::GetQADebugLevel(),Form("count %i %s \n",ir, hname[ir].Data())) ;
- fhRawEff[ir] = hdata;
- }
- }
- }
+ if (index == AliQAv1::kRAW && AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCalib)
+ // if (index == AliQAv1::kRAW )
+ {
+ test[specie] = CheckRaw(list[specie]);
+ }
- //rec
- if(index==2){
- h = (TH2*) list[specie]->UncheckedAt(ir);
- if(h) {
- cname = h->GetName();
- hname[ir] = cname;
- // AliDebug(AliQAv1::GetQADebugLevel(), Form("count %i %s \n",ir, hname[ir].Data())) ;
- fhRecDiff[ir] = h;
- }
- }
- //esd
- if(index==3){
- hdata = (TH1*) list[specie]->UncheckedAt(ir);
- if(hdata){
- fhESD[ir] = hdata;
- AliDebug(AliQAv1::GetQADebugLevel(), Form("count %i %s ",ir, hname[ir].Data()) );
- }
- }
+ if (index == AliQAv1::kESD && AliRecoParam::Convert(specie) != AliRecoParam::kCalib)
+ test[specie] = CheckESD(list[specie]);
+ }
+
+ }
+}
+
+//--------------------------------------------------------------------------
+Double_t AliT0QAChecker::CheckRaw(TObjArray *listrec) const
+{
+ Float_t checkr = 0;
+
+ TString hname[10];
+ TH1*hdata;
+ const char *cname;
+ TH1 *fhRawEff[10];
+ Int_t nh=0;
+
+
+ Int_t nnn[4] = { 420, 458, 459, 460};
+ for (Int_t ir=0; ir<4; ir++)
+ {
+ hdata = (TH1*) listrec->UncheckedAt(nnn[ir]);
+ if(hdata) {
+ cname = hdata->GetName();
+ hname[ir] = cname;
+ fhRawEff[nh] = hdata;
+ nh++;
+ }
}
- //raw data
- if (index == 0) test[specie] = CheckRaw(list[specie]/*,(TObjArray *)QARefRec->GetObject()*/);
+
+ TLine *linelowyellow = new TLine(0, 0.7, 24, 0.7);
+ linelowyellow->SetLineColor(5);
+ linelowyellow->SetLineStyle(3);
+ linelowyellow->SetLineWidth(4);
+ TLine *linelowred = new TLine(0, 0.2, 24, 0.2);
+ linelowred->SetLineColor(2);
+ linelowred->SetLineStyle(3);
+ linelowred->SetLineWidth(4);
+ Float_t thryell = 0.7;
+ // TPaveText* text = new TPaveText(0.30,0.50,0.99,0.99,"NDC");
+ Float_t thrred = 0.2;
+ Float_t chcont =0;
+ for (Int_t ih= 0; ih<4; ih++)
+ {
+ fhRawEff[ih]->SetLineWidth(2);
+ fhRawEff[ih]->SetMaximum(2.);
+ fhRawEff[ih]->SetMinimum(0.);
+ fhRawEff[ih]->GetListOfFunctions()->Add(linelowyellow);
+ fhRawEff[ih]->GetListOfFunctions()->Add(linelowred);
-
- if(index == 2){
- //rec points
- for (Int_t icase=0; icase<2; icase++) {
- for (Int_t idet=0; idet<24; idet++) {
- Double_t mean = fhRecDiff[icase]->
- ProjectionY(Form("%s_py", fhRecDiff[icase]->GetName()),
- idet,idet+1)->GetMean();
- Double_t rms= fhRecDiff[icase]->
- ProjectionY(Form("%s_py", fhRecDiff[icase]->GetName()),
- idet,idet+1)->GetRMS();
- AliDebug(AliQAv1::GetQADebugLevel(), Form("name %s icase %i idet %i mean %f, rms %f\n",
- fhRecDiff[icase]->GetName(), icase, idet, mean,rms));
-
- if(TMath::Abs(mean) >1.5 || rms >1){
- AliDebug(AliQAv1::GetQADebugLevel(), Form(" calibration is nor perfect; test=%f", test)) ;
- test[specie]=0.25;
- }
- if(mean>3 || rms >5) {
- test[specie] = 0.1;
- AliDebug(AliQAv1::GetQADebugLevel(), Form(" wrong calibration test=%f", test[specie])) ;
- }
- }
- }
- }
- if (index == 3) {
- //ESD
- for (Int_t icase=0; icase<2; icase++) {
- Double_t rmsVertex = fhESD[icase]->GetRMS();
- Double_t meanVertex = fhESD[icase]->GetMean();
- test[specie]=1;
- AliDebug(AliQAv1::GetQADebugLevel(), Form("numentries %d meanVertex %f rmsVertex %f", fhESD[icase]->GetEntries(), meanVertex, rmsVertex));
- if (TMath::Abs(rmsVertex)>3) {
- test[specie]=0.25;
- AliDebug(AliQAv1::GetQADebugLevel(), Form("Vertex position resolution not good , rms= %f test=%f",
- rmsVertex, test[specie])) ;
- }
- if (TMath::Abs(meanVertex)>3) {
- test[specie]=0.25;
- AliDebug(AliQAv1::GetQADebugLevel(), Form("Vertex position bad calibrated , Mean= %f test=%f",
- meanVertex, test[specie])) ;
- }
- }
+ Int_t nbins= fhRawEff[ih]->GetNbinsX();
+ Bool_t yell = kFALSE;
+ Bool_t red = kFALSE;
+ for (Int_t in=1; in<nbins-1; in++)
+ {
+ if(ih==0 && in==5) continue;
+ chcont=fhRawEff[ih]->GetBinContent(in);
+ if (chcont < thryell ) yell = kTRUE;
+ if (chcont < thrred ) red = kTRUE;
+ }
+
+ if (! yell && !red) {
+ AliDebug(AliQAv1::GetQADebugLevel(), Form(" efficiency in all channes %s is good", fhRawEff[ih]->GetName() ));
+ checkr=1.;
+ // text->AddText(Form("T0 RUN %d ",AliCDBManager::Instance()->GetRun()));
+ // text->AddText(Form(" No problems "));
+ // text->SetFillColor(3);
+ }
+
+ if(red ) {
+ checkr = 0.;
+ AliDebug(AliQAv1::GetQADebugLevel(), Form(" efficiency in all channes %s is not so good", fhRawEff[ih]->GetName() ));
+ // text->AddText(Form("T0 RUN %d ",AliCDBManager::Instance()->GetRun()));
+ // text->AddText(Form("Very serious problem, call expert "));
+ // text->SetFillColor(2);
+ }
+
+ if ( yell && !red) {
+ AliDebug(AliQAv1::GetQADebugLevel(), Form(" efficiency in all channes %s is not so good", fhRawEff[ih]->GetName() ));
+ checkr=0.75;
+ // text->AddText(Form("T0 RUN %d ",AliCDBManager::Instance()->GetRun()));
+ // text->AddText(Form("Some problems "));
+ // text->SetFillColor(5);
}
- } // if (list->GetEntries() != 0
- AliDebug(AliQAv1::GetQADebugLevel(), Form("Test Result = %f", test[specie])) ;
- }
+ // fhRawEff[ih]->GetListOfFunctions()->Add(text);
+
+ }
+ return checkr;
- return test ;
}
+
//--------------------------------------------------------------------------
-Double_t AliT0QAChecker::CheckRaw(TObjArray *listrec /*, TObjArray *listref*/) const
+Double_t AliT0QAChecker::CheckESD(TObjArray *listrec ) const
{
-
- TH1 *fhRawEff;
- // TH2 *fhRawRef;
- // TIter next(listref) ;
- // Int_t counter=0;
- // Float_t refmean[50];
- // Float_t refrms[50];
Float_t checkr = 0;
- /*
- // Int_t nref = listref->GetEntries();
- // Int_t nrec = listrec->GetEntries();
-
- cout<<" entries in ref "<<nref<<" in rec "<<nrec<<endl;
- // for (Int_t iref=0; iref<nref; iref++){
- while (fhRawRef = dynamic_cast<TH2 *>(next())) {
- // fhRawRef->Dump();
- // fhRawRef =(TH2*) listref->At(iref);
- cout<<counter<<" hist "<<fhRawRef<<endl;
- fhRawRef->Print();
- fhRawRef->Dump();
- refmean[counter] = fhRawRef->GetMean(2);
- cout<<counter<<" mean "<<refmean[counter]<<endl;
- refrms[counter] = fhRawRef->GetRMS(2);
- cout<<counter<<" rms "<<refrms[counter]<<endl;
- counter++;
- cout<<" !!!!! reference "<<counter<<" "<<refmean[counter]<<" "<<refrms[counter]<<endl;
- }
- */
-
- for (Int_t icase=205; icase<208; icase++) {
- fhRawEff = (TH1*) listrec->At(icase);
- for (Int_t idet=0; idet<24; idet++) {
- Double_t mean = fhRawEff->GetBinContent(idet);
- AliDebug(AliQAv1::GetQADebugLevel(),
- Form("name %s icase %i idet %i mean %f \n",
- fhRawEff->GetName(), icase, idet, mean));
-
- if (mean<1.2 && mean> 0.8 ) {
- checkr = 1;
- AliDebug(AliQAv1::GetQADebugLevel(), Form("All channels works meane efficieny %f with test %f", mean, checkr)) ;
- }
- if (mean<=0.8 && mean>= 0.5 ){
- checkr = 0.5;
- AliDebug(AliQAv1::GetQADebugLevel(),
- Form("%s problem in channel %i efficieny %f test %f",
- fhRawEff->GetName(), idet, mean,checkr )) ;
- }
- if (mean<0.5 ) {
- checkr = 0.25;
- AliDebug(AliQAv1::GetQADebugLevel(),
- Form("%s big problem in channel %i efficieny %f test %f",
- fhRawEff->GetName(), idet, mean,checkr )) ;
- }
+ TH1 *fhESD;
+
+ fhESD = (TH1*) listrec->UncheckedAt(2);
+ if(fhESD){
+ AliDebug(AliQAv1::GetQADebugLevel(), Form("count %s ", fhESD->GetName()) );
+ TF1 *f1 = new TF1("f1","gaus",-1,1);
+ fhESD->Fit("f1","R","Q", -1,1);
+ Double_t par[3];
+ f1->GetParameters(&par[0]);
+
+ TPaveText* text = new TPaveText(0.30,0.50,0.99,0.99,"NDC");
+
+ text->AddText(Form("T0 RUN %d ",AliCDBManager::Instance()->GetRun()));
+
+ AliDebug(AliQAv1::GetQADebugLevel(), Form("numentries %f mean %f #sigma %f", fhESD->GetEntries(),par[1], par[2]));
+
+
+ if (par[2] > 0.07 && par[2] < 1.) {
+ checkr=0.5;
+ text->AddText(Form("not good resolution :\n %f ns\n", par[2] ));
+ text->SetFillColor(5);
+ printf("T0 detector resolution is not good enouph: %f ns\n",par[2] );
+ }
+ if(TMath::Abs(par[1])>0.05) {
+ checkr = 0.5;
+ text->AddText(Form(" Check clock shift on %f ns", par[1]));
+ text->SetFillColor(5);
+ }
+ if (par[2] > 1. || TMath::Abs(par[1])>0.1) {
+ checkr = 0.25;
+ text->AddText(Form(" Bad resolution:\n mean %f ns sigma %f ns", par[1], par[2]));
+ text->SetFillColor(2);
+
+ fhESD->GetListOfFunctions()->Add(text);
+ AliDebug(AliQAv1::GetQADebugLevel(),
+ Form("Please, check calibration: shift= %f resolution %f test=%f\n",
+ par[1], par[2], checkr) ) ;
}
}
- /*
- for (Int_t icase=208; icase<210; icase++) {
- fhRawEff = (TH2*) listrec->At(icase);
-
- for (Int_t idet=0; idet<24; idet++) {
- Double_t mean = fhRawEff->
- ProjectionY(Form("%s_py_%i_%i", fhRawEff ->GetName(), idet,icase),
- idet,idet+1)->GetMean();
- Double_t rms= fhRawEff ->
- ProjectionY(Form("%s_py%i_%i",
- fhRawEff ->GetName(), idet,icase),
- idet,idet+1)->GetRMS();
-
-
-
- AliDebug(AliQAv1::GetQADebugLevel(),
- Form("name %s icase %i idet %i mean %f, rms %f\n",
- fhRawEff->GetName(), icase, idet, mean,rms));
+ else
+ {
+ AliDebug(AliQAv1::GetQADebugLevel(),
+ Form("No ESD QA histogram found, nothing to check"));
+ checkr=0;
+ }
+
- }
-
- }
- */
return checkr;
}
-