Пример #1
0
CString	CShellIcons::GetName(LPCTSTR pszType)
{
	CString strType( pszType );
	strType.MakeLower();

	CQuickLock oLock( m_pSection );

	CString strName;
	if ( ! m_Name.Lookup( strType, strName ) )
	{
		Lookup( pszType, &strName, NULL, NULL, NULL, NULL );

		if ( strName.IsEmpty() )
		{
			if ( *pszType )
				strName = pszType + 1;	// Use extension without dot
			else
				strName = LoadString( IDS_STATUS_UNKNOWN );
		}

		m_Name.SetAt( strType, strName );
	}

	return strName;
}
Пример #2
0
void CNetwork::ProcessData( QByteArray &byData )
{
    if ( byData.isEmpty( ) ) {
        return;
    }

    QStringList lstData;

    int nCount = byData.count( SEPERATOR );
    int nIndex = byData.indexOf( SEPERATOR );

    if ( 2 > nCount || -1 == nIndex ) {
        return;
    }

    QString strType( byData.left( nIndex ) );
    if ( DATAGRAM_TOKEN != strType ) {
        return;
    }
    byData.remove( 0, nIndex + 1 );

    for ( int nItem = 0; nItem < nCount - 1; nItem++ ) {
        nIndex = byData.indexOf( SEPERATOR );
        lstData << byData.left( nIndex );
        byData.remove( 0, nIndex + 1 );
    }

    lstData << byData; // Last One

    emit OnReceiveDatagram( lstData );
}
Пример #3
0
int GuestFsObjData::From(const GuestProcessStreamBlock &strmBlk)
{
    int rc = VINF_SUCCESS;

    try
    {
        Utf8Str strType(strmBlk.GetString("ftype"));
        if (strType.equalsIgnoreCase("-"))
            mType = FsObjType_File;
        else if (strType.equalsIgnoreCase("d"))
            mType = FsObjType_Directory;
        /** @todo Add more types! */
        else
            mType = FsObjType_Undefined;

        rc = strmBlk.GetInt64Ex("st_size", &mObjectSize);
        if (RT_FAILURE(rc)) throw rc;

        /** @todo Add complete GuestFsObjData info! */
    }
    catch (int rc2)
    {
        rc = rc2;
    }

    return rc;
}
Пример #4
0
 void UPnP::CloseMapping (std::shared_ptr<i2p::data::RouterInfo::Address> address)
 {
     std::string strType (GetProto (address)), strPort (std::to_string (address->port));
     int r = 0;
     r = UPNP_DeletePortMapping (m_upnpUrls.controlURL, m_upnpData.first.servicetype, strPort.c_str (), strType.c_str (), 0);
     LogPrint (eLogError, "UPnP: DeletePortMapping() returned : ", r);
 }
Пример #5
0
void HDFAtom<std::string>::Create(H5::H5Location &object, std::string atomName) {
    H5::StrType strType(0, H5T_VARIABLE);
    hsize_t defaultDims[] = {1};
    H5::DataSpace defaultDataSpace(1, defaultDims);
    attribute = object.createAttribute(atomName.c_str(), strType, H5::DataSpace(H5S_SCALAR));
    initialized= true;
}
Пример #6
0
 void Create(H5::H5Location &object, const std::string & name, const std::vector<std::string> &vect) {
     hsize_t length = vect.size();
     H5::StrType strType(0,H5T_VARIABLE);
     H5::ArrayType arrayDataType(strType, 1, &length);
     attribute = object.createAttribute(name.c_str(), strType, H5::DataSpace(1, &length));
     attribute.write(strType, &((vect)[0]));    
 }
Пример #7
0
void ATemplateNodeHandler_DADA::Node::_generateLine(ADadaDataHolder *pddh, MAP_AString_AString& globals, const AString& format, ATemplateContext& context, AOutputBuffer& output)
{
  if (format.isEmpty())
    return;
  
  AFile_AString file(format);
  size_t readresult;
  char c = '\x0';
  AString target(1024, 1024), strType(64,128);
  while (AConstant::npos != file.readUntil(target, S_DELIM_START, true, true))
  {
    file.read(c);
    readresult = file.readUntil(strType, S_DELIM_END, true, true);
    if (0 == readresult)
    {
      file.readUntilEOF(target);
      output.append(target);
      target.clear();
      break;
    }

    //a_If not EOF process type
    if (AConstant::npos != readresult)
    {
      if (strType.getSize() > 1)
      {
        switch (c)
        {
          case '%':
            //a_Process the tag {%type:tag,tag,...}
            _appendWordType(pddh, globals, strType, target);
          break;

          case '$':
            //a_ {$variable}
            _appendVariable(pddh, globals, strType, target);
          break;

          default:
            //a_Passthru of unknown tags
            target.append('{');
            target.append(strType);
            target.append('}');
            context.useEventVisitor().addEvent(ASWNL("ATemplateNodeHandler_DADA::Node:") + " unknown type:" + strType, AEventVisitor::EL_WARN);
          break;
        }
        strType.clear(); 
      }
    }
  }
  file.readUntilEOF(target);
  output.append(target);
  target.clear();
}
Пример #8
0
void
DataSetIO::SaveDataSet(const DataSet& dataSet_, const std::string& filename_){
    // Get the relevant params
    hsize_t nEntries     = dataSet_.GetNEntries();
    hsize_t nObs  = dataSet_.GetNObservables();
    hsize_t nData = nObs * nEntries;

    // create colon separated string from list of observables
    std::vector<std::string> observableNames = dataSet_.GetObservableNames();
    if (observableNames.size() != nObs)
        throw HdfIOError("SaveDataSet::Require one name and one name only for each observable");
    

    // Set up files
    H5::H5File file(filename_, H5F_ACC_TRUNC);
    
    // Flatten data into 1D array
    // HDF5 likes c arrays. Here use a vector and pass pointer to first element 
    // memory guaranteed to be contiguous
    std::vector<double> flattenedData;
    std::vector<double> eventData;
    flattenedData.reserve(nData);
    for(size_t i = 0; i < nEntries; i++){
        eventData = dataSet_.GetEntry(i).GetData();
        flattenedData.insert(flattenedData.end(), eventData.begin(), eventData.end());
    }
    
    // Set up the data set
    // 1D, ndata long, called "observations". Saved as native doubles on this computer
    H5::DataSpace dataSpace(1, &nData);  
    H5::DataSet   theData(file.createDataSet("observations", H5::PredType::NATIVE_DOUBLE, dataSpace));
    
    //  Set up the attributes - the number of obs per event and the names of the observables
    //  64 chars max in str to save space
    H5::StrType   strType(H5::PredType::C_S1, 64);
    H5::DataSpace attSpace(H5S_SCALAR);
    H5::Attribute obsListAtt = theData.createAttribute("observed_quantities", strType, attSpace);
    obsListAtt.write(strType, FlattenStringVector(observableNames, fDelimiter));

    H5::Attribute countAtt = theData.createAttribute("n_observables",
                                                     H5::PredType::NATIVE_INT,
                                                     attSpace);
    countAtt.write(H5::PredType::NATIVE_INT, &nObs);

    //  Write the data
    theData.write(&flattenedData.at(0), H5::PredType::NATIVE_DOUBLE);
    
}
Пример #9
0
   void WriteTStrAttrib(const std::string& name, const std::string& value){

      std::string str = value;
      str.resize( STRING_ATTRIB_SIZE );

      //define the data type as a string with the value's length
      H5::StrType strType(0, STRING_ATTRIB_SIZE );

      //open the data set and create a new attribute of type string
      H5::Attribute attrib = 
         dSet_.createAttribute(name, strType, H5::DataSpace(H5S_SCALAR));

      //write value to the attribute and close
      attrib.write(strType, str );
      attrib.close();
   }
Пример #10
0
 void UPnP::TryPortMapping (std::shared_ptr<i2p::data::RouterInfo::Address> address)
 {
     std::string strType (GetProto (address)), strPort (std::to_string (address->port));
     int r;
     std::string strDesc; i2p::config::GetOption("upnp.name", strDesc);
     r = UPNP_AddPortMapping (m_upnpUrls.controlURL, m_upnpData.first.servicetype, strPort.c_str (), strPort.c_str (), m_NetworkAddr, strDesc.c_str (), strType.c_str (), 0, "0");
     if (r!=UPNPCOMMAND_SUCCESS)
     {
         LogPrint (eLogError, "UPnP: AddPortMapping (", m_NetworkAddr, ":", strPort, ") failed with code ", r);
         return;
     }
     else
     {
         LogPrint (eLogDebug, "UPnP: Port Mapping successful. (", m_NetworkAddr ,":", strPort, " type ", strType, " -> ", m_externalIPAddress ,":", strPort ,")");
         return;
     }
 }
