CMS 3D CMS Logo

Classes | Typedefs | Functions | Variables
interprocess_random.cc File Reference
#include "boost/program_options.hpp"
#include <atomic>
#include <csignal>
#include <iostream>
#include <string>
#include <thread>
#include <chrono>
#include "FWCore/TestProcessor/interface/TestProcessor.h"
#include "DataFormats/TestObjects/interface/ToyProducts.h"
#include "DataFormats/Common/interface/RandomNumberGeneratorState.h"
#include "FWCore/Services/interface/ExternalRandomNumberGeneratorService.h"
#include "FWCore/SharedMemory/interface/WriteBuffer.h"
#include "FWCore/SharedMemory/interface/WorkerChannel.h"
#include "FWCore/SharedMemory/interface/ROOTSerializer.h"
#include "FWCore/SharedMemory/interface/ReadBuffer.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

using SentType = std::pair< edmtest::IntProduct, edm::RandomNumberGeneratorState >
 

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"
 

Typedef Documentation

◆ SentType

using SentType = std::pair<edmtest::IntProduct, edm::RandomNumberGeneratorState>

Definition at line 32 of file interprocess_random.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:

Sticking ADC counts in neughbouring TS for HB:

Sticking ADC counts in neughbouring TS for HE:

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:

Prepare maps of good/bad channels:

Prepare maps of good/bad channels:

Definition at line 54 of file interprocess_random.cc.

References edm::shared_memory::WorkerChannel::accessLock(), dir2webdir::argc, GCPpyPlots::argv, cms::cuda::assert(), edm::BeginLuminosityBlock, DummyCfis::c, DMR_cfg::cerr, CMS_SA_ALLOW, JetHT_cfg::configuration, counter, gather_cfg::cout, edm::ServiceRegistry::createContaining(), submitPVResolutionJobs::desc, relativeConstraints::error, edm::Event, cppFunctionSkipper::exception, edm::shared_memory::WorkerChannel::fromWorkerBufferInfo(), Harness::getBeginLumiValue(), Harness::getEventValue(), edm::ExternalRandomNumberGeneratorService::getState(), edm::shared_memory::WorkerChannel::handleTransitions(), mps_fire::i, kHelpCommandOpt, kHelpOpt, kMemoryNameCommandOpt, kMemoryNameOpt, kUniqueIDCommandOpt, kUniqueIDOpt, edm::ExternalRandomNumberGeneratorService::mySeed(), AlcaSiPixelAliHarvester0T_cff::options, AlCaHLTBitMon_ParallelJobs::p, writedatasetfile::run, 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(), and edm::shared_memory::WorkerChannel::workerSetupDone().

