void EnobioStatusConsumer::receiveData(const PData &data) { StatusData * pStatus = (StatusData *)data.getData(); // Provide the data to whatever slot is connected to that signal emit newStatus(QDate::currentDate().toString("dd/MM/yyyy") + " " + QTime::currentTime().toString("hh:mm:ss") + " " + QString::fromStdString(StatusData::getTypeFromCode(pStatus->getCode())) + ": " + QString::fromStdString(pStatus->getString())); }
// // Implementation of the receiveData for both Data and Status consumers // The execution of these methods happens in a thread created by the Enobio // instance so accesing GUI resources might lead to a program crash // void EnobioDataConsumer::receiveData(const PData &data) { // The EnobioData is destroyed after the execution of receiveData by // the caller ChannelData * pData = (ChannelData *)data.getData(); // Provide the data to whatever slot is connected to that signal emit newData(QString::number(pData->data()[0]) + "\t" + QString::number(pData->data()[1]) + "\t" + QString::number(pData->data()[2]) + "\t" + QString::number(pData->data()[3]) + "\t" + QString::number(pData->data()[4]) + "\t" + QString::number(pData->data()[5]) + "\t" + QString::number(pData->data()[6]) + "\t" + QString::number(pData->data()[7]) + "\t" + QString::number(pData->timestamp())); }
void PlotPhaseSpace2D( const TString &sim, Int_t time, UInt_t index = 0, const TString &phaname = "p1x1", const TString &options="") { PlasmaGlob::Initialize(); TString opt = options; // Palettes! gROOT->Macro("PlasmaPalettes.C"); if(opt.Contains("grid")) { gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); } gStyle->SetPadRightMargin(0.20); // Margin for palettes in 2D histos gStyle->SetLabelFont(42,"xyz"); // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; Bool_t CYL = kFALSE; if(sim.Contains("cyl")) CYL = kTRUE; Bool_t ThreeD = kFALSE; if(sim.Contains("3D")) ThreeD = kTRUE; // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Some beam properties: Float_t Ebeam = pData->GetBeamEnergy() * PUnits::MeV; Float_t gamma = Ebeam / PConst::ElectronMassE; Float_t vbeam = TMath::Sqrt(1 - 1/(gamma*gamma)); // cout << Form(" - Bunch gamma = %8.4f", gamma ) << endl; // cout << Form(" - Bunch velocity = %8.4f c", vbeam ) << endl; // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } // Labeling... char xname[24]; char yname[24]; if(phaname.Contains("p1x1")) { sprintf(xname,"z"); sprintf(yname,"p_{z}"); } else if(phaname.Contains("p2x2")) { sprintf(xname,"y"); sprintf(yname,"p_{y}"); } char xunits[24]; char yunits[24]; if(opt.Contains("units")) { sprintf(xunits,"#mum"); sprintf(yunits,"MeV/c"); } else { sprintf(xunits,"c/#omega_{p}"); sprintf(yunits,"m_{e}/c"); } char xaxisname[24]; char yaxisname[24]; sprintf(xaxisname,"%s [%s]",xname,xunits); sprintf(yaxisname,"%s [%s]",yname,yunits); // Get charge density histos UInt_t Nspecies = pData->NSpecies(); TH2F *hPha2D = NULL; for(UInt_t i=0;i<Nspecies;i++) { if(i!=index) continue; for(UInt_t j=0;j<pData->NPhaseSpaces();j++) { if(!pData->GetPhasespaceFileName(i,j)) continue; if(!strcmp(phaname.Data(),pData->GetPhasespaceName(j).c_str())) { char hName[24]; sprintf(hName,"hPha_%i_%s",i,phaname.Data()); hPha2D = (TH2F*) gROOT->FindObject(hName); if(hPha2D) delete hPha2D; hPha2D = pData->GetPhasespace(i,j,opt); hPha2D->SetName(hName); continue; } } hPha2D->GetXaxis()->CenterTitle(); hPha2D->GetYaxis()->CenterTitle(); hPha2D->GetZaxis()->CenterTitle(); hPha2D->GetXaxis()->SetTitle(xaxisname); hPha2D->GetYaxis()->SetTitle(yaxisname); if(i==0) hPha2D->GetZaxis()->SetTitle("#LTn_{e}#GT [n_{0}]"); else hPha2D->GetZaxis()->SetTitle("#LTn_{b}#GT [n_{0}]"); } // Emittance and others // we assume that longitudinal variable is comoving for the range. Double_t xMin = 15.0; Double_t xMax = 35.0; Double_t yMin = 1500.0; Double_t yMax = 2400.0; UInt_t NBINX = hPha2D->GetNbinsX(); UInt_t NBINY = hPha2D->GetNbinsY(); Double_t dx = hPha2D->GetXaxis()->GetBinWidth(1); Double_t dy = hPha2D->GetYaxis()->GetBinWidth(1); Double_t xmean = 0.0; Double_t ymean = 0.0; Double_t xmean2 = 0.0; Double_t ymean2 = 0.0; Double_t xymean = 0.0; Double_t Ntotal = 0.0; for(UInt_t i=1;i<=NBINX;i++) { Double_t x = hPha2D->GetXaxis()->GetBinCenter(i); // if(x<xMin || x>xMax) continue; for(UInt_t j=1;j<=NBINY;j++) { Double_t y = hPha2D->GetYaxis()->GetBinCenter(j); // if(y<yMin || y>yMax) continue; Double_t value = TMath::Abs(hPha2D->GetBinContent(i,j)); xmean += x*value; ymean += y*value; xmean2 += x*x*value; ymean2 += y*y*value; xymean += x*y*value; Ntotal += value; } } // hPha2D->GetXaxis()->SetRangeUser(xMin,xMax); // hPha2D->GetYaxis()->SetRangeUser(yMin,yMax); xmean /= Ntotal; ymean /= Ntotal; xmean2 /= Ntotal; ymean2 /= Ntotal; xymean /= Ntotal; Double_t xrms2 = xmean2 - xmean*xmean; Double_t yrms2 = ymean2 - ymean*ymean; Double_t xyrms2 = xymean - xmean*ymean; Double_t xrms = TMath::Sqrt(xrms2); Double_t yrms = TMath::Sqrt(yrms2); Double_t xyrms = TMath::Sqrt(xyrms2); Double_t emittance = TMath::Sqrt( xrms2*yrms2 - xyrms2); cout << " Bunch properties: " << endl; cout << Form(" xMean = %7.3f yMean = %7.3f",xmean,ymean) << endl; cout << Form(" xRms = %7.3f yRms = %7.3f",xrms,yrms) << endl; cout << Form(" Emittance = %7.3f",emittance) << endl; // Set palette: PPalette * pPalette = (PPalette*) gROOT->FindObject("electron0"); Float_t Max = hPha2D->GetMaximum(); Float_t Min = hPha2D->GetMinimum(); hPha2D->GetZaxis()->SetRangeUser(Min,Max); // Plotting // ----------------------------------------------- // Canvas setup TCanvas *C; if(opt.Contains("hres") && !opt.Contains("pdf")) // high resolution for plain grahics output. C = new TCanvas("C","2D Phasespace",1000,625); else C = new TCanvas("C","2D Phasespace",800,500); // Text objects TPaveText *textTime = new TPaveText(0.50,0.85,0.77,0.9,"NDC"); PlasmaGlob::SetPaveTextStyle(textTime,32); char ctext[128]; if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"Z = %5.1f mm", 1e3 * pData->GetPlasmaSkinDepth() * Time); else sprintf(ctext,"T = %5.1f #omega_{p}^{-1}",Time); textTime->AddText(ctext); TPaveText *textDen = new TPaveText(0.15,0.85,0.48,0.9,"NDC"); PlasmaGlob::SetPaveTextStyle(textDen,12); textDen->SetTextColor(kOrange+10); if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"n_{0} = %5.2f x 10^{15} / cc", 1e-6 * 1e-15 * pData->GetPlasmaDensity()); else if(pData->GetBeamDensity() && pData->GetPlasmaDensity()) sprintf(ctext,"n_{b}/n_{0} = %5.2f", pData->GetBeamDensity()/pData->GetPlasmaDensity()); textDen->AddText(ctext); TPaveText *textWav = new TPaveText(0.15,0.85,0.48,0.9,"NDC"); PlasmaGlob::SetPaveTextStyle(textWav,12); textWav->SetTextColor(kGray+2); sprintf(ctext,"#lambda_{p} = %5.3f mm", 1e3 * pData->GetPlasmaWaveLength()); textWav->AddText(ctext); TPaveText *textEmit = new TPaveText(0.50,0.65,0.77,0.80,"NDC"); PlasmaGlob::SetPaveTextStyle(textEmit,32); textEmit->SetTextColor(kGray+1); sprintf(ctext,"#LT%s#GT_{rms} = %5.3f %s",xname,xrms,xunits); textEmit->AddText(ctext); sprintf(ctext,"#LT%s#GT_{rms} = %5.3f %s",yname,yrms,yunits); textEmit->AddText(ctext); sprintf(ctext,"#epsilon_{N} = %5.3f #mum",emittance); textEmit->AddText(ctext); // Actual Plotting! // ------------------------------------------------------------ // Output file TString fOutName = Form("./%s/Plots/Phase2D-%s/Phase2D-%s",sim.Data(),phaname.Data(),phaname.Data()); fOutName += Form("-%s_%i",sim.Data(),time); C->cd(); gPad->SetFrameLineWidth(3); TH2F *hFrame = (TH2F*) gROOT->FindObject("hFrame1"); if(hFrame) delete hFrame; hFrame = (TH2F*) hPha2D->Clone("hFrame1"); hFrame->Reset(); hFrame->Draw("col"); hPha2D->Draw("colz same"); gPad->Update(); textTime->Draw(); textDen->Draw(); if(opt.Contains("units")) textWav->Draw(); textEmit->Draw(); gPad->RedrawAxis(); C->cd(); // Print to a file PlasmaGlob::imgconv(C,fOutName,opt); // --------------------------------------------------------- }
void PlotPhaseSpaceRawCut2D( const TString &sim, Int_t time, Int_t index = 0, const TString &phaname = "p1x1", const TString &options="") { #ifdef __CINT__ gSystem->Load("libplasma.so"); #endif PlasmaGlob::Initialize(); TString opt = options; // Palettes! gROOT->Macro("PlasmaPalettes.C"); if(opt.Contains("grid")) { gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); } gStyle->SetPadRightMargin(0.15); // Margin for palettes in 2D histos gStyle->SetTitleOffset(0.9,"z"); gStyle->SetLabelFont(42,"xyz"); // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; Bool_t CYL = kFALSE; if(sim.Contains("cyl")) CYL = kTRUE; Bool_t ThreeD = kFALSE; if(sim.Contains("3D")) ThreeD = kTRUE; // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; opt += "comovcenter"; // Centering time and z position: Double_t shiftz = 0.0; if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) { // Centers on the head of the beam. Time += zStartBeam; shiftz += zStartBeam; } else { shiftz += zStartPlasma; } } if(opt.Contains("comov")) { Double_t v = pData->GetBeamVelocity(); if(v==0) v = 1.0; // If equals to 0 (default), then set to c. shiftz += v * pData->GetRealTime(); } // Spatial resolution Float_t dx1 = pData->GetDX(0); Float_t dx2 = pData->GetDX(1); Float_t dx3 = pData->GetDX(2); // Spatial coordinates intervals: Double_t x1Min = -4.3; Double_t x1Max = -3.9; Double_t x2Min = -0.5; Double_t x2Max = 0.5; Double_t x3Min = -0.5; Double_t x3Max = 0.5; if(sim.Contains("DR")) { x1Min = -5.0; x1Max = -3.5; } else if(sim.Contains("flash") && sim.Contains(".G.") ) { x1Min = -6.0; x1Max = -5.0; } else if(sim.Contains("flash") && sim.Contains(".TH.") ) { x1Min = -6.0; x1Max = -5.5; } else if(sim.Contains("facet_v23kA.G.RI")) { x1Min = -7.7; x1Max = -7.0; } char cutString[128]; if(pData->Is3D()) sprintf(cutString,"TMath::Abs(q)*(x1 > %f && x1 < %f && x2 > %f && x2 < %f && x3 > %f && x3 < %f)",x1Min+shiftz,x1Max+shiftz,x2Min,x2Max,x3Min,x3Max); else sprintf(cutString,"TMath::Abs(q)*(x1 > %f && x1 < %f && x2 > %f && x2 < %f)",x1Min+shiftz,x1Max+shiftz,x2Min,x2Max); TCut Cut = cutString; // Bining, intervals, labels, etc. Int_t xNbin = 250; Int_t yNbin = 250; Double_t xMin,yMin,xMax,yMax; xMin = yMin = xMax = yMax = 0.0; // Labeling... char xname[24]; char yname[24]; char xlabel[24]; char ylabel[24]; char alabel[24]; char tlabel[24]; if(phaname.Contains("p1x1")) { xMin = x1Min; xMax = x1Max; yMin = 0.0; yMax = 10000.0; sprintf(xname,"(x1-%f)",shiftz); sprintf(yname,"p1"); sprintf(xlabel,"#zeta"); sprintf(ylabel,"p_{z}"); sprintf(alabel,"#epsilon_{z}"); } else if(phaname.Contains("p2x2")) { xMin = x2Min; xMax = x2Max; yMin = -20.0; yMax = 20.0; sprintf(xname,"x2"); sprintf(yname,"p2"); sprintf(xlabel,"y"); sprintf(ylabel,"p_{y}"); sprintf(alabel,"#epsilon_{y}"); } else if(phaname.Contains("p3x3")) { xMin = x3Min; xMax = x3Max; yMin = -20.0; yMax = 20.0; sprintf(xname,"x3"); sprintf(yname,"p3"); sprintf(xlabel,"x"); sprintf(ylabel,"p_{x}"); sprintf(alabel,"#epsilon_{x}"); } else if(phaname.Contains("x2x1")){ xMin = x1Min; xMax = x1Max; yMin = x2Min; yMax = x3Max; sprintf(xname,"(x1-%f)",shiftz); sprintf(yname,"x2"); sprintf(xlabel,"#zeta"); sprintf(ylabel,"y"); } sprintf(tlabel,"time"); char xunits[24]; char yunits[24]; char aunits[24]; char tunits[24]; if(opt.Contains("units")) { sprintf(xunits,"#mum"); sprintf(tunits,"mm"); if(phaname.Contains("p1x1")) { sprintf(yunits,"GeV/c"); sprintf(aunits,"#mum"); } else if(phaname.Contains("p2x2") || phaname.Contains("p3x3")) { sprintf(yunits,"MeV/c"); sprintf(aunits,"#mum"); } else if(phaname.Contains("x2x1")) { sprintf(yunits,"#mum"); sprintf(aunits,"#mum^{2}"); } } else { sprintf(xunits,"c/#omega_{p}"); sprintf(tunits,"#omega_{p}^{-1}"); if(phaname.Contains("p1x1") || phaname.Contains("p2x2") || phaname.Contains("p3x3")) { sprintf(yunits,"m_{e}c"); sprintf(aunits,"m_{e}c^{2}/#omega_{p}"); } else if(phaname.Contains("x2x1")) { sprintf(yunits,"c/#omega_{p}"); sprintf(aunits,"(c/#omega_{p})^{2}"); } } char xaxisname[24]; char yaxisname[24]; sprintf(xaxisname,"%s [%s]",xlabel,xunits); sprintf(yaxisname,"%s [%s]",ylabel,yunits); // Get phasespace histos Int_t Nspecies = pData->NSpecies(); TH1F *hPha1Dx = NULL; TH1F *hPha1Dy = NULL; TH2F *hPha2D = NULL; Double_t Charge = 0.; for(Int_t i=0;i<Nspecies;i++) { if(i!=index) continue; if(!pData->GetRawFileName(i)) continue; char hName[24]; sprintf(hName,"hPha_%i_%s",i,yname); hPha1Dy = (TH1F*) gROOT->FindObject(hName); if(hPha1Dy) delete hPha1Dy; hPha1Dy = new TH1F(hName,"",yNbin,yMin,yMax); // cout << "filename = " << pData->GetRawFileName(i)->c_str() << endl; // pData->GetH1Raw(pData->GetRawFileName(i)->c_str(),yname,hPha1Dy,opt); TTree *tree = pData->GetTreeRaw(pData->GetRawFileName(i)->c_str(),opt); tree->Project(hName,yname,Cut); // Explore the 1D histogram in the 2nd variable : // It gets the mean the rms and the boundaries for plotting Double_t yNtotal = 0.0; Double_t ymean = 0.0; Double_t ymean2 = 0.0; Double_t yLeft = -1; Double_t yRight = -1; Int_t ybinLeft = -1; Int_t ybinRight = -1; for(Int_t j=1;j<=yNbin;j++) if(yLeft==-1 && hPha1Dy->GetBinContent(j)>0.001*hPha1Dy->GetMaximum()) { yLeft = hPha1Dy->GetBinCenter(j); ybinLeft = j; break; } for(Int_t j=yNbin;j>0;j--) if(yRight==-1 && hPha1Dy->GetBinContent(j)>0.001*hPha1Dy->GetMaximum()) { yRight = hPha1Dy->GetBinCenter(j); ybinRight = j; break; } for(Int_t k=ybinLeft;k<=ybinRight;k++) { Double_t y = hPha1Dy->GetXaxis()->GetBinCenter(k); Double_t value = TMath::Abs(hPha1Dy->GetBinContent(k)); ymean += y*value; ymean2 += y*y*value; yNtotal += value; } ymean /= yNtotal; ymean2 /= yNtotal; Double_t yrms = TMath::Sqrt(ymean2 - ymean*ymean); // Redefine axis range according with the mean and the rms of the 1D distributions: TString YNAME = yname; if(YNAME.Contains("p1") || YNAME.Contains("p2") || YNAME.Contains("p3")) { yMin = yLeft - TMath::Abs(yRight-yLeft)*0.5; yMax = yRight + TMath::Abs(yRight-yLeft)*0.5; } // Center the plot around 0 if(phaname.Contains("p2x2") || phaname.Contains("p3x3")) { if(fabs(xMin)>fabs(xMax)) xMax = -xMin; else xMin = -xMax; if(fabs(yMin)>fabs(yMax)) yMax = -yMin; else yMin = -yMax; } sprintf(hName,"hPha_%i_%s",i,phaname.Data()); hPha2D = (TH2F*) gROOT->FindObject(hName); if(hPha2D) delete hPha2D; hPha2D = new TH2F(hName,"",xNbin,xMin,xMax,yNbin,yMin,yMax); //pData->GetH2Raw(pData->GetRawFileName(i)->c_str(),xname,yname,hPha2D,opt); char dcommand[6]; sprintf(dcommand,"%s:%s",yname,xname); tree->Project(hName,dcommand,Cut); hPha2D->GetXaxis()->CenterTitle(); hPha2D->GetYaxis()->CenterTitle(); hPha2D->GetZaxis()->CenterTitle(); hPha2D->GetXaxis()->SetTitle(xaxisname); hPha2D->GetYaxis()->SetTitle(yaxisname); hPha2D->GetZaxis()->SetTitle("n [a.u.]"); Charge = hPha2D->Integral(); } // Emittance and others Double_t xmean = 0.0; Double_t ymean = 0.0; Double_t x2mean = 0.0; Double_t y2mean = 0.0; Double_t xymean = 0.0; Double_t Ntotal = 0.0; for(Int_t i=1;i<=xNbin;i++) { Double_t x = hPha2D->GetXaxis()->GetBinCenter(i); // if(x<xmin || x>xmax) continue; for(Int_t j=1;j<=yNbin;j++) { Double_t y = hPha2D->GetYaxis()->GetBinCenter(j); // if(y<ymin || y>ymax) continue; Double_t value = TMath::Abs(hPha2D->GetBinContent(i,j)); xmean += x*value; ymean += y*value; x2mean += x*x*value; y2mean += y*y*value; xymean += x*y*value; Ntotal += value; } } xmean /= Ntotal; ymean /= Ntotal; x2mean /= Ntotal; y2mean /= Ntotal; xymean /= Ntotal; Double_t xrms2 = x2mean - xmean*xmean; Double_t yrms2 = y2mean - ymean*ymean; Double_t xrms = TMath::Sqrt(xrms2); Double_t yrms = TMath::Sqrt(yrms2); Double_t xyrms2 = xymean - xmean*ymean; Double_t emittance = TMath::Sqrt(xrms2*yrms2 - xyrms2*xyrms2); // Set palette: PPalette * pPalette = (PPalette*) gROOT->FindObject("electron"); pPalette->cd(); Float_t Max = hPha2D->GetMaximum(); Float_t Min = hPha2D->GetMinimum(); hPha2D->GetZaxis()->SetRangeUser(Min,Max); // Charge Charge *= dx1*dx2*dx3; if(opt.Contains("units")) { Double_t dV = skindepth * skindepth * skindepth; Charge *= n0 * dV; Charge *= (PConst::ElectronCharge/PUnits::picocoulomb); cout << Form(" Skindepth = %8.4f um",skindepth/PUnits::um) << endl; cout << Form(" Volume = %e cm^3",dx1 * dx2 * dx3 * dV / (PUnits::cm * PUnits::cm * PUnits::cm)) << endl; cout << Form(" Plasma volume charge = %8.4f",dx1 * dx2 * dx3 * n0 * dV * PConst::ElectronCharge/PUnits::picocoulomb) << endl; cout << Form(" Integrated charge (RAW) of specie %3i = %8f pC",index,Charge) << endl; } else { cout << Form(" Integrated charge (RAW) of specie %3i = %8.4f n0 * kp^-3",index,Charge) << endl; } // Changing to user units: // -------------------------- if(opt.Contains("units") && n0) { xMin *= skindepth / PUnits::um; xMax *= skindepth / PUnits::um; if(phaname.Contains("p1x1")) { yMin *= pData->GetBeamMass() / PUnits::GeV; yMax *= pData->GetBeamMass() / PUnits::GeV; } else if(phaname.Contains("p2x2") || phaname.Contains("p3x3")) { yMin *= pData->GetBeamMass() / PUnits::MeV; yMax *= pData->GetBeamMass() / PUnits::MeV; } else if(phaname.Contains("x2x1")) { yMin *= skindepth / PUnits::um; yMax *= skindepth / PUnits::um; } hPha2D->SetBins(xNbin,xMin,xMax,yNbin,yMin,yMax); // for(Int_t j=0;j<=xNbin;j++) { // for(Int_t k=0;k<=yNbin;k++) { // hPha2D->SetBinContent(j,k, hPha2D->GetBinContent(j,k) * n0 / (1e15/PUnits::cm3) ); // } // } xmean *= skindepth / PUnits::um; xrms *= skindepth / PUnits::um; if(phaname.Contains("p1x1")) { ymean *= pData->GetBeamMass() / PUnits::GeV; yrms *= pData->GetBeamMass() / PUnits::GeV; emittance *= (skindepth / PUnits::um);// * (pData->GetBeamMass() / PUnits::GeV); } else if(phaname.Contains("p2x2")||phaname.Contains("p3x3")) { ymean *= pData->GetBeamMass() / PUnits::MeV; yrms *= pData->GetBeamMass() / PUnits::MeV; emittance *= (skindepth / PUnits::um);// * (pData->GetBeamMass() / PUnits::MeV); } else if(phaname.Contains("x2x1")) { ymean *= skindepth / PUnits::um; yrms *= skindepth / PUnits::um; emittance *= (skindepth / PUnits::um) * (skindepth / PUnits::um); } } cout << " Bunch properties: " << endl; cout << Form(" xMean = %7.3f yMean = %7.3f xyMean = %7.3f",xmean,ymean,xymean) << endl; cout << Form(" xRms = %7.3f yRms = %7.3f",xrms,yrms) << endl; cout << Form(" Emittance = %7.3f",emittance) << endl; // Plotting // ----------------------------------------------- // Canvas setup TCanvas *C; if(opt.Contains("hres") && !opt.Contains("pdf")) // high resolution for plain graphics output. C = new TCanvas("C","2D Phasespace",1000,625); else C = new TCanvas("C","2D Phasespace",800,500); // Text objects TPaveText *textTime = new TPaveText(0.55,0.85,0.82,0.9,"NDC"); PlasmaGlob::SetPaveTextStyle(textTime,32); char ctext[128]; if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"Z = %5.1f mm", Time * skindepth / PUnits::mm); else sprintf(ctext,"T = %5.1f #omega_{p}^{-1}",Time); textTime->AddText(ctext); TPaveText *textDen = new TPaveText(0.15,0.85,0.48,0.9,"NDC"); PlasmaGlob::SetPaveTextStyle(textDen,12); textDen->SetTextColor(kOrange+10); if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"n_{0} = %5.2f x 10^{17} / cc", n0 / (1e17/PUnits::cm3)); else if(pData->GetBeamDensity() && pData->GetPlasmaDensity()) sprintf(ctext,"n_{b}/n_{0} = %5.2f", pData->GetBeamDensity()/n0); textDen->AddText(ctext); TPaveText *textWav = new TPaveText(0.15,0.2,0.48,0.25,"NDC"); PlasmaGlob::SetPaveTextStyle(textWav,12); textWav->SetTextColor(kGray+2); sprintf(ctext,"#lambda_{p} = %5.3f #mum", pData->GetPlasmaWaveLength() / PUnits::um); textWav->AddText(ctext); TPaveText *textCharge = new TPaveText(0.15,0.25,0.48,0.3,"NDC"); PlasmaGlob::SetPaveTextStyle(textCharge,12); textCharge->SetTextColor(kGray+2); if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"Charge = %5.3f pC", Charge); else sprintf(ctext,"Charge = %5.3f n0#timeskp^{-3}", Charge); textCharge->AddText(ctext); TPaveText *textEmit = new TPaveText(0.55,0.2,0.82,0.35,"NDC"); PlasmaGlob::SetPaveTextStyle(textEmit,32); textEmit->SetTextColor(kGray+1); sprintf(ctext,"#LT%s#GT_{rms} = %5.3f %s",xlabel,xrms,xunits); textEmit->AddText(ctext); sprintf(ctext,"#LT%s#GT_{rms} = %5.3f %s",ylabel,yrms,yunits); textEmit->AddText(ctext); if(!phaname.Contains("x2x1")) { sprintf(ctext,"#epsilon_{N} = %5.3f %s",emittance,aunits); textEmit->AddText(ctext); } // Actual Plotting! // ------------------------------------------------------------ // Output file TString fOutName = Form("./%s/Plots/PhaseRawCut2D-%s/PhaseRawCut2D-%s",sim.Data(),phaname.Data(),phaname.Data()); fOutName += Form("-%s_%i",sim.Data(),time); C->cd(); gPad->SetFrameLineWidth(3); hPha2D->Draw("colz"); gPad->Update(); textTime->Draw(); textDen->Draw(); if(opt.Contains("units")) textWav->Draw(); textCharge->Draw(); textEmit->Draw(); gPad->RedrawAxis(); C->cd(); // Print to a file PlasmaGlob::imgconv(C,fOutName,opt); // --------------------------------------------------------- }
void PlotArray2D( const TString &sim, Int_t time, Float_t zoom=1, Int_t Nbins=1, const TString &options="") { #ifdef __CINT__ gSystem->Load("libptools.so"); #endif // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; // Refresh and Style PGlobals::Initialize(); // Coloured palettes gROOT->Macro("PPalettes.C"); TString opt = options; // More makeup if(opt.Contains("grid")) { gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); } // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Some beam properties: Float_t Ebeam = pData->GetBeamEnergy() * PUnits::MeV; Float_t gamma = Ebeam / PConst::ElectronMassE; Float_t vbeam = TMath::Sqrt(1 - 1/(gamma*gamma)); // cout << Form(" - Bunch gamma = %8.4f", gamma ) << endl; // cout << Form(" - Bunch velocity = %8.4f c", vbeam ) << endl; Float_t nb = pData->GetBeamDensity(); // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; // z start of the neutral in normalized units. Float_t zStartNeutral = pData->GetNeutralStart()*kp; // z end of the neutral in normalized units. Float_t zEndNeutral = pData->GetNeutralEnd()*kp; if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } Float_t shiftz = pData->Shift(opt); // cout << "Shift = " << shiftz << endl; // Calculate the "axis range" in number of bins. // If Nbins==0 a RMS width is taken. Double_t rms0 = pData->GetBeamRmsY() * kp; if(pData->IsCyl()) rms0 = pData->GetBeamRmsR() * kp; if(Nbins==0) { Nbins = TMath::Nint(rms0 / pData->GetDX(1)); } // ------------------------------------------------------------------------------- // Zoom window: // Take just the middle bin in 3rd dimension Float_t x3Min = (pData->GetXMax(2) + pData->GetXMin(2))/2.; Float_t x3Max = x3Min + pData->GetDX(2); pData->SetX3Min(x3Min); pData->SetX3Max(x3Max); // Perform a center zoom in 2nd dimension. Float_t x2Range = (pData->GetXMax(1) - pData->GetXMin(1))/zoom; Float_t midPoint = (pData->GetXMax(1) + pData->GetXMin(1))/2.; Float_t x2Min = midPoint - x2Range/2.0; Float_t x2Max = midPoint + x2Range/2.0; pData->SetX2Min(x2Min); pData->SetX2Max(x2Max); // keep the whole 1st dimension // Float_t x1Min = pData->GetXMin(0); // Float_t x1Max = pData->GetXMax(0); // pData->SetX1Min(x1Min); // pData->SetX1Max(x1Max); cout << Form(" Plotting range: %.2f < x1 < %.2f , %.2f < x2 < %.2f , %.2f < x2 < %.2f", pData->GetX1Min(),pData->GetX1Max(),pData->GetX2Min(),pData->GetX2Max(),pData->GetX3Min(),pData->GetX3Max()) << endl; cout << Form(" %3i [%3i,%3i] , %3i [%3i,%3i] , %3i [%3i,%3i]", pData->GetX1N(),pData->GetX1iMin(),pData->GetX1iMax(),pData->GetX2N(),pData->GetX2iMin(),pData->GetX2iMax(),pData->GetX3N(),pData->GetX3iMin(),pData->GetX3iMax()) << endl; // ---------------------------------------------------------------------------------- // Get array UInt_t dim[3]; Float_t *data = NULL; if(pData->GetChargeFileName(0)) { data = pData->Get3Darray(pData->GetChargeFileName(0)->c_str(),"charge",dim); } cout << Form("%i %i %i", dim[0],dim[1],dim[2]) << endl; // if(data) { // for(UInt_t i=0;i<dim[0];i++) // for(UInt_t j=0;j<dim[1];j++) // for(UInt_t k=0;k<dim[2];k++) // cout << Form("%i, %i, %i : %.2f",i,j,k,data[i * dim[2] * dim[1] + j * dim[2] + k]) << endl; } TH2F *h2D = new TH2F("h2D","",dim[2],pData->GetX1Min(),pData->GetX1Max(),dim[1],pData->GetX2Min(),pData->GetX2Max()); if(data) { for(UInt_t j=0;j<dim[1];j++) for(UInt_t k=0;k<dim[2];k++) { h2D->SetBinContent(k+1,j+1,-data[ (dim[0]/2) * dim[2] * dim[1] + j * dim[2] + k] ); } } h2D->Draw("colz"); }
void PlotField2D( const TString &sim, Int_t time, Int_t index = 0, Int_t zoom=2, const TString &options="") { PlasmaGlob::Initialize(); TString opt = options; // Palettes! gROOT->Macro("PlasmaPalettes.C"); if(opt.Contains("grid")) { gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); } gStyle->SetPadRightMargin(0.20); // Margin for palettes in 2D histos gStyle->SetLabelFont(42,"xyz"); // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; Bool_t CYL = kFALSE; if(sim.Contains("cyl")) CYL = kTRUE; Bool_t ThreeD = kFALSE; if(sim.Contains("3D")) ThreeD = kTRUE; // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Some beam properties: Float_t Ebeam = pData->GetBeamEnergy() * PUnits::MeV; Float_t gamma = Ebeam / PConst::ElectronMassE; Float_t vbeam = TMath::Sqrt(1 - 1/(gamma*gamma)); // cout << Form(" - Bunch gamma = %8.4f", gamma ) << endl; // cout << Form(" - Bunch velocity = %8.4f c", vbeam ) << endl; // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } // Get field histos const Int_t Nfields = 3; TH2F **hE2D = new TH2F*[Nfields]; for(Int_t i=0;i<Nfields;i++) { hE2D[i] = NULL; if(i!=index) continue; if(!pData->GetEfieldFileName(i)) continue; char hName[24]; sprintf(hName,"hE2D_%i",i); hE2D[i] = (TH2F*) gROOT->FindObject(hName); if(hE2D[i]) delete hE2D[i]; if(!ThreeD) hE2D[i] = pData->GetEField(i,opt); else hE2D[i] = pData->GetEField2DSliceZY(i,-1,1); hE2D[i]->SetName(hName); hE2D[i]->GetXaxis()->CenterTitle(); hE2D[i]->GetYaxis()->CenterTitle(); hE2D[i]->GetZaxis()->CenterTitle(); if(opt.Contains("comov")) hE2D[i]->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]"); else hE2D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]"); if(CYL) hE2D[i]->GetYaxis()->SetTitle("r [c/#omega_{p}]"); else hE2D[i]->GetYaxis()->SetTitle("y [c/#omega_{p}]"); if(i==0) hE2D[i]->GetZaxis()->SetTitle("E_{z} [E_{0}]"); else if(i==1) hE2D[i]->GetZaxis()->SetTitle("E_{y} [E_{0}]"); else if(i==2) hE2D[i]->GetZaxis()->SetTitle("E_{x} [E_{0}]"); } // Tunning the Histograms // --------------------- // Chaning to user units: // -------------------------- if(opt.Contains("units") && n0) { for(Int_t i=0;i<Nfields;i++) { if(i!=index) continue; Int_t NbinsX = hE2D[i]->GetNbinsX(); Float_t xMin = skindepth * hE2D[i]->GetXaxis()->GetXmin() / PUnits::mm; Float_t xMax = skindepth * hE2D[i]->GetXaxis()->GetXmax() / PUnits::mm; Int_t NbinsY = hE2D[i]->GetNbinsY(); Float_t yMin = skindepth * hE2D[i]->GetYaxis()->GetXmin() / PUnits::mm; Float_t yMax = skindepth * hE2D[i]->GetYaxis()->GetXmax() / PUnits::mm; hE2D[i]->SetBins(NbinsX,xMin,xMax,NbinsY,yMin,yMax); for(Int_t j=0;j<hE2D[i]->GetNbinsX();j++) { for(Int_t k=0;k<hE2D[i]->GetNbinsY();k++) { hE2D[i]->SetBinContent(j,k, hE2D[i]->GetBinContent(j,k) * ( E0 / (PUnits::GV/PUnits::m) ) ); } } if(CYL) hE2D[i]->GetYaxis()->SetTitle("r [mm]"); else hE2D[i]->GetYaxis()->SetTitle("y [mm]"); if(opt.Contains("comov")) hE2D[i]->GetXaxis()->SetTitle("#zeta [mm]"); else hE2D[i]->GetXaxis()->SetTitle("z [mm]"); if(i==0) hE2D[i]->GetZaxis()->SetTitle("E_{z} [GV/m]"); else if(i==1) hE2D[i]->GetZaxis()->SetTitle("E_{y} [GV/m]"); else if(i==2) hE2D[i]->GetZaxis()->SetTitle("E_{x} [GV/m]"); } } // Change the range of z axis for the fields to be symmetric. Float_t Emax = hE2D[index]->GetMaximum(); Float_t Emin = hE2D[index]->GetMinimum(); if(Emax > TMath::Abs(Emin)) Emin = -Emax; else Emax = -Emin; hE2D[index]->GetZaxis()->SetRangeUser(Emin,Emax); // Plotting // ----------------------------------------------- // Canvas setup TCanvas *C; if(opt.Contains("hres") && !opt.Contains("pdf")) // high resolution for plain grahics output. C = new TCanvas("C","2D Electric field",1000,625); else C = new TCanvas("C","2D Electric field",800,500); // Palettes setup TExec *exField = new TExec("exField","rbowgrayPalette->cd();"); // Text objects TPaveText *textTime = new TPaveText(0.50,0.85,0.77,0.9,"NDC"); PlasmaGlob::SetPaveTextStyle(textTime,32); char ctext[128]; if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"Z = %5.1f mm", 1e3 * pData->GetPlasmaSkinDepth() * Time); else sprintf(ctext,"T = %5.1f #omega_{p}^{-1}",Time); textTime->AddText(ctext); TPaveText *textDen = new TPaveText(0.15,0.85,0.48,0.9,"NDC"); PlasmaGlob::SetPaveTextStyle(textDen,12); textDen->SetTextColor(kOrange+10); if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"n_{0} = %5.2f x 10^{15} / cc", 1e-6 * 1e-15 * pData->GetPlasmaDensity()); else if(pData->GetBeamDensity() && pData->GetPlasmaDensity()) sprintf(ctext,"n_{b}/n_{0} = %5.2f", pData->GetBeamDensity()/pData->GetPlasmaDensity()); textDen->AddText(ctext); TPaveText *textWav = new TPaveText(0.12,0.78,0.45,0.83,"NDC"); PlasmaGlob::SetPaveTextStyle(textWav,12); textWav->SetTextColor(kGray+2); sprintf(ctext,"#lambda_{p} = %5.3f mm", 1e3 * pData->GetPlasmaWaveLength()); textWav->AddText(ctext); // Actual Plotting! // ------------------------------------------------------------ // Output file TString fOutName = Form("./%s/Plots/Field2D/Field2D",sim.Data()); fOutName += Form("-%s_%i",sim.Data(),time); C->cd(); gPad->SetFrameLineWidth(3); TH2F *hFrame = (TH2F*) gROOT->FindObject("hFrame1"); if(hFrame) delete hFrame; hFrame = (TH2F*) hE2D[index]->Clone("hFrame1"); hFrame->Reset(); hFrame->Draw("col"); exField->Draw(); hE2D[index]->Draw("colz same"); gPad->Update(); textTime->Draw(); textDen->Draw(); if(opt.Contains("units")) textWav->Draw(); gPad->RedrawAxis(); C->cd(); // Print to a file PlasmaGlob::imgconv(C,fOutName,opt); // --------------------------------------------------------- }
void PlotField2D( const TString &sim, Int_t time, Int_t index = 0, Float_t zoom=2, Int_t Nbins=2, const TString &options="") { #ifdef __CINT__ gSystem->Load("libptools.so"); #endif // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; // Refresh and Style PGlobals::Initialize(); // Coloured palettes gROOT->Macro("PPalettes.C"); TString opt = options; // More makeup if(opt.Contains("grid")) { gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); } gStyle->SetTitleFont(42); gStyle->SetStatFont(42); gStyle->SetTextFont(42); gStyle->SetTitleFont(42,"xyz"); gStyle->SetLabelFont(42,"xyz"); // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Some beam properties: Float_t Ebeam = pData->GetBeamEnergy() * PUnits::MeV; Float_t gamma = Ebeam / PConst::ElectronMassE; Float_t vbeam = TMath::Sqrt(1 - 1/(gamma*gamma)); // cout << Form(" - Bunch gamma = %8.4f", gamma ) << endl; // cout << Form(" - Bunch velocity = %8.4f c", vbeam ) << endl; Float_t nb = pData->GetBeamDensity(); // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; // z start of the neutral in normalized units. Float_t zStartNeutral = pData->GetNeutralStart()*kp; // z end of the neutral in normalized units. Float_t zEndNeutral = pData->GetNeutralEnd()*kp; if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } Float_t shiftz = pData->Shift(opt); // cout << "Shift = " << shiftz << endl; // Calculate the "axis range" in number of bins. If Nbins==0 a RMS width is taken. Double_t rms0 = pData->GetBeamRmsY() * kp; if(pData->IsCyl()) rms0 = pData->GetBeamRmsR() * kp; Int_t FirstyBin = 0; Int_t LastyBin = 0; if(Nbins==0) { Nbins = TMath::Nint(rms0 / pData->GetDX(1)); } // Slice width limits. if(!pData->IsCyl()) { FirstyBin = pData->GetNX(1)/2 + 1 - Nbins; LastyBin = pData->GetNX(1)/2 + Nbins; } else { FirstyBin = 1; LastyBin = Nbins; } // ------------------------------------------------------------------------------- // Get field histos const Int_t Nfields = 3; TH2F **hE2D = new TH2F*[Nfields]; for(Int_t i=0;i<Nfields;i++) { hE2D[i] = NULL; if(i!=index) continue; if(!pData->GetEfieldFileName(i)) continue; char hName[24]; sprintf(hName,"hE2D_%i",i); hE2D[i] = (TH2F*) gROOT->FindObject(hName); if(hE2D[i]) delete hE2D[i]; if(!pData->Is3D()) hE2D[i] = pData->GetEField(i,opt); else hE2D[i] = pData->GetEField2DSliceZY(i,-1,Nbins,opt+"avg"); hE2D[i]->SetName(hName); hE2D[i]->GetXaxis()->CenterTitle(); hE2D[i]->GetYaxis()->CenterTitle(); hE2D[i]->GetZaxis()->CenterTitle(); if(opt.Contains("comov")) hE2D[i]->GetXaxis()->SetTitle("k_{p} #zeta"); else hE2D[i]->GetXaxis()->SetTitle("k_{p} z"); if(pData->IsCyl()) hE2D[i]->GetYaxis()->SetTitle("k_{p} r"); else hE2D[i]->GetYaxis()->SetTitle("k_{p} x"); if(i==0) hE2D[i]->GetZaxis()->SetTitle("E_{z} / E_{0}"); else if(i==1) hE2D[i]->GetZaxis()->SetTitle("E_{y} / E_{0}"); else if(i==2) hE2D[i]->GetZaxis()->SetTitle("E_{x} / E_{0}"); } // Tunning the Histograms // --------------------- // Chaning to user units: // -------------------------- if(opt.Contains("units") && n0) { for(Int_t i=0;i<Nfields;i++) { if(i!=index) continue; Int_t NbinsX = hE2D[i]->GetNbinsX(); Float_t xMin = skindepth * hE2D[i]->GetXaxis()->GetXmin() / PUnits::um; Float_t xMax = skindepth * hE2D[i]->GetXaxis()->GetXmax() / PUnits::um; Int_t NbinsY = hE2D[i]->GetNbinsY(); Float_t yMin = skindepth * hE2D[i]->GetYaxis()->GetXmin() / PUnits::um; Float_t yMax = skindepth * hE2D[i]->GetYaxis()->GetXmax() / PUnits::um; hE2D[i]->SetBins(NbinsX,xMin,xMax,NbinsY,yMin,yMax); for(Int_t j=0;j<hE2D[i]->GetNbinsX();j++) { for(Int_t k=0;k<hE2D[i]->GetNbinsY();k++) { hE2D[i]->SetBinContent(j,k, hE2D[i]->GetBinContent(j,k) * ( E0 / (PUnits::GV/PUnits::m) ) ); } } if(pData->IsCyl()) hE2D[i]->GetYaxis()->SetTitle("r [#mum]"); else hE2D[i]->GetYaxis()->SetTitle("x [#mum]"); if(opt.Contains("comov")) hE2D[i]->GetXaxis()->SetTitle("#zeta [#mum]"); else hE2D[i]->GetXaxis()->SetTitle("z [#mum]"); if(i==0) hE2D[i]->GetZaxis()->SetTitle("E_{z} [GV/m]"); else if(i==1) hE2D[i]->GetZaxis()->SetTitle("E_{y} [GV/m]"); else if(i==2) hE2D[i]->GetZaxis()->SetTitle("E_{x} [GV/m]"); } } // --------------------------------------------------- Vertical Zoom ------------ Float_t yRange = (hE2D[index]->GetYaxis()->GetXmax() - hE2D[index]->GetYaxis()->GetXmin())/zoom; Float_t midPoint = (hE2D[index]->GetYaxis()->GetXmax() + hE2D[index]->GetYaxis()->GetXmin())/2.; Float_t yMin = midPoint-yRange/2; Float_t yMax = midPoint+yRange/2; if(pData->IsCyl()) { yMin = hE2D[index]->GetYaxis()->GetXmin(); yMax = yRange; } hE2D[index]->GetYaxis()->SetRangeUser(yMin,yMax); Float_t xMin = hE2D[index]->GetXaxis()->GetXmin(); Float_t xMax = hE2D[index]->GetXaxis()->GetXmax(); Float_t xRange = xMax - xMin; // Change the range of z axis for the fields to be symmetric. Float_t Emax = hE2D[index]->GetMaximum(); Float_t Emin = hE2D[index]->GetMinimum(); if(Emax > TMath::Abs(Emin)) Emin = -Emax; else Emax = -Emin; hE2D[index]->GetZaxis()->SetRangeUser(Emin,Emax); PPalette * plasmaPalette = (PPalette*) gROOT->FindObject("rbowwhite"); plasmaPalette->cd(); // Plotting // ----------------------------------------------- // Canvas setup TCanvas *C = new TCanvas("C","2D electric",800,500); // Actual Plotting! // ------------------------------------------------------------ // Output file TString fname; if(index<3) fname = Form("E%i",index+1); TString fOutName = Form("./%s/Plots/Field2D/Field2D-%s",sim.Data(),fname.Data()); fOutName += Form("-%s_%i",sim.Data(),time); C->cd(); // Setup Pad layout: Float_t lMargin = 0.15; Float_t rMargin = 0.18; Float_t bMargin = 0.20; Float_t tMargin = 0.06; gPad->SetLeftMargin(lMargin); gPad->SetRightMargin(rMargin); gPad->SetBottomMargin(bMargin); gPad->SetTopMargin(tMargin); if(opt.Contains("logz")) { gPad->SetLogz(1); } else { gPad->SetLogz(0); } gPad->SetFrameLineWidth(2); // Define the frames for plotting Int_t fonttype = 43; Int_t fontsize = 28; Int_t tfontsize = 30; Float_t txoffset = 1.3; Float_t lxoffset = 0.02; Float_t tyoffset = 1.0; Float_t lyoffset = 0.01; Float_t tylength = 0.02; Float_t txlength = 0.04; TH2F *hFrame = (TH2F*) gROOT->FindObject("hFrame"); if(hFrame) delete hFrame; hFrame = (TH2F*) hE2D[index]->Clone("hFrame"); hFrame->Reset(); // Format for y axis hFrame->GetYaxis()->SetTitleFont(fonttype); hFrame->GetYaxis()->SetTitleSize(tfontsize); hFrame->GetYaxis()->SetTitleOffset(tyoffset); hFrame->GetYaxis()->SetLabelFont(fonttype); hFrame->GetYaxis()->SetLabelSize(fontsize); hFrame->GetYaxis()->SetLabelOffset(lyoffset); hFrame->GetYaxis()->SetTickLength(tylength); // Format for x axis hFrame->GetXaxis()->SetTitleFont(fonttype); hFrame->GetXaxis()->SetTitleSize(tfontsize+2); hFrame->GetXaxis()->SetTitleOffset(txoffset); hFrame->GetXaxis()->SetLabelFont(fonttype); hFrame->GetXaxis()->SetLabelSize(fontsize+2); hFrame->GetXaxis()->SetLabelOffset(lxoffset); hFrame->GetXaxis()->SetTickLength(txlength); hFrame->Draw("col"); // hE2D[index]->GetZaxis()->SetNdivisions(505); hE2D[index]->GetZaxis()->SetTitleFont(fonttype); hE2D[index]->Draw("colz same"); // Re-touchs gPad->Update(); Float_t y1 = gPad->GetBottomMargin(); Float_t y2 = 1 - gPad->GetTopMargin(); Float_t x1 = gPad->GetLeftMargin(); Float_t x2 = 1 - gPad->GetRightMargin(); Float_t gap = 0.005; TPaletteAxis *palette = (TPaletteAxis*)hE2D[index]->GetListOfFunctions()->FindObject("palette"); if(palette) { palette->SetY2NDC(y2 - gap); palette->SetY1NDC(y1 + gap); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); palette->SetTitleOffset(tyoffset); palette->SetTitleSize(tfontsize); palette->SetLabelFont(fonttype); palette->SetLabelSize(fontsize); if(opt.Contains("logz")) palette->SetLabelOffset(0); else palette->SetLabelOffset(lyoffset); palette->SetBorderSize(2); palette->SetLineColor(1); } // Text objects TPaveText *textTime = new TPaveText(xMax - 0.30*xRange, yMax-0.10*yRange, xMax-0.02*xRange, yMax-0.02*yRange); PGlobals::SetPaveTextStyle(textTime,32); char ctext[128]; if(opt.Contains("units") && n0) sprintf(ctext,"z = %5.1f #mum", Time * skindepth / PUnits::um); else sprintf(ctext,"#omega_{p} t = %5.1f",Time); textTime->AddText(ctext); TPaveText *textDen = new TPaveText(xMin + 0.02*xRange, yMax-0.10*yRange, xMin + 0.40*xRange, yMax-0.02*yRange); PGlobals::SetPaveTextStyle(textDen,12); textDen->SetTextColor(kOrange+10); if(opt.Contains("units") && n0) { sprintf(ctext,"n_{0} = %5.2f x 10^{17} / cm^{3}", 1e-17 * n0 * PUnits::cm3); textDen->AddText(ctext); textDen->Draw(); } textTime->Draw(); gPad->RedrawAxis(); C->cd(); // Print to a file PGlobals::imgconv(C,fOutName,opt); // --------------------------------------------------------- }
void PlotChargeFieldFocus2D( const TString &sim, Int_t time, Int_t zoom=2, Int_t Nbins=2, const TString &options="") { #ifdef __CINT__ gSystem->Load("libplasma.so"); #endif PlasmaGlob::Initialize(); // Palettes! gROOT->Macro("PlasmaPalettes.C"); // Init Units table PUnits::UnitsTable::Get(); // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; TString opt = options; // More makeup if(opt.Contains("grid")) { gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); } gStyle->SetTitleFont(42); gStyle->SetStatFont(42); gStyle->SetTextFont(42); gStyle->SetTitleFont(42,"xyz"); gStyle->SetLabelFont(42,"xyz"); // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Some beam properties: Float_t Ebeam = pData->GetBeamEnergy() * PUnits::MeV; Float_t gamma = Ebeam / PConst::ElectronMassE; Float_t vbeam = TMath::Sqrt(1 - 1/(gamma*gamma)); // cout << Form(" - Bunch gamma = %8.4f", gamma ) << endl; // cout << Form(" - Bunch velocity = %8.4f c", vbeam ) << endl; Float_t nb = pData->GetBeamDensity(); // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; // z start of the neutral in normalized units. Float_t zStartNeutral = pData->GetNeutralStart()*kp; // z end of the neutral in normalized units. Float_t zEndNeutral = pData->GetNeutralEnd()*kp; if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } Float_t shiftz = pData->Shift(opt); // cout << "Shift = " << shiftz << endl; // Calculate the "axis range" in number of bins. If Nbins==0 a RMS width is taken. Double_t rms0 = pData->GetBeamRmsY() * kp; if(pData->IsCyl()) rms0 = pData->GetBeamRmsR() * kp; Int_t FirstyBin = 0; Int_t LastyBin = 0; if(Nbins==0) { Nbins = TMath::Nint(rms0 / pData->GetDX(1)); } // Slice width limits. if(!pData->IsCyl()) { FirstyBin = pData->GetNX(1)/2 + 1 - Nbins; LastyBin = pData->GetNX(1)/2 + Nbins; } else { FirstyBin = 1; LastyBin = Nbins; } // ------------------------------------------------------------------------------- // Get charge density histos Int_t Nspecies = pData->NSpecies(); TH2F **hDen2D = new TH2F*[Nspecies]; TH1F **hDen1D = new TH1F*[Nspecies]; for(Int_t i=0;i<Nspecies;i++) { hDen2D[i] = NULL; hDen1D[i] = NULL; if(!pData->GetChargeFileName(i)) continue; cout << Form(" Getting charge density of specie: ") << i << endl; char hName[24]; sprintf(hName,"hDen2D_%i",i); hDen2D[i] = (TH2F*) gROOT->FindObject(hName); if(hDen2D[i]) delete hDen2D[i]; if(!pData->Is3D()) hDen2D[i] = pData->GetCharge(i,opt); else hDen2D[i] = pData->GetCharge2DSliceZY(i,-1,Nbins,opt+"avg"); // cout << Form(" Charge density of specie '%s' loaded into histogram '%s'",pData->GetSpeciesName(i).c_str(),hName) << endl; hDen2D[i]->SetName(hName); hDen2D[i]->GetXaxis()->CenterTitle(); hDen2D[i]->GetYaxis()->CenterTitle(); hDen2D[i]->GetZaxis()->CenterTitle(); if(opt.Contains("comov")) hDen2D[i]->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]"); else hDen2D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]"); if(pData->IsCyl()) hDen2D[i]->GetYaxis()->SetTitle("r [c/#omega_{p}]"); else hDen2D[i]->GetYaxis()->SetTitle("y [c/#omega_{p}]"); hDen2D[i]->GetZaxis()->SetTitle("n [n_{0}]"); if(!opt.Contains("1dline")) continue; sprintf(hName,"hDen1D_%i",i); hDen1D[i] = (TH1F*) gROOT->FindObject(hName); if(hDen1D[i]) delete hDen1D[i]; if(pData->Is3D()) { hDen1D[i] = pData->GetH1SliceZ3D(pData->GetChargeFileName(i)->c_str(),"charge",-1,Nbins,-1,Nbins,opt+"avg"); } else if(pData->IsCyl()) { // Cylindrical: The first bin with r>0 is actually the number 1 (not the 0). hDen1D[i] = pData->GetH1SliceZ(pData->GetChargeFileName(i)->c_str(),"charge",1,Nbins,opt+"avg"); } else { // 2D cartesian hDen1D[i] = pData->GetH1SliceZ(pData->GetChargeFileName(i)->c_str(),"charge",-1,Nbins,opt+"avg"); } // cout << Form(" Charge density of specie '%s' loaded into histogram '%s'",pData->GetSpeciesName(i).c_str(),hName) << endl; hDen1D[i]->SetName(hName); hDen1D[i]->GetXaxis()->CenterTitle(); hDen1D[i]->GetYaxis()->CenterTitle(); if(opt.Contains("comov")) hDen1D[i]->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]"); else hDen1D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]"); hDen1D[i]->GetYaxis()->SetTitle("n [n_{0}]"); } // Get electric fields const Int_t Nfields = 3; TH2F **hE2D = new TH2F*[Nfields]; TH1F **hE1D = new TH1F*[Nfields]; for(Int_t i=0;i<Nfields;i++) { hE2D[i] = NULL; hE1D[i] = NULL; if(!pData->GetEfieldFileName(i)) continue; cout << Form(" Getting electric field number ") << i+1 << endl; char hName[24]; sprintf(hName,"hE2D_%i",i); hE2D[i] = (TH2F*) gROOT->FindObject(hName); if(hE2D[i]) delete hE2D[i]; if(!pData->Is3D()) hE2D[i] = pData->GetEField(i,opt); else hE2D[i] = pData->GetEField2DSliceZY(i,-1,Nbins,opt+"avg"); hE2D[i]->SetName(hName); hE2D[i]->GetXaxis()->CenterTitle(); hE2D[i]->GetYaxis()->CenterTitle(); hE2D[i]->GetZaxis()->CenterTitle(); if(opt.Contains("comov")) hE2D[i]->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]"); else hE2D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]"); if(pData->IsCyl()) hE2D[i]->GetYaxis()->SetTitle("r [c/#omega_{p}]"); else hE2D[i]->GetYaxis()->SetTitle("y [c/#omega_{p}]"); if(i==0) hE2D[i]->GetZaxis()->SetTitle("E_{z} [E_{0}]"); else if(i==1) hE2D[i]->GetZaxis()->SetTitle("E_{y} [E_{0}]"); else if(i==2) hE2D[i]->GetZaxis()->SetTitle("E_{x} [E_{0}]"); if(!opt.Contains("1dline")) continue; sprintf(hName,"hE1D_%i",i); hE1D[i] = (TH1F*) gROOT->FindObject(hName); if(hE1D[i]) delete hE1D[i]; // 1D histograms char nam[3]; sprintf(nam,"e%i",i+1); if(pData->Is3D()) { if(i==0) hE1D[i] = pData->GetH1SliceZ3D(pData->GetEfieldFileName(i)->c_str(),nam,-1,Nbins,-1,Nbins,opt+"avg"); else hE1D[i] = pData->GetH1SliceZ3D(pData->GetEfieldFileName(i)->c_str(),nam,-Nbins,Nbins,-Nbins,Nbins,opt+"avg"); } else if(pData->IsCyl()) { // Cylindrical: The first bin with r>0 is actually the number 1 (not the 0). hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,1,Nbins,opt+"avg"); } else { // 2D cartesian if(i==0) hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,-1,Nbins,opt+"avg"); else hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,-Nbins,Nbins,opt+"avg"); } hE1D[i]->SetName(hName); if(opt.Contains("comov")) hE1D[i]->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]"); else hE1D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]"); if(i==0) hE1D[i]->GetYaxis()->SetTitle("E_{z} [E_{0}]"); else if(i==1) hE1D[i]->GetYaxis()->SetTitle("E_{y} [E_{0}]"); else if(i==2) hE1D[i]->GetYaxis()->SetTitle("E_{x} [E_{0}]"); } // Now, combine the electric field components into the total |E| // and calculate ionization probability for He: // Outter Helium electron Double_t Eion0 = 24.59 * PUnits::eV; Double_t Z = 1; Double_t l = 0; Double_t m = 0; TH1F *hIonProb1D = NULL; if(opt.Contains("ionprob")) { hIonProb1D = (TH1F*) hE1D[0]->Clone("hIonProb1D"); hIonProb1D->Reset(); Int_t NbinsX = hE1D[0]->GetNbinsX(); for(Int_t j=1;j<=NbinsX;j++) { Double_t E1 = hE1D[0]->GetBinContent(j); Double_t E2 = hE1D[1]->GetBinContent(j); Double_t E3 = hE1D[2]->GetBinContent(j); Double_t E = TMath::Sqrt(E1*E1+E2*E2+E3*E3); E *= E0; Double_t IonProb = (PFunc::ADK(E,Eion0,Z,l,m)/PUnits::atomictime)*PUnits::femtosecond; hIonProb1D->SetBinContent(j,IonProb); } hIonProb1D->GetYaxis()->SetTitle("W_{ADK} [fs^{-1}]"); } // Tunning the Histograms // --------------------- // Chaning to user units: // -------------------------- if(opt.Contains("units") && n0) { for(Int_t i=0;i<Nspecies;i++) { if(!hDen2D[i]) continue; Int_t NbinsX = hDen2D[i]->GetNbinsX(); Float_t xMin = skindepth * hDen2D[i]->GetXaxis()->GetXmin() / PUnits::um; Float_t xMax = skindepth * hDen2D[i]->GetXaxis()->GetXmax() / PUnits::um; Int_t NbinsY = hDen2D[i]->GetNbinsY(); Float_t yMin = skindepth * hDen2D[i]->GetYaxis()->GetXmin() / PUnits::um; Float_t yMax = skindepth * hDen2D[i]->GetYaxis()->GetXmax() / PUnits::um; hDen2D[i]->SetBins(NbinsX,xMin,xMax,NbinsY,yMin,yMax); // for(Int_t j=0;j<hDen2D[i]->GetNbinsX();j++) { // for(Int_t k=0;k<hDen2D[i]->GetNbinsY();k++) { // hDen2D[i]->SetBinContent(j,k, hDen2D[i]->GetBinContent(j,k) * n0 / (1e15/PUnits::cm3) ); // } // } if(pData->IsCyl()) hDen2D[i]->GetYaxis()->SetTitle("r [#mum]"); else hDen2D[i]->GetYaxis()->SetTitle("y [#mum]"); if(opt.Contains("comov")) hDen2D[i]->GetXaxis()->SetTitle("#zeta [#mum]"); else hDen2D[i]->GetXaxis()->SetTitle("z [#mum]"); // hDen2D[i]->GetZaxis()->SetTitle("n [10^{15}/cm^{3}]"); if(!hDen1D[i]) continue; hDen1D[i]->SetBins(NbinsX,xMin,xMax); if(opt.Contains("comov")) hDen1D[i]->GetXaxis()->SetTitle("#zeta [#mum]"); else hDen1D[i]->GetXaxis()->SetTitle("z [#mum]"); } for(Int_t i=0;i<Nfields;i++) { Int_t NbinsX = hE2D[i]->GetNbinsX(); Float_t xMin = skindepth * hE2D[i]->GetXaxis()->GetXmin() / PUnits::um; Float_t xMax = skindepth * hE2D[i]->GetXaxis()->GetXmax() / PUnits::um; Int_t NbinsY = hE2D[i]->GetNbinsY(); Float_t yMin = skindepth * hE2D[i]->GetYaxis()->GetXmin() / PUnits::um; Float_t yMax = skindepth * hE2D[i]->GetYaxis()->GetXmax() / PUnits::um; hE2D[i]->SetBins(NbinsX,xMin,xMax,NbinsY,yMin,yMax); if(hE1D[i]) hE1D[i]->SetBins(NbinsX,xMin,xMax); for(Int_t j=0;j<hE2D[i]->GetNbinsX();j++) { for(Int_t k=0;k<hE2D[i]->GetNbinsY();k++) { hE2D[i]->SetBinContent(j,k, hE2D[i]->GetBinContent(j,k) * ( E0 / (PUnits::GV/PUnits::m) ) ); } if(!hE1D[i]) continue; hE1D[i]->SetBinContent(j, hE1D[i]->GetBinContent(j) * ( E0 / (PUnits::GV) ) ); } if(pData->IsCyl()) hE2D[i]->GetYaxis()->SetTitle("r [#mum]"); else hE2D[i]->GetYaxis()->SetTitle("y [#mum]"); if(opt.Contains("comov")) hE2D[i]->GetXaxis()->SetTitle("#zeta [#mum]"); else hE2D[i]->GetXaxis()->SetTitle("z [#mum]"); if(i==0) hE2D[i]->GetZaxis()->SetTitle("E_{z} [GV/m]"); else if(i==1) hE2D[i]->GetZaxis()->SetTitle("E_{y} [GV/m]"); else if(i==2) hE2D[i]->GetZaxis()->SetTitle("E_{x} [GV/m]"); if(!hE1D[i]) continue; if(opt.Contains("comov")) hE1D[i]->GetXaxis()->SetTitle("#zeta [mm]"); else hE1D[i]->GetXaxis()->SetTitle("z [mm]"); if(i==0) hE1D[i]->GetYaxis()->SetTitle("E_{z} [GV/m]"); else if(i==1) hE1D[i]->GetYaxis()->SetTitle("E_{y} [GV/m]"); else if(i==2) hE1D[i]->GetYaxis()->SetTitle("E_{x} [GV/m]"); } if(hIonProb1D) { Int_t NbinsX = hIonProb1D->GetNbinsX(); Float_t xMin = skindepth * hIonProb1D->GetXaxis()->GetXmin() / PUnits::um; Float_t xMax = skindepth * hIonProb1D->GetXaxis()->GetXmax() / PUnits::um; hIonProb1D->SetBins(NbinsX,xMin,xMax); } } // --------------------------------------------------- Vertical Zoom ------------ Float_t range = (hDen2D[0]->GetYaxis()->GetXmax() - hDen2D[0]->GetYaxis()->GetXmin())/zoom; Float_t midPoint = (hDen2D[0]->GetYaxis()->GetXmax() + hDen2D[0]->GetYaxis()->GetXmin())/2.; Double_t ymin = midPoint-range/2; Double_t ymax = midPoint+range/2; if(pData->IsCyl()) { ymin = hDen2D[0]->GetYaxis()->GetXmin(); ymax = range; } hDen2D[0]->GetYaxis()->SetRangeUser(ymin,ymax); hE2D[0]->GetYaxis()->SetRangeUser(ymin,ymax); hE2D[1]->GetYaxis()->SetRangeUser(ymin,ymax); // ------------- z Zoom --------------------------------- Plasma palette ----------- // Set the range of the plasma charge density histogram for maximum constrast // using a dynamic palette wich adjust the nominal value to a certain color. Float_t density = 1; // if(opt.Contains("units") && n0) // density = n0 / (1e17/PUnits::cm3); Float_t Base = density; Float_t BaseB = TMath::Nint(100*(nb/n0))/100.0; Float_t gMax = hDen2D[0]->GetMaximum(); Float_t gMin = (0.1001) * Base; if(BaseB<Base) gMin = (0.1001) * BaseB; if(gMax<Base) gMax = 1.1*Base; Float_t *Max = new Float_t[Nspecies]; Float_t *Min = new Float_t[Nspecies]; for(Int_t i=0;i<Nspecies;i++) { if(!hDen2D[i]) continue; Max[i] = hDen2D[i]->GetMaximum(); Min[i] = 0.01*Max[i]; // if(i==1) = Min[i] = 1.001E-4; if(i==2) Min[i] = 1.001E-3; if(Max[i]>gMax) gMax = Max[i]; hDen2D[i]->GetZaxis()->SetRangeUser(Min[i],Max[i]); } hDen2D[0]->GetZaxis()->SetRangeUser(gMin,gMax); // if(hDen2D[1]) { // hDen2D[1]->GetZaxis()->SetRangeUser(gMin,Max[1]); // } // if(Nspecies>=3) { // if(hDen2D[2]) { // hDen2D[2]->GetZaxis()->SetRangeUser(gMin,Max[2]); // } // } // Dynamic plasma palette const Int_t plasmaDNRGBs = 3; const Int_t plasmaDNCont = 128; Double_t basePos = 0.5; if(gMax!=gMin) { if(opt.Contains("logz")) { Float_t a = 1.0/(TMath::Log10(gMax)-TMath::Log10(gMin)); Float_t b = TMath::Log10(gMin); basePos = a*(TMath::Log10(Base) - b); } else { basePos = (1.0/(gMax-gMin))*(Base - gMin); } } Double_t plasmaDStops[plasmaDNRGBs] = { 0.00, basePos, 1.00 }; Double_t plasmaDRed[plasmaDNRGBs] = { 0.99, 0.90, 0.00 }; Double_t plasmaDGreen[plasmaDNRGBs] = { 0.99, 0.90, 0.00 }; Double_t plasmaDBlue[plasmaDNRGBs] = { 0.99, 0.90, 0.00 }; PPalette * plasmaPalette = (PPalette*) gROOT->FindObject("plasma"); plasmaPalette->CreateGradientColorTable(plasmaDNRGBs, plasmaDStops, plasmaDRed, plasmaDGreen, plasmaDBlue, plasmaDNCont); // Change the range of z axis for the fields to be symmetric. Float_t Emax = hE2D[0]->GetMaximum(); Float_t Emin = hE2D[0]->GetMinimum(); if(Emax > TMath::Abs(Emin)) Emin = -Emax; else Emax = -Emin; hE2D[0]->GetZaxis()->SetRangeUser(Emin,Emax); Emax = hE2D[1]->GetMaximum(); Emin = hE2D[1]->GetMinimum(); if(Emax > TMath::Abs(Emin)) Emin = -Emax; else Emax = -Emin; hE2D[1]->GetZaxis()->SetRangeUser(Emin,Emax); // "Axis range" in Osiris units: Double_t ylow = hDen2D[1]->GetYaxis()->GetBinLowEdge(FirstyBin); Double_t yup = hDen2D[1]->GetYaxis()->GetBinUpEdge(LastyBin); Double_t xmin = hDen2D[1]->GetXaxis()->GetXmin(); Double_t xmax = hDen2D[1]->GetXaxis()->GetXmax(); TLine *lineYzero = new TLine(xmin,0.0,xmax,0.0); lineYzero->SetLineColor(kGray+2); lineYzero->SetLineStyle(2); TLine *lineYup = new TLine(xmin,yup,xmax,yup); lineYup->SetLineColor(kGray+1); lineYup->SetLineStyle(2); TLine *lineYdown = new TLine(xmin,ylow,xmax,ylow); lineYdown->SetLineColor(kGray+1); lineYdown->SetLineStyle(2); zStartPlasma -= shiftz; zStartNeutral -= shiftz; zEndNeutral -= shiftz; if(opt.Contains("units")) { zStartPlasma *= skindepth / PUnits::um; zStartNeutral *= skindepth / PUnits::um; zEndNeutral *= skindepth / PUnits::um; } // cout << "Start plasma = " << zStartPlasma << endl; TLine *lineStartPlasma = new TLine(zStartPlasma,ymin,zStartPlasma,ymax); lineStartPlasma->SetLineColor(kRed); lineStartPlasma->SetLineStyle(1); lineStartPlasma->SetLineWidth(2); // cout << "Start plasma = " << zStartNeutral << endl; TLine *lineStartNeutral = new TLine(zStartNeutral,ymin,zStartNeutral,ymax); lineStartNeutral->SetLineColor(kGray+1); lineStartNeutral->SetLineStyle(1); lineStartNeutral->SetLineWidth(2); // cout << "End plasma = " << zEndNeutral << endl; TLine *lineEndNeutral = new TLine(zEndNeutral,ymin,zEndNeutral,ymax); lineEndNeutral->SetLineColor(kGray+1); lineEndNeutral->SetLineStyle(2); lineEndNeutral->SetLineWidth(2); // Plotting // ----------------------------------------------- // Canvas setup TCanvas *C; if(opt.Contains("hres") && !opt.Contains("pdf")) // high resolution for plain grahics output. C = new TCanvas("C","2D Charge density, Accelerating and focusing fields",1500,2000); else C = new TCanvas("C","2D Charge density, Accelerating and focusing fields",750,1000); // Palettes setup TExec *exPlasma = new TExec("exPlasma","plasmaPalette->cd();"); TExec *exHot = new TExec("exHot","hotPalette->cd();"); TExec *exElec = new TExec("exElec","electronPalette->cd();"); TExec *exField = new TExec("exField","rbow2Palette->cd();"); // Text objects TPaveText *textTime = new TPaveText(0.7,0.83,0.85,0.90,"NDC"); PlasmaGlob::SetPaveTextStyle(textTime,32); char ctext[128]; if(opt.Contains("units") && n0) sprintf(ctext,"z = %5.1f #mum", Time * skindepth / PUnits::um); else sprintf(ctext,"t = %5.1f #omega_{p}^{-1}",Time); textTime->AddText(ctext); TPaveText *textDen = new TPaveText(0.13,0.83,0.38,0.90,"NDC"); PlasmaGlob::SetPaveTextStyle(textDen,12); textDen->SetTextColor(kOrange+10); if(opt.Contains("units") && n0) sprintf(ctext,"n_{0} = %5.2f x 10^{15} / cm^{3}", 1e-15 * n0 * PUnits::cm3); else if(pData->GetBeamDensity() && n0) sprintf(ctext,"n_{b}/n_{0} = %5.2f", pData->GetBeamDensity()/n0); textDen->AddText(ctext); TPaveText *textWav = new TPaveText(0.13,0.75,0.38,0.82,"NDC"); PlasmaGlob::SetPaveTextStyle(textWav,12); textWav->SetTextColor(kGray+2); sprintf(ctext,"#lambda_{p} = %5.3f mm", skindepth * TMath::TwoPi() / PUnits::um); textWav->AddText(ctext); // Actual Plotting! // ------------------------------------------------------------ // Output file TString fOutName = Form("./%s/Plots/ChargeFieldFocus2D/ChargeFieldFocus2D",pData->GetPath().c_str()); fOutName += Form("-%s_%i",pData->GetName(),time); // Setup Pad layout: Double_t lMargin = 0.10; Double_t rMargin = 0.12; Double_t bMargin = 0.10; Double_t tMargin = 0.02; Double_t vSpacing = 0.01; Double_t hStep = (1.-lMargin-rMargin); Double_t vStep = (1.-bMargin-tMargin)/3.; TPad *pad[3]; // top plots pad[0] = new TPad("padt", "padt",0.00, bMargin + 2.*vStep + vSpacing, lMargin+hStep+rMargin, 1.00); pad[0]->SetLeftMargin(1./(lMargin+hStep)*lMargin); pad[0]->SetRightMargin(1./(rMargin+hStep)*rMargin); pad[0]->SetBottomMargin(0.0); pad[0]->SetTopMargin(1./(tMargin+vStep)*tMargin); pad[0]->Draw(); // middle plots pad[1] = new TPad("padm", "padm",0.00, bMargin + vStep + vSpacing, lMargin + hStep + rMargin, bMargin + 2.*vStep ); pad[1]->SetLeftMargin(1./(lMargin+hStep)*lMargin); pad[1]->SetRightMargin((1./(rMargin+hStep)*rMargin)); pad[1]->SetBottomMargin(0.0); pad[1]->SetTopMargin(0.); pad[1]->Draw(); // bottom plots pad[2] = new TPad("padb", "padb",0.00, 0.,lMargin+hStep+rMargin,bMargin+vStep); pad[2]->SetLeftMargin(1./(lMargin+hStep)*lMargin); pad[2]->SetRightMargin((1./(rMargin+hStep)*rMargin)); pad[2]->SetBottomMargin(1./(bMargin+vStep)*bMargin); pad[2]->SetTopMargin(0.); pad[2]->Draw(); // Draw! pad[0]->cd(); // <---------------------------------------------- Top Plot --------- if(opt.Contains("logz")) { pad[0]->SetLogz(1); } else { pad[0]->SetLogz(0); } pad[0]->SetFrameLineWidth(3); TH2F *hFrame = (TH2F*) gROOT->FindObject("hFrame1"); if(hFrame) delete hFrame; hFrame = (TH2F*) hDen2D[0]->Clone("hFrame1"); hFrame->Reset(); hFrame->GetXaxis()->SetLabelOffset(999); hFrame->GetYaxis()->SetTitleSize(0.075); hFrame->GetYaxis()->SetTitleOffset(0.65); hFrame->GetYaxis()->SetLabelSize(0.065); hFrame->GetYaxis()->SetLabelOffset(0.02); hFrame->GetYaxis()->SetTickLength(0.02); hFrame->GetZaxis()->SetTitleSize(0.06); hFrame->GetZaxis()->SetTitleOffset(0.45); hFrame->GetZaxis()->SetLabelSize(0.06); hFrame->GetZaxis()->SetTickLength(0.02); // hFrame->GetZaxis()->SetNdivisions(505); hFrame->Draw("col"); if(Nspecies>=3) { if(hDen2D[2]) { exHot->Draw(); hDen2D[2]->Draw("colz same"); } } exPlasma->Draw(); hDen2D[0]->Draw("colz same"); if(hDen2D[1]) { exElec->Draw(); hDen2D[1]->Draw("colz same"); } if(opt.Contains("1dline")) { lineYzero->Draw(); lineYdown->Draw(); lineYup->Draw(); } if(zStartPlasma>xmin && zStartPlasma<xmax) lineStartPlasma->Draw(); if(zStartNeutral>xmin && zStartNeutral<xmax) lineStartNeutral->Draw(); if(zEndNeutral>xmin && zEndNeutral<xmax) lineEndNeutral->Draw(); pad[0]->Update(); TPaletteAxis *palette = NULL; for(Int_t i=0;i<Nspecies;i++) { if(!hDen2D[i]) continue; palette = (TPaletteAxis*) hDen2D[i]->GetListOfFunctions()->FindObject("palette"); if(!palette) continue; Float_t y1 = gPad->GetBottomMargin(); Float_t y2 = 1 - gPad->GetTopMargin(); Float_t x1 = gPad->GetLeftMargin(); Float_t x2 = 1 - gPad->GetRightMargin(); palette->SetY2NDC( (i+1)*(y2-y1)/Nspecies + y1); palette->SetY1NDC( i*(y2-y1)/Nspecies + y1); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); palette->SetTitleOffset(0.65); palette->SetTitleSize(0.07); palette->SetLabelSize(0.065); palette->SetBorderSize(2); palette->SetLineColor(1); } // 1D charge density plots: Float_t yaxismin = pad[0]->GetUymin(); Float_t yaxismax = pad[0]->GetUymin() + 0.33*(pad[0]->GetUymax() - pad[0]->GetUymin()) - 0.00; // Float_t denmin = (0.1001) * density; Float_t denmin = gMin; Float_t denmax = gMax; if(opt.Contains("logz")) { denmin = TMath::Log10(denmin); denmax = TMath::Log10(denmax); } for(Int_t i=0;i<Nspecies;i++) { if(!hDen1D[i]) continue; Float_t slope = (yaxismax - yaxismin)/(denmax - denmin); for(Int_t j=0;j<hDen1D[i]->GetNbinsX();j++) { Float_t content = hDen1D[i]->GetBinContent(j+1); if(opt.Contains("logz")) content = TMath::Log10(content); if(content<denmin) hDen1D[i]->SetBinContent(j+1,yaxismin); else hDen1D[i]->SetBinContent(j+1,(content - denmin) * slope + yaxismin); } hDen1D[i]->SetLineWidth(2); if(i==1) { hDen1D[i]->SetLineColor(PlasmaGlob::elecLine); hDen1D[i]->Draw("same C"); } else if (i==2) { hDen1D[i]->SetLineColor(kOrange+8); hDen1D[i]->Draw("same C"); } } textTime->Draw(); // textDen->Draw(); // textWav->Draw(); pad[0]->RedrawAxis(); pad[1]->cd(); // <--------------------------------------------- Mid Plot pad[1]->SetFrameLineWidth(3); TH2F *hFrame2 = (TH2F*) gROOT->FindObject("hFrame2"); if(hFrame2) delete hFrame2; hFrame2 = (TH2F*) hE2D[0]->Clone("hFrame2"); hFrame2->Reset(); Float_t yFactor = pad[0]->GetAbsHNDC()/pad[1]->GetAbsHNDC(); hFrame2->GetXaxis()->SetLabelOffset(999); hFrame2->GetYaxis()->SetTitleSize(0.075*yFactor); hFrame2->GetYaxis()->SetTitleOffset(0.65/yFactor); hFrame2->GetYaxis()->SetLabelSize(0.0650*yFactor); hFrame2->GetYaxis()->SetLabelOffset(0.02/yFactor); hFrame2->GetYaxis()->SetTickLength(0.02/yFactor); hE2D[0]->GetZaxis()->SetTitleSize(0.06*yFactor); hE2D[0]->GetZaxis()->SetTitleOffset(0.45/yFactor); hE2D[0]->GetZaxis()->SetLabelSize(0.06*yFactor); hE2D[0]->GetZaxis()->SetTickLength(0.02/yFactor); // hFrame2->GetZaxis()->SetNdivisions(505); hFrame2->Draw("col"); exField->Draw(); hE2D[0]->Draw("colz same"); if(opt.Contains("1dline")) { lineYzero->Draw(); lineYdown->Draw(); lineYup->Draw(); } if(zStartPlasma>xmin && zStartPlasma<xmax) lineStartPlasma->Draw(); if(zStartNeutral>xmin && zStartNeutral<xmax) lineStartNeutral->Draw(); if(zEndNeutral>xmin && zEndNeutral<xmax) lineEndNeutral->Draw(); pad[1]->Update(); palette = (TPaletteAxis*) hE2D[0]->GetListOfFunctions()->FindObject("palette"); Float_t y1 = pad[1]->GetBottomMargin(); Float_t y2 = 1 - pad[1]->GetTopMargin(); Float_t x2 = 1 - pad[1]->GetRightMargin(); palette->SetY2NDC(y2 - 0.01); palette->SetY1NDC(y1 + 0.01); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); palette->SetTitleSize(0.07*yFactor); palette->SetTitleOffset(0.65/yFactor); palette->SetLabelSize(0.065*yFactor); palette->SetBorderSize(2); palette->SetLineColor(1); // 1D electric field plots: if(hE1D[0]) { // yaxismin = pad[1]->GetUymin() + 0.16666*(pad[1]->GetUymax() - pad[1]->GetUymin()); // yaxismax = pad[1]->GetUymax() - 0.16666*(pad[1]->GetUymax() - pad[1]->GetUymin()); Float_t yaxismin = pad[1]->GetUymin(); Float_t yaxismax = pad[1]->GetUymax(); Float_t emin = hE1D[0]->GetMinimum(); Float_t emax = hE1D[0]->GetMaximum(); //Float_t slope = (yaxismax - yaxismin)/(emax - emin); Float_t slope = yaxismin/emin; for(Int_t j=0;j<hE1D[0]->GetNbinsX();j++) { Float_t content = hE1D[0]->GetBinContent(j+1); hE1D[0]->SetBinContent(j+1,(content - emin) * slope + yaxismin); } hE1D[0]->SetLineWidth(2); hE1D[0]->SetLineColor(PlasmaGlob::elecLine); // hE1D[0]->SetLineColor(kGray+2); hE1D[0]->Draw("same C"); } // Plot ionization probability: if(hIonProb1D) { Float_t ionmin = 0; Float_t ionmax = hIonProb1D->GetMaximum(); Float_t slope = yaxismax/ionmax; for(Int_t j=0;j<hIonProb1D->GetNbinsX();j++) { Float_t content = hIonProb1D->GetBinContent(j+1); hIonProb1D->SetBinContent(j+1,content * slope); } hIonProb1D->SetLineWidth(2); hIonProb1D->SetLineColor(kGray+2); hIonProb1D->Draw("same C"); } pad[1]->RedrawAxis(); pad[2]->cd(); // <--------------------------------------------- Bottom Plot pad[2]->SetFrameLineWidth(3); TH2F *hFrame3 = (TH2F*) gROOT->FindObject("hFrame3"); if(hFrame3) delete hFrame3; hFrame3 = (TH2F*) hE2D[1]->Clone("hFrame3"); hFrame3->Reset(); yFactor = pad[0]->GetAbsHNDC()/pad[2]->GetAbsHNDC(); hFrame3->GetXaxis()->SetTitleSize(0.075); hFrame3->GetXaxis()->SetLabelSize(0.070); hFrame3->GetYaxis()->SetTitleSize(0.075*yFactor); hFrame3->GetYaxis()->SetTitleOffset(0.65/yFactor); hFrame3->GetYaxis()->SetLabelSize(0.0650*yFactor); hFrame3->GetYaxis()->SetLabelOffset(0.02/yFactor); hFrame3->GetYaxis()->SetTickLength(0.02/yFactor); hE2D[1]->GetZaxis()->SetTitleSize(0.06*yFactor); hE2D[1]->GetZaxis()->SetTitleOffset(0.45/yFactor); hE2D[1]->GetZaxis()->SetLabelSize(0.06*yFactor); hE2D[1]->GetZaxis()->SetTickLength(0.02/yFactor); // hE2D[1]->GetZaxis()->SetNdivisions(505); hFrame3->Draw("col"); exField->Draw(); hE2D[1]->Draw("colz same"); if(opt.Contains("1dline")) { lineYzero->Draw(); lineYup->Draw(); } if(zStartPlasma>xmin && zStartPlasma<xmax) lineStartPlasma->Draw(); if(zStartNeutral>xmin && zStartNeutral<xmax) lineStartNeutral->Draw(); if(zEndNeutral>xmin && zEndNeutral<xmax) lineEndNeutral->Draw(); pad[2]->Update(); palette = (TPaletteAxis*)hE2D[1]->GetListOfFunctions()->FindObject("palette"); y1 = pad[2]->GetBottomMargin(); y2 = 1 - pad[2]->GetTopMargin(); x2 = 1 - pad[2]->GetRightMargin(); palette->SetY2NDC(y2 - 0.01); palette->SetY1NDC(y1 + 0.01); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); palette->SetTitleSize(0.07*yFactor); palette->SetTitleOffset(0.65/yFactor); palette->SetLabelSize(0.065*yFactor); palette->SetBorderSize(2); palette->SetLineColor(1); // 1D electric field plots: if(hE1D[1]) { // yaxismin = pad[2]->GetUymin() + 0.16666*(pad[2]->GetUymax() - pad[2]->GetUymin()); // yaxismax = pad[2]->GetUymax() - 0.16666*(pad[2]->GetUymax() - pad[2]->GetUymin()); Float_t yaxismin = pad[2]->GetUymin(); Float_t yaxismax = pad[2]->GetUymax(); Float_t emin = hE1D[1]->GetMinimum(); Float_t emax = hE1D[1]->GetMaximum(); Float_t slope = yaxismin/emin; for(Int_t j=0;j<hE1D[1]->GetNbinsX();j++) { Float_t content = hE1D[1]->GetBinContent(j+1); hE1D[1]->SetBinContent(j+1,(content - emin) * slope + yaxismin); } hE1D[1]->SetLineWidth(2); //hE1D[1]->SetLineStyle(2); // hE1D[1]->SetLineColor(kGray+2); hE1D[1]->SetLineColor(PlasmaGlob::elecLine); hE1D[1]->Draw("same C"); } // Plot ionization probability: if(hIonProb1D) { Float_t ionmin = 0; Float_t ionmax = hIonProb1D->GetMaximum(); Float_t slope = yaxismax/ionmax; for(Int_t j=0;j<hIonProb1D->GetNbinsX();j++) { Float_t content = hIonProb1D->GetBinContent(j+1); hIonProb1D->SetBinContent(j+1,content * slope); } hIonProb1D->SetLineWidth(2); hIonProb1D->SetLineColor(kGray+2); hIonProb1D->Draw("same C"); } pad[2]->RedrawAxis(); C->cd(); // Print to a file PlasmaGlob::imgconv(C,fOutName,opt); // --------------------------------------------------------- }
void PlotPhaseSpaceAutoTag2D( const TString &sim, Int_t time, Int_t index = 0,TString dcom = "p1:x1", const TString &options="") { #ifdef __CINT__ gSystem->Load("libplasma.so"); #endif PlasmaGlob::Initialize(); TString opt = options; // Palettes! gROOT->Macro("PlasmaPalettes.C"); if(opt.Contains("gridx")) { gStyle->SetPadGridX(1); } else if(opt.Contains("gridy")) { gStyle->SetPadGridY(1); } gStyle->SetTitleAlign(22); gStyle->SetPadRightMargin(0.17); // Margin for palettes in 2D histos gStyle->SetLabelFont(42,"xyz"); gStyle->SetTitleFont(42,"xyz"); // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; //opt += "comovcenter"; // Centering time and z position: Double_t shiftz = 0.0; if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) { // Centers on the head of the beam. Time += zStartBeam; shiftz += zStartBeam; } else { shiftz += zStartPlasma; } } if(opt.Contains("comov")) { Double_t v = pData->GetBeamVelocity(); if(v==0) v = 1.0; // If equals to 0 (default), then set to c. shiftz += v * pData->GetRealTime(); } TString sshiftz = Form("(x1-%f)",shiftz); //cout << Form("string = %s",sshiftz.Data()) << endl; TString sx1 = "x1"; dcom.ReplaceAll(sx1,sshiftz); //cout << Form("%s replaced by %s result = %s",sx1.Data(),sshiftz.Data(),dcom.Data()) << endl; // ---- // Weighting by the macroparticle charge: char cutString[128]; sprintf(cutString,"TMath::Abs(q)"); TCut Cut = cutString; // Bining, intervals, labels, etc. Int_t xNbin = 200; Int_t yNbin = 200; // Pointer to data TTree TTree *tree = pData->GetTreeRaw(pData->GetRawFileName(index)->c_str(),opt); // Get phasespace histos TH2F *hPha2D = NULL; char hName[24]; sprintf(hName,"hPha2D"); char dCom[128]; sprintf(dCom,"%s>>%s(%i,%i)",dcom.Data(),hName,xNbin,yNbin); tree->Draw(dCom,Cut,"goff"); hPha2D = (TH2F*) gROOT->FindObject(hName); hPha2D->GetXaxis()->CenterTitle(); hPha2D->GetYaxis()->CenterTitle(); hPha2D->GetZaxis()->CenterTitle(); // hPha2D->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]"); // hPha2D->GetYaxis()->SetTitle("y [c/#omega_{p}]"); // hPha2D->GetZaxis()->SetTitle("dn/d#zetady"); Float_t xMean = hPha2D->GetMean(1); Float_t xRms = hPha2D->GetRMS(1); Float_t yMean = hPha2D->GetMean(2); Float_t yRms = hPha2D->GetRMS(2); cout << Form(" xMean = %f xRms = %f yMean = %f yRms = %f",xMean,xRms,yMean,yRms) << endl; // Read array of tags: TString filename = Form("./%s/Plots/RakeDump/RakeDump-%s_%i.raw",sim.Data(),sim.Data(),100); ifstream fDataIn(filename.Data(),ios::in); Int_t Npart; fDataIn >> Npart; vector<Int_t*> tags; Int_t it = 0; while (!fDataIn.eof()) { tags.push_back(new Int_t[2]); fDataIn >> tags[it][0] >> tags[it][1]; // cout << Form("%10i %10i",tags[it][0],tags[it][1]) << endl; it++; } // Redo the histogram with only tagged particles: TH2F *hPha2DTag = (TH2F*) hPha2D->Clone("hPha2DTag"); hPha2DTag->Reset(); // Loop for event selection: const Int_t Nvar = 8; Float_t var[Nvar]; char varname[Nvar][4] = {{"ene"},{"p1"},{"p2"},{"p3"},{"q"},{"x1"},{"x2"},{"x3"}}; for(Int_t i=0;i<Nvar;i++) { tree->SetBranchAddress(varname[i],&var[i]); } Int_t tag[2]; tree->SetBranchAddress("tag",&tag); Int_t nentries = (Int_t)tree->GetEntries(); for(Int_t i=0;i<nentries;i++) { tree->GetEntry(i); var[5] = var[5] - shiftz; Bool_t found = kFALSE; for(Int_t it = 0; it<(int)tags.size(); it++) { if((tag[0]==tags[it][0]) && (tag[1]==tags[it][1])) { hPha2DTag->Fill(var[5],var[6]); //tags.erase(tags.begin()+it); continue; } } } // Plotting // ----------------------------------------------- // Canvas setup TCanvas *C; if(opt.Contains("hres") && !opt.Contains("pdf")) // high resolution for plain graphics output. C = new TCanvas("C","Phasespace",1200,750); else C = new TCanvas("C","Phasespace",960,600); // Text objects TPaveText *textTime = new TPaveText(0.55,0.85,0.82,0.9,"NDC"); PlasmaGlob::SetPaveTextStyle(textTime,32); char ctext[128]; if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"z = %5.1f mm", Time * skindepth / PUnits::mm); else sprintf(ctext,"t = %5.1f #omega_{p}^{-1}",Time); textTime->AddText(ctext); // Actual Plotting! // ------------------------------------------------------------ // Output file TString fOutName = Form("./%s/Plots/PhaseSpaceAutoTag2D/PhaseSpaceAutoTag2D",sim.Data()); fOutName += Form("-%s_%i",sim.Data(),time); C->cd(); gPad->SetFrameLineWidth(2); if(opt.Contains("logz")) { gPad->SetLogz(1); } else { gPad->SetLogz(0); } // Set palette: PPalette * pPalette = (PPalette*) gROOT->FindObject("electron"); pPalette->cd(); hPha2D->Draw("colz"); hPha2DTag->SetMarkerStyle(6); hPha2DTag->SetMarkerColor(kGray+2); hPha2DTag->Draw("same"); textTime->Draw(); gPad->RedrawAxis(); C->cd(); // Print to a file PlasmaGlob::imgconv(C,fOutName,opt); // --------------------------------------------------------- }
void PlotDensity1D( const TString &sim, Int_t time, Int_t Nbins=1, const TString &options="") { #ifdef __CINT__ gSystem->Load("libplasma.so"); #endif PlasmaGlob::Initialize(); // Init Units table PUnits::UnitsTable::Get(); // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; TString opt = options; gStyle->SetPadRightMargin(0.20); // Margin right axis if(opt.Contains("grid")) { gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); } Bool_t CYL = kFALSE; if(sim.Contains("cyl")) { CYL = kTRUE; opt += "cyl"; } Bool_t ThreeD = kFALSE; if(sim.Contains("3D")) ThreeD = kTRUE; Bool_t INT = kTRUE; // Integrate instead of averaging. // Some plasma constants Float_t n0 = pData->GetPlasmaDensity(); Float_t kp = pData->GetPlasmaK(); Float_t skindepth = (1/kp); Float_t E0 = pData->GetPlasmaE0(); // Some beam properties: Double_t Ebeam = pData->GetBeamEnergy(); Double_t gamma = pData->GetBeamGamma(); Double_t vbeam = pData->GetBeamVelocity(); Double_t kbeta = PFunc::BeamBetatronWavenumber(gamma,n0); Double_t rms0 = pData->GetBeamRmsY() * kp; if(CYL) rms0 = pData->GetBeamRmsR() * kp; cout << Form(" - Bunch gamma = %8.4f", gamma ) << endl; cout << Form(" - Bunch velocity = %8.4f c", vbeam ) << endl; cout << Form(" - Bunch betatron k = %8.4f mm-1", kbeta * PUnits::mm) << endl; cout << Form(" - Bunch RMS_0 = %8.4f um", rms0 * skindepth / PUnits::um) << endl; cout << endl; // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } // Get charge density histos Int_t Nspecies = pData->NSpecies(); TH1F **hDen1D = new TH1F*[Nspecies]; TH2F *hDen2D = NULL; for(Int_t i=0;i<Nspecies;i++) { hDen1D[i] = NULL; if(!pData->GetChargeFileName(i)) continue; if(i==0) { if(ThreeD) hDen2D = pData->GetCharge2DSliceZY(i,-1,Nbins); else hDen2D = pData->GetCharge(i,opt); char hName[24]; sprintf(hName,"hDen_%i",i); hDen2D->SetName(hName); hDen2D->GetXaxis()->CenterTitle(); hDen2D->GetYaxis()->CenterTitle(); hDen2D->GetZaxis()->CenterTitle(); hDen2D->GetXaxis()->SetTitle("z [c/#omega_{p}]"); hDen2D->GetYaxis()->SetTitle("y [c/#omega_{p}]"); if(i==0) hDen2D->GetZaxis()->SetTitle("#LTn_{e}#GT [n_{0}]"); else hDen2D->GetZaxis()->SetTitle("#LTn_{b}#GT [n_{0}]"); } if(Nbins==0) { Nbins = TMath::Nint(rms0 / hDen2D->GetYaxis()->GetBinWidth(1)) ; // cout << Form(" Rms0 = %6.2f Dx = %6.2f Nbins = %4i .", // rms0, hDen2D[i]->GetYaxis()->GetBinWidth(1), Nbins) << endl; } // 1D histograms TString opth1 = opt; opth1 += "avg"; if(CYL) opth1 += "cyl"; if(ThreeD) { hDen1D[i] = pData->GetH1SliceZ3D(pData->GetChargeFileName(i)->c_str(),"charge",-1,Nbins,-1,Nbins); } else if(CYL) { // Cylindrical: The first bin with r>0 is actually the number 1 (not the 0). hDen1D[i] = pData->GetH1SliceZ(pData->GetChargeFileName(i)->c_str(),"charge",1,Nbins,opth1.Data()); } else { // 2D cartesian hDen1D[i] = pData->GetH1SliceZ(pData->GetChargeFileName(i)->c_str(),"charge",-1,Nbins,opth1.Data()); } char hName[24]; sprintf(hName,"hDen_%i",i); hDen1D[i]->SetName(hName); hDen1D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]"); hDen1D[i]->GetYaxis()->SetTitle("#LTn_{e}#GT [n_{0}]"); } // Get electric fields const Int_t Nfields = 2; TH1F **hE1D = new TH1F*[Nfields]; for(Int_t i=0;i<Nfields;i++) { hE1D[i] = NULL; if(!pData->GetEfieldFileName(i)) continue; // 1D histograms TString opth1 = opt; opth1 += "avg"; if(CYL) opth1 += "cyl"; char nam[3]; sprintf(nam,"e%i",i+1); if(ThreeD) { if(i==0) hE1D[i] = pData->GetH1SliceZ3D(pData->GetEfieldFileName(i)->c_str(),nam,-1,Nbins,-1,Nbins); else hE1D[i] = pData->GetH1SliceZ3D(pData->GetEfieldFileName(i)->c_str(),nam,-Nbins,Nbins,-Nbins,Nbins); } else if(CYL) { // Cylindrical: The firt bin with r>0 is actually the number 1 (not the 0). if(i==0) hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,1,Nbins,opth1.Data()); else hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,1,Nbins,opth1.Data()); } else { // 2D cartesian if(i==0) hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,-1,Nbins,opth1.Data()); else hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,-Nbins,Nbins,opth1.Data()); } char hName[24]; sprintf(hName,"hE_%i",i); hE1D[i]->SetName(hName); hE1D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]"); hE1D[i]->GetYaxis()->SetTitle("E [E_{e}]"); } // Y range: Int_t NbinsY = (Int_t) hDen2D->GetNbinsY(); Int_t midyBin = NbinsY/2; if(!CYL && (Nbins > midyBin) ) Nbins = midyBin; if(CYL && (Nbins >= NbinsY ) ) Nbins = NbinsY-1; Int_t FirstyBin = midyBin + 1 - Nbins; Int_t LastyBin = midyBin + Nbins; if(CYL) { FirstyBin = 1; LastyBin = Nbins; } if(LastyBin>=NbinsY) LastyBin = NbinsY - 1; Float_t ymin = hDen2D->GetYaxis()->GetBinLowEdge(FirstyBin); Float_t ymax = hDen2D->GetYaxis()->GetBinLowEdge(LastyBin+1); cout << Form(" Nbins = %i. Firstbin = %i Lastbin = %i -> ymin = %7.2f , ymax = %7.2f",Nbins,FirstyBin,LastyBin,ymin,ymax) << endl; // ---- // Tunning the Histograms // --------------------- // Chaning to user units: // cout << Form(" n0 = %10e ", n0 * PUnits::cm3) << endl; if(opt.Contains("units") && n0) { Int_t NbinsX = hDen2D->GetNbinsX(); Float_t xMin = skindepth * hDen2D->GetXaxis()->GetXmin() / PUnits::mm; Float_t xMax = skindepth * hDen2D->GetXaxis()->GetXmax() / PUnits::mm; Int_t NbinsY = hDen2D->GetNbinsY(); Float_t yMin = skindepth * hDen2D->GetYaxis()->GetXmin() / PUnits::mm; Float_t yMax = skindepth * hDen2D->GetYaxis()->GetXmax() / PUnits::mm; hDen2D->SetBins(NbinsX,xMin,xMax,NbinsY,yMin,yMax); for(Int_t j=0;j<hDen2D->GetNbinsX();j++) { for(Int_t k=0;k<hDen2D->GetNbinsY();k++) { hDen2D->SetBinContent(j,k, hDen2D->GetBinContent(j,k) * n0 / (1e15/PUnits::cm3) ); } } hDen2D->GetYaxis()->SetTitle("y [mm]"); if(opt.Contains("comov")) hDen2D->GetXaxis()->SetTitle("#zeta [mm]"); else hDen2D->GetXaxis()->SetTitle("z [mm]"); hDen2D->GetZaxis()->SetTitle("#LTn_{b}#GT [10^{15}/cm^{3}]"); for(Int_t i=0;i<Nspecies;i++) { Int_t NbinsX = hDen1D[i]->GetNbinsX(); Float_t xMin = skindepth * hDen1D[i]->GetXaxis()->GetXmin() / PUnits::mm; Float_t xMax = skindepth * hDen1D[i]->GetXaxis()->GetXmax() / PUnits::mm; hDen1D[i]->SetBins(NbinsX,xMin,xMax); for(Int_t j=0;j<hDen1D[i]->GetNbinsX();j++) { Float_t bincontent = (hDen1D[i]->GetBinContent(j) * n0 / (1e15/PUnits::cm3)); hDen1D[i]->SetBinContent(j,bincontent); } hDen1D[i]->GetYaxis()->SetTitle("#LTn_{e}#GT [10^{15}/cm^{3}]"); if(opt.Contains("comov")) hDen1D[i]->GetXaxis()->SetTitle("#zeta [mm]"); else hDen1D[i]->GetXaxis()->SetTitle("z [mm]"); } for(Int_t i=0;i<Nfields;i++) { Int_t NbinsX = hE1D[i]->GetNbinsX(); Float_t xMin = skindepth * hE1D[i]->GetXaxis()->GetXmin() / PUnits::mm; Float_t xMax = skindepth * hE1D[i]->GetXaxis()->GetXmax() / PUnits::mm; hE1D[i]->SetBins(NbinsX,xMin,xMax); for(Int_t j=0;j<hE1D[i]->GetNbinsX();j++) { hE1D[i]->SetBinContent(j, hE1D[i]->GetBinContent(j) * ( E0 / (PUnits::GV/PUnits::m) ) ); } hE1D[i]->GetYaxis()->SetTitle("E [GV/m]"); if(opt.Contains("comov")) hE1D[i]->GetXaxis()->SetTitle("#zeta [mm]"); else hE1D[i]->GetXaxis()->SetTitle("z [mm]"); } } // Set the range of the histogram for maximum constrast Float_t density = 1; if(opt.Contains("units") && n0) density = 1e-15 * 1e-6 * n0; Float_t Max = 1.1*hDen1D[0]->GetMaximum(); Float_t Min = 0; // Float_t Base = density; // Float_t Min = 2.* Base - Max; // if(Max >= 2. * Base) { // Max = 2. * Base; // Min = 2. * Base - Max; // } else if(Max<1.0 * Base) { // Max = 1.1 * Base; // Min = 0.; // } hDen1D[0]->GetYaxis()->SetRangeUser(0.,Max); // Plotting // ----------------------------------------------- // Canvas setup TCanvas *C = new TCanvas("C","Charge density and Electric field on axis",850,500); TPaveText *textTime = new TPaveText(0.63,0.87,0.78,0.92,"NDC"); PlasmaGlob::SetPaveTextStyle(textTime); textTime->SetTextColor(kGray+2); char ctext[128]; if(opt.Contains("units") && n0) sprintf(ctext,"Z = %5.1f mm", 1e3 * skindepth * Time); else sprintf(ctext,"T = %5.1f 1/#omega_{p}",Time); textTime->AddText(ctext); TPaveText *textRange = new TPaveText(0.13,0.87,0.38,0.92,"NDC"); PlasmaGlob::SetPaveTextStyle(textRange,12); textRange->SetTextColor(kGray+2); if(opt.Contains("units") && n0) sprintf(ctext,"%5.3f < y < %5.3f mm",ymin,ymax); else sprintf(ctext,"%5.3f < y < %5.3f c/#omega_{p}",ymin,ymax); textRange->AddText(ctext); // Actual Plotting! // ------------------------------------------------------------ // Output file TString fOutName = Form("./%s/Plots/Density1D/Density1D",sim.Data()); fOutName += Form("-%s_%i",sim.Data(),time); // Colors Int_t plasmaC = kGray+1; Int_t beamC = kAzure-5; Int_t fieldC = kOrange+10; Int_t fieldCb = kGray+1; C->cd(0); gPad->SetFrameLineWidth(2); hDen1D[0]->SetLineColor(plasmaC); hDen1D[0]->SetLineWidth(1); hDen1D[0]->Draw("C"); hDen1D[0]->GetYaxis()->CenterTitle(); hDen1D[0]->GetXaxis()->CenterTitle(); C->Update(); TLine *line0 = new TLine(hDen1D[0]->GetXaxis()->GetXmin(), (gPad->GetUymin()+gPad->GetUymax())/2., hDen1D[0]->GetXaxis()->GetXmax(), (gPad->GetUymin()+gPad->GetUymax())/2.); line0->SetLineColor(kGray+1); line0->SetLineStyle(2); line0->Draw(); Float_t rightmax = 2.5 * hDen1D[1]->GetMaximum(); Float_t slope = (gPad->GetUymax() - gPad->GetUymin())/rightmax; for(Int_t i=0;i<hDen1D[1]->GetNbinsX();i++) { hDen1D[1]->SetBinContent(i+1,hDen1D[1]->GetBinContent(i+1)*slope + Min); } hDen1D[1]->SetLineWidth(2); hDen1D[1]->SetLineColor(beamC); hDen1D[1]->Draw("same C"); // hTest->Draw("same"); //draw an axis on the right side TGaxis *axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,505,"+L"); axis->SetLineWidth(1); axis->SetLineColor(beamC); axis->SetLabelColor(beamC); if(opt.Contains("units") && n0) axis->SetTitle("#LTn_{b}#GT [10^{15}/cm^{3}]"); else axis->SetTitle("#LTn_{b}#GT [n_{0}]"); axis->CenterTitle(); axis->SetTitleColor(beamC); axis->SetTitleOffset(1.2); axis->Draw(); // Longitudinal Electric field Float_t factor = 1.5; Float_t rightmin = factor * hE1D[0]->GetMinimum(); rightmax = factor * hE1D[0]->GetMaximum(); if(hE1D[1]) { if(hE1D[1]->GetMaximum() > hE1D[0]->GetMaximum()) rightmax = factor * hE1D[1]->GetMaximum(); } if(rightmax > TMath::Abs(rightmin)) rightmin = -rightmax; else rightmax = - rightmin; slope = (gPad->GetUymax() - gPad->GetUymin())/(rightmax-rightmin); for(Int_t i=0;i<hE1D[0]->GetNbinsX();i++) { hE1D[0]->SetBinContent(i+1,(hE1D[0]->GetBinContent(i+1)-rightmin)*slope + Min); } hE1D[0]->SetLineStyle(1); hE1D[0]->SetLineWidth(2); hE1D[0]->SetLineColor(fieldC); hE1D[0]->Draw("same C"); // Transverse field for(Int_t i=0;i<hE1D[1]->GetNbinsX();i++) { hE1D[1]->SetBinContent(i+1,(hE1D[1]->GetBinContent(i+1)-rightmin)*slope + Min); } hE1D[1]->SetLineStyle(2); hE1D[1]->SetLineWidth(1); hE1D[1]->SetLineColor(fieldC); hE1D[1]->Draw("same C"); //draw an axis on the right side Float_t rightmargin = 0.08; Float_t ux = gPad->PixeltoX(gPad->UtoPixel(1-rightmargin)); TGaxis *axisE = new TGaxis(ux,gPad->GetUymin(),ux, gPad->GetUymax(),rightmin,rightmax,505,"+L"); axisE->SetLineWidth(1); axisE->SetLineColor(fieldC); axisE->SetLabelColor(fieldC); axisE->SetTitleColor(fieldC); if(opt.Contains("units") && n0) axisE->SetTitle("E [GV/m]"); else axisE->SetTitle("E [E_{0}]"); axisE->CenterTitle(); axisE->SetTitleOffset(0.8); axisE->Draw(); textTime->Draw(); textRange->Draw(); C->cd(); // Print to a file PlasmaGlob::imgconv(C,fOutName,opt); // --------------------------------------------------------- }
void PlotBunch( const TString &sim, Int_t time, Int_t index = 0, const TString &options="") { #ifdef __CINT__ gSystem->Load("libplasma.so"); #endif PlasmaGlob::Initialize(); TString opt = options; // Palettes! gROOT->Macro("PlasmaPalettes.C"); if(opt.Contains("grid")) { gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); } gStyle->SetLabelFont(42,"xyz"); gStyle->SetTextFont(62); // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; Int_t Nspecies = pData->NSpecies(); if(index>Nspecies-1) { return; } if(!pData->GetRawFileName(index)) { return; } Bool_t CYL = kFALSE; if(sim.Contains("cyl")) CYL = kTRUE; Bool_t ThreeD = kFALSE; if(sim.Contains("3D")) ThreeD = kTRUE; // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; opt += "comovcenter"; // Centering time and z position: Double_t shiftz = pData->Shift(opt); TString sshiftz = Form("(x1-%f)",shiftz); if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } // Bining, intervals, labels, etc. Int_t xNbin = 200; Int_t pNbin = 200; // Spatial resolution Float_t dx1 = pData->GetDX(0); Float_t dx2 = pData->GetDX(1); Float_t dx3 = pData->GetDX(2); // Spatial coordinates intervals: Float_t x1Min = -7.8; Float_t x1Max = -7.0; Float_t x2Min = -0.5; Float_t x2Max = 0.5; Float_t x3Min = -0.5; Float_t x3Max = 0.5; // Momentum coordinates intervals: Float_t p1Min = 4050.01; Float_t p1Max = 6199.99; Float_t p2Min = -15.0; Float_t p2Max = 15.0; Float_t p3Min = -15.0; Float_t p3Max = 15.0; char hName[8]; sprintf(hName,"hP1X1"); TH2F *hP1X1 = (TH2F*) gROOT->FindObject(hName); if(hP1X1) delete hP1X1; hP1X1 = new TH2F(hName,"",xNbin,x1Min,x1Max,pNbin,p1Min,p1Max); sprintf(hName,"hP2X2"); TH2F *hP2X2 = (TH2F*) gROOT->FindObject(hName); if(hP2X2) delete hP2X2; hP2X2 = new TH2F(hName,"",xNbin,x2Min,x2Max,pNbin,p2Min,p2Max); // Sliced quantities: // -------------------------------------------------------------------------- UInt_t SNbin = 40; Float_t x1BinMin = -7.54; Float_t x1BinMax = -7.14; if(sim.Contains("DDR.") || sim.Contains(".DR.")) { SNbin = 10; x1BinMin = -4.7; x1BinMax = -3.8; } else if(sim.Contains("flash")) { SNbin = 20; x1BinMin = -4.15; x1BinMax = -4.02; } else if(sim.Contains("facet_v23kA.G.RI.e")) { SNbin = 30; x1BinMin = -7.60; x1BinMax = -7.35; } else if(sim.Contains("facet_v23kA.G.RI")) { SNbin = 40; x1BinMin = -7.54; x1BinMax = -7.14; } else if(sim.Contains("facet_v23kA.G")) { SNbin = 40; x1BinMin = -7.55; x1BinMax = -7.15; } // Set the binning Float_t *sBinLim = new Float_t[SNbin+1]; sBinLim[0] = x1BinMin; sBinLim[SNbin] = x1BinMax; Float_t slbinSize = (sBinLim[SNbin] - sBinLim[0])/SNbin; for(UInt_t i=1;i<SNbin;i++) { sBinLim[i] = sBinLim[i-1] + slbinSize; } TH1F **hP1sl = new TH1F*[SNbin]; TH2F **hP2X2sl = new TH2F*[SNbin]; for(UInt_t k=0;k<SNbin;k++) { sprintf(hName,"hP2X2sl_%2i",k); hP2X2sl[k] = (TH2F*) gROOT->FindObject(hName); if(hP2X2sl[k]) delete hP2X2sl[k]; hP2X2sl[k] = new TH2F(hName,"",xNbin,x2Min,x2Max,pNbin,p2Min,p2Max); hP2X2sl[k]->GetXaxis()->SetTitle("k_{p} y"); hP2X2sl[k]->GetYaxis()->SetTitle("p_{y}/mc"); sprintf(hName,"hP1sl_%2i",k); hP1sl[k] = (TH1F*) gROOT->FindObject(hName); if(hP1sl[k]) delete hP1sl[k]; hP1sl[k] = new TH1F(hName,"",pNbin,p1Min,p1Max); } //Float_t **var = NULL; const UInt_t Nvar = 8; Float_t *var[Nvar]; UInt_t Np = pData->GetRawArray(pData->GetRawFileName(index)->c_str(),var); // Filling histos cout << endl; cout << " 2. Filling histograms from file : " << pData->GetRawFileName(index)->c_str() << endl; for(UInt_t i=0;i<Np;i++) { var[5][i] = var[5][i] - shiftz; if(var[5][i]<x1Min || var[5][i]>x1Max ) continue; if(var[6][i]<x2Min || var[6][i]>x2Max ) continue; if(var[7][i]<x3Min || var[7][i]>x3Max ) continue; if(var[1][i]<p1Min || var[1][i]>p1Max ) continue; if(var[2][i]<p2Min || var[2][i]>p2Max ) continue; if(var[3][i]<p3Min || var[3][i]>p3Max ) continue; hP1X1->Fill(var[5][i],var[1][i],TMath::Abs(var[4][i])); } cout << "\n7. Plotting... " << endl; // Canvas setup // Create the canvas and the pads before the Frame loop // Resolution: Int_t sizex = 800; Int_t sizey = 600; if(opt.Contains("hres")) { Int_t sizex = 1600; Int_t sizey = 1200; } TCanvas *C = new TCanvas("C","Bunch properties",sizex,sizey); C->cd(); // Set palette: PPalette * pPalette = (PPalette*) gROOT->FindObject("electron"); pPalette->cd(); hP1X1->Draw("colz"); // Print to a file // Output file TString fOutName = Form("./%s/Plots/Bunch/Bunch",sim.Data()); fOutName += Form("-%s_%i",sim.Data(),time); PlasmaGlob::imgconv(C,fOutName,opt); // --------------------------------------------------------- }
void PlotBlowoutScalings(Int_t time, const TString &options="") { #ifdef __CINT__ gSystem->Load("libptools.so"); #endif PGlobals::Initialize(); TString opt = options; const Int_t Nsim = 11; char sName[Nsim][36] = {"rake-v1.0kA.G.SR2.MC01.3D", "rake-v2.5kA.G.SR2.MC01.3D", "rake-v04kA.G.SR2.MC01.3D", "rake-v06kA.G.SR2.MC01.3D", "rake-v08kA.G.SR2.MC01.3D", "rake-v10kA.G.SR2.MC01.3D", "rake-v15kA.G.SR2.MC01.3D", "rake-v20kA.G.MC01.3D", "rake-v30kA.G.SR2.MC01.3D", "rake-v45kA.G.SR2.MC01.3D", "rake-v60kA.G.SR2.MC01.3D"}; // Load first simulation data (for instance) PData *pData = PData::Get(sName[0]); pData->LoadFileNames(time); if(!pData->IsInit()) return; // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); Double_t lightspeed = PConst::c_light; // Some beam properties: Float_t gamma = pData->GetBeamGamma(); // Trapping potential Float_t trapPotential = 1.0 - (1.0/gamma); // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; // Compulsory options opt += "comovcenter"; // Centering time and z position: Double_t shiftz = pData->Shift(opt); if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } TFile *sFile[Nsim]; TString *sPath[Nsim]; Int_t color[Nsim]; // histos and graphs TH2F *hEz2D[Nsim]; TH2F *hDen2D[Nsim]; TH1F *hCur1D[Nsim]; TH1F *hEz1D[Nsim]; TH1F *hV1D[Nsim]; TH1F *hFocus1D[Nsim]; TH1F *hDenx1D[Nsim]; // Arrays with the quantities Float_t Current[Nsim]; Float_t Zeta0[Nsim]; Float_t RadiusX[Nsim]; Float_t RadiusZ[Nsim]; Float_t RadiusPsi[Nsim]; Float_t EzMax[Nsim]; Float_t EzMaxUse[Nsim]; Float_t EzLimit[Nsim]; Float_t EzMaxFocus[Nsim]; Float_t EzSlope[Nsim]; Float_t EzSlopeMaxFocus[Nsim]; Float_t EzMaxBeam[Nsim]; Float_t DeltaPsi[Nsim]; Float_t DeltaPsiFocus[Nsim]; Float_t TransRatio[Nsim]; Float_t TransRatioFocus[Nsim]; // Theory Float_t EzMaxLU[Nsim]; Float_t EzMaxLO[Nsim]; Float_t EzMaxUseBO[Nsim]; Float_t EzMaxBeamLO[Nsim]; Float_t EzSlopeLO[Nsim]; Float_t RadiusLO[Nsim]; Float_t RadiusLU[Nsim]; Float_t RadiusPsiBO[Nsim]; Float_t PsiMaxLO[Nsim]; Float_t DeltaPsiLO[Nsim]; Float_t DeltaPsiLU[Nsim]; // Maximums and minimums for plotting Float_t maxCur = -999.; Float_t minCur = 999.; Float_t maxRadius = -999.; Float_t minRadius = 999.; Float_t maxEz = -999.; Float_t minEz = 999.; Float_t maxEzSlope = -999.; Float_t minEzSlope = 999.; Float_t maxPsi = -999.; Float_t minPsi = 999.; Float_t maxTR = -999.; Float_t minTR = 999.; for(Int_t i=0;i<Nsim;i++) { TString filename = Form("./%s/Plots/Snapshots/Snapshot-%s_%i.root",sName[i],sName[i],time); sFile[i] = new TFile(filename,"READ"); // Load histos and graphs hEz2D[i] = (TH2F*) sFile[i]->Get("hE2D_0"); hDen2D[i] = (TH2F*) sFile[i]->Get("hDen2D_0"); hEz1D[i] = (TH1F*) sFile[i]->Get("hE1D_0"); hCur1D[i] = (TH1F*) sFile[i]->Get("hCur1D_1"); hV1D[i] = (TH1F*) sFile[i]->Get("hV1D"); hFocus1D[i] = (TH1F*) sFile[i]->Get("hFocus1D"); hDen2D[i]->ResetStats(); hEz1D[i]->ResetStats(); hCur1D[i]->ResetStats(); hV1D[i]->ResetStats(); cout << Form("\n Analyzing simulation %s : \n",sName[i]) << endl; // Driver RMS Double_t rmslength = hCur1D[i]->GetRMS(); // Find the first point on-axis where Ez changes from positive to negative: Int_t MAXCROSS = 2; Float_t *EzCross = new Float_t[MAXCROSS]; Float_t *EzExtr = new Float_t[MAXCROSS]; memset(EzCross,0,sizeof(Float_t)*MAXCROSS); memset(EzExtr,0,sizeof(Float_t)*MAXCROSS); Int_t auxNcross = PGlobals::HCrossings(hEz1D[i],EzCross,EzExtr,MAXCROSS,0.0,2*rmslength); // for(Int_t j=0;j<auxNcross;j++) { // if(opt.Contains("units")) // cout << Form(" %i Ez crossing found at zeta = %.2f um -> Ez maximum = %.2f GV/m",j,EzCross[j],EzExtr[j]) << endl; // else // cout << Form(" %i Ez crossing found at zeta = %.2f kp^-1 -> Ez maximum = %.2f E0",j,EzCross[j],EzExtr[j]) << endl; // } Zeta0[i] = EzCross[0]; Int_t bin0 = hEz1D[i]->FindBin(Zeta0[i]); hDenx1D[i] = (TH1F*) hDen2D[i]->ProjectionY("_py",bin0); RadiusX[i] = fabs(hDenx1D[i]->GetBinCenter(hDenx1D[i]->GetMaximumBin())); RadiusZ[i] = fabs(hV1D[i]->GetBinCenter(hV1D[i]->GetMinimumBin()) - Zeta0[i]); DeltaPsi[i] = hV1D[i]->GetBinContent(hV1D[i]->GetMaximumBin()) - hV1D[i]->GetBinContent(hV1D[i]->GetMinimumBin()); Float_t zshift = 0.5; if(opt.Contains("units")) zshift *= PUnits::um * kp; Int_t bin1 = hEz1D[i]->FindBin(Zeta0[i]-zshift); Int_t bin2 = hEz1D[i]->FindBin(Zeta0[i]+zshift); EzSlope[i] = (hEz1D[i]->GetBinContent(bin1)-hEz1D[i]->GetBinContent(bin2))/ (hEz1D[i]->GetBinCenter(bin1)-hEz1D[i]->GetBinCenter(bin2)); EzMaxUse[i] = EzSlope[i] * RadiusZ[i]; EzMaxBeam[i] = EzExtr[0]; EzMax[i] = fabs(EzExtr[1]); Current[i] = hCur1D[i]->GetMaximum(); if(opt.Contains("units")) { Current[i] *= PUnits::kA / PConst::I0; rmslength *= PUnits::um * kp; } RadiusLO[i] = PFunc::RadiusBO(Current[i],rmslength); RadiusLU[i] = 2.0 * TMath::Sqrt(Current[i]); EzMaxLU[i] = PFunc::EzMaxLu(Current[i]); EzMaxBeamLO[i] = PFunc::EzMaxBeamLo(Current[i]); EzMaxLO[i] = RadiusLO[i]/2.0; Float_t RadiusLO2 = RadiusLO[i]*RadiusLO[i]; Float_t RadiusLU2 = RadiusLU[i]*RadiusLU[i]; // EzSlopeLO[i] = RadiusLO2 * (RadiusLO2 + 8.0) / (2.0 * (RadiusLO2 + 4.0) * (RadiusLO2 + 4.0)); EzSlopeLO[i] = RadiusLU2 * (RadiusLU2 + 8.0) / (2.0 * (RadiusLU2 + 4.0) * (RadiusLU2 + 4.0)); PsiMaxLO[i] = RadiusLO[i]*RadiusLO[i]/4.0; DeltaPsiLO[i] = RadiusLO[i]*RadiusLO[i]/4.0; DeltaPsiLU[i] = RadiusLU[i]*RadiusLU[i]/4.0; RadiusPsiBO[i] = TMath::Sqrt(2*(DeltaPsiLO[i]-1)); EzMaxUseBO[i] = RadiusPsiBO[i]/2.0; if(opt.Contains("units")) { Current[i] /= PUnits::kA / PConst::I0; rmslength /= PUnits::um * kp; RadiusLO[i] *= skindepth / PUnits::um; RadiusLU[i] *= skindepth / PUnits::um; RadiusPsiBO[i] *= skindepth / PUnits::um; EzMaxLU[i] *= E0 / (PUnits::GV/PUnits::m); EzMaxBeamLO[i] *= E0 / (PUnits::GV/PUnits::m); EzMaxUseBO[i] *= E0 / (PUnits::GV/PUnits::m); EzSlope[i] *= (E0 / (PUnits::GV/PUnits::m)) * skindepth / PUnits::um; cout << Form(" Beam max. current = %.2f kA RMS = %.2f um",Current[i],rmslength) << endl; cout << Form(" Radius of the bubble (Lotov): R = %.2f um",RadiusLO[i]) << endl; cout << Form(" Radius of the bubble (Lu) : R = %.2f um",RadiusLU[i]) << endl; cout << Form(" Ez max beam (Lo) = %.2f GV/m",EzMaxBeamLO[i]) << endl; cout << Form(" Ez max (Lu) = %.2f GV/m",-EzMaxLU[i]) << endl; cout << Form(" Ez slope at crossing = %.2f (GV/m)/um ",EzSlope[i]) << endl; } else { cout << Form(" Beam max. current = %.2f I0 RMS = %.2f kp^-1",Current[i],rmslength) << endl; cout << Form(" Radius of the bubble (Lotov): R = %.2f kp^-1",RadiusLO[i]) << endl; cout << Form(" Radius of the bubble (Lu) : R = %.2f kp^-1",RadiusLU[i]) << endl; cout << Form(" Ez max beam (Lo) = %.2f E0",EzMaxBeamLO[i]) << endl; cout << Form(" Ez max (Lu) = %.2f E0",-EzMaxLU[i]) << endl; cout << Form(" Ez slope at crossing = %.2f ",EzSlope[i]) << endl; } if(opt.Contains("kA")) { Current[i] /= PUnits::kA / PConst::I0; } // Find the first Focusing crossing after the maximum MAXCROSS = 1; Float_t *FocusCross = new Float_t[MAXCROSS]; Float_t *FocusExtr = new Float_t[MAXCROSS]; memset(FocusCross,0,sizeof(Float_t)*MAXCROSS); memset(FocusExtr,0,sizeof(Float_t)*MAXCROSS); auxNcross = PGlobals::HCrossings(hFocus1D[i],FocusCross,FocusExtr,MAXCROSS,0.0,Zeta0[i]); if(opt.Contains("units") && n0) { trapPotential *= ( E0 * skindepth / (PUnits::MV) ); } Int_t binFcross = hFocus1D[i]->FindBin(FocusCross[0]); Float_t potValueFin = hV1D[i]->GetBinContent(binFcross); EzMaxFocus[i] = fabs(hEz1D[i]->GetBinContent(binFcross)); TransRatio[i] = EzMax[i]/EzMaxBeam[i]; TransRatioFocus[i] = EzMaxFocus[i]/EzMaxBeam[i]; cout << Form(" Max. R = %.2f ",TransRatio[i]) << endl; cout << Form(" Max. R focus = %.2f ",TransRatioFocus[i]) << endl; Int_t binPotValueIni = -99; Float_t potValueIni = -99; for(Int_t j=binFcross;j<hV1D[i]->GetNbinsX();j++) { if(hV1D[i]->GetBinContent(j)>=potValueFin+trapPotential) { binPotValueIni = j; potValueIni = hV1D[i]->GetBinContent(j); //break; } } // Ez slope at max focusing Ez zshift = 0.1; bin1 = hEz1D[i]->FindBin(FocusCross[0]-zshift); bin2 = hEz1D[i]->FindBin(FocusCross[0]+zshift); EzSlopeMaxFocus[i] = (hEz1D[i]->GetBinContent(bin1)-hEz1D[i]->GetBinContent(bin2))/ (hEz1D[i]->GetBinCenter(bin1)-hEz1D[i]->GetBinCenter(bin2)); cout << Form(" Ez slope at max focus = %.2f ",EzSlopeMaxFocus[i]) << endl; // Difference between psi maximum and psi final focus DeltaPsiFocus[i] = hV1D[i]->GetBinContent(hV1D[i]->GetMaximumBin()) - potValueFin; // Find the first Psi crossing after the maximum MAXCROSS = 1; Float_t *PsiCross = new Float_t[MAXCROSS]; Float_t *PsiExtr = new Float_t[MAXCROSS]; memset(PsiCross,0,sizeof(Float_t)*MAXCROSS); memset(PsiExtr,0,sizeof(Float_t)*MAXCROSS); auxNcross = PGlobals::HCrossings(hV1D[i],PsiCross,PsiExtr,MAXCROSS,potValueIni,Zeta0[i]); Int_t binVcross = -1; EzLimit[i] = 0.0; RadiusPsi[i] = 0.0; if(auxNcross>0) { binVcross = hEz1D[i]->FindBin(PsiCross[0]); EzLimit[i] = fabs(hEz1D[i]->GetBinContent(binVcross)); RadiusPsi[i] = fabs(PsiCross[0]- Zeta0[i]); } cout << Form(" Trapping zone radius = %.2f ",RadiusPsi[i]) << endl; if(RadiusX[i]>maxRadius) maxRadius = RadiusX[i]; if(RadiusZ[i]>maxRadius) maxRadius = RadiusZ[i]; if(RadiusLO[i]>maxRadius) maxRadius = RadiusLO[i]; if(RadiusLU[i]>maxRadius) maxRadius = RadiusLU[i]; if(RadiusX[i]<minRadius) minRadius = RadiusX[i]; if(RadiusZ[i]<minRadius) minRadius = RadiusZ[i]; if(RadiusLO[i]<minRadius) minRadius = RadiusLO[i]; if(RadiusLU[i]<minRadius) minRadius = RadiusLU[i]; if(EzMax[i]>maxEz) maxEz = EzMax[i]; if(EzMaxUse[i]>maxEz) maxEz = EzMaxUse[i]; if(EzLimit[i]>maxEz) maxEz = EzLimit[i]; if(EzMaxFocus[i]>maxEz) maxEz = EzMaxFocus[i]; if(EzMaxBeam[i]>maxEz) maxEz = EzMaxBeam[i]; if(EzMaxLO[i]>maxEz) maxEz = EzMaxLO[i]; if(EzMaxLU[i]>maxEz) maxEz = EzMaxLU[i]; if(EzMaxBeamLO[i]>maxEz) maxEz = EzMaxBeamLO[i]; if(EzMax[i]<minEz) minEz = EzMax[i]; if(EzMaxUse[i]<minEz) minEz = EzMaxUse[i]; if(EzLimit[i]<minEz) minEz = EzLimit[i]; if(EzMaxFocus[i]<minEz) minEz = EzMaxFocus[i]; if(EzMaxBeam[i]<minEz) minEz = EzMaxBeam[i]; if(EzMaxLO[i]<minEz) minEz = EzMaxLO[i]; if(EzMaxLU[i]<minEz) minEz = EzMaxLU[i]; if(EzMaxBeamLO[i]<minEz) minEz = EzMaxBeamLO[i]; if(EzSlope[i]>maxEzSlope) maxEzSlope = EzSlope[i]; if(EzSlope[i]<minEzSlope) minEzSlope = EzSlope[i]; // if(EzSlopeMaxFocus[i]>maxEzSlope) maxEzSlope = EzSlopeMaxFocus[i]; // if(EzSlopeMaxFocus[i]<minEzSlope) minEzSlope = EzSlopeMaxFocus[i]; if(DeltaPsi[i]>maxPsi) maxPsi = DeltaPsi[i]; if(DeltaPsiFocus[i]>maxPsi) maxPsi = DeltaPsiFocus[i]; if(DeltaPsiLO[i]>maxPsi) maxPsi = DeltaPsiLO[i]; if(DeltaPsiLU[i]>maxPsi) maxPsi = DeltaPsiLU[i]; if(DeltaPsi[i]<minPsi) minPsi = DeltaPsi[i]; if(DeltaPsiFocus[i]<minPsi) minPsi = DeltaPsiFocus[i]; if(DeltaPsiLO[i]<minPsi) minPsi = DeltaPsiLO[i]; if(DeltaPsiLU[i]<minPsi) minPsi = DeltaPsiLU[i]; if(TransRatio[i]<minTR) minTR = TransRatio[i]; if(TransRatio[i]>maxTR) maxTR = TransRatio[i]; if(TransRatioFocus[i]<minTR) minTR = TransRatioFocus[i]; if(TransRatioFocus[i]>maxTR) maxTR = TransRatioFocus[i]; if(Current[i]<minCur) minCur = Current[i]; if(Current[i]>maxCur) maxCur = Current[i]; } Float_t xMin = minCur - (maxCur-minCur)*0.1; Float_t xMax = maxCur + (maxCur-minCur)*0.1; // Graphs for the max. current dependence TGraph *gRadiusX = new TGraph(Nsim,Current,RadiusX); TGraph *gRadiusZ = new TGraph(Nsim,Current,RadiusZ); TGraph *gRadiusPsi = new TGraph(Nsim,Current,RadiusPsi); TGraph *gRadiusLO = new TGraph(Nsim,Current,RadiusLO); TGraph *gRadiusLU = new TGraph(Nsim,Current,RadiusLU); TGraph *gRadiusPsiBO = new TGraph(Nsim,Current,RadiusPsiBO); TGraph *gEzMax = new TGraph(Nsim,Current,EzMax); TGraph *gEzMaxUse = new TGraph(Nsim,Current,EzMaxUse); TGraph *gEzMaxBeam = new TGraph(Nsim,Current,EzMaxBeam); TGraph *gEzLimit = new TGraph(Nsim,Current,EzLimit); TGraph *gEzMaxFocus = new TGraph(Nsim,Current,EzMaxFocus); TGraph *gEzMaxLU = new TGraph(Nsim,Current,EzMaxLU); TGraph *gEzMaxLO = new TGraph(Nsim,Current,EzMaxLO); TGraph *gEzMaxUseBO = new TGraph(Nsim,Current,EzMaxUseBO); TGraph *gEzMaxBeamLO = new TGraph(Nsim,Current,EzMaxBeamLO); TGraph *gDeltaPsi = new TGraph(Nsim,Current,DeltaPsi); TGraph *gDeltaPsiFocus = new TGraph(Nsim,Current,DeltaPsiFocus); TGraph *gDeltaPsiLO = new TGraph(Nsim,Current,DeltaPsiLO); TGraph *gDeltaPsiLU = new TGraph(Nsim,Current,DeltaPsiLU); TGraph *gEzSlope = new TGraph(Nsim,Current,EzSlope); TGraph *gEzSlopeMaxFocus = new TGraph(Nsim,Current,EzSlopeMaxFocus); TGraph *gEzSlopeLO = new TGraph(Nsim,Current,EzSlopeLO); TGraph *gTransRatio = new TGraph(Nsim,Current,TransRatio); TGraph *gTransRatioFocus = new TGraph(Nsim,Current,TransRatioFocus); // Int_t color1 = kMagenta-8; // Int_t color2 = kMagenta-2; // Int_t color3 = kMagenta-4; // Int_t color4 = kAzure+1; // Int_t color5 = kGray+2; // Int_t markersty = 20; // Float_t markersiz = 1.0; // Int_t linewit = 2; Int_t color1 = kGray+3; Int_t color2 = kGray+2; Int_t color3 = kAzure+1; Int_t color4 = kRed; Int_t color5 = kGray+1; Int_t markersty = 20; Float_t markersiz = 1.0; Int_t linewit = 1; gRadiusX->SetLineColor(color1); gRadiusX->SetLineWidth(linewit); gRadiusX->SetMarkerColor(color1); gRadiusX->SetMarkerStyle(markersty); gRadiusX->SetMarkerSize(markersiz); gRadiusLU->SetLineColor(color1); gRadiusLU->SetLineWidth(1); gRadiusLU->SetLineStyle(4); gRadiusLU->SetMarkerColor(color1); gRadiusLU->SetMarkerStyle(markersty); gRadiusLU->SetMarkerSize(0.0); gRadiusZ->SetLineColor(color2); gRadiusZ->SetLineWidth(linewit); gRadiusZ->SetMarkerColor(color2); gRadiusZ->SetMarkerStyle(markersty); gRadiusZ->SetMarkerSize(markersiz); gRadiusLO->SetLineColor(color2); gRadiusLO->SetLineWidth(1); gRadiusLO->SetLineStyle(3); gRadiusLO->SetMarkerColor(color2); gRadiusLO->SetMarkerStyle(markersty); gRadiusLO->SetMarkerSize(0.0); gRadiusPsi->SetLineColor(color3); gRadiusPsi->SetLineWidth(linewit); gRadiusPsi->SetMarkerColor(color3); gRadiusPsi->SetMarkerStyle(markersty); gRadiusPsi->SetMarkerSize(markersiz); gEzMax->SetLineColor(color2); gEzMax->SetLineWidth(linewit); gEzMax->SetMarkerColor(color2); gEzMax->SetMarkerStyle(markersty); gEzMax->SetMarkerSize(markersiz); gEzMaxUse->SetLineColor(color2); gEzMaxUse->SetLineWidth(linewit); gEzMaxUse->SetMarkerColor(color2); gEzMaxUse->SetMarkerStyle(markersty); gEzMaxUse->SetMarkerSize(markersiz); gEzLimit->SetLineColor(color3); gEzLimit->SetLineWidth(linewit); gEzLimit->SetMarkerColor(color3); gEzLimit->SetMarkerStyle(markersty); gEzLimit->SetMarkerSize(markersiz); gEzMaxFocus->SetLineColor(color1); gEzMaxFocus->SetLineWidth(linewit); gEzMaxFocus->SetMarkerColor(color1); gEzMaxFocus->SetMarkerStyle(markersty); gEzMaxFocus->SetMarkerSize(markersiz); gEzSlope->SetLineColor(color2); gEzSlope->SetLineWidth(linewit); gEzSlope->SetMarkerColor(color2); gEzSlope->SetMarkerStyle(markersty); gEzSlope->SetMarkerSize(markersiz); gEzSlopeMaxFocus->SetLineColor(color1); gEzSlopeMaxFocus->SetLineWidth(linewit); gEzSlopeMaxFocus->SetMarkerColor(color1); gEzSlopeMaxFocus->SetMarkerStyle(markersty); gEzSlopeMaxFocus->SetMarkerSize(markersiz); gEzSlopeLO->SetLineColor(color2); gEzSlopeLO->SetLineWidth(1); gEzSlopeLO->SetLineStyle(3); gEzSlopeLO->SetMarkerColor(color2); gEzSlopeLO->SetMarkerStyle(markersty); gEzSlopeLO->SetMarkerSize(0); gDeltaPsi->SetLineColor(color2); gDeltaPsi->SetLineWidth(linewit); gDeltaPsi->SetMarkerColor(color2); gDeltaPsi->SetMarkerStyle(markersty); gDeltaPsi->SetMarkerSize(markersiz); gDeltaPsiFocus->SetLineColor(color1); gDeltaPsiFocus->SetLineWidth(linewit); gDeltaPsiFocus->SetMarkerColor(color1); gDeltaPsiFocus->SetMarkerStyle(markersty); gDeltaPsiFocus->SetMarkerSize(markersiz); gEzMaxBeam->SetLineColor(color4); gEzMaxBeam->SetLineWidth(linewit); gEzMaxBeam->SetMarkerColor(color4); gEzMaxBeam->SetMarkerStyle(markersty); gEzMaxBeam->SetMarkerSize(markersiz); gRadiusPsiBO->SetLineColor(color3); gRadiusPsiBO->SetLineWidth(1); gRadiusPsiBO->SetLineStyle(3); gRadiusPsiBO->SetMarkerColor(color3); gRadiusPsiBO->SetMarkerStyle(markersty); gRadiusPsiBO->SetMarkerSize(0.0); gEzMaxLU->SetLineColor(color5); gEzMaxLU->SetLineWidth(1); gEzMaxLU->SetLineStyle(4); gEzMaxLU->SetMarkerColor(color5); gEzMaxLU->SetMarkerStyle(markersty); gEzMaxLU->SetMarkerSize(0.0); gEzMaxLO->SetLineColor(color2); gEzMaxLO->SetLineWidth(1); gEzMaxLO->SetLineStyle(3); gEzMaxLO->SetMarkerColor(color2); gEzMaxLO->SetMarkerStyle(markersty); gEzMaxLO->SetMarkerSize(0.0); gEzMaxUseBO->SetLineColor(color3); gEzMaxUseBO->SetLineWidth(1); gEzMaxUseBO->SetLineStyle(3); gEzMaxUseBO->SetMarkerColor(color3); gEzMaxUseBO->SetMarkerStyle(markersty); gEzMaxUseBO->SetMarkerSize(0.0); gEzMaxBeamLO->SetLineColor(color4); gEzMaxBeamLO->SetLineWidth(1); gEzMaxBeamLO->SetLineStyle(3); gEzMaxBeamLO->SetMarkerColor(color4); gEzMaxBeamLO->SetMarkerStyle(markersty); gEzMaxBeamLO->SetMarkerSize(0.0); gDeltaPsiLO->SetLineColor(color2); gDeltaPsiLO->SetLineWidth(1); gDeltaPsiLO->SetLineStyle(3); gDeltaPsiLO->SetMarkerColor(color2); gDeltaPsiLO->SetMarkerStyle(markersty); gDeltaPsiLO->SetMarkerSize(0.0); gDeltaPsiLU->SetLineColor(color2); gDeltaPsiLU->SetLineWidth(1); gDeltaPsiLU->SetLineStyle(4); gDeltaPsiLU->SetMarkerColor(color2); gDeltaPsiLU->SetMarkerStyle(markersty); gDeltaPsiLU->SetMarkerSize(0.0); gTransRatio->SetLineColor(color2); gTransRatio->SetLineWidth(linewit); gTransRatio->SetMarkerColor(color2); gTransRatio->SetMarkerStyle(markersty); gTransRatio->SetMarkerSize(markersiz); gTransRatioFocus->SetLineColor(color1); gTransRatioFocus->SetLineWidth(linewit); gTransRatioFocus->SetMarkerColor(color1); gTransRatioFocus->SetMarkerStyle(markersty); gTransRatioFocus->SetMarkerSize(markersiz); // Canvas setup // Create the canvas and the pads before the Frame loop // Resolution: Int_t sizex = 800; Int_t sizey = 1000; char cName[32]; sprintf(cName,"C"); TCanvas *C = (TCanvas*) gROOT->FindObject(cName); if(C==NULL) C = new TCanvas("C","",sizex,sizey); C->cd(); C->Clear(); // Setup Pad layout: const Int_t Npads = 5; // Text objects // TPaveText **textLabel = new TPaveText*[Npads]; TPad **pad = new TPad*[Npads]; TH1F *hFrame[Npads]; TGaxis *axis[Npads]; TLegend *Leg[Npads]; // Setup Pad layout: Double_t lMargin = 0.14; Double_t rMargin = 0.05; Double_t bMargin = 0.10; Double_t tMargin = 0.04; Float_t mMargin = 0.01; PGlobals::CanvasPartition(C,Npads,lMargin,rMargin,bMargin,tMargin,mMargin); //PGlobals::CanvasAsymPartition(C,Npads,lMargin,rMargin,bMargin,tMargin,1.,mMargin); // Define the frames for plotting Int_t fonttype = 43; Int_t fontsize = 24; Int_t tfontsize = 28; Float_t txoffset = 3.8; Float_t lxoffset = 0.02; Float_t tyoffset = 2.0; Float_t lyoffset = 0.01; Float_t tylength = 0.02; Float_t txlength = 0.04; for(Int_t i=0;i<Npads;i++) { char name[16]; sprintf(name,"pad_%i",i); pad[i] = (TPad*) gROOT->FindObject(name); pad[i]->SetFrameLineWidth(2); // pad[i]->SetTickx(1); // pad[i]->SetTicky(1); sprintf(name,"hFrame_%i",i); hFrame[i] = (TH1F*) gROOT->FindObject(name); if(hFrame[i]) delete hFrame[i]; hFrame[i] = new TH1F(name,"",100,xMin,xMax); hFrame[i]->Reset(); Float_t xFactor = pad[0]->GetAbsWNDC()/pad[i]->GetAbsWNDC(); Float_t yFactor = pad[0]->GetAbsHNDC()/pad[i]->GetAbsHNDC(); // Format for y axis hFrame[i]->GetYaxis()->SetTitleFont(fonttype); hFrame[i]->GetYaxis()->SetTitleSize(tfontsize); hFrame[i]->GetYaxis()->SetTitleOffset(tyoffset); hFrame[i]->GetYaxis()->SetLabelFont(fonttype); hFrame[i]->GetYaxis()->SetLabelSize(fontsize); hFrame[i]->GetYaxis()->SetLabelOffset(lyoffset); hFrame[i]->GetYaxis()->SetTickLength(xFactor*tylength/yFactor); hFrame[i]->GetYaxis()->CenterTitle(); // Format for x axis hFrame[i]->GetXaxis()->SetTitleFont(fonttype); hFrame[i]->GetXaxis()->SetTitleSize(tfontsize+2); hFrame[i]->GetXaxis()->SetTitleOffset(txoffset); hFrame[i]->GetXaxis()->SetLabelFont(fonttype); hFrame[i]->GetXaxis()->SetLabelSize(fontsize+2); hFrame[i]->GetXaxis()->SetLabelOffset(lxoffset); hFrame[i]->GetXaxis()->CenterTitle(); hFrame[i]->GetXaxis()->SetTickLength(yFactor*txlength/xFactor); } C->cd(0); pad[0]->Draw(); pad[0]->cd(); // gPad->SetLogx(1); Float_t yMin = minTR - (maxTR-minTR)*0.2; Float_t yMax = maxTR + (maxTR-minTR)*0.2; if(yMin<0.0) yMin = 0.001; hFrame[0]->GetYaxis()->SetRangeUser(yMin,yMax); hFrame[0]->GetXaxis()->SetTitle("#Lambda_{b}"); if(opt.Contains("kA")) hFrame[0]->GetXaxis()->SetTitle("I_{b}^{ 0} [kA]"); hFrame[0]->GetYaxis()->SetTitle("R"); hFrame[0]->Draw("AXIS"); // if(opt.Contains("theo")) { // gDeltaPsiLO->Draw("PL"); // gDeltaPsiLU->Draw("PL"); // } gTransRatio->Draw("PL"); gTransRatioFocus->Draw("PL"); Int_t fontsizeleg = 20; if(opt.Contains("leg")) { Leg[0]=new TLegend(1 - gPad->GetRightMargin() - 0.26, gPad->GetBottomMargin() + 0.40, 1 - gPad->GetRightMargin() - 0.02, gPad->GetBottomMargin() + 0.55); PGlobals::SetPaveStyle(Leg[0]); Leg[0]->SetTextAlign(13); Leg[0]->SetTextColor(kGray+3); Leg[0]->SetTextFont(43); Leg[0]->SetTextSizePixels(fontsizeleg); Leg[0]->SetLineColor(1); Leg[0]->SetBorderSize(0); Leg[0]->SetFillColor(0); Leg[0]->SetFillStyle(1001); Leg[0]->SetFillStyle(0); // Hollow Leg[0]->AddEntry(gTransRatio,"Max R","LP"); Leg[0]->AddEntry(gTransRatioFocus,"Max R in focus","LP"); Leg[0]->Draw(); } C->cd(0); pad[1]->Draw(); pad[1]->cd(); // gPad->SetLogx(1); yMin = minPsi - (maxPsi-minPsi)*0.2; yMax = maxPsi + (maxPsi-minPsi)*0.2; //if(yMin<0.0) yMin = 0.001; hFrame[1]->GetYaxis()->SetRangeUser(yMin,yMax); hFrame[1]->GetXaxis()->SetTitle("#Lambda_{b}"); if(opt.Contains("kA")) hFrame[1]->GetXaxis()->SetTitle("I_{b} [kA]"); hFrame[1]->GetYaxis()->SetTitle("#Delta#psi"); hFrame[1]->Draw("AXIS"); TLine *line1 = new TLine(xMin,1.0,xMax,1.0); line1->SetLineColor(kGray+2); line1->SetLineStyle(2); line1->Draw(); if(opt.Contains("theo")) { gDeltaPsiLO->Draw("PL"); gDeltaPsiLU->Draw("PL"); } gDeltaPsi->Draw("PL"); gDeltaPsiFocus->Draw("PL"); if(opt.Contains("leg")) { Leg[1]=new TLegend(gPad->GetLeftMargin() + 0.03, 1 - gPad->GetTopMargin() - 0.32, gPad->GetLeftMargin() + 0.24, 1 - gPad->GetTopMargin() - 0.08); PGlobals::SetPaveStyle(Leg[1]); Leg[1]->SetTextAlign(13); Leg[1]->SetTextColor(kGray+3); Leg[1]->SetTextFont(43); Leg[1]->SetTextSizePixels(fontsizeleg); Leg[1]->SetLineColor(1); Leg[1]->SetBorderSize(0); Leg[1]->SetFillColor(0); Leg[1]->SetFillStyle(1001); Leg[1]->SetFillStyle(0); // Hollow Leg[1]->AddEntry(gDeltaPsi,"Max #Delta#psi","LP"); Leg[1]->AddEntry(gDeltaPsiFocus,"Max #Delta#psi in focus","LP"); // Leg[1]->AddEntry(gDeltaPsiLO,"Max #Psi Lotov","L"); // Leg[1]->AddEntry(gDeltaPsiLU,"Max #Psi Lu","L"); Leg[1]->Draw(); } C->cd(0); pad[2]->Draw(); pad[2]->cd(); // gPad->SetLogx(1); yMin = minEz - (maxEz-minEz)*0.2; yMax = maxEz + (maxEz-minEz)*0.2; if(yMin<=0.0) yMin = -0.999; hFrame[2]->GetYaxis()->SetRangeUser(yMin,yMax); hFrame[2]->GetYaxis()->SetTitle("|E_{z}/E_{0}|"); hFrame[2]->Draw("AXIS"); TLine *line0 = new TLine(xMin,0.0,xMax,0.0); line0->SetLineColor(kGray+2); line0->SetLineStyle(2); line0->Draw(); if(opt.Contains("theo")) { gEzMaxLO->Draw("PL"); //gEzMaxUseBO->Draw("PL"); gEzMaxBeamLO->Draw("PL"); // gEzMaxLU->Draw("PL"); } gEzMax->Draw("PL"); // gEzMaxUse->Draw("PL"); gEzMaxBeam->Draw("PL"); gEzLimit->Draw("PL"); gEzMaxFocus->Draw("PL"); if(opt.Contains("leg")) { Leg[2]=new TLegend(gPad->GetLeftMargin() + 0.03, 1 - gPad->GetTopMargin() - 0.4, gPad->GetLeftMargin() + 0.24, 1 - gPad->GetTopMargin() - 0.04); PGlobals::SetPaveStyle(Leg[2]); Leg[2]->SetTextAlign(13); Leg[2]->SetTextColor(kGray+3); Leg[2]->SetTextFont(43); Leg[2]->SetTextSizePixels(fontsizeleg-2); Leg[2]->SetLineColor(1); Leg[2]->SetBorderSize(0); Leg[2]->SetFillColor(0); Leg[2]->SetFillStyle(1001); Leg[2]->SetFillStyle(0); // Hollow Leg[2]->AddEntry(gEzMax,"Min E_{z}","LP"); Leg[2]->AddEntry(gEzMaxFocus,"Min E_{z} in focus","LP"); Leg[2]->AddEntry(gEzLimit,"Min E_{z} trapping","LP"); Leg[2]->AddEntry(gEzMaxBeam,"Max E_{z} beam","LP"); Leg[2]->Draw(); } C->cd(0); pad[3]->Draw(); pad[3]->cd(); // gPad->SetLogx(1); yMin = minEzSlope - (maxEzSlope-minEzSlope)*0.25; yMax = maxEzSlope + (maxEzSlope-minEzSlope)*0.25; if(yMin<=0.0) yMin = -0.999; // hFrame[3]->GetYaxis()->SetRangeUser(yMin,yMax); hFrame[3]->GetYaxis()->SetRangeUser(-0.0499,0.5499); hFrame[3]->GetYaxis()->SetNdivisions(510); hFrame[3]->GetYaxis()->SetTitle("#partial_{#zeta}E_{z}^{0}/k_{p}E_{0}"); hFrame[3]->Draw("AXIS"); TLine *line05 = new TLine(xMin,0.5,xMax,0.5); line05->SetLineColor(kGray+2); line05->SetLineStyle(2); line05->Draw(); line0->Draw(); if(opt.Contains("theo")) { // gEzSlopeLO->Draw("PL"); } gEzSlope->Draw("PL"); // gEzSlopeMaxFocus->Draw("PL"); if(opt.Contains("leg")) { Leg[3]=new TLegend(1 - gPad->GetRightMargin() - 0.26, gPad->GetBottomMargin() + 0.14,1- gPad->GetRightMargin() - 0.02, gPad->GetBottomMargin() + 0.24); PGlobals::SetPaveStyle(Leg[3]); Leg[3]->SetTextAlign(12); Leg[3]->SetTextColor(kGray+3); Leg[3]->SetTextFont(43); Leg[3]->SetTextSizePixels(fontsizeleg); Leg[3]->SetLineColor(1); Leg[3]->SetBorderSize(0); Leg[3]->SetFillColor(0); Leg[3]->SetFillStyle(1001); Leg[3]->SetFillStyle(0); // Hollow Leg[3]->AddEntry(gEzSlope,"E_{z} slope at #zeta_{m}","LP"); Leg[3]->Draw(); } C->cd(0); pad[4]->Draw(); pad[4]->cd(); // gPad->SetLogx(1); yMin = minRadius - (maxRadius-minRadius)*0.2; yMax = maxRadius + (maxRadius-minRadius)*0.2; if(yMin<=0.0) yMin = -0.999; hFrame[4]->GetYaxis()->SetRangeUser(yMin,yMax); hFrame[4]->GetYaxis()->SetTitle("k_{p} x"); hFrame[4]->Draw("AXIS"); line0->Draw(); if(opt.Contains("theo")) { gRadiusLO->Draw("PL"); gRadiusLU->Draw("PL"); // gRadiusPsiBO->Draw("PL"); } gRadiusPsi->Draw("PL"); gRadiusX->Draw("PL"); gRadiusZ->Draw("PL"); if(opt.Contains("leg")) { Leg[4]=new TLegend(1 - gPad->GetRightMargin() - 0.15, gPad->GetBottomMargin() + 0.15, 1 - gPad->GetRightMargin() + 0.09, gPad->GetBottomMargin() + 0.45); PGlobals::SetPaveStyle(Leg[4]); Leg[4]->SetTextAlign(12); Leg[4]->SetTextColor(kGray+3); Leg[4]->SetTextFont(43); Leg[4]->SetTextSizePixels(fontsizeleg); Leg[4]->SetLineColor(1); Leg[4]->SetBorderSize(0); Leg[4]->SetFillColor(0); Leg[4]->SetFillStyle(1001); Leg[4]->SetFillStyle(0); // Hollow // Leg[4]->AddEntry(gRadiusZ,"Longitudinal radius","LP"); // Leg[4]->AddEntry(gRadiusX,"Transverse radius","LP"); // Leg[4]->AddEntry(gRadiusPsi,"Trapping radius","LP"); Leg[4]->AddEntry(gRadiusZ,"l_{m}","LP"); Leg[4]->AddEntry(gRadiusX,"r_{m}","LP"); Leg[4]->AddEntry(gRadiusPsi,"l_{t}","LP"); Leg[4]->Draw(); } C->cd(); // Output file TString fOutName = Form("./Blowout/Blowout-Scalings"); fOutName += Form("_%i",time); PGlobals::imgconv(C,fOutName,opt); // --------------------------------------------------------- }
void PlotDummy( const TString &sim, UInt_t time, Int_t zoom=2, const TString &opt="") { PlasmaGlob::Initialize(); // Palettes! gROOT->Macro("PlasmaPalettes.C"); // More makeup gStyle->SetPadRightMargin(0.12); // Margin for palettes in 2D histos // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; // Get charge density histos Int_t index = 1; if(opt.Contains("beam")) index = 1; char hName[24]; sprintf(hName,"hDen_%i",index); TH2F *hDen2D = (TH2F*) gROOT->FindObject(hName); if(hDen2D) delete hDen2D; hDen2D = pData->GetCharge(index); hDen2D->SetName(hName); hDen2D->GetXaxis()->CenterTitle(); hDen2D->GetYaxis()->CenterTitle(); hDen2D->GetXaxis()->SetTitle("z [c/#omega_{p}]"); hDen2D->GetYaxis()->SetTitle("y [c/#omega_{p}]"); hDen2D->SetBit(kCanDelete); // Tunning the Histograms // --------------------- Float_t Time = hDen2D->GetXaxis()->GetXmin(); // Set the range of the histogram for maximum constrast Float_t density = 1; if(opt.Contains("units") && pData->GetPlasmaDensity()) density = 1e-15 * 1e-6 * pData->GetPlasmaDensity(); if(index==0) { Float_t Max = 1.1 * hDen2D->GetMaximum(); Float_t Base = density; Float_t Min = 2.* Base - Max; if(Max >= 2. * Base) { Min = 0; } else if(Max<1.0 * Base) { Max = 1.1 * Base; Min = 0.; } hDen2D->GetZaxis()->SetRangeUser(Min,Max); } // Zoom Float_t range = (hDen2D->GetYaxis()->GetXmax() - hDen2D->GetYaxis()->GetXmin())/zoom; Float_t midPoint = (hDen2D->GetYaxis()->GetXmax() + hDen2D->GetYaxis()->GetXmin())/2.; hDen2D->GetYaxis()->SetRangeUser(midPoint-range/2,midPoint+range/2); // Plotting // ----------------------------------------------- // Canvas setup TCanvas *C = new TCanvas("C","Charge density and Electric field",850,500); // Text objects TPaveText text1(0.6,0.94,0.88,1.0,"NDC"); PlasmaGlob::SetPaveStyle(&text1); text1.AddText("Charge density [a.u.]"); TPaveText textTime(0.7,0.82,0.85,0.88,"NDC"); PlasmaGlob::SetPaveStyle(&textTime); char ctext[128]; sprintf(ctext,"T = %5.1f [1/#omega_{p}]",Time); textTime.AddText(ctext); // Palettes!! // const Int_t electronNRGBs = 5; // const Int_t electronNCont = 64; // Double_t electronStops[electronNRGBs] = { 0.00, 0.10, 0.50, 0.95, 1.00}; // Double_t electronRed[electronNRGBs] = { 0.90, 0.52, 0.22, 0.39, 0.50}; // Double_t electronGreen[electronNRGBs] = { 0.90, 0.74, 0.34, 0.05, 0.00}; // Double_t electronBlue[electronNRGBs] = { 0.90, 0.80, 0.58, 0.33, 0.09}; // PPalette *electronPalette = new PPalette("electron"); // electronPalette->CreateGradientColorTable(electronNRGBs, electronStops, electronRed, electronGreen, electronBlue, electronNCont); // Actual Plotting! // ------------------------------------------------------------ // Output file TString fOutName = Form("./%s/Plots/Dummy/Dummy",sim.Data()); fOutName += Form("-%s_%i",sim.Data(),time); C->cd(0); C->cd(1); // <--- Top Plot gPad->SetFrameLineWidth(3); // if(index == 0) // plasmaPalette->cd(); // else PPalette * electronPalette = (PPalette*) gROOT->FindObject("electron"); electronPalette->cd(); hDen2D->Draw("colz"); // text1.Draw(); // textTime.Draw(); C->cd(); // Print to a file PlasmaGlob::imgconv(C,fOutName,opt); // --------------------------------------------------------- }
void EnobioStatusReceiver::receiveData(const PData& rData) { BOOST_VERIFY(mpEnobioSignalHandler != 0); mpEnobioSignalHandler->handleStatusData((StatusData *)rData.getData()); }
void PlotEvolutionsWIII(const TString &sim, UInt_t mask = 3, const TString &options="png") { #ifdef __CINT__ gSystem->Load("libptools.so"); #endif string imask = DecToBin(mask); cout << Form("\n Plotting Evolultion with mask: %s",imask.c_str()) << endl; PGlobals::Initialize(); // Palettes! gROOT->Macro("PPalettes.C"); TString opt = options; // More makeup Float_t margins[4] = {0.15,0.15,0.20,0.10}; gStyle->SetPadLeftMargin(margins[0]); // Margin left axis gStyle->SetPadRightMargin(margins[2]); gStyle->SetPadTopMargin(margins[3]); // Margin left axis gStyle->SetPadBottomMargin(margins[1]); gStyle->SetPadTickX(0); gStyle->SetPadTickY(0); if(opt.Contains("grid")) { gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); } // Load first simulation data (for instance) PData *pData = PData::Get(sim.Data()); Double_t E0 = pData->GetPlasmaE0(); Float_t maxEcross = -999.; Float_t minEcross = 999.; Float_t maxEextr = -999.; Float_t minEextr = 999.; Float_t maxEdephas = -999.; Float_t minEdephas = 999.; const Int_t Nfields = 2; // E_z, E_x TH2F *hEvsTime[Nfields]; Int_t NCross[Nfields]; TGraph **gEcross[Nfields]; TGraph **gEextr[Nfields]; TGraph **gEdephas[Nfields]; TGraph *gTRatio; TH2F *hFvsTime; TGraph **gFcross = NULL; TGraph **gFextr = NULL; TH2F *hETvsTime; TGraph **gETcross = NULL; TGraph **gETextr = NULL; TH2F *hVvsTime; TGraph **gVcross = NULL; TGraph **gVextr = NULL; const Int_t NAtoms = 3; char atNames[NAtoms][4] = {"H","He","He2"}; TH2F *hIonProbvsTime[NAtoms]; // For H, He and He+. TGraph *gIonProb10[NAtoms]; TGraph *gIonProb100[NAtoms]; Float_t IonTh[NAtoms] = {33.8,92.75,234.96} ; // GV/m // if(!opt.Contains("units")) // for(Int_t i=0;i<NAtoms;i++) IonTh[i] /= ( E0 / (PUnits::GV/PUnits::m)); char hName[24]; char gName[24]; TString filename; filename = Form("./%s/Plots/Evolutions/Evolutions-%s.root",sim.Data(),sim.Data()); TFile *ifile = (TFile*) gROOT->GetListOfFiles()->FindObject(filename.Data()); if (!ifile) ifile = new TFile(filename,"READ"); TH2F *hDen1DvsTime = NULL; sprintf(hName,"hDenvsTime_1"); hDen1DvsTime = (TH2F*) ifile->Get(hName); TH2F *hRmsvsTime = NULL; sprintf(hName,"hRmsvsTime_1"); hRmsvsTime = (TH2F*) ifile->Get(hName); for(Int_t i=0;i<Nfields;i++) { sprintf(hName,"hEvsTime_%i",i); hEvsTime[i] = (TH2F*) ifile->Get(hName); if(!hEvsTime[i]) continue; cout << Form("ANALYZING FIELD %i ...",i) << endl; Int_t NTBins = hEvsTime[i]->GetNbinsX(); for(Int_t it=NTBins;it>0;it--) { // 1D field at certain timestep "it". TH1F *hE1D = (TH1F*) hEvsTime[i]->ProjectionY("_py",it,it); Int_t MAXCROSS = 2; Float_t *Cross = new Float_t[MAXCROSS]; Float_t *Extr = new Float_t[MAXCROSS]; memset(Cross,0,sizeof(Float_t)*MAXCROSS); memset(Extr,0,sizeof(Float_t)*MAXCROSS); Int_t auxNcross = PGlobals::HCrossings(hE1D,Cross,Extr,MAXCROSS,0.,0.); // cout << Form(" -> Number of crossings for histogram \"%s\" : %i ",hE1D->GetName(),auxNcross) << endl; // for(Int_t ic=0;ic<auxNcross;ic++) { // cout << Form(" %2i: cross = %6.4f extreme = %6.4f", ic, Cross[ic], Extr[ic]) << endl; // } if(it==NTBins) { NCross[i] = auxNcross; gEcross[i] = new TGraph*[NCross[i]]; gEextr[i] = new TGraph*[NCross[i]]; for(Int_t ic = 0;ic<NCross[i];ic++) { gEcross[i][ic] = new TGraph(NTBins); sprintf(gName,"gEcross_%i_%i",i,ic); gEcross[i][ic]->SetName(gName); gEextr[i][ic] = new TGraph(NTBins); sprintf(gName,"gEextr_%i_%i",i,ic); gEextr[i][ic]->SetName(gName); } } Float_t time = hEvsTime[i]->GetXaxis()->GetBinCenter(it); // cout << Form("Time step %i (%.2f): %i crossings",it,time,NCross[i]) << endl; for(Int_t ic=0;ic<NCross[i];ic++) { // cout << Form(" - Adding %i crossing: cross = %6.4f extreme = %6.4f",ic,Cross[ic],Extr[ic]) << endl; gEcross[i][ic]->SetPoint(it-1,time,Cross[ic]); gEextr[i][ic]->SetPoint(it-1,time,Extr[ic]); } } // Calculate the max and min of every crossing. // Also calculates dephasing: gEdephas[i] = new TGraph*[NCross[i]]; for(Int_t ic = 0;ic<NCross[i];ic++) { Int_t Npoints = gEcross[i][ic]->GetN(); Double_t *yEcross = gEcross[i][ic]->GetY(); Double_t *yEextr = gEextr[i][ic]->GetY(); Double_t *xEextr = gEextr[i][ic]->GetX(); Double_t *yEdephas = new Double_t[Npoints]; for(Int_t j=0;j<Npoints;j++) { yEdephas[j] = yEcross[j] - yEcross[0]; } gEdephas[i][ic] = new TGraph(Npoints,xEextr,yEdephas); sprintf(gName,"gEdephas_%i_%i",i,ic); gEdephas[i][ic]->SetName(gName); for(Int_t j=0;j<Npoints;j++) { if(yEcross[j]>maxEcross) maxEcross = yEcross[j]; if(yEcross[j]<minEcross) minEcross = yEcross[j]; if(yEextr[j]>maxEextr) maxEextr = yEextr[j]; if(yEextr[j]<minEextr) minEextr = yEextr[j]; // Only takes into account the minimums of the accelerating field: if(ic%2 || i!=0) continue; if(yEdephas[j]>maxEdephas) maxEdephas = yEdephas[j]; if(yEdephas[j]<minEdephas) minEdephas = yEdephas[j]; } } } // Transformer ratio vs time: // Take the ratio of the minimum over the maximum of the first oscillation of the Ez. { Int_t Npoints = gEextr[0][1]->GetN(); Double_t *TR = new Double_t[Npoints]; Double_t *yExtrPrev = gEextr[0][0]->GetY(); Double_t *yExtr = gEextr[0][1]->GetY(); Double_t *xExtr = gEextr[0][1]->GetX(); for(Int_t j=0;j<Npoints;j++) { TR[j] = TMath::Abs(yExtr[j]/yExtrPrev[j]); } gTRatio = new TGraph(Npoints,xExtr,TR); sprintf(gName,"gTRatio"); gTRatio->SetName(gName); } sprintf(hName,"hVvsTime"); hVvsTime = (TH2F*) ifile->Get(hName); Int_t NVCross = 0; cout << Form("ANALYZING POTENTIAL") << endl; Int_t NTBins = hVvsTime->GetNbinsX(); for(Int_t it=NTBins;it>0;it--) { // 1D field at certain timestep "it". TH1F *hV1D = (TH1F*) hVvsTime->ProjectionY("_py",it,it); Int_t MAXCROSS = 2; Float_t *Cross = new Float_t[MAXCROSS]; Float_t *Extr = new Float_t[MAXCROSS]; memset(Cross,0,sizeof(Float_t)*MAXCROSS); memset(Extr,0,sizeof(Float_t)*MAXCROSS); Int_t auxNcross = PGlobals::HCrossings(hV1D,Cross,Extr,MAXCROSS,0.,20.); // cout << Form(" -> Number of crossings for histogram \"%s\" : %i ",hV1D->GetName(),auxNcross) << endl; // for(Int_t ic=0;ic<auxNcross;ic++) { // cout << Form(" %2i: cross = %6.4f extreme = %6.4f", ic, Cross[ic], Extr[ic]) << endl; // } if(it==NTBins) { NVCross = auxNcross; gVcross = new TGraph*[NVCross]; gVextr = new TGraph*[NVCross]; for(Int_t ic = 0;ic<NVCross;ic++) { gVcross[ic] = new TGraph(NTBins); sprintf(gName,"gVcross_%i",ic); gVcross[ic]->SetName(gName); gVextr[ic] = new TGraph(NTBins); sprintf(gName,"gVextr_%i",ic); gVextr[ic]->SetName(gName); } } Float_t time = hVvsTime->GetXaxis()->GetBinCenter(it); // cout << Form("Time step %i (%.2f): %i crossings",it,time,NVCross) << endl; for(Int_t ic=0;ic<NVCross;ic++) { // cout << Form(" - Adding %i crossing: cross = %6.4f extreme = %6.4f",ic,Cross[ic],Extr[ic]) << endl; gVcross[ic]->SetPoint(it-1,time,Cross[ic]); gVextr[ic]->SetPoint(it-1,time,Extr[ic]); } } sprintf(hName,"hETotalvsTime"); hETvsTime = (TH2F*) ifile->Get(hName); Int_t NETCross = 0; cout << Form("ANALYZING TOTAL ELECTRIC FIELD") << endl; NTBins = hETvsTime->GetNbinsX(); for(Int_t it=NTBins;it>0;it--) { // 1D field at certain timestep "it". TH1F *hET1D = (TH1F*) hETvsTime->ProjectionY("_py",it,it); Int_t MAXCROSS = 2; Float_t *Cross = new Float_t[MAXCROSS]; Float_t *Extr = new Float_t[MAXCROSS]; memset(Cross,0,sizeof(Float_t)*MAXCROSS); memset(Extr,0,sizeof(Float_t)*MAXCROSS); Float_t baseline = 0.5; if(opt.Contains("units")) baseline *= E0 / (PUnits::GV/PUnits::m); Int_t auxNcross = PGlobals::HCrossings(hET1D,Cross,Extr,MAXCROSS,baseline,-999,-999,"cum"); // cout << Form(" -> Number of crossings for histogram \"%s\" : %i ",hET1D->GetName(),auxNcross) << endl; // for(Int_t ic=0;ic<auxNcross;ic++) { // cout << Form(" %2i: cross = %6.4f extreme = %6.4f", ic, Cross[ic], Extr[ic]) << endl; // } if(it==NTBins) { NETCross = auxNcross; gETcross = new TGraph*[NETCross]; gETextr = new TGraph*[NETCross]; for(Int_t ic = 0;ic<NETCross;ic++) { gETcross[ic] = new TGraph(NTBins); sprintf(gName,"gETcross_%i",ic); gETcross[ic]->SetName(gName); gETextr[ic] = new TGraph(NTBins); sprintf(gName,"gETextr_%i",ic); gETextr[ic]->SetName(gName); } } Float_t time = hETvsTime->GetXaxis()->GetBinCenter(it); // if(it==1) // cout << Form("Time step %i (%.2f): %i crossings",it,time,NETCross) << endl; for(Int_t ic=0;ic<NETCross;ic++) { //if(it==1) // cout << Form(" - Adding %i crossing: cross = %6.4f extreme = %6.4f",ic,Cross[ic],Extr[ic]) << endl; gETcross[ic]->SetPoint(it-1,time,Cross[ic]); gETextr[ic]->SetPoint(it-1,time,Extr[ic]); } } sprintf(hName,"hFocusvsTime"); hFvsTime = (TH2F*) ifile->Get(hName); Int_t NFCross = 0; cout << Form("ANALYZING FOCUSING") << endl; NTBins = hFvsTime->GetNbinsX(); for(Int_t it=NTBins;it>0;it--) { // 1D field at certain timestep "it". TH1F *hF1D = (TH1F*) hFvsTime->ProjectionY("_py",it,it); Int_t MAXCROSS = 2; Float_t *Cross = new Float_t[MAXCROSS]; Float_t *Extr = new Float_t[MAXCROSS]; memset(Cross,0,sizeof(Float_t)*MAXCROSS); memset(Extr,0,sizeof(Float_t)*MAXCROSS); Int_t auxNcross = PGlobals::HCrossings(hF1D,Cross,Extr,MAXCROSS,0.,0.); // cout << Form(" -> Number of crossings for histogram \"%s\" : %i ",hF1D->GetName(),auxNcross) << endl; // for(Int_t ic=0;ic<auxNcross;ic++) { // cout << Form(" %2i: cross = %6.4f extreme = %6.4f", ic, Cross[ic], Extr[ic]) << endl; // } if(it==NTBins) { NFCross = auxNcross; gFcross = new TGraph*[NFCross]; gFextr = new TGraph*[NFCross]; for(Int_t ic = 0;ic<NFCross;ic++) { gFcross[ic] = new TGraph(NTBins); sprintf(gName,"gFcross_%i",ic); gFcross[ic]->SetName(gName); gFextr[ic] = new TGraph(NTBins); sprintf(gName,"gFextr_%i",ic); gFextr[ic]->SetName(gName); } } Float_t time = hFvsTime->GetXaxis()->GetBinCenter(it); // cout << Form("Time step %i (%.2f): %i crossings",it,time,NFCross) << endl; for(Int_t ic=0;ic<NFCross;ic++) { // cout << Form(" - Adding %i crossing: cross = %6.4f extreme = %6.4f",ic,Cross[ic],Extr[ic]) << endl; gFcross[ic]->SetPoint(it-1,time,Cross[ic]); gFextr[ic]->SetPoint(it-1,time,Extr[ic]); } } for(Int_t i=0;i<NAtoms;i++) { sprintf(hName,"hIonProbvsTime_%s",atNames[i]); hIonProbvsTime[i] = (TH2F*) ifile->Get(hName); if(!hIonProbvsTime[i]) continue; cout << Form("ANALYZING Ionization probability %i ...",i) << endl; Int_t NTBins = hIonProbvsTime[i]->GetNbinsX(); for(Int_t it=NTBins;it>0;it--) { // 1D field at certain timestep "it". TH1F *hIonProb1D = (TH1F*) hIonProbvsTime[i]->ProjectionY("_py",it,it); Int_t MAXCROSS = 2; Float_t *Cross = new Float_t[MAXCROSS]; Float_t *Extr = new Float_t[MAXCROSS]; memset(Cross,0,sizeof(Float_t)*MAXCROSS); memset(Extr,0,sizeof(Float_t)*MAXCROSS); Int_t auxNcross = PGlobals::HCrossings(hIonProb1D,Cross,Extr,MAXCROSS,10.0); if(it==NTBins) { gIonProb10[i] = new TGraph(NTBins); sprintf(gName,"gIonProb10_%i",i); gIonProb10[i]->SetName(gName); } Float_t time = hIonProbvsTime[i]->GetXaxis()->GetBinCenter(it); gIonProb10[i]->SetPoint(it-1,time,Cross[0]); memset(Cross,0,sizeof(Float_t)*MAXCROSS); memset(Extr,0,sizeof(Float_t)*MAXCROSS); auxNcross = PGlobals::HCrossings(hIonProb1D,Cross,Extr,MAXCROSS,99.0); if(it==NTBins) { gIonProb100[i] = new TGraph(NTBins); sprintf(gName,"gIonProb100_%i",i); gIonProb100[i]->SetName(gName); } gIonProb100[i]->SetPoint(it-1,time,Cross[0]); } } // Set the color of the different evolutions according to a palette // UInt_t np = 50; // PPalette * colorPalette = (PPalette*) gROOT->FindObject("colorPalette"); // if(!colorPalette) { // const UInt_t Number = 3; // Double_t Red[Number] = { 1.00, 0.00, 0.00}; // Double_t Green[Number] = { 0.00, 1.00, 0.00}; // Double_t Blue[Number] = { 1.00, 0.00, 1.00}; // Double_t Length[Number] = { 0.00, 0.50, 1.00 }; // colorPalette = new PPalette("colorPalette"); // colorPalette->CreateGradientColorTable(Number,Length,Red,Green,Blue,np); // } // for(Int_t i=0;i<Nfields;i++) { // for(Int_t ic=0;ic<Ncross;ic++) { // Float_t step = (np/Nosc); // Int_t icolor = TMath::Nint( ((ic+1)/2) * step - 1 ); // gEextr[i][ic]->SetLineColor(colorPalette->GetColor(icolor)); // gEextr[i][ic]->SetLineWidth(2); // gEdephas[i][ic]->SetLineColor(colorPalette->GetColor(icolor)); // gEdephas[i][ic]->SetLineWidth(2); // } // } // -------------------------------------------------------------------------- // Manual coloring: const Int_t NCOLORS = 5; // Int_t colors[NCOLORS] = {kMagenta+2,kRed,kBlue,kYellow+2,kCyan+2}; Int_t colors[NCOLORS] = {kGray+3,kGray+2,kGray+1,kGray}; for(Int_t i=0;i<Nfields;i++) { for(Int_t ic=0;ic<NCross[i];ic++) { if( !gEcross[i][ic] || !gEextr[i][ic] ) continue; Int_t index = ic/2; if(index>=NCOLORS) index = NCOLORS-1; gEcross[i][ic]->SetLineColor(colors[index]); gEextr[i][ic]->SetLineColor(colors[index]); gEextr[i][ic]->SetLineWidth(1); gEdephas[i][ic]->SetLineColor(colors[index]); gEdephas[i][ic]->SetLineWidth(1); // cout << "EEEOOO" << endl; // if(ic%2) { // gEcross[i][ic]->SetLineStyle(2); // gEextr[i][ic]->SetLineStyle(2); // gEdephas[i][ic]->SetLineStyle(2); // } else { // gEcross[i][ic]->SetLineStyle(1); // gEextr[i][ic]->SetLineStyle(1); // gEdephas[i][ic]->SetLineStyle(1); // } } } for(Int_t ic = 0;ic<NFCross;ic++) { // Graph's attributes Int_t index = ic/2; if(index>=NCOLORS) index = NCOLORS-1; gFcross[ic]->SetLineColor(colors[index]); if(ic%2-1) { gFcross[ic]->SetLineStyle(2); gFextr[ic]->SetLineStyle(2); } else { gFcross[ic]->SetLineStyle(1); gFextr[ic]->SetLineStyle(1); } } for(Int_t ic = 0;ic<NVCross;ic++) { // Graph's attributes Int_t index = ic/2; if(index>=NCOLORS) index = NCOLORS-1; gVcross[ic]->SetLineColor(colors[index]); gVcross[ic]->SetLineStyle(3); gVextr[ic]->SetLineStyle(1); } for(Int_t ic = 0;ic<NETCross;ic++) { // Graph's attributes Int_t index = ic/2; if(index>=NCOLORS) index = NCOLORS-1; gETcross[ic]->SetLineColor(colors[index]); if(ic%2-1) { gETcross[ic]->SetLineStyle(2); gETextr[ic]->SetLineStyle(2); } else { gETcross[ic]->SetLineStyle(1); gETextr[ic]->SetLineStyle(1); } } for(Int_t i=0;i<NAtoms;i++) { gIonProb10[i]->SetLineStyle(2); gIonProb10[i]->SetLineColor(kGray+2); gIonProb100[i]->SetLineStyle(1); gIonProb100[i]->SetLineColor(kGray+2); } // Plotting // ------------------------------------------------------------ // Canvas setup UInt_t NPad = BitCounter(mask); if(NPad==0) NPad = 1; Float_t ypadsize = 250; Float_t ymarginsize = 200; if(NPad==1) ypadsize = 300; Float_t ysize = ypadsize * NPad + ymarginsize; Float_t boom = 1.2; if(opt.Contains("boom")) ysize *= boom; TCanvas *C = new TCanvas("C","Snapshot",1050,ysize); C->SetFillStyle(4000); UInt_t lineColor = kOrange+10; //UInt_t lineColor = TColor::GetColor(196,30,78); // Setup Pad layout: TPad **pad = new TPad*[NPad]; TH2F **hFrame = new TH2F*[NPad]; Float_t bMargin = 0.12 * (950/ysize); Float_t tMargin = 0.04 * (950/ysize); Float_t lMargin = 0.14; Float_t rMargin = 0.18; Float_t mMargin = 0.015 * (950/ysize); Float_t pfactor = 1.0; if(opt.Contains("nomar")) bMargin = tMargin = lMargin = rMargin = mMargin = 0.0; if(NPad==1) PGlobals::CanvasPartition(C,NPad,lMargin,rMargin,bMargin,tMargin,mMargin); else PGlobals::CanvasAsymPartition(C,NPad,lMargin,rMargin,bMargin,tMargin,pfactor,mMargin); // Define the frames for plotting Int_t fonttype = 43; Int_t fontsize = 32; Int_t tfontsize = 38; Int_t txsize = tfontsize+6; Int_t lxsize = fontsize; Int_t tysize = tfontsize; Int_t lysize = fontsize-2; Int_t tzsize = tfontsize-4; Int_t lzsize = fontsize-2; Float_t txoffset = (250/ypadsize) * 2.4 / (950/ysize); Float_t lxoffset = 0.015; Float_t tyoffset = 1.2 / (950/ysize); Float_t lyoffset = 0.01; Float_t tzoffset = 1.4 / (950/ysize); Float_t lzoffset = 0.01; Float_t tylength = 0.015; Float_t txlength = 0.04; for(Int_t i=NPad-1;i>=0;i--) { char name[16]; sprintf(name,"pad_%i",i); pad[i] = (TPad*) gROOT->FindObject(name); pad[i]->SetFrameLineWidth(2); pad[i]->SetTickx(1); pad[i]->SetTicky(1); if(opt.Contains("trans")) pad[i]->SetFillStyle(4000); pad[i]->SetFrameFillStyle(4000); sprintf(name,"hFrame_%i",i); hFrame[i] = (TH2F*) gROOT->FindObject(name); if(hFrame[i]) delete hFrame[i]; hFrame[i] = (TH2F*) hEvsTime[0]->Clone(name); hFrame[i]->Reset(); Float_t xFactor = pad[NPad-1]->GetAbsWNDC()/pad[i]->GetAbsWNDC(); Float_t yFactor = pad[NPad-1]->GetAbsHNDC()/pad[i]->GetAbsHNDC(); // Format for y axis hFrame[i]->GetYaxis()->SetLabelFont(fonttype); hFrame[i]->GetYaxis()->SetLabelSize(lysize); hFrame[i]->GetYaxis()->SetLabelOffset(lyoffset); hFrame[i]->GetYaxis()->SetTitleFont(fonttype); hFrame[i]->GetYaxis()->SetTitleSize(tysize); hFrame[i]->GetYaxis()->SetTitleOffset(tyoffset); hFrame[i]->GetYaxis()->SetTickLength(xFactor*tylength/yFactor); // Format for x axis hFrame[i]->GetXaxis()->SetLabelFont(fonttype); hFrame[i]->GetXaxis()->SetLabelSize(lxsize); hFrame[i]->GetXaxis()->SetLabelOffset(lxoffset); hFrame[i]->GetXaxis()->SetTitleFont(fonttype); hFrame[i]->GetXaxis()->SetTitleSize(txsize); hFrame[i]->GetXaxis()->SetTitleOffset(txoffset); hFrame[i]->GetXaxis()->SetTickLength(yFactor*txlength/xFactor); if(i>0) { // skip x axis labels except for the lowest one hFrame[i]->GetXaxis()->SetLabelSize(0.0); hFrame[i]->GetXaxis()->SetTitleSize(0.0); } if(opt.Contains("nomar")) { hFrame[i]->GetYaxis()->SetTickLength(0.0); hFrame[i]->GetXaxis()->SetTickLength(0.0); } // Labels for the frames } // Access to color Palettes TExec *exPlasma = new TExec("exPlasma","plasmaPalette->cd();"); TExec *exElec = new TExec("exElec","electron0Palette->cd();"); TExec *exHot = new TExec("exHot","hotPalette->cd();"); TExec *exField = new TExec("exField","rbowwhitePalette->cd();"); TExec *exFieldT = new TExec("exFieldT","red0Palette->cd();"); TExec *exIonP = new TExec("exIonP","redelectron0Palette->cd();"); TExec *exPot = new TExec("exPot","rbowinvPalette->cd();"); // Actual Plotting! // ------------------------------------------------------------ C->cd(0); Float_t x1,x2,y1,y2; Float_t gap = 0.01; TPaletteAxis *palette = NULL; UInt_t ip = NPad-1; if(mask & 0x1) { pad[ip]->Draw(); pad[ip]->cd(); if(opt.Contains("logz")) { pad[ip]->SetLogz(1); } else { pad[ip]->SetLogz(0); } hFrame[ip]->Draw("col"); // hDen1DvsTime->GetZaxis()->SetNdivisions(503); hDen1DvsTime->GetZaxis()->SetTitleFont(fonttype); Float_t xFactor = pad[0]->GetAbsWNDC()/pad[ip]->GetAbsWNDC(); Float_t yFactor = pad[0]->GetAbsHNDC()/pad[ip]->GetAbsHNDC(); hDen1DvsTime->GetZaxis()->SetTickLength(xFactor*tylength/yFactor); exElec->Draw(); hDen1DvsTime->Draw("colz same"); pad[ip]->Update(); y1 = pad[ip]->GetBottomMargin(); y2 = 1 - pad[ip]->GetTopMargin(); x1 = pad[ip]->GetLeftMargin(); x2 = 1 - pad[ip]->GetRightMargin(); palette = (TPaletteAxis*) hDen1DvsTime->GetListOfFunctions()->FindObject("palette"); if(palette) { palette->SetY2NDC(y2 - gap); palette->SetY1NDC(y1 + gap); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); palette->SetTitleOffset(tzoffset); palette->SetTitleSize(tzsize); palette->SetLabelFont(fonttype); palette->SetLabelSize(lzsize); palette->SetLabelOffset(lyoffset); palette->SetBorderSize(2); palette->SetLineColor(1); } pad[ip]->RedrawAxis(); ip--; C->cd(0); } if(mask & 0x2) { pad[ip]->Draw(); pad[ip]->cd(); if(opt.Contains("logz")) { pad[ip]->SetLogz(1); } else { pad[ip]->SetLogz(0); } hFrame[ip]->Draw("col"); // hRmsvsTime->GetZaxis()->SetNdivisions(503); hRmsvsTime->GetZaxis()->SetTitleFont(fonttype); Float_t xFactor = pad[0]->GetAbsWNDC()/pad[ip]->GetAbsWNDC(); Float_t yFactor = pad[0]->GetAbsHNDC()/pad[ip]->GetAbsHNDC(); hRmsvsTime->GetZaxis()->SetTickLength(xFactor*tylength/yFactor); exElec->Draw(); hRmsvsTime->Draw("colz same"); pad[ip]->Update(); y1 = pad[ip]->GetBottomMargin(); y2 = 1 - pad[ip]->GetTopMargin(); x1 = pad[ip]->GetLeftMargin(); x2 = 1 - pad[ip]->GetRightMargin(); palette = (TPaletteAxis*) hRmsvsTime->GetListOfFunctions()->FindObject("palette"); if(palette) { palette->SetY2NDC(y2 - gap); palette->SetY1NDC(y1 + gap); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); palette->SetTitleOffset(tzoffset); palette->SetTitleSize(tzsize); palette->SetLabelFont(fonttype); palette->SetLabelSize(lzsize); palette->SetLabelOffset(lyoffset); palette->SetBorderSize(2); palette->SetLineColor(1); } pad[ip]->RedrawAxis(); ip--; C->cd(0); } if(mask & 0x4) { pad[ip]->Draw(); pad[ip]->cd(); if(opt.Contains("logz")) { pad[ip]->SetLogz(1); } else { pad[ip]->SetLogz(0); } hFrame[ip]->Draw("col"); // hEvsTime[0]->GetZaxis()->SetNdivisions(503); hEvsTime[0]->GetZaxis()->SetTitleFont(fonttype); Float_t xFactor = pad[0]->GetAbsWNDC()/pad[ip]->GetAbsWNDC(); Float_t yFactor = pad[0]->GetAbsHNDC()/pad[ip]->GetAbsHNDC(); hEvsTime[0]->GetZaxis()->SetTickLength(xFactor*tylength/yFactor); exField->Draw(); hEvsTime[0]->Draw("colz same"); pad[ip]->Update(); y1 = pad[ip]->GetBottomMargin(); y2 = 1 - pad[ip]->GetTopMargin(); x1 = pad[ip]->GetLeftMargin(); x2 = 1 - pad[ip]->GetRightMargin(); palette = (TPaletteAxis*) hEvsTime[0]->GetListOfFunctions()->FindObject("palette"); if(palette) { palette->SetY2NDC(y2 - gap); palette->SetY1NDC(y1 + gap); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); palette->SetTitleOffset(tzoffset); palette->SetTitleSize(tzsize); palette->SetLabelFont(fonttype); palette->SetLabelSize(lzsize); palette->SetLabelOffset(lyoffset); palette->SetBorderSize(2); palette->SetLineColor(1); } if(!opt.Contains("nocross")) { for(Int_t ic=0;ic<NVCross;ic++) { if( gVcross[ic] ) gVcross[ic]->Draw("L"); } if(gEcross[1][0]) { gEcross[1][0]->SetLineStyle(4); gEcross[1][0]->Draw("L"); } } pad[ip]->RedrawAxis(); ip--; C->cd(0); } if(mask & 0x8) { pad[ip]->Draw(); pad[ip]->cd(); if(opt.Contains("logz")) { pad[ip]->SetLogz(1); } else { pad[ip]->SetLogz(0); } hFrame[ip]->Draw("col"); // hEvsTime[1]->GetZaxis()->SetNdivisions(503); hEvsTime[1]->GetZaxis()->SetTitleFont(fonttype); Float_t xFactor = pad[0]->GetAbsWNDC()/pad[ip]->GetAbsWNDC(); Float_t yFactor = pad[0]->GetAbsHNDC()/pad[ip]->GetAbsHNDC(); hEvsTime[1]->GetZaxis()->SetTickLength(xFactor*tylength/yFactor); exField->Draw(); hEvsTime[1]->Draw("colz same"); pad[ip]->Update(); y1 = pad[ip]->GetBottomMargin(); y2 = 1 - pad[ip]->GetTopMargin(); x1 = pad[ip]->GetLeftMargin(); x2 = 1 - pad[ip]->GetRightMargin(); palette = (TPaletteAxis*) hEvsTime[1]->GetListOfFunctions()->FindObject("palette"); if(palette) { palette->SetY2NDC(y2 - gap); palette->SetY1NDC(y1 + gap); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); palette->SetTitleOffset(tzoffset); palette->SetTitleSize(tzsize); palette->SetLabelFont(fonttype); palette->SetLabelSize(lzsize); palette->SetLabelOffset(lyoffset); palette->SetBorderSize(2); palette->SetLineColor(1); } pad[ip]->RedrawAxis(); ip--; C->cd(0); } if(mask & 0x10) { pad[ip]->Draw(); pad[ip]->cd(); if(opt.Contains("logz")) { pad[ip]->SetLogz(1); } else { pad[ip]->SetLogz(0); } hFrame[ip]->Draw("col"); // hETvsTime->GetZaxis()->SetNdivisions(503); hETvsTime->GetZaxis()->SetTitleFont(fonttype); Float_t xFactor = pad[0]->GetAbsWNDC()/pad[ip]->GetAbsWNDC(); Float_t yFactor = pad[0]->GetAbsHNDC()/pad[ip]->GetAbsHNDC(); hETvsTime->GetZaxis()->SetTickLength(xFactor*tylength/yFactor); exFieldT->Draw(); hETvsTime->Draw("colz same"); pad[ip]->Update(); y1 = pad[ip]->GetBottomMargin(); y2 = 1 - pad[ip]->GetTopMargin(); x1 = pad[ip]->GetLeftMargin(); x2 = 1 - pad[ip]->GetRightMargin(); palette = (TPaletteAxis*) hETvsTime->GetListOfFunctions()->FindObject("palette"); if(palette) { palette->SetY2NDC(y2 - gap); palette->SetY1NDC(y1 + gap); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); palette->SetTitleOffset(tzoffset); palette->SetTitleSize(tzsize); palette->SetLabelFont(fonttype); palette->SetLabelSize(lzsize); palette->SetLabelOffset(lyoffset); palette->SetBorderSize(2); palette->SetLineColor(1); } if(!opt.Contains("nocross")) { for(Int_t ic=0;ic<NVCross;ic++) { if( gVcross[ic] ) gVcross[ic]->Draw("L"); } if(gEcross[1][0]) { gEcross[1][0]->SetLineStyle(4); gEcross[1][0]->Draw("L"); } } pad[ip]->RedrawAxis(); ip--; C->cd(0); } if(mask & 0x20) { pad[ip]->Draw(); pad[ip]->cd(); if(opt.Contains("logz")) { pad[ip]->SetLogz(1); } else { pad[ip]->SetLogz(0); } hFrame[ip]->Draw("col"); // hVvsTime->GetZaxis()->SetNdivisions(503); hVvsTime->GetZaxis()->SetTitleFont(fonttype); Float_t xFactor = pad[0]->GetAbsWNDC()/pad[ip]->GetAbsWNDC(); Float_t yFactor = pad[0]->GetAbsHNDC()/pad[ip]->GetAbsHNDC(); hVvsTime->GetZaxis()->SetTickLength(xFactor*tylength/yFactor); exPot->Draw(); hVvsTime->Draw("colz same"); pad[ip]->Update(); y1 = pad[ip]->GetBottomMargin(); y2 = 1 - pad[ip]->GetTopMargin(); x1 = pad[ip]->GetLeftMargin(); x2 = 1 - pad[ip]->GetRightMargin(); palette = (TPaletteAxis*) hVvsTime->GetListOfFunctions()->FindObject("palette"); if(palette) { palette->SetY2NDC(y2 - gap); palette->SetY1NDC(y1 + gap); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); palette->SetTitleOffset(tzoffset); palette->SetTitleSize(tzsize); palette->SetLabelFont(fonttype); palette->SetLabelSize(lzsize); palette->SetLabelOffset(lyoffset); palette->SetBorderSize(2); palette->SetLineColor(1); } pad[ip]->RedrawAxis(); ip--; C->cd(0); } if(mask & 0x40) { pad[ip]->Draw(); pad[ip]->cd(); if(opt.Contains("logz")) { pad[ip]->SetLogz(1); } else { pad[ip]->SetLogz(0); } hFrame[ip]->Draw("col"); hIonProbvsTime[1]->GetZaxis()->SetNdivisions(503); hIonProbvsTime[1]->GetZaxis()->SetTitleFont(fonttype); Float_t xFactor = pad[0]->GetAbsWNDC()/pad[ip]->GetAbsWNDC(); Float_t yFactor = pad[0]->GetAbsHNDC()/pad[ip]->GetAbsHNDC(); hIonProbvsTime[1]->GetZaxis()->SetTickLength(xFactor*tylength/yFactor); hIonProbvsTime[1]->GetZaxis()->SetRangeUser(0.,0.12); // exFieldT->Draw(); // exPlasma->Draw(); exIonP->Draw(); hIonProbvsTime[1]->Draw("colz same"); pad[ip]->Update(); y1 = pad[ip]->GetBottomMargin(); y2 = 1 - pad[ip]->GetTopMargin(); x1 = pad[ip]->GetLeftMargin(); x2 = 1 - pad[ip]->GetRightMargin(); palette = (TPaletteAxis*) hIonProbvsTime[1]->GetListOfFunctions()->FindObject("palette"); if(palette) { palette->SetY2NDC(y2 - gap); palette->SetY1NDC(y1 + gap); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); palette->SetTitleOffset(tzoffset); palette->SetTitleSize(tzsize); palette->SetLabelFont(fonttype); palette->SetLabelSize(lzsize); palette->SetLabelOffset(lyoffset); palette->SetBorderSize(2); palette->SetLineColor(1); } if(!opt.Contains("nocross")) { for(Int_t ic=0;ic<NVCross;ic++) { if( gVcross[ic] ) gVcross[ic]->Draw("L"); } if(gEcross[1][0]) { gEcross[1][0]->SetLineStyle(4); gEcross[1][0]->Draw("L"); } } pad[ip]->RedrawAxis(); ip--; C->cd(0); } // Print to a file // Output file TString fOutName = Form("./%s/Plots/Evolutions/Evolutions%s-WII-%s",sim.Data(),imask.c_str(),sim.Data()); PGlobals::imgconv(C,fOutName,opt); // --------------------------------------------------------- ifile->Close(); cout << endl; }
void PlotCharge2D( const TString &sim, Int_t time, Int_t index = 0, Int_t zoom=2, Int_t Nbins=2, const TString &options="") { #ifdef __CINT__ gSystem->Load("libplasma.so"); #endif PlasmaGlob::Initialize(); // Palettes! gROOT->Macro("PlasmaPalettes.C"); // Init Units table PUnits::UnitsTable::Get(); // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; TString opt = options; // More makeup if(opt.Contains("grid")) { gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); } gStyle->SetTitleFont(42); gStyle->SetStatFont(42); gStyle->SetTextFont(42); gStyle->SetTitleFont(42,"xyz"); gStyle->SetLabelFont(42,"xyz"); // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Some beam properties: Float_t Ebeam = pData->GetBeamEnergy() * PUnits::MeV; Float_t gamma = Ebeam / PConst::ElectronMassE; Float_t vbeam = TMath::Sqrt(1 - 1/(gamma*gamma)); // cout << Form(" - Bunch gamma = %8.4f", gamma ) << endl; // cout << Form(" - Bunch velocity = %8.4f c", vbeam ) << endl; Float_t nb = pData->GetBeamDensity(); // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; // z start of the neutral in normalized units. Float_t zStartNeutral = pData->GetNeutralStart()*kp; // z end of the neutral in normalized units. Float_t zEndNeutral = pData->GetNeutralEnd()*kp; if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } Float_t shiftz = pData->Shift(opt); // cout << "Shift = " << shiftz << endl; // Calculate the "axis range" in number of bins. If Nbins==0 a RMS width is taken. Double_t rms0 = pData->GetBeamRmsY() * kp; if(pData->IsCyl()) rms0 = pData->GetBeamRmsR() * kp; Int_t FirstyBin = 0; Int_t LastyBin = 0; if(Nbins==0) { Nbins = TMath::Nint(rms0 / pData->GetDX(1)); } // Slice width limits. if(!pData->IsCyl()) { FirstyBin = pData->GetNX(1)/2 + 1 - Nbins; LastyBin = pData->GetNX(1)/2 + Nbins; } else { FirstyBin = 1; LastyBin = Nbins; } // ------------------------------------------------------------------------------- // Get charge density histos Int_t Nspecies = pData->NSpecies(); TH2F **hDen2D = new TH2F*[Nspecies]; for(Int_t i=0;i<Nspecies;i++) { hDen2D[i] = NULL; if(i!=index) continue; if(!pData->GetChargeFileName(i)) continue; char hName[24]; sprintf(hName,"hDen_%i",i); hDen2D[i] = (TH2F*) gROOT->FindObject(hName); if(hDen2D[i]) delete hDen2D[i]; if(!pData->Is3D()) hDen2D[i] = pData->GetCharge(i,opt); else hDen2D[i] = pData->GetCharge2DSliceZY(i,-1,Nbins,opt+"avg"); hDen2D[i]->SetName(hName); hDen2D[i]->GetXaxis()->CenterTitle(); hDen2D[i]->GetYaxis()->CenterTitle(); hDen2D[i]->GetZaxis()->CenterTitle(); hDen2D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]"); hDen2D[i]->GetYaxis()->SetTitle("y [c/#omega_{p}]"); if(i==0) hDen2D[i]->GetZaxis()->SetTitle("n_{e} [n_{0}]"); else hDen2D[i]->GetZaxis()->SetTitle("n_{b} [n_{0}]"); // ------------------------------------------------------------------------------------ } // Tunning the Histograms // --------------------- // Chaning to user units: // -------------------------- if(opt.Contains("units") && n0) { for(Int_t i=0;i<Nspecies;i++) { if(i!=index) continue; Int_t NbinsX = hDen2D[i]->GetNbinsX(); Float_t xMin = skindepth * hDen2D[i]->GetXaxis()->GetXmin() / PUnits::um; Float_t xMax = skindepth * hDen2D[i]->GetXaxis()->GetXmax() / PUnits::um; Int_t NbinsY = hDen2D[i]->GetNbinsY(); Float_t yMin = skindepth * hDen2D[i]->GetYaxis()->GetXmin() / PUnits::um; Float_t yMax = skindepth * hDen2D[i]->GetYaxis()->GetXmax() / PUnits::um; hDen2D[i]->SetBins(NbinsX,xMin,xMax,NbinsY,yMin,yMax); // for(Int_t j=0;j<hDen2D[i]->GetNbinsX();j++) { // for(Int_t k=0;k<hDen2D[i]->GetNbinsY();k++) { // hDen2D[i]->SetBinContent(j,k, hDen2D[i]->GetBinContent(j,k) * n0 / (1e15/PUnits::cm3) ); // } // } if(pData->IsCyl()) hDen2D[i]->GetYaxis()->SetTitle("r [#mum]"); else hDen2D[i]->GetYaxis()->SetTitle("y [#mum]"); if(opt.Contains("comov")) hDen2D[i]->GetXaxis()->SetTitle("#zeta [#mum]"); else hDen2D[i]->GetXaxis()->SetTitle("z [#mum]"); // if(i==0) // hDen2D[i]->GetZaxis()->SetTitle("n [10^{15}/cm^{3}]"); // else // hDen2D[i]->GetZaxis()->SetTitle("n_{b} [10^{15}/cm^{3}]"); } } // --------------------------------------------------- Vertical Zoom ------------ Float_t range = (hDen2D[index]->GetYaxis()->GetXmax() - hDen2D[index]->GetYaxis()->GetXmin())/zoom; Float_t midPoint = (hDen2D[index]->GetYaxis()->GetXmax() + hDen2D[index]->GetYaxis()->GetXmin())/2.; Double_t ymin = midPoint-range/2; Double_t ymax = midPoint+range/2; if(pData->IsCyl()) { ymin = hDen2D[index]->GetYaxis()->GetXmin(); ymax = range; } for(Int_t i=0;i<Nspecies;i++) { if(!hDen2D[i]) continue; hDen2D[i]->GetYaxis()->SetRangeUser(ymin,ymax); } // ------------- z Zoom --------------------------------- Plasma palette ----------- // Set the range of the plasma charge density histogram for maximum constrast // using a dynamic palette wich adjust the nominal value to a certain color. Float_t density = 1; Float_t Base = density; Float_t *Max = new Float_t[Nspecies]; Float_t *Min = new Float_t[Nspecies]; for(Int_t i=0;i<Nspecies;i++) { if(!hDen2D[i]) continue; Max[i] = hDen2D[i]->GetMaximum(); Min[i] = 1.01E-1 * Base; if(i==2) Min[i] = 1.01E-3 * Base; if(sim.Contains("pitz")) { if(i==0) { if(Max[i]<2) { Min[i] = Base - (Max[i] - Base); } } else if(i==1) { Min[i] = 0.501E-3 * Base; } } hDen2D[i]->GetZaxis()->SetRangeUser(Min[i],Max[i]); } // Dynamic plasma palette const Int_t plasmaDNRGBs = 3; const Int_t plasmaDNCont = 64; Double_t basePos = 0.5; if(Max[index]!=Min[index]) { if(opt.Contains("logz")) { Float_t a = 1.0/(TMath::Log10(Max[index])-TMath::Log10(Min[index])); Float_t b = TMath::Log10(Min[index]); basePos = a*(TMath::Log10(Base) - b); } else { basePos = (1.0/(Max[index]-Min[index]))*(Base - Min[index]); } } Double_t plasmaDStops[plasmaDNRGBs] = { 0.00, basePos, 1.00 }; Double_t plasmaDRed[plasmaDNRGBs] = { 0.99, 0.90, 0.00 }; Double_t plasmaDGreen[plasmaDNRGBs] = { 0.99, 0.90, 0.00 }; Double_t plasmaDBlue[plasmaDNRGBs] = { 0.99, 0.90, 0.00 }; PPalette * plasmaPalette = (PPalette*) gROOT->FindObject("plasma"); plasmaPalette->CreateGradientColorTable(plasmaDNRGBs, plasmaDStops, plasmaDRed, plasmaDGreen, plasmaDBlue, plasmaDNCont); // Plotting // ----------------------------------------------- // Canvas setup TCanvas *C; if(opt.Contains("hres") && !opt.Contains("pdf")) // high resolution for plain grahics output. C = new TCanvas("C","2D Charge",1000,625); else C = new TCanvas("C","2D Charge",800,500); // Actual Plotting! // ------------------------------------------------------------ // Output file TString fOutName = Form("./%s/Plots/Charge2D/Charge2D",sim.Data()); fOutName += Form("-%s_%i",sim.Data(),time); C->cd(); // Setup Pad layout: Float_t lMargin = 0.15; Float_t rMargin = 0.18; Float_t bMargin = 0.17; Float_t tMargin = 0.04; gPad->SetLeftMargin(lMargin); gPad->SetRightMargin(rMargin); gPad->SetBottomMargin(bMargin); gPad->SetTopMargin(tMargin); // Text objects Float_t y1 = gPad->GetBottomMargin(); Float_t y2 = 1 - gPad->GetTopMargin(); Float_t x1 = gPad->GetLeftMargin(); Float_t x2 = 1 - gPad->GetRightMargin(); TPaveText *textTime = new TPaveText(x2-0.17,y2-0.12,x2-0.02,y2-0.02,"NDC"); PlasmaGlob::SetPaveTextStyle(textTime,32); char ctext[128]; if(opt.Contains("units") && n0) sprintf(ctext,"z = %5.1f #mum", Time * skindepth / PUnits::um); else sprintf(ctext,"t = %5.1f #omega_{p}^{-1}",Time); textTime->AddText(ctext); TPaveText *textDen = new TPaveText(x1+0.02,y2-0.12,x1+0.22,y2-0.02,"NDC"); PlasmaGlob::SetPaveTextStyle(textDen,12); textDen->SetTextColor(kOrange+10); if(opt.Contains("units") && n0) sprintf(ctext,"n_{0} = %5.2f x 10^{17} / cm^{3}", 1e-17 * n0 * PUnits::cm3); else if(pData->GetBeamDensity() && n0) sprintf(ctext,"n_{b}/n_{0} = %5.2f", pData->GetBeamDensity()/n0); textDen->AddText(ctext); if(opt.Contains("logz")) { gPad->SetLogz(1); } else { gPad->SetLogz(0); } gPad->SetFrameLineWidth(3); TH2F *hFrame = (TH2F*) gROOT->FindObject("hFrame1"); if(hFrame) delete hFrame; hFrame = (TH2F*) hDen2D[index]->Clone("hFrame1"); hFrame->Reset(); hFrame->GetXaxis()->SetTitleSize(0.07); hFrame->GetXaxis()->SetLabelSize(0.065); hFrame->GetXaxis()->SetLabelOffset(0.02); hFrame->GetXaxis()->SetTitleOffset(1.0); hFrame->GetYaxis()->SetTitleSize(0.07); hFrame->GetYaxis()->SetTitleOffset(1.0); hFrame->GetYaxis()->SetLabelSize(0.065); hFrame->GetYaxis()->SetLabelOffset(0.02); hFrame->GetYaxis()->SetTickLength(0.02); hFrame->Draw("col"); hDen2D[index]->GetZaxis()->SetTitleSize(0.06); hDen2D[index]->GetZaxis()->SetTitleOffset(1.0); hDen2D[index]->GetZaxis()->SetLabelSize(0.06); hDen2D[index]->GetZaxis()->SetTickLength(0.02); // hDen2D[index]->GetZaxis()->SetNdivisions(505); hDen2D[index]->Draw("colz same"); gPad->Update(); textTime->Draw(); textDen->Draw(); gPad->RedrawAxis(); C->cd(); // Print to a file PlasmaGlob::imgconv(C,fOutName,opt); // --------------------------------------------------------- }
void PlotVectorPotential( const TString &sim, Int_t timestep, const TString &options="") { #ifdef __CINT__ gSystem->Load("libptools.so"); #endif PData *pData = PData::Get(sim.Data()); if(pData->isHiPACE()) { delete pData; pData = NULL; pData = PDataHiP::Get(sim.Data()); } pData->LoadFileNames(timestep); if(!pData->IsInit()) return; PGlobals::Initialize(); TString opt = options; // Open snapshot file and get the histograms TString filename; filename = Form("./%s/Plots/Snapshots/Snapshot-%s_%i.root",sim.Data(),sim.Data(),timestep); TFile *ifile = (TFile*) gROOT->GetListOfFiles()->FindObject(filename.Data()); if (!ifile) ifile = new TFile(filename,"READ"); ifile->cd(); // Time in OU Double_t Time = pData->GetRealTime(); cout << Form(" Getting histos..." ); // Electron density (plasma) char hName[36]; sprintf(hName,"hDen2D_0"); TH2F *hDen2D = (TH2F*) ifile->Get(hName); // Electron density species 2 (if any) sprintf(hName,"hDen2D_1"); TH2F *hDen2D_1 = (TH2F*) ifile->Get(hName); if(hDen2D_1) hDen2D->Add(hDen2D_1,1); // Electron density species 3 (if any) sprintf(hName,"hDen2D_2"); TH2F *hDen2D_2 = (TH2F*) ifile->Get(hName); if(hDen2D_2) hDen2D->Add(hDen2D_2,1); cout << Form(" done!" ) << endl; // Get the sliced 1D histograms Int_t NBinsZ = hDen2D->GetXaxis()->GetNbins(); Float_t zmin = hDen2D->GetXaxis()->GetBinLowEdge(1); Float_t zmax = hDen2D->GetXaxis()->GetBinUpEdge(NBinsZ); Float_t zrange = zmax-zmin; Int_t NBinsX = hDen2D->GetYaxis()->GetNbins(); Float_t xmin = hDen2D->GetYaxis()->GetBinLowEdge(1); Float_t xmax = hDen2D->GetYaxis()->GetBinUpEdge(NBinsX); Float_t xrange = xmax-xmin; // cout << Form(" Creating 2D histos..." ); // cout << Form(" done!" ) << endl; cout << Form(" Allocating array with real data..." ); Int_t dims[2] = {NBinsZ,NBinsX}; Double_t *data = new Double_t[NBinsZ*NBinsX]; // TVirtualFFT::SetTransform(0); cout << Form(" done!" ) << endl; cout << Form(" Filling data aray..." ); for(Int_t i=0; i<NBinsZ; i++) { for(Int_t j=0; j<NBinsX; j++) { Int_t index = i * NBinsX + j; data[index] = hDen2D->GetBinContent(i+1,j+1); // substract ion background data[index] -= 1; } } cout << Form(" done!" ) << endl; cout << Form(" Fourier transform ..." ); // TH2F *hFFTREb = new TH2F("hFFTREb","",NBinsZ,kzmin,kzmax,NBinsX,kxmin,kxmax); // TH2F *hFFTIMb = new TH2F("hFFTIMb","",NBinsZ,kzmin,kzmax,NBinsX,kxmin,kxmax); // TH2F *hFFTREb = new TH2F("hFFTREb","",NBinsZ,0.,NBinsZ,NBinsX,0.,NBinsX); // TH2F *hFFTIMb = new TH2F("hFFTIMb","",NBinsZ,0.,NBinsZ,NBinsX,0.,NBinsX); // TH2F *hFFTRE = 0; // hFFTRE = (TH2F*) TH1::TransformHisto(fft, hFFTRE, "RE"); // hFFTRE->SetName("hFFTRE"); // TH2F *hFFTIM = 0; // hFFTIM = (TH2F*) TH1::TransformHisto(fft, hFFTIM, "IM"); // hFFTIM->SetName("hFFTIM"); TVirtualFFT *fft = TVirtualFFT::FFT(2, dims, "R2C ES K"); fft->SetPoints(data); fft->Transform(); cout << Form(" done!" ) << endl; cout << Form(" Solving equation for potential in fourier space" ) << endl; // \phi(kz,kx) = 1/(kz^2 + kx^2) fft->GetPoints(data); for(Int_t i=0; i<dims[0]; i++) { for(Int_t j=0; j<(dims[1]/2+1); j++) { Int_t index = 2 * (i * (dims[1]/2+1) + j); Float_t kz; if(i<dims[0]/2) kz = TMath::Pi() * (i+0.5) / zrange; else kz = -TMath::Pi() * (dims[0]-i+0.5) / zrange; Float_t kx = TMath::TwoPi() * (j+0.5) / xrange; Float_t k2 = kx*kx + kz*kz; data[index] /= k2; data[index+1] /= k2; } } cout << Form(" done!" ) << endl; cout << Form(" Inverse Fourier transform ..." ); // backward transform: TVirtualFFT *fft_back = TVirtualFFT::FFT(2, dims, "C2R ES K"); fft_back->SetPoints(data); fft_back->Transform(); cout << Form(" done!" ) << endl; Double_t *re_back = fft_back->GetPointsReal(); TH2F *hPhi2D = new TH2F("hPhi2D","",NBinsZ,zmin,zmax,NBinsX,xmin,xmax); TH2F *hE2D_1_ifft = new TH2F("hE2D_1_ifft","",NBinsZ,zmin,zmax,NBinsX,xmin,xmax); Double_t dx = hPhi2D->GetYaxis()->GetBinWidth(1); for(Int_t i=0; i<NBinsZ; i++) { for(Int_t j=0; j<NBinsX; j++) { Int_t index = i * NBinsX + j; hPhi2D->SetBinContent(i+1,j+1,re_back[index]); Double_t der = 0.; if(j>2 && j<=NBinsX-2) { Int_t indjp1 = i * NBinsX + (j+1); Int_t indjp2 = i * NBinsX + (j+2); Int_t indjm1 = i * NBinsX + (j-1); Int_t indjm2 = i * NBinsX + (j-2); der = ( 4.0 / 3.0 * (re_back[indjp1] - re_back[indjm1]) / (2.0 * dx) - 1.0 / 3.0 * (re_back[indjp2] - re_back[indjm2]) / (4.0 * dx) ); } hE2D_1_ifft->SetBinContent(i+1,j+1,der); } } hPhi2D->Scale(1.0/(NBinsZ*NBinsX)); hE2D_1_ifft->Scale(1.0/(NBinsZ*NBinsX)); TH2F *hE2D_0_ifft = new TH2F("hE2D_0_ifft","",NBinsZ,zmin,zmax,NBinsX,xmin,xmax); Double_t dz = hPhi2D->GetXaxis()->GetBinWidth(1); for(Int_t j=0; j<NBinsX; j++) { for(Int_t i=0; i<NBinsZ; i++) { Double_t der = 0.; if(i>2 && j<=NBinsZ-2) { Int_t indip1 = (i+1) * NBinsX + j; Int_t indip2 = (i+2) * NBinsX + j; Int_t indim1 = (i-1) * NBinsX + j; Int_t indim2 = (i-2) * NBinsX + j; der = ( 4.0 / 3.0 * (re_back[indip1] - re_back[indim1]) / (2.0 * dz) - 1.0 / 3.0 * (re_back[indip2] - re_back[indim2]) / (4.0 * dz) ); } hE2D_0_ifft->SetBinContent(i+1,j+1,der); } } hE2D_0_ifft->Scale(1.0/(NBinsZ*NBinsX)); // TH2F *hPhi2D = 0; // hPhi2D = (TH2F*) TH1::TransformHisto(fft_back, hPhi2D, "RE"); // hPhi2D->SetName("hPhi2D"); }
void DoEvolutions( const TString &sim, Int_t time, Int_t Nbins=1, const TString &options="") { #ifdef __CINT__ gSystem->Load("libptools.so"); #endif PGlobals::Initialize(); // Palettes! gROOT->Macro("PPalettes.C"); TString opt = options; // cout << "options = " << opt << endl; // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; Bool_t CYL = kFALSE; if(sim.Contains("cyl")) { CYL = kTRUE; opt += "cyl"; } Bool_t ThreeD = kFALSE; if(sim.Contains("3D")) ThreeD = kTRUE; // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.0; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Some initial beam properties: Float_t Ebeam = pData->GetBeamEnergy() * PUnits::MeV; Float_t gamma = pData->GetBeamGamma(); Float_t vbeam = pData->GetBeamVelocity(); Double_t rms0 = pData->GetBeamRmsY() * kp; if(CYL) rms0 = pData->GetBeamRmsR() * kp; // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart() * kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart() * kp; if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } // Beam charge 2D and 1D histogram (on-axis) // ------------------------------------------------------------------ TH2F *hDen2D = NULL; if(pData->GetChargeFileName(1)) { char hName[24]; sprintf(hName,"hDen2D"); hDen2D = (TH2F*) gROOT->FindObject(hName); if(hDen2D) { delete hDen2D; hDen2D = NULL; } if(!ThreeD) hDen2D = pData->GetCharge(1,opt); else hDen2D = pData->GetCharge2DSliceZY(1,-1,1,opt+"avg"); hDen2D->SetName(hName); hDen2D->GetXaxis()->CenterTitle(); hDen2D->GetYaxis()->CenterTitle(); hDen2D->GetZaxis()->CenterTitle(); if(opt.Contains("comov")) hDen2D->GetXaxis()->SetTitle("k_{p}#zeta"); else hDen2D->GetXaxis()->SetTitle("k_{p}z"); if(CYL) hDen2D->GetYaxis()->SetTitle("k_{p}r"); else hDen2D->GetYaxis()->SetTitle("k_{p}y"); hDen2D->GetZaxis()->SetTitle("n_{b}/n_{0}"); } // Define ranges from the charge 2D histogram: // Binning for 2D histograms: // We get this values from the 2D density histogram. Int_t x1Nbin = hDen2D->GetNbinsX(); Float_t x1Range = (hDen2D->GetXaxis()->GetXmax() - hDen2D->GetXaxis()->GetXmin()); Float_t x1Mid = (hDen2D->GetXaxis()->GetXmax() + hDen2D->GetXaxis()->GetXmin())/2.; Float_t x1Min = hDen2D->GetXaxis()->GetXmin(); Float_t x1Max = hDen2D->GetXaxis()->GetXmax(); Int_t x2Nbin = hDen2D->GetNbinsY(); Float_t x2Range = (hDen2D->GetYaxis()->GetXmax() - hDen2D->GetYaxis()->GetXmin()); Float_t x2Mid = (hDen2D->GetYaxis()->GetXmax() + hDen2D->GetYaxis()->GetXmin())/2.; Float_t x2Min = x2Mid - x2Range/2; Float_t x2Max = x2Mid + x2Range/2; if(Nbins==0) { Nbins = TMath::Nint(rms0 / hDen2D->GetYaxis()->GetBinWidth(1)) ; // cout << Form(" Rms0 = %6.2f Dx = %6.2f Nbins = %4i .", // rms0, hDen2D->GetYaxis()->GetBinWidth(1), Nbins) << endl; } // Slice width limits. Int_t FirstyBin = 0; Int_t LastyBin = 0; if(!CYL) { FirstyBin = hDen2D->GetNbinsY()/2 + 1 - Nbins; LastyBin = hDen2D->GetNbinsY()/2 + Nbins; } else { FirstyBin = 1; LastyBin = Nbins; } // OUTPUT ROOT FILE WITH THE PLOTS: TString filename = Form("./%s/Plots/Evolutions/Evolutions-%s.root",sim.Data(),sim.Data()); TFile * ifile = (TFile*) gROOT->GetListOfFiles()->FindObject(filename); // if doesn't exist the directory should be created if (!ifile) { TString f = filename; TString dir2 = f.Remove( f.Last( '/' ), f.Length() - f.Last( '/' ) ); TString dir1 = f.Remove( f.Last( '/' ), f.Length() - f.Last( '/' ) ); gSystem->mkdir( dir1 ); gSystem->mkdir( dir2 ); ifile = new TFile(filename,"UPDATE"); } // Charge 1D histogram on axis TH1F *hDen1D = NULL; if(pData->GetChargeFileName(1)) { TString opth1 = opt; opth1 += "avg"; char hName[24]; sprintf(hName,"hDen1D"); hDen1D = (TH1F*) gROOT->FindObject(hName); if(hDen1D) delete hDen1D; if(ThreeD) { hDen1D = pData->GetH1SliceZ3D(pData->GetChargeFileName(1)->c_str(),"charge",-1,Nbins,-1,Nbins,opth1.Data()); } else if(CYL) { // Cylindrical: The first bin with r>0 is actually the number 1 (not the 0). hDen1D = pData->GetH1SliceZ(pData->GetChargeFileName(1)->c_str(),"charge",1,Nbins,opth1.Data()); } else { // 2D cartesian hDen1D = pData->GetH1SliceZ(pData->GetChargeFileName(1)->c_str(),"charge",-1,Nbins,opth1.Data()); } hDen1D->SetName(hName); if(opt.Contains("comov")) hDen1D->GetXaxis()->SetTitle("k_{p}#zeta"); else hDen1D->GetXaxis()->SetTitle("k_{p}z"); hDen1D->GetYaxis()->SetTitle("n_{b}/n_{0}"); } // On-axis beam density vs \zeta vs time! _________________________________ TH2F *hDen1DvsTime = NULL; if(hDen1D) { char hName[24]; sprintf(hName,"hDen1DvsTime"); TH2F *hDen1DvsTimeOld = (TH2F*) ifile->Get(hName); Int_t nBins = 1; Float_t edge0 = Time-0.5; Float_t edge1 = Time+0.5; if(hDen1DvsTimeOld!=NULL) { nBins = hDen1DvsTimeOld->GetNbinsX()+1; Float_t binwidth = (Time - hDen1DvsTimeOld->GetXaxis()->GetBinCenter(1))/(nBins-1); edge0 = hDen1DvsTimeOld->GetXaxis()->GetBinCenter(1) - binwidth/2.; edge1 = Time + binwidth/2.; } hDen1DvsTime = new TH2F("temp","",nBins,edge0,edge1, hDen1D->GetNbinsX(), hDen1D->GetBinLowEdge(1), hDen1D->GetBinLowEdge(hDen1D->GetNbinsX()+1)); for(Int_t ix=1;ix<hDen1DvsTime->GetNbinsX();ix++) { for(Int_t iy=1;iy<hDen1DvsTime->GetNbinsY();iy++) { hDen1DvsTime->SetBinContent(ix,iy,hDen1DvsTimeOld->GetBinContent(ix,iy)); } } delete hDen1DvsTimeOld; // Fill last bin with the newest values. for(Int_t iy=1;iy<=hDen1D->GetNbinsX();iy++) { hDen1DvsTime->SetBinContent(nBins,iy,hDen1D->GetBinContent(iy)); } hDen1DvsTime->GetZaxis()->SetTitle("n_{b}/n_{0}"); hDen1DvsTime->GetYaxis()->SetTitle("k_{p}#zeta"); hDen1DvsTime->GetXaxis()->SetTitle("k_{p}z"); hDen1DvsTime->GetZaxis()->CenterTitle(); hDen1DvsTime->GetYaxis()->CenterTitle(); hDen1DvsTime->GetXaxis()->CenterTitle(); hDen1DvsTime->SetName(hName); // Change the range of z axis Float_t Denmax = hDen1DvsTime->GetMaximum(); hDen1DvsTime->GetZaxis()->SetRangeUser(0,Denmax); hDen1DvsTime->Write(hName,TObject::kOverwrite); } // RMS (vs z) of the beam's charge distribution: TProfile *hDen2Dprof = NULL; TH1F *hRms = NULL; Double_t axisPos = x2Mid; if(hDen2D) { TString pname = hDen2D->GetName(); pname += "_pfx"; hDen2Dprof = (TProfile*) gROOT->FindObject(pname.Data()); if(hDen2Dprof) { delete hDen2Dprof; hDen2Dprof = NULL; } hDen2Dprof = hDen2D->ProfileX("_pfx",1,-1,"s"); hRms = (TH1F*) gROOT->FindObject("hRms"); if(hRms) delete hRms; hRms = new TH1F("hRms","",x1Nbin,x1Min,x1Max); if(CYL) axisPos = 0.0; for(Int_t j=0;j<hRms->GetNbinsX();j++) { Double_t rms = 0; Double_t total = 0; for(Int_t k=1;k<=x2Nbin;k++) { Double_t value = hDen2D->GetBinContent(j,k); Double_t radius = hDen2D->GetYaxis()->GetBinCenter(k) - axisPos; if(CYL) { rms += radius*radius*radius*value; total += radius*value; } else { rms += radius*radius*value; total += value; } // cout << Form(" (%i,%i) -> radius = %7.4f , density = %7.4f",j,k,radius,value) << endl; } rms /= total; rms = sqrt(rms); hRms->SetBinContent(j,rms); } hRms->GetXaxis()->SetTitle("k_{p}z"); if(opt.Contains("comov")) hRms->GetXaxis()->SetTitle("k_{p}#zeta"); hRms->GetYaxis()->SetTitle("k_{p}#LTr#GT_{rms}"); } // Transverse charge RMS vs \zeta vs time! _________________________________ TH2F *hRmsvsTime = NULL; if(hRms) { char hName[24]; sprintf(hName,"hRmsvsTime"); TH2F *hRmsvsTimeOld = (TH2F*) ifile->Get(hName); Int_t nBins = 1; Float_t edge0 = Time-0.5; Float_t edge1 = Time+0.5; if(hRmsvsTimeOld!=NULL) { nBins = hRmsvsTimeOld->GetNbinsX()+1; Float_t binwidth = (Time - hRmsvsTimeOld->GetXaxis()->GetBinCenter(1))/(nBins-1); edge0 = hRmsvsTimeOld->GetXaxis()->GetBinCenter(1) - binwidth/2.; edge1 = Time + binwidth/2.; } hRmsvsTime = new TH2F("temp","",nBins,edge0,edge1, hRms->GetNbinsX(), hRms->GetBinLowEdge(1), hRms->GetBinLowEdge(hRms->GetNbinsX()+1)); for(Int_t ix=1;ix<hRmsvsTime->GetNbinsX();ix++) { for(Int_t iy=1;iy<hRmsvsTime->GetNbinsY();iy++) { hRmsvsTime->SetBinContent(ix,iy,hRmsvsTimeOld->GetBinContent(ix,iy)); } } delete hRmsvsTimeOld; // Fill last bin with the newest values. for(Int_t iy=1;iy<=hRms->GetNbinsX();iy++) { hRmsvsTime->SetBinContent(nBins,iy,hRms->GetBinContent(iy)); } hRmsvsTime->GetZaxis()->SetTitle("#LTr#GT_{rms}"); hRmsvsTime->GetYaxis()->SetTitle("k_{p}#zeta"); hRmsvsTime->GetXaxis()->SetTitle("k_{p}z"); hRmsvsTime->GetZaxis()->CenterTitle(); hRmsvsTime->GetYaxis()->CenterTitle(); hRmsvsTime->GetXaxis()->CenterTitle(); hRmsvsTime->SetName(hName); // Change the range of z axis Float_t Rmsmax = hRmsvsTime->GetMaximum(); hRmsvsTime->GetZaxis()->SetRangeUser(0,Rmsmax); hRmsvsTime->Write(hName,TObject::kOverwrite); } // INTEGRATED Beam's Charge: // Total charge vs time : TGraph *gQvsTime = NULL; if(hDen2D) { Double_t Q = 0; for(Int_t i=1;i<=x1Nbin;i++) { for(Int_t j=1;j<=x2Nbin;j++) { Double_t value = hDen2D->GetBinContent(i,j); if(CYL) { Double_t radius = hDen2D->GetYaxis()->GetBinCenter(j); Q += radius * value; // cout << Form(" (%i,%i) -> radius = %7.4f , value = %7.4f",i,j,radius,value) << endl; } else { Q += value; } } } Double_t xbinsize = hDen2D->GetXaxis()->GetBinWidth(1); Double_t ybinsize = hDen2D->GetYaxis()->GetBinWidth(1); Q *= xbinsize * ybinsize; if(!CYL && !ThreeD) { Q *= TMath::Sqrt(2*TMath::Pi()) * rms0; } else if(CYL) { Q *= 2*TMath::Pi(); } if(opt.Contains("units")) { Double_t dV = skindepth * skindepth * skindepth; Q *= n0 * dV; Q *= (PConst::ElectronCharge/PUnits::picocoulomb); cout << Form(" Integrated charge = %8i pC", TMath::Nint(Q)) << endl; } else { cout << Form(" Integrated charge = %8.4f n0 * kp^-3",Q) << endl; } Int_t nPoints = 0; char gName[32]; sprintf(gName,"gQvsTime"); gQvsTime = (TGraph*) ifile->Get(gName); if(gQvsTime==NULL) { gQvsTime = new TGraph(); gQvsTime->SetName(gName); nPoints = 0; // Some cosmetics at creation time: gQvsTime->SetLineWidth(3); gQvsTime->SetLineColor(PGlobals::fieldLine); gQvsTime->SetMarkerStyle(20); gQvsTime->SetMarkerSize(0.4); gQvsTime->SetMarkerColor(PGlobals::fieldLine); gQvsTime->GetYaxis()->SetTitle("charge [n_{0}/k_{p}^{3}]"); gQvsTime->GetXaxis()->SetTitle("k_{p}z"); } else { nPoints = gQvsTime->GetN(); } gQvsTime->Set(nPoints+1); gQvsTime->SetPoint(nPoints,Time,Q); gQvsTime->Write(gName,TObject::kOverwrite); } // ------------------------------------------------------------------------------------ // Longitudinal phasespace Int_t gNbin = 100; // Float_t gMin = 80; // Float_t gMax = 120; Float_t gMin = 43.07 - 1.2; Float_t gMax = 43.07 + 1.2; TH2F *hGvsZ = NULL; if(pData->GetRawFileName(1)) { char hName[24]; sprintf(hName,"hGvsZ"); hGvsZ = (TH2F*) gROOT->FindObject(hName); if(hGvsZ) { delete hGvsZ; hGvsZ = NULL; } hGvsZ = new TH2F(hName,"",x1Nbin,x1Min,x1Max,gNbin,gMin,gMax); pData->GetH2Raw(pData->GetRawFileName(1)->c_str(),"x1","gamma",hGvsZ,opt); hGvsZ->GetXaxis()->CenterTitle(); hGvsZ->GetYaxis()->CenterTitle(); hGvsZ->GetZaxis()->CenterTitle(); hGvsZ->GetYaxis()->SetTitle("#gamma"); if(opt.Contains("comov")) { hGvsZ->GetXaxis()->SetTitle("k_{p}#zeta"); hGvsZ->GetZaxis()->SetTitle("dN/d#zetad#gamma [a.u.]"); } else { hGvsZ->GetXaxis()->SetTitle("k_{p}z"); hGvsZ->GetZaxis()->SetTitle("dN/dzd#gamma [a.u.]"); } } else { cout << Form("--> No RAW data file is present for species 1") << endl; } TH2F *hGvsTime = NULL; TProfile *hGvsZprof = NULL; TGraphErrors *gGvsZ = NULL; if(hGvsZ) { TString pname = hGvsZ->GetName(); pname += "_pfx"; hGvsZprof = (TProfile*) gROOT->FindObject(pname.Data()); if(hGvsZprof) delete hGvsZprof; hGvsZprof = hGvsZ->ProfileX("_pfx",1,-1,"s"); gGvsZ = (TGraphErrors*) gROOT->FindObject("gGvsZ"); if(gGvsZ) delete gGvsZ; Int_t Npoints = hGvsZprof->GetNbinsX(); Double_t *x = new Double_t[Npoints]; Double_t *y = new Double_t[Npoints]; Double_t *ex = new Double_t[Npoints]; Double_t *ey = new Double_t[Npoints]; for(Int_t j=0;j<Npoints;j++) { x[j] = hGvsZprof->GetBinCenter(j); y[j] = hGvsZprof->GetBinContent(j); ex[j] = 0; ey[j] = hGvsZprof->GetBinError(j); } gGvsZ = new TGraphErrors(Npoints,x,y,ex,ey); gGvsZ->SetName("gGvsZ"); // PGlobals::SetH1Style((TH1*)gGvsZ,1); PGlobals::SetGraphStyle(gGvsZ,1); if(opt.Contains("comov")) gGvsZ->GetXaxis()->SetTitle("k_{p}#zeta"); else gGvsZ->GetXaxis()->SetTitle("k_{p}z"); gGvsZ->GetYaxis()->SetTitle("#LT#gamma#GT [MeV]"); char hName[24]; sprintf(hName,"hGvsTime"); TH2F *hGvsTimeOld = (TH2F*) ifile->Get(hName); Int_t nBins = 1; Float_t edge0 = Time-0.5; Float_t edge1 = Time+0.5; if(hGvsTimeOld!=NULL) { nBins = hGvsTimeOld->GetNbinsX()+1; Float_t binwidth = (Time - hGvsTimeOld->GetXaxis()->GetBinCenter(1))/(nBins-1); edge0 = hGvsTimeOld->GetXaxis()->GetBinCenter(1) - binwidth/2.; edge1 = Time + binwidth/2.; } hGvsTime = new TH2F("temp","",nBins,edge0,edge1, hGvsZprof->GetNbinsX(), hGvsZprof->GetBinLowEdge(1), hGvsZprof->GetBinLowEdge(hGvsZprof->GetNbinsX()+1)); for(Int_t ix=1;ix<hGvsTime->GetNbinsX();ix++) { for(Int_t iy=1;iy<hGvsTime->GetNbinsY();iy++) { hGvsTime->SetBinContent(ix,iy,hGvsTimeOld->GetBinContent(ix,iy)); } } delete hGvsTimeOld; // Fill last bin with the newest values. for(Int_t iy=1;iy<=hGvsZprof->GetNbinsX();iy++) { hGvsTime->SetBinContent(nBins,iy,hGvsZprof->GetBinContent(iy)); } hGvsTime->GetZaxis()->SetTitle("#LT#gamma#GT"); hGvsTime->GetYaxis()->SetTitle("k_{p}#zeta"); hGvsTime->GetXaxis()->SetTitle("k_{p}z"); hGvsTime->GetZaxis()->CenterTitle(); hGvsTime->GetYaxis()->CenterTitle(); hGvsTime->GetXaxis()->CenterTitle(); hGvsTime->SetName(hName); // Change the range of z axis Float_t Gmax = hGvsTime->GetMaximum(); Float_t Gmin = hGvsTime->GetMinimum(); hGvsTime->GetZaxis()->SetRangeUser(Gmin,Gmax); hGvsTime->Write(hName,TObject::kOverwrite); } // --------------------------------------------------------------------------------- // EM fields on - axis : TString opth1 = opt; opth1 += "avg"; // Get electric fields const Int_t Nfields = 2; TH1F **hE1D = new TH1F*[Nfields]; for(Int_t i=0;i<Nfields;i++) { hE1D[i] = NULL; if(!pData->GetEfieldFileName(i)) continue; char nam[3]; sprintf(nam,"e%i",i+1); if(ThreeD) { if(i==0) hE1D[i] = pData->GetH1SliceZ3D(pData->GetEfieldFileName(i)->c_str(),nam,-1,Nbins,-1,Nbins,opth1.Data()); else hE1D[i] = pData->GetH1SliceZ3D(pData->GetEfieldFileName(i)->c_str(),nam,-Nbins,Nbins,-Nbins,Nbins,opth1.Data()); } else if(CYL) { // Cylindrical: The first bin with r>0 is actually the number 1 (not the 0). if(i==0) hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,1,Nbins,opth1.Data()); else hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,1,Nbins,opth1.Data()); } else { // 2D cartesian if(i==0) hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,-1,Nbins,opth1.Data()); else hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,-Nbins,Nbins,opth1.Data()); } char hName[24]; sprintf(hName,"hE_%i_%i",i,time); hE1D[i]->SetName(hName); if(opt.Contains("comov")) hE1D[i]->GetXaxis()->SetTitle("k_{p}#zeta"); else hE1D[i]->GetXaxis()->SetTitle("k_{p}z"); if(i==0) hE1D[i]->GetYaxis()->SetTitle("E_{z}/E_{0}"); else if(i==1) hE1D[i]->GetYaxis()->SetTitle("E_{y}/E_{0}"); else if(i==2) hE1D[i]->GetYaxis()->SetTitle("E_{x}/E_{0}"); hE1D[i]->GetYaxis()->CenterTitle(); hE1D[i]->GetXaxis()->CenterTitle(); } // Calculate wave positions: // ---------------------------------------------------------------- // Calculate the crossings and the extremes of the Electric fields Float_t Ecross[Nfields][100] = {{0.0}}; Float_t Eextr[Nfields][100] = {{0.0}}; Int_t Ncross[Nfields] = {0}; for(Int_t i=0;i<Nfields;i++) { Ncross[i] = 0; if(!hE1D[i]) continue; // Only smooths the focusing if flag activated.. if(i>0 && opt.Contains("smooth")) { // cout << " Smoothing fields on axis..." << endl; hE1D[i]->Smooth(10); } Float_t maxZeta = zStartBeam; if(opt.Contains("center")) maxZeta -= zStartBeam; for(Int_t ip=hE1D[i]->GetNbinsX();ip>1;ip--) { Float_t Z2 = hE1D[i]->GetBinCenter(ip-1); if(Z2 > maxZeta) continue; Float_t E1 = hE1D[i]->GetBinContent(ip); Float_t E2 = hE1D[i]->GetBinContent(ip-1); Float_t Z1 = hE1D[i]->GetBinCenter(ip); // cout << Form("Z1 = %6.4f Z2 = %6.4f E1 = %6.4f E2 = %6.4f", Z1, Z2, E1, E2) << endl; if(E1*E2 >= 0) { // No change of sign means we are in a side of the zero axis. if(fabs(E2)>fabs(Eextr[i][Ncross[i]])) { Eextr[i][Ncross[i]] = E2; } } if(E1*E2 < 0) { // change of sign means a crossing! // The next crossing has to be far enough from the previous one: Float_t zcross = -E1 * ( (Z2-Z1)/(E2-E1) ) + Z1; if(Ncross[i]>0 && fabs(Ecross[i][Ncross[i]-1]-zcross)<TMath::PiOver2() ) continue; // cout << " CROSS! " << endl; // add the point Ecross[i][Ncross[i]] = zcross; Ncross[i]++; } } cout << " -> Number of crossings for field " << i << " : " << Ncross[i] << endl; for(Int_t ic=0;ic<Ncross[i];ic++) { // cout << Form(" %2i: zeta = %6.4f E = %6.4f", ic, Ecross[i][ic], Eextr[i][ic]) << endl; } hE1D[i]->SetLineColor(kRed); hE1D[i]->Write(hE1D[i]->GetName(),TObject::kOverwrite); } // Get the Graphs and histos from file Int_t nPoints = 0; TGraph ***gEcross = new TGraph**[Nfields]; TGraph ***gEextr = new TGraph**[Nfields]; TH2F **hEvsTime = new TH2F*[Nfields]; for(Int_t i=0;i<Nfields;i++) { char hName[24]; sprintf(hName,"hEvsTime_%i",i); TH2F *hEvsTimeOld = (TH2F*) ifile->Get(hName); Int_t nBins = 1; Float_t edge0 = Time-0.5; Float_t edge1 = Time+0.5; if(hEvsTimeOld!=NULL) { nBins = hEvsTimeOld->GetNbinsX()+1; Float_t binwidth = (Time - hEvsTimeOld->GetXaxis()->GetBinCenter(1))/(nBins-1); edge0 = hEvsTimeOld->GetXaxis()->GetBinCenter(1) - binwidth/2.; edge1 = Time + binwidth/2.; } hEvsTime[i] = new TH2F("temp","",nBins,edge0,edge1, hE1D[i]->GetNbinsX(), hE1D[i]->GetBinLowEdge(1), hE1D[i]->GetBinLowEdge(hE1D[i]->GetNbinsX()+1)); for(Int_t ix=1;ix<hEvsTime[i]->GetNbinsX();ix++) { for(Int_t iy=1;iy<hEvsTime[i]->GetNbinsY();iy++) { hEvsTime[i]->SetBinContent(ix,iy,hEvsTimeOld->GetBinContent(ix,iy)); } } delete hEvsTimeOld; // Fill last bin with the newest values. for(Int_t iy=1;iy<=hE1D[i]->GetNbinsX();iy++) { hEvsTime[i]->SetBinContent(nBins,iy,hE1D[i]->GetBinContent(iy)); } if(i==0) hEvsTime[i]->GetZaxis()->SetTitle("E_{z}/E_{0}"); else if(i==1) hEvsTime[i]->GetZaxis()->SetTitle("E_{y}/E_{0}"); else if(i==2) hEvsTime[i]->GetZaxis()->SetTitle("E_{x}/E_{0}"); hEvsTime[i]->GetYaxis()->SetTitle("k_{p}#zeta"); hEvsTime[i]->GetXaxis()->SetTitle("k_{p}z"); hEvsTime[i]->GetZaxis()->CenterTitle(); hEvsTime[i]->GetYaxis()->CenterTitle(); hEvsTime[i]->GetXaxis()->CenterTitle(); hEvsTime[i]->SetName(hName); // Change the range of z axis for the fields to be symmetric. Float_t Emax = hEvsTime[i]->GetMaximum(); Float_t Emin = hEvsTime[i]->GetMinimum(); if(Emax > TMath::Abs(Emin)) Emin = -Emax; else Emax = -Emin; hEvsTime[i]->GetZaxis()->SetRangeUser(Emin,Emax); hEvsTime[i]->Write(hName,TObject::kOverwrite); // --- gEcross[i] = new TGraph*[Ncross[i]]; gEextr[i] = new TGraph*[Ncross[i]]; char gName[24]; Int_t ifail = 0; for(Int_t ic=0;ic<Ncross[i];ic++) { sprintf(gName,"gEcross_%i_%i",i,ic); gEcross[i][ic] = (TGraph*) ifile->Get(gName); if(gEcross[i][ic]==NULL) { gEcross[i][ic] = new TGraph(); gEcross[i][ic]->SetName(gName); nPoints = 0; // Some cosmetics at creation time: if(i==1) gEcross[i][ic]->SetLineStyle(2); else gEcross[i][ic]->SetLineStyle(1); gEcross[i][ic]->SetLineWidth(1); gEcross[i][ic]->SetLineColor(kGray+1); gEcross[i][ic]->SetMarkerStyle(20); gEcross[i][ic]->SetMarkerSize(0.4); gEcross[i][ic]->SetMarkerColor(kGray+1); gEcross[i][ic]->GetYaxis()->SetTitle("k_{p}#zeta]"); gEcross[i][ic]->GetXaxis()->SetTitle("k_{p}z"); } else { nPoints = gEcross[i][ic]->GetN(); } // Check the new crossings respect the previous ones: // Double_t t,zeta; // if(nPoints>0) { // gEcross[i][ic]->GetPoint(nPoints-1,t,zeta); // if(fabs(zeta-Ecross[i][ic+ifail])>TMath::Pi()) { // ic--; // ifail++; // continue; // } // } gEcross[i][ic]->Set(nPoints+1); gEcross[i][ic]->SetPoint(nPoints,Time,Ecross[i][ic+ifail]); gEcross[i][ic]->Write(gName,TObject::kOverwrite); // if(ic==Ncross[i]-1) continue; sprintf(gName,"gEextr_%i_%i",i,ic); gEextr[i][ic] = (TGraph*) ifile->Get(gName); if(gEextr[i][ic]==NULL) { gEextr[i][ic] = new TGraph(); gEextr[i][ic]->SetName(gName); nPoints = 0; // Some cosmetics at creation time: if(i==0) { gEextr[i][ic]->SetLineWidth(3); gEextr[i][ic]->SetLineColor(PGlobals::fieldLine); gEextr[i][ic]->SetMarkerStyle(20); gEextr[i][ic]->SetMarkerSize(0.4); gEextr[i][ic]->SetMarkerColor(PGlobals::fieldLine); gEextr[i][ic]->GetYaxis()->SetTitle("E_{z}/E_{0}"); gEextr[i][ic]->GetXaxis()->SetTitle("k_{p}z"); } else if(i==1) { gEextr[i][ic]->SetLineWidth(1); gEextr[i][ic]->SetLineColor(kGray+2); gEextr[i][ic]->SetMarkerStyle(20); gEextr[i][ic]->SetMarkerSize(0.4); gEextr[i][ic]->SetMarkerColor(kGray+2); gEextr[i][ic]->GetYaxis()->SetTitle("E_{y}/E_{0}"); gEextr[i][ic]->GetXaxis()->SetTitle("k_{p}z"); } } else { nPoints = gEextr[i][ic]->GetN(); } gEextr[i][ic]->Set(nPoints+1); gEextr[i][ic]->SetPoint(nPoints,Time,Eextr[i][ic]); gEextr[i][ic]->Write(gName,TObject::kOverwrite); } } ifile->Close(); }
void PlotRakeInjection( const TString &sim, Int_t zoom=2, Int_t Nbins=2, const TString &options="") { #ifdef __CINT__ gSystem->Load("libplasma.so"); #endif PlasmaGlob::Initialize(); // Palettes! gROOT->Macro("PlasmaPalettes.C"); // Init Units table PUnits::UnitsTable::Get(); TString opt = options; // More makeup gStyle->SetPadGridY(0); if(opt.Contains("grid")) { gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); } Bool_t CYL = kFALSE; if(sim.Contains("cyl")) { CYL = kTRUE; opt += "cyl"; } Bool_t ThreeD = kFALSE; if(sim.Contains("3D")) ThreeD = kTRUE; // Load PData PData *pData = PData::Get(sim.Data()); // Create the canvas and the pads before the Frame loop // Resolution: Int_t sizex = 600; Int_t sizey = 640; if(opt.Contains("hres")) { Int_t sizex = 1200; Int_t sizey = 1280; } TCanvas *C1 = new TCanvas("C1","Evolution of Injection",sizex,sizey); C1->cd(); // Palettes TExec *exPlasma = new TExec("exPlasma","plasmaPalette->cd();"); TExec *exElec = new TExec("exElec","electronPalette->cd();"); TExec *exHot = new TExec("exHot","hotPalette->cd();"); const Int_t NFrames = 4; // Int_t timestep[NFrames] = {18,22,26,34}; // TString sLabels[NFrames] = {"(a)","(b)","(c)","(d)"}; // Int_t timestep[NFrames] = {34,26,22,18}; Int_t timestep[NFrames] = {500,60,36,31}; TString sLabels[NFrames] = {"(d)","(c)","(b)","(a)"}; Float_t Time[NFrames] = {0.0}; TH2F ***hDen2D = new TH2F**[NFrames]; Float_t **zDenMax = new Float_t*[NFrames]; Float_t *zDenMaxTotal = NULL; // Text objects TPaveText **textTime = new TPaveText*[NFrames]; TPaveText **textLabel = new TPaveText*[NFrames]; TPad **pad = new TPad*[NFrames]; TH2F *hFrame[NFrames]; // C1->Divide(1,NFrames); // Setup Pad layout: Double_t lMargin = 0.15; Double_t rMargin = 0.18; Double_t bMargin = 0.10; Double_t tMargin = 0.04; Double_t vSpacing = 0.00; Double_t hStep = (1.-lMargin-rMargin); Double_t vStep = (1.- bMargin - tMargin - (NFrames-1) * vSpacing) / NFrames; Float_t vposd = 0.0; Float_t vposu = 0.0; Float_t vmard = 0.0; Float_t vmaru = 0.0; Float_t vfactor = 0.0; Float_t hposl = 0.0; Float_t hposr = 1.0; Float_t hmarl = lMargin; Float_t hmarr = rMargin; Float_t hfactor = 1.0; Double_t n0,kp,skindepth,E0; Int_t Nspecies; for(Int_t k=0;k<NFrames;k++) { pData->LoadFileNames(timestep[k]); if(!pData->IsInit()) continue; // Some plasma constants n0 = pData->GetPlasmaDensity(); kp = pData->GetPlasmaK(); skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; E0 = pData->GetPlasmaE0(); // Time in OU Time[k] = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; if(opt.Contains("center")) { Time[k] -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time[k] += zStartBeam; } // Get charge density histos Nspecies = pData->NSpecies(); hDen2D[k] = new TH2F*[Nspecies]; zDenMax[k] = new Float_t[Nspecies]; if(k==0) zDenMaxTotal = new Float_t[Nspecies]; for(Int_t i=0;i<Nspecies;i++) { hDen2D[k][i] = NULL; if(k==0) zDenMaxTotal[i] = -999.; if(!pData->GetChargeFileName(i)) continue; char hName[24]; sprintf(hName,"hDen_%i_%i",k,i); hDen2D[k][i] = (TH2F*) gROOT->FindObject(hName); if(hDen2D[k][i]) delete hDen2D[k][i]; if(!ThreeD) hDen2D[k][i] = pData->GetCharge(i,opt); else hDen2D[k][i] = pData->GetCharge2DSliceZY(i,-1,Nbins,opt+"avg"); hDen2D[k][i]->SetName(hName); hDen2D[k][i]->GetXaxis()->CenterTitle(); hDen2D[k][i]->GetYaxis()->CenterTitle(); hDen2D[k][i]->GetZaxis()->CenterTitle(); zDenMax[k][i] = hDen2D[k][i]->GetMaximum(); if(zDenMax[k][i]>zDenMaxTotal[i]) zDenMaxTotal[i] = zDenMax[k][i]; // Changing to user units: // -------------------------- if(opt.Contains("units") && n0) { Int_t NbinsX = hDen2D[k][i]->GetNbinsX(); Float_t xMin = skindepth * hDen2D[k][i]->GetXaxis()->GetXmin() / PUnits::um; Float_t xMax = skindepth * hDen2D[k][i]->GetXaxis()->GetXmax() / PUnits::um; Int_t NbinsY = hDen2D[k][i]->GetNbinsY(); Float_t yMin = skindepth * hDen2D[k][i]->GetYaxis()->GetXmin() / PUnits::um; Float_t yMax = skindepth * hDen2D[k][i]->GetYaxis()->GetXmax() / PUnits::um; hDen2D[k][i]->SetBins(NbinsX,xMin,xMax,NbinsY,yMin,yMax); hDen2D[k][i]->GetXaxis()->SetTitle("#zeta [#mum]"); } else { hDen2D[k][i]->GetXaxis()->SetTitle("k_{p} #zeta"); } // Zoom Float_t range = (hDen2D[k][i]->GetYaxis()->GetXmax() - hDen2D[k][i]->GetYaxis()->GetXmin())/zoom; Float_t midPoint = (hDen2D[k][i]->GetYaxis()->GetXmax() + hDen2D[k][i]->GetYaxis()->GetXmin())/2.; Float_t yMin,yMax; if(!CYL) { yMin = midPoint-range/2; yMax = midPoint+range/2; } else { yMin = 0.; yMax = range; } hDen2D[k][i]->GetYaxis()->SetRangeUser(yMin,yMax); } } Float_t density = 1; Float_t Base = density; Float_t *Max = new Float_t[Nspecies]; Float_t *Min = new Float_t[Nspecies]; for(Int_t k=0;k<NFrames;k++) { // Set Z ranges: for(Int_t i=0;i<Nspecies;i++) { Max[i] = zDenMaxTotal[i]; Min[i] = 1.01E-1 * Base; if(i==2) { Min[i] = 1.01E-3 * Base; Max[i] = zDenMax[k][i]; } hDen2D[k][i]->GetZaxis()->SetRangeUser(Min[i],Max[i]); if(i==0 && k==0) { // Dynamic plasma palette const Int_t plasmaDNRGBs = 3; const Int_t plasmaDNCont = 128; Double_t basePos = 0.5; if(Max[i]!=Min[i]) { if(opt.Contains("logz")) { Float_t a = 1.0/(TMath::Log10(Max[i])-TMath::Log10(Min[i])); Float_t b = TMath::Log10(Min[i]); basePos = a*(TMath::Log10(Base) - b); // cout << Form("Min = %f Base = %f Max = %f",a*(TMath::Log10(Min) - b),basePos,a*(TMath::Log10(Max) - b)) << endl; } else { basePos = (1.0/(Max[i]-Min[i]))*(Base - Min[i]); } } Double_t plasmaDStops[plasmaDNRGBs] = { 0.00, basePos, 1.00 }; Double_t plasmaDRed[plasmaDNRGBs] = { 0.99, 0.90, 0.00 }; Double_t plasmaDGreen[plasmaDNRGBs] = { 0.99, 0.90, 0.00 }; Double_t plasmaDBlue[plasmaDNRGBs] = { 0.99, 0.90, 0.00 }; PPalette * plasmaPalette = (PPalette*) gROOT->FindObject("plasma"); plasmaPalette->CreateGradientColorTable(plasmaDNRGBs, plasmaDStops, plasmaDRed, plasmaDGreen, plasmaDBlue, plasmaDNCont); } } // PLOTTING! if(k==0) { vposd = 0.0; vposu = bMargin + vStep; vfactor = vposu-vposd; vmard = bMargin / vfactor; vmaru = 0.0; } else if(k == NFrames-1) { vposd = vposu + vSpacing; vposu = vposd + vStep + tMargin; vfactor = vposu-vposd; vmard = 0.0; vmaru = tMargin / (vposu-vposd); } else { vposd = vposu + vSpacing; vposu = vposd + vStep; vfactor = vposu-vposd; vmard = 0.0; vmaru = 0.0; } hfactor = hposl-hposr; C1->cd(); char name[16]; sprintf(name,"pad_%i",k); pad[k] = new TPad(name,"",hposl,vposd,hposr,vposu); // // cout << Form("%f %f %f %f",hposl,vposd,hposr,vposu) << endl; // // cout << Form("%f %f %f %f",hmarl,vmard,hmarr,vmaru) << endl; pad[k]->SetLeftMargin(hmarl); pad[k]->SetRightMargin(hmarr); pad[k]->SetBottomMargin(vmard); pad[k]->SetTopMargin(vmaru); pad[k]->SetFrameLineWidth(3); if(opt.Contains("logz")) { pad[k]->SetLogz(1); } else { pad[k]->SetLogz(0); } pad[k]->Draw(); pad[k]->cd(); sprintf(name,"hFrame_%i",k); hFrame[k] = (TH2F*) gROOT->FindObject(name); if(hFrame[k]) delete hFrame[k]; hFrame[k] = (TH2F*) hDen2D[k][0]->Clone(name); hFrame[k]->Reset(); hFrame[k]->GetXaxis()->CenterTitle(); hFrame[k]->GetYaxis()->CenterTitle(); hFrame[k]->GetZaxis()->CenterTitle(); hFrame[k]->SetLabelFont(42,"xyz"); hFrame[k]->SetTitleFont(42,"xyz"); hFrame[k]->SetNdivisions(505,"xyz"); hFrame[k]->SetTickLength(0.04,"xyz"); hFrame[k]->SetTickLength(0.04*vfactor,"y"); hFrame[k]->GetYaxis()->SetLabelSize(0.03/vfactor); hFrame[k]->GetYaxis()->SetLabelOffset(0.02); hFrame[k]->GetYaxis()->SetTitleSize(0.03/vfactor); hFrame[k]->GetYaxis()->SetTitleOffset(999.0*vfactor); if(k==0) { hFrame[k]->GetXaxis()->SetLabelSize(0.10); hFrame[k]->GetXaxis()->SetLabelOffset(0.02); hFrame[k]->GetXaxis()->SetTitleSize(0.14); hFrame[k]->GetXaxis()->SetTitleOffset(1.0); } else { hFrame[k]->GetXaxis()->SetLabelSize(0.0); hFrame[k]->GetXaxis()->SetTitleSize(0.0); } hFrame[k]->Draw("axis"); exPlasma->Draw(); // Sum of histograms! hDen2D[k][0]->Add(hDen2D[k][1]); // hDen2D[k][0]->GetZaxis()->SetRangeUser(Min[1],Max[1]); hDen2D[k][0]->Draw("colz same"); pad[k]->Update(); TPaletteAxis *palette = (TPaletteAxis*)hDen2D[k][0]->GetListOfFunctions()->FindObject("palette"); Float_t y1 = pad[k]->GetBottomMargin(); Float_t y2 = 1 - pad[k]->GetTopMargin(); Float_t x1 = pad[k]->GetLeftMargin(); Float_t x2 = 1 - pad[k]->GetRightMargin(); palette->SetY2NDC(y2 - 1*(y2-y1)/2.0 - 0.00); palette->SetY1NDC(y1 + 0*(y2-y1)/2.0 + 0.00); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); palette->SetLabelFont(42); palette->SetLabelSize(0.03/vfactor); palette->SetLabelOffset(-0.004); palette->SetTitleSize(0.03/vfactor); palette->SetTitleOffset(9999.0*vfactor); palette->SetBorderSize(2); palette->SetLineColor(1); exHot->Draw(); hDen2D[k][2]->Draw("colz same"); pad[k]->Update(); palette = (TPaletteAxis*)hDen2D[k][2]->GetListOfFunctions()->FindObject("palette"); palette->SetY2NDC(y2 - 0*(y2-y1)/2.0 - 0.00); palette->SetY1NDC(y1 + 1*(y2-y1)/2.0 + 0.00); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); palette->SetLabelFont(42); palette->SetLabelSize(0.03/vfactor); palette->SetLabelOffset(-0.004); palette->SetTitleSize(0.03/vfactor); palette->SetTitleOffset(9999.0*vfactor); palette->SetBorderSize(2); palette->SetLineColor(1); textTime[k] = new TPaveText(x2-0.17,y2-(0.05/vfactor),x2-0.02,y2-0.04,"NDC"); PlasmaGlob::SetPaveTextStyle(textTime[k],32); char ctext[128]; if(opt.Contains("units")) sprintf(ctext,"z = %5.0f #mum", skindepth * Time[k] / PUnits::um); else sprintf(ctext,"z = %5.1f #omega_{p}^{-1}",Time[k]); textTime[k]->AddText(ctext); textTime[k]->Draw(); textLabel[k] = new TPaveText(x1+0.02,y1+(0.02/vfactor),x1+0.07,y1+(0.06/vfactor),"NDC"); PlasmaGlob::SetPaveTextStyle(textLabel[k],32); textLabel[k]->SetTextFont(42); textLabel[k]->AddText(sLabels[k]); textLabel[k]->Draw(); pad[k]->RedrawAxis(); } C1->cd(); // PlasmaGlob::SetPaveTextStyle(textYaxis,11); char ctext[128]; if(opt.Contains("units")) sprintf(ctext,"y [#mum]"); else sprintf(ctext,"k_{p} y"); TLatex *textYaxis = new TLatex(0.05,0.6,ctext); textYaxis->SetTextAlign(22); textYaxis->SetTextFont(42); textYaxis->SetTextAngle(90); textYaxis->Draw(); sprintf(ctext,"n [n_{0}]"); TLatex *textZaxis = new TLatex(0.95,0.6,ctext); textZaxis->SetTextAlign(22); textZaxis->SetTextFont(42); textZaxis->SetTextAngle(90); textZaxis->Draw(); // Output file TString fOutName = Form("./%s/Plots/RakeInjection/RakeInjection",pData->GetPath().c_str()); fOutName += Form("-%s",pData->GetName()); // Print to a file PlasmaGlob::imgconv(C1,fOutName,opt); // --------------------------------------------------------- }
void PlotPotential2D( const TString &sim, Int_t time, Int_t zoom=2, Int_t Nbins=2, const TString &options="") { #ifdef __CINT__ gSystem->Load("libplasma.so"); #endif PlasmaGlob::Initialize(); // Palettes! gROOT->Macro("PlasmaPalettes.C"); // Init Units table PUnits::UnitsTable::Get(); // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; TString opt = options; // More makeup gStyle->SetPadGridY(0); if(opt.Contains("gridx")) { gStyle->SetPadGridX(1); } if(opt.Contains("gridy")) { gStyle->SetPadGridY(1); } // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t omegap = pData->GetPlasmaFrequency(); Double_t timedepth = 1.; if(omegap!=0.0) timedepth = 1/omegap; Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Some beam properties: Double_t Ebeam = pData->GetBeamEnergy(); Double_t gamma = pData->GetBeamGamma(); Double_t vbeam = pData->GetBeamVelocity(); cout << Form(" - Bunch gamma = %8.4f", gamma ) << endl; cout << Form(" - Bunch velocity = %8.4f c", vbeam ) << endl; // Other parameters Float_t trapPotential = 1.0 - (1.0/gamma); cout << Form(" - Trap. potential = %8.4f mc2/e",trapPotential) << endl; cout << endl; // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; // z start of the neutral in normalized units. Float_t zStartNeutral = pData->GetNeutralStart()*kp; // z end of the neutral in normalized units. Float_t zEndNeutral = pData->GetNeutralEnd()*kp; if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } Float_t shiftz = pData->Shift(opt); // cout << "Shift = " << shiftz << endl; // Calculate the "axis range" in number of bins. If Nbins==0 a RMS width is taken. Double_t rms0 = pData->GetBeamRmsY() * kp; if(pData->IsCyl()) rms0 = pData->GetBeamRmsR() * kp; Int_t FirstyBin = 0; Int_t LastyBin = 0; if(Nbins==0) { if(rms0>0.0) Nbins = TMath::Nint(rms0 / pData->GetDX(1)); else Nbins = 1; } // Slice width limits. if(!pData->IsCyl()) { FirstyBin = pData->GetNX(1)/2 + 1 - Nbins; LastyBin = pData->GetNX(1)/2 + Nbins; } else { FirstyBin = 1; LastyBin = Nbins; } // ---------------------------------------------------------------------------------- // Get charge density histos Int_t Nspecies = pData->NSpecies(); TH2F **hDen2D = new TH2F*[Nspecies]; // Get charge density on-axis TH1F **hDen1D = new TH1F*[Nspecies]; // And electric current (integrated) TH1F **hCur1D = new TH1F*[Nspecies]; for(Int_t i=0; i<Nspecies; i++) { hDen2D[i] = NULL; if(!pData->GetChargeFileName(i)) continue; cout << Form(" Getting charge density of specie: ") << i << endl; char hName[24]; sprintf(hName,"hDen2D_%i",i); hDen2D[i] = (TH2F*) gROOT->FindObject(hName); if(hDen2D[i]) delete hDen2D[i]; if(!pData->Is3D()) hDen2D[i] = pData->GetCharge(i,opt); else hDen2D[i] = pData->GetCharge2DSliceZY(i,-1,Nbins,opt+"avg"); hDen2D[i]->SetName(hName); hDen2D[i]->GetXaxis()->CenterTitle(); hDen2D[i]->GetYaxis()->CenterTitle(); hDen2D[i]->GetZaxis()->CenterTitle(); if(opt.Contains("comov")) hDen2D[i]->GetXaxis()->SetTitle("k_{p} #zeta"); else hDen2D[i]->GetXaxis()->SetTitle("k_{p} z"); if(pData->IsCyl()) hDen2D[i]->GetYaxis()->SetTitle("k_{p} r"); else hDen2D[i]->GetYaxis()->SetTitle("k_{p} y"); hDen2D[i]->GetZaxis()->SetTitle("n [n_{0}]"); hDen1D[i] = NULL; hCur1D[i] = NULL; if(!pData->GetEfieldFileName(i)) continue; sprintf(hName,"hDen1D_%i",i); hDen1D[i] = (TH1F*) gROOT->FindObject(hName); if(hDen1D[i]) delete hDen1D[i]; // 1D histograms if(pData->Is3D()) { hDen1D[i] = pData->GetH1SliceZ3D(pData->GetChargeFileName(i)->c_str(),"charge",-1,Nbins,-1,Nbins,opt+"avg"); } else if(pData->IsCyl()) { // Cylindrical: The first bin with r>0 is actually the number 1 (not the 0). hDen1D[i] = pData->GetH1SliceZ(pData->GetChargeFileName(i)->c_str(),"charge",1,Nbins,opt+"avg"); } else { // 2D cartesian hDen1D[i] = pData->GetH1SliceZ(pData->GetChargeFileName(i)->c_str(),"charge",-1,Nbins,opt+"avg"); } hDen1D[i]->SetName(hName); // if(hDen1D[i]) delete hDen1D[i]; // hDen1D[i] = (TH1F*) hE2D[i]->ProjectionX(hName,FirstyBin,LastyBin); // hDen1D[i]->Scale(1.0/(LastyBin-FirstyBin+1)); if(opt.Contains("comov")) hDen1D[i]->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]"); else hDen1D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]"); if(i==0) hDen1D[i]->GetYaxis()->SetTitle("n/n_{0}"); else if(i==1) hDen1D[i]->GetYaxis()->SetTitle("n_{b}/n_{0}"); else hDen1D[i]->GetYaxis()->SetTitle("n_{i}/n_{0}"); // Get the current: if(i==0) continue; sprintf(hName,"hCur1D_%i",i); hCur1D[i] = (TH1F*) gROOT->FindObject(hName); if(hCur1D[i]) delete hCur1D[i]; if(opt.Contains("curr")) { // To get the current is needed to read in a wider transverse range which includes all the charge. Int_t NbinsT = 100; if(pData->Is3D()) { hCur1D[i] = pData->GetH1SliceZ3D(pData->GetChargeFileName(i)->c_str(),"charge",-1,NbinsT,-1,NbinsT,opt+"int"); } else if(pData->IsCyl()) { // Cylindrical: The first bin with r>0 is actually the number 1 (not the 0). hCur1D[i] = pData->GetH1SliceZ(pData->GetChargeFileName(i)->c_str(),"charge",1,NbinsT,opt+"int"); } else { // 2D cartesian hCur1D[i] = pData->GetH1SliceZ(pData->GetChargeFileName(i)->c_str(),"charge",-1,NbinsT,opt+"int"); } hCur1D[i]->SetName(hName); if(opt.Contains("comov")) { hCur1D[i]->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]"); hCur1D[i]->GetYaxis()->SetTitle("dn/d#zeta [(n_{0}/k_{p}^{3}) (#omega_{p}/c)]"); } else { hCur1D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]"); hCur1D[i]->GetYaxis()->SetTitle("dn/dz [(n_{0}/k_{p}^{3}) (#omega_{p}/c)]"); } Int_t NB = hCur1D[i]->GetNbinsX(); Float_t dx = (hCur1D[i]->GetBinLowEdge(1)-hCur1D[i]->GetBinLowEdge(NB+1))/NB; // hCur1D[i]->Scale(dx); Float_t Charge = hCur1D[i]->Integral() * dx; cout << Form(" Integrated charge of specie %3i = %8.4f n0 * kp^-3",i,Charge) << endl; } } // Get electric fields 2D const Int_t Nfields = 3; TH2F **hE2D = new TH2F*[Nfields]; TH1F **hE1D = new TH1F*[Nfields]; TH2F *hV2D = NULL; TH1F *hV1D = NULL; for(Int_t i=0; i<Nfields; i++) { hE2D[i] = NULL; hE1D[i] = NULL; if(!pData->GetEfieldFileName(i)) continue; cout << Form(" Getting electric field number ") << i+1 << endl; char hName[24]; sprintf(hName,"hE2D_%i",i); hE2D[i] = (TH2F*) gROOT->FindObject(hName); if(hE2D[i]) delete hE2D[i]; if(!pData->Is3D()) hE2D[i] = pData->GetEField(i,opt); else hE2D[i] = pData->GetEField2DSliceZY(i,-1,Nbins,opt+"avg"); hE2D[i]->SetName(hName); hE2D[i]->GetXaxis()->CenterTitle(); hE2D[i]->GetYaxis()->CenterTitle(); hE2D[i]->GetZaxis()->CenterTitle(); if(opt.Contains("comov")) hE2D[i]->GetXaxis()->SetTitle("k_{p} #zeta"); else hE2D[i]->GetXaxis()->SetTitle("k_{p} z"); if(pData->IsCyl()) hE2D[i]->GetYaxis()->SetTitle("k_{p} r"); else hE2D[i]->GetYaxis()->SetTitle("k_{p} y"); if(i==0) hE2D[i]->GetZaxis()->SetTitle("E_{z}/E_{0}"); else if(i==1) hE2D[i]->GetZaxis()->SetTitle("E_{y}/E_{0}"); else if(i==2) hE2D[i]->GetZaxis()->SetTitle("E_{x}/E_{0}"); sprintf(hName,"hE1D_%i",i); hE1D[i] = (TH1F*) gROOT->FindObject(hName); if(hE1D[i]) delete hE1D[i]; // 1D histograms char nam[3]; sprintf(nam,"e%i",i+1); if(pData->Is3D()) { if(i==0) hE1D[i] = pData->GetH1SliceZ3D(pData->GetEfieldFileName(i)->c_str(),nam,-1,Nbins,-1,Nbins,opt+"avg"); else hE1D[i] = pData->GetH1SliceZ3D(pData->GetEfieldFileName(i)->c_str(),nam,-Nbins,Nbins,-Nbins,Nbins,opt+"avg"); } else if(pData->IsCyl()) { // Cylindrical: The first bin with r>0 is actually the number 1 (not the 0). hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,1,Nbins,opt+"avg"); } else { // 2D cartesian if(i==0) hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,-1,Nbins,opt+"avg"); else hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,-Nbins,Nbins,opt+"avg"); } hE1D[i]->SetName(hName); if(opt.Contains("comov")) hE1D[i]->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]"); else hE1D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]"); if(i==0) hE1D[i]->GetYaxis()->SetTitle("E_{z} [E_{0}]"); else if(i==1) hE1D[i]->GetYaxis()->SetTitle("E_{y} [E_{0}]"); else if(i==2) hE1D[i]->GetYaxis()->SetTitle("E_{x} [E_{0}]"); // Alternative // if(hE1D[i]) delete hE1D[i]; // hE1D[i] = (TH1F*) hE2D[i]->ProjectionX(hName,FirstyBin,LastyBin); // hE1D[i]->Scale(1.0/(LastyBin-FirstyBin+1)); if(i==0) { Int_t NbinsX = hE2D[i]->GetNbinsX(); Int_t NbinsY = hE2D[i]->GetNbinsY(); Float_t dx = pData->GetDX(0); sprintf(hName,"hV2D"); hV2D = (TH2F*) hE2D[i]->Clone(hName); hV2D->Reset(); sprintf(hName,"hV1D"); hV1D = (TH1F*) hE1D[i]->Clone(hName); hV1D->Reset(); for(Int_t j=NbinsY; j>0; j--) { Double_t integral = 0.0; for(Int_t k=NbinsX; k>0; k--) { integral += hE2D[i]->GetBinContent(k,j) * dx; hV2D->SetBinContent(k,j,integral); } } Double_t integral = 0.0; for(Int_t k=NbinsX; k>0; k--) { integral += hE1D[i]->GetBinContent(k) * dx; hV1D->SetBinContent(k,integral); } } } // Now, combine the electric field components into the total |E| // and calculate ionization probability for He: // Outter Helium electron Double_t Eion0 = 24.59 * PUnits::eV; Double_t Z = 1; TH2F *hETotal2D = (TH2F*) hE2D[0]->Clone("hETotal2D"); hETotal2D->Reset(); TH2F *hIonProb2D = (TH2F*) hE2D[0]->Clone("hIonProb2D"); hIonProb2D->Reset(); TH1F *hETotal1D = (TH1F*) hE1D[0]->Clone("hETotal1D"); hETotal1D->Reset(); TH1F *hIonProb1D = (TH1F*) hE1D[0]->Clone("hIonProb1D"); hIonProb1D->Reset(); { Int_t NbinsX = hE2D[0]->GetNbinsX(); Int_t NbinsY = hE2D[0]->GetNbinsY(); for(Int_t j=0; j<NbinsX; j++) { for(Int_t k=0; k<NbinsY; k++) { Double_t E1 = hE2D[0]->GetBinContent(j,k); Double_t E2 = hE2D[1]->GetBinContent(j,k); Double_t E3 = hE2D[2]->GetBinContent(j,k); Double_t E = TMath::Sqrt(E1*E1+E2*E2+E3*E3); hETotal2D->SetBinContent(j,k,E); E *= E0; // Double_t IonProb = (PFunc::ADK(E,Eion0,Z,l,m)/PUnits::atomictime)*PUnits::femtosecond; Double_t IonProb = PFunc::ADK_ENG(E,Eion0,Z) * PUnits::femtosecond; // if(IonProb>1) IonProb = 1.0; // cout << "Ion prob = " << IonProb << endl; hIonProb2D->SetBinContent(j,k,IonProb); } Double_t E1 = hE1D[0]->GetBinContent(j); Double_t E2 = hE1D[1]->GetBinContent(j); Double_t E3 = hE1D[2]->GetBinContent(j); Double_t E = TMath::Sqrt(E1*E1+E2*E2+E3*E3); hETotal1D->SetBinContent(j,E); E *= E0; // Double_t IonProb = (PFunc::ADK(E,Eion0,Z,l,m)/PUnits::atomictime)*PUnits::femtosecond; Double_t IonProb = PFunc::ADK_ENG(E,Eion0,Z) * PUnits::femtosecond; // cout << "Ion prob = " << IonProb << endl; hIonProb1D->SetBinContent(j,IonProb); } } hETotal2D->GetZaxis()->SetTitle("E [E_{0}]"); hIonProb2D->GetZaxis()->SetTitle("W_{ADK} [fs^{-1}]"); hETotal1D->GetYaxis()->SetTitle("E [E_{0}]"); hIonProb1D->GetYaxis()->SetTitle("W_{ADK} [fs^{-1}]"); // Tunning the Histograms // --------------------- // Chaning to user units: // -------------------------- if(opt.Contains("units") && n0) { for(Int_t i=0; i<Nspecies; i++) { if(!hDen2D[i]) continue; Int_t NbinsX = hDen2D[i]->GetNbinsX(); Float_t xMin = skindepth * hDen2D[i]->GetXaxis()->GetXmin() / PUnits::um; Float_t xMax = skindepth * hDen2D[i]->GetXaxis()->GetXmax() / PUnits::um; Int_t NbinsY = hDen2D[i]->GetNbinsY(); Float_t ymin = skindepth * hDen2D[i]->GetYaxis()->GetXmin() / PUnits::um; Float_t ymax = skindepth * hDen2D[i]->GetYaxis()->GetXmax() / PUnits::um; hDen2D[i]->SetBins(NbinsX,xMin,xMax,NbinsY,ymin,ymax); // for(Int_t j=0;j<hDen2D[i]->GetNbinsX();j++) { // for(Int_t k=0;k<hDen2D[i]->GetNbinsY();k++) { // hDen2D[i]->SetBinContent(j,k, hDen2D[i]->GetBinContent(j,k) * n0 / (1e17/PUnits::cm3) ); // } // } if(pData->IsCyl()) hDen2D[i]->GetYaxis()->SetTitle("r [#mum]"); else hDen2D[i]->GetYaxis()->SetTitle("y [#mum]"); if(opt.Contains("comov")) hDen2D[i]->GetXaxis()->SetTitle("#zeta [#mum]"); else hDen2D[i]->GetXaxis()->SetTitle("z [#mum]"); // if(i==0) // hDen2D[i]->GetZaxis()->SetTitle("n_{e} [10^{17}/cm^{3}]"); // else if(i==1) // hDen2D[i]->GetZaxis()->SetTitle("n_{b} [10^{17}/cm^{3}]"); // else // hDen2D[i]->GetZaxis()->SetTitle("n_{i} [10^{17}/cm^{3}]"); hDen1D[i]->SetBins(NbinsX,xMin,xMax); // for(Int_t j=0;j<hDen1D[i]->GetNbinsX();j++) { // hDen1D[i]->SetBinContent(j, hDen1D[i]->GetBinContent(j) * n0 / (1e17/PUnits::cm3) ); // } if(opt.Contains("comov")) hDen1D[i]->GetXaxis()->SetTitle("#zeta [#mum]"); else hDen1D[i]->GetXaxis()->SetTitle("z [#mum]"); if(hCur1D[i]) { hCur1D[i]->SetBins(NbinsX,xMin,xMax); Double_t binSize = (xMax - xMin)/NbinsX; // bin size in um. Double_t dV = skindepth * skindepth * skindepth; Double_t lightspeed = PConst::c_light / (PUnits::um/PUnits::femtosecond); hCur1D[i]->Scale(TMath::Abs(n0 * dV * (PConst::ElectronCharge/PUnits::picocoulomb) * (kp * PConst::c_light * PUnits::femtosecond))); hCur1D[i]->GetYaxis()->SetTitle("I[kA]"); hCur1D[i]->GetYaxis()->SetTitle(""); if(opt.Contains("comov")) hCur1D[i]->GetXaxis()->SetTitle("#zeta [#mum]"); else hCur1D[i]->GetXaxis()->SetTitle("z [#mum]"); Float_t Charge = hCur1D[i]->Integral() * (binSize / lightspeed); cout << Form(" Integrated charge of specie %3i = %8f pC",i,Charge) << endl; } } for(Int_t i=0; i<Nfields; i++) { Int_t NbinsX = hE2D[i]->GetNbinsX(); Float_t xMin = skindepth * hE2D[i]->GetXaxis()->GetXmin() / PUnits::um; Float_t xMax = skindepth * hE2D[i]->GetXaxis()->GetXmax() / PUnits::um; Int_t NbinsY = hE2D[i]->GetNbinsY(); Float_t ymin = skindepth * hE2D[i]->GetYaxis()->GetXmin() / PUnits::um; Float_t ymax = skindepth * hE2D[i]->GetYaxis()->GetXmax() / PUnits::um; hE2D[i]->SetBins(NbinsX,xMin,xMax,NbinsY,ymin,ymax); hE1D[i]->SetBins(NbinsX,xMin,xMax); for(Int_t j=0; j<hE2D[i]->GetNbinsX(); j++) { for(Int_t k=0; k<hE2D[i]->GetNbinsY(); k++) { hE2D[i]->SetBinContent(j,k, hE2D[i]->GetBinContent(j,k) * ( E0 / (PUnits::GV/PUnits::m) ) ); } hE1D[i]->SetBinContent(j, hE1D[i]->GetBinContent(j) * ( E0 / (PUnits::GV/PUnits::m) ) ); } if(pData->IsCyl()) hE2D[i]->GetYaxis()->SetTitle("r [#mum]"); else hE2D[i]->GetYaxis()->SetTitle("y [#mum]"); if(opt.Contains("comov")) hE2D[i]->GetXaxis()->SetTitle("#zeta [#mum]"); else hE2D[i]->GetXaxis()->SetTitle("z [#mum]"); if(i==0) hE2D[i]->GetZaxis()->SetTitle("E_{z} [GV/m]"); else if(i==1) hE2D[i]->GetZaxis()->SetTitle("E_{y} [GV/m]"); else if(i==2) hE2D[i]->GetZaxis()->SetTitle("E_{x} [GV/m]"); if(opt.Contains("comov")) hE1D[i]->GetXaxis()->SetTitle("#zeta [mm]"); else hE1D[i]->GetXaxis()->SetTitle("z [mm]"); if(i==0) hE1D[i]->GetYaxis()->SetTitle("E_{z} [GV/m]"); else if(i==1) hE1D[i]->GetYaxis()->SetTitle("E_{y} [GV/m]"); else if(i==2) hE1D[i]->GetYaxis()->SetTitle("E_{x} [GV/m]"); if(i==0) { hV2D->SetBins(NbinsX,xMin,xMax,NbinsY,ymin,ymax); hETotal2D->SetBins(NbinsX,xMin,xMax,NbinsY,ymin,ymax); hIonProb2D->SetBins(NbinsX,xMin,xMax,NbinsY,ymin,ymax); hV1D->SetBins(NbinsX,xMin,xMax); hETotal1D->SetBins(NbinsX,xMin,xMax); hIonProb1D->SetBins(NbinsX,xMin,xMax); for(Int_t j=0; j<NbinsX; j++) { for(Int_t k=0; k<NbinsY; k++) { hV2D->SetBinContent(j,k, hV2D->GetBinContent(j,k) * E0 * skindepth / (PUnits::MV)); hETotal2D->SetBinContent(j,k, hETotal2D->GetBinContent(j,k) * ( E0 / (PUnits::GV/PUnits::m) ) ); } hV1D->SetBinContent(j, hV1D->GetBinContent(j) * ( E0 * skindepth / (PUnits::MV) ) ); hETotal1D->SetBinContent(j, hETotal1D->GetBinContent(j) * ( E0 / (PUnits::GV/PUnits::m) ) ); } if(pData->IsCyl()) { hV2D->GetYaxis()->SetTitle("r [#mum]"); hETotal2D->GetYaxis()->SetTitle("r [#mum]"); } else { hV2D->GetYaxis()->SetTitle("y [#mum]"); hETotal2D->GetYaxis()->SetTitle("y [#mum]"); } if(opt.Contains("comov")) { hV2D->GetXaxis()->SetTitle("#zeta [#mum]"); hV1D->GetXaxis()->SetTitle("#zeta [#mum]"); hETotal2D->GetXaxis()->SetTitle("#zeta [#mum]"); hETotal1D->GetXaxis()->SetTitle("#zeta [#mum]"); } else { hV2D->GetXaxis()->SetTitle("z [#mum]"); hV2D->GetXaxis()->SetTitle("z [#mum]"); hETotal2D->GetXaxis()->SetTitle("z [#mum]"); hETotal1D->GetXaxis()->SetTitle("z [#mum]"); } hV2D->GetZaxis()->SetTitle("#Psi-#Psi_{t} [MV]"); hV1D->GetYaxis()->SetTitle("#Psi-#Psi_{t} [MV]"); hETotal2D->GetZaxis()->SetTitle("E [GV/m]"); hETotal1D->GetYaxis()->SetTitle("E [GV/m]"); } } } // --------------------------------------------------- Vertical Zoom ------------ Float_t yRange = (hDen2D[0]->GetYaxis()->GetXmax() - hDen2D[0]->GetYaxis()->GetXmin())/zoom; Float_t midPoint = (hDen2D[0]->GetYaxis()->GetXmax() + hDen2D[0]->GetYaxis()->GetXmin())/2.; Float_t yMin = midPoint-yRange/2; Float_t yMax = midPoint+yRange/2; if(pData->IsCyl()) { yMin = pData->GetXMin(1); yMax = yRange; } for(Int_t i=0; i<Nspecies; i++) { if(!hDen2D[i]) continue; hDen2D[i]->GetYaxis()->SetRangeUser(yMin,yMax); } for(Int_t i=0; i<Nfields; i++) { if(!hE2D[i]) continue; hE2D[i]->GetYaxis()->SetRangeUser(yMin,yMax); } hETotal2D->GetYaxis()->SetRangeUser(yMin,yMax); Float_t xMin = hDen2D[0]->GetXaxis()->GetXmin(); Float_t xMax = hDen2D[0]->GetXaxis()->GetXmax(); Float_t xRange = xMax - xMin; // ------------- z Zoom --------------------------------- Plasma palette ----------- // Set the range of the plasma charge density histogram for maximum constrast // using a dynamic palette wich adjust the nominal value to a certain color. Float_t density = 1; Float_t Base = density; Float_t *Max = new Float_t[Nspecies]; Float_t *Min = new Float_t[Nspecies]; for(Int_t i=0; i<Nspecies; i++) { if(!hDen2D[i]) continue; Max[i] = hDen2D[i]->GetMaximum(); Min[i] = 1.01E-1 * Base; if(i==1) Min[i] = 1.01E-1 * Base; if(i==2) Min[i] = 1.01E-4 * Base; hDen2D[i]->GetZaxis()->SetRangeUser(Min[i],Max[i]); } // Dynamic plasma palette const Int_t plasmaDNRGBs = 3; const Int_t plasmaDNCont = 64; Float_t basePos = 0.5; if(Max[0]!=Min[0]) { if(opt.Contains("logz")) { Float_t a = 1.0/(TMath::Log10(Max[0])-TMath::Log10(Min[0])); Float_t b = TMath::Log10(Min[0]); basePos = a*(TMath::Log10(Base) - b); } else { basePos = (1.0/(Max[0]-Min[0]))*(Base - Min[0]); } } Double_t plasmaDStops[plasmaDNRGBs] = { 0.00, basePos, 1.00 }; Double_t plasmaDRed[plasmaDNRGBs] = { 0.99, 0.90, 0.00 }; Double_t plasmaDGreen[plasmaDNRGBs] = { 0.99, 0.90, 0.00 }; Double_t plasmaDBlue[plasmaDNRGBs] = { 0.99, 0.90, 0.00 }; PPalette * plasmaPalette = (PPalette*) gROOT->FindObject("plasma"); plasmaPalette->CreateGradientColorTable(plasmaDNRGBs, plasmaDStops, plasmaDRed, plasmaDGreen, plasmaDBlue, plasmaDNCont); // Change the range of z axis for the fields to be symmetric. Float_t *Emax = new Float_t[Nfields]; Float_t *Emin = new Float_t[Nfields]; for(Int_t i=0; i<Nfields; i++) { Emax[i] = hE2D[i]->GetMaximum(); Emin[i] = hE2D[i]->GetMinimum(); if(Emax[i] > TMath::Abs(Emin[i])) Emin[i] = -Emax[i]; else Emax[i] = -Emin[i]; hE2D[i]->GetZaxis()->SetRangeUser(Emin[i],Emax[i]); } // Potential if(opt.Contains("units")) { trapPotential *= ( E0 * skindepth / (PUnits::MV) ); } Float_t Vmin = hV1D->GetMinimum(); { // Shift potential Int_t NbinsX = hV2D->GetNbinsX(); Int_t NbinsY = hV2D->GetNbinsY(); for(Int_t j=0; j<NbinsX; j++) { for(Int_t k=0; k<NbinsY; k++) { hV2D->SetBinContent(j,k, hV2D->GetBinContent(j,k) - Vmin -trapPotential); } hV1D->SetBinContent(j, hV1D->GetBinContent(j) - Vmin -trapPotential); } } Vmin = hV1D->GetMinimum(); Float_t Vmax = hV1D->GetMaximum(); // Dynamic potential palette const Int_t potPNRGBs = 5; const Int_t potPNCont = 64; Float_t zeroPos = -Vmin/(Vmax-Vmin); Double_t potPStops[potPNRGBs] = { 0.00, zeroPos-3.0/potPNCont,zeroPos, zeroPos+3.0/potPNCont, 1.00 }; Double_t potPRed[potPNRGBs] = { 0.518, 0.965, 0.90, 0.498, 0.106 }; Double_t potPGreen[potPNRGBs] = { 0.078, 0.925, 0.90, 0.718, 0.078 }; Double_t potPBlue[potPNRGBs] = { 0.106, 0.353, 0.90, 0.780, 0.518 }; PPalette * potentialPalette = (PPalette*) gROOT->FindObject("rbow2inv"); potentialPalette->CreateGradientColorTable(potPNRGBs, potPStops, potPRed, potPGreen, potPBlue, potPNCont); // Extract contours TCanvas* c = new TCanvas("c","Contour List",0,0,600,600); c->cd(); // Potential TH2F *hV2Dc = (TH2F*) hV2D->Clone("hV2Dc"); const Int_t Ncontours = 25; Double_t contours[Ncontours]; for(Int_t i=0; i<Ncontours; i++) { contours[i] = i*(trapPotential/5.0) - trapPotential; } hV2Dc->SetContour(Ncontours, contours); hV2Dc->Draw("cont list"); c->Update(); TObjArray *contsV2D = (TObjArray*) gROOT->GetListOfSpecials()->FindObject("contours"); TClonesArray graphsV2D("TGraph",Ncontours); { Int_t ncontours = contsV2D->GetSize(); TList* clist = NULL; Int_t nGraphs = 0; TGraph *gr = NULL; for(Int_t i = 0; i < ncontours; i++) { if(i==0) continue; clist = (TList*) contsV2D->At(i); for(Int_t j = 0 ; j < clist->GetSize(); j++) { gr = (TGraph*) clist->At(j); if(!gr) continue; gr->SetLineWidth(1); gr->SetLineColor(kGray+1); if( !((i)%5) ) { gr->SetLineWidth(2); gr->SetLineColor(kGray+2); } new(graphsV2D[nGraphs]) TGraph(*gr) ; nGraphs++; } } } // Ion probability hIonProb2D->GetZaxis()->SetRangeUser(0.00501,80); TH2F *hIonProb2Dc = (TH2F*) hIonProb2D->Clone("hIonProb2Dc"); const Int_t NcontI = 4; Double_t contI[NcontI] = {0.01,0.1,1.0,10.0}; hIonProb2Dc->SetContour(NcontI, contI); hIonProb2Dc->Draw("cont list"); c->Update(); TObjArray *contsI2D = (TObjArray*) gROOT->GetListOfSpecials()->FindObject("contours"); TClonesArray graphsI2D("TGraph",NcontI); { Int_t ncontours = contsI2D->GetSize(); TList* clist = NULL; Int_t nGraphs = 0; TGraph *gr = NULL; for(Int_t i = 0; i < ncontours; i++) { clist = (TList*) contsI2D->At(i); for(Int_t j = 0 ; j < clist->GetSize(); j++) { gr = (TGraph*) clist->At(j); if(!gr) continue; if( !(i%2) ) { gr->SetLineWidth(1); gr->SetLineStyle(2); gr->SetLineColor(kOrange-3); } else { gr->SetLineWidth(1); gr->SetLineStyle(1); gr->SetLineColor(kOrange-3); } new(graphsI2D[nGraphs]) TGraph(*gr) ; nGraphs++; } } } // "Axis range" in Osiris units: Double_t ylow = hDen2D[0]->GetYaxis()->GetBinLowEdge(FirstyBin); Double_t yup = hDen2D[0]->GetYaxis()->GetBinUpEdge(LastyBin); Double_t xmin = hDen2D[0]->GetXaxis()->GetXmin(); Double_t xmax = hDen2D[0]->GetXaxis()->GetXmax(); TLine *lineYzero = new TLine(xmin,0.0,xmax,0.0); lineYzero->SetLineColor(kGray+2); lineYzero->SetLineStyle(2); TLine *lineYup = new TLine(xmin,yup,xmax,yup); lineYup->SetLineColor(kGray+1); lineYup->SetLineStyle(2); TLine *lineYdown = new TLine(xmin,ylow,xmax,ylow); lineYdown->SetLineColor(kGray+1); lineYdown->SetLineStyle(2); zStartPlasma -= shiftz; zStartNeutral -= shiftz; zEndNeutral -= shiftz; if(opt.Contains("units")) { zStartPlasma *= skindepth / PUnits::um; zStartNeutral *= skindepth / PUnits::um; zEndNeutral *= skindepth / PUnits::um; } // cout << "Start plasma = " << zStartPlasma << endl; TLine *lineStartPlasma = new TLine(zStartPlasma,yMin,zStartPlasma,yMax); lineStartPlasma->SetLineColor(kGray+2); lineStartPlasma->SetLineStyle(2); lineStartPlasma->SetLineWidth(3); // cout << "Start plasma = " << zStartNeutral << endl; TLine *lineStartNeutral = new TLine(zStartNeutral,yMin,zStartNeutral,yMax); lineStartNeutral->SetLineColor(kGray+1); lineStartNeutral->SetLineStyle(2); lineStartNeutral->SetLineWidth(3); // cout << "End plasma = " << zEndNeutral << endl; TLine *lineEndNeutral = new TLine(zEndNeutral,yMin,zEndNeutral,yMax); lineEndNeutral->SetLineColor(kGray+1); lineEndNeutral->SetLineStyle(2); lineEndNeutral->SetLineWidth(3); // Plotting // ----------------------------------------------- // Canvas setup TCanvas *C = new TCanvas("C","2D Charge density and Electric field",750,666); // Palettes setup TExec *exPlasma = new TExec("exPlasma","plasmaPalette->cd();"); TExec *exElec = new TExec("exElec","redelectronPalette->cd();"); TExec *exHot = new TExec("exHot","hotPalette->cd();"); TExec *exField = new TExec("exField","rbow2Palette->cd();"); TExec *exFieldT = new TExec("exFieldT","redPalette->cd();"); TExec *exIonP = new TExec("exIonP","redPalette->cd();"); TExec *exPot = new TExec("exPot","rbow2invPalette->cd();"); // Actual Plotting! // ------------------------------------------------------------ // Output file TString fOutName = Form("./%s/Plots/Potential2D/Potential2D",pData->GetPath().c_str()); fOutName += Form("-%s_%i",pData->GetName(),time); // Setup Pad layout: Float_t lMargin = 0.15; Float_t rMargin = 0.18; Float_t bMargin = 0.15; Float_t tMargin = 0.04; Float_t factor = 1.0; PlasmaGlob::CanvasAsymPartition(C,2,lMargin,rMargin,bMargin,tMargin,factor); TPad *pad[2]; TString sLabels[] = {"(a)","(b)"}; // Text objects TPaveText **textLabel = new TPaveText*[2]; C->cd(0); char pname[16]; sprintf(pname,"pad_%i",1); pad[0] = (TPad*) gROOT->FindObject(pname); pad[0]->Draw(); pad[0]->cd(); // <---------------------------------------------- Top Plot --------- if(opt.Contains("logz")) { pad[0]->SetLogz(1); } else { pad[0]->SetLogz(0); } pad[0]->SetFrameLineWidth(3); pad[0]->SetTickx(1); // Re-range: for(Int_t i=0; i<Nspecies; i++) { if(!hDen2D[i]) continue; hDen2D[i]->GetYaxis()->SetRangeUser(yMin -(factor-1)*yRange, yMax); } TH2F *hFrame = (TH2F*) gROOT->FindObject("hFrame1"); if(hFrame) delete hFrame; hFrame = (TH2F*) hDen2D[0]->Clone("hFrame1"); hFrame->Reset(); hFrame->SetLabelFont(42,"xyz"); hFrame->SetTitleFont(42,"xyz"); hFrame->GetYaxis()->SetNdivisions(505); hFrame->GetYaxis()->SetLabelSize(0.085); hFrame->GetYaxis()->SetTitleSize(0.09); hFrame->GetYaxis()->SetTitleOffset(0.7); hFrame->GetYaxis()->SetTickLength(0.02); hFrame->GetXaxis()->SetLabelOffset(999.); hFrame->GetXaxis()->SetTitleOffset(999.); hFrame->GetXaxis()->SetTickLength(0.04); // Frame asymmetry: hFrame->Draw("col"); // hDen2D[0]->GetZaxis()->SetNdivisions(505); // Injected electrons if any if(Nspecies>=3) { if(hDen2D[2]) { exHot->Draw(); hDen2D[2]->Draw("colz same"); } } // Plasma hDen2D[0]->GetZaxis()->SetTitleFont(42); exPlasma->Draw(); hDen2D[0]->Draw("colz same"); // Beam driver. if(hDen2D[1]) { // hDen2D[1]->GetZaxis()->SetNdivisions(505); exElec->Draw(); hDen2D[1]->Draw("colz same"); } { TGraph *gr = (TGraph*) graphsV2D.At(4); gr->Draw("C"); } { TGraph *gr = (TGraph*) graphsI2D.At(1); gr->Draw("C"); } if(opt.Contains("1dline")) { lineYzero->Draw(); lineYdown->Draw(); lineYup->Draw(); } if(opt.Contains("sline")) { if(zStartPlasma>xmin && zStartPlasma<xmax) lineStartPlasma->Draw(); if(zStartNeutral>xmin && zStartNeutral<xmax) lineStartNeutral->Draw(); if(zEndNeutral>xmin && zEndNeutral<xmax) lineEndNeutral->Draw(); } // lineYdown->Draw(); // lineYup->Draw(); // Palettes re-arrangement pad[0]->Update(); Float_t y1 = pad[0]->GetBottomMargin(); Float_t y2 = 1 - pad[0]->GetTopMargin(); Float_t x1 = pad[0]->GetLeftMargin(); Float_t x2 = 1 - pad[0]->GetRightMargin(); TPaletteAxis *palette = NULL; if(Nspecies>=3) { if(hDen2D[2]) { palette = (TPaletteAxis*)hDen2D[2]->GetListOfFunctions()->FindObject("palette"); } } if(palette) { palette->SetY2NDC(y2 - 0.00); palette->SetY1NDC(0.66*(y1+y2) + 0.00); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); // palette->SetTitleFont(42); // palette->SetTitleOffset(0.85); palette->SetTitleOffset(999.9); palette->SetTitleSize(0.075); palette->SetLabelFont(42); palette->SetLabelSize(0.075); palette->SetLabelOffset(0.001); palette->SetBorderSize(2); palette->SetLineColor(1); } palette = (TPaletteAxis*)hDen2D[0]->GetListOfFunctions()->FindObject("palette"); if(palette) { palette->SetY2NDC(0.66*(y1+y2) - 0.00); palette->SetY1NDC(0.33*(y1+y2) + 0.00); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); // palette->SetTitleFont(42); palette->SetTitleOffset(0.80); palette->SetTitleSize(0.075); palette->SetLabelFont(42); palette->SetLabelSize(0.075); palette->SetLabelOffset(0.001); palette->SetBorderSize(2); palette->SetLineColor(1); } palette = (TPaletteAxis*)hDen2D[1]->GetListOfFunctions()->FindObject("palette"); if(palette) { palette->SetY2NDC(0.33*(y1+y2) - 0.00); palette->SetY1NDC(y1 + 0.00); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); //palette->SetTitleFont(42); //palette->SetTitleOffset(0.85); palette->SetTitleOffset(999.9); palette->SetTitleSize(0.075); palette->SetLabelFont(42); palette->SetLabelSize(0.075); palette->SetLabelOffset(0.001); palette->SetBorderSize(2); palette->SetLineColor(1); } // 1D charge density plots: Float_t yaxismin = pad[0]->GetUymin(); Float_t yaxismax = pad[0]->GetUymin() + 0.33*(pad[0]->GetUymax() - pad[0]->GetUymin()) - 0.00; Float_t denmin = Min[1]; Float_t denmax = Max[1]; if(opt.Contains("logz")) { denmin = TMath::Log10(denmin); denmax = TMath::Log10(denmax); } Float_t curmin = 0.0; Float_t curmax = 0.0; if(opt.Contains("curr")) { curmin = 0.0; curmax = hCur1D[1]->GetMaximum(); cout << Form(" Maximum driver current = %6.2f kA ", curmax) << endl ; if(Nspecies>=3) if(hCur1D[2]) cout << Form(" Maximum witness current = %6.2f kA ", hCur1D[2]->GetMaximum()) << endl ; // Round for better plotting curmax = 0.1*TMath::Nint(curmax*10); } for(Int_t i=0; i<Nspecies; i++) { if(!hDen1D[i]) continue; Float_t slope = (yaxismax - yaxismin)/(denmax - denmin); for(Int_t j=0; j<hDen1D[i]->GetNbinsX(); j++) { Float_t content = hDen1D[i]->GetBinContent(j+1); if(opt.Contains("logz")) content = TMath::Log10(content); if(content<denmin) hDen1D[i]->SetBinContent(j+1,yaxismin); else hDen1D[i]->SetBinContent(j+1,(content - denmin) * slope + yaxismin); } if(hCur1D[i]) { slope = (yaxismax - yaxismin)/(curmax - curmin); for(Int_t j=0; j<hCur1D[i]->GetNbinsX(); j++) { Float_t content = hCur1D[i]->GetBinContent(j+1); if(content<curmin) hCur1D[i]->SetBinContent(j+1,yaxismin); else hCur1D[i]->SetBinContent(j+1,(content - curmin) * slope + yaxismin); } } } // Plasma on-axis density: // hDen1D[0]->SetLineWidth(2); // hDen1D[0]->SetLineColor(kGray+1); // // // PlasmaGlob::SetH1Style(hDen1D[0],1); // hDen1D[0]->Draw("same C"); if(opt.Contains("curr")) { hCur1D[1]->SetLineWidth(2); hCur1D[1]->SetLineColor(PlasmaGlob::elecLine); hCur1D[1]->Draw("same C"); } else { hDen1D[1]->SetLineWidth(2); hDen1D[1]->SetLineColor(PlasmaGlob::elecLine); // hDen1D[1]->Draw("same C"); } if(Nspecies>=3) { if(hDen1D[2]) { if(opt.Contains("curr")) { hCur1D[2]->SetLineWidth(2); hCur1D[2]->SetLineColor(kOrange+8); hCur1D[2]->Draw("same C"); } else { hDen1D[2]->SetLineWidth(2); hDen1D[2]->SetLineColor(kOrange+8); // hDen1D[2]->Draw("same C"); } } } // Current axis TGaxis *axis = NULL; if(opt.Contains("curr")) { axis = new TGaxis(xMax-xRange/6.0,yMin - (factor-1)*yRange, xMax-xRange/6.0,yaxismax, 0.001,curmax,503,"+LS"); axis->SetLineWidth(1); axis->SetLineColor(kGray+3);//PlasmaGlob::elecLine); axis->SetLabelColor(kGray+3);//PlasmaGlob::elecLine); axis->SetLabelSize(0.06); axis->SetLabelOffset(0.01); axis->SetLabelFont(42); axis->SetTitleColor(kGray+3);//PlasmaGlob::elecLine); axis->SetTitleSize(0.06); axis->SetTitleOffset(0.6); axis->SetTitleFont(42); axis->SetTickSize(0.03); axis->SetTitle("I [kA]"); axis->CenterTitle(); axis->SetNdivisions(505); axis->Draw(); } TPaveText *textTime = new TPaveText(xMax - 0.3*xRange, yMax-0.15*yRange, xMax-0.1, yMax-0.05*yRange); //x2-0.17,y2-0.12,x2-0.02,y2-0.02,"NDC"); PlasmaGlob::SetPaveTextStyle(textTime,32); char ctext[128]; if(opt.Contains("units") && n0) sprintf(ctext,"z = %5.1f #mum", Time * skindepth / PUnits::um); else sprintf(ctext,"t = %5.1f #omega_{p}^{-1}",Time); textTime->SetTextFont(42); textTime->AddText(ctext); textTime->Draw(); // textDen->Draw(); // if(opt.Contains("units")) // textWav->Draw(); textLabel[0] = new TPaveText(xMin + 0.02*xRange, yMax-0.2*yRange, xMin+0.30*xRange, yMax-0.05*yRange); PlasmaGlob::SetPaveTextStyle(textLabel[0],12); textLabel[0]->SetTextFont(42); textLabel[0]->AddText(sLabels[0]); textLabel[0]->Draw(); pad[0]->RedrawAxis(); C->cd(0); sprintf(pname,"pad_%i",0); pad[1] = (TPad*) gROOT->FindObject(pname); pad[1]->Draw(); pad[1]->cd(); // <--------------------------------------------------------- Bottom Plot pad[1]->SetFrameLineWidth(3); pad[1]->SetTickx(1); hFrame = (TH2F*) gROOT->FindObject("hFrame2"); if(hFrame) delete hFrame; hFrame = (TH2F*) hDen2D[0]->Clone("hFrame2"); hFrame->Reset(); Float_t yFactor = pad[0]->GetAbsHNDC()/pad[1]->GetAbsHNDC(); hFrame->GetYaxis()->SetLabelSize(yFactor*0.085); hFrame->GetYaxis()->SetTitleSize(yFactor*0.09); hFrame->GetYaxis()->SetTitleOffset(0.7/yFactor); hFrame->GetYaxis()->SetTickLength(0.02/yFactor); hFrame->GetXaxis()->SetTitleSize(0.10); hFrame->GetXaxis()->SetLabelSize(0.08); hFrame->GetXaxis()->SetLabelOffset(0.02); hFrame->GetXaxis()->SetTitleOffset(1.0); hFrame->GetXaxis()->SetTickLength(0.04*yFactor); hFrame->SetLabelFont(42,"xyz"); hFrame->SetTitleFont(42,"xyz"); hFrame->Draw("col"); // hE2D[0]->GetZaxis()->SetNdivisions(505); hV2D->GetZaxis()->SetTitleFont(42); hV2D->GetZaxis()->SetTickLength(0.02/yFactor); exPot->Draw(); hV2D->Draw("col z same"); for(Int_t i=0; i<graphsV2D.GetEntriesFast(); i++) { TGraph *gr = (TGraph*) graphsV2D.At(i); if(!gr) continue; gr->Draw("C"); } for(Int_t i=0; i<graphsI2D.GetEntriesFast(); i++) { //if(i!=2) continue; TGraph *gr = (TGraph*) graphsI2D.At(i); if(!gr) continue; gr->Draw("C"); } if(opt.Contains("1dline")) { lineYzero->Draw(); lineYdown->Draw(); lineYup->Draw(); } if(opt.Contains("sline")) { if(zStartPlasma>xmin && zStartPlasma<xmax) lineStartPlasma->Draw(); if(zStartNeutral>xmin && zStartNeutral<xmax) lineStartNeutral->Draw(); if(zEndNeutral>xmin && zEndNeutral<xmax) lineEndNeutral->Draw(); } pad[1]->Update(); y1 = pad[1]->GetBottomMargin(); y2 = 1 - pad[1]->GetTopMargin(); x1 = pad[1]->GetLeftMargin(); x2 = 1 - pad[1]->GetRightMargin(); palette = (TPaletteAxis*)hV2D->GetListOfFunctions()->FindObject("palette"); if(palette) { palette->SetY2NDC(y2 - 0.00); palette->SetY1NDC(y1 + 0.00); palette->SetX1NDC(x2 + 0.005); palette->SetX2NDC(x2 + 0.03); // palette->SetTitleFont(42); palette->SetTitleSize(yFactor*0.075); palette->SetTitleOffset(0.80/yFactor); palette->SetLabelSize(yFactor*0.075); palette->SetLabelFont(42); palette->SetLabelOffset(0.01/yFactor); palette->SetBorderSize(2); palette->SetLineColor(1); } pad[1]->RedrawAxis(); textLabel[1] = new TPaveText(xMin + 0.02*xRange, yMax-0.2*yRange, xMin+0.30*xRange, yMax-0.05*yRange); PlasmaGlob::SetPaveTextStyle(textLabel[1],12); textLabel[1]->SetTextFont(42); textLabel[1]->AddText(sLabels[1]); textLabel[1]->Draw(); C->cd(); // Print to a file PlasmaGlob::imgconv(C,fOutName,opt); // --------------------------------------------------------- PlasmaGlob::DestroyCanvases(); }
void PlotRakeBunch( const TString &sim, Int_t time, Int_t index = 0, const TString &options="") { #ifdef __CINT__ gSystem->Load("libplasma.so"); #endif PlasmaGlob::Initialize(); TString opt = options; // Palettes! gROOT->Macro("PlasmaPalettes.C"); if(opt.Contains("grid")) { gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); } gStyle->SetLabelFont(42,"xyz"); gStyle->SetTextFont(62); // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; Bool_t CYL = kFALSE; if(sim.Contains("cyl")) CYL = kTRUE; Bool_t ThreeD = kFALSE; if(sim.Contains("3D")) ThreeD = kTRUE; // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1.; if(kp!=0.0) skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Time in OU Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; opt += "comovcenter"; // Centering time and z position: Double_t shiftz = pData->Shift(opt); TString sshiftz = Form("(x1-%f)",shiftz); if(opt.Contains("center")) { Time -= zStartPlasma; if(opt.Contains("comov")) // Centers on the head of the beam. Time += zStartBeam; } // Spatial coordinates intervals: Float_t x1Min = -4.3; Float_t x1Max = -3.9; Float_t x2Min = -0.5; Float_t x2Max = 0.5; Float_t x3Min = -0.5; Float_t x3Max = 0.5; // Momentum coordinates intervals: Float_t p1Min = 6500.01; Float_t p1Max = 10099.99; Float_t p2Min = -20.0; Float_t p2Max = 20.0; Float_t p3Min = -20.0; Float_t p3Max = 20.0; // Bining, intervals, labels, etc. Int_t xNbin = 200; Int_t yNbin = 200; if(sim.Contains("DR")) { xNbin = 200; yNbin = 200; // p1Min = 2200.01; // p1Max = 3399.99; // p1Min = 3500.01; // p1Max = 4999.99; p1Min = 1800.01; p1Max = 3999.99; // x1Min = -4.0; // x1Max = -3.2; x1Min = 8637.0; x1Max = 8639.0; x2Min = -0.5; x2Max = 0.5; x3Min = -0.5; x3Max = 0.5; } else if(sim.Contains("flash") && sim.Contains(".G.") ) { x1Min = -6.3; x1Max = -5.0; //p1Min = 0.001; p1Min = 650.001; p1Max = 1499.99; } else if(sim.Contains("facet_v23kA.G.A")) { x1Min = -7.8; x1Max = -7.1; x2Min = -1.0; x2Max = 1.0; x3Min = -1.0; x3Max = 1.0; // t=150 p1Min = 1100.001; p1Max = 1999.99; } else if(sim.Contains("facet_v23kA.G")) { x1Min = -7.8; x1Max = -7.0; x2Min = -1.0; x2Max = 1.0; x3Min = -1.0; x3Max = 1.0; // t=60 p1Min = 350.01; p1Max = 799.99; // t = 100 // p1Min = 700.01; // p1Max = 1399.99; // t=105 //p1Min = 800.001; //p1Max = 1399.99; // t=183 // p1Min = 1500.001; // p1Max = 2499.99; // t=235 // p1Min = 2000.01; // p1Max = 3499.99; // t=310 // p1Min = 2800.01; // p1Max = 4799.99; } // Get phasespace histos Int_t Nspecies = pData->NSpecies(); if(index>Nspecies-1) { return; } if(!pData->GetRawFileName(index)) { return; } TH1F *hX1 = NULL; TH1F *hP1 = NULL; TH2F *hP1X1 = NULL; TH2F *hP2X2 = NULL; cout << Form("\n1. Getting data... ") << endl; char cutString[512]; sprintf(cutString,"TMath::Abs(q)*(%s > %.1f && %s < %.1f && x2 > %.1f && x2 < %.1f && x3 > %.1f && x3 < %.1f)",sshiftz.Data(),x1Min,sshiftz.Data(),x1Max,x2Min,x2Max,x3Min,x3Max); TCut Cut = cutString; cout << Form(" (applied cut: \n %s)",cutString) << endl; TTree *tree = pData->GetTreeRaw(pData->GetRawFileName(index)->c_str(),opt); char hName[24]; char dCommand[128]; cout << Form("\n2. Dumping 1D histograms.. ") << endl; sprintf(hName,"hX1"); hX1 = (TH1F*) gROOT->FindObject(hName); if(hX1) delete hX1; hX1 = new TH1F(hName,"",xNbin,x1Min,x1Max); sprintf(dCommand,"%s>>%s",sshiftz.Data(),hName); cout << Form(" - x1. ") << endl; tree->Draw(dCommand,Cut,"goff"); sprintf(hName,"hP1"); hP1 = (TH1F*) gROOT->FindObject(hName); if(hP1) delete hP1; hP1 = new TH1F(hName,"",yNbin,p1Min,p1Max); sprintf(dCommand,"p1>>%s",hName); cout << Form(" - p1. ") << endl; tree->Draw(dCommand,Cut,"goff"); cout << Form("\n3. Dumping 2D histograms.. ") << endl; sprintf(hName,"hP1X1"); hP1X1 = (TH2F*) gROOT->FindObject(hName); if(hP1X1) delete hP1X1; hP1X1 = new TH2F(hName,"",xNbin,x1Min,x1Max,yNbin,p1Min,p1Max); sprintf(dCommand,"p1:%s>>%s",sshiftz.Data(),hName); cout << Form(" - p1 vs. x1 ") << endl; tree->Draw(dCommand,Cut,"goff"); sprintf(hName,"hP2X2"); hP2X2 = (TH2F*) gROOT->FindObject(hName); if(hP2X2) delete hP2X2; hP2X2 = new TH2F(hName,"",xNbin,x2Min,x2Max,yNbin,p2Min,p2Max); sprintf(dCommand,"p2:x2>>%s",hName); cout << Form(" - p2 vs. x2 ") << endl; tree->Draw(dCommand,Cut,"goff"); hX1->GetXaxis()->CenterTitle(); hX1->GetYaxis()->CenterTitle(); hX1->GetZaxis()->CenterTitle(); hP1X1->GetXaxis()->CenterTitle(); hP1X1->GetYaxis()->CenterTitle(); hP1X1->GetZaxis()->CenterTitle(); hP2X2->GetXaxis()->CenterTitle(); hP2X2->GetYaxis()->CenterTitle(); hP2X2->GetZaxis()->CenterTitle(); // Integrated long. emittance: cout << Form("\n4. Calculating integrated quantities.. ") << endl; Double_t xmean = 0.0; Double_t ymean = 0.0; Double_t x2mean = 0.0; Double_t y2mean = 0.0; Double_t xymean = 0.0; Double_t Ntotal = 0.0; for(Int_t i=1;i<=xNbin;i++) { Double_t x = hP1X1->GetXaxis()->GetBinCenter(i); // if(x<xmin || x>xmax) continue; for(Int_t j=1;j<=yNbin;j++) { Double_t y = hP1X1->GetYaxis()->GetBinCenter(j); // if(y<ymin || y>ymax) continue; Double_t value = TMath::Abs(hP1X1->GetBinContent(i,j)); xmean += x*value; ymean += y*value; x2mean += x*x*value; y2mean += y*y*value; xymean += x*y*value; Ntotal += value; } } xmean /= Ntotal; ymean /= Ntotal; x2mean /= Ntotal; y2mean /= Ntotal; xymean /= Ntotal; Double_t xrms2 = x2mean - xmean*xmean; Double_t yrms2 = y2mean - ymean*ymean; Double_t xrms = TMath::Sqrt(xrms2); Double_t yrms = TMath::Sqrt(yrms2); Double_t xyrms2 = xymean - xmean*ymean; Double_t emittance = TMath::Sqrt(xrms2*yrms2 - xyrms2*xyrms2); // cout << " xrms = " << xrms << endl; // Sliced emittance: // -------------------------------------------------------------------------- cout << Form("\n5. Slicing ") << endl; // Bining for sliced quantities: // const Int_t SNbin = 7; // Float_t sBinLim[SNbin+1] = {-4.16,-4.14,-4.12,-4.10,-4.08,-4.06,-4.04,-4.02}; // const Int_t SNbin = 7; // Float_t sBinLim[SNbin+1] = {-4.20,-4.17,-4.14,-4.12,-4.10,-4.08,-4.06,-4.00}; // const Int_t SNbin = 8; // Float_t sBinLim[SNbin+1] = {-3.93,-3.87,-3.81,-3.75,-3.69,-3.63,-3.57,-3.51,-3.45}; Int_t SNbin = 7; Float_t nsigma = 2; Float_t x1BinMin = -4.16; Float_t x1BinMax = -4.02; if(sim.Contains("DR")) { SNbin = 150; nsigma = 1.4; } else if(sim.Contains("facet_v23kA.G.A")) { SNbin = 46; nsigma = 1; x1BinMin = -7.55; x1BinMax = -7.25; } else if(sim.Contains("facet_v23kA.G")) { SNbin = 10; nsigma = 1; x1BinMin = -7.55; x1BinMax = -7.15; } Float_t *sBinLim = new Float_t[SNbin+1]; if(opt.Contains("rms")) { sBinLim[0] = xmean - nsigma*xrms; sBinLim[SNbin] = xmean + nsigma*xrms; } else { sBinLim[0] = x1BinMin; sBinLim[SNbin] = x1BinMax; } Float_t slbinSize = (sBinLim[SNbin] - sBinLim[0])/SNbin; for(Int_t i=1;i<SNbin;i++) { sBinLim[i] = sBinLim[i-1] + slbinSize; } TH1F **hP1sl = new TH1F*[SNbin]; TH2F **hP2X2sl = new TH2F*[SNbin]; cout << Form("\n - Dumping in %i bins ",SNbin) << endl; for(Int_t k=0;k<SNbin;k++) { cout<< Form("k = %i : (x1 > %f && x1 < %f)",k,sBinLim[k],sBinLim[k+1]) << endl; sprintf(hName,"hP2X2sl_%2i",k); hP2X2sl[k] = (TH2F*) gROOT->FindObject(hName); if(hP2X2sl[k]) delete hP2X2sl[k]; hP2X2sl[k] = new TH2F(hName,"",xNbin,x2Min,x2Max,yNbin,p2Min,p2Max); char zCutString[128]; sprintf(zCutString,"(%s > %f && %s < %f)",sshiftz.Data(),sBinLim[k],sshiftz.Data(),sBinLim[k+1]); TCut zCut = zCutString; tree->Project(hName,"p2:x2",Cut + zCut); sprintf(hName,"hP1sl_%2i",k); hP1sl[k] = (TH1F*) gROOT->FindObject(hName); if(hP1sl[k]) delete hP1sl[k]; hP1sl[k] = new TH1F(hName,"",yNbin,p1Min,p1Max); tree->Project(hName,"p1",Cut + zCut); } cout << Form("\n6. Calculating sliced quantities.. ") << endl; TGraph *gemit = NULL; TGraph *gYrms = NULL; TGraph *gErms = NULL; TGraph *gErmsB = NULL; Double_t * sxmean = new Double_t[SNbin]; Double_t * symean = new Double_t[SNbin]; Double_t * sx2mean = new Double_t[SNbin]; Double_t * sy2mean = new Double_t[SNbin]; Double_t * sxymean = new Double_t[SNbin]; Double_t * sNtotal = new Double_t[SNbin]; Double_t * sxrms2 = new Double_t[SNbin]; Double_t * syrms2 = new Double_t[SNbin]; Double_t * sxrms = new Double_t[SNbin]; Double_t * syrms = new Double_t[SNbin]; Double_t * sxyrms2 = new Double_t[SNbin]; Double_t * xbin = new Double_t[SNbin]; Double_t * semittance = new Double_t[SNbin]; Double_t * sNEtotal = new Double_t[SNbin]; Double_t * sEmean = new Double_t[SNbin]; Double_t * sE2mean = new Double_t[SNbin]; Double_t * sErms = new Double_t[SNbin]; for(Int_t k=0;k<SNbin;k++) { sxmean[k] = symean[k] = sx2mean[k] = sy2mean[k] = sxymean[k] = sNtotal[k] = sxrms2[k] = syrms2[k] = sxrms[k] = syrms[k] = sxyrms2[k] = xbin[k] = semittance[k] = 0.0; sNEtotal[k] = sEmean[k] = sE2mean[k] = sErms[k] = 0.0; xbin[k] = (sBinLim[k] + sBinLim[k+1])/2.; for(Int_t i=1;i<=xNbin;i++) { Double_t x = hP2X2sl[k]->GetXaxis()->GetBinCenter(i); // if(x<xmin || x>xmax) continue; for(Int_t j=1;j<=yNbin;j++) { Double_t y = hP2X2sl[k]->GetYaxis()->GetBinCenter(j); // if(y<ymin || y>ymax) continue; Double_t value = TMath::Abs(hP2X2sl[k]->GetBinContent(i,j)); sxmean[k] += x*value; symean[k] += y*value; sx2mean[k] += x*x*value; sy2mean[k] += y*y*value; sxymean[k] += x*y*value; sNtotal[k] += value; } } for(Int_t i=1;i<=yNbin;i++) { Double_t y = hP1sl[k]->GetXaxis()->GetBinCenter(i); Double_t value = TMath::Abs(hP1sl[k]->GetBinContent(i)); sEmean[k] += y*value; sE2mean[k] += y*y*value; sNEtotal[k] += value; } sxmean[k] /= sNtotal[k]; symean[k] /= sNtotal[k]; sx2mean[k] /= sNtotal[k]; sy2mean[k] /= sNtotal[k]; sxymean[k] /= sNtotal[k]; sxrms2[k] = sx2mean[k] - sxmean[k]*sxmean[k]; syrms2[k] = sy2mean[k] - symean[k]*symean[k]; sxrms[k] = TMath::Sqrt(sxrms2[k]); syrms[k] = TMath::Sqrt(syrms2[k]); sxyrms2[k] = sxymean[k] - sxmean[k]*symean[k]; semittance[k] = TMath::Sqrt(sxrms2[k]*syrms2[k] - sxyrms2[k]*sxyrms2[k]); sEmean[k] /= sNEtotal[k]; sE2mean[k] /= sNEtotal[k]; sErms[k] = TMath::Sqrt(sE2mean[k] - sEmean[k]*sEmean[k]); cout << " Bunch properties: " << endl; cout << Form(" xMean = %7.3f yMean = %7.3f",sxmean[k],symean[k]) << endl; cout << Form(" xRms = %7.3f yRms = %7.3f",sxrms[k],syrms[k]) << endl; cout << Form(" Emittance = %7.3f",semittance[k]) << endl; cout << Form(" Emean = %7.3f Erms = %7.3f",sEmean[k],sErms[k]) << endl; } // Charge Double_t dx1 = pData->GetDX(0); Double_t dx2 = pData->GetDX(1); Double_t dx3 = pData->GetDX(2); hX1->Scale(dx1*dx2*dx3); Double_t Charge = hX1->Integral(); // Charge *= dx1*dx2*dx3; if(opt.Contains("units")) { Double_t dV = skindepth * skindepth * skindepth; Charge *= n0 * dV * (PConst::ElectronCharge/PUnits::picocoulomb); cout << Form(" Integrated charge (RAW) of specie %3i = %8f pC",index,Charge) << endl; } else { cout << Form(" Integrated charge (RAW) of specie %3i = %8.4f n0 * kp^-3",index,Charge) << endl; } // Chaning to user units: // -------------------------- if(opt.Contains("units") && n0) { Int_t NbinsX = hP1X1->GetNbinsX(); Double_t xMin = skindepth * hP1X1->GetXaxis()->GetXmin() / PUnits::um; Double_t xMax = skindepth * hP1X1->GetXaxis()->GetXmax() / PUnits::um; Int_t NbinsY = hP1X1->GetNbinsY(); Double_t yMin = hP1X1->GetYaxis()->GetXmin() * pData->GetBeamMass() / PUnits::GeV; Double_t yMax = hP1X1->GetYaxis()->GetXmax() * pData->GetBeamMass() / PUnits::GeV; hP1X1->SetBins(NbinsX,xMin,xMax,NbinsY,yMin,yMax); // Converting electron density Double_t dVb = skindepth * skindepth * skindepth; Double_t dX = (xMax-xMin)/NbinsX; Double_t dE = (yMax-yMin)/NbinsY; for(Int_t j=0;j<hP1X1->GetNbinsX();j++) { for(Int_t k=0;k<hP1X1->GetNbinsY();k++) { Double_t binValue = fabs(hP1X1->GetBinContent(j,k) * dx1 * dx2 * dx3 * dVb * n0 * (PConst::ElectronCharge/PUnits::picocoulomb)); //cout << Form(" value = %f",binValue) << endl; hP1X1->SetBinContent(j,k,binValue); } } if(opt.Contains("comov")) hP1X1->GetXaxis()->SetTitle("#zeta [#mum]"); else hP1X1->GetXaxis()->SetTitle("z [#mum]"); hP1X1->GetYaxis()->SetTitle("p_{z} [GeV/c]"); hP1X1->GetZaxis()->SetTitle("dQ/d#zetadp_{z} [pC]"); hP1->SetBins(NbinsY,yMin,yMax); hP1->GetYaxis()->SetTitle("p_{z} [GeV/c]"); hX1->SetBins(NbinsX,xMin,xMax); Double_t binSize = (xMax - xMin)/NbinsX; Double_t dV = skindepth * skindepth * skindepth; Double_t lightspeed = PConst::c_light / (PUnits::um/PUnits::femtosecond); cout << Form("Speed of light = %f",lightspeed) << endl; hX1->Scale(TMath::Abs(n0 * dV * (PConst::ElectronCharge/PUnits::picocoulomb) * (lightspeed/binSize))); // hX1->Scale(TMath::Abs((PUnits::um/skindepth)*(PConst::ElectronCharge/PUnits::picocoulomb)*PConst::c_light)); // hX1->GetYaxis()->SetTitle("I[kA]"); hX1->GetYaxis()->SetTitle(""); if(opt.Contains("comov")) hX1->GetXaxis()->SetTitle("#zeta [#mum]"); else hX1->GetXaxis()->SetTitle("z [#mum]"); xmean *= skindepth / PUnits::um; xrms *= skindepth / PUnits::um; ymean *= pData->GetBeamMass() / PUnits::GeV; yrms *= pData->GetBeamMass() / PUnits::GeV; emittance *= (skindepth / PUnits::um); for(Int_t k=0;k<SNbin;k++) { xbin[k] *= skindepth / PUnits::um; sxmean[k] *= skindepth / PUnits::um; sxrms[k] *= skindepth / PUnits::um; symean[k] *= pData->GetBeamMass() / PUnits::MeV; syrms[k] *= pData->GetBeamMass() / PUnits::MeV; semittance[k] *= (skindepth / PUnits::um); sEmean[k] *= pData->GetBeamMass() / PUnits::GeV; sErms[k] *= 100 * pData->GetBeamMass() / PUnits::GeV / ymean; //sEmean[k]; // sErms[k] *= pData->GetBeamMass() / PUnits::GeV; } } // Create the graph with the emittances: gemit = new TGraph(SNbin,xbin,semittance); gYrms = new TGraph(SNbin,xbin,sxrms); gErms = new TGraph(SNbin,xbin,sErms); // Profile energy for p1 vs x1: TString pname = hP1X1->GetName(); pname += "_pfx"; TProfile *hP1X1prof = (TProfile*) gROOT->FindObject(pname.Data()); if(hP1X1prof) { delete hP1X1prof; hP1X1prof = NULL; } hP1X1prof = hP1X1->ProfileX("_pfx",1,-1,"s"); // get the errors from the profile: Int_t NP1X1Bins = hP1X1prof->GetNbinsX(); Double_t *x1bins = new Double_t[NP1X1Bins]; Double_t *eRms = new Double_t[NP1X1Bins]; for(Int_t i=1;i<=hP1X1prof->GetNbinsX();i++) { x1bins[i] = hP1X1prof->GetBinCenter(i); eRms[i] = 100 * hP1X1prof->GetBinError(i) / hP1X1prof->GetBinContent(i); } gErmsB = new TGraph(NP1X1Bins,x1bins,eRms); // Vertical Energy histogram: // -------------------------------------------------------------------------------- TGraph *gP1left = NULL; if(hP1) { Double_t *yarray = new Double_t[yNbin]; Double_t *xarray = new Double_t[yNbin]; // This is for the right side: // Double_t xMax = x1Min + (x1Max-x1Min) * 0.9; // Double_t xMin = x1Max; // And this for left: Double_t xMin = hX1->GetXaxis()->GetXmin(); Double_t xMax = hX1->GetXaxis()->GetXmin() + (hX1->GetXaxis()->GetXmax() -hX1->GetXaxis()->GetXmin()) * 0.2; Double_t EneMax = hP1->GetMaximum(); // cout << Form(" EneMax = %f ", EneMax) << endl; for(Int_t j=0; j<yNbin; j++) { yarray[j] = hP1->GetBinCenter(j+1); xarray[j] = ((xMax-xMin)/EneMax)*hP1->GetBinContent(j+1) + xMin; // cout << Form(" x = %f y = %f ", xarray[j],yarray[j]) << endl; } gP1left = new TGraph(yNbin,xarray,yarray); gP1left->SetLineColor(PlasmaGlob::elecLine); gP1left->SetLineWidth(2); gP1left->SetFillStyle(1001); gP1left->SetFillColor(PlasmaGlob::elecFill); } // Plotting // ----------------------------------------------- // Canvas setup // Create the canvas and the pads before the Frame loop // Resolution: Int_t sizex = 800; Int_t sizey = 600; if(opt.Contains("hres")) { Int_t sizex = 1600; Int_t sizey = 1200; } TCanvas *C = new TCanvas("C1","Evolution of Injection",sizex,sizey); C->cd(); // Set palette: PPalette * pPalette = (PPalette*) gROOT->FindObject("electron"); pPalette->cd(); // Float_t Max = hP1X1->GetMaximum(); // Float_t Min = hP1X1->GetMinimum(); // hP1X1->GetZaxis()->SetRangeUser(Min,Max); // Text objects TPaveText *textTime = new TPaveText(0.55,0.8,0.82,0.9,"NDC"); PlasmaGlob::SetPaveTextStyle(textTime,32); textTime->SetTextColor(kGray+2); char ctext[128]; if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"z = %5.1f mm", Time * skindepth / PUnits::mm); else sprintf(ctext,"t = %5.1f #omega_{p}^{-1}",Time); textTime->AddText(ctext); TPaveText *textDen = new TPaveText(0.15,0.85,0.48,0.9,"NDC"); PlasmaGlob::SetPaveTextStyle(textDen,12); textDen->SetTextColor(kOrange+10); if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"n_{0} = %5.2f x 10^{17} / cc", n0 / (1e17/PUnits::cm3)); else if(pData->GetBeamDensity() && pData->GetPlasmaDensity()) sprintf(ctext,"n_{b}/n_{0} = %5.2f", pData->GetBeamDensity()/n0); textDen->AddText(ctext); TPaveText *textWav = new TPaveText(0.15,0.2,0.48,0.25,"NDC"); PlasmaGlob::SetPaveTextStyle(textWav,12); textWav->SetTextColor(kGray+2); sprintf(ctext,"#lambda_{p} = %5.2f #mum", pData->GetPlasmaWaveLength() / PUnits::um); textWav->AddText(ctext); TPaveText *textCharge = new TPaveText(0.15,0.25,0.48,0.3,"NDC"); PlasmaGlob::SetPaveTextStyle(textCharge,12); textCharge->SetTextColor(kGray+2); if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"Charge = %5.2f pC", Charge); else sprintf(ctext,"Charge = %5.2f n0#timeskp^{-3}", Charge); textCharge->AddText(ctext); TPaveText *textMom = new TPaveText(0.55,0.03,0.82,0.13,"NDC"); PlasmaGlob::SetPaveTextStyle(textMom,32); textMom->SetTextColor(kGray+3); textMom->SetTextFont(62); if(opt.Contains("units") && pData->GetPlasmaDensity()) sprintf(ctext,"#LTp_{z}#GT = %5.2f GeV/c", ymean); else sprintf(ctext,"Mom = %5.2f mc", ymean); textMom->AddText(ctext); TPaveText *textInfo = new TPaveText(0.55,0.52,0.82,0.75,"NDC"); PlasmaGlob::SetPaveTextStyle(textInfo,32); textInfo->SetTextColor(kGray+2); textInfo->SetTextFont(42); sprintf(ctext,"Charge = %5.2f pC",Charge); textInfo->AddText(ctext); sprintf(ctext,"#LT#zeta#GT_{rms} = %5.2f #mum",xrms); textInfo->AddText(ctext); sprintf(ctext,"#LTp_{z}#GT_{rms} = %5.2f GeV/c",yrms); textInfo->AddText(ctext); // sprintf(ctext,"#epsilon_{N} = %5.2f #mum",emittance); // textInfo->AddText(ctext); // Setup Pad layout: const Int_t NFrames = 2; TPad **pad = new TPad*[NFrames]; TH1F *hFrame[NFrames]; Double_t lMargin = 0.15; Double_t rMargin = 0.18; Double_t bMargin = 0.15; Double_t tMargin = 0.04; Double_t vSpacing = 0.00; Double_t hStep = (1.-lMargin-rMargin); Double_t vStep = (1.- bMargin - tMargin - (NFrames-1) * vSpacing) / NFrames; Float_t vposd = 0.0; Float_t vposu = 0.0; Float_t vmard = 0.0; Float_t vmaru = 0.0; Float_t vfactor = 0.0; Float_t hposl = 0.0; Float_t hposr = 1.0; Float_t hmarl = lMargin; Float_t hmarr = rMargin; Float_t hfactor = 1.0; // Actual Plotting! // ------------------------------------------------------------ for(Int_t k=0;k<NFrames;k++) { // PLOTTING! if(k==0) { vposd = 0.0; vposu = bMargin + vStep; vfactor = vposu-vposd; vmard = bMargin / vfactor; vmaru = 0.0; } else if(k == NFrames-1) { vposd = vposu + vSpacing; vposu = vposd + vStep + tMargin; vfactor = vposu-vposd; vmard = 0.0; vmaru = tMargin / (vposu-vposd); } else { vposd = vposu + vSpacing; vposu = vposd + vStep; vfactor = vposu-vposd; vmard = 0.0; vmaru = 0.0; } hfactor = hposl-hposr; char name[16]; sprintf(name,"pad_%i",k); pad[k] = new TPad(name,"",hposl,vposd,hposr,vposu); // // cout << Form("%f %f %f %f",hposl,vposd,hposr,vposu) << endl; // // cout << Form("%f %f %f %f",hmarl,vmard,hmarr,vmaru) << endl; pad[k]->SetLeftMargin(hmarl); pad[k]->SetRightMargin(hmarr); pad[k]->SetBottomMargin(vmard); pad[k]->SetTopMargin(vmaru); pad[k]->SetFrameLineWidth(3); sprintf(name,"hFrame_%i",k); hFrame[k] = (TH1F*) gROOT->FindObject(name); if(hFrame[k]) delete hFrame[k]; hFrame[k] = (TH1F*) hX1->Clone(name); hFrame[k]->Reset(); hFrame[k]->GetXaxis()->CenterTitle(); hFrame[k]->GetYaxis()->CenterTitle(); hFrame[k]->GetZaxis()->CenterTitle(); hFrame[k]->SetLabelFont(42,"xyz"); hFrame[k]->SetTitleFont(42,"xyz"); hFrame[k]->SetNdivisions(505,"xyz"); hFrame[k]->SetTickLength(0.04,"xyz"); hFrame[k]->SetTickLength(0.04*vfactor,"y"); hFrame[k]->GetYaxis()->SetLabelSize(0.04/vfactor); hFrame[k]->GetYaxis()->SetLabelOffset(0.02); hFrame[k]->GetYaxis()->SetTitleSize(0.05/vfactor); hFrame[k]->GetYaxis()->SetTitleOffset(1.2*vfactor); if(k==0) { hFrame[k]->GetXaxis()->SetLabelSize(0.08); hFrame[k]->GetXaxis()->SetLabelOffset(0.02); hFrame[k]->GetXaxis()->SetTitleSize(0.12); hFrame[k]->GetXaxis()->SetTitleOffset(1.0); } else { hFrame[k]->GetXaxis()->SetLabelSize(0.0); hFrame[k]->GetXaxis()->SetTitleSize(0.0); } } // Ranges!! Double_t yMin = 999.9; Double_t yMax = -999.9; for(Int_t k=0;k<SNbin;k++) { if(semittance[k]<yMin) yMin = semittance[k]; if(semittance[k]>yMax) yMax = semittance[k]; if(sErms[k]<yMin) yMin = sErms[k]; if(sErms[k]>yMax) yMax = sErms[k]; } for(Int_t k=1;k<=xNbin;k++) { Double_t value = hX1->GetBinContent(k); if(value<yMin) yMin = value; if(value>yMax) yMax = value; } C->cd(); pad[1]->Draw(); pad[1]->cd(); if(opt.Contains("logz")) { gPad->SetLogz(1); } else { gPad->SetLogz(0); } hFrame[1]->GetYaxis()->SetRangeUser(hP1X1->GetYaxis()->GetXmin(),hP1X1->GetYaxis()->GetXmax()); if(opt.Contains("units")) hFrame[1]->GetYaxis()->SetTitle("p_{z} [GeV/c]"); hFrame[1]->Draw(); gP1left->SetLineWidth(2); gP1left->Draw("F"); gP1left->Draw("L"); TLine lZmean(xmean,hP1X1->GetYaxis()->GetXmin(),xmean,hP1X1->GetYaxis()->GetXmax()); lZmean.SetLineColor(kGray+2); lZmean.SetLineStyle(2); lZmean.Draw(); TLine lPmean(hP1X1->GetXaxis()->GetXmin(),ymean,hP1X1->GetXaxis()->GetXmax(),ymean); lPmean.SetLineColor(kGray+2); lPmean.SetLineStyle(2); lPmean.Draw(); hP1X1->GetYaxis()->SetNdivisions(503); hP1X1->GetZaxis()->SetNdivisions(503); hP1X1->GetZaxis()->SetRangeUser(0.001*hP1X1->GetMaximum(),hP1X1->GetMaximum()); hP1X1->GetZaxis()->SetLabelSize(0.05); hP1X1->GetZaxis()->SetTitleSize(0.04); hP1X1->GetZaxis()->SetTitleFont(42); hP1X1->Draw("colzsame"); // hP1X1->SetContour(20); // hP1X1->Draw("contzsame"); // hP1X1prof->SetMarkerStyle(1); // hP1X1prof->SetLineWidth(2); // hP1X1prof->Draw("zsame"); //hP1->Draw("C"); gPad->Update(); TPaletteAxis *palette = (TPaletteAxis*)hP1X1->GetListOfFunctions()->FindObject("palette"); if(palette) { Float_t y1 = gPad->GetBottomMargin(); Float_t y2 = 1 - gPad->GetTopMargin(); Float_t x1 = 1 - gPad->GetRightMargin(); palette->SetY2NDC(y2 - 0.04); palette->SetY1NDC(y1 + 0.04); palette->SetX1NDC(x1 + 0.01); palette->SetX2NDC(x1 + 0.04); palette->SetLabelFont(42); palette->SetLabelSize(0.08); //palette->SetLabelOffset(0.005/vfactor); palette->SetTitleSize(0.10); // palette->SetTitleOffset(9999.0*vfactor); palette->SetTitleOffset(0.6); palette->SetBorderSize(2); palette->SetLineColor(1); } textTime->Draw(); textInfo->Draw(); // textCharge->Draw(); textMom->Draw(); gPad->RedrawAxis(); // Bottom plot ----------------------------------------- C->cd(); pad[0]->Draw(); pad[0]->cd(); hFrame[0]->GetYaxis()->SetRangeUser(0.0,1.1*yMax); hFrame[0]->Draw(); hX1->SetLineWidth(2); hX1->SetFillStyle(1001); hX1->SetFillColor(PlasmaGlob::elecFill); // hX1->SetLineColor(kBlue); hX1->Draw("FL same"); //hX1->Draw("C"); TLine lZmean2(xmean,0.0,xmean,1.1*yMax); lZmean2.SetLineColor(kGray+2); lZmean2.SetLineStyle(2); lZmean2.Draw(); Int_t markerSize = 1.2; Int_t lineWidth = 2.0; gYrms->SetMarkerStyle(20); gYrms->SetLineStyle(1); gYrms->SetMarkerColor(kGray+1); gYrms->SetMarkerSize(markerSize); gYrms->SetLineColor(kGray+1); gYrms->SetLineWidth(lineWidth); gYrms->Draw("PL"); // hP2X2sl[0]->Draw("colz"); gemit->SetMarkerStyle(20); // gemit->SetMarkerColor(kMagenta-2); gemit->SetMarkerColor(kGray+2); gemit->SetMarkerSize(markerSize); gemit->SetLineWidth(lineWidth); gemit->SetLineColor(kGray+2); gemit->Draw("PL"); gErms->SetMarkerStyle(20); gErms->SetMarkerSize(markerSize); gErms->SetMarkerColor(kOrange+10); gErms->SetLineColor(kOrange+10); gErms->SetLineWidth(lineWidth); gErms->Draw("PL"); TLegend *Leg; if(!sim.Contains("DR")) Leg=new TLegend(0.55,0.60,1 - gPad->GetRightMargin() - 0.02,0.95); else Leg=new TLegend(gPad->GetLeftMargin() + 0.02, 1.0-gPad->GetTopMargin()-0.20, gPad->GetLeftMargin() + 0.30, 1.0-gPad->GetTopMargin()-0.02); PlasmaGlob::SetPaveStyle(Leg); Leg->SetTextAlign(12); Leg->SetTextColor(kGray+3); Leg->SetTextFont(42); Leg->SetLineColor(1); Leg->SetBorderSize(0); Leg->SetFillColor(0); Leg->SetFillStyle(1001); Leg->SetFillStyle(0); // Hollow Leg->AddEntry(hX1 ,"Current [kA]","L"); // Leg->AddEntry(gErms,"Energy spread (GeV)","PL"); Leg->AddEntry(gErms,"Energy spread [%]","PL"); Leg->AddEntry(gemit,"Emittance [#mum]","PL"); Leg->AddEntry(gYrms,"Bunch width [#mum]","PL"); Leg->Draw(); gPad->RedrawAxis(); gPad->Update(); // Print to file -------------------------------------- C->cd(); // Print to a file // Output file TString fOutName = Form("./%s/Plots/RakeBunch/RakeBunch",sim.Data()); fOutName += Form("-%s_%i",sim.Data(),time); PlasmaGlob::imgconv(C,fOutName,opt); // --------------------------------------------------------- }
void PlotField1D( const TString &sim, Int_t time, Int_t Nbins=1, const TString &options="") { #ifdef __CINT__ gSystem->Load("libplasma.so"); #endif PlasmaGlob::Initialize(); TString opt = options; gStyle->SetPadLeftMargin(0.10); // Margin left axis gStyle->SetPadRightMargin(0.12); // Margin right axis if(opt.Contains("grid")) { gStyle->SetPadGridX(1); gStyle->SetPadGridY(1); } // Load PData PData *pData = PData::Get(sim.Data()); pData->LoadFileNames(time); if(!pData->IsInit()) return; Bool_t CYL = kFALSE; if(sim.Contains("cyl")) { CYL = kTRUE; opt += "cyl"; } Bool_t ThreeD = kFALSE; if(sim.Contains("3D")) ThreeD = kTRUE; // Some plasma constants Double_t n0 = pData->GetPlasmaDensity(); Double_t kp = pData->GetPlasmaK(); Double_t skindepth = 1/kp; Double_t E0 = pData->GetPlasmaE0(); // Some beam properties: Float_t Ebeam = pData->GetBeamEnergy() * PUnits::MeV; Float_t gamma = Ebeam / PConst::ElectronMassE; Float_t vbeam = TMath::Sqrt(1 - 1/(gamma*gamma)); // cout << Form(" - Bunch gamma = %8.4f", gamma ) << endl; // cout << Form(" - Bunch velocity = %8.4f c", vbeam ) << endl; Float_t Time = pData->GetRealTime(); // z start of the plasma in normalized units. Float_t zStartPlasma = pData->GetPlasmaStart()*kp; // z start of the beam in normalized units. Float_t zStartBeam = pData->GetBeamStart()*kp; Time -= zStartPlasma - zStartBeam; // 1D histograms TString opth1 = opt; opth1 += "avg"; // Get electric fields const Int_t Nfields = 1; TH1F **hE1D = new TH1F*[Nfields]; for(Int_t i=0;i<Nfields;i++) { hE1D[i] = NULL; if(!pData->GetEfieldFileName(i)) continue; char nam[3]; sprintf(nam,"e%i",i+1); if(ThreeD) { if(i==0) hE1D[i] = pData->GetH1SliceZ3D(pData->GetEfieldFileName(i)->c_str(),nam,-1,Nbins,-1,Nbins,opth1.Data()); else hE1D[i] = pData->GetH1SliceZ3D(pData->GetEfieldFileName(i)->c_str(),nam,-Nbins,Nbins,-Nbins,Nbins,opth1.Data()); } else if(CYL) { // Cylindrical: The firt bin with r>0 is actually the number 1 (not the 0). if(i==0) hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,1,Nbins,opth1.Data()); else hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,1,Nbins,opth1.Data()); } else { // 2D cartesian if(i==0) hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,-1,Nbins,opth1.Data()); else hE1D[i] = pData->GetH1SliceZ(pData->GetEfieldFileName(i)->c_str(),nam,-Nbins,Nbins,opth1.Data()); } char hName[24]; sprintf(hName,"hE_%i",i); hE1D[i]->SetName(hName); if(opt.Contains("comov")) hE1D[i]->GetXaxis()->SetTitle("#zeta [c/#omega_{p}]"); else hE1D[i]->GetXaxis()->SetTitle("z [c/#omega_{p}]"); if(i==0) hE1D[i]->GetYaxis()->SetTitle("E_{z} [E_{0}]"); else if(i==1) hE1D[i]->GetYaxis()->SetTitle("E_{y} [E_{0}}]"); else if(i==2) hE1D[i]->GetYaxis()->SetTitle("E_{x} [E_{0}}]"); } // Chaning to user units: if(opt.Contains("units") && n0) { for(Int_t i=0;i<Nfields;i++) { Int_t NbinsX = hE1D[i]->GetNbinsX(); Float_t xMin = (skindepth/PUnits::mm) * hE1D[i]->GetXaxis()->GetXmin(); Float_t xMax = (skindepth/PUnits::mm) * hE1D[i]->GetXaxis()->GetXmax(); hE1D[i]->SetBins(NbinsX,xMin,xMax); for(Int_t j=0;j<NbinsX;j++) { hE1D[i]->SetBinContent(j, hE1D[i]->GetBinContent(j) * ( E0 / (PUnits::GV/PUnits::m) ) ); } if(opt.Contains("comov")) hE1D[i]->GetXaxis()->SetTitle("#zeta [mm]"); else hE1D[i]->GetXaxis()->SetTitle("z [mm]"); if(i==0) hE1D[i]->GetYaxis()->SetTitle("E_{z} [GV/m]"); else if(i==1) hE1D[i]->GetYaxis()->SetTitle("E_{y} [GV/m]"); else if(i==2) hE1D[i]->GetYaxis()->SetTitle("E_{x} [GV/m]"); } } // Calculate wave positions: // ---------------------------------------------------------------- // Retrieve the previous time TGraph if any; // Open TGraph TString filename = Form("./%s/Plots/Field1D/Field1D-%s.root",sim.Data(),sim.Data()); TFile * ifile = (TFile*) gROOT->GetListOfFiles()->FindObject(filename); // if doesn't exist the directory should be created if (!ifile) { TString f = filename; TString dir2 = f.Remove( f.Last( '/' ), f.Length() - f.Last( '/' ) ); TString dir1 = f.Remove( f.Last( '/' ), f.Length() - f.Last( '/' ) ); gSystem->mkdir( dir1 ); gSystem->mkdir( dir2 ); ifile = new TFile(filename,"UPDATE"); } Float_t *EMaxPos = new Float_t[Nfields]; Float_t *EMaxValue = new Float_t[Nfields]; // Get the Graph with the x1 positions of the maximum E_1 TGraph **graph = new TGraph*[Nfields]; char gName[24]; for(Int_t i=0;i<Nfields;i++) { if(!hE1D[i]) continue; EMaxPos[i] = EMaxValue[i] = -999; // Initial time search window: Float_t xCenter = (hE1D[i]->GetXaxis()->GetXmin()+hE1D[i]->GetXaxis()->GetXmax())/2.; Float_t xs1min = 0.5*(hE1D[i]->GetXaxis()->GetXmin()+xCenter); Float_t xs1max = xCenter; // For focusing fields i==1,2 we use a narrower window based on the previosly found // minimum for the accelerating fields i==0. if(i>0) { xCenter = EMaxPos[0]; if(opt.Contains("units") && n0) { xs1min = xCenter - (0.25*TMath::Pi() * 1e3 * skindepth); xs1max = xCenter + (0.25*TMath::Pi() * 1e3 * skindepth); } else { xs1min = xCenter - 0.25*TMath::Pi(); xs1max = xCenter + 0.25*TMath::Pi(); } } sprintf(gName,"gEMaxPos_%i",i); graph[i] = (TGraph*) ifile->Get(gName); if(graph[i]) { Double_t *y = graph[i]->GetY(); // Setup the searching windows to +/- pi/2 respect the last found minimum. if(opt.Contains("units") && n0) { xs1min = y[graph[i]->GetN()-1] - (0.5*TMath::Pi() * 1e3 * skindepth); xs1max = y[graph[i]->GetN()-1] + (0.5*TMath::Pi() * 1e3 * skindepth); } else { xs1min = y[graph[i]->GetN()-1] - 0.5*TMath::Pi(); xs1max = y[graph[i]->GetN()-1] + 0.5*TMath::Pi(); } delete graph[i]; } TH1F *htemp = (TH1F*) hE1D[i]->Clone("htemp"); htemp->GetXaxis()->SetRangeUser(xs1min,xs1max); //htemp->Smooth(1,"R"); Int_t binMax = htemp->GetMinimumBin(); EMaxPos[i] = (Float_t) htemp->GetBinCenter(binMax); EMaxValue[i] = (Float_t) htemp->GetBinContent(binMax); delete htemp; } // Tunning the Histograms // --------------------- // Plotting // ----------------------------------------------- // Output file TString fOutName = Form("./%s/Plots/Field1D/Field1D",sim.Data()); fOutName += Form("-%s_%i",sim.Data(),time); // Canvas setup TCanvas *C = new TCanvas("C","Electric wakefield on axis",850,1000); C->Divide(1,2); // Draw objects TPaveText *textTime = new TPaveText(0.70,0.87,0.85,0.92,"NDC"); PlasmaGlob::SetPaveTextStyle(textTime); char ctext[128]; if(opt.Contains("units") && n0) sprintf(ctext,"Z = %5.1f mm", 1e3 * skindepth * Time); else sprintf(ctext,"T = %5.1f 1/#omega_{p}",Time); textTime->AddText(ctext); // Colors Int_t fieldC = PlasmaGlob::fieldLine; Int_t phaseC = kGray+1; // Actual Plotting! // ------------------------------------------------------------ // More makeup C->cd(1); gPad->SetGridy(0); gPad->SetGridx(0); gPad->SetFrameLineWidth(2); hE1D[0]->SetLineWidth(1); hE1D[0]->GetYaxis()->CenterTitle(); hE1D[0]->GetXaxis()->CenterTitle(); hE1D[0]->SetLineStyle(1); hE1D[0]->SetLineWidth(3); hE1D[0]->SetLineColor(fieldC); hE1D[0]->SetMarkerStyle(20); if(Nfields>1) { hE1D[1]->GetYaxis()->CenterTitle(); hE1D[1]->GetXaxis()->CenterTitle(); hE1D[1]->SetLineStyle(1); hE1D[1]->SetLineWidth(1); hE1D[1]->SetLineColor(fieldC); hE1D[1]->SetMarkerStyle(24); } Float_t factor = 1.5; Float_t minimum = factor * hE1D[0]->GetMinimum(); Float_t maximum = factor * hE1D[0]->GetMaximum(); if(Nfields>1) { if(hE1D[1]->GetMaximum() > hE1D[0]->GetMaximum()) { maximum = factor * hE1D[1]->GetMaximum(); } if(hE1D[1]->GetMinimum() < hE1D[0]->GetMinimum()) { minimum = factor * hE1D[1]->GetMinimum(); } } if( maximum >= TMath::Abs(minimum)) minimum = -maximum; else maximum = - minimum; hE1D[0]->GetYaxis()->SetRangeUser(minimum,maximum); hE1D[0]->Draw("C"); if(Nfields>1) hE1D[1]->Draw("C same"); C->Update(); TLine *line0 = new TLine(hE1D[0]->GetXaxis()->GetXmin(), (gPad->GetUymin()+gPad->GetUymax())/2., hE1D[0]->GetXaxis()->GetXmax(), (gPad->GetUymin()+gPad->GetUymax())/2.); line0->SetLineColor(kGray+1); line0->SetLineStyle(2); line0->Draw(); TMarker *markEMax0 = new TMarker(EMaxPos[0],EMaxValue[0], 24); markEMax0->SetMarkerColor(fieldC); markEMax0->SetMarkerSize(1.6); markEMax0->Draw(); if(Nfields>1) { TMarker *markEMax1 = new TMarker(EMaxPos[1],EMaxValue[1], 24); markEMax1->SetMarkerColor(fieldC); markEMax1->SetMarkerSize(1.4); markEMax1->Draw(); } textTime->Draw(); // ---- // Define the TGraphs Int_t nPoints = 0; TGraph **gEMaxPos = new TGraph*[Nfields]; TGraph **gEMaxValue = new TGraph*[Nfields]; for(Int_t i=0;i<Nfields;i++) { if(!hE1D[i]) continue; sprintf(gName,"gEMaxPos_%i",i); gEMaxPos[i] = (TGraph*) ifile->Get(gName); if(gEMaxPos[i]==NULL) { gEMaxPos[i] = new TGraph(); gEMaxPos[i]->SetName(gName); } else { nPoints = gEMaxPos[i]->GetN(); } gEMaxPos[i]->Set(nPoints+1); if(opt.Contains("units") && n0) gEMaxPos[i]->SetPoint(nPoints, 1e3 * skindepth * Time,EMaxPos[i]); else gEMaxPos[i]->SetPoint(nPoints,Time,EMaxPos[i]); if(opt.Contains("units") && n0) { gEMaxPos[i]->GetYaxis()->SetTitle("#zeta_{min} [mm]"); gEMaxPos[i]->GetXaxis()->SetTitle("Z [mm]"); } else { gEMaxPos[i]->GetYaxis()->SetTitle("#zeta_{min} [c/#omega_{p}]"); gEMaxPos[i]->GetXaxis()->SetTitle("T [c/#omega_{p}]"); } gEMaxPos[i]->Write(gEMaxPos[i]->GetName(),TObject::kOverwrite); sprintf(gName,"gEMaxValue_%i",i); gEMaxValue[i] = (TGraph*) ifile->Get(gName); if(gEMaxValue[i]==NULL) { gEMaxValue[i] = new TGraph(); gEMaxValue[i]->SetName(gName); } else { nPoints = gEMaxValue[i]->GetN(); } gEMaxValue[i]->Set(nPoints+1); if(opt.Contains("units") && n0) gEMaxValue[i]->SetPoint(nPoints, 1e3 * skindepth * Time,EMaxValue[i]); else gEMaxValue[i]->SetPoint(nPoints,Time,EMaxValue[i]); if(opt.Contains("units") && n0) { gEMaxValue[i]->GetYaxis()->SetTitle("E_{min} [GV/m]"); gEMaxValue[i]->GetXaxis()->SetTitle("Z [mm]"); } else { gEMaxValue[i]->GetYaxis()->SetTitle("E_{min} [E_{0}]"); gEMaxValue[i]->GetXaxis()->SetTitle("T [c/#omega_{p}]"); } gEMaxValue[i]->Write(gEMaxValue[i]->GetName(),TObject::kOverwrite); } C->cd(2); gPad->SetGridy(1); gPad->SetGridx(0); gPad->SetFrameLineWidth(2); Float_t minPhase = 99.; Float_t maxPhase = -99.; Float_t minField = 99.; Float_t maxField = -99.; Double_t *yEMaxPos[Nfields]; Double_t *yEMaxValue[Nfields]; for(Int_t i=0;i<Nfields;i++) { yEMaxPos[i] = gEMaxPos[i]->GetY(); yEMaxValue[i] = gEMaxValue[i]->GetY(); for(Int_t j=0;j<gEMaxPos[0]->GetN();j++) { if(yEMaxPos[i][j]>maxPhase) maxPhase = yEMaxPos[i][j]; if(yEMaxPos[i][j]<minPhase) minPhase = yEMaxPos[i][j]; if(yEMaxValue[i][j]>maxField) maxField = yEMaxValue[i][j]; if(yEMaxValue[i][j]<minField) minField = yEMaxValue[i][j]; } } Float_t margin = (maxPhase - minPhase)/10; gEMaxPos[0]->GetYaxis()->SetRangeUser(minPhase-margin,maxPhase+margin); gEMaxPos[0]->GetYaxis()->CenterTitle(); gEMaxPos[0]->GetXaxis()->CenterTitle(); gEMaxPos[0]->SetLineColor(phaseC); gEMaxPos[0]->SetMarkerColor(phaseC); gEMaxPos[0]->SetLineWidth(3); gEMaxPos[0]->SetMarkerStyle(20); gEMaxPos[0]->SetMarkerSize(1.4); gEMaxPos[0]->Draw("APC"); if(Nfields>1) { gEMaxPos[1]->SetLineStyle(1); gEMaxPos[1]->SetLineColor(phaseC); gEMaxPos[1]->SetMarkerColor(phaseC); gEMaxPos[1]->SetLineWidth(1); gEMaxPos[1]->SetMarkerStyle(24); gEMaxPos[1]->SetMarkerSize(1.4); gEMaxPos[1]->Draw("PC"); } // Emax value // New axis first: C->Update(); // Needed for the axis! margin = (maxField - minField)/10; if (margin==0) margin = 1; Float_t rightmin = minField-margin; Float_t rightmax = maxField+margin; Float_t slope = (gPad->GetUymax() - gPad->GetUymin())/(rightmax-rightmin); TGaxis *axisEmax = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),gPad->GetUxmax(), gPad->GetUymax(),rightmin,rightmax,505,"+L"); axisEmax->SetLineWidth(1); axisEmax->SetLineColor(fieldC); axisEmax->SetLabelColor(fieldC); axisEmax->SetTitleColor(fieldC); if(opt.Contains("units") && n0) axisEmax->SetTitle("E_{min} [GV/m]"); else axisEmax->SetTitle("E_{min} [E_{0}]"); axisEmax->CenterTitle(); axisEmax->SetTitleSize(0.05); axisEmax->SetTitleOffset(1.2); axisEmax->SetLabelSize(0.05); axisEmax->SetLabelOffset(0.006); axisEmax->Draw(); // Adjust the TGraph Double_t *x = gEMaxValue[0]->GetX(); Double_t *y = gEMaxValue[0]->GetY(); for(Int_t i=0;i<gEMaxValue[0]->GetN();i++) { gEMaxValue[0]->SetPoint(i,x[i],(y[i]-rightmin)*slope + gPad->GetUymin()); } gEMaxValue[0]->SetLineColor(fieldC); gEMaxValue[0]->SetMarkerColor(fieldC); gEMaxValue[0]->SetLineWidth(3); gEMaxValue[0]->SetMarkerStyle(20); gEMaxValue[0]->SetMarkerSize(1.4); gEMaxValue[0]->Draw("PC"); if(Nfields>1) { x = gEMaxValue[1]->GetX(); y = gEMaxValue[1]->GetY(); for(Int_t i=0;i<gEMaxValue[1]->GetN();i++) { gEMaxValue[1]->SetPoint(i,x[i],(y[i]-rightmin)*slope + gPad->GetUymin()); } gEMaxValue[1]->SetLineColor(fieldC); gEMaxValue[1]->SetMarkerColor(fieldC); gEMaxValue[1]->SetLineWidth(1); gEMaxValue[1]->SetMarkerStyle(24); gEMaxValue[1]->SetMarkerSize(1.4); gEMaxValue[1]->Draw("PC"); } // Emax value // New axis first: C->Update(); // Needed for the axis! C->cd(); ifile->Close(); // Print to a file PlasmaGlob::imgconv(C,fOutName,opt); // --------------------------------------------------------- }