TObject * Plugin::getFileObject(const char *name) { if (!infile) return ((genericmap*) getMemoryObject("File Object Map"))->map[name]; return infile->Get(name); }
TGCompositeFrame * Plugin::addTab(const char *name) { TGTab *tabs=(TGTab *) getMemoryObject("Tab Widget"); if (!tabs) return NULL; return tabs->AddTab(name); }
Plugin::Plugin(TTree *in_, TTree *out_, TFile *inf_, TFile *outf_,TObject *p_) { std::cout<<"Called constructor"<<std::endl; std::cout<<"....with Trees:"<<in_<<" "<<out_<<std::endl; std::cout<<"....with Files:"<<inf_<<" "<<outf_<<std::endl; std::cout<<"....with Object:"<<p_<<std::endl; in=in_; out=out_; infile=inf_; outfile=outf_; lib=(std::map<std::string,TObject *> *) p_; weight=(double *)getMemoryObject("Weight"); debuglevel=0; random=(rng*) getMemoryObject("Random"); }
TH2D *Plugin::dH2(const char * name, const char * title, int c1, double f1, double t1, int c2, double f2, double t2) { TH2D *hist=0; gDirectory->GetObject(name,hist); if (!hist) { const char * path=gDirectory->GetPath(); TDirectory * curr=gDirectory->CurrentDirectory(); char buf[1000]; strlcpy(buf,name,1000); hist=new CH2D(mkdirs(buf),title, c1,f1,t1,c2,f2,t2,(double *) getMemoryObject("Weight")); gErrorIgnoreLevel = 2001; if (getMemoryObject("Callbacks")) ((FrameworkCallbacks *)getMemoryObject("Callbacks"))->addHisto((std::string(path)+"/"+std::string(name)).c_str(),(TH1D *)hist); gErrorIgnoreLevel = 0; curr->cd(); } return hist; }
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; }
void Plugin::saveValue(const char *tagname, const char *tablename, const char *valstring) { #ifdef WITHDB PGconn *conn = NULL; TObject *dummy=getMemoryObject("Runnumber"); int runnumber=htonl(*(int*) &dummy); //ugly but works // Make a connection to the database conn = PQconnectdb("user=runinfo password=runinfo dbname=runinfo host=CookerWorkerNodeLNS00"); // Check to see that the backend connection was successfully made if (PQstatus(conn) != CONNECTION_OK) { debug(0,"Connection to database failed\n"); PQfinish(conn); return ; } const char *params[]={tagname,(char *) &runnumber,valstring}; int lengths[3]={strlen(tagname),sizeof(runnumber),strlen(valstring)}; int binary[3]={0,1,0}; debug(100,"Connection to database - OK\n"); PGresult *res=PQexecParams(conn, "select tagid from tagnames where tagname=$1::varchar;",1,NULL,params,lengths,binary,0); if (PQresultStatus(res) != PGRES_TUPLES_OK) { debug(0, "select tagid command failed: %s\n", PQerrorMessage(conn)); PQclear(res); PQfinish(conn); return; } debug(100,"Found %i\n",PQntuples(res)); if (PQntuples(res)==0) { PQclear(res); debug(100,"Trying to insert\n"); res=PQexecParams(conn, "insert into tagnames (tagname) values ($1::varchar);",1,NULL,params,lengths,binary,0); if (PQresultStatus(res) != PGRES_COMMAND_OK) { debug(0, "insert into tagid command failed: %s\n", PQerrorMessage(conn)); PQclear(res); PQfinish(conn); return; } } PQclear(res); debug(100,"Trying to insert\n"); char command[1000]; sprintf(command,"insert into %s (timestamp,runid,tagid,value) select now(),$2::int4,tagid,$3::double precision from tagnames where tagname=$1::varchar;",tablename); res=PQexecParams(conn, command,3,NULL,params,lengths,binary,0); if (PQresultStatus(res) != PGRES_COMMAND_OK) { debug(100, "insert into rundata command failed: %s\n Trying update", PQerrorMessage(conn)); PQclear(res); sprintf(command,"update %s set timestamp=now(), value=$3::double precision where runid=$2::int4 and tagid=(select tagid from tagnames where tagname=$1::varchar);",tablename); res=PQexecParams(conn, command,3,NULL,params,lengths,binary,0); if (PQresultStatus(res) != PGRES_COMMAND_OK) { debug(100, "update failed too: %s\n", PQerrorMessage(conn)); PQclear(res); PQfinish(conn); return; } } PQclear(res); PQfinish(conn); #else debug(10000,"DB not compiled in\n"); #endif }