Пример #11
0
   const std::string ReadStrAttrib(const std::string& name){
      //attributes are clunky in HDF5++ implementation - this is a workaround
      //template is required to pass the proper value type

      std::string value;
      value.resize( STRING_ATTRIB_SIZE );

      H5::StrType strType(0, STRING_ATTRIB_SIZE );
      //access the built-in root group and create a new attribute for it.
      H5::Group rootGroup = file_->openGroup("/");
      H5::Attribute attrib = rootGroup.openAttribute(name);

      //write the value to the attribute and close
      attrib.read(strType,value);
      attrib.close();

      return value;
   }
Пример #12
0
CString	CShellIcons::GetMIME(LPCTSTR pszType)
{
	CString strType( pszType );
	strType.MakeLower();

	CQuickLock oLock( m_pSection );

	CString strMIME;
	if ( ! m_MIME.Lookup( strType, strMIME ) )
	{
		Lookup( pszType, NULL, &strMIME, NULL, NULL, NULL );

		if ( strMIME.IsEmpty() )
			strMIME = L"application/x-binary";

		m_MIME.SetAt( strType, strMIME );
	}

	return strMIME;
}
Пример #13
0
   void WriteStrAttrib(const std::string& name, const std::string& value){
      //HDF5 has a mangled way of creating string attributes - 
      //this is a workaround

      //create a string array of length 1 containing the value to be written
      //std::string strBuf[1] = {value};
      std::string str = value;
      str.resize( STRING_ATTRIB_SIZE );

      //define the data type as a string with the value's length
      H5::StrType strType(0, STRING_ATTRIB_SIZE );

      //open the root group and create a new attribute of type string
      H5::Group rootGroup = file_->openGroup("/");
      H5::Attribute attrib = rootGroup.createAttribute(name,
            strType,H5::DataSpace());

      //write value to the attribute and close
      attrib.write(strType, str);
      attrib.close();
   }
Пример #14
0
   const std::string ReadTStrAttrib(const int& tableNum, const std::string& name){

      //attributes are clunky in HDF5++ implementation - this is a workaround
      //template is required to pass the proper value type

      std::string tNum = Num2Table(tableNum);

      std::string value;
      value.resize( STRING_ATTRIB_SIZE );
      //std::cout << "attribute string read name = " << tNum << std::endl;

      H5::StrType strType(0, STRING_ATTRIB_SIZE );

      dSet_ = file_->openDataSet(tNum);
      H5::Attribute attrib = dSet_.openAttribute(name);

      //write the value to the attribute and close
      attrib.read(strType,value);
      attrib.close();

      return value;
   }
