Evio2nt

From New IAC Wiki
Jump to navigation Jump to search

summary

Evio2nt is supplied a .dat file, e.g. "r3245.dat", and creates a ROOT file named r3245.root containing a tree named "R1DC".

The resulting TTree has a single branch, which contains a structure defined below:

 
struct evt_t
{
  int EventNumber;
  int TDC1190[100][129]; 
};

evt_t evt;
tree->Branch("evt",&evt,"EventNumber/I:TDC1190[100][129]/I");



TDC1190[y][x]: y is the hit number x is the TDC channel.

TDC1190[0][x]: stores number of hits in channel x.


C code

#include <fstream>
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;


#ifndef __CINT__
#include "TFile.h"
#include "TH1.h"
#include "TH2.h"
#include "TProfile.h"
#include "TNtuple.h"
#include "TTree.h"
#include "TRandom.h"

#include "TApplication.h"
#include "TCanvas.h"
#include "TLine.h"
#include "TPaveLabel.h"

/* for posix */
#define _POSIX_SOURCE_ 1
#define __EXTENSIONS__


/*  misc macros, etc. */
#define MAXEVIOBUF   100000
#define MAXXMLSTRING 500000

/* include files */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <signal.h>
//#include "DecodeData.h"

/*  misc variables */
const char * filename;
//static char *filename;
static char *dictfilename = NULL;
static char *outfilename  = NULL;
static int gzip           = 0;
static char *main_tag     = (char*)"evio-data";
static int nevent         = 0;
static int skip_event     = 0;
static int max_event      = 0;
static int nevok          = 0;
static int evok[100];
static int nnoev          = 0;
static int noev[100];
static int nfragok        = 0;
static int fragok[100];
static int nnofrag        = 0;
static int nofrag[100];
static int pause1          = 0;
static int debug          = 0;
static int done           = 0;
static char xml[MAXXMLSTRING];


/* prototypes */
extern "C"
{
void decode_command_line(int argc, char **argv);
void writeit(FILE *f, char *s, int len);
int user_event_select(unsigned int *buf);
int user_frag_select(int tag);
int evOpen(const char *filename, const char *mode, int *handle);
int evRead(int handle, unsigned int *buf, int maxbuflen );
int evClose(int handle);
FILE *gzopen(char*,char*);
void gzclose(FILE*);
void gzwrite(FILE*,char*,int);
int set_event_tag(char *tag);
int set_bank2_tag(char *tag);
int set_n8(int val);
int set_n16(int val);
int set_n32(int val);
int set_n64(int val);
int set_w8(int val);
int set_w16(int val);
int set_w32(int val);
int set_w64(int val);
int set_xtod(int val);
int set_indent_size(int val);
int set_max_depth(int val);
int set_no_typename(int val);
int set_verbose(int val);
}



float GetData();

//
//  Tree format
//
//

struct evt_t
{
  int EventNumber;
/* 
first index is the hit number second is the channel number
TDC1190[0][x] = stored number of hits in channel x
TDC1190[y][x] = y is the hit number x is the TDC channel
*/
  int TDC1190[100][129]; 
};

