Running root in each directory in windows

Hello on windows, is there a way to run ROOT in each directory in which I cd into??
I mean…if for example I’m in the directory C:/analysis and I’ve a macro in this directory, is there a way to run ROOT in this directory and to run the macro saved into it as it is possible using LINUX or MAC?
@bellenot surely you can answer


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Try:

std::cout << gSystem->pwd() << std::endl;
gSystem->cd("C:/analysis");
std::cout << gSystem->pwd() << std::endl;

HEllo @Wile_E_Coyote writing
std::cout << gSystem->pwd() << std::endl;
@bellenot in the root command line ROOT crashes…

Hi,

This is a known issue. Try:

std::cout << gSystem->pwd() << "\n";

And now, back to the original question: you can run ROOT in any directory once you executed C:\wherever\root\bin\thisroot.bat

Hello @bellenot, I tried…
actually I could run ROOT in other directory (I tried C:/analys) …but when I run the macro saved in this directory ROOT crashes… Notice that the macro works because I can use it on my laptop if it is saved in the $ROOT/macros directory and I can use it by the ROOT installed on cvmf (i.e. by vpn connection)

Then there is maybe something wrong in your macro. Can you attach it?

yes! this is the macro …but as I said, I use it saving it in the $ROOT/macros directory (on windows) and by vpn connection (linux)

PoissonUL.C (512 Bytes)

Well, it works with ROOT master:

C:\analysis>root -l
root [0] .L PoissonUL.C
root [1] PoissonUL(2)
5.32232
root [2]

I’ll try with v6.24.00 and we’ll see

I’ve tried this macro and it works in the C:/analysis directory…
muoneneene.cpp (2.4 KB)
Muon_ene_Beam-energy_Be.txt (92 Bytes)
Muon_ene_Beam-energy_C.txt (94 Bytes)

and it works in the C:/analysis directory…it looks like thae problem is with that macro!

Which ROOT version did you use?

C:\analysis>root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.24/00                        https://root.cern |
  | (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for win32 on Apr 14 2021, 14:33:50                         |
  | From tags/v6-24-00@v6-24-00                                      |
  | With MSVC 19.23.28107.0                                          |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'       |
   ------------------------------------------------------------------

root [0] .L PoissonUL.C
root [1] PoissonUL(2)
5.32232
root [2]

It’s weird…as I previously wrote other macros work in the C:/analysis directory in my laptop too…
I had the problem with that macro…but for you it works…
Well, don’t worry! it isn’t a big problem!
When I need this macro, I will run it saving it in the $ROOT/macros directory or by vpn connection!
It is important that other macros work in each directory because it was a bit annoying saving them in the $ROOT/macros directory
Thank you @bellenot

Can you list the content of your analysis directory?

Nothing…because I just created it to try running ROOT in each directory

OK, so I don’t know…

Don’t worry :slight_smile: as I said in the previous message, other macros work…then it isn’t a big problem if one doesn’t work!
when I need this macro, I will run it in the $ROOT/macros directory!

Thank you @bellenot

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.