Esempio n. 1
0
int main() 
{

  // Set up pset param explicitly required by CSCGasCollisions.
  // Note that it has no effect because this stand-alone program
  // does not activate MessageLogger which now controls output
  // in CSCGasCollisions.
  edm::ParameterSet pset;
  pset.addUntrackedParameter<bool>("dumpGasCollisions", false); 
  pset.registerIt();

  CSCGasCollisions collisions (  pset );

  ParticleDataTable dummyTable;
  // let the code assume a muon
  collisions.setParticleDataTable(&dummyTable);

  CLHEP::HepJamesRandom engine;

  PSimHit simHit(LocalPoint(0.,0.,-0.5), LocalPoint(0.,0.,0.5),
                 4., 0., 0.000005, 13,
                 CSCDetId(1,1,1,1,1), 0, 0., 0., 0);

  /*
  PSimHit( const Local3DPoint& entry, const Local3DPoint& exit,
           float pabs, float tof, float eloss, int particleType,
           unsigned int detId, unsigned int trackId,
           float theta, float phi, unsigned short processType=0) :
  */

  int n = 100;
  int sumElectrons = 0;
  int sumClusters = 0;
  for(int i = 0; i < n; ++i) {
    std::vector<LocalPoint> clusters;
    std::vector<int> electrons;
    collisions.simulate(simHit, clusters, electrons, &engine);

    sumElectrons += std::accumulate(electrons.begin(), electrons.end(), 0);
    sumClusters += clusters.size();
  }

  std::cout << "Clusters: " << sumClusters/n << "  electrons: " << sumElectrons/n << std::endl;
  return 0;
}
Esempio n. 2
0
void CInMapDraw::GotNetMsg(const unsigned char* msg)
{
	const int playerID = msg[2];

	if ((playerID < 0) || (playerID >= playerHandler->ActivePlayers())) {
		return;
	}
	const CPlayer* sender = playerHandler->Player(playerID);
	if (sender == NULL) {
		return;
	}

	switch (msg[3]) {
		case NET_POINT: {
			const float3 pos(*(short*) &msg[4], 0, *(short*) &msg[6]);
			const bool fromLua = msg[8];
			const string label = (char*) &msg[9];
			if (!fromLua || allowLuaMapDrawing) {
				LocalPoint(pos, label, playerID);
			}
			break;
		}
		case NET_LINE: {
			const float3 pos1(*(short*) &msg[4], 0, *(short*) &msg[6]);
			const float3 pos2(*(short*) &msg[8], 0, *(short*) &msg[10]);
			const bool fromLua = msg[12];
			if (!fromLua || allowLuaMapDrawing) {
				LocalLine(pos1, pos2, playerID);
			}
			break;
		}
		case NET_ERASE: {
			float3 pos(*(short*) &msg[4], 0, *(short*) &msg[6]);
			LocalErase(pos, playerID);
			break;
		}
	}
}
Esempio n. 3
0
void CInMapDraw::GotNetMsg(const unsigned char* msg)
{
	const int playerID = msg[2];

	switch (msg[3]) {
		case NET_POINT: {
			float3 pos(*(short*) &msg[4], 0, *(short*) &msg[6]);
			const string label = (char*) &msg[8];
			LocalPoint(pos, label, playerID);
			break;
		}
		case NET_LINE: {
			float3 pos1(*(short*) &msg[4], 0, *(short*) &msg[6]);
			float3 pos2(*(short*) &msg[8], 0, *(short*) &msg[10]);
			LocalLine(pos1, pos2, playerID);
			break;
		}
		case NET_ERASE: {
			float3 pos(*(short*) &msg[4], 0, *(short*) &msg[6]);
			LocalErase(pos, playerID);
			break;
		}
	}
}
Esempio n. 4
0
int CInMapDraw::GotNetMsg(boost::shared_ptr<const netcode::RawPacket> &packet)
{
	int playerID = -1;

	try {
		netcode::UnpackPacket pckt(packet, 2);

		unsigned char uPlayerID;
		pckt >> uPlayerID;
		if (uPlayerID >= playerHandler->ActivePlayers()) {
			throw netcode::UnpackPacketException("Invalid player number");
		}
		playerID = uPlayerID;

		const CPlayer* sender = playerHandler->Player(playerID);

		unsigned char drawType;
		pckt >> drawType;

		switch (drawType) {
			case MAPDRAW_POINT: {
				short int x,z;
				pckt >> x;
				pckt >> z;
				const float3 pos(x, 0, z);
				unsigned char fromLua;
				pckt >> fromLua;
				string label;
				pckt >> label;
				if (!fromLua || allowLuaMapDrawing) {
					LocalPoint(pos, label, playerID);
				}
				break;
			}
			case MAPDRAW_LINE: {
				short int x1,z1,x2,z2;
				pckt >> x1;
				pckt >> z1;
				pckt >> x2;
				pckt >> z2;
				const float3 pos1(x1, 0, z1);
				const float3 pos2(x2, 0, z2);
				unsigned char fromLua;
				pckt >> fromLua;
				if (!fromLua || allowLuaMapDrawing) {
					LocalLine(pos1, pos2, playerID);
				}
				break;
			}
			case MAPDRAW_ERASE: {
				short int x,z;
				pckt >> x;
				pckt >> z;
				float3 pos(x, 0, z);
				LocalErase(pos, playerID);
				break;
			}
		}
	} catch (netcode::UnpackPacketException &e) {
		logOutput.Print("Got invalid MapDraw: %s", e.err.c_str());
		playerID = -1;
	}

	return playerID;
}