(file) Return to thTree.c CVS log (file) (dir) Up to [HallC] / Analyzer / CTP

Diff for /Analyzer/CTP/thTree.c between version 1.2 and 1.5

version 1.2, 2004/07/02 18:46:29 version 1.5, 2004/07/09 20:44:11
Line 1 
Line 1 
 #ifdef ROOTTREE  
 /*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
  * Copyright (c) 1999      Thomas Jefferson National Accelerator Facility  * Copyright (c) 1999      Thomas Jefferson National Accelerator Facility
  *  *
Line 16 
Line 15 
  *  *
  * Revision History:  * Revision History:
  *   $Log$  *   $Log$
    *   Revision 1.5  2004/07/09 20:44:11  saw
    *   Can now put a test on a tree block
    *
    *
    *   Revision 1.1.16.2  2004/07/09 20:41:50  saw
    *   Can now put a test on a tree block
    *
    *   Revision 1.1.16.1  2004/07/09 14:12:11  saw
    *   Add ability for CTP to make ROOT Trees
    *
    *   Revision 1.4  2004/07/08 20:07:00  saw
    *   Supply dummy routines when ROOTSYS not defined
    *
    *   Revision 1.3  2004/07/07 18:16:30  saw
    *   Use properly exported names from thRootStuff.cpp
    *
  *   Revision 1.2  2004/07/02 18:46:29  saw  *   Revision 1.2  2004/07/02 18:46:29  saw
  *   Update ugly cpp routine for gcc 3.2.3.  Need to find a better way to  *   Update ugly cpp routine for gcc 3.2.3.  Need to find a better way to
  *   reference C++ routines.  *   reference C++ routines.
Line 37 
Line 52 
 #include "thInternal.h" #include "thInternal.h"
 #include "thUtils.h" #include "thUtils.h"
  
   #ifdef ROOTTREE
 extern daVarStatus thTreeRHandler(); extern daVarStatus thTreeRHandler();
  
 struct thLeafList {             /* Variable and index list */ struct thLeafList {             /* Variable and index list */
Line 96 
Line 112 
  
   /*  thHistZeroLastId(); */   /*  thHistZeroLastId(); */
  
   printf("In booktrees\n");    /* printf("In booktrees\n");*/
   /* Get the name without the block.test on it */   /* Get the name without the block.test on it */
   blockname = var->name;        /* If name doesn't fit pattern, use whole */   blockname = var->name;        /* If name doesn't fit pattern, use whole */
   if(strcasestr(var->name,BLOCKSTR)==var->name){   if(strcasestr(var->name,BLOCKSTR)==var->name){
Line 109 
Line 125 
     }     }
   }   }
  
   printf("Booking tree %s\n",blockname);    /*printf("Booking tree %s\n",blockname);*/
  
   if(var->opaque) thRemoveTree(blockname);   if(var->opaque) thRemoveTree(blockname);
  