Пример #15
0
int GuestFsObjData::FromStat(const GuestProcessStreamBlock &strmBlk)
{
    LogFlowFunc(("\n"));

    int rc = VINF_SUCCESS;

    try
    {
#ifdef DEBUG
        strmBlk.DumpToLog();
#endif
        /* Node ID, optional because we don't include this
         * in older VBoxService (< 4.2) versions. */
        mNodeID = strmBlk.GetInt64("node_id");
        /* Object name. */
        mName = strmBlk.GetString("name");
        if (mName.isEmpty()) throw VERR_NOT_FOUND;
        /* Type. */
        Utf8Str strType(strmBlk.GetString("ftype"));
        if (strType.equalsIgnoreCase("-"))
            mType = FsObjType_File;
        else if (strType.equalsIgnoreCase("d"))
            mType = FsObjType_Directory;
        /** @todo Add more types! */
        else
            mType = FsObjType_Undefined;
        /* Object size. */
        rc = strmBlk.GetInt64Ex("st_size", &mObjectSize);
        if (RT_FAILURE(rc)) throw rc;
        /** @todo Add complete stat info! */
    }
    catch (int rc2)
    {
        rc = rc2;
    }

    LogFlowFuncLeaveRC(rc);
    return rc;
}
Пример #16
0
void CPropertiesWnd::PropertyChanged(CMFCPropertyGridProperty* pProp)
{
	CString strName(pProp->GetName());
	if (strName.CompareNoCase(_T("TYPE")) == 0)
	{
		CMFCPropertyGridProperty* pPropGroup = pProp->GetParent();
		for (int i = pPropGroup->GetSubItemsCount() - 1; i >= 0; i--)
		{
			CMFCPropertyGridProperty* pChildProp = pPropGroup->GetSubItem(i);
			if (pChildProp == pProp)
			{
				break;
			}
			pPropGroup->RemoveSubItem(pChildProp);
		}

		CString strType(pProp->GetValue());
		if (strType.CompareNoCase(_T("Combo")) == 0)
		{
			CMFCPropertyGridProperty* pNewProp = new CMFCPropertyGridProperty(_T("VALUE"), (COleVariant)_T(""));
			pPropGroup->AddSubItem(pNewProp);

			pNewProp = new CMFCPropertyGridProperty(_T("ITEMS"), PROP_DATA_ITEMS, TRUE);
			pPropGroup->AddSubItem(pNewProp);
		}
		else if (strType.CompareNoCase(_T("Number")) == 0)
		{ 
			CMFCPropertyGridProperty* pNewProp = new CMFCPropertyGridProperty(_T("VALUE"), (_variant_t)0, _T(""));
			pPropGroup->AddSubItem(pNewProp);

			pNewProp = new CMFCPropertyGridProperty(_T("RANGE MIN"), (_variant_t)0, _T(""));
			pNewProp->EnableSpinControl(TRUE, -9999, 9999);
			pPropGroup->AddSubItem(pNewProp);
			pNewProp = new CMFCPropertyGridProperty(_T("RANGE MAX"), (_variant_t)100, _T(""));
			pNewProp->EnableSpinControl(TRUE, -9999, 9999);
			pPropGroup->AddSubItem(pNewProp);

			BOOL bBuddy = FALSE;
			pNewProp = new CMFCPropertyGridProperty(_T("BUDDY"), (_variant_t)(bBuddy == TRUE), _T(""));
			pPropGroup->AddSubItem(pNewProp);

			pNewProp = new CMFCPropertyGridProperty(_T("SHORT"), (_variant_t)_T(""), _T(""));
			pPropGroup->AddSubItem(pNewProp);

			pNewProp = new CMFCPropertyGridProperty(_T("PREVIEW"), (_variant_t)_T(""), _T(""));
			pPropGroup->AddSubItem(pNewProp);
		}
		else if (strType.CompareNoCase(_T("Text")) == 0)
		{
			CMFCPropertyGridProperty* pNewProp = new CMFCPropertyGridProperty(_T("VALUE"), (COleVariant)_T(""));
			pPropGroup->AddSubItem(pNewProp);

			pNewProp = new CMFCPropertyGridProperty(_T("SHORT"), (COleVariant)_T(""));
			pPropGroup->AddSubItem(pNewProp);

			pNewProp = new CMFCPropertyGridProperty(_T("PREVIEW"), (COleVariant)_T(""));
			pPropGroup->AddSubItem(pNewProp);
		}

		m_wndPropList.AdjustLayout();
	}
	else if (strName.CompareNoCase(_T("PREVIEW")) == 0)
	{
		((CMainFrame*)AfxGetMainWnd())->GetClassView()->RefreshPreview();
	}
	else if (strName.CompareNoCase(_T("NAME")) == 0)
	{
		((CMainFrame*)AfxGetMainWnd())->GetFileView()->RefreshPropName(pProp);
	}
	((CMainFrame*)AfxGetMainWnd())->GetFileView()->SetFileModifiedFlag(TRUE);
}
bool ITEM_MANAGER::ReadMonsterDropItemGroup(const char * c_pszFileName)
{
	CTextFileLoader loader;

	if (!loader.Load(c_pszFileName))
		return false;

	for (DWORD i = 0; i < loader.GetChildNodeCount(); ++i)
	{
		std::string stName("");

		loader.GetCurrentNodeName(&stName);

		if (strncmp (stName.c_str(), "kr_", 3) == 0)
		{
			if (LC_IsYMIR())
			{
				stName.assign(stName, 3, stName.size() - 3);
			}
			else
			{
				continue;
			}
		}

		loader.SetChildNode(i);

		int iMobVnum = 0;
		int iKillDrop = 0;
		int iLevelLimit = 0;

		std::string strType("");

		if (!loader.GetTokenString("type", &strType))
		{
			sys_err("ReadMonsterDropItemGroup : Syntax error %s : no type (kill|drop), node %s", c_pszFileName, stName.c_str());
			loader.SetParentNode();
			return false;
		}

		if (!loader.GetTokenInteger("mob", &iMobVnum))
		{
			sys_err("ReadMonsterDropItemGroup : Syntax error %s : no mob vnum, node %s", c_pszFileName, stName.c_str());
			loader.SetParentNode();
			return false;
		}

		if (strType == "kill")
		{
			if (!loader.GetTokenInteger("kill_drop", &iKillDrop))
			{
				sys_err("ReadMonsterDropItemGroup : Syntax error %s : no kill drop count, node %s", c_pszFileName, stName.c_str());
				loader.SetParentNode();
				return false;
			}
		}
		else
		{
			iKillDrop = 1;
		}

		if ( strType == "limit" )
		{
			if ( !loader.GetTokenInteger("level_limit", &iLevelLimit) )
			{
				sys_err("ReadmonsterDropItemGroup : Syntax error %s : no level_limit, node %s", c_pszFileName, stName.c_str());
				loader.SetParentNode();
				return false;
			}
		}
		else
		{
			iLevelLimit = 0;
		}

		sys_log(0,"MOB_ITEM_GROUP %s [%s] %d %d", stName.c_str(), strType.c_str(), iMobVnum, iKillDrop);

		if (iKillDrop == 0)
		{
			loader.SetParentNode();
			continue;
		}

		TTokenVector* pTok = NULL;

		if (strType == "kill")
		{
			CMobItemGroup * pkGroup = M2_NEW CMobItemGroup(iMobVnum, iKillDrop, stName);

			for (int k = 1; k < 256; ++k)
			{
				char buf[4];
				snprintf(buf, sizeof(buf), "%d", k);

				if (loader.GetTokenVector(buf, &pTok))
				{
					//sys_log(1, "               %s %s", pTok->at(0).c_str(), pTok->at(1).c_str());
					std::string& name = pTok->at(0);
					DWORD dwVnum = 0;

					if (!GetVnumByOriginalName(name.c_str(), dwVnum))
					{
						str_to_number(dwVnum, name.c_str());
						if (!ITEM_MANAGER::instance().GetTable(dwVnum))
						{
							sys_err("ReadMonsterDropItemGroup : there is no item %s : node %s : vnum %d", name.c_str(), stName.c_str(), dwVnum);
							return false;
						}
					}

					int iCount = 0;
					str_to_number(iCount, pTok->at(1).c_str());

					if (iCount<1)
					{
						sys_err("ReadMonsterDropItemGroup : there is no count for item %s : node %s : vnum %d, count %d", name.c_str(), stName.c_str(), dwVnum, iCount);
						return false;
					}

					int iPartPct = 0;
					str_to_number(iPartPct, pTok->at(2).c_str());

					if (iPartPct == 0)
					{
						sys_err("ReadMonsterDropItemGroup : there is no drop percent for item %s : node %s : vnum %d, count %d, pct %d", name.c_str(), stName.c_str(), iPartPct);
						return false;
					}

					int iRarePct = 0;
					str_to_number(iRarePct, pTok->at(3).c_str());
					iRarePct = MINMAX(0, iRarePct, 100);

					sys_log(0,"        %s count %d rare %d", name.c_str(), iCount, iRarePct);
					pkGroup->AddItem(dwVnum, iCount, iPartPct, iRarePct);
					continue;
				}

				break;
			}
			m_map_pkMobItemGroup.insert(std::map<DWORD, CMobItemGroup*>::value_type(iMobVnum, pkGroup));

		}
		else if (strType == "drop")
		{
			CDropItemGroup* pkGroup;
			bool bNew = true;
			itertype(m_map_pkDropItemGroup) it = m_map_pkDropItemGroup.find (iMobVnum);
			if (it == m_map_pkDropItemGroup.end())
			{
				pkGroup = M2_NEW CDropItemGroup(0, iMobVnum, stName);
			}
			else
			{
				bNew = false;
				CDropItemGroup* pkGroup = it->second;
			}

			for (int k = 1; k < 256; ++k)
			{
				char buf[4];
				snprintf(buf, sizeof(buf), "%d", k);

				if (loader.GetTokenVector(buf, &pTok))
				{
					std::string& name = pTok->at(0);
					DWORD dwVnum = 0;

					if (!GetVnumByOriginalName(name.c_str(), dwVnum))
					{
						str_to_number(dwVnum, name.c_str());
						if (!ITEM_MANAGER::instance().GetTable(dwVnum))
						{
							sys_err("ReadDropItemGroup : there is no item %s : node %s", name.c_str(), stName.c_str());
							M2_DELETE(pkGroup);

							return false;
						}
					}

					int iCount = 0;
					str_to_number(iCount, pTok->at(1).c_str());

					if (iCount < 1)
					{
						sys_err("ReadMonsterDropItemGroup : there is no count for item %s : node %s", name.c_str(), stName.c_str());
						M2_DELETE(pkGroup);

						return false;
					}

					float fPercent = atof(pTok->at(2).c_str());

					DWORD dwPct = (DWORD)(10000.0f * fPercent);

					sys_log(0,"        name %s pct %d count %d", name.c_str(), dwPct, iCount);
					pkGroup->AddItem(dwVnum, dwPct, iCount);

					continue;
				}

				break;
			}
			if (bNew)
				m_map_pkDropItemGroup.insert(std::map<DWORD, CDropItemGroup*>::value_type(iMobVnum, pkGroup));

		}
		else if ( strType == "limit" )
		{
			CLevelItemGroup* pkLevelItemGroup = M2_NEW CLevelItemGroup(iLevelLimit);

			for ( int k=1; k < 256; k++ )
			{
				char buf[4];
				snprintf(buf, sizeof(buf), "%d", k);

				if ( loader.GetTokenVector(buf, &pTok) )
				{
					std::string& name = pTok->at(0);
					DWORD dwItemVnum = 0;

					if (false == GetVnumByOriginalName(name.c_str(), dwItemVnum))
					{
						str_to_number(dwItemVnum, name.c_str());
						if ( !ITEM_MANAGER::instance().GetTable(dwItemVnum) )
						{
							M2_DELETE(pkLevelItemGroup);
							return false;
						}
					}

					int iCount = 0;
					str_to_number(iCount, pTok->at(1).c_str());

					if (iCount < 1)
					{
						M2_DELETE(pkLevelItemGroup);
						return false;
					}

					float fPct = atof(pTok->at(2).c_str());
					DWORD dwPct = (DWORD)(10000.0f * fPct);

					pkLevelItemGroup->AddItem(dwItemVnum, dwPct, iCount);

					continue;
				}

				break;
			}

			m_map_pkLevelItemGroup.insert(std::map<DWORD, CLevelItemGroup*>::value_type(iMobVnum, pkLevelItemGroup));
		}
		else if (strType == "thiefgloves")
		{
			CBuyerThiefGlovesItemGroup* pkGroup = M2_NEW CBuyerThiefGlovesItemGroup(0, iMobVnum, stName);

			for (int k = 1; k < 256; ++k)
			{
				char buf[4];
				snprintf(buf, sizeof(buf), "%d", k);

				if (loader.GetTokenVector(buf, &pTok))
				{
					std::string& name = pTok->at(0);
					DWORD dwVnum = 0;

					if (!GetVnumByOriginalName(name.c_str(), dwVnum))
					{
						str_to_number(dwVnum, name.c_str());
						if (!ITEM_MANAGER::instance().GetTable(dwVnum))
						{
							sys_err("ReadDropItemGroup : there is no item %s : node %s", name.c_str(), stName.c_str());
							M2_DELETE(pkGroup);

							return false;
						}
					}

					int iCount = 0;
					str_to_number(iCount, pTok->at(1).c_str());

					if (iCount < 1)
					{
						sys_err("ReadMonsterDropItemGroup : there is no count for item %s : node %s", name.c_str(), stName.c_str());
						M2_DELETE(pkGroup);

						return false;
					}

					float fPercent = atof(pTok->at(2).c_str());

					DWORD dwPct = (DWORD)(10000.0f * fPercent);

					sys_log(0,"        name %s pct %d count %d", name.c_str(), dwPct, iCount);
					pkGroup->AddItem(dwVnum, dwPct, iCount);

					continue;
				}

				break;
			}

			m_map_pkGloveItemGroup.insert(std::map<DWORD, CBuyerThiefGlovesItemGroup*>::value_type(iMobVnum, pkGroup));
		}
		else
		{
			sys_err("ReadMonsterDropItemGroup : Syntax error %s : invalid type %s (kill|drop), node %s", c_pszFileName, strType.c_str(), stName.c_str());
			loader.SetParentNode();
			return false;
		}

		loader.SetParentNode();
	}

	return true;
}
Пример #18
0
AliAnalysisTaskEmcalHFCJQA* AddTaskEmcalHFCJQA(
  const char *ntracks            = "Tracks",
  const char *nclusters          = "CaloClusters",
  const char *njets              = "Jets",
  const char *nrho               = "Rho",
  Int_t       nCentBins          = 1,
  Double_t    jetradius          = 0.4,
  Double_t    jetptcut           = 0,
  Double_t    jetareacut         = 0.6,
  const char *type               = "TPC",
  Int_t       leadhadtype        = 0,
  const char *taskname           = "AliAnalysisTaskEmcalHFCJQA",
  TString cutfile				 ="HFCJCuts.root",
  UInt_t triggerMask			 =-1,//AliVEvent::kEMC1 | AliVEvent::kEMC7 | AliVEvent::kEMC8,/*kMB kEMC7 (kEMC8) kEMCEJE kEMCEGA*/
  Bool_t isMC					 = kFALSE,
  Float_t minC					 = 0.,
  Float_t maxC					 = 7.5
)
{  
  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr)
  {
    ::Error("AddTaskEmcalHFCJQA", "No analysis manager to connect to.");
    return NULL;
  }  
  
  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler())
  {
    ::Error("AddTaskEmcalHFCJQA", "This task requires an input event handler");
    return NULL;
  }
  
  //-------------------------------------------------------
  // Init the task and do settings
  //-------------------------------------------------------

  TString name(taskname);
  if (strcmp(njets,"")) {
    name += "_";
    name += njets;
  }
  if (strcmp(nrho,"")) {
    name += "_";
    name += nrho;
  }
  if (strcmp(type,"")) {
    name += "_";
    name += type;
  }

  Printf("name: %s",name.Data());

  AliAnalysisTaskEmcalHFCJQA* jetTask = new AliAnalysisTaskEmcalHFCJQA(name);
  jetTask->SetReadMC(isMC);
  jetTask->SetDebug(-1);
  jetTask->SetFilterBit(AliAODTrack::kTrkGlobalNoDCA);
  //Defaut parameters
  
  AliParticleContainer *trackCont  = jetTask->AddParticleContainer(ntracks);
  trackCont->SetClassName("AliVTrack");
  AliClusterContainer *clusterCont = jetTask->AddClusterContainer(nclusters);

  TString strType(type);
  AliJetContainer *jetCont = jetTask->AddJetContainer(njets,strType,jetradius);
  if(jetCont) {
    jetCont->SetRhoName(nrho);
    jetCont->ConnectParticleContainer(trackCont);
    jetCont->ConnectClusterContainer(clusterCont);
    jetCont->SetZLeadingCut(0.98,0.98);
    jetCont->SetPercAreaCut(0.6);
    jetCont->SetJetPtCut(jetptcut);    
    jetCont->SetLeadingHadronType(leadhadtype);
  }