//______________________________________________________________________________
//int main(int argc, char *argv[])
int main(int argc, char** argv)
{
  int i, j;
  int ChannelNum,buffLength,EventNum,EventType,EventLength;
  int HeaderID;
  int BunchID;
  evt_t evt;

  int handle,status;
  //size_t buf[MAXEVIOBUF];
  unsigned int buf[MAXEVIOBUF];
  FILE *out = NULL;
  char s[256];

  string teststring;
  string teststring2;
  const char * rootfilename;
  
 if(argc>1)
	{
//	  ChannelNum=atoi(argv[2]);
}
 else
{
	cout << "Please provide 1 arguments " << endl;
	cout << "Usage: evio2root -ffilename " << endl;
	exit(EXIT_FAILURE);
}

    cout << "Running program " << argv[0];

    cout << " the supplied arguments are:" << endl;

/*
    for (int i = 1; i < argc; i++) {
        cout << "arg " << i << " ";
        cout << argv[i] << endl;
    }

*/

   teststring=argv[1];
   teststring=string(argv[1],2,teststring.length());
   filename=teststring.c_str();
  cout << "filename = " << filename << endl;

  cout << "ADC " << ChannelNum << "for file " << filename << endl;	


//open root output file

  teststring2=string(argv[1],2,teststring.length()-4);
  cout << "teststring2 = " << teststring2 << endl;

   rootfilename=teststring2.c_str();

  cout << "root filename = " << rootfilename << endl;

  TFile *hfile  = new TFile(rootfilename,"RECREATE","DAQ");

  TTree *tree=new TTree("R1DC","Region 1 DC");

  tree->Branch("evt",&evt.EventNumber,"EventNumber/I:TDC1190[100][129]/I");

  float* NtupleEventArray = new float[66];


  //   ntuple = new TNtuple("ntuple","ADCs",NtupleColumnNames);
   NtupleEventArray[0]=0;

  /* decode command line */

//  decode_command_line(argc,argv);


  /* open evio input file */
  if((status=evOpen(filename,"r",&handle))!=0) {
    printf("\n ?Unable to open file %s, status=%d\n\n",filename,status);
    exit(EXIT_FAILURE);
  }

  /* loop over events, perhaps skip some, dump up to max_event events */
  nevent=0;
  NtupleEventArray[0]=0;

  while ((status=evRead(handle,buf,MAXEVIOBUF))==0) {
    nevent++;
    if(skip_event>=nevent)continue;
    if(user_event_select(buf)==0)continue;

    //DecodeData(buf,MAXXMLSTRING);


	for(i=1;i<66;i++)
	    NtupleEventArray[i]=0.0;
	NtupleEventArray[0]++;
	for(j=0;j<100;j++)
	  for(i=0;i<129;i++)
	    evt.TDC1190[j][i]=0;

	/*  The first word is a header and the last word is and event counter for the ADC output data*/

	buffLength=buf[0]; /* number of entries in the buf[buffLength] array*/
	EventType=(buf[1]>>16);

	if(EventType==1)
	  {
	    printf("\n\tBuffer Length=:\t%d\n",buf[0]);
	    
	    printf("Event type=%d\t%x\n",EventType,buf[1]);
	    
	    /*
	      dumb data array
	    for(i=0;i<buffLength;i++)
	    for(i=0;i<20;i++)
	      {
		printf("buf[%d]==%d\t%x\n",i,buf[i],buf[i]);
	      }
	    */
	    EventLength=buf[7];
	    printf("Found the following DAT banks\n");
	    for(i=9;i<8+EventLength;i++)
	      {
		/* fill histograms here     */
		HeaderID=((buf[i]>>27)&0x1F);

          if(HeaderID==8)/*General TDC header*/
            {
	      //	      printf("General TDC header\n");
              //printf("\tEventNumber=0x%x\t%d\n",(buf[i]>>5)&0x3FFFFF,(buf[i]>>5)&0x3FFFFF);
	      printf("Event:%d\n",(buf[i]>>5)&0x3FFFFF);
              
	      NtupleEventArray[0]=((buf[i]>>5)&0x3FFFFF);
	      evt.EventNumber=((buf[i]>>5)&0x3FFFFF);
            }
          if(HeaderID==1)/*TDC Header*/
            {

              /*
               printf("TDC header\n");
              printf("\tEventID=0x%x\t%d\n",(buf[i]>>12)&0xFFF,(buf[i]>>12)&0xFFF);
              printf("\tTDCnum=0x%x\t%d\n",(buf[11]>>24)&0x03,(buf[11]>>24)&0x3);
              */
	      BunchID=(buf[11])&0xfff;
              printf("\tBunchID=0x%x\t%d=%d\n",(buf[11])&0xfff,(buf[11])&0xfff,BunchID);
            }
          if(HeaderID==3)/*TDC trailer*/
            {
              /*
              printf("TDC trailer\n");
              printf("\tEventID=0x%x\t%d\n",(buf[i]>>12)&0xFFF,(buf[i]>>12)&0xFFF);
              printf("\tWord Count=0x%x\t%d\n",(buf[i]&0xFFF),(buf[i]&0xFFF));
              */
            }
          if(HeaderID==0)/*TDC data*/
            {
              //              printf("TDC data\n");
              //              printf("\tChan=0x%x\t%d\n",(buf[i]>>19)&0x7F,(buf[i]>>19)&0x7F);
              //printf("\tMeasurement=0x%x\t%d\n",(buf[i]&0x7FFFF),(buf[i]&0x7FFFF));
              printf("buf[%d]=%x\t",i,buf[i]);
              printf("\tChan:%d\t",1+(buf[i]>>21)&0x1F);
              printf("Measurement:%d\t",(buf[i]&0x1FFFFF));
              printf("%x\n",(buf[i]&0x1FFFFF));
              printf("Measurement-BunchID :%d\n",(buf[i]&0x1FFFFF)-BunchID);
		  //		  NtupleEventArray[((buf[i]>>19)&0x7F)-79]=((buf[i]&0x7FFFF));
	      //	      if(((buf[i]>>19)&0x7F)>0 && ((buf[i]>>19)&0x7F) < 129 && i==12)
	      //		    evt.TDC1190[((buf[i]>>19)&0x7F)]=(buf[i]&0x7FFFF)-BunchID;
	      if(((buf[i]>>21)&0x1F)>=0 && ((buf[i]>>21)&0x1F) < 129 )
		{
		  evt.TDC1190[0][1+((buf[i]>>21)&0x1F)]++; /* this counts the number of triggers*/
		  evt.TDC1190[evt.TDC1190[0][1+((buf[i]>>21)&0x1F)]][1+((buf[i]>>21)&0x1F)]=(buf[i]&0x1FFFFF);
		  printf("Channel %d has %d hits with last hit = %d\n", 1+(buf[i]>>21)&0x1F,evt.TDC1190[0][1+((buf[i]>>21)&0x1F)],buf[i]&0x1FFFFF);

		}
	      //	      if(((buf[i]>>19)&0x7F)>0 && ((buf[i]>>19)&0x7F) < 129 )
	      //		    evt.TDC1190[((buf[i]>>19)&0x7F)]=((buf[i]&0x1FFFF));

            }
          if(HeaderID==4)/*TDC Error*/
            {
              printf("TDC Error\n");
            }
	      
	  //		i+=buf[i];

	    
	      }
	    if((done!=0)||((nevent>=max_event+skip_event)&&(max_event!=0)))break;
	    
	    //	    ntuple->Fill(NtupleEventArray);
	    tree->Fill();
	  }
	printf("Event %d Summary\n",evt.EventNumber);
	for(j=0;j<129;j++)
	  {
	    //	    for(i=0;i<129;i++)
	      {
		if(evt.TDC1190[0][j]>0)
		  printf("Channel %d has %d hits with last hit = %d\n", j,evt.TDC1190[0][j],evt.TDC1190[evt.TDC1190[0][j]][j]);
	      }
	  }

  }
//  printf("Data for Channel # %d\n",ChannelNum);
//Hist1->Draw();
//c->Update();


  /* done */

  hfile->Write();

  // Close the file. Note that this is automatically done when you leave
  // the application.
  hfile->Close();

  evClose(handle);
  if((out!=NULL)&&(gzip!=0))gzclose(out);


//  theApp.Run();

  exit(EXIT_SUCCESS);

}
#endif

