CMS 3D CMS Logo

Classes | Typedefs | Functions | Variables
externalGenerator.cc File Reference
#include "boost/program_options.hpp"
#include <atomic>
#include <csignal>
#include <iostream>
#include <string>
#include <thread>
#include "FWCore/TestProcessor/interface/TestProcessor.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/GenRunInfoProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/GenLumiInfoHeader.h"
#include "SimDataFormats/GeneratorProducts/interface/GenLumiInfoProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
#include "SimDataFormats/GeneratorProducts/interface/ExternalGeneratorEventInfo.h"
#include "SimDataFormats/GeneratorProducts/interface/ExternalGeneratorLumiInfo.h"
#include "FWCore/Services/interface/ExternalRandomNumberGeneratorService.h"
#include "FWCore/SharedMemory/interface/WriteBuffer.h"
#include "FWCore/SharedMemory/interface/ReadBuffer.h"
#include "FWCore/SharedMemory/interface/WorkerChannel.h"
#include "FWCore/SharedMemory/interface/ROOTSerializer.h"
#include "FWCore/SharedMemory/interface/ROOTDeserializer.h"
#include "FWCore/SharedMemory/interface/WorkerMonitorThread.h"

Go to the source code of this file.

Classes

class  Harness
 

Typedefs

template<typename T >
using Serializer = ROOTSerializer< T, WriteBuffer >
 

Functions

int main (int argc, char *argv[])
 

Variables

static char const *const kHelpCommandOpt = "help,h"
 
static char const *const kHelpOpt = "help"
 
static char const *const kMemoryNameCommandOpt = "memory-name,m"
 
static char const *const kMemoryNameOpt = "memory-name"
 
static char const *const kUniqueIDCommandOpt = "unique-id,i"
 
static char const *const kUniqueIDOpt = "unique-id"
 
static char const *const kVerboseCommandOpt = "verbose,v"
 
static char const *const kVerboseOpt = "verbose"
 

Typedef Documentation

◆ Serializer

template<typename T >
using Serializer = ROOTSerializer<T, WriteBuffer>

Definition at line 76 of file externalGenerator.cc.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

===============================================================================================================================================================================================


variant2: for each run define phi-averaged A for normalization channel (Dref,16) and then, divide Rijk on it, i.e. get RRijk

eta=27

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=19

eta=17

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=20

eta=19

eta=18

eta=27 L1=1

eta=25 L1=1

eta=23 L1=1

eta=22 L1=1

eta=21 L1=1

eta=29 L1=1

eta=26 L1=1

eta=24 L1=1

eta=20 L1=1

eta=19 L1=1

eta=18 L1=1

eta=17 L1=1

eta=28 L7=1

eta=27 L7=1

eta=25 L7=1

eta=23 L7=1

eta=22 L7=1

eta=21 L7=1

eta=26 L7=1

eta=24 L7=1

eta=20 L7=1

eta=19 L7=1

eta=18 L7=1

eta=17 L7=1

eta=27

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=19

eta=17

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=20

eta=19

eta=18

eta=27 L1=1

eta=25 L1=1

eta=23 L1=1

eta=22 L1=1

eta=21 L1=1

eta=26 L1=1

eta=24 L1=1

eta=20 L1=1

eta=19 L1=1

eta=18 L1=1

eta=17 L1=1

eta=28 L7=1

eta=27 L7=1

eta=25 L7=1

eta=23 L7=1

eta=22 L7=1

eta=21 L7=1

eta=26 L7=1

eta=24 L7=1

eta=20 L7=1

eta=19 L7=1

eta=18 L7=1

eta=17 L7=1

eta=27

eta=28

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

Prepare maps of good/bad channels:

Prepare maps of good/bad channels:

Definition at line 78 of file externalGenerator.cc.

