Script for running root based C++ code


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script for running root based C++ code
# 1  
Old 09-23-2012
Script for running root based C++ code

Hi all,
I have to run C++ file using root programming, using following commands:
Code:
$root -l
root [0] .L TwoTrees.C++
root [2] TwoTrees t
root [3] t.Loop()
root[4].q


I wonder if I can write script to do the following.

Thanks
Pooja
# 2  
Old 09-23-2012
As in, feed that into the standard input of the program?

Code:
program <<EOF
.L TwoTrees.C++
TwoTrees t
t.Loop()
.q
EOF

Note that the last EOF is not indented and must not be indented.
# 3  
Old 09-23-2012
Hi,
Thanks for the reply. I am not sure what the variable "program" would be. I tried following,
Code:
#!/bin/bash                                                                                                                                           
date

root -l  <<EOF                                                                                                                                         
.L  TwoTrees.C++                                                                                                                                      
TwoTrees t                                                                                                                                      
 t.Loop()                                                                                                                                             
.q                                                                                                                                                    
EOF

The execution seems to be working [2], but immediately there was the following Error message [1]

[1]
Code:
Limitation: Function can not be defined in a command line or a tempfile
You need to write it in a source file (tmpfile):1:
*** Interpreter error recovered ***

[2]
Code:
poojasaxena@poojasaxena-laptop:~/Desktop/CMS/script/DataMCMatch/version3$ ./DataMC.sh 
Sun Sep 23 21:43:45 CEST 2012
Info in <TUnixSystem::ACLiC>: creating shared library /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees_C.so
In file included from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/TwoTrees_C_ACLiC_dict.h:34:0,
                 from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/TwoTrees_C_ACLiC_dict.cxx:17:
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:352:40: warning: "/*" within comment [-Wcomment]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:402:38: warning: "/*" within comment [-Wcomment]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:452:39: warning: "/*" within comment [-Wcomment]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:502:38: warning: "/*" within comment [-Wcomment]
In file included from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:2:0,
                 from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/TwoTrees_C_ACLiC_dict.h:34,
                 from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/TwoTrees_C_ACLiC_dict.cxx:17:
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.h:253:7: warning: unused parameter ‘entry' [-Wunused-parameter]
In file included from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./commonHeaders.h:10:0,
                 from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:3,
                 from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/TwoTrees_C_ACLiC_dict.h:34,
                 from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/TwoTrees_C_ACLiC_dict.cxx:17:
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvas(TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:57:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
In file included from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./commonHeaders.h:10:0,
                 from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:3,
                 from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/TwoTrees_C_ACLiC_dict.h:34,
                 from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/TwoTrees_C_ACLiC_dict.cxx:17:
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawProfileX(TH2F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:204:12: warning: variable ‘entry2' set but not used [-Wunused-but-set-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: At global scope:
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:193:7: warning: unused parameter ‘xtitle' [-Wunused-parameter]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:193:7: warning: unused parameter ‘dirName' [-Wunused-parameter]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:193:7: warning: unused parameter ‘gifName' [-Wunused-parameter]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvas2dFor2(TH2F*, TH2F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:275:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:280:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:267:10: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:287:8: warning: unused variable ‘clr' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasForIF3(TH2F*, TH2F*, TH2F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:360:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:366:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:352:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:373:9: warning: unused variable ‘clr' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasForUL7(TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:484:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:490:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:473:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:474:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasForUL3(TH2F*, TH2F*, TH2F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:678:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:684:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:661:12: warning: variable ‘myStack' set but not used [-Wunused-but-set-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:670:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:671:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:692:7: warning: unused variable ‘clr' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasForUL4LXLY(TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:801:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:807:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:793:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:794:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasForUL4LY(TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:954:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:960:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:946:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:947:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasFor2(TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1108:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1114:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1100:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1101:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasLogFor3(TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1235:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1241:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1227:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1228:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasFor3(TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1370:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1376:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1362:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1363:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasOverlayFor3(TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1496:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1502:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1528:48: warning: ISO C++ says that these are ambiguous, even though the worst conversion for the first is better than the worst conversion for the second: [enabled by default]
/opt/root5.34/root/include/TMathBase.h:199:17: note: candidate 1: Double_t TMath::Max(Double_t, Double_t)
/opt/root5.34/root/include/TMathBase.h:196:16: note: candidate 2: Float_t TMath::Max(Float_t, Float_t)
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1489:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1490:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasForUL4(TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1626:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1632:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1618:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1619:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasFor4St(TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1773:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1778:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1765:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1766:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvas2(TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1933:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1935:67: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:1940:69: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasForUL6(TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2047:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2053:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2039:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2040:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvas2withErr(TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2250:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2252:67: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2256:69: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasForUL4Ratio(TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2374:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2376:67: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2380:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2382:71: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2387:59: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasForUL6Ratio(TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2606:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2608:67: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2612:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2614:71: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2619:59: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasFit(TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2850:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2852:67: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2856:69: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasForUL11(TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2922:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2928:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2912:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:2913:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasForUL12(TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3188:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3194:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3178:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3179:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3426:9: warning: unused variable ‘mygifname' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasForUL13(TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3482:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3488:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3472:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3473:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3731:9: warning: unused variable ‘mygifname' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasForUL10(TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3785:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3787:67: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3791:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3793:71: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3775:9: warning: unused variable ‘pad1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:3776:9: warning: unused variable ‘pad2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvasCP4(TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:4030:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:4032:67: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:4036:69: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:4105:16: warning: comparison with string literal results in unspecified behaviour [-Waddress]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:4106:69: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:4108:16: warning: comparison with string literal results in unspecified behaviour [-Waddress]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:4109:65: warning: format ‘%f' expects argument of type ‘double', but argument 3 has type ‘int' [-Wformat]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc: In function ‘void drawCanvaswithErr(TH1F*, TH1F*, TH1F*, TH1F*, char*, char*, char*)':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:4197:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:4242:10: warning: unused variable ‘xlow' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./drawCanvas.cc:4243:10: warning: unused variable ‘xhigh' [-Wunused-variable]
In file included from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./commonHeaders.h:14:0,
                 from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:3,
                 from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/TwoTrees_C_ACLiC_dict.h:34,
                 from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/TwoTrees_C_ACLiC_dict.cxx:17:
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./utilities_TwoTrees.C: In member function ‘virtual bool TwoTrees::EB_EE_EB()':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./utilities_TwoTrees.C:13:10: warning: unused variable ‘cutee1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./utilities_TwoTrees.C:14:10: warning: unused variable ‘cutee2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./utilities_TwoTrees.C: In member function ‘virtual bool TwoTrees::EBe_EEe()':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./utilities_TwoTrees.C:45:10: warning: unused variable ‘cutee1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./utilities_TwoTrees.C:46:10: warning: unused variable ‘cutee2' [-Wunused-variable]
In file included from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/TwoTrees_C_ACLiC_dict.h:34:0,
                 from /home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/TwoTrees_C_ACLiC_dict.cxx:17:
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C: In member function ‘virtual void TwoTrees::Loop()':
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:546:29: warning: deprecated conversion from string constant to ‘char*' [-Wwrite-strings]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:556:29: warning: deprecated conversion from string constant to ‘char*' [-Wwrite-strings]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:560:86: warning: deprecated conversion from string constant to ‘char*' [-Wwrite-strings]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:566:39: warning: deprecated conversion from string constant to ‘char*' [-Wwrite-strings]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:574:45: warning: deprecated conversion from string constant to ‘char*' [-Wwrite-strings]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:583:40: warning: deprecated conversion from string constant to ‘char*' [-Wwrite-strings]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:592:45: warning: deprecated conversion from string constant to ‘char*' [-Wwrite-strings]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:601:53: warning: deprecated conversion from string constant to ‘char*' [-Wwrite-strings]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:28:10: warning: unused variable ‘Nww' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:37:10: warning: unused variable ‘wwPB' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:38:10: warning: unused variable ‘zzPB' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:39:10: warning: unused variable ‘wjetPB' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:40:10: warning: unused variable ‘qcd30To80PB' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:41:10: warning: unused variable ‘qcd50To80PB' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:46:7: warning: unused variable ‘HowMany' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:545:10: warning: unused variable ‘outputName3' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:546:10: warning: unused variable ‘xtitle3' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:565:10: warning: unused variable ‘outputName1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:566:10: warning: unused variable ‘xtitle1' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:573:10: warning: unused variable ‘outputName2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:574:10: warning: unused variable ‘xtitle2' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:582:10: warning: unused variable ‘outputName4' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:583:10: warning: unused variable ‘xtitle4' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:591:10: warning: unused variable ‘outputName5' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:592:10: warning: unused variable ‘xtitle5' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:600:10: warning: unused variable ‘outputName6' [-Wunused-variable]
/home/poojasaxena/Desktop/CMS/script/DataMCMatch/version3/./TwoTrees.C:601:10: warning: unused variable ‘xtitle6' [-Wunused-variable]
Limitation: Function can not be defined in a command line or a tempfile
You need to write it in a source file (tmpfile):1:
*** Interpreter error recovered ***

# 4  
Old 09-23-2012
replace 'root -L' with 'cat' to see if your program ends up as exactly what you want once you leave the here-document.
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 09-24-2012
Hi,
It is working. I found a typo..:P :P

Thanks Smilie

---------- Post updated 2012-09-24 at 08:39 AM ---------- Previous update was 2012-09-23 at 04:06 PM ----------

Hi Corona,
I wrote a complete script to fulfill my requirement [1]. It seems that I am making some mistake. It is throwing following error:
Code:
  Mon Sep 24 15:34:08 CEST 2012
./DataMC.sh: line 55: syntax error near unexpected token `exit'
./DataMC.sh: line 55: `    exit 0'

I guess, root based application does not need "exit 0", but then how shall I exit it.

Thanks

[1]
Code:
  #!/bin/bash 
date

FILENAME=$1

usage () {
    echo "Script to Run TwoTrees Function"
    echo "      ==Possible options=="
    echo "  loop    - For making DataMcPlot"
    echo "  pileup  - For PU plot"
    echo "  vtx     - For Vtx plot (Normazed to Unity w/o selection)"
    echo "  help                  - shows this help"
    echo "Example:   ./DataMC.sh option"
}

#For Running Loop()
RunLoop() {
root -l <<EOF
.L  TwoTrees.C++
TwoTrees t  
t.Loop()
.q 
EOF
}

#ForMakingPU 
MakePU() {
root -l <<EOF
.L  TwoTrees.C++                                                                                                                                     TwoTrees t
t.ToCheckPUReweight() 
EOF
}

#ForMakingVtx
MakeVtx() {
    root -l <<EOF
.L TwoTrees.C++
TwoTrees t
t.ToCheckVtx()
EOF
}

if [ $# -lt 1 ]; then
    usage
    exit 1
fi

if [ $1 = "help" ]; then
    usage
    exit 0

#For DataMC match
elif [ "$1" = "loop" ]; then
    RunLoop()
    exit 1

#For PU plot [normalized to unity && w/o selection]
elif [ "$1" = "pileup" ]; then
    MakePU()
    exit 0

#For vtx plot [normalized to unity && w/o selection]
elif [ "$1" = "vtx" ]; then
    MakeVtx()
    exit 0
fi

# 6  
Old 09-24-2012
Code:
MakeVtx() {
    root -l <<EOF
.L TwoTrees.C++
TwoTrees t
t.ToCheckVtx()
EOF
}

This is also function right..?

You should call this as. no need of round brackets. Not sure is that issue because of this... give a try..

Code:
elif [ "$1" = "vtx" ]; then
    MakeVtx
    exit 0
fi

# 7  
Old 09-24-2012
Hi,
Thanks Pamu, you are a life saver.SmilieSmilie

It worked..Smilie

---------- Post updated at 09:26 AM ---------- Previous update was at 09:05 AM ----------

Hi Pamu,
I modified it to take second variable as input,
Code:
  
SAMPLE=$2
#ForMakingPU                                                                                                                                          
MakePU() {
cat <<EOF                                                                                                                                             
.L  TwoTrees.C++                                                                                                                                      
TwoTrees t                                                                                                                                            
t.ToCheckPUReweight($2)                                                                                                                               
.q                                                                                                                                                    
EOF                                                                                                                                                   
}

It is not working, I did cat<<EOF to check the input, it is following:
Code:
  Mon Sep 24 16:25:32 CEST 2012
.L  TwoTrees.C++ 
TwoTrees t
t.ToCheckPUReweight() 
.q

Did not accept the second variable.

Thanks..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Running a script as root in the script

hi all, i think i have got the solution for this but want to run it past you guys first when i run a script sometimes its necassary to sudo to root so it can create users, chmod etc etc, the normal way for me doing this is just to simply run the script as root but i have created a user... (11 Replies)
Discussion started by: robertkwild
11 Replies

2. Shell Programming and Scripting

Root running a script calling to scp using user "xyz" is not authenticating!

Close duplicate thread. (0 Replies)
Discussion started by: denissi
0 Replies

3. Shell Programming and Scripting

Running a script as root but with different users inside

Hi All, my script.sh has the below lines, and i need to run the script as root or wam. please tell me if this will work #!/bin/bash sudo -t wam /usr/local/wam/stopwam -r ------- this needs run as wam user /usr/local/web/stopweb -a --- this needs to run as... (18 Replies)
Discussion started by: nanz143
18 Replies

4. Shell Programming and Scripting

Need to run a bash script that logs on as a non-root user and runs script as root

So I have a script that runs as a non-root user, lets say the username is 'xymon' . This script needs to log on to a remote system as a non-root user also and call up a bash script that runs another bash script as root. in short: user xymon on system A needs to run a file as root user and have... (2 Replies)
Discussion started by: damang111
2 Replies

5. UNIX and Linux Applications

Getting error code when running the script 2 (RC)2

hi All, we have a script to remove the files from particular path,when we tryingto run manually the script went to success and removed the files but the same script which is running by other team it got failed and giving the error "2 (RC)2 "..what is the cause of the failure..and we passing the... (2 Replies)
Discussion started by: nagavenkatesh
2 Replies

6. Shell Programming and Scripting

Issue running script as root

1) Environment:Red Hat Linux, bash shell Script to be run owned by user :myUser Home environment of myUser: pathto/home 2) ESP agent with root access will run JobXXX.sh su - myUser -c "/pathto/home/bin/script.sh" where script.sh has some echo statements and an exit statement in the end... (4 Replies)
Discussion started by: cj09
4 Replies

7. Cybersecurity

Running script through SSH as root

Hi all, I have a situation where I have a shell script that I need to run remotely on multiple *nix machines via SSH. Unfortunately, some of the commands in it require root access. I know that best practices for ssh entail configuring it so that the root account cannot log in, you need to... (4 Replies)
Discussion started by: irinotecan
4 Replies

8. Shell Programming and Scripting

As root , running script as different user with su - problem

Dear All I am running into a situation where I am running a script as another user lets say oracle using su command as below, and the script fails because the .profile of oracle is not executed so the environment variables are not set. cat /etc/passwd | grep oracle... (4 Replies)
Discussion started by: dbsupp
4 Replies

9. Shell Programming and Scripting

Running a command or script as root

I'm writing an application (Progress language) that needs to: 1) load the contents of a cron table into the Progress application; 2) display this information in a human manner and allow a select group of people to update it (these people are logged in as themselves, not as root); 3) save... (3 Replies)
Discussion started by: rm-r
3 Replies

10. UNIX for Dummies Questions & Answers

Run non-root script as root with non-root environment

All, I want to run a non-root script as the root user with non-root environment variables with crontab. The non-root user would have environment variables for database access such as Oracle or Sybase. The root user does not have the Oracle or Sybase enviroment variables. I thought you could do... (2 Replies)
Discussion started by: bubba112557
2 Replies
Login or Register to Ask a Question