103 #include "TGraphErrors.h"
111 #include "TPaveText.h"
113 #include "TProfile.h"
119 #include "StEmbeddingQADraw.h"
120 #include "StEmbeddingQAUtilities.h"
121 #include "StMessMgr.h"
122 #include "StParticleDefinition.hh"
124 using namespace std ;
133 const Bool_t isEmbeddingOnly)
134 : mIsEmbeddingOnly(isEmbeddingOnly), mIsGIFOn(kFALSE), mIsJPGOn(kFALSE), mIsEPSOn(kFALSE), mIsPSOn(kFALSE), mGeantId(geantid)
141 mInputEmbedding = 0 ;
145 mIsOpen = open(embeddingFile, realDataFile);
149 TString fileName(embeddingFile);
150 fileName.Remove(fileName.Index(
".root"), fileName.Length());
152 for(Int_t i=0;i<3;i++){
153 const Int_t start = 0 ;
154 const Int_t stop = fileName.First(
"_") ;
155 const TString subString(fileName(start, stop));
157 fileName.Remove(start, stop+1);
160 mYear = subString.Atoi();
161 mProduction = fileName ;
171 mInputParentGeantId = 0 ;
176 const Int_t year,
const TString production,
const Int_t geantid,
const Bool_t isEmbeddingOnly)
177 : mIsEmbeddingOnly(isEmbeddingOnly), mIsGIFOn(kFALSE), mIsJPGOn(kFALSE), mIsEPSOn(kFALSE), mIsPSOn(kFALSE), mGeantId(geantid)
183 mIsOpen = open(embeddingFile, realDataFile);
187 mProduction = production ;
189 mInputParentGeantId = 0 ;
199 mDaughterGeantId.clear();
200 mParentGeantId.clear();
201 mParentParentGeantId.clear();
204 if( mInputEmbedding || mInputEmbedding->IsOpen() ) mInputEmbedding->Close();
205 if( mInputRealData || mInputRealData->IsOpen() ) mInputRealData->Close();
211 mInputParentGeantId = parentgeantid ;
212 LOG_INFO <<
"StEmbeddingQADraw::setParentGeantId Set parent geantid = "
213 << mInputParentGeantId
218 void StEmbeddingQADraw::setPtMax(
const Double_t ptmax)
221 LOG_INFO <<
"StEmbeddingQADraw::setPtMax() Set maximum pt = " << mPtMax
222 <<
" GeV/c to be drawn" << endm;
227 Bool_t StEmbeddingQADraw::open(
const TString embeddingFile,
const TString realDataFile)
232 mInputEmbedding = TFile::Open(embeddingFile);
234 if(!mInputEmbedding || !mInputEmbedding->IsOpen() || mInputEmbedding->IsZombie() ){
235 Error(
"StEmbeddingQADraw",
"can't find %s", embeddingFile.Data());
238 LOG_INFO <<
"OPEN input (embedding) : " << mInputEmbedding->GetName() << endm;
242 if( mIsEmbeddingOnly )
return kTRUE ;
245 mInputRealData = TFile::Open(realDataFile);
247 if(!mInputRealData || !mInputRealData->IsOpen() || mInputRealData->IsZombie() ){
248 Error(
"StEmbeddingQADraw",
"can't find %s", realDataFile.Data());
251 LOG_INFO <<
"OPEN input (real data) : " << mInputRealData->GetName() << endm;
268 mDaughterGeantId.clear();
269 mParentGeantId.clear();
270 mParentParentGeantId.clear();
272 LOG_INFO <<
"#------------------------------------------------------------" << endm;
273 LOG_INFO << Form(
" Year = %10d", mYear) << endm;
274 LOG_INFO << Form(
" Production = %10s", mProduction.Data()) << endm;
276 LOG_INFO <<
"#------------------------------------------------------------" << endm;
282 checkInputGeantId() ;
285 setDaughterGeantId();
288 LOG_INFO <<
"Initialize canvas" << endm ;
289 mCanvas =
new TCanvas(Form(
"c%d", mCanvasId), Form(
"c%d", mCanvasId++), 700, 800);
290 mCanvas->SetFillColor(1);
294 mMainPad =
new TPad(
"mainPad",
"", 0.00, 0.00, 1.00, 0.90);
295 mMainPad->SetFillColor(10);
299 mPDF =
new TPDF(Form(
"%sqa_%s.pdf", mOutputFigureDirectory.Data(), getBaseName()));
300 LOG_INFO <<
"Initialize PDF file : " << mPDF->GetName() << endm ;
304 TPaveText* info =
new TPaveText(0.00, 0.95, 0.63, 1.00);
305 info->SetBorderSize(1);
306 info->SetFillColor(kBlack);
307 info->SetTextFont(42);
308 info->SetTextColor(10);
309 info->SetTextSize(0.030);
311 const Int_t nevents = getEntries() ;
312 TString neventsName(Form(
"%d", getEntries())) ;
313 if( nevents > 1000000 ) neventsName = Form(
"%1.2f M", (Double_t)nevents/1.0e+06);
314 else if ( nevents > 1000 ) neventsName = Form(
"%1.2f K", (Double_t)nevents/1.0e+03);
316 info->AddText(Form(
"N_{events}=%s, MC=%s, %s, (%d)", neventsName.Data(),
getParticleName(), mProduction.Data(), mYear));
322 TLatex* title =
new TLatex(0.1, 0.6,
"Embedding QA");
323 title->SetTextSize(0.10);
326 TString qaName(
"embedding + real");
327 if ( mIsEmbeddingOnly ){
328 qaName =
"embedding only";
331 TLatex* qaTitle =
new TLatex(0.12, 0.5, qaName);
332 qaTitle->SetTextSize(0.07);
337 TLine* lineEmbedding =
new TLine(0, 0, 1, 1);
338 TLine* lineRealBlue =
new TLine(0, 0, 1, 1);
339 TLine* lineRealBlack =
new TLine(0, 0, 1, 1);
340 lineEmbedding->SetLineColor(kRed); lineEmbedding->SetLineWidth(2);
341 lineRealBlue ->SetLineColor(kBlue); lineRealBlue ->SetLineWidth(2);
342 lineRealBlack->SetLineColor(kBlack); lineRealBlack->SetLineWidth(2);
344 TLegend* colorCode =
new TLegend(0.05, 0.15, 0.8, 0.45);
345 colorCode->SetTextSize(0.035);
346 colorCode->SetFillColor(10);
347 colorCode->SetHeader(
"Color code for embedding and real data");
348 colorCode->AddEntry(lineRealBlack,
"MC (black)",
"L");
349 colorCode->AddEntry(lineEmbedding,
"Reconstructed embedding tracks* (red)",
"L");
350 colorCode->AddEntry(lineRealBlue,
"Real** (blue)",
"L");
353 TLatex* note0 =
new TLatex(0.1, 0.10,
"* matched pairs or contaminated pairs");
354 TLatex* note1 =
new TLatex(0.1, 0.05,
"** black is also used, see legend for each pad");
355 note0->SetTextSize(0.03);
356 note1->SetTextSize(0.03);
367 TPaveText* header = initCanvas(
"Event & track selections");
370 TPaveText* eventSelections =
new TPaveText(0.05, 0.60, 0.95, 0.92);
371 eventSelections->SetTextAlign(12);
372 eventSelections->SetBorderSize(1);
373 eventSelections->SetFillColor(10);
374 eventSelections->SetTextColor(kBlack);
375 eventSelections->SetTextSize(0.030);
376 eventSelections->SetTextFont(42);
378 eventSelections->AddText(
"*** Event selections");
380 eventSelections->AddText(Form(
" z-vertex cut : |v_{z}| < %1.1f cm", utility->getZVertexCut()));
382 const vector<UInt_t> triggerId(utility->getTriggerIdCut());
383 if ( !triggerId.empty() ) {
384 TString triggers(
"");
385 for(UInt_t i=0; i<triggerId.size(); i++) {
386 triggers += Form(
"%d", triggerId[i]);
387 if( i != triggerId.size() - 1 ) triggers +=
", ";
389 eventSelections->AddText(Form(
" trigger id cut : id = %s", triggers.Data()));
391 eventSelections->AddText(
"NOTE: Trigger id cut for real data has to be made manually in doEmbeddingQAMaker.C");
392 eventSelections->SetAllWith(
"***",
"color", kRed);
393 eventSelections->SetAllWith(
"***",
"font", 72);
394 eventSelections->SetAllWith(
"***",
"size", 0.033);
395 eventSelections->SetAllWith(
"NOTE",
"color", kBlue);
396 eventSelections->SetAllWith(
"NOTE",
"font", 72);
397 eventSelections->SetAllWith(
"NOTE",
"size", 0.020);
398 eventSelections->Draw();
401 TPaveText* trackSelections =
new TPaveText(0.05, 0.05, 0.95, 0.59);
402 trackSelections->SetTextAlign(12);
403 trackSelections->SetBorderSize(1);
404 trackSelections->SetFillColor(10);
405 trackSelections->SetTextColor(kBlack);
406 trackSelections->SetTextSize(0.030);
407 trackSelections->SetTextFont(42);
408 trackSelections->AddText(
"*** Track selections");
409 trackSelections->AddText(Form(
" %1.1f < p_{T} < %1.1f GeV/c", utility->
getPtMinCut(), utility->getPtMaxCut()));
410 trackSelections->AddText(Form(
" |#eta| < %1.2f", utility->getEtaCut()));
411 trackSelections->AddText(Form(
" |y| < %1.2f", utility->getRapidityCut()));
412 trackSelections->AddText(Form(
" nHitsFit > %3d", utility->getNHitCut()));
413 trackSelections->AddText(Form(
" nHitsFit/nHitsPoss > %1.2f", utility->getNHitToNPossCut()));
414 trackSelections->AddText(Form(
" global Dca < %1.1f cm", utility->getDcaCut()));
415 trackSelections->AddText(Form(
" |n#sigma| < %1.1f, using %s", utility->getNSigmaCut(),utility->getBTofPid()?
"BTOF":
"TPC dE/dx"));
416 trackSelections->AddText(
"NOTE1: Rapidity cut for real data has to be made manually in doEmbeddingQAMaker.C");
417 trackSelections->AddText(
"NOTE2: Cut on its own variable is currently disabled, e.x. no dca cut for dca histogram");
418 trackSelections->SetAllWith(
"***",
"color", kRed);
419 trackSelections->SetAllWith(
"***",
"font", 72);
420 trackSelections->SetAllWith(
"***",
"size", 0.033);
421 trackSelections->SetAllWith(
"NOTE",
"color", kBlue);
422 trackSelections->SetAllWith(
"NOTE",
"font", 72);
423 trackSelections->SetAllWith(
"NOTE",
"size", 0.020);
424 trackSelections->Draw();
438 mOutputFigureDirectory = name ;
441 if( gSystem->AccessPathName(name) == kTRUE ){
442 Error(
"setOutputDirectory",
"Directory %s does not exist. Set current directory as the output location",name.Data());
443 mOutputFigureDirectory =
"./";
447 if ( mOutputFigureDirectory.Last(
'/') + 1 != mOutputFigureDirectory.Length() ){
449 LOG_INFO <<
"Put / at the end of output directory name" << endm;
450 mOutputFigureDirectory.Append(
"/");
453 LOG_INFO <<
"Set output directory for figures : " << mOutputFigureDirectory << endm;
457 void StEmbeddingQADraw::print(
const TCanvas& canvas,
const TString name)
const
461 if( mIsPNGOn ) canvas.Print(Form(
"%s%s_%s.png", mOutputFigureDirectory.Data(), name.Data(), getBaseName()));
462 if( mIsGIFOn ) canvas.Print(Form(
"%s%s_%s.gif", mOutputFigureDirectory.Data(), name.Data(), getBaseName()));
463 if( mIsJPGOn ) canvas.Print(Form(
"%s%s_%s.jpg", mOutputFigureDirectory.Data(), name.Data(), getBaseName()));
464 if( mIsEPSOn ) canvas.Print(Form(
"%s%s_%s.eps", mOutputFigureDirectory.Data(), name.Data(), getBaseName()));
465 if( mIsPSOn ) canvas.Print(Form(
"%s%s_%s.ps", mOutputFigureDirectory.Data(), name.Data(), getBaseName()));
469 void StEmbeddingQADraw::checkInputGeantId()
474 TH1* hGeantId = (TH1D*) getHistogram(
"hGeantId_0");
483 for(Int_t
id=0;
id<hGeantId->GetNbinsX();
id++){
484 const Bool_t isGeantIdOk = hGeantId->GetBinContent(
id+1)>0.0;
485 if(!isGeantIdOk) continue ;
487 const Int_t geantid = TMath::Nint(hGeantId->GetBinLowEdge(
id+1));
488 mMcGeantId.push_back(geantid);
493 if( mMcGeantId.size() == 1 ){
498 if ( mGeantId == mMcGeantId[0] ) return ;
500 LOG_INFO <<
"#----------------------------------------------------------------------------------------------------" << endm;
501 LOG_INFO <<
" Input geant id doesn't correspond to the geant id in the MC histogram" << endm ;
502 LOG_INFO <<
" Geantid in the MC histogram, geantid = " << mMcGeantId[0]
504 LOG_INFO <<
" Do you want to proceed to the QA for geantid = " << mMcGeantId[0] <<
" ?" << endm;
505 LOG_INFO <<
" [yes=1/no=0]:" << endm;
506 UInt_t proceedQA = 0 ;
508 LOG_INFO <<
"#----------------------------------------------------------------------------------------------------" << endm;
514 mGeantId = mMcGeantId[0] ;
522 for(vector<Int_t>::iterator iter = mMcGeantId.begin(); iter != mMcGeantId.end(); iter++){
523 const Int_t geantidFound = (*iter) ;
524 if ( mGeantId == geantidFound ) return ;
528 LOG_INFO <<
"#----------------------------------------------------------------------------------------------------" << endm;
529 LOG_INFO <<
" Cannot find input geantid in the MC histogram" << endm;
530 LOG_INFO <<
" Available geantid's are listed below;" << endm;
531 LOG_INFO <<
" geantid particle name" << endm;
532 for(vector<Int_t>::iterator iter = mMcGeantId.begin(); iter != mMcGeantId.end(); iter++){
533 const Int_t geantidFound = (*iter) ;
534 LOG_INFO << Form(
" %5d %10s", geantidFound,
537 LOG_INFO <<
" Which geantid you want to do the QA ?" << endm;
538 LOG_INFO <<
" [Put the one geantid listed above. If you want to stop the program, please put 0]:" << endm;
544 LOG_INFO <<
" QA for geantid = " << mGeantId
546 LOG_INFO <<
"#----------------------------------------------------------------------------------------------------" << endm;
552 Bool_t StEmbeddingQADraw::isOpen()
const
560 if(!mIsOpen) LOG_INFO <<
"No input files found" << endm;
563 const Bool_t isGeantIdOk = mGeantId>0 ;
564 if(!isGeantIdOk) LOG_INFO <<
"Cannot find input geantid in the histogram or no histogram in the input" << endm;
571 Bool_t StEmbeddingQADraw::isMatchedPairOk()
const
599 void StEmbeddingQADraw::setDaughterGeantId()
604 if(isMatchedPairOk()){
606 mDaughterGeantId.push_back(mGeantId);
608 mParentGeantId.push_back(0);
609 mParentParentGeantId.push_back(0);
614 for(UInt_t
id=0;
id<1000;
id++){
616 const Int_t contamCategoryId = utility->
getCategoryId(
"CONTAM") ;
619 if( mInputParentGeantId == 0 ) n = 1 ;
622 for(Int_t i=0; i<n; i++) {
623 Int_t daughterId = id ;
624 Int_t parentId = mGeantId ;
625 Int_t parentParentId = 0 ;
628 parentId = mInputParentGeantId ;
629 parentParentId = mGeantId ;
633 TH3* hDca = (TH3D*) mInputEmbedding->Get(Form(
"hDca_%d_%d_%d_%d", contamCategoryId, parentParentId, parentId, daughterId)) ;
640 LOG_INFO << Form(
"Find daughter %10s from parent %10s", daughterName, parentName) << endm;
647 LOG_INFO << Form(
"Find daughter %10s from parent %10s (from %10s)", daughterName, parentName, parentparentName) << endm;
650 mDaughterGeantId.push_back(
id);
651 mParentGeantId.push_back(parentId);
652 mParentParentGeantId.push_back(parentParentId);
658 if ( mDaughterGeantId.empty() ) mDaughterGeantId.push_back(mGeantId);
662 Int_t StEmbeddingQADraw::getEntries()
const
666 TH1* hVz = (TH1D*) getHistogram(
"hVzAccepted");
669 return (Int_t)( hVz->GetEntries() );
673 Bool_t StEmbeddingQADraw::isDecay()
const
679 if(isMatchedPairOk())
return kFALSE ;
682 return ( mDaughterGeantId.size() > 1 ) ;
686 Int_t StEmbeddingQADraw::getGeantIdReal(
const Int_t daughter)
const
691 if(mDaughterGeantId[daughter]==6)
return 9;
696 Int_t StEmbeddingQADraw::getCategoryId(
const Bool_t isEmbedding)
const
714 TObject* StEmbeddingQADraw::getHistogram(
const TString name,
const Bool_t isEmbedding)
const
718 if(!isOpen())
return 0;
722 if( mIsEmbeddingOnly && !isEmbedding)
return 0 ;
724 TObject* obj = (isEmbedding) ? mInputEmbedding->Get(name) : mInputRealData->Get(name) ;
726 Error(
"StEmbeddingQADraw::getHistogram",
"Histogram %s doesn't exist", name.Data());
730 LOG_DEBUG <<
"StEmbeddingQADraw::getHistogram() get histogram = " << name << endm;
737 TObject* StEmbeddingQADraw::getHistogram(
const TString name,
const UInt_t daughter,
const Bool_t isEmbedding,
738 const UInt_t parentparentid)
const
745 if ( daughter >= mDaughterGeantId.size() ){
746 Error(
"StEmbeddingQADraw::getHistogram",
"Unknown daughter index, index=%3d", daughter);
750 return getHistogram(getHistogramName(name, daughter, isEmbedding, parentparentid), isEmbedding) ;
754 const Char_t* StEmbeddingQADraw::getHistogramName(
const TString name,
const UInt_t daughter,
const Bool_t isEmbedding,
755 const UInt_t parentparentid)
const
757 const Int_t category = getCategoryId(isEmbedding) ;
767 return Form(
"%s_%d_%d_%d_%d", name.Data(), category, mParentParentGeantId[daughter], mParentGeantId[daughter], mDaughterGeantId[daughter]) ;
770 return Form(
"%s_%d_%d", name.Data(), category, mGeantId) ;
777 const Int_t geantidReal = getGeantIdReal(daughter) ;
779 return Form(
"%s_%d_%d", name.Data(), category, geantidReal) ;
784 Double_t StEmbeddingQADraw::getNormalization(
const TH1& h)
const
789 const Double_t ntrack = h.Integral() ;
790 if( ntrack == 0 )
return 1.0 ;
792 const Double_t binWidth = h.GetBinWidth(1) ;
793 if( binWidth == 0.0 )
return 1.0 ;
795 return 1.0/(ntrack*binWidth);
799 const Char_t* StEmbeddingQADraw::getBaseName()
const
807 Bool_t StEmbeddingQADraw::drawStatistics(
const Double_t x1,
const Double_t y1,
const Double_t x2,
const Double_t y2,
808 const Double_t textSize)
const
816 TPaveText* statistics =
new TPaveText(x1, y1, x2, y2);
817 statistics->SetTextFont(42);
818 statistics->SetTextSize(textSize);
819 statistics->SetBorderSize(1);
820 statistics->SetFillColor(10);
821 statistics->AddText(Form(
"N_{evts} = %d", getEntries()));
822 statistics->AddText(Form(
"Year: %d", mYear));
823 statistics->AddText(Form(
"Production: %s", mProduction.Data()));
831 TPaveText* StEmbeddingQADraw::drawHeader(
const TString description,
832 const Double_t x1,
const Double_t y1,
const Double_t x2,
const Double_t y2,
const Double_t textSize)
const
835 TPaveText* header =
new TPaveText(x1, y1, x2, y2);
836 header->SetBorderSize(1);
837 header->SetFillColor(kBlack);
838 header->SetTextColor(10);
839 header->SetTextSize(textSize);
840 header->SetTextFont(42);
841 header->AddText(description);
848 void StEmbeddingQADraw::drawLegend(
const UInt_t
id, TH1* hembed, TH1* hreal,
849 const Option_t* option,
const Bool_t doSplit)
const
851 TLegend* leg =
new TLegend(0, 0.2, 1, 0.8);
852 leg->SetFillColor(10);
855 leg->SetTextFont(43);
856 leg->SetTextSize(15);
858 leg->AddEntry(hembed, getEmbeddingParticleName(
id, doSplit), option) ;
859 if(hreal) leg->AddEntry(hreal, getRealParticleName(
id, doSplit), option) ;
864 void StEmbeddingQADraw::drawErrorMessages(
const TString histogramName)
const
867 const Int_t categoryId = getCategoryId() ;
870 TPaveText* error0 =
new TPaveText(0.05, 0.60, 0.95, 0.92,
"NDC");
871 error0->SetTextAlign(12);
872 error0->SetBorderSize(1);
873 error0->SetFillColor(10);
874 error0->SetTextColor(kBlack);
875 error0->SetTextSize(0.030);
876 error0->SetTextFont(42);
877 error0->AddText(Form(
"*** No histogram \"%s\" found", histogramName.Data()));
878 error0->AddText(Form(
"Please make sure that you have %s in the minimc.root.", title.Data()));
879 error0->AddText(
"Open minimc.root file and then check number of tracks.");
880 error0->AddText(Form(
"There are maybe no %s in the minimc.", title.Data()));
881 error0->AddText(
"Or you used older base QA codes.");
882 error0->AddText(
"In case you have finite number of tracks,");
883 error0->AddText(
"please also have a look at geantid.");
884 error0->SetAllWith(
"***",
"color", kRed);
885 error0->SetAllWith(
"***",
"font", 72);
886 error0->SetAllWith(
"***",
"size", 0.033);
889 TPaveText* error1 =
new TPaveText(0.05, 0.05, 0.95, 0.55,
"NDC");
890 error1->SetTextAlign(12);
891 error1->SetBorderSize(1);
892 error1->SetFillColor(10);
893 error1->SetTextColor(kBlack);
894 error1->SetTextSize(0.025);
895 error1->SetTextFont(42);
896 error1->AddText(
"See example below how to check number of tracks and geantid");
899 error1->AddText(
"[ROOT]> StMiniMcTree->Draw(\"mNContamPair\")");
900 error1->AddText(
"or");
901 error1->AddText(
"[ROOT]> StMiniMcTree->Scan(\"mNContamPair\")");
902 error1->AddText(Form(
"For geantid in %s", title.Data()));
903 error1->AddText(
"[ROOT]> StMiniMcTree->Draw(\"mContamPairs.mGeantId\")");
904 error1->AddText(
"or use \"Scan()\" function");
907 error1->AddText(
"[ROOT]> StMiniMcTree->Draw(\"mNMatchedPair\")");
908 error1->AddText(
"or");
909 error1->AddText(
"[ROOT]> StMiniMcTree->Scan(\"mNMatchedPair\")");
910 error1->AddText(Form(
"For geantid in %s", title.Data()));
911 error1->AddText(
"[ROOT]> StMiniMcTree->Draw(\"mMatchedPairs.mGeantId\")");
912 error1->AddText(
"or use \"Scan()\" function");
914 error1->SetAllWith(
"ROOT",
"color", kBlue);
915 error1->SetAllWith(
"ROOT",
"font", 52);
916 error1->SetAllWith(
"ROOT",
"size", 0.028);
928 const Int_t
id = (geantid<0) ? mGeantId : geantid ;
932 Error(
"StEmbeddingQADraw::getParticleName",
"Can't find particle geantid=%d in StParticleDefinition",
id);
942 name = particle->name().c_str();
943 while( name.Contains(
"/") ) name.Remove(name.Index(
"/"), 1);
944 while( name.Contains(
"(") ) name.Remove(name.Index(
"("), 1);
945 while( name.Contains(
")") ) name.Remove(name.Index(
")"), 1);
946 while( name.Contains(
"*") ) name.Replace(name.Index(
"*"), 1,
"star");
952 const Char_t* StEmbeddingQADraw::getMcParticleName()
const
955 const Int_t categoryId = getCategoryId() ;
957 const TString parent( (utility->
isContaminated(name)) ?
"Parent " :
"" );
959 return Form(
"%s%s (MC, geantid=%d)", parent.Data(),
getParticleName(mGeantId), mGeantId);
963 const Char_t* StEmbeddingQADraw::getEmbeddingParticleName(
const UInt_t
id,
const Bool_t doSplit)
const
965 if(
id>=mDaughterGeantId.size()){
966 Error(
"StEmbeddingQADraw::getEmbeddingParticleName",
"Unknown daughter particle index, id=%3d",
id);
971 const Int_t categoryId = getCategoryId() ;
977 const Int_t parentParentId = mParentParentGeantId[id] ;
978 const Int_t parentId = mParentGeantId[id] ;
979 const Int_t daughterId = mDaughterGeantId[id] ;
981 const TString daughter( (utility->
isContaminated(name)) ?
"Daughter " :
"" );
984 if ( parentId != 0 ) {
987 if ( parentParentId == 0 ) {
988 parent =
" (from " + parentName +
")";
992 parent =
" (from " + parentName +
" #leftarrow " + parentParentName +
")";
996 return (doSplit) ? Form(
"#splitline{%s%s%s}{(%s, geantid=%d)}", daughter.Data(),
getParticleName(daughterId),
997 parent.Data(), utility->
getCategoryName(categoryId).Data(), daughterId)
998 : Form(
"%s%s%s (%s, geantid=%d)", daughter.Data(),
getParticleName(daughterId),
999 parent.Data(), utility->
getCategoryName(categoryId).Data(), daughterId);
1003 const Char_t* StEmbeddingQADraw::getRealParticleName(
const UInt_t
id,
const Bool_t doSplit)
const
1008 if(
id>=mDaughterGeantId.size()){
1009 Error(
"StEmbeddingQADraw::getRealParticleName",
"Unknown daughter particle index, id=%3d",
id);
1013 const Int_t geantid = getGeantIdReal(
id) ;
1014 return (doSplit) ? Form(
"#splitline{%s}{(%s, |n #sigma_{%s}|<2 %s)}",
getParticleName(geantid),
1026 LOG_INFO <<
"----------------------------------------------------------------------------------------------------" << endm ;
1027 LOG_INFO <<
"QA for Event-wise informations ..." << endm;
1030 if(!isOpen())
return kFALSE ;
1046 drawNumberOfParticles() ;
1048 LOG_INFO <<
"----------------------------------------------------------------------------------------------------" << endm ;
1055 Bool_t StEmbeddingQADraw::drawVertices()
const
1058 LOG_INFO <<
"QA for event-vertices ..." << endm;
1061 const Double_t vzMin = getVzAcceptedMinimum() ;
1062 const Double_t vzMax = getVzAcceptedMaximum() ;
1063 TPaveText* header = initCanvas(Form(
"Event vertices, offline cuts: %1.1f < v_{z} < %1.1f cm", vzMin, vzMax), 2, 2);
1067 TH1* hVz = (TH1D*) getHistogram(
"hVz");
1068 if(!hVz)
return kFALSE ;
1070 TH1* hVzAccepted = (TH1D*) getHistogram(
"hVzAccepted");
1071 if(!hVzAccepted)
return kFALSE ;
1073 hVzAccepted->SetLineColor(kCyan);
1074 hVzAccepted->SetFillColor(kCyan);
1076 hVzAccepted->Draw(
"same");
1081 TH2* hVyVx = (TH2D*) getHistogram(
"hVyVx");
1082 if(!hVyVx)
return kFALSE ;
1083 hVyVx->Draw(
"colz");
1087 TH2* hVxVz = (TH2D*) getHistogram(
"hVxVz");
1088 if(!hVxVz)
return kFALSE ;
1089 hVxVz->SetAxisRange(vzMin, vzMax,
"X");
1090 hVxVz->Draw(
"colz");
1094 TH2* hVyVz = (TH2D*) getHistogram(
"hVyVz");
1095 if(!hVyVz)
return kFALSE ;
1096 hVyVz->SetAxisRange(vzMin, vzMax,
"X");
1097 hVyVz->Draw(
"colz");
1105 header = initCanvas(
"Event vertices, #Deltav = v(Data) - v(MC)", 2, 2);
1108 for(Int_t i=0; i<3; i++){
1111 if( i == 0 ) hdV = (TH1D*) getHistogram(
"hdVx");
1112 if( i == 1 ) hdV = (TH1D*) getHistogram(
"hdVy");
1113 if( i == 2 ) hdV = (TH1D*) getHistogram(
"hdVz");
1114 if(!hdV)
return kFALSE ;
1131 Bool_t StEmbeddingQADraw::drawRunEventId()
const
1134 LOG_INFO <<
"QA for run and event id ..." << endm;
1136 TPaveText* header = initCanvas(
"Run and event id", 2, 2);
1139 TH1* hRunNumber = (TH1D*) mInputEmbedding->Get(
"hRunNumber");
1140 if(!hRunNumber)
return kFALSE ;
1144 TH1* hEventId = (TH1D*) mInputEmbedding->Get(
"hEventId");
1145 if(!hEventId)
return kFALSE ;
1149 TPaveText* runlist[2];
1150 for(Int_t i=0;i<2;i++){
1151 runlist[i] =
new TPaveText(0.1, 0.05, 0.9, 0.95);
1152 runlist[i]->SetTextFont(42);
1153 runlist[i]->SetTextSize(0.04);
1154 runlist[i]->SetBorderSize(1);
1155 runlist[i]->SetFillColor(10);
1156 runlist[i]->AddText(
"Run id statistics");
1160 Int_t runTotal = 0 ;
1161 for(Int_t irun=0; irun<hRunNumber->GetNbinsX(); irun++){
1162 if(hRunNumber->GetBinContent(irun+1)>0.0) runTotal++;
1166 Int_t runAccepted = 0 ;
1167 for(Int_t irun=0; irun<hRunNumber->GetNbinsX(); irun++){
1168 const Double_t count = hRunNumber->GetBinContent(irun+1);
1169 if(count==0.0) continue ;
1172 if( runTotal < 10 ) pad = 0 ;
1175 if( runAccepted < runTotal/2 ) pad = 0;
1180 runlist[pad]->AddText(Form(
"%10d %10d events", runid, (Int_t)count));
1203 Bool_t StEmbeddingQADraw::drawNumberOfParticles()
const
1206 LOG_INFO <<
"QA for multiplicity distributions (number of particles per event) ..." << endm;
1208 TPaveText* header = initCanvas(
"Multiplicity distribution", 2, 3);
1210 for(UInt_t ic=0; ic<StEmbeddingQAConst::mNEmbedding; ic++){
1212 mMainPad->GetPad(ic+1)->SetLogy();
1214 TH1* hNParticles = (TH1D*) mInputEmbedding->Get(Form(
"hNParticles_%d", ic));
1215 if(!hNParticles)
return kFALSE ;
1217 TString title(hNParticles->GetTitle());
1218 title.Remove(0, title.Index(
',')+2);
1219 hNParticles->SetTitle(title);
1222 if( hNParticles->GetMean() == 0 && hNParticles->GetRMS() == 0 ){
1224 hNParticles->SetAxisRange(0, 10,
"X");
1226 LOG_DEBUG <<
"StEmbeddingQADraw::drawNumberOfParticles no particles for " << title << endm ;
1228 else if( hNParticles->GetRMS() == 0 ){
1230 const Double_t mean = hNParticles->GetMean() ;
1231 const Double_t xmin = (mean-10.0<0.0) ? 0.0 : mean-10.0 ;
1232 const Double_t xmax = mean + 10.0 ;
1233 hNParticles->SetAxisRange(xmin, xmax,
"X");
1235 LOG_DEBUG <<
"StEmbeddingQADraw::drawNumberOfParticles constant number of particles = " << mean
1243 Double_t xmax = 0.0 ;
1244 for(Int_t i=hNParticles->GetNbinsX()-1; i!=0; i--){
1245 if( hNParticles->GetBinContent(i+1) != 0.0 ){
1247 xmax = hNParticles->GetBinCenter(i+1) ;
1251 hNParticles->SetAxisRange(0, xmax+10,
"X");
1253 LOG_DEBUG <<
"StEmbeddingQADraw::drawNumberOfParticles varied multiplicity, max range = " << xmax
1258 hNParticles->Draw();
1276 LOG_INFO <<
"QA for MC tracks (pt, eta, y, phi) ..." << endm;
1279 if(!isOpen())
return kFALSE ;
1283 TPaveText* header = initCanvas(
"MC track QA (2D)", 2, 2);
1287 TH2* hPtVsEta = (TH2D*) getHistogram(Form(
"hPtVsEta_0_%d", mGeantId));
1288 if(!hPtVsEta)
return kFALSE;
1290 hPtVsEta->SetTitle(
"");
1291 hPtVsEta->Draw(
"colz");
1292 hPtVsEta->SetAxisRange(0, mPtMax,
"Y");
1296 TH2* hPtVsY = (TH2D*) getHistogram(Form(
"hPtVsY_0_%d", mGeantId));
1297 if(!hPtVsY)
return kFALSE ;
1299 hPtVsY->SetTitle(
"");
1300 hPtVsY->Draw(
"colz");
1301 hPtVsY->SetAxisRange(0, mPtMax,
"Y");
1305 TH2* hPtVsPhi = (TH2D*) getHistogram(Form(
"hPtVsPhi_0_%d", mGeantId));
1306 if(!hPtVsPhi)
return kFALSE ;
1308 hPtVsPhi->SetTitle(
"");
1309 hPtVsPhi->Draw(
"colz");
1310 hPtVsPhi->SetAxisRange(0, mPtMax,
"Y");
1320 header = initCanvas(
"MC track QA (1D)", 2, 2);
1323 TH1* hPt = (TH1D*) hPtVsPhi->ProjectionY(
"hPtMc");
1324 TH1* hEta = (TH1D*) hPtVsEta->ProjectionX(
"hEtaMc");
1325 TH1* hY = (TH1D*) hPtVsY->ProjectionX(
"hYMc");
1326 TH1* hPhi = (TH1D*) hPtVsPhi->ProjectionX(
"hPhiMc");
1327 hPt->SetTitleOffset(1.0,
"X");
1328 hPt->SetXTitle(
"p_{T} (GeV/c)");
1329 hEta->SetXTitle(
"#eta");
1330 hY->SetXTitle(
"rapidity");
1342 hPt->SetMinimum(0.0);
1343 hPt->SetMaximum(hPt->GetMaximum()*1.2);
1344 hPt->SetAxisRange(0, mPtMax,
"X");
1345 hEta->SetMinimum(0.0);
1346 hEta->SetMaximum(hEta->GetMaximum()*1.2);
1347 hY->SetMinimum(0.0);
1348 hY->SetMaximum(hY->GetMaximum()*1.2);
1349 hPhi->SetMinimum(0.0);
1350 hPhi->SetMaximum(hPhi->GetMaximum()*1.2);
1356 gStyle->SetOptFit(1);
1357 for(Int_t ipad=0; ipad<4; ipad++){
1358 mMainPad->cd(ipad+1);
1360 if( ipad == 0 ) hdraw = hPt ;
1361 if( ipad == 1 ) hdraw = hEta ;
1362 if( ipad == 2 ) hdraw = hY ;
1363 if( ipad == 3 ) hdraw = hPhi ;
1369 Double_t min = -1.0 ;
1370 Double_t max = 1.0 ;
1371 if( ipad == 3 ){ min = -TMath::Pi() ; max = TMath::Pi() ; }
1373 TF1* pol0Fit =
new TF1(Form(
"pol0Fit_%d", ipad),
"pol0", min, max);
1374 pol0Fit->SetLineColor(kRed);
1375 pol0Fit->SetLineWidth(1);
1376 pol0Fit->SetLineStyle(2);
1377 pol0Fit->SetParameter(0, hdraw->GetMean(2));
1378 hdraw->Fit(pol0Fit,
"rq0");
1379 pol0Fit->Draw(
"same");
1390 gStyle->SetOptFit(0);
1400 LOG_INFO <<
"#----------------------------------------------------------------------------------------------------" << endm ;
1401 LOG_INFO <<
"QA for reconstructed tracks ..." << endm ;
1404 if(!isOpen())
return kFALSE ;
1412 const Bool_t isPhiOk =
drawPhi();
1419 const Bool_t isPtOk =
drawPt();
1422 const Bool_t isdEdxOk =
drawdEdx();
1425 const Bool_t isDcaOk =
drawDca();
1428 const Bool_t isNHitOk =
drawNHit();
1430 LOG_INFO <<
"#----------------------------------------------------------------------------------------------------" << endm ;
1433 return isGeantIdOk && isPhiOk && isRapidityOk && isMomentumOk && isPtOk && isdEdxOk && isDcaOk && isNHitOk ;
1441 LOG_INFO <<
"QA for geant id ..." << endm;
1444 if(!isOpen())
return kFALSE ;
1449 TPaveText* header = initCanvas(
"Geant id", 1, 2);
1452 TPad* topPad = (TPad*) mMainPad->cd(1);
1453 topPad->Divide(2, 1);
1455 TH1* hGeantIdMc = (TH1D*) getHistogram(
"hGeantId_0");
1456 if(!hGeantIdMc)
return kFALSE ;
1459 const Int_t mcIdBin = hGeantIdMc->GetMaximumBin() ;
1460 const Double_t mcId = hGeantIdMc->GetBinCenter(mcIdBin);
1461 const Double_t mcIdMin = (mcId-10<0) ? 0 : mcId-10 ;
1462 const Double_t mcIdMax = mcId + 10 ;
1465 hGeantIdMc->SetMaximum(hGeantIdMc->GetMaximum()*1.2);
1466 hGeantIdMc->SetAxisRange(mcIdMin, mcIdMax,
"X");
1470 TLine* hGeantIdMcExpected =
new TLine(mGeantId+0.5, 0, mGeantId+0.5, hGeantIdMc->GetMaximum()) ;
1471 hGeantIdMcExpected->SetLineColor(kBlue);
1472 hGeantIdMcExpected->Draw();
1476 TH1* hGeantIdReco = (TH1D*) getHistogram(Form(
"hGeantId_%d", getCategoryId()));
1477 if(!hGeantIdReco)
return kFALSE ;
1479 hGeantIdReco->SetTitle(
"Reconstructed geant id");
1480 hGeantIdReco->SetMaximum(hGeantIdReco->GetMaximum()*1.2);
1481 hGeantIdReco->SetAxisRange(0, 50,
"X");
1482 hGeantIdReco->Draw();
1485 TLine** hGeantIdRecoExpected =
new TLine*[mDaughterGeantId.size()];
1487 for(UInt_t
id=0;
id<mDaughterGeantId.size();
id++){
1488 const Int_t geantid = mDaughterGeantId[id] ;
1489 hGeantIdRecoExpected[id] =
new TLine(geantid+0.5, 0, geantid+0.5, hGeantIdReco->GetMaximum()) ;
1490 hGeantIdRecoExpected[id]->SetLineColor(kRed);
1491 hGeantIdRecoExpected[id]->SetLineStyle(
id+1);
1492 hGeantIdRecoExpected[id]->Draw();
1496 TLegend* leg =
new TLegend(0.1, 0.2, 0.9, 0.8);
1497 leg->SetTextSize(0.05);
1498 leg->SetFillColor(10);
1499 leg->SetHeader(
"Particle informations");
1501 leg->AddEntry(hGeantIdMcExpected, getMcParticleName(),
"L");
1503 for(UInt_t
id=0;
id<mDaughterGeantId.size();
id++){
1504 leg->AddEntry( hGeantIdRecoExpected[
id], getEmbeddingParticleName(
id),
"L");
1524 if(!isOpen())
return kFALSE ;
1527 Bool_t isPhiEmbeddingVsMcOk = drawProjection2D(
"phi", kTRUE);
1530 Bool_t isPhiEmbeddingVsRealOk = drawProjection2D(
"phi", kFALSE);
1532 return isPhiEmbeddingVsMcOk && isPhiEmbeddingVsRealOk ;
1541 if(!isOpen())
return kFALSE ;
1544 const Bool_t isEtaOk = drawProjection2D(
"eta");
1547 const Bool_t isYOk = drawProjection2D(
"y");
1549 return isEtaOk && isYOk ;
1558 if(!isOpen())
return kFALSE ;
1561 for(UInt_t
id=0;
id<mDaughterGeantId.size();
id++){
1562 TPaveText* header = 0 ;
1564 TH2* hRecoPVsMcP = (TH2D*) getHistogram(
"hRecoPVsMcP",
id, kTRUE);
1567 header = initCanvas(
"Reconstructed momentum vs MC momentum");
1568 drawErrorMessages(getHistogramName(
"hRecoPVsMcP",
id, kTRUE)) ;
1579 header = initCanvas(
"Reconstructed momentum vs MC momentum");
1581 hRecoPVsMcP->SetAxisRange(0, mPtMax,
"X");
1582 hRecoPVsMcP->SetAxisRange(0, mPtMax,
"Y");
1586 hRecoPVsMcP->Draw(
"colz");
1596 return drawProjection2D(
"momentum");
1605 if(!isOpen())
return kFALSE ;
1608 for(UInt_t
id=0;
id<mDaughterGeantId.size();
id++){
1609 TPaveText* header = 0 ;
1611 TH2* hdInvPtVsPt = (TH2D*) getHistogram(
"hdInvPtVsPt",
id, kTRUE);
1614 header = initCanvas(Form(
"1/p_{T} (Gl) - 1/p_{T} (MC) vs p_{T} (MC) (%s)",
getParticleName(mDaughterGeantId[
id])));
1615 drawErrorMessages(getHistogramName(
"hdInvPtVsPt",
id, kTRUE)) ;
1626 gStyle->SetPadRightMargin(0.15);
1628 header = initCanvas(Form(
"1/p_{T} (Gl) - 1/p_{T} (MC) vs p_{T} (MC) (%s)",
getParticleName(mDaughterGeantId[
id])), 1, 2);
1631 hdInvPtVsPt->SetAxisRange(0, mPtMax,
"X");
1632 hdInvPtVsPt->SetTitle(
"");
1633 hdInvPtVsPt->Draw(
"colz");
1637 TProfile* pdInvPtVsPt = (TProfile*) hdInvPtVsPt->ProfileX(Form(
"p%s", hdInvPtVsPt->GetName()));
1638 pdInvPtVsPt->SetAxisRange(0, mPtMax,
"X");
1639 pdInvPtVsPt->SetTitle(
"");
1640 pdInvPtVsPt->SetYTitle(hdInvPtVsPt->GetYaxis()->GetTitle());
1641 pdInvPtVsPt->SetLineWidth(2);
1642 pdInvPtVsPt->SetMinimum(hdInvPtVsPt->GetYaxis()->GetXmin());
1643 pdInvPtVsPt->SetMaximum(hdInvPtVsPt->GetYaxis()->GetXmax());
1644 pdInvPtVsPt->Draw();
1654 gStyle->SetPadRightMargin(0.05);
1656 return drawProjection2D(
"pt");
1660 Bool_t StEmbeddingQADraw::drawProjection2D(
const TString name,
const Bool_t isMC)
const
1677 TString nameLower(name);
1678 nameLower.ToLower();
1680 LOG_INFO <<
"QA for " << name <<
" ..." << endm;
1683 TString histoName(
"");
1684 Bool_t isProjectionX = kFALSE ;
1688 if( nameLower.Contains(
"pt") ){
1691 histoName =
"hPtVsEta";
1692 isProjectionX = kFALSE ;
1694 else if( nameLower.Contains(
"momentum") ){
1697 histoName =
"hMomVsEta";
1698 isProjectionX = kFALSE ;
1700 else if( nameLower.Contains(
"eta") || name.Contains(
"pseudorapidity") ){
1703 histoName =
"hPtVsEta";
1704 isProjectionX = kTRUE ;
1706 else if( nameLower.Contains(
"y") || name.Contains(
"rapidity") ){
1709 histoName =
"hPtVsY";
1710 isProjectionX = kTRUE ;
1712 else if( nameLower.Contains(
"phi")){
1715 histoName =
"hPtVsPhi";
1716 isProjectionX = kTRUE ;
1719 Error(
"DrawProjection2D",
"Unknown variable, %s", name.Data());
1720 LOG_INFO <<
" Current implemented variables are" << endm;
1721 LOG_INFO <<
"-----------------------------------------------------------------" << endm;
1722 LOG_INFO <<
" Input variable" << endm;
1723 LOG_INFO <<
"-----------------------------------------------------------------" << endm;
1724 LOG_INFO <<
" pt p_{T}" << endm;
1725 LOG_INFO <<
" momentum p" << endm;
1726 LOG_INFO <<
" eta or pseudorapidity eta" << endm;
1727 LOG_INFO <<
" y or rapidity y" << endm;
1728 LOG_INFO <<
" phi phi" << endm;
1729 LOG_INFO <<
"-----------------------------------------------------------------" << endm;
1731 LOG_INFO <<
"NOTE : Input is case insensitive" << endm;
1737 gStyle->SetPadRightMargin(0.05);
1740 TH2* h2DMc = (TH2D*) getHistogram(Form(
"%s_0_%d", histoName.Data(), mGeantId));
1742 for(UInt_t
id=0;
id<mDaughterGeantId.size();
id++){
1743 const TString headerTitle(Form(
"Projection of %s for each %s bin", yTitle.Data(), xTitle.Data()));
1744 TPaveText* header = 0 ;
1746 TH2* h2DEmbed = (TH2D*) getHistogram(histoName,
id, kTRUE);
1749 header = initCanvas(headerTitle);
1750 drawErrorMessages(getHistogramName(histoName,
id, kTRUE)) ;
1761 TH2* h2DReal = (TH2D*) getHistogram(histoName,
id, kFALSE);
1764 header = initCanvas(headerTitle);
1768 if( isProjectionX ){
1769 mMainPad->Divide(2, 3);
1774 mMainPad->Divide(2, 4);
1782 const Int_t nbins = (isProjectionX) ? 10 : 6 ;
1783 const Double_t binStep = 0.5 ;
1784 const Double_t binMin = (isProjectionX) ? 0.0 : -1.5 ;
1787 for(Int_t ibin=0; ibin<nbins; ibin++){
1788 if( ipad%(npad+1) == 0 ){
1793 if(header)
delete header ;
1794 header = initCanvas(headerTitle);
1796 if( isProjectionX ) mMainPad->Divide(2, 3);
1797 else mMainPad->Divide(2, 4);
1801 const Double_t xMin = (isProjectionX && ibin==0) ? 0.2 : binMin + binStep * ibin ;
1802 const Double_t xMax = (isProjectionX && ibin==0) ? 0.5 : binMin + binStep * (ibin+1.0) ;
1803 const Int_t xMinBin = (isProjectionX) ? h2DEmbed->GetYaxis()->FindBin(xMin) : h2DEmbed->GetXaxis()->FindBin(xMin) ;
1804 const Int_t xMaxBin = (isProjectionX) ? h2DEmbed->GetYaxis()->FindBin(xMax) - 1 : h2DEmbed->GetXaxis()->FindBin(xMax) - 1;
1809 if( isProjectionX ){
1810 if( h2DEmbed ) hEmbed = (TH1D*) h2DEmbed->ProjectionX(Form(
"h%sEmbed_%d_%d", name.Data(), id, ibin), xMinBin, xMaxBin);
1811 if( h2DReal ) hReal = (TH1D*) h2DReal->ProjectionX(Form(
"h%sReal_%d_%d", name.Data(), id, ibin), xMinBin, xMaxBin);
1812 if( h2DMc ) hMc = (TH1D*) h2DMc->ProjectionX(Form(
"h%sMc_%d_%d", name.Data(), id, ibin), xMinBin, xMaxBin);
1815 if( h2DEmbed ) hEmbed = (TH1D*) h2DEmbed->ProjectionY(Form(
"h%sEmbed_%d_%d", name.Data(), id, ibin), xMinBin, xMaxBin);
1816 if( h2DReal ) hReal = (TH1D*) h2DReal->ProjectionY(Form(
"h%sReal_%d_%d", name.Data(), id, ibin), xMinBin, xMaxBin);
1817 if( h2DMc ) hMc = (TH1D*) h2DMc->ProjectionY(Form(
"h%sMc_%d_%d", name.Data(), id, ibin), xMinBin, xMaxBin);
1820 hEmbed->SetLineColor(kRed);
1821 if(hEmbed->GetSumw2N()==0) hEmbed->Sumw2();
1822 hEmbed->Scale( getNormalization(*hEmbed) );
1825 hReal->SetLineColor(kBlue);
1826 if(hReal->GetSumw2N()==0) hReal->Sumw2();
1827 hReal->Scale( getNormalization(*hReal) );
1831 hMc->SetLineColor(kBlack);
1832 if(hMc->GetSumw2N()==0) hMc->Sumw2();
1833 hMc->Scale( getNormalization(*hMc) );
1836 hEmbed->SetMinimum(0.0);
1838 if( isProjectionX ){
1839 hEmbed->SetTitle(Form(
"%1.1f < p_{T} < %1.1f (GeV/c)", xMin, xMax));
1842 hEmbed->SetTitle(Form(
"%1.1f < #eta < %1.1f", xMin, xMax));
1843 hEmbed->SetAxisRange(0, mPtMax,
"X");
1845 hEmbed->SetYTitle(Form(
"(1/N_{trk})dN/d%s", yTitle.Data()));
1847 mMainPad->cd(ipad) ;
1851 if(isMC && !isDecay()){
1853 hEmbed->SetMaximum( TMath::Max(hMc->GetMaximum(), hEmbed->GetMaximum()) * 1.2 );
1861 const Double_t yMax = (hReal) ? TMath::Max(hReal->GetMaximum(), hEmbed->GetMaximum()) : hEmbed->GetMaximum() ;
1862 hEmbed->SetMaximum( yMax * 1.2 );
1864 if(hReal) hReal->Draw(
"hsame");
1866 hEmbed->Draw(
"same");
1870 mMainPad->cd(npadMax);
1871 TLegend* leg =
new TLegend(0.0, 0.2, 1.0, 0.8);
1872 leg->SetFillColor(10);
1873 leg->SetTextFont(43);
1874 leg->SetTextSize(15);
1876 leg->AddEntry(hEmbed, getEmbeddingParticleName(
id, kTRUE),
"L");
1877 if(isMC && !isDecay()){
1878 leg->AddEntry(hMc, getMcParticleName(),
"L");
1881 if(hReal) leg->AddEntry(hReal, getRealParticleName(
id, kTRUE),
"L");
1894 if(header)
delete header ;
1897 gStyle->SetPadRightMargin(0.15);
1908 if(!isOpen())
return kFALSE ;
1911 const Bool_t isMcOk = drawdEdxVsMomentum(kTRUE) ;
1914 const Bool_t isRecoOk = drawdEdxVsMomentum(kFALSE) ;
1916 return isMcOk && isRecoOk ;
1920 Bool_t StEmbeddingQADraw::drawdEdxVsMomentum(
const Bool_t isMcMomentum)
const
1930 const TString momName = (isMcMomentum) ?
"Mc" :
"Reco" ;
1932 LOG_INFO <<
"QA for dE/dx (" << momName <<
" momentum ...)" << endm;
1934 gStyle->SetOptFit(0);
1935 gStyle->SetPadRightMargin(0.05);
1937 for(UInt_t
id=0;
id<mDaughterGeantId.size();
id++){
1941 TString headerTitle(
"");
1942 if( mIsEmbeddingOnly ){
1943 headerTitle = Form(
"dE/dx vs momentum (Embedding:%s)",
getParticleName(mDaughterGeantId[
id]) );
1946 headerTitle = Form(
"dE/dx vs momentum (Embedding:%s, Real:%s)",
1949 TPaveText* header = 0 ;
1952 TH2* hdEdxVsMomEmbed = (TH2D*) getHistogram(Form(
"hdEdxVsMom%s", momName.Data()),
id, kTRUE);
1953 if(!hdEdxVsMomEmbed){
1955 header = initCanvas(headerTitle);
1956 drawErrorMessages(getHistogramName(Form(
"hdEdxVsMom%s", momName.Data()),
id, kTRUE)) ;
1967 header = initCanvas(headerTitle, 1, 2);
1969 hdEdxVsMomEmbed->SetLineColor(kRed);
1970 hdEdxVsMomEmbed->SetMarkerColor(kRed);
1973 TH2* hdEdxVsMomReal = (TH2D*) getHistogram(
"hdEdxVsMomReco",
id, kFALSE);
1976 if( hdEdxVsMomReal ){
1977 hdEdxVsMomReal->SetLineColor(kBlack);
1978 hdEdxVsMomReal->SetMarkerColor(kBlack);
1982 TH2* hdEdxVsMomPidReal = (TH2D*) getHistogram(
"hdEdxVsMomRecoPidCut",
id, kFALSE);
1985 if( hdEdxVsMomPidReal ){
1986 hdEdxVsMomPidReal->SetLineColor(kBlue);
1987 hdEdxVsMomPidReal->SetMarkerColor(kBlue);
1992 hdEdxVsMomEmbed->SetAxisRange(0, mPtMax,
"X");
1993 hdEdxVsMomEmbed->SetXTitle(Form(
"%s momentum (GeV/c)", momName.Data()));
1994 hdEdxVsMomEmbed->SetTitle(
"");
1995 hdEdxVsMomEmbed->SetMinimum(0);
1997 hdEdxVsMomEmbed->Draw(
"box");
1998 if( hdEdxVsMomReal ) hdEdxVsMomReal->Draw(
"box same");
1999 if( hdEdxVsMomPidReal ) hdEdxVsMomPidReal->Draw(
"box same");
2000 hdEdxVsMomEmbed->Draw(
"box same");
2005 TLegend* leg =
new TLegend(0.1, 0.25, 0.9, 0.9);
2006 leg->SetFillColor(10);
2007 leg->SetTextSize(0.05);
2008 leg->AddEntry( hdEdxVsMomEmbed, getEmbeddingParticleName(
id),
"L");
2009 if( hdEdxVsMomReal ) leg->AddEntry( hdEdxVsMomReal,
"Real data",
"L");
2010 if( hdEdxVsMomPidReal ) leg->AddEntry( hdEdxVsMomPidReal, Form(
"Real data with PID cut (#sigma<2) %s",utility->getBTofPid()?
"BTOF":
"TPC"),
"L");
2024 headerTitle =
"Projection of dE/dx for each p bin";
2026 header = initCanvas(headerTitle, 2, 4);
2030 const Int_t npad = 6 ;
2031 const Int_t npadMax = 8;
2033 TGraphErrors* gMeanVsMom[2];
2034 TGraphErrors* gSigmaVsMom[2];
2036 for(Int_t i=0; i<2; i++){
2037 gMeanVsMom[i] =
new TGraphErrors();
2038 gSigmaVsMom[i] =
new TGraphErrors();
2039 gMeanVsMom[i] ->SetMarkerStyle(24 - i*4);
2040 gSigmaVsMom[i]->SetMarkerStyle(24 - i*4);
2042 gMeanVsMom[0] ->SetMarkerColor(kRed); gMeanVsMom[0] ->SetLineColor(kRed);
2043 gSigmaVsMom[0]->SetMarkerColor(kRed); gSigmaVsMom[0]->SetLineColor(kRed);
2044 gMeanVsMom[1] ->SetMarkerColor(kBlue); gMeanVsMom[1] ->SetLineColor(kBlue);
2045 gSigmaVsMom[1]->SetMarkerColor(kBlue); gSigmaVsMom[1]->SetLineColor(kBlue);
2047 const Int_t npt = 24 ;
2048 const Double_t ptBin = 0.2 ;
2049 for(Int_t ipt=0; ipt<npt; ipt++){
2050 if( ipad % (npad+1) == 0 ){
2056 if(header)
delete header ;
2057 header = initCanvas(headerTitle, 2, 4);
2061 const Double_t ptMin = 0.2 + ipt*ptBin ;
2062 const Double_t ptMax = ptMin + ptBin ;
2063 const Int_t ptMinBin = hdEdxVsMomEmbed->GetXaxis()->FindBin(ptMin);
2064 const Int_t ptMaxBin = hdEdxVsMomEmbed->GetXaxis()->FindBin(ptMax-0.001);
2065 if( ptMinBin == ptMaxBin ){
2066 LOG_INFO << Form(
"%1.1f - %1.1f GeV/c : bin = (%4d, %4d)", ptMin, ptMax, ptMinBin, ptMaxBin) << endm;
2070 TH1* hdEdxEmbed = (TH1D*) hdEdxVsMomEmbed->ProjectionY(Form(
"hdEdxEmbed%s_%d_%d", momName.Data(), id, ipt), ptMinBin, ptMaxBin);
2072 if( hdEdxVsMomPidReal )
2073 hdEdxReal = (TH1D*) hdEdxVsMomPidReal->ProjectionY(Form(
"hdEdxReal%s_%d_%d", momName.Data(), id, ipt), ptMinBin, ptMaxBin);
2075 hdEdxEmbed->Sumw2() ;
2076 hdEdxEmbed->Scale( getNormalization(*hdEdxEmbed) ) ;
2079 hdEdxReal->Sumw2() ;
2080 hdEdxReal->Scale( getNormalization(*hdEdxReal) ) ;
2083 hdEdxEmbed->SetMinimum(0.0);
2088 hdEdxEmbed->SetMaximum( TMath::Max(hdEdxReal->GetMaximum(), hdEdxEmbed->GetMaximum())*1.2 );
2091 hdEdxEmbed->SetMaximum( hdEdxEmbed->GetMaximum()*1.2 );
2094 hdEdxEmbed->SetTitle(Form(
"%1.1f < %s p < %1.1f GeV/c", ptMin, momName.Data(), ptMax));
2095 hdEdxEmbed->SetYTitle(
"(1/N_{trk})dN/d(dE/dx)");
2098 hdEdxEmbed->Draw(
"h");
2099 if( hdEdxReal ) hdEdxReal->Draw(
"hsame");
2100 hdEdxEmbed->Draw(
"hsame");
2105 TF1 fEmbed(Form(
"fEmbed%s_%d_%d", momName.Data(), id, ipt),
"gaus", 0, 10);
2106 TF1 fReal(Form(
"fReal%s_%d_%d", momName.Data(), id, ipt),
"gaus", 0, 10);
2107 fEmbed.SetLineColor(kRed);
2108 fReal.SetLineColor(kBlue);
2109 fEmbed.SetLineWidth(1);
2110 fReal.SetLineWidth(1);
2113 hdEdxReal->Fit(fReal.GetName(),
"rq0");
2116 hdEdxEmbed->Fit(fEmbed.GetName(),
"rq0");
2117 fEmbed.Draw(
"same");
2119 const Double_t pt = (ptMin+ptMax)/2.0 ;
2120 gMeanVsMom[0]->SetPoint(ipt, pt, fEmbed.GetParameter(1));
2121 gMeanVsMom[0]->SetPointError(ipt, 0.0, fEmbed.GetParError(1));
2122 gSigmaVsMom[0]->SetPoint(ipt, pt, fEmbed.GetParameter(2));
2123 gSigmaVsMom[0]->SetPointError(ipt, 0.0, fEmbed.GetParError(2));
2126 gMeanVsMom[1]->SetPoint(ipt, pt, fReal.GetParameter(1));
2127 gMeanVsMom[1]->SetPointError(ipt, 0.0, fReal.GetParError(1));
2128 gSigmaVsMom[1]->SetPoint(ipt, pt, fReal.GetParameter(2));
2129 gSigmaVsMom[1]->SetPointError(ipt, 0.0, fReal.GetParError(2));
2132 gMeanVsMom[1]->SetPoint(ipt, pt, -9999.);
2133 gMeanVsMom[1]->SetPointError(ipt, 0.0, 0.0);
2134 gSigmaVsMom[1]->SetPoint(ipt, pt, -9999.);
2135 gSigmaVsMom[1]->SetPointError(ipt, 0.0, 0.0);
2140 mMainPad->cd(npadMax);
2141 drawLegend(
id, hdEdxEmbed, hdEdxReal,
"L", kTRUE) ;
2164 headerTitle =
"Mean/#sigma of dE/dx vs momentum";
2165 header = initCanvas(headerTitle, 1, 2);
2167 for(Int_t i=0; i<2; i++){
2170 const Double_t ymax = (i==0) ? 7.2 : 1.4 ;
2171 TH1* frame = mMainPad->GetPad(i+1)->DrawFrame(0, 0.0, 5.0, ymax);
2172 frame->SetXTitle(Form(
"%s momentum (GeV/c)", momName.Data()));
2173 if( i == 0 ) frame->SetYTitle(
"Mean (keV/cm)");
2174 if( i == 1 ) frame->SetYTitle(
"#sigma (keV/cm)");
2176 TLegend* leg =
new TLegend(0.23, 0.86, 0.92, 0.99);
2177 leg->SetBorderSize(1);
2178 leg->SetTextFont(43);
2179 leg->SetTextSize(15);
2180 leg->SetFillColor(10);
2183 gMeanVsMom[0]->Draw(
"P");
2184 gMeanVsMom[1]->Draw(
"P");
2186 leg->AddEntry( gMeanVsMom[0], getEmbeddingParticleName(
id),
"P");
2187 leg->AddEntry( gMeanVsMom[1], getRealParticleName(
id),
"P");
2190 gSigmaVsMom[0]->Draw(
"P");
2191 gSigmaVsMom[1]->Draw(
"P");
2193 leg->AddEntry( gSigmaVsMom[0], getEmbeddingParticleName(
id),
"P");
2194 leg->AddEntry( gSigmaVsMom[1], getRealParticleName(
id),
"P");
2215 LOG_INFO <<
"QA for dca distributions ..." << endm;
2218 if(!isOpen())
return kFALSE ;
2220 return drawProjection3D(
"Dca");
2228 LOG_INFO <<
"QA for NHit distributions ..." << endm;
2231 if(!isOpen())
return kFALSE ;
2233 gStyle->SetPadRightMargin(0.17);
2236 for(UInt_t
id=0;
id<mDaughterGeantId.size();
id++){
2237 TH3* hNCommonHitVsNHit = (TH3D*) getHistogram(
"hNCommonHitVsNHit",
id, kTRUE);
2238 if ( !hNCommonHitVsNHit ) continue ;
2240 TString headerTitle(
"");
2241 if( mIsEmbeddingOnly ){
2242 headerTitle = Form(
"N_{common} vs N_{hit} (Embedding:%s)",
getParticleName(mDaughterGeantId[
id]) );
2245 headerTitle = Form(
"N_{common} vs N_{hit} (Embedding:%s, Real:%s)",
2250 TPaveText* header = initCanvas(headerTitle);
2253 hNCommonHitVsNHit->SetAxisRange(0.2, 5.0);
2254 TH2* hNCommonHitVsNHit2D = (TH2D*) hNCommonHitVsNHit->Project3D(
"zy");
2255 hNCommonHitVsNHit2D->SetName(Form(
"hNCommonHitVsNHit2D_%d",
id));
2256 hNCommonHitVsNHit2D->SetTitle(Form(
"%1.1f < p_{T} < %1.1f GeV/c", 0.2, 5.0));
2257 hNCommonHitVsNHit2D->Draw(
"colz");
2265 if( mIsEmbeddingOnly ){
2266 headerTitle = Form(
"N_{common} vs N_{hit}, p_{T} dependence (Embedding:%s)",
getParticleName(mDaughterGeantId[
id]) );
2269 headerTitle = Form(
"N_{common} vs N_{hit}, p_{T} dependence (Embedding:%s, Real:%s)",
2272 for(Int_t jpt=0; jpt<2; jpt++) {
2273 TPaveText* header = initCanvas(headerTitle, 2, 3);
2275 const Int_t npt = hNCommonHitVsNHit->GetNbinsX()/2 ;
2276 for(Int_t ipt=0; ipt<npt; ipt++) {
2277 mMainPad->cd(ipt+1);
2278 const Int_t ptId = jpt*npt + ipt + 1;
2279 Double_t ptmin = hNCommonHitVsNHit->GetXaxis()->GetBinLowEdge(ptId) ;
2280 Double_t ptmax = hNCommonHitVsNHit->GetXaxis()->GetBinLowEdge(ptId+1) ;
2281 if( ptmin == 0.0 ) ptmin = 0.2 ;
2283 hNCommonHitVsNHit->SetAxisRange(ptmin, ptmax);
2284 hNCommonHitVsNHit2D = (TH2D*) hNCommonHitVsNHit->Project3D(
"zy");
2285 hNCommonHitVsNHit2D->SetName(Form(
"hNCommonHitVsNHit2D_%d_%d_%d",
id, ipt, jpt));
2286 hNCommonHitVsNHit2D->SetTitle(Form(
"%1.1f < p_{T} < %1.1f GeV/c", ptmin, ptmax));
2287 hNCommonHitVsNHit2D->Draw(
"colz");
2296 gStyle->SetPadRightMargin(0.05);
2298 return drawProjection3D(
"NHit") ;
2302 Bool_t StEmbeddingQADraw::drawProjection3D(
const TString name)
const
2310 const Bool_t isBatch = gROOT->IsBatch() ;
2312 LOG_INFO <<
"Enter batch mode ..." << endm;
2313 gROOT->SetBatch(kTRUE);
2316 TString nameLower(name);
2317 nameLower.ToLower();
2319 TString headerTitle(Form(
"%s distribution for (p_{T}, #eta) slices", name.Data()));
2320 for(UInt_t
id=0;
id<mDaughterGeantId.size();
id++){
2321 TPaveText* header = 0 ;
2324 TH3* h3DEmbed = (TH3D*) getHistogram(Form(
"h%s", name.Data()),
id, kTRUE);
2327 header = initCanvas(headerTitle);
2328 drawErrorMessages(getHistogramName(Form(
"h%s", name.Data()),
id, kTRUE));
2339 TH3* h3DReal = (TH3D*) getHistogram(Form(
"h%s", name.Data()),
id, kFALSE);
2341 const Int_t nPt = h3DEmbed->GetNbinsX() ;
2342 const Int_t nEta = h3DEmbed->GetNbinsY() ;
2343 const Double_t ptMin = h3DEmbed->GetXaxis()->GetXmin() ;
2344 const Double_t ptMax = h3DEmbed->GetXaxis()->GetXmax() ;
2345 const Double_t etaMin = h3DEmbed->GetYaxis()->GetXmin() ;
2346 const Double_t etaMax = h3DEmbed->GetYaxis()->GetXmax() ;
2347 const Double_t etaBin = (etaMax-etaMin)/(Double_t)nEta ;
2348 const Double_t ptBin = (ptMax-ptMin)/(Double_t)nPt ;
2350 for(Int_t ipt=0; ipt<nPt; ipt++){
2351 TString pt(Form(
"%1.1f < p_{T} < %1.1f (GeV/c)", ptMin+ipt*ptBin, ptMin+(ipt+1)*ptBin));
2352 if( ipt == 0 ) pt = Form(
"%1.1f < p_{T} < %1.1f (GeV/c)", 0.1, ptMin+(ipt+1)*ptBin);
2354 TPaveText* header = initCanvas(headerTitle, 2, 3);
2356 const Int_t npad = 5 ;
2357 const Int_t npadMax = 6 ;
2359 for(Int_t ieta=0; ieta<nEta; ieta++){
2360 if( ipad % (npad+1) == 0 ){
2365 if(header)
delete header ;
2366 header = initCanvas(headerTitle, 2, 3);
2371 TString eta(Form(
"%1.1f < #eta < %1.1f", etaMin+ieta*etaBin, etaMin+(ieta+1)*etaBin));
2373 TH1* hEmbed = (TH1D*) h3DEmbed->ProjectionZ(Form(
"h%sEmbed_%d_%d_%d", name.Data(), id, ipt, ieta), ipt+1, ipt+1, ieta+1, ieta+1);
2376 hReal = (TH1D*) h3DReal->ProjectionZ(Form(
"h%sReal_%d_%d_%d", name.Data(), id, ipt, ieta), ipt+1, ipt+1, ieta+1, ieta+1);
2378 hReal ->Scale( getNormalization(*hReal) );
2379 hReal ->SetLineColor(kBlue);
2382 hEmbed->Scale( getNormalization(*hEmbed) );
2383 hEmbed->SetLineColor(kRed);
2384 hEmbed->SetMinimum(0.0);
2390 hEmbed->SetMaximum( TMath::Max(hReal->GetMaximum(), hEmbed->GetMaximum()) * 1.2 );
2393 hEmbed->SetMaximum( hEmbed->GetMaximum() * 1.2 );
2396 hEmbed->SetTitle(eta +
", " + pt);
2397 hEmbed->SetYTitle(Form(
"(1/N_{trk})dN/d%s", name.Data())) ;
2401 if(hReal) hReal->Draw(
"hsame");
2402 hEmbed->Draw(
"same");
2406 mMainPad->cd(npadMax);
2407 drawLegend(
id, hEmbed, hReal,
"L", kTRUE);
2426 if( isBatch ) gROOT->SetBatch(kTRUE);
2427 else gROOT->SetBatch(kFALSE);
2433 TPaveText* StEmbeddingQADraw::initCanvas(
const TString headerTitle,
const Int_t nx,
const Int_t ny)
const
2439 TPaveText* header = drawHeader(headerTitle);
2442 if( nx != 0 && ny != 0 ) mMainPad->Divide(nx, ny);
2448 Double_t StEmbeddingQADraw::getVzAcceptedMinimum()
const
2470 Double_t StEmbeddingQADraw::getVzAcceptedMaximum()
const
2517 return isEventOk && isMcTrackOk && isTrackOk ;
2524 LOG_INFO <<
"StEmbeddingQADraw::finish() Close PDF file : " << mPDF->GetName() << endm ;
2529 TLatex* title =
new TLatex(0.1, 0.6,
"End of QA");
2530 title->SetTextSize(0.1);
Bool_t drawPhi() const
Geant id.
const Char_t * getParticleName(const Int_t geantid=-1) const
Get geant id.
Bool_t drawPt() const
(pseudo-)rapidity in different eta bins
Bool_t drawDca() const
dE/dx (2D) and projections
Bool_t drawdEdx() const
momentum (|eta|<2, 0.5 eta increment)
Bool_t drawNHit() const
Dca vs (pt, eta)
Bool_t drawGeantId() const
Draw Reconstructed track histograms.
void setJPGOn()
Set true for gif file flag (default is false)
virtual ~StEmbeddingQADraw()
void setPNGOn()
Finish QA.
TString getCategoryName(const UInt_t id) const
Category from category id.
void setStyle() const
Check the input geantid is gamma.
void setEPSOn()
Set true for jpg file flag (default is false)
Bool_t isContaminated(const TString name) const
Check whether the track is Ghost pair or not.
StParticleDefinition * getParticleDefinition(const UInt_t geantid) const
runnumber = runid - (year - 2000 + 1) * 10^6
Bool_t drawRapidity() const
Azimuthal angle (phi) distributions.
Bool_t drawTrack() const
Draw MC track histograms.
Float_t getPtMinCut() const
Get track and event selections.
Int_t getRunId(const Int_t runnumber, const Int_t year) const
Set font, title and label styles.
Bool_t finish()
NHit vs (pt, eta)
static StEmbeddingQAUtilities * instance()
Get instance.
void setParentGeantId(const Int_t parentgeantid)
Set parent geant id (default is 0)
void setPSOn()
Set true for eps file flag (default is false)
Bool_t drawMomentum() const
pt (|eta|<2, 0.5 eta increment)
void setGIFOn()
Set true for png file flag (default is false)
Bool_t drawMcTrack() const
Draw all event-wise histograms.
TString getCategoryTitle(const UInt_t id) const
Category name from category id.
Bool_t drawEvent() const
Draw all histograms (event and track histograms).
Int_t getCategoryId(const TString name) const
Category title from category id.
void init()
Initialization.
void setOutputDirectory(const TString name="./")
Default is current directory.
StEmbeddingQADraw(const TString embeddingFile, const TString realDataFile, const Int_t geantid, const Bool_t isEmbeddingOnly=kFALSE)