78  {
79  std::string descString(argv[0]);
80  descString += " [--";
81  descString += kMemoryNameOpt;
82  descString += "] memory_name";
83  boost::program_options::options_description desc(descString);
84 
85  desc.add_options()(kHelpCommandOpt, "produce help message")(
87  boost::program_options::value<std::string>(),
88  "memory name")(kUniqueIDCommandOpt, boost::program_options::value<std::string>(), "unique id")(kVerboseCommandOpt,
89  "verbose output");
90 
91  boost::program_options::positional_options_description p;
92  p.add(kMemoryNameOpt, 1);
93  p.add(kUniqueIDOpt, 2);
94 
95  boost::program_options::options_description all_options("All Options");
96  all_options.add(desc);
97 
98  boost::program_options::variables_map vm;
99  try {
100  store(boost::program_options::command_line_parser(argc, argv).options(all_options).positional(p).run(), vm);
101  notify(vm);
102  } catch (boost::program_options::error const& iException) {
103  std::cout << argv[0] << ": Error while trying to process command line arguments:\n"
104  << iException.what() << "\nFor usage and an options list, please do 'cmsRun --help'.";
105  return 1;
106  }
107 
108  if (vm.count(kHelpOpt)) {
109  std::cout << desc << std::endl;
110  return 0;
111  }
112 
113  bool verbose = false;
114  if (vm.count(kVerboseOpt)) {
115  verbose = true;
116  }
117 
118  if (!vm.count(kMemoryNameOpt)) {
119  std::cout << " no argument given" << std::endl;
120  return 1;
121  }
122 
123  if (!vm.count(kUniqueIDOpt)) {
124  std::cout << " no second argument given" << std::endl;
125  return 1;
126  }
127 
128  WorkerMonitorThread monitorThread;
129 
130  monitorThread.startThread();
131 
132  CMS_SA_ALLOW try {
133  std::string const memoryName(vm[kMemoryNameOpt].as<std::string>());
134  std::string const uniqueID(vm[kUniqueIDOpt].as<std::string>());
135  {
136  //This class is holding the lock
137  WorkerChannel communicationChannel(memoryName, uniqueID);
138 
139  WriteBuffer sm_buffer{memoryName, communicationChannel.fromWorkerBufferInfo()};
140  ReadBuffer sm_readbuffer{std::string("Rand") + memoryName, communicationChannel.toWorkerBufferInfo()};
141  int counter = 0;
142 
143  //The lock must be released if there is a catastrophic signal
144  auto lockPtr = communicationChannel.accessLock();
145  monitorThread.setAction([lockPtr]() {
146  if (lockPtr) {
147  std::cerr << "SIGNAL CAUGHT: unlock\n";
148  lockPtr->unlock();
149  }
150  });
151 
152  Serializer<ExternalGeneratorEventInfo> serializer(sm_buffer);
153  Serializer<ExternalGeneratorLumiInfo> bl_serializer(sm_buffer);
154  Serializer<GenLumiInfoProduct> el_serializer(sm_buffer);
155  Serializer<GenRunInfoProduct> er_serializer(sm_buffer);
156 
157  ROOTDeserializer<edm::RandomNumberGeneratorState, ReadBuffer> random_deserializer(sm_readbuffer);
158 
159  std::cerr << uniqueID << " process: initializing " << std::endl;
160  int nlines;
161  std::cin >> nlines;
162 
164  for (int i = 0; i < nlines; ++i) {
165  std::string c;
166  std::getline(std::cin, c);
167  if (verbose) {
168  std::cerr << c << "\n";
169  }
170  configuration += c + "\n";
171  }
172 
174  auto serviceToken =
175  edm::ServiceRegistry::createContaining(std::unique_ptr<edm::RandomNumberGenerator>(randomService));
176  Harness harness(configuration, serviceToken);
177 
178  //Either ROOT or the Framework are overriding the signal handlers
179  monitorThread.setupSignalHandling();
180 
181  if (verbose) {
182  std::cerr << uniqueID << " process: done initializing" << std::endl;
183  }
184  communicationChannel.workerSetupDone();
185 
186  if (verbose)
187  std::cerr << uniqueID << " process: waiting " << counter << std::endl;
188  communicationChannel.handleTransitions([&](edm::Transition iTransition, unsigned long long iTransitionID) {
189  ++counter;
190  switch (iTransition) {
192  if (verbose)
193  std::cerr << uniqueID << " process: start beginRun " << std::endl;
194  if (verbose)
195  std::cerr << uniqueID << " process: end beginRun " << std::endl;
196 
197  break;
198  }
200  if (verbose)
201  std::cerr << uniqueID << " process: start beginLumi " << std::endl;
202  auto randState = random_deserializer.deserialize();
203  if (verbose)
204  std::cerr << uniqueID << " random " << randState.state_.size() << " " << randState.seed_ << std::endl;
205  randomService->setState(randState.state_, randState.seed_);
206  auto value = harness.getBeginLumiValue(iTransitionID);
207  value.randomState_.state_ = randomService->getState();
208  value.randomState_.seed_ = randomService->mySeed();
209 
210  bl_serializer.serialize(value);
211  if (verbose)
212  std::cerr << uniqueID << " process: end beginLumi " << std::endl;
213  if (verbose)
214  std::cerr << uniqueID << " rand " << value.randomState_.state_.size() << " " << value.randomState_.seed_
215  << std::endl;
216  break;
217  }
218  case edm::Transition::Event: {
219  if (verbose)
220  std::cerr << uniqueID << " process: event " << counter << std::endl;
221  auto randState = random_deserializer.deserialize();
222  randomService->setState(randState.state_, randState.seed_);
223  auto value = harness.getEventValue();
224  value.randomState_.state_ = randomService->getState();
225  value.randomState_.seed_ = randomService->mySeed();
226 
227  if (verbose)
228  std::cerr << uniqueID << " process: event " << counter << std::endl;
229 
230  serializer.serialize(value);
231  if (verbose)
232  std::cerr << uniqueID << " process: "
233  << " " << counter << std::endl;
234  //usleep(10000000);
235  break;
236  }
238  if (verbose)
239  std::cerr << uniqueID << " process: start endLumi " << std::endl;
240  auto value = harness.getEndLumiValue();
241 
242  el_serializer.serialize(value);
243  if (verbose)
244  std::cerr << uniqueID << " process: end endLumi " << std::endl;
245 
246  break;
247  }
249  if (verbose)
250  std::cerr << uniqueID << " process: start endRun " << std::endl;
251  auto value = harness.getEndRunValue();
252 
253  er_serializer.serialize(value);
254  if (verbose)
255  std::cerr << uniqueID << " process: end endRun " << std::endl;
256 
257  break;
258  }
259  default: {
260  assert(false);
261  }
262  }
263  if (verbose)
264  std::cerr << uniqueID << " process: notifying and waiting " << counter << std::endl;
265  });
266  }
267  } catch (std::exception const& iExcept) {
268  std::cerr << "caught exception \n" << iExcept.what() << "\n";
269  return 1;
270  } catch (...) {
271  std::cerr << "caught unknown exception";
272  return 1;
273  }
274  return 0;
275 }

