Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions util/root_tree/froot.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ using namespace std;
extern "C" {
void initrootnt_(const char *title, const char *access, int ltitle, int laccess);
void reinitrootnt_(const char *access, int laccess);
void addntbranch_(float *element, const char *chtag, int ltag);
void addntbranch_(double *element, const char *chtag, int ltag);
void fillntbranch_(const char *chtag, int ltag);
int getnumbranches_();
void rootntoutp_();
Expand Down Expand Up @@ -87,6 +87,30 @@ char *truestr(const char *str, int len)
return tstr;
}//truestr->

//--------------------------------------------------------------------------
char *leaftruestr(const char *str, int len)
// Converts a Fortran character string str of length len into a properly
// formed C character string with '\0' at the end; trims blank spaces
// at the end of the string
// DJG: This version adds the definition of the data type to put in the leaf of the branch
// DJG: ("/D"=double)
{
int tlen=0;
char tem;
/*Counts non-blank charachters in a string str until a first blank character
or the end of the string is met*/

while (str[tlen] !=' ' && (tlen < len ) && (tem=str[tlen++],tem)) ;


char *tstr = new char[tlen+2];
strncpy(tstr,str,tlen);
tstr[tlen]='/';
tstr[tlen+1]='D';
tstr[tlen+2]='\0';

return tstr;
}//truestr->

void teststr_(const char *str,int lstr)
{
Expand Down Expand Up @@ -151,10 +175,10 @@ void reinitrootnt_(const char *access, int laccess)


//------------------------------------------------------------------------
void addntbranch_(float *element, const char *chtag, int ltag)
void addntbranch_(double *element, const char *chtag, int ltag)
//Add an ntuple branch pointing at a Fortran variable element
{
nt->Branch(truestr(chtag,ltag),element, truestr(chtag,ltag));
nt->Branch(truestr(chtag,ltag), element, leaftruestr(chtag,ltag));

return;
}//addntbranch_ ->
Expand Down Expand Up @@ -204,7 +228,7 @@ void printnt_()
//////////////////////////////////////////////////////////////////////////
void initrootnt_(const char *title, const char *access, int ltitle, int laccess){return;}
void reinitrootnt_(const char *access, int laccess){return;}
void addntbranch_(float *element, const char *chtag, int ltag){return;}
void addntbranch_(double *element, const char *chtag, int ltag){return;}
void fillntbranch_(const char *chtag, int ltag){return;}
int getnumbranches_(){return;}
void printnt_(){return;}
Expand Down
5 changes: 3 additions & 2 deletions util/root_tree/make_root_tree.f
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ program make_root_tree
external GetNumBranches

real*8 ntup(80)
real*4 ntup_out(80)
real*8 ntup_out(80)

parameter(nev=10000000)
io=99

c input filename
write(6,*) 'Enter filename to convert (without .bin extesntion)'
write(6,*) 'Enter filename to convert (without .bin extension)'
read(5,*) rawname
i=index(rawname,' ')
filename='../../worksim/'//rawname(1:i-1)//'.bin'
Expand All @@ -36,6 +36,7 @@ program make_root_tree
do i=1,NtupleSize
read(io) NtupleTag(i)
call AddNtBranch(ntup_out(i),NtupleTag(i))
write(6,*) NtupleTag(i)
enddo

c now loop over events
Expand Down