Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:53

0001 #! /usr/bin/perl
0002 
0003 if (@ARGV < 1) {
0004    print "Usage: writePmonProject.pl <projectname>\n" ;
0005    print "   e.g writePmonProject.pl MyAnalysis \n" ;
0006    exit 1;
0007 }
0008 
0009 $projectname=$ARGV[0];
0010 
0011 print "creating project $projectname\n";
0012 
0013 open (CC, "> $projectname.cc");
0014 
0015 print CC <<EOF;
0016 
0017 #include <iostream>
0018 #include <pmonitor/pmonitor.h>
0019 #include "$projectname.h"
0020 
0021 #include <TH1.h>
0022 #include <TH2.h>
0023 
0024 int init_done = 0;
0025 
0026 using namespace std;
0027 
0028 //TH1F *h1; 
0029 //TH2F *h2; 
0030 
0031 
0032 int pinit()
0033 {
0034 
0035   if (init_done) return 1;
0036   init_done = 1;
0037 
0038   // h1 = new TH1F ( "h1","test histogram", 400, -50, 50); 
0039   // h2 = new TH2F ( "h2","test histogram 2D", 100, -50.5, 49.5, 100, -500, 500);  
0040 
0041   return 0;
0042 
0043 }
0044 
0045 int process_event (Event * e)
0046 {
0047 
0048   Packet *p = e->getPacket(1003);
0049   if (p)
0050     {
0051 
0052       //  h1->Fill ( p->iValue(3)/1000. );
0053       //  h2->Fill ( p->iValue(0), p->iValue(1) );
0054 
0055       delete p;
0056 
0057     }
0058   return 0;
0059 }
0060 
0061 EOF
0062 
0063 close CC;
0064 
0065 open (HH, "> $projectname.h");
0066 
0067 
0068 print HH "#ifndef __";
0069 print HH uc($projectname);
0070 print HH "_H__\n";
0071 print HH "#define __";
0072 print HH uc($projectname);
0073 print HH "_H__\n";
0074 
0075 print HH <<EOF;
0076 
0077 #include <pmonitor/pmonitor.h>
0078 #include <Event/Event.h>
0079 #include <Event/EventTypes.h>
0080 
0081 int process_event (Event *e); //++CINT 
0082 
0083 EOF
0084 print HH "#endif /* __";
0085 print HH uc($projectname);
0086 print HH "_H__ */\n";
0087 
0088 
0089 close HH;
0090 
0091 open (MF, "> $projectname.Makefile");
0092 
0093 print MF <<EOF;
0094 PACKAGE = $projectname
0095 
0096 ROOTFLAGS = \$(shell root-config --cflags)
0097 ROOTLIBS = \$(shell root-config --glibs)
0098 
0099 
0100 CXXFLAGS = -I.  \$(ROOTFLAGS) -I\$(ONLINE_MAIN)/include -I\$(OFFLINE_MAIN)/include
0101 RCFLAGS = -I.  -I\$(ONLINE_MAIN)/include -I\$(OFFLINE_MAIN)/include
0102 
0103 LDFLAGS = -Wl,--no-as-needed  -L\$(ONLINE_MAIN)/lib -L\$(OFFLINE_MAIN)/lib -lpmonitor -lEvent -lNoRootEvent -lmessage  \$(ROOTLIBS) -fPIC
0104 
0105 
0106 
0107 HDRFILES = \$(PACKAGE).h
0108 LINKFILE = \$(PACKAGE)LinkDef.h
0109 
0110 
0111 ADDITIONAL_SOURCES = 
0112 ADDITIONAL_LIBS = 
0113 
0114 
0115 SO = lib\$(PACKAGE).so
0116 
0117 \$(SO) : \$(PACKAGE).cc \$(PACKAGE)_dict.C \$(ADDITIONAL_SOURCES) \$(LINKFILE)
0118     \$(CXX) \$(CXXFLAGS) -o \$@ -shared  \$<  \$(ADDITIONAL_SOURCES) \$(PACKAGE)_dict.C \$(LDFLAGS)  \$(ADDITIONAL_LIBS)
0119 
0120 
0121 \$(PACKAGE)_dict.C : \$(HDRFILES) \$(LINKFILE)
0122     rootcint -f \$@  -c \$(RCFLAGS) \$^
0123 
0124 
0125 .PHONY: clean
0126 
0127 clean: 
0128     rm -f \$(SO) \$(PACKAGE)_dict.C \$(PACKAGE)_dict.h
0129 
0130 EOF
0131 
0132 close MF;
0133 
0134 if (! -e Makefile)
0135 {
0136     symlink ("$projectname.Makefile", "Makefile");
0137 }
0138          
0139 $lfname = $projectname . "LinkDef.h";
0140 open (LF, "> $lfname");
0141 print LF <<EOF;
0142 #ifdef __CINT__
0143 
0144 #pragma link C++ defined_in "$projectname.h";
0145 
0146 #endif /* __CINT__ */
0147 EOF
0148 
0149 close LF;
0150 
0151 open (HC, "> $projectname.C");
0152 print HC <<EOF;
0153 #include "$projectname.h"
0154 R__LOAD_LIBRARY(lib$projectname.so)
0155 
0156 void $projectname(const char * filename)
0157 {
0158   if ( filename != NULL)
0159     {
0160       pfileopen(filename);
0161     }
0162 }
0163 EOF
0164 
0165 
0166 open (HS, "> $projectname.sh");
0167 print HS <<EOF;
0168 #! /bin/bash
0169 
0170 FILE=\"\$1\"
0171 
0172 if [ -z \"\$FILE\" ] ; then
0173 
0174     root -l $projectname.C\\(0\\)
0175 else
0176 
0177     root -l $projectname.C\\(\\\"\$FILE\\\"\\)
0178 fi
0179 EOF
0180