float GetData()
{
  Float_t random = gRandom->Rndm(1);
  
  return (2.5+random*5.0);
}



void writeit(FILE *f, char *s, int len) {

  if(f==NULL) {
    printf("%s",s);
  } else if (gzip==0) {
    fprintf(f,s,len);
  } else {
    gzwrite(f,s,len);
  }

}


/*---------------------------------------------------------------- */


int user_event_select(unsigned int *buf) {

  int i;
  int event_tag = buf[1]>>16;


  if((nevok<=0)&&(nnoev<=0)) {
    return(1);

  } else if(nevok>0) {
    for(i=0; i<nevok; i++) if(event_tag==evok[i])return(1);
    return(0);
    
  } else {
    for(i=0; i<nnoev; i++) if(event_tag==noev[i])return(0);
    return(1);
  }

}


/*---------------------------------------------------------------- */


int user_frag_select(int tag) {

  int i;

  if((nfragok<=0)&&(nnofrag<=0)) {
    return(1);

  } else if(nfragok>0) {
    for(i=0; i<nfragok; i++) if(tag==fragok[i])return(1);
    return(0);
    
  } else {
    for(i=0; i<nnofrag; i++) if(tag==nofrag[i])return(0);
    return(1);
  }

}




/*---------------------------------------------------------------- */


