void pgConstructEquCkt(Circuit *ckt, Circuit *newCkt) /* equivalent circuit nodes */ { Nodes *node; int i; BranchLink *blaux; Branches *baux; int numNodeRemoved = 0, numNodeRemained = 0; assert(ckt); assert(newCkt); /* build the node array of original circuit if necessary */ if(!ckt->theNodeArray) pgBuildNodeArray(ckt); /* perform the DC analysis on the original circuit */ /*pgDCAnalysis(ckt);*/ pgComputeStateFromRes(ckt); /* preparation */ markAllNodeUnvisited(ckt); /* we then go through all the nodes */ for(i = 0; i <= ckt->nNumNode; i++) { node = &(ckt->theNodeArray[i]); /* skip the node visited */ if(node->visited) continue; /* ignore node that needs to be suppressed. Such a node has two resistant branch and one current. The current is coming from one branch and go out to another branch. */ if(isSuppressedNode(ckt, node->index)) continue; /* node to be kept in the new netlist. Note that we only process resistant branch which has current flowing away from the branch */ node->visited = 1; numNodeRemained++; for(blaux = node->blist; blaux; blaux = blaux->next) { baux = blaux->dev; if(baux->type != dRES) { copyBranch(baux, newCkt); continue; } if(((baux->n1 == node->index) && (baux->current > 0.0f)) || ((baux->n2 == node->index) && (baux->current < 0.0f))) { if(baux->n1 == node->index) { if(!isSuppressedNode(ckt,baux->n2)) copyBranch(baux, newCkt); else numNodeRemoved += suppressBranches(baux, ckt, newCkt); } else { if(!isSuppressedNode(ckt, baux->n1)) copyBranch(baux, newCkt); else numNodeRemoved += suppressBranches(baux,ckt, newCkt); } } } } printf("# of nodes suppressed: %d\n", numNodeRemoved); printf("# of nodes remains: %d\n", numNodeRemained-1); /* newCkt->nNumDevice = ckt->nNumDevice - numNodeRemoved;*/ newCkt->nMatrixSize = ckt->nMatrixSize; newCkt->nNumNode = ckt->nNumNode; }
Long_t MCPropGeant4::startup() { // set the seed from global seed int seed=* ( (int*) getMemoryObject("GlobalSeed") ); debug(1,"Propagation seed set to %i\n",seed); CLHEP::HepRandom::setTheSeed(seed); // construct geant 4 and geometry debug(100,"Reading GDML to construct geometry\n"); // Print the file names into the appropriate places char buffer[1024]; snprintf(buffer,1000,"%s/.cooker/shared/gdml/%s",getenv("COOKERHOME"),gdmlFileName.c_str()); char fieldbuf[1024]; snprintf(fieldbuf,1000,"%s",fieldfile.c_str()); //std::cout<<"\n\nField: "<<fieldfile<<" Geo: "<<gdmlFileName<<"\n\n"; runmanager=new cookerRM(); cD = new cookerDetector(buffer,fieldbuf,this); runmanager->SetUserInitialization(cD); runmanager->SetUserInitialization( new Physics("",fullBrem,supBrem)); // If visualization is requested, add the step action if (vism) { visStepAct = new MCPropVis(); runmanager->SetUserAction(visStepAct); } // If field integration is requested, add the step action if (fint) { fieldIntAct = new MCFieldIntegrator(); runmanager->SetUserAction(fieldIntAct); } GeneratorEvent * ge=NULL; getOutBranchObject("Generator",(TObject **) &ge); debug(0,"Out gen %p\n",ge); if (!ge) { copyBranch("Generator"); getBranchObject("Generator",(TObject **) &ge); } if (!ge) { debug(0,"Failed to find Generator Branch.\n"); exit(-1); } runmanager->SetUserAction(new cookerGen(ge)); // runaction, eventaction? runmanager->Initialize(); if (!runmanager->startRun()) { debug(0,"Error starting Geant4 run\n"); exit(-1); } // Need GD ROOT TObjStrings to put them in a tree fieldFile = new TObjString(cD->fieldFile.data()); fieldHash = new TObjString(cD->fieldHash.data()); // std::cout<<"\n\n"<<fieldFile->String()<<" "<<fieldHash->String()<<"\n\n"; copyFileObject("ConfigData/trigger"); return 0; }