//=========================CUTS=========================
AliRDHFJetsCuts *cuts;

bool kFileExists=kFALSE;
//if(!gSystem->AccessPathName(cutfile.Data(),kFileExists)){
  
if(gSystem->AccessPathName(cutfile.Data(),kFileExists))
{
	Printf("\n==CutObject not Defined in .root File. Using Standard Cuts==\n");

// possible (!not standard!) selection for pp2012 data triggered with EMCAL
    cuts=new AliRDHFJetsCuts();
    hfTask = new AliAnalysisTaskEmcalHFCJQA("AliAnalysisTaskEmcalHFCJQA");
   
    // AliRDHFJetsCutsVertex *cuts2=new AliRDHFJetsCutsVertex("jetCuts");

    //cuts for jets
    //    cuts->SetJetRadius(0.4);
    //    cuts->SetMaxEtaJet(0.5);//0.9-R
    //    cuts->SetMinPtJet(0);
    //    cuts->SetMaxPtJet(200);
    //    cuts->ResetMaskAndEnableMBTrigger();
    //cuts->SetUseAnyTrigger();
    //cuts->SetTriggerMask(0);
    cuts->SetTriggerMask(AliVEvent::kEMC1 | AliVEvent::kEMC7 | AliVEvent::kEMC8);
    cuts->SetTriggerClass("");

    AliESDtrackCuts *esdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts","default");
    esdTrackCuts->SetRequireSigmaToVertex(kFALSE);
    esdTrackCuts->SetMinNClustersTPC(70);
    esdTrackCuts->SetMaxChi2PerClusterTPC(4);
    esdTrackCuts->SetRequireTPCRefit(kTRUE);
    esdTrackCuts->SetRequireITSRefit(kTRUE);
    esdTrackCuts->SetMinNClustersITS(2);
    esdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,AliESDtrackCuts::kAny);
    esdTrackCuts->SetMinDCAToVertexXY(0.);
    esdTrackCuts->SetEtaRange(-0.8,0.8);
    esdTrackCuts->SetPtRange(1,1.e10);

    if(minC>0&&minC<maxC)
    {
      // Pb-Pb
      cuts->SetTriggerClass("");
      cuts->ResetMaskAndEnableMBTrigger();
      cuts->EnableCentralTrigger();
      cuts->EnableSemiCentralTrigger();
      cuts->SetUseCentrality(AliRDHFCuts::kCentV0M);
      cuts->SetMinCentrality(minC);
      cuts->SetMaxCentrality(maxC);  
    }

    cuts->AddTrackCuts(esdTrackCuts);
    //cuts for vertexing
    //    ::Error("AddTaskSEHFJets","No Cut Object");
}
else
{
	TFile *f=TFile::Open(cutfile.Data());
	//cuts= (AliRDHFCutsD0toKpi*)f->Get("EventTrackCuts");
	cuts= (AliRDHFJetsCuts*)f->Get("HFCJCuts");

	cout<<"\n==========================================\n Cutfile used:\n"<<cutfile.Data()<<endl;
	//cuts->PrintAll();
	//jetTask->SetJetCuts(cuts);
}
if(triggerMask>0) cuts->SetTriggerMask(triggerMask);

jetTask->SetJetCuts(cuts);
delete cuts;
//========================================================== 
  
//-------------------------------------------------------
// Final settings, pass to manager and set the containers
//-------------------------------------------------------
  
  mgr->AddTask(jetTask);

  // Create containers for input/output
  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer()  ;
  TString contname(name);
  contname += "_histos";
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(), 
							    TList::Class(),AliAnalysisManager::kOutputContainer,
							    Form("%s", AliAnalysisManager::GetCommonFileName()));
  mgr->ConnectInput  (jetTask, 0,  cinput1 );
  mgr->ConnectOutput (jetTask, 1, coutput1 );
  
  return jetTask;
}
Пример #19
0
AliAnalysisTaskEmcalHFeJetCorrel* AddTaskEmcalHFCJ(
  const char *ntracks            = "Tracks",
  const char *nclusters          = "CaloClusters",
  const char *njets              = "Jets",
  const char *nrho               = "Rho",
  Int_t       nCentBins          = 1,
  Double_t    jetradius          = 0.4,
  Double_t    jetptcut           = 0,
  Double_t    jetareacut         = 0.6,
  const char *type               = "EMCAL",
  Int_t       leadhadtype        = 0,
  const char *taskname           = "AliAnalysisTaskEmcalHFeJetCorrel",
  TString cutfile				 ="HFCJCuts.root",
  UInt_t triggerMask			 =-1,/*AliVEvent::kEMC1 | AliVEvent::kEMC7 | AliVEvent::kEMC8, kMB kEMC7 (kEMC8) kEMCEJE kEMCEGA*/
  Bool_t isMC					 = kFALSE,
  bool TestContainer			 = kFALSE,
  bool EGA1                      = kFALSE,
  const char *MCtracks            = "",
  const char *MCclusters          = "",
  const char *MCjets              = ""
)
{  
  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr)
  {
    ::Error("AddTaskEmcalHFCJ", "No analysis manager to connect to.");
    return NULL;
  }  
  
  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler())
  {
    ::Error("AddTaskEmcalHFCJ", "This task requires an input event handler");
    return NULL;
  }
  
  //-------------------------------------------------------
  // Init the task and do settings
  //-------------------------------------------------------

  TString name(taskname);
  if (strcmp(njets,"")) {
    name += "_";
    name += njets;
  }
  if (strcmp(nrho,"")) {
    name += "_";
    name += nrho;
  }
  if (strcmp(type,"")) {
    name += "_";
    name += type;
  }

  Printf("name: %s",name.Data());

  AliAnalysisTaskEmcalHFeJetCorrel* jetTask = new AliAnalysisTaskEmcalHFeJetCorrel(name);
  jetTask->SetCentRange(0.,100.);
  jetTask->SetNCentBins(nCentBins);
  jetTask->SetReadMC(isMC);
  jetTask->SetMCParticles(MCtracks);
  jetTask->SetQA(kTRUE);//FALSE);
  jetTask->SetCheckClusterMatching(kFALSE);
  jetTask->SetDoAnalysis(kTRUE);//FALSE);
  jetTask->SetGeneralSpectra(kTRUE);//FALSE);
  jetTask->SetDetectorsTest(kTRUE);//FALSE);
  //Shingo Electron Selection
  jetTask->SetFilterBitElectron(AliAODTrack::kTrkGlobalNoDCA);

  //Defaut parameters
  jetTask->SetMinPtElectron(0.1);
  jetTask->SetEtaTracks(-0.9,0.9);
  jetTask->SetNsigmaTPCelectron(-10,3.5);
  jetTask->SetPhotonicMassCut(0.5);
  jetTask->SetMinNumberOfClusterCells(4);
  jetTask->SetMaxM20(0.9);
  jetTask->SetMaxM02(0.9);
  jetTask->SetEoverPlimits(0.0, 3.0);
  
  AliParticleContainer *trackCont  = jetTask->AddParticleContainer(ntracks);
  trackCont->SetClassName("AliVTrack");
  AliClusterContainer *clusterCont = jetTask->AddClusterContainer(nclusters);

  TString strType(type);
  AliJetContainer *jetCont = jetTask->AddJetContainer(njets,strType,jetradius);
  if(jetCont) {
    jetCont->SetRhoName(nrho);
    jetCont->ConnectParticleContainer(trackCont);
    jetCont->ConnectClusterContainer(clusterCont);
    jetCont->SetZLeadingCut(0.98,0.98);
    jetCont->SetPercAreaCut(0.6);
    jetCont->SetJetPtCut(jetptcut);    
    jetCont->SetLeadingHadronType(leadhadtype);
  }