References edm::shared_memory::WorkerChannel::accessLock(), dir2webdir::argc, cmsBatch::argv, cms::cuda::assert(), edm::BeginLuminosityBlock, edm::BeginRun, c, EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, CMS_SA_ALLOW, ctppsRawToDigi_cff::configuration, counter, gather_cfg::cout, edm::ServiceRegistry::createContaining(), submitPVResolutionJobs::desc, edm::shared_memory::ROOTDeserializer< T, READBUFFER >::deserialize(), edm::EndLuminosityBlock, edm::EndRun, relativeConstraints::error, edm::Event, cppFunctionSkipper::exception, edm::shared_memory::WorkerChannel::fromWorkerBufferInfo(), Harness::getBeginLumiValue(), Harness::getEndLumiValue(), Harness::getEndRunValue(), Harness::getEventValue(), edm::ExternalRandomNumberGeneratorService::getState(), edm::shared_memory::WorkerChannel::handleTransitions(), mps_fire::i, kHelpCommandOpt, kHelpOpt, kMemoryNameCommandOpt, kMemoryNameOpt, kUniqueIDCommandOpt, kUniqueIDOpt, kVerboseCommandOpt, kVerboseOpt, edm::ExternalRandomNumberGeneratorService::mySeed(), AlcaSiPixelAliHarvester0T_cff::options, AlCaHLTBitMon_ParallelJobs::p, writedatasetfile::run, edm::shared_memory::ROOTSerializer< T, WRITEBUFFER >::serialize(), edm::shared_memory::WorkerMonitorThread::setAction(), edm::ExternalRandomNumberGeneratorService::setState(), edm::shared_memory::WorkerMonitorThread::setupSignalHandling(), edm::shared_memory::WorkerMonitorThread::startThread(), AlCaHLTBitMon_QueryRunRegistry::string, edm::shared_memory::WorkerChannel::toWorkerBufferInfo(), verbose, and edm::shared_memory::WorkerChannel::workerSetupDone().

Variable Documentation

◆ kHelpCommandOpt

char const* const kHelpCommandOpt = "help,h"
static

Definition at line 33 of file externalGenerator.cc.

Referenced by main().

◆ kHelpOpt

char const* const kHelpOpt = "help"
static

Definition at line 32 of file externalGenerator.cc.

Referenced by main().

◆ kMemoryNameCommandOpt

char const* const kMemoryNameCommandOpt = "memory-name,m"
static

Definition at line 29 of file externalGenerator.cc.

Referenced by main().

◆ kMemoryNameOpt

char const* const kMemoryNameOpt = "memory-name"
static