void decode_command_line(int argc, char**argv) {
  
  const char *help = 
    "\nusage:\n\n  evio2xml [-max max_event] [-pause] [-skip skip_event] [-dict dictfilename]\n"
    "           [-ev evtag] [-noev evtag] [-frag frag] [-nofrag frag] [-max_depth max_depth]\n"
    "           [-n8 n8] [-n16 n16] [-n32 n32] [-n64 n64]\n"
    "           [-w8 w8] [-w16 w16] [-w32 w32] [-w64 w64]\n"
    "           [-verbose] [-xtod] [-m main_tag] [-e event_tag]\n"
    "           [-indent indent_size] [-no_typename] [-debug]\n"
    "           [-out outfilenema] [-gz] filename\n";
  int i;
    
  printf("\nargc=%d\n",argc);    
  if(argc<2) {
    printf("%s\n",help);
    exit(EXIT_SUCCESS);
  } 


  /* loop over arguments */
  i=1;
  while (i<argc) {
    if (strncasecmp(argv[i],"-h",2)==0) {
      printf("%s\n",help);
      exit(EXIT_SUCCESS);

    } else if (strncasecmp(argv[i],"-pause",6)==0) {
      pause1=1;
      i=i+1;

    } else if (strncasecmp(argv[i],"-out",4)==0) {
      outfilename=strdup(argv[i+1]);
      i=i+2;

    } else if (strncasecmp(argv[i],"-debug",6)==0) {
      debug=1;
      i=i+1;

    } else if (strncasecmp(argv[i],"-gz",3)==0) {
      gzip=1;
      i=i+1;

    } else if (strncasecmp(argv[i],"-verbose",8)==0) {
      //      set_verbose(1);
      i=i+1;

    } else if (strncasecmp(argv[i],"-no_typename",12)==0) {
      //      set_no_typename(1);
      i=i+1;

    } else if (strncasecmp(argv[i],"-max_depth",10)==0) {
      //      set_max_depth(atoi(argv[i+1]));
      i=i+2;

    } else if (strncasecmp(argv[i],"-indent",7)==0) {
      //      set_indent_size(atoi(argv[i+1]));
      i=i+2;

    } else if (strncasecmp(argv[i],"-max",4)==0) {
      max_event=atoi(argv[i+1]);
      i=i+2;

    } else if (strncasecmp(argv[i],"-skip",5)==0) {
      skip_event=atoi(argv[i+1]);
      i=i+2;

    } else if (strncasecmp(argv[i],"-dict",5)==0) {
      dictfilename=strdup(argv[i+1]);
      i=i+2;

    } else if (strncasecmp(argv[i],"-xtod",5)==0) {
      //      set_xtod(1);
      i=i+1;

    } else if (strncasecmp(argv[i],"-ev",3)==0) {
      if(nevok<(sizeof(evok)/sizeof(int))) {
	evok[nevok++]=atoi(argv[i+1]);
	i=i+2;
      } else {
	printf("?too many ev flags: %s\n",argv[i+1]);
      }

    } else if (strncasecmp(argv[i],"-noev",5)==0) {
      if(nnoev<(sizeof(noev)/sizeof(int))) {
	noev[nnoev++]=atoi(argv[i+1]);
	i=i+2;
      } else {
	printf("?too many noev flags: %s\n",argv[i+1]);
      }

    } else if (strncasecmp(argv[i],"-frag",5)==0) {
      if(nfragok<(sizeof(fragok)/sizeof(int))) {
	fragok[nfragok++]=atoi(argv[i+1]);
	i=i+2;
      } else {
	printf("?too many frag flags: %s\n",argv[i+1]);
      }

    } else if (strncasecmp(argv[i],"-nofrag",7)==0) {
      if(nnofrag<(sizeof(nofrag)/sizeof(int))) {
	nofrag[nnofrag++]=atoi(argv[i+1]);
	i=i+2;
      } else {
	printf("?too many nofrag flags: %s\n",argv[i+1]);
      }

    } else if (strncasecmp(argv[i],"-n8",3)==0) {
      //      set_n8(atoi(argv[i+1]));
      i=i+2;

    } else if (strncasecmp(argv[i],"-n16",4)==0) {
      //      set_n16(atoi(argv[i+1]));
      i=i+2;

    } else if (strncasecmp(argv[i],"-n32",4)==0) {
      //      set_n32(atoi(argv[i+1]));
      i=i+2;

    } else if (strncasecmp(argv[i],"-n64",4)==0) {
      //      set_n64(atoi(argv[i+1]));
      i=i+2;

    } else if (strncasecmp(argv[i],"-w8",3)==0) {
      //      set_w8(atoi(argv[i+1]));
      i=i+2;

    } else if (strncasecmp(argv[i],"-w16",4)==0) {
      //      set_w16(atoi(argv[i+1]));
      i=i+2;

    } else if (strncasecmp(argv[i],"-w32",4)==0) {
      //      set_w32(atoi(argv[i+1]));
      i=i+2;

    } else if (strncasecmp(argv[i],"-w64",4)==0) {
      //      set_w64(atoi(argv[i+1]));
      i=i+2;

    } else if (strncasecmp(argv[i],"-m",2)==0) {
      main_tag=argv[i+1];
      i=i+2;

    } else if (strncasecmp(argv[i],"-e",2)==0) {
      //      set_event_tag(strdup(argv[i+1]));
      i=i+2;

    } else if (strncasecmp(argv[i],"-",1)==0) {
      printf("\n  ?unknown command line arg: %s\n\n",argv[i]);
      exit(EXIT_FAILURE);

    } else {
      break;
    }
  }
  
  /* last arg better be filename */
  //  filename=argv[argc];
//  filename="temp.dat";

  return;
}


/*---------------------------------------------------------------- */


Makewfile

#
# Makefile for the ROOT test programs.
# This Makefile shows nicely how to compile and link applications
# using the ROOT libraries on all supported platforms.
#
# Copyright (c) 2000 Rene Brun and Fons Rademakers
#
# Author: Fons Rademakers, 29/2/2000

include Makefile.arch
-include ../MyConfig.mk

#------------------------------------------------------------------------------


HSIMPLEO      = evio2nt.$(ObjSuf)
HSIMPLES      = evio2nt.$(SrcSuf)
HSIMPLE       = evio2nt$(ExeSuf)




