Affine2Main<AF_iAF>& Affine2Main<AF_iAF>::operator*=(const Interval& y) { if ( (!is_actif())|| y.is_empty()|| y.is_unbounded() ) { *this = itv()*y; } else { double yVal0; int i; //std::cout << "in * "<<y<<std::endl; //saxpy(y.mid(), Affine2Main<AF_iAF>(), 0.0, y.rad(), true, false, false, true); yVal0 = y.mid(); // RES = X%(0) * res for (i=0; i<=_n;i++) { _elt._val[i] *=yVal0; } //_elt._err *= (fabs(yVal0)+Interval(y.rad())); _elt._err *= (abs(y).ub()); { bool b = (_elt._err.ub()<POS_INFINITY); for (i=0;i<=_n;i++) { b &= (abs(_elt._val[i]).ub()<POS_INFINITY); } if (!b) { *this = Interval::ALL_REALS; } } } return *this; }
Affine2Main<AF_iAF>& Affine2Main<AF_iAF>::operator*=(const Interval& y) { if ( (!is_actif())|| y.is_empty()|| y.is_unbounded() ) { *this = itv()*y; } else { *this *= Affine2Main<AF_iAF>(size(),0,y); } return *this; }
double Vector<C>::wrmsqr_norm(const double atol, const double rtol, const Vector<C>& v, const Vector<C>& w) const { assert(size() == w.size()); double result = 0; for (const_iterator it(begin()), itv (v.begin()), itw(w.begin()), itend(end()); it != itend; ++it, ++itv, ++itw) { const double help = *it / (atol + rtol * std::max(*itv, *itw)); result += help * help; } return result == 0 ? 0 : sqrt(result/size()); }
void BrowserView::update(const Q3PtrList<BrowserView> & lv) { Q3Dict<Use> all_nodes(DICT_SIZE); Q3PtrListIterator<BrowserView> itv(lv); all_nodes.setAutoDelete(TRUE); // look at the revision in each view for (; itv.current(); ++itv) { Q3DictIterator<BrowserNode> itd(itv.current()->nodes); for (; itd.current(); ++itd) { BrowserNode * bn = itd.current(); int rev = bn->get_rev(); Use * use = all_nodes.find(itd.currentKey()); if (use == 0) all_nodes.insert(itd.currentKey(), new Use(rev)); else { if (rev < use->rev_min) use->rev_min = rev; if (rev > use->rev_max) use->rev_max = rev; use->count += 1; } } } // first solve step // only the package existing in all the view are solved int nviews = lv.count(); QStringList deleted_or_new; Q3DictIterator<Use> itu(all_nodes); for (; itu.current(); ++itu) { QString who = itu.currentKey(); Use * use = itu.current(); if (use->count == nviews) { // exist in all views : solve the state if (use->rev_min == use->rev_max) { // up to date in all views for (itv.toFirst(); itv.current(); ++itv) itv.current()->nodes.find(who)->set_state(UpToDate); } else { int max = use->rev_max; for (itv.toFirst(); itv.current(); ++itv) { BrowserNode * pack = itv.current()->nodes.find(who); pack->set_state((pack->get_rev() == max) ? Young : Old); } } } else { // deleted or new, mark it unknown for this step deleted_or_new.append(who); for (itv.toFirst(); itv.current(); ++itv) { BrowserNode * pack = itv.current()->nodes.find(who); if (pack != 0) pack->set_state(Unknown); } } } all_nodes.clear(); // solve packages marked unknown // a package is deleted if its parent is never 'Young' QStringList::Iterator it; for (it = deleted_or_new.begin(); it != deleted_or_new.end(); ++it) { QString who = *it; Q3PtrList<BrowserNode> images; bool young = FALSE; // set the state in each view without looking at the others for (itv.toFirst(); itv.current(); ++itv) { BrowserNode * pack = itv.current()->nodes.find(who); if (pack != 0) { images.append(pack); if (pack->solve()) young = TRUE; } } // set the final state if young, else all already marked deleted if (young) { BrowserNode * pack; for (pack = images.first(); pack != 0; pack = images.next()) pack->set_state(Young); } } // force update on views for (itv.toFirst(); itv.current(); ++itv) itv.current()->update_it(); }
MObject createSubD(double iFrame, SubDAndColors & iNode, MObject & iParent) { Alembic::AbcGeom::ISubDSchema schema = iNode.mMesh.getSchema(); Alembic::AbcCoreAbstract::index_t index, ceilIndex; getWeightAndIndex(iFrame, schema.getTimeSampling(), schema.getNumSamples(), index, ceilIndex); Alembic::AbcGeom::ISubDSchema::Sample samp; schema.get(samp, Alembic::Abc::ISampleSelector(index)); MString name(iNode.mMesh.getName().c_str()); MFnMesh fnMesh; MFloatPointArray pointArray; Alembic::Abc::P3fArraySamplePtr emptyPtr; fillPoints(pointArray, samp.getPositions(), emptyPtr, 0.0); fillTopology(fnMesh, iParent, pointArray, samp.getFaceIndices(), samp.getFaceCounts()); fnMesh.setName(iNode.mMesh.getName().c_str()); setInitialShadingGroup(fnMesh.partialPathName()); MObject obj = fnMesh.object(); setUVs(iFrame, fnMesh, schema.getUVsParam()); setColors(iFrame, fnMesh, iNode.mC3s, iNode.mC4s, true); // add the mFn-specific attributes to fnMesh node MFnNumericAttribute numAttr; MString attrName("SubDivisionMesh"); MObject attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean, 1); numAttr.setKeyable(true); numAttr.setHidden(false); fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr); if (samp.getInterpolateBoundary() > 0) { attrName = MString("interpolateBoundary"); attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean, samp.getInterpolateBoundary()); numAttr.setKeyable(true); numAttr.setHidden(false); fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr); } if (samp.getFaceVaryingInterpolateBoundary() > 0) { attrName = MString("faceVaryingInterpolateBoundary"); attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean, samp.getFaceVaryingInterpolateBoundary()); numAttr.setKeyable(true); numAttr.setHidden(false); fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr); } if (samp.getFaceVaryingPropagateCorners() > 0) { attrName = MString("faceVaryingPropagateCorners"); attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean, samp.getFaceVaryingPropagateCorners()); numAttr.setKeyable(true); numAttr.setHidden(false); fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr); } #if MAYA_API_VERSION >= 201100 Alembic::Abc::Int32ArraySamplePtr holes = samp.getHoles(); if (holes && !holes->size() == 0) { unsigned int numHoles = (unsigned int)holes->size(); MUintArray holeData(numHoles); for (unsigned int i = 0; i < numHoles; ++i) { holeData[i] = (*holes)[i]; } if (fnMesh.setInvisibleFaces(holeData) != MS::kSuccess) { MString warn = "Failed to set holes on: "; warn += iNode.mMesh.getName().c_str(); printWarning(warn); } } #endif Alembic::Abc::FloatArraySamplePtr creases = samp.getCreaseSharpnesses(); if (creases && !creases->size() == 0) { Alembic::Abc::Int32ArraySamplePtr indices = samp.getCreaseIndices(); Alembic::Abc::Int32ArraySamplePtr lengths = samp.getCreaseLengths(); std::size_t numLengths = lengths->size(); MUintArray edgeIds; MDoubleArray creaseData; std::size_t curIndex = 0; // curIndex incremented here to move on to the next crease length for (std::size_t i = 0; i < numLengths; ++i, ++curIndex) { std::size_t len = (*lengths)[i] - 1; float creaseSharpness = (*creases)[i]; // curIndex incremented here to go between all the edges that make // up a given length for (std::size_t j = 0; j < len; ++j, ++curIndex) { Alembic::Util::int32_t vertA = (*indices)[curIndex]; Alembic::Util::int32_t vertB = (*indices)[curIndex+1]; MItMeshVertex itv(obj); int prev; itv.setIndex(vertA, prev); MIntArray edges; itv.getConnectedEdges(edges); std::size_t numEdges = edges.length(); for (unsigned int k = 0; k < numEdges; ++k) { int oppVert = -1; itv.getOppositeVertex(oppVert, edges[k]); if (oppVert == vertB) { creaseData.append(creaseSharpness); edgeIds.append(edges[k]); break; } } } } if (fnMesh.setCreaseEdges(edgeIds, creaseData) != MS::kSuccess) { MString warn = "Failed to set creases on: "; warn += iNode.mMesh.getName().c_str(); printWarning(warn); } } Alembic::Abc::FloatArraySamplePtr corners = samp.getCornerSharpnesses(); if (corners && !corners->size() == 0) { Alembic::Abc::Int32ArraySamplePtr cornerVerts = samp.getCornerIndices(); unsigned int numCorners = static_cast<unsigned int>(corners->size()); MUintArray vertIds(numCorners); MDoubleArray cornerData(numCorners); for (unsigned int i = 0; i < numCorners; ++i) { cornerData[i] = (*corners)[i]; vertIds[i] = (*cornerVerts)[i]; } if (fnMesh.setCreaseVertices(vertIds, cornerData) != MS::kSuccess) { MString warn = "Failed to set corners on: "; warn += iNode.mMesh.getName().c_str(); printWarning(warn); } } return obj; }
Affine2Main<AF_iAF>& Affine2Main<AF_iAF>::operator*=(const Affine2Main<AF_iAF>& y) { // std::cout << "in *= "<< *this <<std::endl; if (is_actif() && (y.is_actif())) { if (_n==y.size()) { Interval Sx, Sy, Sxy, Sz, xVal0,tmp; int i; Interval * xTmp; xTmp = new Interval[_n + 1]; Sx=0.0; Sy=0.0; Sxy=0.0; Sz=0.0; xVal0=0.0; tmp =0.0; for (i = 1; i <= _n; i++) { tmp =_elt._val[i]*y._elt._val[i]; Sz += tmp; Sxy += abs(tmp); Sx += abs(_elt._val[i]); Sy += abs(y._elt._val[i]); } xVal0 = _elt._val[0]; // RES = X%T(0) * res for (i = 0; i <= _n; i++) { _elt._val[i] *= y._elt._val[0]; } // Xtmp = X%T(0) * Y xTmp[0] = 0.0; for (i = 1; i <= _n; i++) { xTmp[i] = xVal0*y._elt._val[i]; } //RES = RES + Xtmp = ( Y%(0) * X ) + ( X%T(0) * Y - X%T(0)*Y%(0) ) for (i = 0; i <= _n; i++) { _elt._val[i] += xTmp[i]; } _elt._val[0] += 0.5 *Sz ; _elt._err = abs(y._elt._val[0]) * _elt._err + abs(xVal0) * y._elt._err +(_elt._err+Sx)*(y._elt._err+Sy)- 0.5 * Sxy; { bool b = (_elt._err.ub()<POS_INFINITY); for (i=0;i<=_n;i++) { b &= (abs(_elt._val[i]).ub()<POS_INFINITY); } if (!b) { *this = Interval::ALL_REALS; } } delete[] xTmp; } else { if (_n>y.size()) { *this *= y.itv(); } else { Interval tmp1 = this->itv(); *this = y; *this *= tmp1; } } } else { *this = itv()*y.itv(); } // std::cout << "out *= "<< *this<<std::endl; return *this; }
Affine2Main<AF_iAF>& Affine2Main<AF_iAF>::saxpy(double alpha, const Affine2Main<AF_iAF>& y, double beta, double ddelta, bool B1, bool B2, bool B3, bool B4) { //std::cout << "saxpy IN " << alpha << " x " << *this << " + " << y << " + "<< beta << " +error " << ddelta << " / "<< B1 << B2 << B3 << B4 << std::endl; int i; // std::cout << "in saxpy alpha=" << alpha << " beta= " << beta << " delta = " << ddelta << std::endl; if (is_actif()) { if (B1) { // multiply by a scalar alpha if (alpha==0.0) { for (i=0; i<=_n;i++) { _elt._val[i]=0; } _elt._err = 0; } else if ((fabs(alpha)) < POS_INFINITY) { for (i=0; i<=_n;i++) { _elt._val[i] *= alpha; } _elt._err *= fabs(alpha); } else { *this = itv()*alpha; } } if (B2) { // add a affine2 form y if (y.is_actif()) { if (_n==y._n) { for(i=0;i<=_n;i++) { _elt._val[i] +=y._elt._val[i]; } _elt._err += y._elt._err; } else { if (_n>y.size()) { *this += y.itv(); } else { Interval tmp1 = itv(); *this = y; *this += tmp1; } } } else { // y is not a valid affine2 form. So we add y.itv() such as an interval *this = itv()+y.itv(); } } if (B3) { //add a constant beta if ((fabs(beta))<POS_INFINITY) { _elt._val[0] += beta; } else { *this = itv()+beta; } } if (B4) { // add an error ddelta if ((fabs(ddelta))<POS_INFINITY) { _elt._err += fabs(ddelta); } else { *this = itv()+Interval(-1,1)*ddelta; } } if (_elt._val != NULL) { bool b = (_elt._err.ub()<POS_INFINITY); for (i=0;i<=_n;i++) { b &= (abs(_elt._val[i]).ub()<POS_INFINITY); } if (!b) { *this = Interval::ALL_REALS; } } } else { if (B1) { //scalar alpha *this = itv()* alpha; } if (B2) { // add y *this = itv()+ y.itv(); } if (B3) { //constant beta *this = itv()+ beta; } if (B4) { // error delta *this = itv()+Interval(-1,1)*ddelta;; } } // std::cout << " saxpy OUT x= "<< *this<<std::endl; return *this; }
double Affine2Main<AF_iAF>::mid() const{ return itv().mid(); }
//_________________________________________________________________________________ void ProcessTRDRunQA(TString qaFile, Int_t runNumber, TString dataType, Int_t year, TString period, TString pass, TString ocdbStorage) { // // Process run level QA // Create standard QA plots and trending tree in the current directory const Char_t *friendsOpt="PID DET RES"; //gStyle->SetTitleX(gStyle->GetPadLeftMargin()); gStyle->SetGridColor(kBlack); gStyle->SetGridStyle(3); gStyle->SetGridWidth(1); // Load needed libraries gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_PHYSICS/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT -I$ALICE_PHYSICS -I$ALICE_ROOT/TRD"); gSystem->Load("libSTEERBase"); gSystem->Load("libSTAT"); gSystem->Load("libANALYSIS"); gSystem->Load("libANALYSISalice"); gSystem->Load("libTender"); gSystem->Load("libTenderSupplies"); gSystem->Load("libCORRFW"); gSystem->Load("libPWGPP"); // Initialize a tree streamer TTreeSRedirector *treeStreamer = new TTreeSRedirector("trending.root","RECREATE"); (*treeStreamer)<< "trending" << "run=" << runNumber; // connect to grid if its the case if(qaFile.Contains("alien://") || ocdbStorage.Contains("alien://") || ocdbStorage[0]=='\0') TGrid::Connect("alien://"); // trending values from the ESD task ------------------------------------------------ gROOT->LoadMacro("$ALICE_PHYSICS/PWGPP/TRD/macros/makeResults.C"); Double_t esdTrendValues[100]; for(Int_t i=0;i<100;i++) esdTrendValues[i]=0.0; makeSummaryESD(qaFile.Data(), esdTrendValues, 1); const Int_t kNESDtrends = 24; const TString kESDTrendNames[kNESDtrends] = { "TPCTRDmatchEffPosAll","TPCTRDmatchEffPosAllErr", "TPCTRDmatchEffNegAll","TPCTRDmatchEffNegAllErr", "TRDTOFmatchEffPosAll","TRDTOFmatchEffPosAllErr", "TRDTOFmatchEffNegAll","TRDTOFmatchEffNegAllErr", "AvTRDtrkltsPerTrackAll", "AvTRDtrkltsPerTrackAllErr", "AvNclsPerTrackAll", "AvNclsPerTrackAllErr", "PHplateauHeight", "PHplateauHeightErr", "PHplateauSlope", "PHplateauSlopeErr", "QtotLandauMPV1GeVAll", "QtotLandauWidth1GeVAll", "PHplateauHeightAbsolute", "PHplateauHeightErrAbsolute", "PHplateauSlopeAbsolute", "PHplateauSlopeErrAbsolute", "QtotLandauMPV1GeVAllAbsolute", "QtotLandauWidth1GeVAllAbsolute" }; for(Int_t i=0; i<kNESDtrends; ++i) (*treeStreamer)<< "trending" << Form("%s=",kESDTrendNames[i].Data()) << esdTrendValues[i]; // process the QA output from the other tasks---------------------------------------- if(dataType.Contains("sim")) makeResults(friendsOpt, qaFile.Data()); else makeResults(Form("NOMC %s", friendsOpt), qaFile.Data()); TFile *trendFile = TFile::Open("TRD.Trend.root","READ"); if(!trendFile || !trendFile->IsOpen() ){ Warning("ProcessTRDRunQA.C", "Couldn't open the TRD.Trend.root file."); if(trendFile) delete trendFile; trendFile=0; } TFile *trendDB = TFile::Open("$ALICE_PHYSICS/PWGPP/TRD/data/TRD.Trend.root","READ"); if(!trendDB || !trendDB->IsOpen() ){ Error("ProcessTRDRunQA.C", "Couldn't open the Trending DB !"); if(trendDB) delete trendDB; trendDB=0; } if(trendDB){ TKey *tk(NULL); AliTRDtrendValue *tv(NULL); Int_t itv(0); const Int_t ntrends(5000); Double_t trendValues[ntrends]={0.0}; TIterator *it(trendDB->GetListOfKeys()->MakeIterator()); while((tk = (TKey*)it->Next()) && itv < ntrends){ trendValues[itv] = -999.; if(trendFile && (tv = (AliTRDtrendValue*)trendFile->Get(tk->GetName()))){ trendValues[itv] = tv->GetVal(); printf("Found trend %03d \"%s\" %f\n", itv, tk->GetName(), trendValues[itv]); } (*treeStreamer)<< "trending" << Form("%s=", tk->GetName()) << trendValues[itv]; itv++; } } // get OCDB information--------------------------------------------------------------- // switch off grid infos to reduce output and logfilesize AliLog::SetGlobalLogLevel(AliLog::kFatal); AliCDBManager* man=AliCDBManager::Instance(); if(ocdbStorage[0]=='\0') man->SetDefaultStorage(Form("alien://folder=/alice/data/%d/OCDB/", year)); else man->SetDefaultStorage(ocdbStorage.Data()); man->SetRun(runNumber); AliCDBEntry* entryExB = 0x0; AliCDBEntry* entryGainFactor = 0x0; AliCDBEntry* entryT0 = 0x0; AliCDBEntry* entryVdrift = 0x0; entryExB = man->Get("TRD/Calib/ChamberExB"); entryGainFactor = man->Get("TRD/Calib/ChamberGainFactor"); entryT0 = man->Get("TRD/Calib/ChamberT0"); entryVdrift = man->Get("TRD/Calib/ChamberVdrift"); AliTRDCalDet *caldetExB=0x0; AliTRDCalDet *caldetGainFactor=0x0; AliTRDCalDet *caldetT0=0x0; AliTRDCalDet *caldetVdrift=0x0; if(entryExB) caldetExB = (AliTRDCalDet*)entryExB->GetObject(); if(entryGainFactor) caldetGainFactor = (AliTRDCalDet*)entryGainFactor->GetObject(); if(entryT0) caldetT0 = (AliTRDCalDet*)entryT0->GetObject(); if(entryVdrift) caldetVdrift = (AliTRDCalDet*)entryVdrift->GetObject(); // get the values Double_t meanExB = (caldetExB ? caldetExB->CalcMean(1) : 0.0); Double_t rmsExB = (caldetExB ? caldetExB->CalcRMS(1) : 0.0); Double_t meanGainFactor = (caldetGainFactor ? caldetGainFactor->CalcMean(1) : 0.0); Double_t rmsGainFactor = (caldetGainFactor ? caldetGainFactor->CalcRMS(1) : 0.0); Double_t meanT0 = (caldetT0 ? caldetT0->CalcMean(1) : 0.0); Double_t rmsT0 = (caldetT0 ? caldetT0->CalcRMS(1) : 0.0); Double_t meanVdrift = (caldetVdrift ? caldetVdrift->CalcMean(1) : 0.0); Double_t rmsVdrift = (caldetVdrift ? caldetVdrift->CalcRMS(1) : 0.0); (*treeStreamer)<< "trending" << "meanExB=" << meanExB << "rmsExB=" << rmsExB << "meanGainFactor=" << meanGainFactor << "rmsGainFactor=" << rmsGainFactor << "meanT0=" << meanT0 << "rmsT0=" << rmsT0 << "meanVdrift=" << meanVdrift << "rmsVdrift=" << rmsVdrift; // Get the beam luminosity AliCDBEntry *entryLHCData = man->Get("GRP/GRP/LHCData"); AliLHCData *lhcData = (entryLHCData ? (AliLHCData*)entryLHCData->GetObject() : 0x0); Double_t beamIntensityA=0.0; Double_t beamIntensityC=0.0; if(lhcData) { Int_t nLumiMeasA=lhcData->GetNLuminosityTotal(0); Int_t nA=0; Int_t nLumiMeasC=lhcData->GetNLuminosityTotal(1); Int_t nC=0; // Sum up the measurements AliLHCDipValF *dipVal0,*dipVal1; for(Int_t iLumiMeas=0;iLumiMeas<nLumiMeasA;iLumiMeas++){ dipVal0 = lhcData->GetLuminosityTotal(0,iLumiMeas); if(dipVal0) { beamIntensityA += dipVal0->GetValue(); ++nA; } } if(nA) beamIntensityA /= Double_t(nA); for(Int_t iLumiMeas=0;iLumiMeas<nLumiMeasC;iLumiMeas++){ dipVal1 = lhcData->GetLuminosityTotal(1,iLumiMeas); if(dipVal1) { beamIntensityC += dipVal1->GetValue(); ++nC; } } if(nC) beamIntensityC /= Double_t(nC); } (*treeStreamer)<< "trending" << "beamIntensityA=" << beamIntensityA << "beamIntensityC=" << beamIntensityC; // Get the magnetic field polarity Double_t Bfield=-2.; AliGRPManager grpManager; if(grpManager.ReadGRPEntry() && grpManager.SetMagField()){ AliMagF *f=TGeoGlobalMagField::Instance()->GetField(); Bfield=f->Factor(); } (*treeStreamer)<< "trending" << "Bfield=" << Bfield; (*treeStreamer)<< "trending" << "\n"; delete treeStreamer; }