EXPORT_C void CMTPTypeObjectPropListElement::SetUint16L(TInt aElementId, TUint16 aData) { switch(aElementId) { case EPropertyCode: { iPropertyCode = aData; // Copy PropertyCode to page buffer TUint pageIndex = iPageIndex; TUint bufIndex = iBufIndex; iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint32), ETrue); iPropList->MemoryCopyL(pageIndex, bufIndex, &aData, sizeof(TUint16)); } break; case EDatatype: SetDataType(aData); break; case EValue: SetDataType(EMTPTypeUINT16); SetValueL(&aData, sizeof(TUint16)); break; default: User::Leave(KErrArgument); } }
void checkAggregationAvgGeneric() { const GenericType &type = GenericType::Instance(true); initializeHandle(type); EXPECT_TRUE(aggregation_handle_avg_->finalize(*aggregation_handle_avg_state_).isNull()); typename GenericType::cpptype val; typename GenericType::cpptype sum; SetDataType(0, &sum); iterateHandle(aggregation_handle_avg_state_.get(), type.makeNullValue()); for (int i = 0; i < kNumSamples; ++i) { if (type.getTypeID() == kInt || type.getTypeID() == kLong) { SetDataType(i - 10, &val); } else { SetDataType(static_cast<float>(i - 10)/10, &val); } iterateHandle(aggregation_handle_avg_state_.get(), type.makeValue(&val)); sum += val; } iterateHandle(aggregation_handle_avg_state_.get(), type.makeNullValue()); CheckAvgValue<typename OutputType::cpptype>(static_cast<typename OutputType::cpptype>(sum) / kNumSamples, *aggregation_handle_avg_, *aggregation_handle_avg_state_); // Test mergeStates(). std::unique_ptr<AggregationState> merge_state( aggregation_handle_avg_->createInitialState()); aggregation_handle_avg_->mergeStates(*merge_state, aggregation_handle_avg_state_.get()); iterateHandle(merge_state.get(), type.makeNullValue()); for (int i = 0; i < kNumSamples; ++i) { if (type.getTypeID() == kInt || type.getTypeID() == kLong) { SetDataType(i - 10, &val); } else { SetDataType(static_cast<float>(i - 10)/10, &val); } iterateHandle(merge_state.get(), type.makeValue(&val)); sum += val; } aggregation_handle_avg_->mergeStates(*merge_state, aggregation_handle_avg_state_.get()); CheckAvgValue<typename OutputType::cpptype>( static_cast<typename OutputType::cpptype>(sum) / (2 * kNumSamples), *aggregation_handle_avg_, *aggregation_handle_avg_state_); }
void checkAggregationAvgGenericColumnVector() { const GenericType &type = GenericType::Instance(true); initializeHandle(type); EXPECT_TRUE(aggregation_handle_avg_->finalize(*aggregation_handle_avg_state_).isNull()); typename GenericType::cpptype sum; SetDataType(0, &sum); std::vector<std::unique_ptr<ColumnVector>> column_vectors; column_vectors.emplace_back(createColumnVectorGeneric<GenericType>(type, &sum)); std::unique_ptr<AggregationState> cv_state( aggregation_handle_avg_->accumulateColumnVectors(column_vectors)); // Test the state generated directly by accumulateColumnVectors(), and also // test after merging back. CheckAvgValue<typename OutputType::cpptype>( static_cast<typename OutputType::cpptype>(sum) / kNumSamples, *aggregation_handle_avg_, *cv_state); aggregation_handle_avg_->mergeStates(*cv_state, aggregation_handle_avg_state_.get()); CheckAvgValue<typename OutputType::cpptype>( static_cast<typename OutputType::cpptype>(sum) / kNumSamples, *aggregation_handle_avg_, *aggregation_handle_avg_state_); }
EXPORT_C void CMTPTypeObjectPropListElement::SetArrayL(TInt aElementId, const TDesC& aString) { if(EValue != aElementId) { User::Leave(KErrArgument); } TUint32 len = aString.Length() + 1; SetDataType(EMTPTypeAUINT16); iValueSize = sizeof(TUint32) + len * sizeof(TUint16); TUint pageIndex = iPageIndex; TUint bufIndex = iBufIndex; // Copy string length iPropList->IncreaseIndexL(pageIndex, bufIndex, KPropElemHeaderSize, ETrue); iPropList->MemoryCopyL(pageIndex, bufIndex, &len, sizeof(TUint32)); // Copy string data iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint32), ETrue); iPropList->MemoryCopyL(pageIndex, bufIndex, aString.Ptr(), (len - 1) * sizeof(TUint16)); // Append terminator iPropList->IncreaseIndexL(pageIndex, bufIndex, (len - 1) * sizeof(TUint16), ETrue); iPropList->MemoryCopyL(pageIndex, bufIndex, KMtpStringTerminator().Ptr(), 2); iArrayBuffered = EFalse; }
EXPORT_C void CMTPTypeObjectPropListElement::SetArrayL(TInt aElementId, const CMTPTypeArray& aArray) { if(EValue != aElementId) { User::Leave(KErrArgument); } SetDataType(aArray.Type()); TUint32 num = aArray.NumElements(); TUint pageIndex = iPageIndex; TUint bufIndex = iBufIndex; // Set number of array elements iPropList->IncreaseIndexL(pageIndex, bufIndex, KPropElemHeaderSize, ETrue); iPropList->MemoryCopyL(pageIndex, bufIndex, &num, sizeof(TUint32)); TPtrC8 srcPtr; aArray.FirstReadChunk(srcPtr); srcPtr.Set(srcPtr.Ptr() + sizeof(TUint32), srcPtr.Length() - sizeof(TUint32)); iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint32), ETrue); TUint arrayWidth = iPropList->ArrayElemWidth(iDataType); iValueSize = sizeof(TUint32) + num * arrayWidth; iPropList->MemoryCopyL(pageIndex, bufIndex, srcPtr.Ptr(), num * arrayWidth); iArrayBuffered = EFalse; }
EXPORT_C void CMTPTypeObjectPropListElement::SetStringL(TInt aElementId, const TDesC& aString) { if(EValue != aElementId || aString.Length() > KMaxStringSize) { User::Leave(KErrArgument); } TUint8 len = aString.Length() + 1; // For string which length is 255, truncate the last character to handle the file name of 255 if (aString.Length() == KMaxStringSize) { len = KMaxStringSize; } SetDataType(EMTPTypeString); iValueSize = 1 + len * sizeof(TUint16); TUint pageIndex = iPageIndex; TUint bufIndex = iBufIndex; // Copy string length iPropList->IncreaseIndexL(pageIndex, bufIndex, KPropElemHeaderSize, ETrue); iPropList->MemoryCopyL(pageIndex, bufIndex, &len, sizeof(TUint8)); // Copy string data iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint8), ETrue); iPropList->MemoryCopyL(pageIndex, bufIndex, aString.Ptr(), (len - 1) * sizeof(TUint16)); // Append terminator iPropList->IncreaseIndexL(pageIndex, bufIndex, (len - 1) * sizeof(TUint16), ETrue); iPropList->MemoryCopyL(pageIndex, bufIndex, KMtpStringTerminator().Ptr(), 2); iArrayBuffered = EFalse; }
void checkAggregationAvgGenericValueAccessor() { const GenericType &type = GenericType::Instance(true); initializeHandle(type); EXPECT_TRUE(aggregation_handle_avg_->finalize(*aggregation_handle_avg_state_).isNull()); typename GenericType::cpptype sum; SetDataType(0, &sum); std::unique_ptr<ColumnVectorsValueAccessor> accessor(new ColumnVectorsValueAccessor()); accessor->addColumn(createColumnVectorGeneric<GenericType>(type, &sum)); std::unique_ptr<AggregationState> va_state( aggregation_handle_avg_->accumulateValueAccessor(accessor.get(), std::vector<attribute_id>(1, 0))); // Test the state generated directly by accumulateValueAccessor(), and also // test after merging back. CheckAvgValue<typename OutputType::cpptype>( static_cast<typename OutputType::cpptype>(sum) / kNumSamples, *aggregation_handle_avg_, *va_state); aggregation_handle_avg_->mergeStates(*va_state, aggregation_handle_avg_state_.get()); CheckAvgValue<typename OutputType::cpptype>( static_cast<typename OutputType::cpptype>(sum) / kNumSamples, *aggregation_handle_avg_, *aggregation_handle_avg_state_); }
EXPORT_C void CMTPTypeObjectPropListElement::SetUint64L(TInt aElementId, TUint64 aData) { if(EValue != aElementId) User::Leave(KErrArgument); SetDataType(EMTPTypeUINT64); SetValueL(&aData, sizeof(TUint64)); }
H223ChannelParam& H223ChannelParam::operator =(const H223ChannelParam & that) { Clear(); lcn = that.lcn; SetLcnParams(that.pH223Lcp); SetDataType(that.pDataType); bitrate = that.bitrate; sample_interval = that.sample_interval; return *this; }
CGXStandardObisCode::CGXStandardObisCode(std::vector< std::string > obis, std::string& desc, std::string& interfaces, std::string& dataType) { m_OBIS.clear(); m_OBIS.insert(m_OBIS.end(), obis.begin(), obis.end()); SetDescription(desc); SetInterfaces(interfaces); SetDataType(dataType); }
ColumnVector *createColumnVectorGeneric(const Type &type, typename GenericType::cpptype *sum) { NativeColumnVector *column = new NativeColumnVector(type, kNumSamples + 3); typename GenericType::cpptype val; SetDataType(0, sum); column->appendTypedValue(type.makeNullValue()); for (int i = 0; i < kNumSamples; ++i) { if (type.getTypeID() == kInt || type.getTypeID() == kLong) { SetDataType(i - 10, &val); } else { SetDataType(static_cast<float>(i - 10)/10, &val); } column->appendTypedValue(type.makeValue(&val)); *sum += val; // One NULL in the middle. if (i == kNumSamples/2) { column->appendTypedValue(type.makeNullValue()); } } column->appendTypedValue(type.makeNullValue()); return column; }
EXPORT_C void CMTPTypeObjectPropListElement::SetUint128L(TInt aElementId, TUint64 high, TUint64 low) { if(EValue != aElementId) { User::Leave(KErrArgument); } SetDataType(EMTPTypeUINT128); TUint pageIndex = iPageIndex; TUint bufIndex = iBufIndex; iPropList->IncreaseIndexL(pageIndex, bufIndex, KPropElemHeaderSize, ETrue); iPropList->MemoryCopyL(pageIndex, bufIndex, &low, sizeof(TUint64)); iPropList->IncreaseIndexL(pageIndex, bufIndex, sizeof(TUint64), ETrue); iPropList->MemoryCopyL(pageIndex, bufIndex, &high, sizeof(TUint64)); iValueSize = sizeof(TUint64) * 2; }
EXPORT_C void CMTPTypeObjectPropListElement::SetUint32L(TInt aElementId, TUint32 aData) { switch(aElementId) { case EObjectHandle: iObjectHandle = aData; iPropList->MemoryCopyL(iPageIndex, iBufIndex, &aData, sizeof(TUint32)); break; case EValue: SetDataType(EMTPTypeUINT32); SetValueL(&aData, sizeof(TUint32)); break; default: User::Leave(KErrArgument); } }
void CObjectEntry::Parse_XML_Document(XML_PARSER* pXmlParser) { if(pXmlParser) { //*Attributes* //Index if(pXmlParser->Is_Having_Attribute(_T("Index"))) { SetIndex(pXmlParser->Get_Attribute_Value()); } //SubIndex if(pXmlParser->Is_Having_Attribute(_T("SubIndex"))) { SetSubIndex(pXmlParser->Get_Attribute_Value()); } //ParameterName if(pXmlParser->Is_Having_Attribute(_T("ParameterName"))) { SetParameterName(pXmlParser->Get_Attribute_Value()); } //ObjectType if(pXmlParser->Is_Having_Attribute(_T("ObjectType"))) { SetObjectType(pXmlParser->Get_Attribute_Value()); } //DataType if(pXmlParser->Is_Having_Attribute(_T("DataType"))) { SetDataType(pXmlParser->Get_Attribute_Value()); } //AccessType if(pXmlParser->Is_Having_Attribute(_T("AccessType"))) { SetAccessType(pXmlParser->Get_Attribute_Value()); } //Default if(pXmlParser->Is_Having_Attribute(_T("DefaultValue"))) { SetDefaultValue(pXmlParser->Get_Attribute_Value()); } //LowLimit if(pXmlParser->Is_Having_Attribute(_T("LowLimit"))) { SetLowLimit(pXmlParser->Get_Attribute_Value()); } //HighLimit if(pXmlParser->Is_Having_Attribute(_T("HighLimit"))) { SetHighLimit(pXmlParser->Get_Attribute_Value()); } //PDOMapping if(pXmlParser->Is_Having_Attribute(_T("PDOMapping"))) { SetPDOMapping(pXmlParser->Get_Attribute_Value()); } //ObjFlags if(pXmlParser->Is_Having_Attribute(_T("ObjFlags"))) { SetObjFlags(pXmlParser->Get_Attribute_Value()); } } }
void QueryAttributes::SetFromNode(DataNode *parentNode) { if(parentNode == 0) return; DataNode *searchNode = parentNode->GetNode("QueryAttributes"); if(searchNode == 0) return; DataNode *node; if((node = searchNode->GetNode("name")) != 0) SetName(node->AsString()); if((node = searchNode->GetNode("variables")) != 0) SetVariables(node->AsStringVector()); if((node = searchNode->GetNode("resultsMessage")) != 0) SetResultsMessage(node->AsString()); if((node = searchNode->GetNode("worldPoint")) != 0) SetWorldPoint(node->AsDoubleArray()); if((node = searchNode->GetNode("domain")) != 0) SetDomain(node->AsInt()); if((node = searchNode->GetNode("element")) != 0) SetElement(node->AsInt()); if((node = searchNode->GetNode("resultsValue")) != 0) SetResultsValue(node->AsDoubleVector()); if((node = searchNode->GetNode("elementType")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 2) SetElementType(ElementType(ival)); } else if(node->GetNodeType() == STRING_NODE) { ElementType value; if(ElementType_FromString(node->AsString(), value)) SetElementType(value); } } if((node = searchNode->GetNode("timeStep")) != 0) SetTimeStep(node->AsInt()); if((node = searchNode->GetNode("varTypes")) != 0) SetVarTypes(node->AsIntVector()); if((node = searchNode->GetNode("dataType")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 2) SetDataType(DataType(ival)); } else if(node->GetNodeType() == STRING_NODE) { DataType value; if(DataType_FromString(node->AsString(), value)) SetDataType(value); } } if((node = searchNode->GetNode("pipeIndex")) != 0) SetPipeIndex(node->AsInt()); if((node = searchNode->GetNode("useGlobalId")) != 0) SetUseGlobalId(node->AsBool()); if((node = searchNode->GetNode("xUnits")) != 0) SetXUnits(node->AsString()); if((node = searchNode->GetNode("yUnits")) != 0) SetYUnits(node->AsString()); if((node = searchNode->GetNode("darg1")) != 0) SetDarg1(node->AsDoubleVector()); if((node = searchNode->GetNode("darg2")) != 0) SetDarg2(node->AsDoubleVector()); if((node = searchNode->GetNode("floatFormat")) != 0) SetFloatFormat(node->AsString()); if((node = searchNode->GetNode("xmlResult")) != 0) SetXmlResult(node->AsString()); }
Int_t mkFRPlots(TString Tag, TString SelecReg){ std::cout<<"Making plots for the region \""<<SelecReg.Data()<<"\"."<<std::endl; std::vector<TFile*> *vec_datafiles = new std::vector<TFile*>(); std::vector<TFile*> *vec_mcfiles = new std::vector<TFile*>(); vec_datafiles ->clear(); vec_mcfiles ->clear(); SetDataType(); SetBGType(); SetDistType(); const Int_t nDistType = DistTypeNames->size(); TString filepath_prefix = "$ROOTCOREBIN/../result/"; //Background Files for(Int_t bgtype=0; bgtype<nBGType; bgtype++){ UInt_t nsamples = BGFileNames[bgtype]->size(); std::cout<<"Now processing for the background : "<<BGTypeNames[bgtype].Data()<<" ("<<nsamples<<" files)"<<std::endl; for(UInt_t bgfile=0; bgfile<nsamples; bgfile++){ TString dsid = BGFileNames[bgtype]->at(bgfile).Data(); TString includeflag = BGIncludeFlag[bgtype]->at(bgfile).Data(); TString filename = getHistFileName((filepath_prefix+"/"+Tag+"/"+dsid+"."+SelecReg+".AnaHists.root").Data()); std::cout<<"**** DatasetID : "<<dsid.Data()<<", filename=\""<<filename.Data()<<"\", IncludeFlag="<<includeflag.Data()<<std::endl; TFile *f_tmp = new TFile(filename.Data()); vec_mcfiles->push_back(f_tmp); } } //////////////////////////////////////////////////// //Defining histograms //////////////////////////////////////////////////// TH1::SetDefaultSumw2(); //No need to call this for ROOT6? Bool_t debugPlot = kTRUE; TUtil *u = new TUtil(("plots/"+Tag+"."+SelecReg+".ps").Data(),("plots/"+Tag+"."+SelecReg+".root").Data(),debugPlot); gStyle->SetPalette(1); TH1F* dist_ratio[nDistType]; for(Int_t disttype=0; disttype<nDistType; disttype++){ std::string distname = DistTypeNames ->at(disttype).Data(); std::string distbasename = DistBaseTypeNames->at(disttype).Data(); std::string distrationame = DistRatioTypeNames->at(disttype).Data(); TFile *f_tmp = vec_mcfiles->at(0); TH1F *s_tmp = (TH1F*)(f_tmp->Get(Form("all_%s;1",distname.c_str(),disttype))); TH1F *b_tmp = (TH1F*)(f_tmp->Get(Form("all_%s;1",distbasename.c_str(),disttype))); dist_ratio[disttype] = (TH1F*)(s_tmp->Clone(Form("%s",distrationame.c_str()))); dist_ratio[disttype]->Divide(s_tmp,b_tmp,1,1,"B"); dist_ratio[disttype]->GetYaxis()->SetTitle("Ratio"); u->Draw(dist_ratio[disttype],"text"); s_tmp->Reset(); s_tmp->Sumw2(); b_tmp->Reset(); b_tmp->Sumw2(); } u->cdPad(); delete vec_datafiles; delete vec_mcfiles; delete u; return 0; }
void H223ChannelParam::Clear() { lcn = CHANNEL_ID_UNKNOWN; SetLcnParams(NULL); SetDataType(NULL); }