Line 184 
Line 200 
             }             }
           }           }
         }         }
           if(p = strcasestr(lines,"test=")) {
             /* RHS must be a variable */
             char *varname=0; char *s; int len, testindex;
             daVarStruct *testp;
             p += 5;
             s = p;
             while(*s && !isspace(*s) && *s !='\n') s++;
             len = (s-p);
             varname = (char *) malloc(len+1);
             strncpy(varname,p,len);
             varname[len] = '\0';
             if(thVarResolve(varname,&testp,&testindex,1,0) != S_SUCCESS) {
               return(S_FAILURE); /* Test flag not registered */
         /* ASAP we must change this to register variables as they are needed */
         /* If the variable exists, then we also must check to make sure that
            the requested index does not exceed the size of the array.
            a new thVarResolve should also increase the size of the array if
            it was created by CTP */
             }
             treedef->test = testp;
             treedef->testindex = testindex;
           } else {
             treedef->test = 0; /* No test, always true */
           }
       }       }
  
       if(fname) {       if(fname) {
         /*printf("Opening Root file %s\n",fname);*/         /*printf("Opening Root file %s\n",fname);*/
         treedef->file = (void *) _Z12thRoot_TFilePc(fname);          treedef->file = (void *) thRoot_TFile(fname);
         free(fname);         free(fname);
       } else {       } else {
         /*printf("Opening Root file %s\n","ctp.tree");*/         /*printf("Opening Root file %s\n","ctp.tree");*/
         treedef->file = (void *) _Z12thRoot_TFilePc("ctp.root");          treedef->file = (void *) thRoot_TFile("ctp.root");
       }       }
  
       /*printf("Call to TTree(\"%s\",\"title\") goes here\n",blockname);*/       /*printf("Call to TTree(\"%s\",\"title\") goes here\n",blockname);*/
       treedef->treeptr = (void *) _Z12thRoot_TTreePc(blockname);        treedef->treeptr = (void *) thRoot_TTree(blockname);
  
       if(strcasestr(lines,BEGINSTR) != 0){       if(strcasestr(lines,BEGINSTR) != 0){
         /*      printf("Is a begin\n");*/         /*      printf("Is a begin\n");*/
Line 364 
Line 404 
   brancharg = malloc(lenbrancharg+10);   brancharg = malloc(lenbrancharg+10);
   brancharg[0] = '\0';   brancharg[0] = '\0';
   while(thisleaf) {   while(thisleaf) {
     /*    printf("thisleaf = %x\n",thisleaf);*/      /*printf("thisleaf = %x\n",thisleaf);
     /*printf("Adding %s to branchlist\n",thisleaf->name);*/        printf("Adding %s to branchlist\n",thisleaf->name);*/
     strcat(brancharg,thisleaf->name);     strcat(brancharg,thisleaf->name);
     if(thisleaf->varp->type == DAVARINT) {     if(thisleaf->varp->type == DAVARINT) {
       strcat(brancharg,"/I");       strcat(brancharg,"/I");
Line 408 
Line 448 
             - D : a 64 bit floating point (Double_t)             - D : a 64 bit floating point (Double_t)
   */   */
  
   /*printf("Branch=%s  Leafs=%s\n",Branch->branchname,brancharg);*/    printf("Branch=%s  Leafs=%s\n",Branch->branchname,brancharg);
   _Z13thRoot_BranchP5TTreePcPvS1_(treedef->treeptr,Branch->branchname,(Branch->evstruct),brancharg);    thRoot_Branch(treedef->treeptr,Branch->branchname,(Branch->evstruct),brancharg);
  
   free(brancharg);   free(brancharg);
   /*printf("Exiting book a branch\n");*/    printf("Exiting book a branch\n");
   return(S_SUCCESS);   return(S_SUCCESS);
 } }
  
Line 422 
Line 462 
   thLeafList *thisleaf;   thLeafList *thisleaf;
   void *structp;   void *structp;
   /*  printf("Executing Tree %s\n",var->name);*/   /*  printf("Executing Tree %s\n",var->name);*/
   
   treedef = ((thTreeOpaque *)(var->opaque));   treedef = ((thTreeOpaque *)(var->opaque));
   thisbranch = treedef->branchlistP;   thisbranch = treedef->branchlistP;
     if(! (treedef->test ? *((DAINT *) treedef->test->varptr
                             + treedef->testindex) : 1)) {
       return(S_SUCCESS);  /* Test was false */
     }
   while(thisbranch) {   while(thisbranch) {
     structp = thisbranch->evstruct;     structp = thisbranch->evstruct;
     /*    printf("Filling branch %s at %x\n",thisbranch->branchname,structp);*/     /*    printf("Filling branch %s at %x\n",thisbranch->branchname,structp);*/
Line 450 
Line 493 
     }     }
     thisbranch = thisbranch->next;     thisbranch = thisbranch->next;
   }   }
   _Z11thRoot_FillP5TTree(treedef->treeptr);    thRoot_Fill(treedef->treeptr);
  
   (*((DAINT *)var->varptr))++; /* Increment block counter */   (*((DAINT *)var->varptr))++; /* Increment block counter */
   return(S_SUCCESS);   return(S_SUCCESS);
 } }
 thStatus thClearTreeV(daVarStruct *var){ thStatus thClearTreeV(daVarStruct *var){
  
   printf("Clearing Tree %s\n",var->name);    /* printf("Clearing Tree %s\n",var->name); */
  
   (*((DAINT *)var->varptr)) = 0; /* Increment block counter */   (*((DAINT *)var->varptr)) = 0; /* Increment block counter */
   return(S_SUCCESS);   return(S_SUCCESS);
 } }
 thStatus thWriteTreeV(daVarStruct *var){ thStatus thWriteTreeV(daVarStruct *var){
  
   printf("Writing Tree %s\n",var->name);    /* printf("Writing Tree %s\n",var->name); */
   _Z12thRoot_WriteP14thRootFileList(((thTreeOpaque *)(var->opaque))->file);    thRoot_Write(((thTreeOpaque *)(var->opaque))->file);
  
   (*((DAINT *)var->varptr)) = 0; /* Increment block counter */   (*((DAINT *)var->varptr)) = 0; /* Increment block counter */
   return(S_SUCCESS);   return(S_SUCCESS);
 } }
 thStatus thCloseTreeV(daVarStruct *var){ thStatus thCloseTreeV(daVarStruct *var){
  
   printf("Closing Tree %s\n",var->name);    /*printf("Closing Tree %s\n",var->name);*/
   _Z12thRoot_CloseP14thRootFileList(((thTreeOpaque *)(var->opaque))->file);    thRoot_Close(((thTreeOpaque *)(var->opaque))->file);
  
   (*((DAINT *)var->varptr)) = 0; /* Increment block counter */   (*((DAINT *)var->varptr)) = 0; /* Increment block counter */
   return(S_SUCCESS);   return(S_SUCCESS);
Line 487 
Line 530 
 /* /*
 int thtreewrite_() int thtreewrite_()
 { {
   thRoot_Write__Fv();    thRoot_Write();
 } }
 */ */
  
   #else
   
   thStatus thBookTree(daVarStruct *var) {
     return(S_SUCCESS);
   }
   
   thStatus thFillTreeV(daVarStruct *var) {
     return(S_SUCCESS);
   }
   thStatus thClearTreeV(daVarStruct *var) {
     return(S_SUCCESS);
   }
   thStatus thWriteTreeV(daVarStruct *var) {
     return(S_SUCCESS);
   }
   thStatus thCloseTreeV(daVarStruct *var) {
     return(S_SUCCESS);
   }
   
 #endif #endif


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.5

Analyzer/Replay: Mark Jones, Documents: Stephen Wood
Powered by
ViewCVS 0.9.2-cvsgraph-1.4.0