//=========================CUTS=========================
AliRDHFJetsCuts *cuts;

bool kFileExists=kFALSE;
//if(!gSystem->AccessPathName(cutfile.Data(),kFileExists)){
  
if(gSystem->AccessPathName(cutfile.Data(),kFileExists))
{
	::Error("\n==CutObject not Defined. Verify your .root file==\n");
	return NULL;
}
	TFile *f=TFile::Open(cutfile.Data());
	//cuts= (AliRDHFCutsD0toKpi*)f->Get("EventTrackCuts");
	cuts= (AliRDHFJetsCuts*)f->Get("HFCJCuts");

	cout<<"\n==========================================\n Cutfile used:\n"<<cutfile.Data()<<endl;
	//cuts->PrintAll();
    
    if(triggerMask>0)
    {
        cuts->SetTriggerMask(triggerMask);
        if( (triggerMask == AliVEvent::kEMCEGA)&&(EGA1) )cuts->SetTriggerClass("EG1");
    }

jetTask->SetJetCuts(cuts);
delete cuts;
//========================================================== 
  
//-------------------------------------------------------
// Final settings, pass to manager and set the containers
//-------------------------------------------------------
  
  mgr->AddTask(jetTask);

  // Create containers for input/output
  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer()  ;
  TString contname(name);
  contname += "_histos";
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(), 
							    TList::Class(),AliAnalysisManager::kOutputContainer,
							    Form("%s", AliAnalysisManager::GetCommonFileName()));
  mgr->ConnectInput  (jetTask, 0,  cinput1 );
  mgr->ConnectOutput (jetTask, 1, coutput1 );
  
  return jetTask;
}
Пример #20
0
void CTemplateWizardDialog::UpdateFromHtml()
{
	CComPtr<IDispatch> pDispDocument;
	m_pBrowserApp->get_Document(&pDispDocument);
	if (!pDispDocument)
		return;

	CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDocument(pDispDocument);

	CComPtr<IHTMLElementCollection> pElements;
	pDocument->get_all(&pElements);

	CComVariant nullVariant;

	// Now get the INPUT elements.
	CComPtr<IDispatch> pDispInputElements;
	pElements->tags(CComVariant("INPUT"), &pDispInputElements);
	if (pDispInputElements)
	{
		CComQIPtr<IHTMLElementCollection, &IID_IHTMLElementCollection> pInputElements(pDispInputElements);
		if (pInputElements)
		{
			long count;
			pInputElements->get_length(&count);

			for (int i = 0; i < count; i++)
			{
				// Get the element, if it exists.
				CComPtr<IDispatch> pDispElement;
				pInputElements->item(CComVariant(i), nullVariant, &pDispElement);
				if (!pDispElement)
					continue;

				CComQIPtr<IHTMLElement, &IID_IHTMLElement> pElement(pDispElement);
				if (!pElement)
					continue;		//??

				CComBSTR bstrID;
				pElement->get_id(&bstrID);

				CComQIPtr<IHTMLInputElement, &IID_IHTMLInputElement> pInputElement(pDispElement);
				if (!pInputElement)
					continue;		//??

				// Get the type.
				CComBSTR bstrType;
				pInputElement->get_type(&bstrType);
				CString strType(bstrType);

				CString id(bstrID);
				if (strType == "text"  ||  strType == "file")
				{
					CComBSTR bstrValue;
					pInputElement->get_value(&bstrValue);
					CString value(bstrValue);
					value = g_wwhizTemplateManager->ParseCode(value, NULL, &m_code);

					m_params[id] = value;
				}
				else if (strType == "checkbox")
				{
					short variant;
					pInputElement->get_checked(&variant);
					if (variant == VARIANT_FALSE)
						m_params[id] = "0";
					else
						m_params[id] = "1";
				}
				else if (strType == "radio")
				{
					short variant;
					pInputElement->get_checked(&variant);
					if (variant == VARIANT_FALSE)
						m_params[id] = "0";
					else
						m_params[id] = "1";
				}
			}
		}
	}

	// Now get the SELECT elements.
	CComPtr<IDispatch> pDispSelectElements;
	pElements->tags(CComVariant("SELECT"), &pDispSelectElements);
	if (pDispSelectElements)
	{
		CComQIPtr<IHTMLElementCollection, &IID_IHTMLElementCollection> pSelectElements(pDispSelectElements);
		if (pSelectElements)
		{
			long count;
			pSelectElements->get_length(&count);

			for (int i = 0; i < count; i++)
			{
				// Get the element, if it exists.
				CComPtr<IDispatch> pDispElement;
				pSelectElements->item(CComVariant(i), nullVariant, &pDispElement);
				if (!pDispElement)
					continue;

				CComQIPtr<IHTMLElement, &IID_IHTMLElement> pElement(pDispElement);
				if (!pElement)
					continue;		//??

				CComBSTR bstrID;
				pElement->get_id(&bstrID);
				CString id(bstrID);
				if (id.IsEmpty())
					continue;

				CComQIPtr<IHTMLSelectElement, &IID_IHTMLSelectElement> pSelectElement(pElement);
				if (!pSelectElement)
					continue;		//??

				// Get the type.
				CComBSTR bstrType;
				pSelectElement->get_type(&bstrType);
				CString strType(bstrType);
				
				// Get the current selection index.
				long curSel;
				pSelectElement->get_selectedIndex(&curSel);

				// Get the item at the index.
				CComPtr<IDispatch> pDispOptionElement;
				pSelectElement->item(CComVariant(curSel), nullVariant, &pDispOptionElement);
				if (pDispOptionElement)
				{
					CComQIPtr<IHTMLOptionElement, &IID_IHTMLOptionElement> pOptionElement(pDispOptionElement);

					CComBSTR bstrItem;
					pOptionElement->get_text(&bstrItem);
					m_params[id] = bstrItem;
				}
			}
		}
	}
}
Пример #21
0
void HDFAtom<std::string>::Write(std::string value) {
  //	H5::StrType strType(0, value.size());
	H5::StrType strType(0, H5T_VARIABLE);
	attribute.write(strType, std::string(value.c_str()));
}
Пример #22
0
void CTemplateWizardDialog::DocumentComplete(LPDISPATCH pDisp, VARIANT* URL)
{
	UNUSED_ALWAYS(pDisp);
//	ASSERT(V_VT(URL) == VT_BSTR);

	CString str(V_BSTR(URL));

	// Load in the new file...
    HRESULT       hr;
    LPUNKNOWN     pUnkContainedBrowser = NULL;
    LPUNKNOWN     pUnkDispParam = NULL;
    IStream       *pStream = NULL;
    HGLOBAL       hHTMLText;
	CComPtr<IDispatch> pDispDocument;
//	HWND shellWnd;
//	HWND ieWnd;

    // Test for valid pointers.
    if (!m_pBrowserApp || !pDisp)
        goto CleanUp;

    // To test object equality, use COM identity rules: query both 
    // pointers for IUnknown and compare them.
    hr = m_pBrowserApp->QueryInterface(IID_IUnknown, 
        (void**)&pUnkContainedBrowser);
    if (hr)
        goto CleanUp;

    // Query the passed-in IDispatch for IUnknown.
    hr = pDisp->QueryInterface(IID_IUnknown, 
        (void**)&pUnkDispParam);
    if (hr)
        goto CleanUp;

    // If they're unequal, the event is for a subframe and we're not
    // interested.
    if (pUnkContainedBrowser != pUnkDispParam)
        goto CleanUp;

    // As a further check, make sure the URL is "about:blank".
    if (str == "about:blank")
	{
		// The string is about:blank.  This means load the correct page.
		LONG len = (LONG)m_htmlFile.GetLength();
		BYTE* data = m_htmlFile.Detach();
		hHTMLText = GlobalAlloc(GPTR, len + 1);
		if (!hHTMLText)
			goto CleanUp;

		memcpy((CHAR *)hHTMLText, (char*)data, len);
		*(char*)((char*)hHTMLText + len) = 0;

		free(data);

		hr = ::CreateStreamOnHGlobal(hHTMLText, TRUE, &pStream);
		if (hr)
			goto CleanUp;

		// Call the helper function to load the WebOC from the stream.
		//
		hr = LoadWebOCFromStream(m_pBrowserApp, pStream);

		goto CleanUp;
	}
	
/*	// Set the focus to the right window.
	shellWnd = ::FindWindowEx(m_wndBrowser.GetSafeHwnd(), NULL, "Shell DocObject View", NULL);
	ieWnd = ::FindWindowEx(shellWnd, NULL, "Internet Explorer_Server", NULL);
	::SetFocus(ieWnd);
*/
	// Set to the first available input field.
	m_pBrowserApp->get_Document(&pDispDocument);

	if (pDispDocument)
	{
		CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDocument(pDispDocument);

		// Get all of the HTML elements.
		CComPtr<IHTMLElementCollection> pElements;
		pDocument->get_all(&pElements);

		CComVariant nullVariant;
		CComPtr<IDispatch> pDispFirstElement;

		// Now get the INPUT elements.
		CComPtr<IDispatch> pDispInputElements;
		pElements->tags(CComVariant("INPUT"), &pDispInputElements);
		if (pDispInputElements)
		{
			CComQIPtr<IHTMLElementCollection, &IID_IHTMLElementCollection> pInputElements(pDispInputElements);
			if (pInputElements)
			{
				long count;
				pInputElements->get_length(&count);

				for (int i = 0; i < count; i++)
				{
					// Get the element, if it exists.
					CComPtr<IDispatch> pDispElement;
					pInputElements->item(CComVariant(i), nullVariant, &pDispElement);
					if (!pDispElement)
						continue;

					CComQIPtr<IHTMLElement, &IID_IHTMLElement> pElement(pDispElement);
					if (!pElement)
						continue;		//??

					CComBSTR bstrID;
					pElement->get_id(&bstrID);

					CComQIPtr<IHTMLInputElement, &IID_IHTMLInputElement> pInputElement(pElement);
					if (!pInputElement)
						continue;		//??

					// Get the type.
					CComBSTR bstrType;
					pInputElement->get_type(&bstrType);
					CString strType(bstrType);
					
					CString id(bstrID);
					CString value;
					if (!m_params.Lookup(id, value))
					{
						value = m_code.GetEntry(id);
					}

					if (strType == "text")
					{
						value = g_wwhizTemplateManager->ParseCode(value, NULL, &m_code);
						pInputElement->put_value(CComBSTR(value));

						if (!pDispFirstElement)
							pDispFirstElement = pDispElement;
					}
					else if (strType == "checkbox")
					{
						pInputElement->put_checked(value == "1" ? VARIANT_TRUE : VARIANT_FALSE);
					}
					else if (strType == "radio")
					{
						pInputElement->put_checked(value == "1" ? VARIANT_TRUE : VARIANT_FALSE);
					}
					else if (strType == "file")
					{
						CComQIPtr<IHTMLInputFileElement,
							&IID_IHTMLInputFileElement> pInputFileElement(pElement);
						if (!pInputFileElement)
							continue;		//??

						value = g_wwhizTemplateManager->ParseCode(value, NULL, &m_code);
						pInputFileElement->put_value(CComBSTR(value));

						if (!pDispFirstElement)
							pDispFirstElement = pDispElement;
					}
				}
			}
		}

		// Now get the SELECT elements.
		CComPtr<IDispatch> pDispSelectElements;
		pElements->tags(CComVariant("SELECT"), &pDispSelectElements);
		if (pDispSelectElements)
		{
			CComQIPtr<IHTMLElementCollection, &IID_IHTMLElementCollection> pSelectElements(pDispSelectElements);
			if (pSelectElements)
			{
				long count;
				pSelectElements->get_length(&count);

				for (int i = 0; i < count; i++)
				{
					// Get the element, if it exists.
					CComPtr<IDispatch> pDispElement;
					pSelectElements->item(CComVariant(i), nullVariant, &pDispElement);
					if (!pDispElement)
						continue;

					CComQIPtr<IHTMLElement, &IID_IHTMLElement> pElement(pDispElement);
					if (!pElement)
						continue;		//??

					CComBSTR bstrID;
					pElement->get_id(&bstrID);

					CComQIPtr<IHTMLSelectElement, &IID_IHTMLSelectElement> pSelectElement(pElement);
					if (!pSelectElement)
						continue;		//??

					// Get the type.
					CComBSTR bstrType;
					pSelectElement->get_type(&bstrType);
					CString strType(bstrType);
					
					CString id(bstrID);
					CString value;
					if (!m_params.Lookup(id, value))
					{
						value = m_code.GetEntry(id);
					}

					// This is the only way I can figure out to do this!

					// Match the name.
					long optionCount;
					pSelectElement->get_length(&optionCount);
					int j;
					for (j = 0; j < optionCount; j++)
					{
						// Get the item at the index.
						CComPtr<IDispatch> pDispOptionElement;
						pSelectElement->item(CComVariant(j), nullVariant, &pDispOptionElement);
						if (pDispOptionElement)
						{
							CComQIPtr<IHTMLOptionElement, &IID_IHTMLOptionElement> pOptionElement(pDispOptionElement);

							CComBSTR bstrItem;
							pOptionElement->get_text(&bstrItem);
							CString strItem(bstrItem);
							if (value == strItem)
							{
								pSelectElement->put_selectedIndex(j);
								break;
							}
						}
					}

					if (j == optionCount)
					{
						pSelectElement->put_selectedIndex(0);
					}
				}
			}
		}

		if (pDispFirstElement)
		{
			CComQIPtr<IHTMLControlElement, &IID_IHTMLControlElement> pHtmlElement(pDispFirstElement);
			pHtmlElement->focus();
			CComQIPtr<IHTMLInputTextElement, &IID_IHTMLInputTextElement> pElement(pDispFirstElement);
			if (pElement)
			{
				pElement->select();
			}
		}
	}

CleanUp:
    if (pStream)
        pStream->Release();
    if (pUnkContainedBrowser)
        pUnkContainedBrowser->Release();
    if (pUnkDispParam)
        pUnkDispParam->Release();

	if (!m_asciiFilename.IsEmpty())
	{
		_unlink(m_asciiFilename);
		m_asciiFilename.Empty();
	}
}
Пример #23
0
AliAnalysisTaskSoftDrop* AddTaskSoftDrop(
  const char *ntracks            = "Tracks",
  const char *nclusters          = "CaloClusters",
  const char *njets              = "Jets",
  const char *nrho               = "Rho",
  Int_t       nCentBins          = 1,
  Double_t    jetradius          = 0.2,
  Double_t    jetptcut           = 1,
  Double_t    jetareacut         = 0.6,
  const char *type               = "EMCAL",
  Int_t       leadhadtype        = 0,
  const char *taskname           = "AliAnalysisTaskSoftDrop"
)
{
  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr)
  {
    ::Error("AddTaskEmcalJetSample", "No analysis manager to connect to.");
    return NULL;
  }

  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler())
  {
    ::Error("AddTaskEmcalJetSample", "This task requires an input event handler");
    return NULL;
  }

  //-------------------------------------------------------
  // Init the task and do settings
  //-------------------------------------------------------

  TString trackName(ntracks);
  TString clusName(nclusters);

  TString name(taskname);
  if (strcmp(njets,"")) {
    name += "_";
    name += njets;
  }
  if (strcmp(nrho,"")) {
    name += "_";
    name += nrho;
  }
  if (strcmp(type,"")) {
    name += "_";
    name += type;
  }

  Printf("name: %s",name.Data());

  AliAnalysisTaskSoftDrop* jetTask = new AliAnalysisTaskSoftDrop(name);
  //jetTask->SetCentRange(0.,100.);
  //jetTask->SetNCentBins(nCentBins);

  AliParticleContainer* partCont = 0;
  if (trackName == "mcparticles") {
    partCont = jetTask->AddMCParticleContainer(ntracks);
  }
  else if (trackName == "tracks" || trackName == "Tracks") {
    partCont = jetTask->AddTrackContainer(ntracks);
  }
  else if (!trackName.IsNull()) {
    partCont = new AliParticleContainer(trackName);
  }

  AliClusterContainer *clusterCont = jetTask->AddClusterContainer(nclusters);

  TString strType(type);
  AliJetContainer *jetCont = jetTask->AddJetContainer(njets,strType,jetradius);
  if(jetCont) {
    jetCont->SetRhoName(nrho);
    jetCont->ConnectParticleContainer(partCont);
    jetCont->ConnectClusterContainer(clusterCont);
    //jetCont->SetZLeadingCut(0.98,0.98);
    jetCont->SetPercAreaCut(jetareacut);
    jetCont->SetJetPtCut(jetptcut);
    jetCont->SetLeadingHadronType(leadhadtype);
  }

  //-------------------------------------------------------
  // Final settings, pass to manager and set the containers
  //-------------------------------------------------------

  mgr->AddTask(jetTask);

  // Create containers for input/output
  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer()  ;
  TString contname(name);
  contname += "_histos";
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(),
							    TList::Class(),AliAnalysisManager::kOutputContainer,
							    Form("%s", AliAnalysisManager::GetCommonFileName()));
  mgr->ConnectInput  (jetTask, 0,  cinput1 );
  mgr->ConnectOutput (jetTask, 1, coutput1 );

  return jetTask;
}
Пример #24
0
 void Create(H5::H5Location &object, const std::string & name, const std::string & value) {
     H5::StrType strType(0, value.size());
     attribute = object.createAttribute(name.c_str(), strType, H5::DataSpace(0,NULL));
     isInitialized = true;
     attribute.write(strType, value.c_str());
 }
