FileEditor::FileEditor(shared_ptr<EntitiesEntity> entity, shared_ptr<EntitiesEntity> parent) : EditorBase(portalObjectTypeFile, entity, parent), m_title(OS_NEW HtmlTextBox()), m_description(OS_NEW HtmlTextBox()), m_enableBrowser(OS_NEW HtmlCheckBox()), m_browser(OS_NEW HtmlFileBrowser()) { m_title->setID(_S("title")); m_title->setCss(_S("os_input_full")); m_title->setMaxLength(OS_CONTROLS_TITLE_MAXLENGTH); m_description->setID(_S("description")); m_description->setCss(_S("os_input_full")); m_description->setMaxLength(OS_CONTROLS_DESCRIPTION_MAXLENGTH); m_browser->setID(_S("browser")); m_browser->setCss(_S("os_input_full")); getTemplate()->addChildParam(m_title, _S("title")); getTemplate()->addChildParam(m_description, _S("description")); if(isRevision()) { m_enableBrowser->setID(_S("enableBrowser")); m_enableBrowser->setCheck(false); m_enableBrowser->setAutoPostBack(true); getTemplate()->addChildParam(m_enableBrowser, _S("enable_browser")); } getTemplate()->addChildParam(m_browser, _S("browser")); }
DictionaryTemplate::DictionaryTemplate(QObject *parent) :QObject(parent), mLastSectionClosed(true), mTemplateRoot(getTemplate(":/templates/templates/root.html")), mTemplateSection(getTemplate(":/templates/templates/section.html")), mTemplateItem(getTemplate(":/templates/templates/item.html")) { }
virtual void writeXML(TiXmlElement *element) const { // Here's an example of how to make instances only write out differences from their templates... const ObjectB *temp = (const ObjectB*) getTemplate(); if (!temp || param != temp->param) XMLParser::setInt(element, "parameter", param); }
wstring QueryAssembler::getQueryTemplateFromDB(const wstring& frameName, const string& pathToDb) { DataTuple<QueryColumnTypes> key; std::list<DataTuple<QueryResultTypes>> rows; string sframeName = ""; string tabName(tableName); CONVERT_TO_UTF8_STRING(frameName, sframeName); key.set<frame_name>(sframeName); getTemplate(tabName, key, rows); if(rows.size() == 0) { throw ENoInterpretation(frameName.c_str()); } if(rows.size() > 1) { throw EMultipleInterpretations(frameName.c_str()); } wstring wtemplate = L""; for (std::list<DataTuple<QueryResultTypes> >::iterator i = rows.begin(); i != rows.end(); ++i) { wtemplate = CONVERT_TO_WSTRING(i->get<0>()); } return wtemplate; }
void LifeComponent::onDie() { FLAT_ASSERT(!m_spawning && !m_despawning && !m_dead); #ifdef FLAT_DEBUG m_dead = true; #endif m_despawning = true; disableComponent<movement::MovementComponent>(); disableComponent<behavior::BehaviorComponent>(); const LifeComponentTemplate* lifeComponentTemplate = getTemplate(); const flat::lua::SharedLuaReference<LUA_TFUNCTION>& despawnFunc = lifeComponentTemplate->getDespawnFunc(); if (!despawnFunc.isEmpty()) { lua_State* L = despawnFunc.getLuaState(); { FLAT_LUA_EXPECT_STACK_GROWTH(L, 0); despawnFunc.push(L); m_spawnDespawnThread.set(L, -1); lua_pop(L, 1); m_spawnDespawnThread.start(m_owner); } } checkSpawnDespawnThreadFinished(); }
osg::ref_ptr<osg::Node> SceneManager::createInstance(const std::string& name) { osg::ref_ptr<const osg::Node> scene = getTemplate(name); osg::ref_ptr<osg::Node> cloned = osg::clone(scene.get(), SceneUtil::CopyOp()); // add a ref to the original template, to hint to the cache that it's still being used and should be kept in cache cloned->getOrCreateUserDataContainer()->addUserObject(new TemplateRef(scene)); return cloned; }
Object *ObjectLibrary::createObject(string name) { Object *templ=getTemplate(name); if (!templ) { Error::addMessage(Error::EXCEPTION, LIBGENS_OBJECT_H_ERROR_FIND_TEMPLATE + name); return NULL; } Object *obj=new Object(templ); return obj; }
int checkForCycles(struct Node* _t) { reset(_t); if (hasCycles(_t)) { LOGD("deadlock found !"); struct Template tmpl; init_Template(&tmpl); getTemplate(&tmpl); saveTemplate(&tmpl); return true; } return false; }
void SelectionComponent::init() { m_owner->setCanBeSelected(getTemplate()->canBeSelected()); auto pushEntityCallback = [this](lua_State* L) { lua::pushEntity(L, m_owner); }; m_selectedSlotProxy.init(&selected, pushEntityCallback); m_deselectedSlotProxy.init(&deselected, pushEntityCallback); m_clickSlotProxy.init(&click, pushEntityCallback); }
v8::Handle<v8::Function> V8AdaptorFunction::wrap(v8::Handle<v8::Object> object, const AtomicString& name, v8::Isolate* isolate) { if (object.IsEmpty() || !object->IsObject()) return v8::Handle<v8::Function>(); v8::Handle<v8::Function> adaptor = v8::Handle<v8::Function>::Cast(getTemplate(isolate)->GetFunction()); if (adaptor.IsEmpty()) return v8::Handle<v8::Function>(); adaptor->SetName(v8String(name.string(), isolate)); adaptor->SetHiddenValue(V8HiddenPropertyName::adaptorFunctionPeer(), object); object->SetHiddenValue(V8HiddenPropertyName::adaptorFunctionPeer(), adaptor); return adaptor; }
std::string Templates::render(std::string name) { std::string tmpl = getTemplate(name); tmpl = boost::regex_replace(tmpl, varRegex, [this](boost::smatch match){ std::string var = match.str(); std::string buffer; std::string out; TemplateNode * lastNode = nullptr; for (std::string::iterator it = var.begin() + 2; it != (var.end() - 1); ++it) { char c = *it; buffer += c; if (c == '.') { if (lastNode == nullptr) { lastNode = tmplmap[buffer]; buffer = ""; } else if (lastNode->childNodes[buffer] == nullptr) { out = lastNode->body; buffer = ""; break; } else { lastNode = lastNode->childNodes[buffer]; buffer = ""; } } } // Does this template variable exist..? if (tmplmap.count(buffer) == 0) return var; if (buffer.compare("") != 0) out = tmplmap[buffer]->body; return out; }); // Old code.. This is going out the window.. /*std::sregex_iterator it(tmpl.begin(), tmpl.end(), varRegex); std::sregex_iterator it_end; while (it != it_end) { cout << *it << endl; ++it; }*/ return tmpl; }
//----------------------------------------------------------------------- CGUIParticleSystem* CGUIParticleSystemManager::createSystemImpl(const CGUIString& name, const CGUIString& templateName) { // Look up template CGUIParticleSystem* pTemplate = getTemplate(templateName); if (!pTemplate) { OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Cannot find required template '" + templateName + "'", "CGUIParticleSystemManager::createSystem"); } CGUIParticleSystem* sys = createSystemImpl(name, pTemplate->getParticleQuota(), pTemplate->getResourceGroupName()); // Copy template settings *sys = *pTemplate; return sys; }
SceneObject* ObjectManager::createObject(uint32 objectCRC, uint64 objectID) { Locker _locker(this); SceneObject* object = NULL; try { luaMutex.lock(); LuaFunction getTemplate(luaInstance->getLuaState(), "getTemplate", 1); getTemplate << objectCRC; // push first argument getTemplate.callFunction(); LuaObject result(luaInstance->getLuaState()); if (!result.isValidTable()) { luaMutex.unlock(); return NULL; } uint32 gameObjectType = result.getIntField("gameObjectType"); object = objectFactory.createObject(gameObjectType, &result); luaMutex.unlock(); if (object == NULL) return object; object->setObjectID(objectID); object->setZone(zone); StringBuffer logName; logName << object->getLoggingName() << " 0x" << hex << objectID; object->setLoggingName(logName.toString()); objectMap->put(objectID, object); } catch (Exception& e) { error("exception caught in SceneObject* ObjectManager::loadObjectFromTemplate(uint32 objectCRC)"); error(e.getMessage()); e.printStackTrace(); } return object; }
//static LLNotifyBox* LLNotifyBox::showXml( const std::string& xml_desc, const LLStringUtil::format_map_t& args, notify_callback_t callback, void *user_data) { LLPointer<LLNotifyBoxTemplate> xml_template = getTemplate(xml_desc); LLNotifyBox* notify = findExistingNotify(xml_template, args); if (notify) { delete notify->mBehavior; notify->mBehavior = new LLNotifyBehavior(callback, user_data); } else { notify = new LLNotifyBox(xml_template, args, callback, user_data); gNotifyBoxView->addChildAtEnd(notify); notify->moveToBack(); } return notify; }
//----------------------------------------------------------------------- ParticleSystem* ParticleSystemManager::createSystemImpl(IdType id, ObjectMemoryManager *objectMemoryManager, const String& templateName) { // Look up template ParticleSystem* pTemplate = getTemplate(templateName); if (!pTemplate) { OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "Cannot find required template '" + templateName + "'", "ParticleSystemManager::createSystem"); } ParticleSystem* sys = createSystemImpl( id, objectMemoryManager, pTemplate->getParticleQuota(), pTemplate->getResourceGroupName() ); // Copy template settings *sys = *pTemplate; return sys; }
//static LLNotifyBox* LLNotifyBox::showXml( const std::string& xml_desc, const LLStringUtil::format_map_t& args, notify_callback_t callback, void *user_data, const option_list_t& options, BOOL layout_script_dialog) { LLPointer<LLNotifyBoxTemplate> xml_template = getTemplate(xml_desc); LLNotifyBox* notify = findExistingNotify(xml_template, args); if (notify) { delete notify->mBehavior; notify->mBehavior = new LLNotifyBehavior(callback, user_data); } else { notify = new LLNotifyBox(xml_template, args, callback, user_data, FALSE, options, layout_script_dialog); gNotifyBoxView->addChild(notify); } return notify; }
std::wstring ResponseAssembler::getResponseTemplateFromDB(const wstring& frameName, const wstring& _question, const string& _templateType) { std::list<DataTuple<QueryResultTypes> > rows; string sframeName = ""; CONVERT_TO_UTF8_STRING(frameName, sframeName); string squestion = ""; CONVERT_TO_UTF8_STRING(_question, squestion); string templateType = _templateType; string tabName(tableName); DataTuple<QueryColumnTypes> key; key.set<frame_name>(sframeName); key.set<question>(squestion); key.set<type>(templateType); getTemplate(tabName, key, rows); std::wstring currentTemplate = L""; for (std::list<DataTuple<QueryResultTypes> >::iterator i = rows.begin(); i != rows.end(); ++i) { currentTemplate = CONVERT_TO_WSTRING(i->get<0>()); } if(rows.size() > 1) { throw EMultipleInterpretations(frameName.c_str()); } else if(rows.size() == 0) { ENoInterpretation(frameName.c_str()); } return currentTemplate; }
void onEntityDestroyed(Entity entity) { uint32 tpl = getTemplate(entity); if (tpl != 0) { Array<Entity>& instances = m_instances.get(tpl); instances.eraseItemFast(entity); if (instances.empty()) { m_instances.erase(tpl); for (int i = 0; i < m_template_names.size(); ++i) { if (crc32(m_template_names[i].c_str()) == tpl) { m_template_names.eraseFast(i); break; } } } } }
//virtual bool JsonGenerator::processBeanSpecification(BeanClazzSpecification & bcs) { std::string content = getTemplateContent("json_bean_template.t"); if(bcs.getFields().size() == 0) { std::ostringstream msg; msg << "Bean " << bcs.getName() << " has no fields ?!?"; addError(msg.str()); return false; } if(!registerOutputTemplate(bcs.getName(), content)) { return false; } std::cout << "Generating bean file : " << bcs.getName() << std::endl; //1: replace the names std::string beanName = bcs.getName(); FTemplate & t = getTemplate(beanName); std::string lowercaseName = boost::to_lower_copy(beanName); std::string uppercaseName = boost::to_upper_copy(beanName); t.replaceToken("BEANNAME", uppercaseName); t.replaceToken("beanname", lowercaseName); t.replaceToken("BeanName", beanName); //2: fix the namespaces std::string namespaceBegin; std::string namespaceEnd; for(auto & s : spec.getNamespaces()) { namespaceBegin.append("namespace ").append(s).append(" { "); namespaceEnd.append("} "); } t.replaceToken("namespace_def_begin", namespaceBegin); t.replaceToken("namespace_def_end", namespaceEnd); std::ostringstream n; n << bcs.getFields().size(); t.replaceToken("bean_number_of_fields", n.str()); //3: process the fields return processBeanFieldsSpecification(t, bcs); }
bool HmcModule::doLoad() { if(!fileExists(_modelPath)) { Log::error("HMC model file not found"); return false; } std::ifstream modelFile(_modelPath); CSVReader modelReader(modelFile); for(unsigned int i = 0;modelReader.hasNextLine();++i) { std::vector<std::string> modelLine; modelReader.readNextLine(modelLine); if(modelLine.size()<2) break; std::string name = modelLine[0]; name[0]= toupper(name[0]); std::string type = modelLine[1]; addParser(name); const ObjectTypeTemplate& typeTemplate = newTemplate(name); setSpecification(EbmlModule::EBMLElement(i), typeTemplate()); for(int j =0;j<EbmlModule::numberOfTypeElements;++j) { if(type == EbmlModule::typeElementAtributes[j]) { setExtension(typeTemplate, getTemplate(EbmlModule::typeElements[j])()); break; } } } return true; }
ShaderDiscardCase* makeDiscardCase (Context& context, DiscardTemplate tmpl, DiscardMode mode) { StringTemplate shaderTemplate(getTemplate(tmpl)); map<string, string> params; switch (mode) { case DISCARDMODE_ALWAYS: params["DISCARD"] = "discard"; break; case DISCARDMODE_NEVER: params["DISCARD"] = "if (false) discard"; break; case DISCARDMODE_UNIFORM: params["DISCARD"] = "if (ui_one > 0) discard"; break; case DISCARDMODE_DYNAMIC: params["DISCARD"] = "if (v_coords.x+v_coords.y > 0.0) discard"; break; case DISCARDMODE_TEXTURE: params["DISCARD"] = "if (texture(ut_brick, v_coords.xy*0.25+0.5).x < 0.7) discard"; break; default: DE_ASSERT(DE_FALSE); break; } string name = string(getTemplateName(tmpl)) + "_" + getModeName(mode); string description = string(getModeDesc(mode)) + " in " + getTemplateDesc(tmpl); return new ShaderDiscardCase(context, name.c_str(), description.c_str(), shaderTemplate.specialize(params).c_str(), getEvalFunc(mode), mode == DISCARDMODE_TEXTURE); }
static void bserEncodeArray(dynamic const& dyn, QueueAppender& appender, const serialization_opts& opts) { auto templ = getTemplate(opts, dyn); if (UNLIKELY(templ != nullptr)) { appender.write((int8_t)BserType::Template); // Emit the list of property names bserEncodeArraySimple(*templ, appender, opts); // The number of objects in the array bserEncodeInt(dyn.size(), appender); // For each object in the array for (const auto& ele : dyn) { // For each key in the template for (const auto& name : *templ) { if (auto found = ele.get_ptr(name)) { if (found->isNull()) { // Prefer to Skip rather than encode a null value for // compatibility with the other bser implementations appender.write((int8_t)BserType::Skip); } else { bserEncode(*found, appender, opts); } } else { appender.write((int8_t)BserType::Skip); } } } return; } bserEncodeArraySimple(dyn, appender, opts); }
int putOne(char *buf,const char *col_name) { return putOne(buf,getTemplate(col_name)); }
int *findPossibleBlinks( int *num_blinks, const NUMTYPE *channel, int len_channel, const BlinkParams *params ) { unsigned int i, j, max_level, len_coef, lengths[8]; int cor_length, temp_start, len_template; NUMTYPE *coefs, *chan_a, *chan_d, *chan_r, *thresh, *templ; NUMTYPE min; int above, min_index, num_indices, *indices, steps_1, index, *blinks; NUMTYPE *cors; // Pull out the parameters that we'll be using. NUMTYPE t_1 = params->t_1; NUMTYPE t_cor = params->t_cor; // Make sure that we are capable of taking the 5th, 6th, and 7th level // decompositions. max_level = wavedecMaxLevel( len_channel, COIF3.len_filter ); if (max_level < 7) { fprintf( stderr, "Channel too short for processing!\n" ); (*num_blinks) = 0; return NULL; } ////////////////////////////////////////////////////////////////////////////// // Allocate memory. ////////////////////////////////////////////////////////////////////////////// len_coef = wavedecResultLength( len_channel, COIF3.len_filter, 7 ); coefs = (NUMTYPE*) malloc( sizeof(NUMTYPE) * len_coef ); chan_a = (NUMTYPE*) malloc( sizeof(NUMTYPE) * len_channel ); chan_d = (NUMTYPE*) malloc( sizeof(NUMTYPE) * len_channel ); chan_r = (NUMTYPE*) malloc( sizeof(NUMTYPE) * len_channel ); thresh = (NUMTYPE*) malloc( sizeof(NUMTYPE) * len_channel ); ////////////////////////////////////////////////////////////////////////////// // Extract the appropriate approximation and detail signals. ////////////////////////////////////////////////////////////////////////////// wavedec( coefs, lengths, channel, len_channel, COIF3, 7 ); wrcoef( chan_a, coefs, lengths, 8, RECON_APPROX, COIF3, 3 ); // Sum the enveloped 5th, 6th, and 7th level details. for (i = 0; i < len_channel; i++) { chan_d[i] = 0.0; } for (i = 5; i <= 7; i++) { wrcoef( chan_r, coefs, lengths, 8, RECON_DETAIL, COIF3, i ); envelope( chan_r, len_channel ); for (j = 0; j < len_channel; j++) { chan_d[j] += chan_r[j]; } } ////////////////////////////////////////////////////////////////////////////// // Generate the first guess at eyeblink locations. ////////////////////////////////////////////////////////////////////////////// // Compute the moving average threshold. movingAverage( thresh, chan_d, len_channel ); for (i = 0; i < len_channel; i++) { thresh[i] += t_1; } // Find the minimums of the original channel between rising/falling edge pairs // of the enveloped channel details. above = 0; num_indices = 0; min = INFINITY; min_index = 0; indices = NULL; for (i = 1; i < len_channel; i++) { // Check to see if we crossed the threshold. if (!above && chan_d[i] > thresh[i] && chan_d[i-1] <= thresh[i-1]) { above = 1; // Reset the 'min' value so that we can find a new minimum. min = INFINITY; } else if (above && chan_d[i] < thresh[i] && chan_d[i-1] >= thresh[i-1]) { above = 0; // We just found the falling edge of a pair. Record the index of the // minimum value that we found within the pair. num_indices++; indices = (int*) realloc( indices, sizeof(int) * num_indices ); indices[num_indices-1] = min_index; } // If we're above the threshold, keep track of the minimum value that we // see. if (above) { if (min > chan_a[i]) { min = chan_a[i]; min_index = i; } } } ////////////////////////////////////////////////////////////////////////////// // Refine our first guess, getting our final guess at eyeblink locations. ////////////////////////////////////////////////////////////////////////////// cors = (NUMTYPE*) malloc( sizeof(NUMTYPE) * num_indices ); // Generate the eyeblink template to correlate with the eyeblink locations. templ = getTemplate( &steps_1, &len_template, params ); // Calculate the correlations of the original channel around the minimum // points. (*num_blinks) = num_indices; for (i = 0; i < num_indices; i++) { index = indices[i] - steps_1; temp_start = 0; cor_length = len_template; // Make sure the correlation function will not access beyond the bounds // of our arrays. if (index < 0) { temp_start = -index; cor_length = len_template + index; index = 0; } else if (index + len_template >= len_channel) { cor_length = len_template - (index + len_template - len_channel); } cors[i] = correlate( chan_a + index, templ + temp_start, cor_length ); // Mark for elimination the indices with correlations below the threshold. if (cors[i] < t_cor) { indices[i] = -1; (*num_blinks)--; } } // If we still have blinks after all this, allocate memory for them. if ((*num_blinks) == 0) { blinks = NULL; } else { blinks = (int*) malloc( sizeof(int) * (*num_blinks) ); index = 0; for (i = 0; i < num_indices; i++) { if (indices[i] > 0) { blinks[index] = indices[i]; index++; } } } ////////////////////////////////////////////////////////////////////////////// // Clean up and return. ////////////////////////////////////////////////////////////////////////////// free( indices ); free( cors ); free( coefs ); free( chan_a ); free( chan_d ); free( chan_r ); free( thresh ); free( templ ); return blinks; }
void photonTemplateProducer(int cutOpt=3, int ppHI = kHI, int isoChoice = kSumIso, int isoCut = -100, bool onlygjEvents=false, float specialSbCut=10, float mcSigShift=0, float sbBkgShift=0) { CutAndBinCollection cab; cab.setCuts(cutOpt); int nPtBin = cab.getNPtBin(); vector<double> ptBinVector = cab.getPtBin(); double ptBin[100]; for ( int i = 0 ; i<=nPtBin ;i++) { ptBin[i] = ptBinVector[i]; } int nCentBin = cab.getNCentBin(); vector<double> centBinVector = cab.getCentBin(); double centBin[100]; for ( int i = 0 ; i<=nCentBin ;i++) { centBin[i] = centBinVector[i]; } TString pphiLabel = ""; if ( ppHI == kPP) pphiLabel = "pp"; TCanvas* c1[5]; TH1D* hData[5][5]; TH1D* hSig[5][5]; TH1D* hBkg[5][5]; // TH1D* hDatapp[5]; // TH1D* hSigpp[5]; // TH1D* hBkgpp[5]; TH1D* hBkgMCsr[5][5]; TH1D* hBkgMCsb[5][5]; TH1D* rawSpectra[5]; TH1D* finSpectra[5]; TH2D* hPurity2D = new TH2D("hPurity2D",";pT(GeV);Centrality bin",nPtBin,ptBin,nCentBin,centBin); int nCent(-1); if ( ppHI == kHI ) nCent = nCentBin; if ( ppHI == kPP ) nCent = 1; for ( int icent = 1 ; icent<=nCent ; icent++) { rawSpectra[icent] = new TH1D(Form("rawSpec_icent%d_%s",icent,getIsoLabel(isoChoice).Data()),"",nPtBin,ptBin); } for (int ipt = 1; ipt <= nPtBin ; ipt++) { c1[ipt] = new TCanvas(Form("c1_ipt%d",ipt),"",700,700); if ( ppHI == kHI ) makeMultiPanelCanvas(c1[ipt],nCent/2,2,0.0,0.0,0.2,0.15,0.02); TCut ptCut = Form("corrPt>%.2f && corrPt<%.2f",(float)ptBin[ipt-1],(float)ptBin[ipt]); for ( int icent = 1 ; icent<=nCent ; icent++) { int lowCent = centBinVector[icent-1]; int highCent = centBinVector[icent]-1; hData[icent][ipt] = new TH1D(Form("hData_cent%d_pt%d",icent,ipt),";shower shape (#sigma_{#eta#eta});Entries per photon candidate;",25,0,0.025); hSig[icent][ipt] = (TH1D*)hData[icent][ipt]->Clone(Form("hSig_cent%d_pt%d",icent,ipt)); hBkg[icent][ipt] = (TH1D*)hData[icent][ipt]->Clone(Form("hBkg_cent%d_pt%d",icent,ipt)); hBkgMCsr[icent][ipt] = (TH1D*)hData[icent][ipt]->Clone(Form("hBkgMCsr_cent%d_pt%d",icent,ipt)); hBkgMCsb[icent][ipt] =(TH1D*)hData[icent][ipt]->Clone(Form("hBkgMCsb_cent%d_pt%d",icent,ipt)); TString fNamedata = fNameHIdata; if ( ppHI == kPP ) fNamedata = fNamePPdata; getTemplate(ppHI, hSig[icent][ipt],"meaningless",isoChoice,isoCut, kSig,lowCent,highCent,ptCut,onlygjEvents,specialSbCut,mcSigShift); getTemplate(ppHI, hData[icent][ipt],fNamedata ,isoChoice,isoCut, kData,lowCent,highCent,ptCut,onlygjEvents,specialSbCut); if ( ppHI == kHI) { getTemplate(ppHI, hBkg[icent][ipt], fNamedata ,isoChoice,isoCut, kSBB,lowCent,highCent,ptCut,onlygjEvents,specialSbCut,sbBkgShift); } if ( ppHI == kPP) getTemplate(ppHI, hBkg[icent][ipt], fNamedata ,isoChoice,isoCut, kSBBpp,lowCent,highCent,ptCut,onlygjEvents,specialSbCut); } for ( int icent = 1 ; icent<=nCent ; icent++) { int lowerCent = centBinVector[icent-1]; int upperCent =centBinVector[icent]-1; c1[ipt]->cd(nCent - icent+1); fitResult fitr = doFit ( hSig[icent][ipt], hBkg[icent][ipt], hData[icent][ipt], 0.005,0.025); if ( icent== nCent) drawPatch(0,0,0.05,0.14,0,1001, "ndc"); cout << " shift = " << mcSigShift << endl; cout << " purity = " << fitr.purity010 << endl; if ( ptBin[ipt]> 200) drawText(Form(" E_{T}^{#gamma} > %d GeV", (int)ptBin[ipt-1]),0.5680963,0.529118); else drawText(Form("%d - %d GeV", (int)ptBin[ipt-1], (int)ptBin[ipt]),0.5680963,0.529118); if ( ppHI == kHI) { drawText(Form("%.0f%% - %.0f%%", float((float)lowerCent*2.5), float((float)(upperCent+1)*2.5)),0.5680963,0.4369118); } else if ( ppHI == kPP) { drawText("7TeV pp",0.5680963,0.4369118); } if ( (icent == nCent) || (icent == 2)) drawText(Form("Purity(#sigma_{#eta#eta} < 0.01) : %.0f%%", (float)fitr.purity010*100),0.5680963,0.3569118,1,15); else drawText(Form("Purity(#sigma_{#eta#eta} < 0.01) : %.0f%%", (float)fitr.purity010*100),0.4980963,0.3569118,1,15); drawText(Form("#pm %.0f%% (stat)", float( 100. * fitr.purity010 * (float)fitr.nSigErr / (float)fitr.nSig ) ),0.6680963,0.2869118,1,15); hPurity2D->SetBinContent(ipt,icent,fitr.purity010); hPurity2D->SetBinError (ipt,icent,fitr.purity010* fitr.nSigErr/fitr.nSig); rawSpectra[icent]->SetBinContent( ipt, fitr.nSig); rawSpectra[icent]->SetBinError( ipt,fitr.nSigErr); TString aa = ""; if (isoChoice == kSumIso) aa = "Sum Iso Method"; if (isoChoice == k3dIso) aa = "3d Cut Method"; if (isoChoice == kFisher) aa = "Fisher Method"; if ( (ppHI == kHI) && ( icent==nCent -1) ) drawText(aa.Data(),0.1980963,0.8569118,1,20); else if ( ppHI == kPP) drawText(aa.Data(),0.1980963,0.8569118,1,20); if ( icent<= 2) drawPatch(0,0,0.05,0.14,0,1001, ndcOpt); // drawPatch(0.9,0.05,1.01,0.14,0,1001,ndcOpt); if ( (ppHI == kPP) && ( mcSigShift != 0 )) drawText(Form("Signal template shifted by %f",mcSigShift),0.1980963,0.7569118,1,15); if ( (ppHI == kHI) && ( mcSigShift != 0 ) && (icent==3)) drawText(Form("Signal template shifted by %f",mcSigShift),0.1980963,0.7569118,1,15); } TString ppLabel =""; if ( ppHI == kPP) ppLabel = "_pp"; TString shiftLabel=""; if ( mcSigShift != 0 ) shiftLabel = Form("_%fSigShifted",(float)mcSigShift); c1[ipt]->SaveAs(Form("fittingPurity%s_%s_pt%d%s.pdf",ppLabel.Data(), getIsoLabel(isoChoice).Data(),ipt,shiftLabel.Data())); } // efficiency plots TCanvas* c2 = new TCanvas("c2","",700,700); //100 + nCent_std*300,400); if ( ppHI == kHI) makeMultiPanelCanvas(c2,nCent/2,2,0.0,0.0,0.2,0.15,0.02); TH1D* heff[7][5]; TH1D* heffGj[5]; TH1D* heffDphi[5]; TH1D* effSingleBin = new TH1D("effSingleBin","",1,60,100000); TGraphAsymmErrors* geff[7][5]; TGraphAsymmErrors* gSingleBin = new TGraphAsymmErrors(); TGraphAsymmErrors* geffGj[5]; TGraphAsymmErrors* geffDphi[5]; for (int icent = 1; icent <=nCent; icent++) { for ( int iid=1 ; iid<=5; iid++) { heff[icent][iid] = new TH1D(Form("heff_icent%d_id%d",icent,iid),";photon E_{T} (GeV);Efficiency",nPtBin, ptBin); if ( isoChoice == kSumIso2) heff[icent][iid]->SetName(Form("heff_icent%d_id%d_isoCut%d",icent,iid,(int)isoCut)); if ( isoChoice == kSumIso3) heff[icent][iid]->SetName(Form("heff_icent%d_id%d_sbIsoCut%d",icent,iid,(int)specialSbCut)); geff[icent][iid] = new TGraphAsymmErrors(); geff[icent][iid]->SetName(Form("geff_%s",heff[icent][iid]->GetName())); } heffGj[icent] = new TH1D(Form("heff_icent%d_Gj", icent),";x_J#gamma;Efficiency",10,0,2); heffDphi[icent] = new TH1D(Form("heff_icent%d_Dphi",icent),";#Delta#phi of pair;Efficiency",9,0.3141592,3.141592); geffGj[icent] = new TGraphAsymmErrors(); geffDphi[icent] = new TGraphAsymmErrors(); } TCut srIsoCut = getIsoCut(isoChoice,isoCut); int nId=4; for (int icent = 1; icent <=nCent ; icent++) { int lowCent = centBinVector[icent-1]; int highCent = centBinVector[icent]-1; TCut centCut = Form("yEvt.hiBin >= %d && yEvt.hiBin<= %d",lowCent,highCent); if ( ppHI == kPP ) centCut = ""; getEff("genMatchedPt",heff[icent][1],geff[icent][1],centCut, "swissCrx<0.90 && seedTime<4"); getEff("genMatchedPt",heff[icent][2],geff[icent][2],centCut, "swissCrx<0.90 && seedTime<4 && hadronicOverEm<0.1"); getEff("genMatchedPt",heff[icent][3],geff[icent][3],centCut, "swissCrx<0.90 && seedTime<4 && hadronicOverEm<0.1" && srIsoCut); getEff("genMatchedPt",heff[icent][4],geff[icent][4],centCut, "swissCrx<0.90 && seedTime<4 && hadronicOverEm<0.1 && sigmaIetaIeta<0.010"&& srIsoCut); effSingleBin->Reset(); getEff("genMatchedPt",effSingleBin, gSingleBin, centCut, "swissCrx<0.90 && seedTime<4 && hadronicOverEm<0.1" && srIsoCut); cout << " here Gj" << endl; getEff("yJet.jtpt/photonEt",heffGj[icent],geffGj[icent], centCut && " genIso<5 && abs(genMomId)<=22 && photonEt>60 && abs(yJet.jteta)<2 && yJet.jtpt>30 && acos(cos(photonPhi-yJet.jtphi))>2.749", "hovere<0.1 && sigmaIetaIeta<0.010 && (cc4+cr4+ct4PtCut20)/0.9<1",true); getEff("acos(cos(photonPhi-yJet.jtphi))",heffDphi[icent],geffDphi[icent],centCut && " genIso<5 && abs(genMomId)<=22 && photonEt>60 && abs(yJet.jteta)<2 && yJet.jtpt>30", "hovere<0.1 && sigmaIetaIeta<0.010 && (cc4+cr4+ct4PtCut20)/0.9<1",true); } for (int icent = 1; icent <=nCent; icent++) { for ( int iid=1 ; iid<=nId ; iid++) { handsomeTH1(heff[icent][iid],ycolor[iid]); handsomeTGraph(geff[icent][iid],ycolor[iid]); } } TH1D* htmp = (TH1D*)heff[1][1]->Clone("htmp"); htmp->Reset(); htmp->SetAxisRange(0,1.3,"Y"); htmp->SetYTitle("Efficiency"); handsomeTH1(htmp); for (int icent = 1; icent <=nCent; icent++) { int lowerCent = centBinVector[icent-1]; int upperCent = centBinVector[icent]-1; if ( ppHI == kHI) c2->cd(nCent - icent + 1); htmp->DrawCopy(); for ( int iid=1 ; iid<=nId ; iid++) { heff[icent][iid]->Draw("p same"); geff[icent][iid]->Draw("p"); } if ( ( icent == nCent ) || ( ppHI == kPP) ) { TLegend* leg1 = new TLegend(0.25,0.20,0.95,0.55,NULL,"brNDC"); easyLeg(leg1,"Photon ID efficiency"); leg1->AddEntry(heff[icent][1],"spike rejection","lp"); leg1->AddEntry(heff[icent][2],"+ H/E < 0.1","lp"); if (isoChoice == kSumIso) leg1->AddEntry(heff[icent][3],"+ SumIso cut","lp"); if (isoChoice == kFisher) leg1->AddEntry(heff[icent][3],"+ Fisher cut","lp"); leg1->AddEntry(heff[icent][4],"+ #sigma_{#eta#eta} <0.010","lp"); leg1->Draw(); } drawText(Form("%.0f%% - %.0f%%", float((float)lowerCent*2.5), float((float)(upperCent+1)*2.5)),0.5680963,0.8369118); if ( icent<=2) drawPatch(0,0,0.05,0.14,0,1001,ndcOpt); // drawPatch(0.9,0.05,1.01,0.14,0,1001,ndcOpt); } c2->SaveAs(Form("photonID_efficiency_%s.pdf",getIsoLabel(isoChoice).Data())); TCanvas* c2b = new TCanvas("c2b","",1000,500); //100 + nCent_std*300,400); c2b->Divide(2,1); c2b->cd(1); TH1D* htmpG = (TH1D*)heffGj[1]->Clone("htmpG"); htmpG->Reset(); htmpG->SetAxisRange(0,1.3,"Y"); htmpG->SetYTitle("Efficiency"); handsomeTH1(htmpG); TLegend* legCent = new TLegend(0.4657258,0.2245763,1,0.4512712,NULL,"brNDC"); easyLeg(legCent,"Centrality"); if (isoChoice == kSumIso) easyLeg(legCent,"SumIso Method"); if (isoChoice == kFisher) easyLeg(legCent,"Fisher Method"); cout<< " heffGj "<< endl << endl<< endl; for (int icent = 1; icent <=nCent; icent++) { handsomeTH1(heffGj[icent],ycolor[icent]); heffGj[icent]->Fit("pol1"); heffGj[icent]->GetFunction("pol1")->SetLineColor(ycolor[icent]); heffGj[icent]->GetFunction("pol1")->SetLineStyle(7); } htmpG->DrawCopy(); for (int icent = 1; icent <=nCent; icent++) { heffGj[icent]->Draw("same"); int lowerCent = centBinVector[icent-1]; int upperCent = centBinVector[icent]-1; legCent->AddEntry(heffGj[icent],Form("%.0f%% - %.0f%%", float((float)lowerCent*2.5), float((float)(upperCent+1)*2.5)),"pl"); } legCent->Draw(); c2b->cd(2); TH1D* htmpDp = new TH1D("htmpDp",";#Delta#phi of pair;Efficiency",10,0,3.14); htmpDp->Reset(); htmpDp->SetAxisRange(0,1.3,"Y"); htmpDp->SetYTitle("Efficiency"); handsomeTH1(htmpDp); cout << " heffDphi " << endl << endl << endl ; for (int icent = 1; icent <=nCent; icent++) { handsomeTH1(heffDphi[icent],ycolor[icent]); heffDphi[icent]->Fit("pol1"); heffDphi[icent]->GetFunction("pol1")->SetLineColor(ycolor[icent]); heffDphi[icent]->GetFunction("pol1")->SetLineStyle(7); } htmpDp->DrawCopy(); for (int icent = 1; icent <=nCent; icent++) { heffDphi[icent]->Draw("same"); } legCent->Draw(); c2b->SaveAs(Form("photonID_efficiency_%s_2.pdf",getIsoLabel(isoChoice).Data())); TCanvas* c3 = new TCanvas("cPurity","",500,500); TH1D* hPurity[10]; for (int icent = 1; icent <=nCent; icent++) { hPurity[icent] = (TH1D*)hPurity2D->ProjectionX(Form("purity1D_icent%d",icent),icent,icent); hPurity[icent]->Fit("pol1"); hPurity[icent]->GetFunction("pol1")->SetLineColor(ycolor[icent]); hPurity[icent]->GetFunction("pol1")->SetLineStyle(7); } TH1D* tempPurity = (TH1D*)hPurity[1]->Clone("purityTemp"); tempPurity->Reset(); handsomeTH1(tempPurity,1); tempPurity->SetXTitle("pT (Gev)"); tempPurity->SetYTitle("Purity"); tempPurity->SetAxisRange(0.45,1.2,"Y"); tempPurity->Draw(); for (int icent = 1; icent <=nCent; icent++) { handsomeTH1(hPurity[icent],ycolor[icent]); hPurity[icent]->Draw("same"); } TLegend* legPurity = new TLegend(0.4657258,0.2245763,1,0.4512712,NULL,"brNDC"); easyLeg(legPurity,"Purity"); if (isoChoice == kSumIso) easyLeg(legPurity,"SumIso Method"); if (isoChoice == kFisher) easyLeg(legPurity,"Fisher Method"); for (int icent = 1; icent <=nCent; icent++){ int lowerCent = centBinVector[icent-1]; int upperCent = centBinVector[icent]-1; legPurity->AddEntry(hPurity[icent],Form("%.0f%% - %.0f%%", float((float)lowerCent*2.5), float((float)(upperCent+1)*2.5)),"pl"); } legPurity->Draw(); if ( !onlygjEvents) drawText("inclusive photon",0.25,0.2); c3->SaveAs(Form("purity_%s.pdf",getIsoLabel(isoChoice).Data())); TCanvas* c4 = new TCanvas("efficiencyCorrection","",1000,500); c4->Divide(2,1); c4->cd(1); for (int icent = 1; icent <=nCent; icent++) { TH1ScaleByWidth(rawSpectra[icent]); // divide by width finSpectra[icent] = (TH1D*)rawSpectra[icent]->Clone(Form("finSpec_icent%d_%s",icent,getIsoLabel(isoChoice).Data())); if ( isoChoice == kSumIso2) finSpectra[icent]->SetName(Form("finSpec_icent%d_%s_isoCut%d",icent,getIsoLabel(isoChoice).Data(),(int)isoCut)); if ( isoChoice == kSumIso3) finSpectra[icent]->SetName(Form("finSpec_icent%d_%s_sbisoCut%d",icent,getIsoLabel(isoChoice).Data(),(int)specialSbCut)); finSpectra[icent]->Divide(heff[icent][3]); handsomeTH1(finSpectra[icent],ycolor[icent]); } // TAA and centrality // TFile outf = TFile(cab.getPurityFileName(),"recreate"); hPurity2D->Write(); for ( int icent=1 ; icent<=nCent ; icent++) { heff[icent][3]->Write(); heff[icent][4]->Write(); finSpectra[icent]->Write(); hPurity[icent]->Write(); for (int ipt = 1; ipt <= nPtBin ; ipt++) { hData[icent][ipt]->Write(); } // hBkgMCRatioFit[icent][1]->Write(); } outf.Close(); }
osg::ref_ptr<osg::Node> SceneManager::createInstance(const std::string &name) { osg::ref_ptr<const osg::Node> scene = getTemplate(name); osg::ref_ptr<osg::Node> cloned = osg::clone(scene.get(), SceneUtil::CopyOp()); return cloned; }
float TouchTracker::Calibrator::differenceFromTemplateTouchWithMask(const MLSignal& in, Vec2 pos, const MLSignal& mask) { static float maskThresh = 0.001f; static MLSignal a2(kTemplateSize, kTemplateSize); static MLSignal b(kTemplateSize, kTemplateSize); static MLSignal b2(kTemplateSize, kTemplateSize); float r = 0.f; int height = in.getHeight(); int width = in.getWidth(); MLRect boundsRect(0, 0, width, height); // use linear interpolated z value from input float linearZ = in.getInterpolatedLinear(pos)*getZAdjust(pos); linearZ = clamp(linearZ, 0.00001f, 1.f); float z1 = 1./linearZ; const MLSignal& a = getTemplate(pos); // get normalized input values surrounding touch int tr = kTemplateRadius; b.clear(); for(int j=0; j < kTemplateSize; ++j) { for(int i=0; i < kTemplateSize; ++i) { Vec2 vInPos = pos + Vec2((float)i - tr,(float)j - tr); if (boundsRect.contains(vInPos) && (mask.getInterpolatedLinear(vInPos) < maskThresh)) { float inVal = in.getInterpolatedLinear(vInPos); inVal *= z1; b(i, j) = inVal; } } } int tests = 0; float sum = 0.; // add differences in z from template a2.copy(a); b2.copy(b); a2.partialDiffX(); b2.partialDiffX(); for(int j=0; j < kTemplateSize; ++j) { for(int i=0; i < kTemplateSize; ++i) { if(b(i, j) > 0.) { float d = a2(i, j) - b2(i, j); sum += d*d; tests++; } } } // get RMS difference if(tests > 0) { r = sqrtf(sum / tests); } return r; }
bool execute(const std::string& skeleton, const std::string& config_file, std::string output_dir/* = ""*/) { std::vector<Plot> plots; // If an output directory is specified, use it, otherwise use the current directory if (output_dir == "") output_dir = "."; std::map<std::string, std::string> unique_names; get_plots(config_file, plots); std::cout << "List of requested plots: "; for (size_t i = 0; i < plots.size(); i++) { std::cout << "'" << plots[i].name << "'"; if (i != plots.size() - 1) std::cout << ", "; } std::cout << std::endl; // Convert plots name to unique name to avoid collision between different runs for (Plot& plot: plots) { std::string uuid = get_uuid(); unique_names[uuid] = plot.name; plot.name = uuid; } std::unique_ptr<TChain> t(new TChain("t")); t->Add(skeleton.c_str()); std::vector<Branch> branches; std::function<void(TTreeFormula*)> getBranches = [&branches, &getBranches](TTreeFormula* f) { if (!f) return; for (size_t i = 0; i < f->GetNcodes(); i++) { TLeaf* leaf = f->GetLeaf(i); if (! leaf) continue; TBranch* p_branch = getTopBranch(leaf->GetBranch()); Branch branch; branch.name = p_branch->GetName(); if (std::find_if(branches.begin(), branches.end(), [&branch](const Branch& b) { return b.name == branch.name; }) == branches.end()) { branch.type = p_branch->GetClassName(); if (branch.type.empty()) branch.type = leaf->GetTypeName(); branches.push_back(branch); } for (size_t j = 0; j < f->fNdimensions[i]; j++) { if (f->fVarIndexes[i][j]) getBranches(f->fVarIndexes[i][j]); } } for (size_t i = 0; i < f->fAliases.GetEntriesFast(); i++) { getBranches((TTreeFormula*) f->fAliases.UncheckedAt(i)); } }; std::string hists_declaration; std::string text_plots; for (auto& p: plots) { // Create formulas std::shared_ptr<TTreeFormula> selector(new TTreeFormula("selector", p.plot_cut.c_str(), t.get())); getBranches(selector.get()); std::vector<std::string> splitted_variables = split(p.variable, ":"); for (const std::string& variable: splitted_variables) { std::shared_ptr<TTreeFormula> var(new TTreeFormula("var", variable.c_str(), t.get())); getBranches(var.get()); } std::string binning = p.binning; binning.erase(std::remove_if(binning.begin(), binning.end(), [](char chr) { return chr == '(' || chr == ')'; }), binning.end()); // If a variable bin size is specified, declare array that will be passed as array to histogram constructor if(binning.find("{") != std::string::npos){ std::string arrayString = buildArrayForVariableBinning(binning, splitted_variables.size(), p.name); hists_declaration += arrayString; } std::string title = p.title + ";" + p.x_axis + ";" + p.y_axis + ";" + p.z_axis; std::string histogram_type = getHistogramTypeForDimension(splitted_variables.size()); hists_declaration += " std::unique_ptr<" + histogram_type + "> " + p.name + "(new " + histogram_type + "(\"" + p.name + "\", \"" + title + "\", " + binning + ")); " + p.name + "->SetDirectory(nullptr);\n"; std::string variable_string; for (size_t i = 0; i < splitted_variables.size(); i++) { variable_string += splitted_variables[i]; if (i != splitted_variables.size() - 1) variable_string += ", "; } ctemplate::TemplateDictionary plot("plot"); plot.SetValue("CUT", p.plot_cut); plot.SetValue("VAR", variable_string); plot.SetValue("HIST", p.name); ctemplate::ExpandTemplate(getTemplate("Plot"), ctemplate::DO_NOT_STRIP, &plot, &text_plots); } // Sort alphabetically std::sort(branches.begin(), branches.end(), [](const Branch& a, const Branch& b) { return a.name < b.name; }); std::string text_branches; for (const auto& branch: branches) { text_branches += "const " + branch.type + "& " + branch.name + " = tree[\"" + branch.name + "\"].read<" + branch.type + ">();\n "; } ctemplate::TemplateDictionary header("header"); header.SetValue("BRANCHES", text_branches); std::string output; ctemplate::ExpandTemplate(getTemplate("Plotter.h"), ctemplate::DO_NOT_STRIP, &header, &output); std::ofstream out(output_dir + "/Plotter.h"); out << output; out.close(); output.clear(); std::string text_save_plots; for (auto& p: plots) { ctemplate::TemplateDictionary save_plot("save_plot"); save_plot.SetValue("UNIQUE_NAME", p.name); save_plot.SetValue("PLOT_NAME", unique_names[p.name]); ctemplate::ExpandTemplate(getTemplate("SavePlot"), ctemplate::DO_NOT_STRIP, &save_plot, &text_save_plots); } ctemplate::TemplateDictionary source("source"); source.SetValue("HISTS_DECLARATION", hists_declaration); source.SetValue("PLOTS", text_plots); source.SetValue("SAVE_PLOTS", text_save_plots); ctemplate::ExpandTemplate(getTemplate("Plotter.cc"), ctemplate::DO_NOT_STRIP, &source, &output); out.open(output_dir + "/Plotter.cc"); out << output; out.close(); return true; }
void mmHomePagePanel::createHTML() { getTemplate(); getData(); fillData(); }
RCType TDFParser::processTracePointDetail(const char *line, J9TDFTracepoint *tp, const char *module, unsigned int id, const char *fileName, unsigned int lineNumber) { RCType rc = RC_FAILED; char *tok = NULL; tp->level = -1; tp->hasEnv = true; /* Save original string because strtok mangles the source string by placing \0 at delimiter */ char *tokLine = strdup(line); /* read the first token */ tok = strtok(tokLine, " \t"); line = line + strlen(tok) + 1; while ((' ' == *line || '\t' == *line) && '\0' != *line) { line = line + 1; } tp->name = strdup(strchr(tok, '=') + 1); Port::omrmem_free((void **)&tokLine); /* now parse all of the optional fields */ tokLine = strdup(line); tok = strtok(tokLine, " \t"); while (NULL != tok) { if (StringUtils::startsWithUpperLower(tok, "Explicit")) { /* tp->isExplicit = true; */ FileUtils::printError("WARNING : obsolete keyword 'Explicit' in %s:%u\n", fileName, lineNumber); line = line + strlen(tok); while ((' ' == *line || '\t' == *line) && '\0' != *line) { line = line + 1; } tok = strtok(NULL, " \t"); } else if (StringUtils::startsWithUpperLower(tok, "Suffix")) { /* tp->isSuffix = true; */ FileUtils::printError("WARNING : obsolete keyword 'Suffix' in %s:%u\n", fileName, lineNumber); line = line + strlen(tok); while ((' ' == *line || '\t' == *line) && '\0' != *line) { line = line + 1; } tok = strtok(NULL, " \t"); } else if (StringUtils::startsWithUpperLower(tok, "Prefix")) { /* tp->isPrefix = true; */ FileUtils::printError("WARNING : obsolete keyword 'Prefix' in %s:%u\n", fileName, lineNumber); line = line + strlen(tok); while ((' ' == *line || '\t' == *line) && '\0' != *line) { line = line + 1; } tok = strtok(NULL, " \t"); } else if (StringUtils::startsWithUpperLower(tok, "Exception")) { /* tp->isException = true; */ FileUtils::printError("WARNING : obsolete keyword 'Exception' in %s:%u\n", fileName, lineNumber); line = line + strlen(tok); while ((' ' == *line || '\t' == *line) && '\0' != *line) { line = line + 1; } tok = strtok(NULL, " \t"); } else if (StringUtils::startsWithUpperLower(tok, "Private")) { /* tp->isPrivate = true; */ FileUtils::printError("WARNING : obsolete keyword 'Private' in %s:%u\n", fileName, lineNumber); line = line + strlen(tok); while ((' ' == *line || '\t' == *line) && '\0' != *line) { line = line + 1; } tok = strtok(NULL, " \t"); } else if (StringUtils::startsWithUpperLower(tok, "Test")) { tp->test = true; line = line + strlen(tok); while ((' ' == *line || '\t' == *line) && '\0' != *line) { line = line + 1; } tok = strtok(NULL, " \t"); } else if (StringUtils::startsWithUpperLower(tok, "NoEnv")) { tp->hasEnv = false; line = line + strlen(tok); while ((' ' == *line || '\t' == *line) && '\0' != *line) { line = line + 1; } tok = strtok(NULL, " \t"); } else if (StringUtils::startsWithUpperLower(tok, "Obsolete")) { tp->obsolete = true; line = line + strlen(tok); while ((' ' == *line || '\t' == *line) && '\0' != *line) { line = line + 1; } tok = strtok(NULL, " \t"); } else if (StringUtils::startsWithUpperLower(tok, (UT_ASSERT_TYPE == tp->type ? "Assert=" : "Template="))) { tp->format = getTemplate(line, (UT_ASSERT_TYPE == tp->type ? "Assert=" : "Template=")); if (NULL == tp->format){ goto failed; } line = line + strlen((UT_ASSERT_TYPE == tp->type ? "Assert=" : "Template=")) + (strlen(tp->format) + 2 /* two quotes */); while ((' ' == *line || '\t' == *line) && '\0' != *line) { line = line + 1; } Port::omrmem_free((void **)&tokLine); tokLine = strdup(line); tok = strtok(tokLine, " \t"); } else if (StringUtils::startsWithUpperLower(tok, "Level=")) { if (RC_OK != StringUtils::getPositiveIntValue(tok, "Level=", &tp->level)) { goto failed; } line = line + strlen(tok); while ((' ' == *line || '\t' == *line) && '\0' != *line) { line = line + 1; } Port::omrmem_free((void **)&tokLine); tokLine = strdup(line); tok = strtok(tokLine, " \t"); } else if (StringUtils::startsWithUpperLower(tok, "Overhead=")) { if (RC_OK != StringUtils::getPositiveIntValue(tok, "Overhead=", &tp->overhead)) { goto failed; } line = line + strlen(tok); while ((' ' == *line || '\t' == *line) && '\0' != *line) { line = line + 1; } Port::omrmem_free((void **)&tokLine); tokLine = strdup(line); tok = strtok(tokLine, " \t"); } else if (StringUtils::startsWithUpperLower(tok, "Group=")) { tp->groups = getGroups(tok); line = line + strlen(tok); while ((' ' == *line || '\t' == *line) && '\0' != *line) { line = line + 1; } Port::omrmem_free((void **)&tokLine); tokLine = strdup(line); tok = strtok(tokLine, " \t"); } else { line = line + strlen(tok); while ((' ' == *line || '\t' == *line) && '\0' != *line) { line = line + 1; } Port::omrmem_free((void **)&tokLine); tokLine = strdup(line); tok = strtok(tokLine, " \t"); } } /* Assign default level */ if ((unsigned int)-1 == tp->level) { tp->level = 1; } if (NULL == tp->format) { tp ->format = (char *)Port::omrmem_calloc(1, (strlen("null") + 1)); strncpy(tp ->format, "null", strlen("null")); } if (UT_ASSERT_TYPE == tp->type) { /* Assertion parameters are always \"\\377\\4\\377\" for "** ASSERTION FAILED ** at %s:%d: %s" */ tp->parameters = NULL; rc = processAssertTemplate(tp->format, &tp->parmCount); } else { const char *key = "%"; const char *pch = strpbrk(tp->format, key); unsigned int percentSignCount = 0; while (NULL != pch) { percentSignCount += 1; pch = strpbrk(pch + 1, key); } size_t len = 5 /* \\\"\\\"\0 when no parameters specified */ + (percentSignCount * (strlen(TRACE_DATA_TYPE_STRING) + strlen(TRACE_DATA_TYPE_PRECISION))) /* TRACE_DATA_TYPE_STRING is the longest parameter string + precision specifier*/; tp->parameters = (char *)Port::omrmem_calloc(1, len); if (NULL == tp->parameters) { FileUtils::printError("Failed to allocate memory\n"); goto failed; } rc = processTemplate(tp->format, tp->parameters, &tp->parmCount, fileName, lineNumber); /* We pass NULL for no parameters not the empty string "". */ if (0 == tp->parmCount) { Port::omrmem_free((void **)&tp->parameters); tp->parameters = (char *)Port::omrmem_calloc(1, strlen("NULL") + 1); strcpy(tp->parameters, "NULL"); } } return rc; failed: return rc; }