X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STEER%2FAliMCQA.cxx;h=5c18c8344e2fc7727576dab4cad8e045f96b4b6f;hb=9fa52f92cf5cdd73b189ae882e12ff58613440f1;hp=bc19013e456ceeee3be0220b3d84038ad2e078a2;hpb=e460afec1cd3718b8cc05b3d266b1c17cf150dda;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliMCQA.cxx b/STEER/AliMCQA.cxx index bc19013e456..5c18c8344e2 100644 --- a/STEER/AliMCQA.cxx +++ b/STEER/AliMCQA.cxx @@ -13,60 +13,89 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ -/* -$Log$ -Revision 1.3 2000/12/18 14:16:31 alibrary -HP compatibility fix - -Revision 1.2 2000/12/18 11:33:48 alibrary -New call frequence histograms per module and volume - -Revision 1.1 2000/11/30 07:12:48 alibrary -Introducing new Rndm and QA classes - -*/ +/* $Id$ */ /////////////////////////////////////////////////////////////////////////////// // // +// Quality Assurance class // +// Provides standard histograms for every element of the detector // // // /////////////////////////////////////////////////////////////////////////////// #include -#include "TObjArray.h" -#include "TH1.h" -#include "TList.h" -#include "TROOT.h" -#include "TBrowser.h" -#include "TMath.h" -#include "TLorentzVector.h" -#include "TDatabasePDG.h" -#include "TMath.h" -#include "TPad.h" -#include "TExec.h" -#include "TPaveLabel.h" -#include "TCanvas.h" - +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "AliLog.h" +#include "AliMC.h" #include "AliMCQA.h" -#include "AliRun.h" #include "AliModule.h" -#include "AliMC.h" +#include "AliRun.h" ClassImp(AliMCQA) - -//_____________________________________________________________________________ -AliMCQA::AliMCQA() : fQAList(0), fDetDone(0), fQAHist(0), fVolNames(0), - fModNames(0),fMPaveLabel(0),fVPaveLabel(0) +//_______________________________________________________________________ +AliMCQA::AliMCQA(): + fNdets(0), + fNvolumes(0), + fQAList(0), + fOldId(0), + fDetDone(0), + fQAHist(0), + fVolNames(0), + fModNames(0), + fMPaveLabel(0), + fVPaveLabel(0) { // // Default constructor // } -//_____________________________________________________________________________ -AliMCQA::AliMCQA(Int_t ndets) : fMPaveLabel(0),fVPaveLabel(0) +//_______________________________________________________________________ +AliMCQA::AliMCQA(const AliMCQA &qa): + TObject(qa), + fNdets(0), + fNvolumes(0), + fQAList(0), + fOldId(0), + fDetDone(0), + fQAHist(0), + fVolNames(0), + fModNames(0), + fMPaveLabel(0), + fVPaveLabel(0) +{ + // + // Copy constructor + // + qa.Copy(*this); +} + +//_______________________________________________________________________ +AliMCQA::AliMCQA(Int_t ndets): + fNdets(ndets), + fNvolumes(gMC->NofVolumes()), + fQAList(new TObjArray(ndets)), + fOldId(0), + fDetDone(new Int_t[ndets]), + fQAHist(new TObjArray(2)), + fVolNames(new TObjArray(fNvolumes)), + fModNames(new TObjArray(fNdets)), + fMPaveLabel(0), + fVPaveLabel(0) { // // Constructor, creates the list of lists of histograms @@ -75,19 +104,15 @@ AliMCQA::AliMCQA(Int_t ndets) : fMPaveLabel(0),fVPaveLabel(0) TH1F* h; Int_t i; - fNdets=ndets; - - fQAList = new TObjArray(ndets); TObjArray &hist = *fQAList; char title[100]; // TObjArray &mods = *(gAlice->Modules()); - AliModule *mod; TList *dir = gDirectory->GetList(); for (i=0; i(mods[i]); // Energy Spectrum sprintf(title,"Spectrum entering: %s ",mod->GetName()); @@ -112,70 +137,82 @@ AliMCQA::AliMCQA(Int_t ndets) : fMPaveLabel(0),fVPaveLabel(0) // gROOT->GetListOfBrowsables()->Add(this,"AliMCQA"); - fDetDone = new Int_t[fNdets]; - // // Global QA histograms // - fQAHist = new TObjArray(2); - fNvolumes=gMC->NofVolumes(); fQAHist->Add(new TH1F("hMCVcalls","Monte Carlo calls per volume", fNvolumes, 0.5, fNvolumes+0.5)); - h = (TH1F*) dir->FindObject("hMCVcalls"); + h = dynamic_cast(dir->FindObject("hMCVcalls")); h->GetListOfFunctions()->Add(new TExec("ex","gAlice->GetMCQA()->AddVolumeName()")); dir->Remove(dir->FindObject("hMCVcalls")); // // Build list of volume names // - fVolNames=new TObjArray(fNvolumes); + AliMC * mc = gAlice->GetMCApp(); for(i=0;iModules())[gAlice->DetFromMate(gMC->VolId2Mate(i+1))]; + AliModule *mod = dynamic_cast + ((*gAlice->Modules())[mc->DetFromMate(gMC->VolId2Mate(i+1))]); (*fVolNames)[i]=new TNamed(gMC->VolName(i+1),mod->GetName()); } fQAHist->Add(new TH1F("hMCMcalls","Monte Carlo calls per module", fNdets, -0.5, fNdets-0.5)); - h = (TH1F*) dir->FindObject("hMCMcalls"); + h = dynamic_cast(dir->FindObject("hMCMcalls")); h->GetListOfFunctions()->Add(new TExec("ex","gAlice->GetMCQA()->AddModuleName()")); dir->Remove(dir->FindObject("hMCMcalls")); // // Build list of module names // - fModNames=new TObjArray(fNdets); for(i=0;iModules())[i])->GetName(),""); + new TNamed((dynamic_cast((*gAlice->Modules())[i]))->GetName(),""); } -//_____________________________________________________________________________ +//_______________________________________________________________________ +void AliMCQA::Copy(TObject &) const +{ + AliFatal("Not implemented!"); +} -AliMCQA::~AliMCQA() { +//_______________________________________________________________________ +AliMCQA::~AliMCQA() + { + // + // Destructor + // + gROOT->GetListOfBrowsables()->Remove(this); + //if program crashes here - it probobly means that + //one of added browsables was deleted and not removed previously from that list + //skowron + if (fQAList) { fQAList->Delete(); delete fQAList; - fQAList=0; + fQAList = 0; } if (fQAHist) { fQAHist->Delete(); delete fQAHist; - fQAHist=0; + fQAHist = 0; } if (fVolNames) { fVolNames->Delete(); delete fVolNames; - fVolNames=0; + fVolNames = 0; } if (fModNames) { fModNames->Delete(); delete fModNames; - fModNames=0; + fModNames = 0; } + delete [] fDetDone; + delete fMPaveLabel; + delete fVPaveLabel; } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliMCQA::Browse(TBrowser *b) { // @@ -188,21 +225,21 @@ void AliMCQA::Browse(TBrowser *b) // Global histos first // TIter global(fQAHist); - while((hist = (TH1*)global())) + while((hist = dynamic_cast(global()))) b->Add(hist,hist->GetTitle()); // // Module histograms now // TIter next(fQAList); TList *histos; - while((histos = (TList*)next())) { + while((histos = dynamic_cast(next()))) { TIter next1(histos); - while((hist = (TH1*)next1())) + while((hist = dynamic_cast(next1()))) b->Add(hist,hist->GetTitle()); } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliMCQA::PreTrack() { // @@ -212,7 +249,7 @@ void AliMCQA::PreTrack() for(Int_t i=0; iFindObject("hMCVcalls"); - hist->Fill(gMC->CurrentVolID(copy)); - hist = (TH1F*) fQAHist->FindObject("hMCMcalls"); - hist->Fill(id); + + + static TH1F* mcvcalls = dynamic_cast(fQAHist->FindObject("hMCVcalls")); + mcvcalls->Fill(gMC->CurrentVolID(copy)); + static TH1F* mcmcalls = dynamic_cast(fQAHist->FindObject("hMCMcalls")); + mcmcalls->Fill(id); + // // Now the step manager histograms // if(fOldId != id) { - TLorentzVector p, x; + static Double_t mpi0=0; + static Double_t mpip=0; + static Double_t mpim=0; + static Double_t mep=0; + static Double_t mem=0; + Double_t mass = 0; + Int_t num = gMC->TrackPid(); + + switch (num) { + case 111: + if (mpi0==0) mpi0=gAlice->PDGDB()->GetParticle(num)->Mass(); + mass=mpi0; + break; + case 211: + if (mpip==0) mpip=gAlice->PDGDB()->GetParticle(num)->Mass(); + mass=mpip; + break; + case -211: + if (mpim==0) mpim=gAlice->PDGDB()->GetParticle(num)->Mass(); + mass=mpim; + break; + case 11: + if (mep==0) mep=gAlice->PDGDB()->GetParticle(num)->Mass(); + mass=mep; + break; + case -11: + if (mem==0) mem=gAlice->PDGDB()->GetParticle(num)->Mass(); + mass=mem; + break; + default: + if (gAlice->PDGDB()->GetParticle(num)) + mass = gAlice->PDGDB()->GetParticle(num)->Mass(); + break; + } + + static TLorentzVector p, x; gMC->TrackMomentum(p); gMC->TrackPosition(x); - Double_t energy = TMath::Max( - p[3]-gAlice->PDGDB()->GetParticle(gMC->TrackPid())->Mass(),1.e-12); + Double_t energy = TMath::Max(p[3]-mass,1.e-12); if(fOldId > -1) { if(!fDetDone[fOldId] && !gMC->IsNewTrack()) { - TList *histold = (TList*) (*fQAList)[fOldId]; - hist = (TH1F*) histold->FindObject("hEnOut"); + TList *histold = dynamic_cast((*fQAList)[fOldId]); + hist = dynamic_cast(histold->FindObject("hEnOut")); hist->Fill(TMath::Log10(energy)); - hist = (TH1F*) histold->FindObject("hZOut"); + hist = dynamic_cast(histold->FindObject("hZOut")); hist->Fill(x[2]); fDetDone[fOldId]=1; } } if(!fDetDone[id] && !gMC->IsNewTrack()) { - TList *histnew = (TList*) (*fQAList)[id]; - hist = (TH1F*) histnew->FindObject("hEnIn"); + TList *histnew = dynamic_cast((*fQAList)[id]); + hist = dynamic_cast(histnew->FindObject("hEnIn")); hist->Fill(TMath::Log10(energy)); - hist = (TH1F*) histnew->FindObject("hZIn"); + hist = dynamic_cast(histnew->FindObject("hZIn")); hist->Fill(x[2]); } fOldId=id; } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliMCQA::AddModuleName() { // @@ -272,7 +346,7 @@ void AliMCQA::AddModuleName() } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliMCQA::AddVolumeName() { // @@ -287,7 +361,7 @@ void AliMCQA::AddVolumeName() } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliMCQA::DrawPaveLabel(TPaveLabel *&pv) { // @@ -308,14 +382,14 @@ void AliMCQA::DrawPaveLabel(TPaveLabel *&pv) pv->Draw(); } -//_____________________________________________________________________________ +//_______________________________________________________________________ Int_t AliMCQA::GetHBin(const char* hname) { // // Get the bin where the cursor is // TList *dir = gDirectory->GetList(); - TH1 *h=(TH1*)dir->FindObject(hname); + TH1 *h=dynamic_cast(dir->FindObject(hname)); int px = gPad->GetEventX(); @@ -325,7 +399,7 @@ Int_t AliMCQA::GetHBin(const char* hname) return h->GetXaxis()->FindBin(x); } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliMCQA::DrawModuleName() { // @@ -337,7 +411,7 @@ void AliMCQA::DrawModuleName() Int_t binx = GetHBin("hMCMcalls"); if(0GetName()); + strcpy(lab,dynamic_cast((*fModNames)[binx-1])->GetName()); fMPaveLabel->SetLabel(lab); gPad->Modified(); @@ -345,7 +419,7 @@ void AliMCQA::DrawModuleName() } } -//_____________________________________________________________________________ +//_______________________________________________________________________ void AliMCQA::DrawVolumeName() { // @@ -357,8 +431,8 @@ void AliMCQA::DrawVolumeName() Int_t binx = GetHBin("hMCVcalls"); if(0GetName(), - ((TNamed*)(*fVolNames)[binx-1])->GetTitle()); + sprintf(lab,"%s: %s",dynamic_cast((*fVolNames)[binx-1])->GetName(), + dynamic_cast((*fVolNames)[binx-1])->GetTitle()); fVPaveLabel->SetLabel(lab); gPad->Modified();