OBJS          = $(HSIMPLEO) $(ANNAO)

PROGRAMS      = $(HSIMPLE) $(ANNA)

EVIO_HOME	= /home/daq/evio
EVIOINC	      = -I$(EVIO_HOME)/ -I/home/daq/CODA/ET/include 
EVIOLIBS      =-L$(EVIO_HOME) -L$(CODA_LIB) -lcoda -L/home/daq/CODA/ET/Linux-i686/lib -let -lexpat  -lieee -lrt -lpthread -lz -lm -lnsl -lresolv -ldl -rdynamic

#------------------------------------------------------------------------------

.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
.PHONY:    Aclock Hello Tetris

all:            $(PROGRAMS)

$(EVENTSO):     $(EVENTO)
ifeq ($(ARCH),aix)
		/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
else
ifeq ($(ARCH),aix5)
		/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
else
ifeq ($(PLATFORM),macosx)
# We need to make both the .dylib and the .so
		$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@
ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
ifeq ($(MACOSX_MINOR),4)
		ln -sf $@ $(subst .$(DllSuf),.so,$@)
else
		$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \
		   $(OutPutOpt) $(subst .$(DllSuf),.so,$@)
endif
endif
else
ifeq ($(PLATFORM),win32)
		bindexplib $* $^ > $*.def
		lib -nologo -MACHINE:IX86 $^ -def:$*.def \
		   $(OutPutOpt)$(EVENTLIB)
		$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) \
		   $(OutPutOpt)$@
		$(MT_DLL)
else
		$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(EXPLLINKLIBS)
endif
endif
endif
endif
		@echo "$@ done"

$(EVENTMTSO):     $(EVENTMTO)
ifeq ($(ARCH),aix)
		/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
else
ifeq ($(ARCH),aix5)
		/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
else
ifeq ($(PLATFORM),macosx)
# We need to make both the .dylib and the .so
		$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@
ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
ifeq ($(MACOSX_MINOR),4)
		ln -sf $@ $(subst .$(DllSuf),.so,$@)
else
		$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \
		   $(OutPutOpt) $(subst .$(DllSuf),.so,$@)
endif
endif
else
ifeq ($(PLATFORM),win32)
		bindexplib $* $^ > $*.def
		lib -nologo -MACHINE:IX86 $^ -def:$*.def \
		   $(OutPutOpt)$(EVENTMTLIB)
		$(LD) $(SOFLAGS) $(LDFLAGS) $^ $*.exp $(LIBS) \
		   $(OutPutOpt)$@
		$(MT_DLL)
else
		$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(OutPutOpt) $@ $(EXPLLINKLIBS)
endif
endif
endif
endif
		@echo "$@ done"

$(HSIMPLE):     $(HSIMPLEO)
		$(LD) $(EVIOINC) $(LDFLAGS) $^ $(EVIOLIBS) $(LIBS) $(OutPutOpt)$@
		$(MT_EXE)
		@echo "$@ done"

$(ANNA):     $(ANNAO)
		$(LD) $(EVIOINC) $(LDFLAGS) $^ $(EVIOLIBS) $(LIBS) $(OutPutOpt)$@
		$(MT_EXE)
		@echo "$@ done"

$(MINEXAM):     $(MINEXAMO)
		$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
		$(MT_EXE)
		@echo "$@ done"

$(STRESSSP):    $(STRESSSPO)
ifeq ($(PLATFORM),win32)
		$(LD) $(LDFLAGS) $^ $(LIBS) '$(ROOTSYS)/lib/libSpectrum.lib' $(OutPutOpt)$@
		$(MT_EXE)
else
		$(LD) $(LDFLAGS) $^ $(LIBS) -lSpectrum $(OutPutOpt)$@
endif
		@echo "$@ done"

$(STRESSVEC):   $(STRESSVECO)
ifeq ($(PLATFORM),win32)
		$(LD) $(LDFLAGS) $^ $(LIBS) '$(ROOTSYS)/lib/libGenVector.lib' $(OutPutOpt)$@
		$(MT_EXE)
else
		$(LD) $(LDFLAGS) $^ $(LIBS) -lGenVector $(OutPutOpt)$@
endif
		@echo "$@ done"






$(TRACKMATHLIB):	$(TRACKMATHOBJ)
ifeq ($(ARCH),aix)
		/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
else
ifeq ($(ARCH),aix5)
		/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
else
ifeq ($(PLATFORM),macosx)
# We need to make both the .dylib and the .so
		$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@
ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
ifeq ($(MACOSX_MINOR),4)
		ln -sf $@ $(subst .$(DllSuf),.so,$@)
else
		$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \
		   $(OutPutOpt) $(subst .$(DllSuf),.so,$@)
