// root macro to analyze the simulation output //void convertMCPoints() { // ----- Load libraries ------------------------------------------------ //``gSystem->Load("fstream.h"); gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C"); basiclibs(); gSystem->Load("libGeoBase"); gSystem->Load("libParBase"); gSystem->Load("libBase"); gSystem->Load("libMCStack"); gSystem->Load("libField"); gSystem->Load("libGen"); gSystem->Load("libPassive"); gSystem->Load("libMvd"); // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ /* Convert PndMvdWaferMCPoints to the STAR Format (text, "x y z layer") for the conformal mapping stuff */ PndMvdFileNameCreator namecreator("/home/ralfk/MVD/mvdmacros/data/mvdevalg4.root"); std::string inFile = namecreator.GetSimFileName(false); TFile* f = new TFile(inFile.c_str()); // the sim file you want to analyse TTree *t=(TTree *) f->Get("cbmsim") ; TClonesArray* hit_array=new TClonesArray("PndMvdMCPoint"); t->SetBranchAddress("MVDPoint",&hit_array);//Branch names TClonesArray* mc_array=new TClonesArray("CbmMCTrack"); t->SetBranchAddress("MCTrack",&mc_array);//Branch names TH2D* hisxy = new TH2D("hisxy","MVD MC Points, xy view",400,-15.,15.,400,-15.,15.); TH2D* hisrz = new TH2D("hisrz","MVD MC Points, rz view",400,-20.,20.,400,-15.,25.); TH1D* hisde = new TH1D("hisde","MVD MC Points, Energyloss",500,0.,0.002); TH2D* hisdedx = new TH2D("hisdedx","MVD MC Points, dE/dx",200,0.,1.,200,0.,0.002); int nEvents = 1000; bool verbose = false; TVector3 vecs,veco; TVector3 vecFront,vecBack,vecP; Double_t dx,dE,p,dEdX; for (Int_t j=0; jGetEntriesFast(); j++) { t->GetEntry(j); if(verbose) cout<<"Event No "<GetEntriesFast(); i++) { if(verbose) cout<<"Point No "<At(i); int mcpdg = -1; //CbmMCTrack *mctruth = (CbmMCTrack*)mc_array->At(hit->GetTrackID()); //mcpdg = mctruth->GetPdgCode(); //cout<<"mcpdg="<GetX(), hit->GetY(), hit->GetZ()); veco.SetXYZ(hit->GetXOut(),hit->GetYOut(),hit->GetZOut()); vecP.SetXYZ(hit->GetPxOut(),hit->GetPyOut(),hit->GetPzOut()); dx=(veco-vecs).Mag(); dE=hit->GetEnergyLoss(); p=vecP.Mag(); Int_t layer = Int_t(10.*vecs->Mag()); if(verbose) cout<Fill(vecs.x(),vecs.y()); hisrz->Fill(vecs.z(),((vecs.y()>0.)?1.:-1.)*vecs.Perp()); hisde->Fill(hit->GetEnergyLoss()); if(dx!=0) { dEdX=(dE/dx); hisdedx->Fill(p,dE); } }//end for i (points in event) }// end for j (events) TCanvas* can1 = new TCanvas("can1","MCHit view in MVD",0,0,800,800); can1->Divide(2,2); can1->cd(1); hisxy->DrawCopy("colz"); can1->cd(2); hisrz->DrawCopy("colz"); can1->cd(3); gPad->SetLogy(); hisde->DrawCopy(""); can1->cd(4); hisdedx->DrawCopy("colz"); can1->Print("outAnaMvdSim.ps"); // ----- Finish ------------------------------------------------------- timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished succesfully." << endl; //cout << "Output file is " << outFile << endl; //cout << "Parameter file is " << parFile << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl; cout << endl; // ------------------------------------------------------------------------ }