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

References edm::shared_memory::WorkerChannel::accessLock(), dir2webdir::argc, cmsBatch::argv, cms::cuda::assert(), edm::BeginLuminosityBlock, edm::BeginRun, HltBtagPostValidation_cff::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
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
edm::Transition
Transition
Definition: Transition.h:12
ctppsRawToDigi_cff.configuration
configuration
Definition: ctppsRawToDigi_cff.py:11
value
Definition: value.py:1
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:17
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
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
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