#include "ReactorFortran.hh"
#include "cfortran.h"
#include "ReactorConstants.hh"
#include "ReactorEvent.hh"
#include "ReactorDetector.hh"
#include "ReactorXC.hh"
#include "TFile.h"
#include "ReactorNtuple.hh"
#include "ReactorTree.hh"
#include "ReactorTrigger.hh"
#include <iostream.h>
#include <fstream.h>
#include <iomanip.h>
#include <math.h>
#include <string.h>
#include <cstdio>
Go to the source code of this file.
Compounds | |
| struct | PAWC_DEF |
Defines | |
| #define | PAWC_SIZE 50000 |
| #define | PAWC COMMON_BLOCK(PAWC,pawc) |
Functions | |
| COMMON_BLOCK_DEF (PAWC_DEF, PAWC) | |
| int | main () |
| Top level function of ReactorFsim. More... | |
Variables | |
| PAWC_DEF | PAWC |
ReactorFsim simulates any number of spherical, three-zone liquid scintillator neutrino detectors.
Main author: Tim Bolton
Contributing authors: Erin Abouzaid, Josh Klein, Matthew Worcester
Definition in file ReactorFsim.cpp.
|
|
Top level function of ReactorFsim. First sets the number of events, initializes paw, and defines each detector. The event loop creates an event and runs it through each detector added to the loop, so that each detector "sees" the exact same event each time. Finally, paw is closed and the hbook file created. Definition at line 42 of file ReactorFsim.cpp. References ReactorTree::CloseOut, ReactorTree::Fill, ReactorNtuple::Fill, ReactorDetector::LightsOut, ReactorDetector::SetParam_FastNeutronOption, ReactorDetector::SetParam_PMTDebugOption, ReactorDetector::SetParam_PMTMergeTime, ReactorDetector::SetParam_R0, ReactorDetector::SetParam_R1, ReactorDetector::SetParam_R2, and ReactorTrigger::Trigger.
00042 {
00043
00044 // ReactorNeutrons Neutrons;
00045 //
00046 // Set number of events, paw file name, and ntuple name
00047 //
00048 // defaults
00049 int nevents = 100;
00050 double r0=260;
00051 double r1=260;
00052 double rmaxgen=290;
00053 double r2=350;
00054 int fast=0;
00055 int PMTdebug = 0;
00056 double MergeTime = 1;
00057 int trigger=0;
00058 char* fileName="test.ntuple";
00059 char* rootName="test.root";
00060 char* ntName="event data";
00061 //
00062 // setup the event
00063 //
00064 fstream fin("src/event_setup.txt", ios::in);
00065 //cout << "setup file: src/event_setup.txt" << endl;
00066
00067 char paramLine[256];
00068 std::string dummy;
00069 bool done = false;
00070 std::string fastneutron;
00071 std::string trigsim;
00072 std::string PMTdebugoption;
00073 char pawFile[256];
00074 char rootFile[256];
00075
00076 while(!done){
00077
00078 // '#' specifies a comment line -- ignore it
00079 if(fin.peek() == '#'){
00080
00081 fin.getline(paramLine, 256);
00082 continue;
00083 }
00084
00085 // 'E'ND or 'e'nd specifies end of file -- set done flag to true
00086 if(fin.peek() == 'e' || fin.peek() == 'E'){
00087
00088 done = true;
00089 continue;
00090 }
00091
00092 // 'N'EVENT or 'n'event specifies the number of events
00093 if(fin.peek() == 'n' || fin.peek() == 'N'){
00094
00095 fin >> dummy;
00096 while(fin.peek() == ' ' || fin.peek() == '=')
00097 fin.ignore(1);
00098
00099 fin >> nevents;
00100
00101 if(nevents <= 0){
00102 cout << " SETUP ERROR: number of events <= 0!" << endl;
00103 nevents = 1;
00104 }
00105
00106 continue;
00107 }
00108
00109 // 'O'UTPUTFILE or 'o'utputfile specifies the output filename
00110 if(fin.peek() == 'o' || fin.peek() == 'O'){
00111
00112 fin >> dummy;
00113 while(fin.peek() == ' ' || fin.peek() == '=')
00114 fin.ignore(1);
00115
00116 fin >> pawFile;
00117 fileName = pawFile;
00118
00119 continue;
00120 }
00121
00122 // 'A'ROOTFILE or 'a'rootfile specifies the output filename
00123 if(fin.peek() == 'a' || fin.peek() == 'A'){
00124
00125 fin >> dummy;
00126 while(fin.peek() == ' ' || fin.peek() == '=')
00127 fin.ignore(1);
00128
00129 fin >> rootFile;
00130 rootName = rootFile;
00131
00132 continue;
00133 }
00134
00135 // 'R'ADII or 'r'adii specifies the three detector radii: R0 R1 R2
00136 if(fin.peek() == 'r' || fin.peek() == 'R'){
00137
00138 fin >> dummy;
00139 while(fin.peek() == ' ' || fin.peek() == '=')
00140 fin.ignore(1);
00141
00142 fin >> r0 >> r1 >> r2 >> rmaxgen;
00143
00144 continue;
00145 }
00146
00147 // 'F'ASTNEUTRON or 'f'astneutron turns on/off fast neutrons
00148 if(fin.peek() == 'f' || fin.peek() == 'F'){
00149
00150 fin >> dummy;
00151 while(fin.peek() == ' ' || fin.peek() == '=')
00152 fin.ignore(1);
00153
00154 fin >> fastneutron;
00155
00156 if(fastneutron == "off"){
00157 fast = 0;
00158 }
00159 else{
00160 fast = 1;
00161 }
00162
00163 continue;
00164 }
00165
00166 // 'B'PMTOUTPUTFILE 'b'PMTOUTPUTFILE turns on/off the PMT Debug file
00167 if(fin.peek() == 'b' || fin.peek() == 'B'){
00168
00169 fin >> dummy;
00170 while(fin.peek() == ' ' || fin.peek() == '=')
00171 fin.ignore(1);
00172
00173 fin >> PMTdebugoption;
00174
00175 if(PMTdebugoption == "on"){
00176 PMTdebug = 1;
00177 }
00178 else{
00179 PMTdebug = 0;
00180 }
00181 continue;
00182 }
00183
00184 // 'M'ERGETIME or 'm'ergetime specifies the PMTOutput Resolution (MergeTime)
00185 if(fin.peek() == 'm' || fin.peek() == 'M'){
00186
00187 fin >> dummy;
00188 while(fin.peek() == ' ' || fin.peek() == '=')
00189 fin.ignore(1);
00190
00191 fin >> MergeTime;
00192
00193 continue;
00194 }
00195
00196 // 'T'RIGGER or 't'rigger turns on/off trigger simulation
00197 if(fin.peek() == 't' || fin.peek() == 'T'){
00198
00199 fin >> dummy;
00200 while(fin.peek() == ' ' || fin.peek() == '=')
00201 fin.ignore(1);
00202
00203 fin >> trigsim;
00204
00205 if(trigsim == "off"){
00206 trigger = 0;
00207 }
00208 else{
00209 trigger = 1;
00210 }
00211
00212 continue;
00213 }
00214
00215 // skip K, P, and D
00216 if(fin.peek() == 'K' || fin.peek() == 'k' ||
00217 fin.peek() == 'P' || fin.peek() == 'p' ||
00218 fin.peek() == 'D' || fin.peek() == 'd'){
00219
00220 fin.getline(paramLine, 256);
00221 continue;
00222 }
00223
00224 // ignore extra whitespace
00225 if(fin.peek() == ' ' || fin.peek() == '\n'){
00226
00227 fin.ignore(1);
00228 continue;
00229 }
00230 }
00231 //
00232 cout << "ReactorFsim v0_0_5 by T. Bolton" << endl;
00233 cout << "===============================" << endl;
00234 cout << " " << nevents << " events" << endl;
00235 cout << " Paw output file: " << fileName << endl;
00236 cout << " Root output file: " << rootName << endl;
00237 cout << " R0 = " << r0 << ", R1 = " << r1 << ", R2 = " << r2
00238 << " (Rmaxgen = " << rmaxgen << ") cm" << endl;
00239 cout << " Fast neutrons are " << fastneutron << endl;
00240 cout << " Trigger simulation is " << trigsim << endl;
00241 cout << " PMT output debugging is " << PMTdebugoption << endl;
00242 cout << " PMT MergeTime is " << MergeTime << endl;
00243 cout << "===============================" << endl;
00244 //
00245 // init random number seed
00246 //
00247 int luxury = 2;
00248 int seed = 8796896;
00249 int k1=0;
00250 int k2=0;
00251 rluxgo_(luxury,seed,k1,k2);
00252 //
00253 // setup root output file and create tree
00254 //
00255 TFile *rfile= new TFile(rootName,"RECREATE","ReactorTree");
00256 ReactorTree rtree("RTree");
00257 //
00258 // Paw setup.
00259 //
00260 hlimit_(PAWC_SIZE);
00261 int iostat;
00262 int ntLun=99;
00263 int ntBuf=1024;
00264 char* dirName = "TEST";
00265 char* chopt = "N";
00266 hropen_(ntLun,dirName,fileName,chopt,ntBuf,iostat,
00267 strlen(dirName),strlen(fileName),strlen(chopt));
00268 //
00269 // Set up simple detector models
00270 // Set up simple Ntuple and histogranms
00271 // See ReactorNtuple.hh for ntuple/histogram details.
00272 //
00273
00274 ReactorDetector DetectorA;
00275 DetectorA.SetParam_FastNeutronOption(fast);
00276 DetectorA.SetParam_PMTDebugOption(PMTdebug);
00277 DetectorA.SetParam_PMTMergeTime(MergeTime);
00278 DetectorA.SetParam_R0(r0);
00279 DetectorA.SetParam_R1(r1);
00280 DetectorA.SetParam_R2(r2);
00281 ReactorNtuple ModelA(1,"model A",dirName);
00282 ReactorTrigger TriggerA;
00283 //
00284 // event loop
00285 //
00286 for (int events = 0;events<nevents;events++){
00287 //
00288 // create neutrino event
00289 //
00290 ReactorEvent Event(nevents,rmaxgen);
00291 //
00292 // create fast detector simulation
00293 //
00294 DetectorA.LightsOut(Event, events);
00295 ModelA.Fill(Event,DetectorA);
00296 rtree.Fill(Event,DetectorA);
00297 if(trigger) TriggerA.Trigger(Event,DetectorA);
00298 }
00299 // close up root
00300 //
00301 rfile->Write();
00302 rtree.CloseOut();
00303 // close up paw
00304 //
00305 hldir_(" "," ",strlen(" "),strlen(" "));
00306 char *dirName2 = new char[strlen(dirName)+2];
00307 *dirName2='\0';
00308 strcat(dirName2,"//");
00309 strcat(dirName2,dirName);
00310 hcdir_(dirName2," ",strlen(dirName2),strlen(" "));
00311 int outopt = 0;
00312 int icycle;
00313 hrout_(outopt,icycle," ",strlen(" "));
00314 hrend_(dirName,strlen(dirName));
00315 }
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002