54  {
55  std::string descString(argv[0]);
56  descString += " [--";
57  descString += kMemoryNameOpt;
58  descString += "] memory_name";
59  boost::program_options::options_description desc(descString);
60 
61  desc.add_options()(kHelpCommandOpt, "produce help message")(
62  kMemoryNameCommandOpt, boost::program_options::value<std::string>(), "memory name")(
63  kUniqueIDCommandOpt, boost::program_options::value<std::string>(), "unique id");
64 
65  boost::program_options::positional_options_description p;
66  p.add(kMemoryNameOpt, 1);
67  p.add(kUniqueIDOpt, 2);
68 
69  boost::program_options::options_description all_options("All Options");
70  all_options.add(desc);
71 
72  boost::program_options::variables_map vm;
73  try {
74  store(boost::program_options::command_line_parser(argc, argv).options(all_options).positional(p).run(), vm);
75  notify(vm);
76  } catch (boost::program_options::error const& iException) {
77  std::cout << argv[0] << ": Error while trying to process command line arguments:\n"
78  << iException.what() << "\nFor usage and an options list, please do 'cmsRun --help'.";
79  return 1;
80  }
81 
82  if (vm.count(kHelpOpt)) {
83  std::cout << desc << std::endl;
84  return 0;
85  }
86 
87  if (!vm.count(kMemoryNameOpt)) {
88  std::cout << " no argument given" << std::endl;
89  return 1;
90  }
91 
92  if (!vm.count(kUniqueIDOpt)) {
93  std::cout << " no second argument given" << std::endl;
94  return 1;
95  }
96 
97  WorkerMonitorThread monitorThread;
98 
99  monitorThread.startThread();
100 
101  CMS_SA_ALLOW try {
102  std::string const memoryName(vm[kMemoryNameOpt].as<std::string>());
103  std::string const uniqueID(vm[kUniqueIDOpt].as<std::string>());
104  {
105  //This class is holding the lock
106  WorkerChannel communicationChannel(memoryName, uniqueID);
107 
108  WriteBuffer sm_buffer{memoryName, communicationChannel.fromWorkerBufferInfo()};
109  ReadBuffer sm_readbuffer{std::string("Rand") + memoryName, communicationChannel.toWorkerBufferInfo()};
110  int counter = 0;
111 
112  //The lock must be released if there is a catastrophic signal
113  auto lockPtr = communicationChannel.accessLock();
114  monitorThread.setAction([lockPtr]() {
115  if (lockPtr) {
116  std::cerr << "SIGNAL CAUGHT: unlock\n";
117  lockPtr->unlock();
118  }
119  });
120 
121  using TCSerializer = ROOTSerializer<SentType, WriteBuffer>;
122  TCSerializer serializer(sm_buffer);
123  TCSerializer bl_serializer(sm_buffer);
124 
126  TCDeserializer random_deserializer(sm_readbuffer);
127 
128  std::cerr << uniqueID << " process: initializing " << std::endl;
129  int nlines;
130  std::cin >> nlines;
131 
133  for (int i = 0; i < nlines; ++i) {
134  std::string c;
135  std::getline(std::cin, c);
136  std::cerr << c << "\n";
137  configuration += c + "\n";
138  }
139 
141  auto serviceToken =
142  edm::ServiceRegistry::createContaining(std::unique_ptr<edm::RandomNumberGenerator>(randomService));
143 
144  Harness harness(configuration, serviceToken);
145 
146  //Either ROOT or the Framework are overriding the signal handlers
147  monitorThread.setupSignalHandling();
148 
149  std::cerr << uniqueID << " process: done initializing" << std::endl;
150  communicationChannel.workerSetupDone();
151 
152  std::cerr << uniqueID << " process: waiting " << counter << std::endl;
153  communicationChannel.handleTransitions([&](edm::Transition iTransition, unsigned long long iTransitionID) {
154  ++counter;
155  switch (iTransition) {
157  std::cerr << uniqueID << " process: start beginLumi " << std::endl;
158  auto randState = random_deserializer.deserialize();
159  std::cerr << " state " << randState.seed_ << std::endl;
160  randomService->setState(randState.state_, randState.seed_);
161  SentType toSend;
162  toSend.first = harness.getBeginLumiValue(iTransitionID);
163  toSend.second.state_ = randomService->getState();
164  toSend.second.seed_ = randomService->mySeed();
165  bl_serializer.serialize(toSend);
166  std::cerr << uniqueID << " process: end beginLumi " << toSend.first.value << std::endl;
167 
168  break;
169  }
170  case edm::Transition::Event: {
171  std::cerr << uniqueID << " process: begin event " << counter << std::endl;
172  auto randState = random_deserializer.deserialize();
173  randomService->setState(randState.state_, randState.seed_);
174  SentType toSend;
175  toSend.first = harness.getEventValue();
176  toSend.second.state_ = randomService->getState();
177  toSend.second.seed_ = randomService->mySeed();
178  std::cerr << uniqueID << " process: end event " << counter << std::endl;
179 
180  serializer.serialize(toSend);
181  std::cerr << uniqueID << " process: " << toSend.first.value << " " << counter << std::endl;
182  //std::this_thread::sleep_for(std::chrono::microseconds(10000000));
183  break;
184  }
185  default: {
186  assert(false);
187  }
188  }
189  std::cerr << uniqueID << " process: notifying and waiting" << counter << std::endl;
190  });
191  }
192  } catch (std::exception const& iExcept) {
193  std::cerr << "caught exception \n" << iExcept.what() << "\n";
194  return 1;
195  } catch (...) {
196  std::cerr << "caught unknown exception";
197  return 1;
198  }
199  return 0;
200 }
#define CMS_SA_ALLOW
void setState(std::vector< unsigned long > const &, long seed)
void setupSignalHandling()
Sets the unix signal handler which communicates with the thread.
void setAction(std::function< void()> iFunc)
assert(be >=bs)
static char const *const kHelpOpt
dictionary configuration
Definition: JetHT_cfg.py:38
std::pair< edmtest::IntProduct, edm::RandomNumberGeneratorState > SentType
Transition
Definition: Transition.h:12
static ServiceToken createContaining(std::unique_ptr< T > iService)
create a service token that holds the service defined by iService
static char const *const kUniqueIDCommandOpt
static char const *const kMemoryNameOpt
static char const *const kHelpCommandOpt
static char const *const kMemoryNameCommandOpt
static std::atomic< unsigned int > counter
static char const *const kUniqueIDOpt

Variable Documentation

◆ kHelpCommandOpt

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

Definition at line 28 of file interprocess_random.cc.

Referenced by main().

◆ kHelpOpt

char const* const kHelpOpt = "help"
static

Definition at line 27 of file interprocess_random.cc.

Referenced by main().

◆ kMemoryNameCommandOpt

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

Definition at line 24 of file interprocess_random.cc.

Referenced by main().

◆ kMemoryNameOpt

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

Definition at line 23 of file interprocess_random.cc.

Referenced by main().

◆ kUniqueIDCommandOpt

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

Definition at line 26 of file interprocess_random.cc.

Referenced by main().

◆ kUniqueIDOpt

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

Definition at line 25 of file interprocess_random.cc.

Referenced by main().