Main Page   Compound List   File List   Compound Members   File Members  

test.cpp

00001 #include "ReactorFortran.hh"
00002 #include "ReactorEvent.hh"
00003 #include "ReactorDetector.hh"
00004 #include "ReactorXC.hh"
00005 #include <iostream.h>
00006 #include <math.h>
00007 #include <string.h>
00008 
00009 int main(){
00010   //
00011   int nevents = 10000;
00012   char* fileName="th13.ntuple";
00013   char* ntName="event data";
00014   //
00015   // init random number seed
00016   //
00017   int luxury = 2;
00018   int seed = 8796896;
00019   int k1=0;
00020   int k2=0;
00021   rluxgo_(luxury,seed,k1,k2);
00022   //
00023   // paw
00024   //
00025   hbook_init__();
00026   //
00027   int iostat;
00028   int ntId=1;
00029   int ntLun=99;
00030   int ntBuf=1024;
00031   char* dirName = "TEST    ";
00032   char* chopt = "N";
00033   hropen_(ntLun,dirName,fileName,chopt,ntBuf,iostat,
00034           strlen(dirName),strlen(fileName),strlen(chopt));
00035   //
00036   // define ntuple tags here
00037   //
00038   int wordsize = 8;
00039   int ntVars = 19;
00040   float tuple[ntVars];
00041   char ntTags[ntVars*wordsize];
00042   strcpy(ntTags+ 0*wordsize,"wtc      ");
00043   strcpy(ntTags+ 1*wordsize,"wtf      ");
00044   strcpy(ntTags+ 2*wordsize,"enu      ");
00045   strcpy(ntTags+ 3*wordsize,"KEpos    ");
00046   strcpy(ntTags+ 4*wordsize,"poscos   ");
00047   strcpy(ntTags+ 5*wordsize,"KEneu    ");
00048   strcpy(ntTags+ 6*wordsize,"neucos   ");
00049   strcpy(ntTags+ 7*wordsize,"vposr    ");
00050   strcpy(ntTags+ 8*wordsize,"vposcos  ");
00051   strcpy(ntTags+ 9*wordsize,"vposph   ");
00052   strcpy(ntTags+10*wordsize,"phpos    ");
00053   strcpy(ntTags+11*wordsize,"phneu    ");
00054   strcpy(ntTags+12*wordsize,"vneur    ");
00055   strcpy(ntTags+13*wordsize,"vneucos  ");
00056   strcpy(ntTags+14*wordsize,"vneuphi  ");
00057   strcpy(ntTags+15*wordsize,"tneu     ");
00058   strcpy(ntTags+16*wordsize,"npe      ");
00059   strcpy(ntTags+17*wordsize,"atten    ");
00060   strcpy(ntTags+18*wordsize,"sfact    ");
00061 
00062   //
00063   // set up paw ntuple
00064   //  
00065   hbookn_(ntId,ntName,ntVars,dirName,1000,ntTags,
00066           strlen(ntName),strlen(dirName),wordsize,ntVars);
00067   //
00068   // last argument is need for c++ ==> f strings
00069   //
00070   hbook1_(101,"phpos",200,0,0.02,0,strlen("phpos"));
00071   hbook1_(102,"phneu",200,0,0.02,0,strlen("phneu"));
00072   //
00073   hbook1_(201,"tpos",200,0,50,0,strlen("tpos"));
00074   hbook1_(202,"tneu",200,0,50,0,strlen("tneu"));
00075   //
00076   // set up simple detector model
00077   //
00078   ReactorDetector Detector;
00079   //
00080   // event loop
00081   //
00082   for (int events = 0;events<nevents;events++){
00083 
00084     ReactorEvent Event;
00085 
00086     double light = Detector.LightsOut(Event);
00087 
00088     tuple[ 0] = Event.GetXCWeight();
00089     tuple[ 1] = Event.GetFluxWeight();
00090     tuple[ 2] = Event.GetEnu();
00091     tuple[ 3] = Event.GetPositronKE();
00092     tuple[ 4] = Event.GetCosThetaLab();
00093     tuple[ 5] = Event.GetNeutronKE();
00094     tuple[ 6] = Event.GetNeutronCosTheta();
00095     tuple[ 7] = Event.GetVertexR();
00096     tuple[ 8] = Event.GetVertexCosTheta();
00097     tuple[ 9] = Event.GetVertexPhi();
00098     tuple[10] = Detector.GetPHpositron();
00099     tuple[11] = Detector.GetPHneutron();
00100     tuple[12] = Event.GetnVertexR();
00101     tuple[13] = Event.GetnVertexCosTheta();
00102     tuple[14] = Event.GetnVertexPhi();
00103     tuple[15] = Event.GetNeutronTime();
00104     tuple[16] = Detector.GetMeanNpe();
00105     tuple[17] = Detector.GetMeanAtten();
00106     tuple[18] = Detector.GetMeanSfactor();
00107 
00108     hfn_(ntId,tuple);
00109 
00110     int npmt=Detector.GetNpmt();
00111     for(int n=0;n<npmt;n++){
00112       double xyzpmt[3];
00113       double phpos,phneu;
00114       double tpos,tneu;
00115       
00116       Detector.GetPMTdata(n,xyzpmt,phpos,phneu,tpos,tneu);
00117 
00118       hfill_(101,phpos);
00119       hfill_(102,phneu);
00120 
00121       hfill_(201,tpos);
00122       hfill_(202,tneu);
00123     }
00124   }
00125   //
00126   // close up paw
00127   //
00128   hldir_(" "," ",strlen(" "),strlen(" "));
00129   char* dirName2 = "//TEST";
00130   hcdir_(dirName2," ",strlen(dirName2),strlen(" "));
00131   int outopt = 0;
00132   int icycle;
00133   hrout_(outopt,icycle," ",strlen(" "));
00134   hrend_(dirName,strlen(dirName));
00135 
00136          //  hbook_end__();
00137 }

Generated on Fri Oct 22 13:56:26 2004 for ReactorFsim by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002