| 52 |  | ObjectCount::ObjectCount(SimInfo* info, const std::string& filename, | 
| 53 |  | const std::string& sele) | 
| 54 |  | : StaticAnalyser(info, filename), selectionScript_(sele), | 
| 55 | < | evaluator_(info), seleMan_(info)   { | 
| 55 | > | seleMan_(info), evaluator_(info) { | 
| 56 |  |  | 
| 57 |  | setOutputName(getPrefix(filename) + ".counts"); | 
| 58 |  |  | 
| 63 |  | } | 
| 64 |  | } | 
| 65 |  |  | 
| 66 | < | void ObjectCount::process() { | 
| 67 | < | Molecule* mol; | 
| 68 | < | RigidBody* rb; | 
| 69 | < | SimInfo::MoleculeIterator mi; | 
| 70 | < | Molecule::RigidBodyIterator rbIter; | 
| 66 | > | void ObjectCount::process() { | 
| 67 | > | Molecule* mol; | 
| 68 | > | RigidBody* rb; | 
| 69 | > | SimInfo::MoleculeIterator mi; | 
| 70 | > | Molecule::RigidBodyIterator rbIter; | 
| 71 |  |  | 
| 72 | < | counts_.clear(); | 
| 73 | < | counts_.resize(10, 0); | 
| 74 | < | DumpReader reader(info_, dumpFilename_); | 
| 75 | < | int nFrames = reader.getNFrames(); | 
| 76 | < | unsigned long int nsum = 0; | 
| 77 | < | unsigned long int n2sum = 0; | 
| 72 | > | counts_.clear(); | 
| 73 | > | counts_.resize(10, 0); | 
| 74 | > | DumpReader reader(info_, dumpFilename_); | 
| 75 | > | int nFrames = reader.getNFrames(); | 
| 76 | > | unsigned long int nsum = 0; | 
| 77 | > | unsigned long int n2sum = 0; | 
| 78 |  |  | 
| 79 | < | for (int i = 0; i < nFrames; i += step_) { | 
| 80 | < | reader.readFrame(i); | 
| 81 | < | currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); | 
| 79 | > | for (int i = 0; i < nFrames; i += step_) { | 
| 80 | > | reader.readFrame(i); | 
| 81 | > | currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); | 
| 82 |  |  | 
| 83 | < | for (mol = info_->beginMolecule(mi); mol != NULL; | 
| 84 | < | mol = info_->nextMolecule(mi)) { | 
| 85 | < | //change the positions of atoms which belong to the rigidbodies | 
| 86 | < | for (rb = mol->beginRigidBody(rbIter); rb != NULL; | 
| 87 | < | rb = mol->nextRigidBody(rbIter)) { | 
| 88 | < | rb->updateAtoms(); | 
| 89 | < | } | 
| 90 | < | } | 
| 83 | > | for (mol = info_->beginMolecule(mi); mol != NULL; | 
| 84 | > | mol = info_->nextMolecule(mi)) { | 
| 85 | > | //change the positions of atoms which belong to the rigidbodies | 
| 86 | > | for (rb = mol->beginRigidBody(rbIter); rb != NULL; | 
| 87 | > | rb = mol->nextRigidBody(rbIter)) { | 
| 88 | > | rb->updateAtoms(); | 
| 89 | > | } | 
| 90 | > | } | 
| 91 |  |  | 
| 92 | < | if (evaluator_.isDynamic()) { | 
| 92 | > | if (evaluator_.isDynamic()) { | 
| 93 |  | seleMan_.setSelectionSet(evaluator_.evaluate()); | 
| 94 | < | } | 
| 94 | > | } | 
| 95 |  |  | 
| 96 | < | unsigned int count = seleMan_.getSelectionCount(); | 
| 96 | > | unsigned int count = seleMan_.getSelectionCount(); | 
| 97 |  |  | 
| 98 | < | if (counts_.size() <= count)  { | 
| 99 | < | counts_.resize(count, 0); | 
| 100 | < | } | 
| 98 | > | if (counts_.size() <= count)  { | 
| 99 | > | counts_.resize(count, 0); | 
| 100 | > | } | 
| 101 |  |  | 
| 102 | < | counts_[count]++; | 
| 102 | > | counts_[count]++; | 
| 103 |  |  | 
| 104 | < | nsum += count; | 
| 105 | < | n2sum += count * count; | 
| 106 | < | } | 
| 104 | > | nsum += count; | 
| 105 | > | n2sum += count * count; | 
| 106 | > | } | 
| 107 |  |  | 
| 108 | < | int nProcessed = nFrames /step_; | 
| 108 | > | int nProcessed = nFrames /step_; | 
| 109 |  |  | 
| 110 | < | nAvg = nsum / nProcessed; | 
| 111 | < | n2Avg = n2sum / nProcessed; | 
| 112 | < | sDev = sqrt(n2Avg - nAvg*nAvg); | 
| 113 | < | writeCounts(); | 
| 114 | < | } | 
| 110 | > | nAvg = nsum / nProcessed; | 
| 111 | > | n2Avg = n2sum / nProcessed; | 
| 112 | > | sDev = sqrt(n2Avg - nAvg*nAvg); | 
| 113 | > | writeCounts(); | 
| 114 | > | } | 
| 115 |  |  | 
| 116 |  | void ObjectCount::writeCounts() { | 
| 117 |  | std::ofstream ofs(outputFilename_.c_str(), std::ios::binary); | 
| 128 |  |  | 
| 129 |  | } else { | 
| 130 |  |  | 
| 131 | < | sprintf(painCave.errMsg, "ObjectCount: unable to open %s\n", outputFilename_.c_str()); | 
| 131 | > | sprintf(painCave.errMsg, "ObjectCount: unable to open %s\n", | 
| 132 | > | outputFilename_.c_str()); | 
| 133 |  | painCave.isFatal = 1; | 
| 134 |  | simError(); | 
| 135 |  | } |