1 #ifndef __JDETECTOR__JMONTECARLODETECTOR__
2 #define __JDETECTOR__JMONTECARLODETECTOR__
87 in >> static_cast<JObjectID&>(*
this) >>
string_id >>
z >>
n;
91 iterator p = this->begin();
93 for ( ;
n != 0; --
n, ++p)
117 in >> static_cast<JObjectID&>(*
this) >>
x >>
y >>
z >>
theta >>
phi >>
psi;
143 in >> static_cast<JObjectID&>(*
this) >>
x >>
y >>
z >>
theta >>
phi;
203 iterator p = this->begin();
205 for ( ;
n != 0; --
n, ++p)
240 const int __pmt_id) :
296 for (
string key, buffer; in >>
key; ) {
300 OMaddress.push_back(
OM(in));
302 else if (
key ==
"OM_cluster:")
306 else if (
key ==
"OM_position:")
310 else if (
key ==
"string:")
312 DetectorString.push_back(
String(in));
314 else if (
key ==
"OM_cluster_data:")
318 else if (
key ==
"LCM_logic:")
334 const int lcm_id = i->getID();
336 for (LCM_logic::const_iterator
j = i->begin();
j != i->end(); ++
j) {
339 const int pmt_id =
distance(i->begin(),
j) + 1;
348 sort(OMaddress .begin(), OMaddress .end());
349 sort(OMcluster .begin(), OMcluster .end());
350 sort(OMposition .begin(), OMposition .end());
351 sort(DetectorString .begin(), DetectorString .end());
352 sort(LCMreverselogic.begin(), LCMreverselogic.end());
363 for (OMclusterIterator = OMcluster.begin();
364 OMclusterIterator != OMcluster.end();
365 OMclusterIterator++) {
367 StringIterator =
find(DetectorString.begin(),
368 DetectorString.end(),
369 OMclusterIterator->string_id);
371 if (StringIterator != DetectorString.end()) {
375 for (addressIterator = OMclusterIterator->begin();
376 addressIterator != OMclusterIterator->end();
379 OMIterator =
find(OMaddress.begin(),
383 if (OMIterator != OMaddress.end()) {
385 OMpositionIterator =
find(OMposition.begin(),
387 OMIterator->address);
389 if (OMpositionIterator != OMposition.end()) {
393 double ct = cos(StringIterator->twist *
PI / 180.0);
394 double st = sin(StringIterator->twist *
PI / 180.0);
396 double x = ct * OMpositionIterator->x - st * OMpositionIterator->y;
397 double y = st * OMpositionIterator->x + ct * OMpositionIterator->y;
400 StringIterator->y + y,
401 StringIterator->z + OMpositionIterator->z + OMclusterIterator->z);
404 StringIterator->twist *
PI / 180.0 + OMpositionIterator->phi));
406 int lcm_id = OMclusterIterator->getID();
407 int pmt_id = OMIterator->address;
412 LCMreverselogic.end(),
413 OMIterator->getID());
415 if (p != LCMreverselogic.end()) {
421 detector.
put(lcm_id, pmt_id - 1, location,
JPMT(OMIterator->getID(),
JAxis3D(pos, dir)));
431 for (OMclusterdataIterator = OMclusterdata.begin();
432 OMclusterdataIterator != OMclusterdata.end();
433 OMclusterdataIterator++) {
436 OMclusterdataIterator->y,
437 OMclusterdataIterator->z);
440 OMclusterdataIterator->phi,
441 OMclusterdataIterator->psi));
443 OMclusterIterator =
find(OMcluster.begin(),
445 OMclusterdataIterator->getID());
447 if (OMclusterIterator != OMcluster.end()) {
451 for (addressIterator = OMclusterIterator->begin();
452 addressIterator != OMclusterIterator->end();
455 OMIterator =
find(OMaddress.begin(),
459 if (OMIterator != OMaddress.end()) {
461 OMpositionIterator =
find(OMposition.begin(),
463 OMIterator->address);
465 if (OMpositionIterator != OMposition.end()) {
468 OMpositionIterator->y,
469 OMpositionIterator->z);
472 OMpositionIterator->phi));
479 int lcm_id = OMclusterIterator->getID();
480 int pmt_id = OMIterator->address;
485 LCMreverselogic.end(),
486 OMIterator->getID());
488 if (p != LCMreverselogic.end()) {
494 detector.
put(lcm_id, pmt_id - 1, location,
JPMT(OMIterator->getID(),
JAxis3D(pos, dir)));
508 for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
510 if (module->getString() != string) {
511 string = module->getString();
544 const int pmtAddress,
548 JDetector::iterator p = std::lower_bound(this->begin(), this->end(), moduleID);
550 if (p == this->end() || p->getID() != moduleID) {
552 JModule module(moduleID, location);
554 module.resize(pmtAddress + 1);
556 module[pmtAddress] = pmt;
560 this->insert(p, module);
568 for (JModule::const_iterator i = p->begin(); i != p->end(); ++i) {
574 if (pmtAddress + 1 > (
int) p->size()) {
575 p->resize(pmtAddress + 1);
583 P.
sub(p->at(pmtAddress).getPosition());
590 p->at(pmtAddress) = pmt;
606 static T
find(T __begin, T __end,
const int id)
608 T i = std::lower_bound(__begin, __end,
id);
610 if (i != __end && *i !=
id)