endif
endif
else
		$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(LIBS) $(STRESSMATHLIBS) $(OutPutOpt)$@
		$(MT_DLL)
#endif
endif
endif
endif

$(STRESSMATH):   $(STRESSMATHO) $(TRACKMATHLIB)
ifeq ($(PLATFORM),win32)
		$(LD) $(LDFLAGS) $(STRESSMATHO) $(LIBS) $(STRESSMATHLIBS)  $(OutPutOpt)$@
		$(MT_EXE)
else
		$(LD) $(LDFLAGS) $(STRESSMATHO) $(LIBS) $(STRESSMATHLIBS)  $(OutPutOpt)$@
endif
		@echo "$@ done"


$(STRESSMATHMORE):   $(STRESSMATHMOREO)
ifeq ($(PLATFORM),win32)
		$(LD) $(LDFLAGS) $^ $(LIBS) $(STRESSMATHMORELIBS)  $(OutPutOpt)$@
		$(MT_EXE)
else
		$(LD) $(LDFLAGS) $^ $(LIBS) $(STRESSMATHMORELIBS)  $(OutPutOpt)$@
endif
		@echo "$@ done"

$(STRESSTMVA):   $(STRESSTMVAO)
ifeq ($(PLATFORM),win32)
		$(LD) $(LDFLAGS) $^ $(LIBS) $(STRESSTMVALIBS)  $(OutPutOpt)$@
		$(MT_EXE)
else
		$(LD) $(LDFLAGS) $^ $(LIBS) $(STRESSTMVALIBS)  $(OutPutOpt)$@
endif
		@echo "$@ done"

$(TESTBITS):    $(TESTBITSO)
		$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
		$(MT_EXE)
		@echo "$@ done"

$(THREADS):     $(THREADSO)
ifeq ($(PLATFORM),win32)
		$(LD) $(LDFLAGS) $^ $(LIBS) '$(ROOTSYS)/lib/libThread.lib' $(OutPutOpt)$@
		$(MT_EXE)
		@echo "$@ done"
else
ifeq ($(HASTHREAD),yes)
		$(LD) $(LDFLAGS) $^ $(LIBS) -lThread $(OutPutOpt)$@
		@echo "$@ done"
else
		@echo "This version of ROOT has no thread support, $@ not built"
endif
endif

$(QPRANDOM):    $(QPRANDOMO)
ifeq ($(PLATFORM),win32)
		$(LD) $(LDFLAGS) $^ $(LIBS) '$(ROOTSYS)/lib/libQuadp.lib' $(OutPutOpt)$@
		$(MT_EXE)
else
		$(LD) $(LDFLAGS) $^ $(LIBS) -lQuadp $(OutPutOpt)$@
endif
		@echo "$@ done"

$(GUITEST):     $(GUITESTO)
		$(LD) $(LDFLAGS) $^ $(GLIBS) $(OutPutOpt)$@
		$(MT_EXE)
		@echo "$@ done"

$(GUIVIEWER):   $(GUIVIEWERO)
		$(LD) $(LDFLAGS) $^ $(GLIBS) $(OutPutOpt)$@
		$(MT_EXE)
		@echo "$@ done"

$(STRESS):      $(STRESSO) $(EVENT)
		$(LD) $(LDFLAGS) $(STRESSO) $(EVENTO) $(LIBS) $(OutPutOpt)$@
		$(MT_EXE)
		@echo "$@ done"

$(STRESSGEOMETRY):  $(STRESSGEOMETRYO)
ifeq ($(PLATFORM),win32)
		$(LD) $(LDFLAGS) $^ $(LIBS) '$(ROOTSYS)/lib/libGeom.lib' $(OutPutOpt)$@
		$(MT_EXE)
else
		$(LD) $(LDFLAGS) $^ $(LIBS) -lGeom $(OutPutOpt)$@
endif
		@echo "$@ done"

$(STRESSSHAPES):  $(STRESSSHAPESO)
ifeq ($(PLATFORM),win32)
		$(LD) $(LDFLAGS) $^ $(LIBS) '$(ROOTSYS)/lib/libGeom.lib' $(OutPutOpt)$@
		$(MT_EXE)
else
		$(LD) $(LDFLAGS) $^ $(LIBS) -lGeom $(OutPutOpt)$@
endif
		@echo "$@ done"

$(STRESSFIT):   $(STRESSFITO)
		$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
		$(MT_EXE)
		@echo "$@ done"

$(STRESSHISTOFIT):   $(STRESSHISTOFITO)
ifeq ($(PLATFORM),win32)
		$(LD) $(LDFLAGS) $^ $(LIBS) '$(ROOTSYS)/lib/libUnuran.lib' $(OutPutOpt)$@
		$(MT_EXE)
else
		$(LD) $(LDFLAGS) $^ $(LIBS) -lUnuran $(OutPutOpt)$@