Definition at line 28 of file externalGenerator.cc.

Referenced by main().

◆ kUniqueIDCommandOpt

char const* const kUniqueIDCommandOpt = "unique-id,i"
static

Definition at line 31 of file externalGenerator.cc.

Referenced by main().

◆ kUniqueIDOpt

char const* const kUniqueIDOpt = "unique-id"
static

Definition at line 30 of file externalGenerator.cc.

Referenced by main().

◆ kVerboseCommandOpt

char const* const kVerboseCommandOpt = "verbose,v"
static

Definition at line 35 of file externalGenerator.cc.

Referenced by main().

◆ kVerboseOpt

char const* const kVerboseOpt = "verbose"
static

Definition at line 34 of file externalGenerator.cc.

Referenced by main().

counter
Definition: counter.py:1
cmsBatch.argv
argv
Definition: cmsBatch.py:279
mps_fire.i
i
Definition: mps_fire.py:428
kUniqueIDOpt
static char const *const kUniqueIDOpt
Definition: externalGenerator.cc:30
dir2webdir.argc
argc
Definition: dir2webdir.py:39
edm::Transition::Event
kUniqueIDCommandOpt
static char const *const kUniqueIDCommandOpt
Definition: externalGenerator.cc:31
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cms::cuda::assert
assert(be >=bs)
edm::shared_memory::WorkerMonitorThread
Definition: WorkerMonitorThread.h:32
edm::ExternalRandomNumberGeneratorService::mySeed
std::uint32_t mySeed() const final
Definition: ExternalRandomNumberGeneratorService.cc:69
kMemoryNameCommandOpt
static char const *const kMemoryNameCommandOpt
Definition: externalGenerator.cc:29
edm::shared_memory::ROOTSerializer
Definition: ROOTSerializer.h:31
Harness
Definition: interprocess.cc:28
relativeConstraints.error
error
Definition: relativeConstraints.py:53
CMS_SA_ALLOW
#define CMS_SA_ALLOW
Definition: thread_safety_macros.h:5
kMemoryNameOpt
static char const *const kMemoryNameOpt
Definition: externalGenerator.cc:28
edm::shared_memory::ROOTDeserializer
Definition: ROOTDeserializer.h:31
edm::shared_memory::WriteBuffer
Definition: WriteBuffer.h:37
edm::shared_memory::WorkerMonitorThread::setupSignalHandling
void setupSignalHandling()
Sets the unix signal handler which communicates with the thread.
Definition: WorkerMonitorThread.cc:102
edm::ExternalRandomNumberGeneratorService::setState
void setState(std::vector< unsigned long > const &, long seed)
Definition: ExternalRandomNumberGeneratorService.cc:24
kHelpCommandOpt
static char const *const kHelpCommandOpt
Definition: externalGenerator.cc:33
edm::shared_memory::WorkerMonitorThread::startThread
void startThread()
Definition: WorkerMonitorThread.cc:78
edm::shared_memory::WorkerMonitorThread::setAction
void setAction(std::function< void()> iFunc)
Definition: WorkerMonitorThread.h:48
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
kVerboseCommandOpt
static char const *const kVerboseCommandOpt
Definition: externalGenerator.cc:35
edm::Transition::BeginLuminosityBlock
kVerboseOpt
static char const *const kVerboseOpt
Definition: externalGenerator.cc:34
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
edm::Transition
Transition
Definition: Transition.h:12
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
ctppsRawToDigi_cff.configuration
configuration
Definition: ctppsRawToDigi_cff.py:11
value
Definition: value.py:1
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:18
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::shared_memory::WorkerChannel
Definition: WorkerChannel.h:35
edm::ExternalRandomNumberGeneratorService::getState
std::vector< unsigned long > getState() const
Definition: ExternalRandomNumberGeneratorService.cc:32
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::Transition::EndLuminosityBlock
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::ServiceRegistry::createContaining
static ServiceToken createContaining(std::unique_ptr< T > iService)
create a service token that holds the service defined by iService
Definition: ServiceRegistry.h:99
edm::Transition::BeginRun
AlcaSiPixelAliHarvester0T_cff.options
options
Definition: AlcaSiPixelAliHarvester0T_cff.py:42
edm::shared_memory::ReadBuffer
Definition: ReadBuffer.h:34
kHelpOpt
static char const *const kHelpOpt
Definition: externalGenerator.cc:32
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:56
edm::ExternalRandomNumberGeneratorService
Definition: ExternalRandomNumberGeneratorService.h:20
edm::Transition::EndRun
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8