// 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 MvdWaferMCPoints to the STAR Format (text, "x y z layer") for the conformal mapping stuff */ TFile* f = new TFile("MvdMC.root"); // the sim file you want to analyse TTree *t=(TTree *) f->Get("cbmsim") ; TClonesArray* hit_array=new TClonesArray("MvdPoint"); 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,0.,40.); TH1D* hisde = new TH1D("hisde","MVD MC Points, Energyloss",500,0.,0.002); int nEvents = 1; bool verbose = false; TVector3 vecs; 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="<GetEntriesFast();k++) // { // CbmMCTrack *mctruth = (CbmMCTrack*)mc_array->At(k); // if ( mctruth->GetUniqueID() == hit->GetTrackID() ) // { // mcpdg = mctruth->GetPdgCode(); // } // } vecs.SetXYZ(hit->GetX(), hit->GetY(), hit->GetZ()); Int_t layer = Int_t(10.*vecs->Mag()); if(verbose) cout<Fill(vecs.x(),vecs.y()); hisrz->Fill(vecs.z(),vecs.Perp()); hisde->Fill(hit->GetEnergyLoss()); }//end for i (points in event) }// end for j (events) TCanvas* can1 = new TCanvas("can1","MCHit view in MVD",0,0,1000,1000); can1->Divide(2,2); can1->cd(1); hisxy->DrawCopy(""); can1->cd(2); hisrz->DrawCopy(""); can1->cd(3);gPad->SetLogy(); hisde->DrawCopy(""); delete hisxy; delete hisrz; // ----- 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; // ------------------------------------------------------------------------ }