endif
		@echo "$@ done"

$(STRESSENTRYLIST):	$(STRESSENTRYLISTO)
		$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
		@echo "$@ done"

$(STRESSHEPIX): $(STRESSHEPIXO) $(STRESSGEOMETRY) $(STRESSFIT) $(STRESSL) \
                $(STRESSSP) $(STRESS)
		$(LD) $(LDFLAGS) $(STRESSHEPIXO) $(LIBS) $(OutPutOpt)$@
		$(MT_EXE)
		@echo "$@ done"

$(STRESSROOFITO): stressRooFit_tests.cxx

ifeq ($(shell $(ROOTCONFIG) --has-mathmore),yes)
ifeq ($(PLATFORM),win32)
EXTRAROOFITLIBS = '$(ROOTSYS)/lib/libMathMore.lib'
else
EXTRAROOFITLIBS = -lMathMore
endif
endif

$(STRESSROOFIT): $(STRESSROOFITO)
ifeq ($(PLATFORM),win32)
		$(LD) $(LDFLAGS) $^ $(LIBS) '$(ROOTSYS)/lib/libRooFit.lib' '$(ROOTSYS)/lib/libRooFitCore.lib' '$(ROOTSYS)/lib/libHtml.lib' '$(ROOTSYS)/lib/libThread.lib' '$(ROOTSYS)/lib/libMinuit.lib' '$(ROOTSYS)/lib/libFoam.lib' '$(ROOTSYS)/lib/libProof.lib' $(EXTRAROOFITLIBS) $(OutPutOpt)$@
		$(MT_EXE)
else
		$(LD) $(LDFLAGS) $^ $(LIBS) -lRooFit -lRooFitCore -lHtml -lThread -lMinuit -lFoam $(EXTRAROOFITLIBS) $(OutPutOpt)$@
endif
		@echo "$@ done"

$(STRESSPROOF): $(STRESSPROOFO)
ifeq ($(PLATFORM),win32)
		$(LD) $(LDFLAGS) $^ $(LIBS) '$(ROOTSYS)/lib/libProof.lib' '$(ROOTSYS)/lib/libThread.lib' $(OutPutOpt)$@
		$(MT_EXE)
else
		$(LD) $(LDFLAGS) $(STRESSPROOFO) $(LIBS) -lProof -lThread $(OutPutOpt)$@
endif
		@echo "$@ done"

$(BENCH):       $(BENCHO) $(TBENCHSO)
		$(LD) $(LDFLAGS) $(BENCHO) $(TBENCHO) $(LIBS) $(OutPutOpt)$@
		$(MT_EXE)
		@echo "$@ done"

Hello:          $(HELLOSO)
$(HELLOSO):     $(HELLOO)
ifeq ($(ARCH),aix)
		/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
else
ifeq ($(ARCH),aix5)
		/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
else
ifeq ($(PLATFORM),macosx)
# We need to make both the .dylib and the .so
		$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@
ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
ifeq ($(MACOSX_MINOR),4)
		ln -sf $@ $(subst .$(DllSuf),.so,$@)
else
		$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \
		   $(OutPutOpt) $(subst .$(DllSuf),.so,$@)
endif
endif
else
		$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(EXPLLINKLIBS) $(OutPutOpt)$@
		$(MT_DLL)
endif
endif
endif

Aclock:         $(ACLOCKSO)
$(ACLOCKSO):    $(ACLOCKO)
ifeq ($(ARCH),aix)
		/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
else
ifeq ($(ARCH),aix5)
		/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
else
ifeq ($(PLATFORM),macosx)
# We need to make both the .dylib and the .so
		$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@
ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
ifeq ($(MACOSX_MINOR),4)
		ln -sf $@ $(subst .$(DllSuf),.so,$@)
else
		$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \
		   $(OutPutOpt) $(subst .$(DllSuf),.so,$@)
endif
endif
else
		$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(EXPLLINKLIBS) $(OutPutOpt)$@
		$(MT_DLL)
endif
endif
endif

Tetris:         $(TETRISSO)
$(TETRISSO):    $(TETRISO)
ifeq ($(ARCH),aix)
		/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(GLIBS) -p 0 $^
else
ifeq ($(ARCH),aix5)
		/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(GLIBS) -p 0 $^
else
ifeq ($(PLATFORM),macosx)
# We need to make both the .dylib and the .so
		$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@
ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
ifeq ($(MACOSX_MINOR),4)
		ln -sf $@ $(subst .$(DllSuf),.so,$@)
else
		$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \
	 	   $(OutPutOpt) $(subst .$(DllSuf),.so,$@)
endif
endif
else
		$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(EXPLLINKLIBS) $(OutPutOpt)$@
		$(MT_DLL)
endif
endif
endif

