1 ///////////////////////////////////////////////////////////////////////////
5 // This file is part of starlight.
7 // starlight is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
12 // starlight is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with starlight. If not, see <http://www.gnu.org/licenses/>.
20 ///////////////////////////////////////////////////////////////////////////
22 // File and Version Information:
23 // $Rev:: 102 $: revision of last commit
24 // $Author:: odjuvsla $: author of last commit
25 // $Date:: 2012-10-22 16:25:54 -0500 #$: date of last commit
31 ///////////////////////////////////////////////////////////////////////////
36 #include "reportingUtils.h"
37 #include "starlight.h"
38 #include "inputParameters.h"
39 #include "eventfilewriter.h"
40 #include "starlightStandalone.h"
46 starlightStandalone::starlightStandalone()
47 : _configFileName ("slight.in"),
48 _eventDataFileName("slight.out"),
52 _nmbEventsPerFile (_nmbEventsTot)
56 starlightStandalone::~starlightStandalone()
61 starlightStandalone::init()
63 // read input parameters from config file
64 inputParametersInstance.configureFromFile(_configFileName);
65 if (!inputParametersInstance.init()) {
66 printWarn << "problems initializing input parameters. cannot initialize starlight." << endl;
70 // get the number of events
71 // for now we write everything to one file
72 _nmbEventsTot = inputParametersInstance.nmbEvents();
73 _nmbEventsPerFile = _nmbEventsTot;
75 // create the starlight object
76 _starlight = new starlight();
78 // initialize starlight
79 return _starlight->init();
84 starlightStandalone::run()
87 printWarn << "null pointer to starlight object. make sure that init() was called. "
88 << "cannot generate events." << endl;
93 eventFileWriter fileWriter;
94 fileWriter.writeFullPythiaInfo(inputParametersInstance.pythiaFullEventRecord());
95 fileWriter.open(_eventDataFileName);
97 printInfo << "generating events:" << endl;
98 unsigned int nmbEvents = 0;
99 while (nmbEvents < _nmbEventsTot) {
100 for (unsigned int iEvent = 0; (iEvent < _nmbEventsPerFile) && (nmbEvents < _nmbEventsTot);
101 ++iEvent, ++nmbEvents) {
102 progressIndicator(iEvent, _nmbEventsTot, true, 4);
103 upcEvent event = _starlight->produceEvent();
104 // Boost event from CMS system to lab system
106 fileWriter.writeEvent(event, iEvent);
109 printInfo << "number of attempts = " << _starlight->nmbAttempts() << ", "
110 << "number of accepted events = " << _starlight->nmbAccepted() << endl;
115 void starlightStandalone::boostEvent(upcEvent &event)
118 // Should probably move this calculation to inputParameters (and remove from bbs)
119 // Calculate CMS boost
120 double rap1 = acosh(inputParametersInstance.beam1LorentzGamma());
121 double rap2 = -acosh(inputParametersInstance.beam2LorentzGamma());
122 double boost = (rap1+rap2)/2.;