Пример #25
0
EmcalHJetMassAnalysis::AliAnalysisTaskEmcalHJetMass* AddTaskEmcalHJetMass(const char * njetsBase,
						   const Double_t R,
						   const char * nrhoBase,
						   const char * ntracks,
						   const char * nclusters,
						   const char * type,
						   Double_t     ptMinH         = 5.,
						   Double_t     maxDPhi        = 0.6,
						   Int_t        pSel,
						   const char * CentEst        = "V0M",
						   TString      trigClass      = "",
						   TString      kEmcalTriggers = "",
						   TString      nJetsUnsub     = "",
						   TString      tag            = "") {

  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr)
    {
      Error("AddTaskEmcalHJetMass","No analysis manager found.");
      return 0;
    }
  Bool_t ismc=kFALSE;
  ismc = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE;

  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler())
    {
      ::Error("AddTaskEmcalHJetMass", "This task requires an input event handler");
      return NULL;
    }

  TString wagonName = Form("HJetMass_%s_TC%s%s",njetsBase,trigClass.Data(),tag.Data());

  //Configure jet tagger task
  EmcalHJetMassAnalysis::AliAnalysisTaskEmcalHJetMass *task = new EmcalHJetMassAnalysis::AliAnalysisTaskEmcalHJetMass(wagonName.Data());
  task->SetNCentBins(4);
  task->SetMaxDeltaPhi(maxDPhi);
  
  AliParticleContainer *trackCont  = task->AddParticleContainer(ntracks);
  trackCont->SetParticlePtCut(ptMinH);
  AliClusterContainer *clusterCont = task->AddClusterContainer(nclusters);

  task->SetJetContainerBase(0);

  TString strType(type);
  AliJetContainer *jetContBase = task->AddJetContainer(njetsBase,strType,R);
  if(jetContBase) {
    jetContBase->SetRhoName(nrhoBase);
    jetContBase->ConnectParticleContainer(trackCont);
    jetContBase->ConnectClusterContainer(clusterCont);
    jetContBase->SetPercAreaCut(0.6);
  }
  if(!nJetsUnsub.IsNull()) {
    AliJetContainer *jetContUS = task->AddJetContainer(nJetsUnsub.Data(),strType,R);
    if(jetContUS) {
      jetContUS->SetRhoName(nrhoBase);
      jetContUS->ConnectParticleContainer(trackCont);
      jetContUS->ConnectClusterContainer(clusterCont);
      jetContUS->SetPercAreaCut(0.6);
    }
  }

  task->SetCaloTriggerPatchInfoName(kEmcalTriggers.Data());
  task->SetCentralityEstimator(CentEst);
  task->SelectCollisionCandidates(pSel);
  task->SetUseAliAnaUtils(kFALSE);

  mgr->AddTask(task);

  //Connnect input
  mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer() );

  //Connect output
  TString contName(wagonName);
  TString outputfile = Form("%s",AliAnalysisManager::GetCommonFileName());
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contName.Data(), TList::Class(),AliAnalysisManager::kOutputContainer,outputfile);
  mgr->ConnectOutput(task,1,coutput1);

  return task;  

}
Пример #26
0
AliAnalysisTaskBJetTC* AddTaskBJetTC(
		const char *ntracks             = "PicoTracks",
		const char *nclusters           = "",
		const char *njets               = "Jets",
		const char *nrho                = "",
		Double_t jetradius 		= 0.4,
		Bool_t isMC 			= kFALSE,
		const char * type 		= "TPC",
		const char *taskname           	= "AliAnalysisTaskBJetTC",
		const char *njetsMC             = "Jets",
		const char *nrhoMC              = "RhoMC",
		Bool_t V0PhotonRejection 	= kFALSE,
		Bool_t DoPtRelAna		= kFALSE,
		Bool_t DoJetProb 		= kFALSE,
		TString pathToResolFunc		= "",
  		Int_t       ptHardBin           = -999,
		const char* suffix 		= "")
{


	// Get the pointer to the existing analysis manager via the static access method.
	//==============================================================================
	AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
	if (!mgr)
	{
		::Error("AddTaskEmcalJetSample", "No analysis manager to connect to.");
		return NULL;
	}


	// Check the analysis type using the event handlers connected to the analysis manager.
	//==============================================================================
	if (!mgr->GetInputEventHandler())
	{
		::Error("AddTaskEmcalJetSample", "This task requires an input event handler");
		return NULL;
	}



  	if(V0PhotonRejection){

		  //=========  Set Cutnumber for V0Reader ================================
		  TString cutnumberAODBranch = "8000000060084000001500000";  // cutnumber for AOD branch
		  //TString cutnumberAODBranch = "00000003_06000008400100001000000000";  // cutnumber for AOD branch
		  TString cutnumberPhoton = "10000029200000003220400000";
		  TString cutnumberEvent = "80010103";

		  Bool_t doEtaShift = kFALSE;
		  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
		  //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
		  TString V0ReaderName = Form("V0ReaderV1_%s_%s",cutnumberEvent.Data(),cutnumberPhoton.Data());
		  if( !(AliV0ReaderV1*)mgr->GetTask(V0ReaderName.Data()) ){
			AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1(V0ReaderName.Data());
		    fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
		    fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
		    fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
		    if (!mgr) {
		      Error("AddTask_V0ReaderV1", "No analysis manager found.");
		      return;
		    }

		    AliConvEventCuts *fEventCuts=NULL;
		    if(cutnumberEvent!=""){
		      fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
		      fEventCuts->SetPreSelectionCutFlag(kTRUE);
		      fEventCuts->SetPeriodEnumExplicit(AliConvEventCuts::kLHC16q);
		      fEventCuts->SetV0ReaderName(V0ReaderName);
		      fEventCuts->SetLightOutput(kTRUE);
		      if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
			fEventCuts->DoEtaShift(doEtaShift);
			fV0ReaderV1->SetEventCuts(fEventCuts);
			fEventCuts->SetFillCutHistograms("",kTRUE);
		      }
		    }

		    // Set AnalysisCut Number
		    AliConversionPhotonCuts *fCuts=NULL;
		    if(cutnumberPhoton!=""){
		      fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
		      fCuts->SetPreSelectionCutFlag(kTRUE);
		      fCuts->SetIsHeavyIon(kTRUE);
		      fCuts->SetV0ReaderName(V0ReaderName);
		      fCuts->SetLightOutput(kTRUE);
		      fCuts->SetProcessAODCheck(kTRUE);
		      if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
			cout<<" Photon conversion is working \n";
			fV0ReaderV1->SetConversionCuts(fCuts);
			fCuts->SetFillCutHistograms("",kTRUE);
		      }
		    }
		    if( (mgr->GetInputEventHandler())->IsA()==AliAODInputHandler::Class()){
		    // AOD mode
		      cout << "AOD handler: adding " << cutnumberAODBranch.Data() << " as conversion branch" << endl;
		      fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
		    }
		    fV0ReaderV1->Init();

		    AliLog::SetGlobalLogLevel(AliLog::kInfo);

		    //connect input V0Reader
		    mgr->AddTask(fV0ReaderV1);
		    mgr->ConnectInput(fV0ReaderV1,0,cinput);

		  }
   	}


	TString name(taskname);

	TString combinedName;
	combinedName.Form("%s%s", name.Data(),suffix);

	AliAnalysisTaskBJetTC* jetTask = new AliAnalysisTaskBJetTC(combinedName);

  	jetTask->SetPtHardBin(ptHardBin);

  	jetTask->UseGammaV0Rejection(V0PhotonRejection);
	
	jetTask->DoJetProbabilityAnalysis(DoJetProb);

	jetTask->DoPtRelAnalysis(DoPtRelAna);
			
	AliTrackContainer *trackCont  = jetTask->AddTrackContainer(ntracks);
	trackCont->SetTrackFilterType(AliEmcalTrackSelection::kCustomTrackFilter);
	trackCont->SetAODFilterBits((1<<4)|(1<<9));

	AliClusterContainer *clusterCont = jetTask->AddClusterContainer(nclusters);

	TString strType(type);

	AliJetContainer *jetCont = jetTask->AddJetContainer(njets,strType,jetradius);

	if(jetCont) {
		jetCont->SetRhoName(nrho);

		jetCont->ConnectParticleContainer(trackCont);

		jetCont->ConnectClusterContainer(clusterCont);

		jetCont->SetJetEtaLimits(-0.5,0.5);

		jetCont->SetJetPtCut(0.0);

		jetCont->SetMaxTrackPt(1000);

		jetCont->SetPercAreaCut(0.6);
	}

	if(isMC)
	{
		AliJetContainer *jetContMC = jetTask->AddJetContainer(njetsMC,strType,jetradius);

		if(jetContMC) {

			jetContMC->SetRhoName(nrhoMC);

			jetContMC->SetIsParticleLevel(kTRUE);

			jetContMC->SetJetEtaLimits(-0.5,0.5);

			jetContMC->SetJetPtCut(0.0);

			jetContMC->SetMaxTrackPt(1000);

			jetContMC->SetPercAreaCut(0.6);
		}
	}
	//-------------------------------------------------------
	//  Configure analysis task
	//-------------------------------------------------------

	jetTask->SetIsPythia(isMC);

        if(V0PhotonRejection) jetTask->SetV0ReaderName(V0ReaderName);



	if(DoJetProb && !pathToResolFunc.IsNull()){
		TFile* file = TFile::Open(pathToResolFunc.Data());
		for(int i=0; i<7; i++){
			jetTask->SetResFunction((TF1*)file->Get(Form("QualityClass%i",i)), i);
		}
	}

	//-------------------------------------------------------
	// Final settings, pass to manager and set the containers
	//-------------------------------------------------------

	mgr->AddTask(jetTask);


	// Create containers for input/output
	AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer()  ;

	TString contname(combinedName);
	contname += "_histos";
	AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(),
			TList::Class(),AliAnalysisManager::kOutputContainer,
			Form("%s", AliAnalysisManager::GetCommonFileName()));

	mgr->ConnectInput  (jetTask, 0,  cinput1 );

	mgr->ConnectOutput (jetTask, 1, coutput1 );

	return jetTask;
}
Пример #27
0
AliAnalysisTaskJetMassResponseDet* AddTaskJetMassResponseDet(const char * njetsPart,
							     const char * njetsDet,
							     const Double_t R,
							     const char *type,					     
							     Int_t       pSel,
							     TString     kEmcalTriggers = "",
							     TString     tag            = "") {

  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr)
    {
      Error("AddTaskEmcalJetMass","No analysis manager found.");
      return 0;
    }
  Bool_t ismc=kFALSE;
  ismc = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE;

  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler())
    {
      ::Error("AddTaskEmcalJetMass", "This task requires an input event handler");
      return NULL;
    }

  TString wagonName = Form("JetMassResponseDet_%s%s",njetsDet,tag.Data());
  TString strType(type);

  //Configure jet mass detector response task
  AliAnalysisTaskJetMassResponseDet *task = new AliAnalysisTaskJetMassResponseDet(wagonName.Data());

  task->SetNCentBins(1);
  //task->SetVzRange(-10.,10.);

  task->SetJetContainerPart(0);
  task->SetJetContainerDet(1);

  AliJetContainer *jetContPart = task->AddJetContainer(njetsPart,strType,R);
  if(jetContPart) {
    // jetContPart->SetPercAreaCut(0.6);
  }

  AliJetContainer *jetContDet = task->AddJetContainer(njetsDet,strType,R);
  if(jetContDet) {
    jetContDet->SetPercAreaCut(0.6);
  }

  task->SetCaloTriggerPatchInfoName(kEmcalTriggers.Data());
  task->SelectCollisionCandidates(pSel);
  task->SetUseAliAnaUtils(kFALSE);

  mgr->AddTask(task);

  //Connnect input
  mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer() );

  //Connect output
  TString contName(wagonName);
  TString outputfile = Form("%s",AliAnalysisManager::GetCommonFileName());
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contName.Data(), TList::Class(),AliAnalysisManager::kOutputContainer,outputfile);
  mgr->ConnectOutput(task,1,coutput1);

  return task;  
}
Пример #28
0
jobject MakeObjectInstance(JNIEnv *env,const char *pzObjectType,  DynamicXMLObject *pDO,DynamicXMLObject *pDXOOOwner)
{
	if (env->ExceptionOccurred()) 
	{
		env->ExceptionClear();
	}

	GString strClass(pzObjectType);
	int nStartAt = strClass.ReverseFind("/");
	if(nStartAt == -1)
		nStartAt = 0;
	else
		nStartAt++; // first byte past slash

	logit("MOI Make Object Instance1\n");
	logit(strClass);
	logit("\n");


//								"gapp/MyOrder");
	jclass clazzA = env->FindClass(strClass);

	// Here we are passing in a "variable" as a class name, these are the kids of errors that a bad value will produce:
	//
	//------------------------------------------------------ V ---------------
	//													  gapp/MyOrder    	works.
	//java.lang.ClassNotFoundException: Didn't find class "MyOrder" on
					  // JNI WARNING: illegal class name 'LMyOrder;' (FindClass)
					  // JNI WARNING: illegal class name 'Lgapp/MyOrder;' (FindClass)
								    //illegal class name 'MyOrder;' (FindClass)

	jobject objReturnValue = 0;
	GString strType("Ljava/lang/String;");
	// if this class type exposes a 'ctor that takes a single XMLObject we are using containment.
	jmethodID midctor = env->GetMethodID(clazzA, "<init>", "(LXMLObject;)V");
	if (env->ExceptionOccurred()) 
	{
		env->ExceptionClear();
	}
	if (midctor)
	{
		// create a new java XMLObject instance
		jclass clazzX = env->FindClass("XMLObject");
	    jmethodID midX = env->GetMethodID(clazzX, "<init>", "(Ljava/lang/String;)V");
		jstring	tagX = env->NewStringUTF(pDO->GetObjectTag());
		jobject objX = env->NewObject(clazzA, midX, tagX );

		// assign the object handle into the instance just created.
		jclass clazz = env->GetObjectClass(objX);
		jfieldID fid = env->GetFieldID(clazz, "oH", "I");
		env->SetIntField(objX, fid, CastDXMLO(pDO));

		// create a new instance of some user defined java class that is 
		// not extending XMLObject.  Pass the XMLObject to the 'ctor.
		objReturnValue = env->NewObject(clazzA, midctor, objX );
	}
	else
	{
		// create an instance of a java object derived from the java XMLObject
		objReturnValue = env->AllocObject(clazzA);

		// assign the base class object handle directly.
		jclass clazz = env->GetObjectClass(objReturnValue);

		// any object that extends XMLObject will have the oH (Object Handle)
		// If the Object created is a String the fid will be 0.
		jfieldID fid = env->GetFieldID(clazz, "oH", "I");
		if (env->ExceptionOccurred()) 
		{
			env->ExceptionClear();
		}
		if (fid)
		{
			env->SetIntField(objReturnValue, fid, CastDXMLO(pDO));

			// create the jobject to DXO index
			union CAST_THIS_TYPE_SAFE_COMPILERS
			{
				jobject   mbrObj;
				void *    mbrVoid;
			}Member;  

			Member.mbrObj = env->NewGlobalRef(objReturnValue);
			pDXOOOwner->addSubUserLanguageObject(Member.mbrVoid);
			// printf("===<Factory>NewGlobRef[%d]\n",Member.mbrObj);
			pDO->setUserLanguageObject(Member.mbrVoid);
			cacheManager.addAlternate( pDO );
		}
		else if (strType.CompareNoCase(pzObjectType) != 0)
		{
		  GString Err;
		  Err.Format("Object type [%s] must either be derived from XMLObject\n"
		  "or supply a constructor %s(XMLObject o)",pzObjectType,pzObjectType);
		}
	}
	pDO->SetObjectType(pzObjectType);
	return objReturnValue;
}