$(TBENCHSO):    $(TBENCHO)
ifeq ($(ARCH),aix)
		/usr/ibmcxx/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
else
ifeq ($(ARCH),aix5)
		/usr/vacpp/bin/makeC++SharedLib $(OutPutOpt) $@ $(LIBS) -p 0 $^
else
ifeq ($(PLATFORM),macosx)
# We need to make both the .dylib and the .so
		$(LD) $(SOFLAGS)$@ $(LDFLAGS) $^ $(OutPutOpt) $@
ifneq ($(subst $(MACOSX_MINOR),,1234),1234)
ifeq ($(MACOSX_MINOR),4)
		ln -sf $@ $(subst .$(DllSuf),.so,$@)
else
		$(LD) -bundle -undefined $(UNDEFOPT) $(LDFLAGS) $^ \
		   $(OutPutOpt) $(subst .$(DllSuf),.so,$@)
endif
endif
else
		$(LD) $(SOFLAGS) $(LDFLAGS) $^ $(EXPLLINKLIBS) $(OutPutOpt)$@
		$(MT_DLL)
endif
endif
endif

$(STRESSINTERP): $(STRESSINTERPO) 
		$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
		$(MT_EXE)
		@echo "$@ done"

$(STRESSITER):	$(STRESSITERO) 
		$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
		$(MT_EXE)
		@echo "$@ done"

$(STRESSHIST):  $(STRESSHISTO)
		$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
		$(MT_EXE)
		@echo "$@ done"


clean:
		@rm -f $(OBJS) $(TRACKMATHSRC) core *Dict.*

distclean:      clean
		@rm -f $(PROGRAMS) $(EVENTSO) $(EVENTLIB) *Dict.* *.def *.exp \
		   *.root *.ps *.so *.lib *.dll *.d *.log .def so_locations \
		   files/*
		@rm -rf cxx_repository
		-@cd RootShower && $(MAKE) distclean
		-@cd rhtml && $(MAKE) distclean
		-@cd RootIDE && $(MAKE) distclean
		-@cd periodic && $(MAKE) distclean
		-@cd histviewer && $(MAKE) distclean

.SUFFIXES: .$(SrcSuf)

###
stressIterators.$(ObjSuf): stressIterators.h
 
Event.$(ObjSuf): Event.h
EventMT.$(ObjSuf): EventMT.h
MainEvent.$(ObjSuf): Event.h

EventDict.$(SrcSuf): Event.h EventLinkDef.h
	@echo "Generating dictionary $@..."
	$(ROOTCINT) -f $@ -c $^

EventMTDict.$(SrcSuf): EventMT.h EventLinkDef.h
	@echo "Generating dictionary $@..."
	$(ROOTCINT) -f $@ -c $^

Hello.$(ObjSuf): Hello.h
HelloDict.$(SrcSuf): Hello.h
	@echo "Generating dictionary $@..."
	$(ROOTCINT) -f $@ -c $^

Aclock.$(ObjSuf): Aclock.h
AclockDict.$(SrcSuf): Aclock.h
	@echo "Generating dictionary $@..."
	$(ROOTCINT) -f $@ -c $^

Tetris.$(ObjSuf): Tetris.h
TetrisDict.$(SrcSuf): Tetris.h
	@echo "Generating dictionary $@..."
	$(ROOTCINT) -f $@ -c $^

TBench.$(ObjSuf): TBench.h
TBenchDict.$(SrcSuf): TBench.h benchLinkDef.h
	@echo "Generating dictionary $@..."
	$(ROOTCINT) -f $@ -c $^

guiviewer.$(ObjSuf): guiviewer.h
guiviewerDict.$(SrcSuf): guiviewer.h guiviewerLinkDef.h
	@echo "Generating dictionary $@..."
	$(ROOTCINT) -f $@ -c $^

stressMathCore.$(ObjSuf): 	TrackMathCore.h
TrackMathCoreDict.$(SrcSuf): 	TrackMathCore.h TrackMathCoreLinkDef.h
	@echo "Generating dictionary $@ using rootcint ..."
	$(ROOTCINT) -f $@ -c $^	

TrackMathCoreRflx.$(SrcSuf): 	TrackMathCore.h TrackMathCoreRflx.xml
			@echo "Generating dictionary $@ using gccxml ..."
			genreflex TrackMathCore.h --selection_file=TrackMathCoreRflx.xml -o TrackMathCoreRflx.cxx  -I$(ROOTSYS)/include

.$(SrcSuf).$(ObjSuf):
	$(CXX)  $(CXXFLAGS) $(EVIOINC) -c $<

ifeq ($(GCC_MAJOR),4)
ifeq ($(GCC_MINOR),1)
TBenchDict.o: CXXFLAGS += -Wno-strict-aliasing
endif
endif

                                                                                                   6,1            1%