From c35e9202434392e2b396cfa5325d6c85bec5b091 Mon Sep 17 00:00:00 2001 From: Pedro Arce Date: Tue, 7 Nov 2006 20:29:35 +0000 Subject: [PATCH] --- yaml --- r: 16255 b: "refs/heads/CMSSW_7_1_X" c: a0fd40ac30bb660dab87bd6e7b0c831865bb046d h: "refs/heads/CMSSW_7_1_X" i: 16253: ec5dbf3980fd82cb61e0fda226e37b3825dc343e 16251: 41daf36f40d2bbe75799faa84b2c7c36dfcbf822 16247: 1ee33142c3a5ea3dc2aa55395be1e2b546b9fc2c 16239: c31076aedccda87b5facfa36e1e8ac9a02c4ee24 16223: e25de7e48ee80f2e610c850e8e2e6e61b9d6c3d8 16191: 32eb27aac23c7dee1c10cc7f9468f40ff5476105 16127: 4d4c1168307d34f9404e8f5507d0f614ffc47645 v: v3 --- [refs] | 2 +- .../interface/CocoaAnalyzer.h | 6 +- .../CocoaApplication/src/CocoaAnalyzer.cc | 107 ++++++++++-------- .../src/OptAlignDataConverter.cc | 74 ++++++++---- 4 files changed, 121 insertions(+), 68 deletions(-) diff --git a/[refs] b/[refs] index 79eb48560b568..497b1fbe24e46 100644 --- a/[refs] +++ b/[refs] @@ -1,3 +1,3 @@ --- refs/heads/gh-pages: 09c786f70121f131b3715aaf3464996502bbeb7e -"refs/heads/CMSSW_7_1_X": ac85cc5434e187058adb68333a78d63ccb48a418 +"refs/heads/CMSSW_7_1_X": a0fd40ac30bb660dab87bd6e7b0c831865bb046d diff --git a/trunk/Alignment/CocoaApplication/interface/CocoaAnalyzer.h b/trunk/Alignment/CocoaApplication/interface/CocoaAnalyzer.h index 4f2f8964fcbf4..91759bafd6f60 100644 --- a/trunk/Alignment/CocoaApplication/interface/CocoaAnalyzer.h +++ b/trunk/Alignment/CocoaApplication/interface/CocoaAnalyzer.h @@ -25,6 +25,7 @@ class Event; class EventSetup; +class Entry; //#include "FWCore/Framework/interface/EventSetup.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" @@ -68,8 +69,9 @@ class CocoaAnalyzer : public edm::EDAnalyzer void RunCocoa(); - bool DumpCocoaResults(); - + bool DumpCocoaResults(); + double GetEntryError( const Entry* entry ); + OpticalAlignInfo GetOptAlignInfoFromOptO( OpticalObject* opto ); double myFetchDbl(const DDsvalues_type& dvst, const std::string& spName, diff --git a/trunk/Alignment/CocoaApplication/src/CocoaAnalyzer.cc b/trunk/Alignment/CocoaApplication/src/CocoaAnalyzer.cc index b36aab8903c05..fd507a4156b63 100644 --- a/trunk/Alignment/CocoaApplication/src/CocoaAnalyzer.cc +++ b/trunk/Alignment/CocoaApplication/src/CocoaAnalyzer.cc @@ -35,19 +35,19 @@ void CocoaAnalyzer::beginJob( const edm::EventSetup& evts ) CorrectOptAlignments( oaListCalib ); - CocoaDaqReaderRoot* daqReader = new CocoaDaqReaderRoot( theCocoaDaqRootFileName ); - - /*t + new CocoaDaqReaderRoot( theCocoaDaqRootFileName ); + + /*- int nEvents = daqReader->GetNEvents(); - for( size_t ii = 0; ii < nEvents; ii++) { - std::vector measList = daqReader->ReadEvent( ii ); - daqReader->BuildMeasurementsFromOptAlign( measList ); - + for( int ii = 0; ii < nEvents; ii++) { + if( ! daqReader->ReadEvent( ii ) ) break; } - */ - + */ + RunCocoa(); + // std::cout << "!!!! NOT DumpCocoaResults() " << std::endl; + DumpCocoaResults(); } @@ -293,6 +293,7 @@ void CocoaAnalyzer::ReadXMLFile( const edm::EventSetup& evts ) measParamSigmas[*vsite] = sit->second.doubles(); }else if (sit->second.name() == "meas_is_simulated_value_"+(*vsite)) { measIsSimulatedValue[*vsite] = sit->second.doubles(); // this is not in OptAlignParam info + std::cout << *vsite << " setting issimu " << measIsSimulatedValue[*vsite][0] << std::endl; } if(ALIUtils::debug >= 4) { std::cout << "CocoaAnalyser: looped measObjectNames " << "meas_object_name_"+(*vsite) << " n obj " << measObjectNames[*vsite].size() << std::endl; @@ -343,8 +344,18 @@ void CocoaAnalyzer::ReadXMLFile( const edm::EventSetup& evts ) oaParam.name_ = measParamNames[oaMeas.name_][ind2]; oaParam.value_ = measParamValues[oaMeas.name_][ind2]; oaParam.error_ = measParamSigmas[oaMeas.name_][ind2]; + if( oaMeas.type_ == "SENSOR2D" || oaMeas.type_ == "COPS" || oaMeas.type_ == "DISTANCEMETER" || oaMeas.type_ == "DISTANCEMETER!DIM" || oaMeas.type_ == "DISTANCEMETER3DIM" ) { + oaParam.dim_type_ = "length"; + } else if( oaMeas.type_ == "TILTMETER" ) { + oaParam.dim_type_ = "angle"; + } else { + std::cerr << "CocoaAnalyzer::ReadXMLFile. Invalid measurement type: " << oaMeas.type_ << std::endl; + std::exception(); + } + oaMeas.values_.push_back( oaParam ); oaMeas.isSimulatedValue_.push_back( measIsSimulatedValue[oaMeas.name_][ind2] ); + std::cout << oaMeas.name_ << " copying issimu " << oaMeas.isSimulatedValue_[oaMeas.isSimulatedValue_.size()-1] << " = " << measIsSimulatedValue[oaMeas.name_][ind2] << std::endl; //- std::cout << ind2 << " adding meas value " << oaParam << std::endl; oaParam.clear(); } @@ -612,6 +623,7 @@ std::string CocoaAnalyzer:: myFetchString(const DDsvalues_type& dvst, //----------------------------------------------------------------------- bool CocoaAnalyzer::DumpCocoaResults() { + OpticalAlignments* myobj=new OpticalAlignments; static std::vector< OpticalObject* > optolist = Model::OptOList(); @@ -620,34 +632,36 @@ bool CocoaAnalyzer::DumpCocoaResults() if( (*ite)->type() == "system" ) continue; OpticalAlignInfo data = GetOptAlignInfoFromOptO( *ite ); myobj->opticalAlignments_.push_back(data); - } + std::cout << "@@@@ OPTALIGNINFO WRITTEN TO DB " + << data + << std::endl; } edm::Service mydbservice; if( mydbservice.isAvailable() ){ // try{ - mydbservice->newValidityForNewPayload(myobj,mydbservice->endOfTime()); - /* }std::catch(const cond::Exception& er){ - std::cout<newValidityForNewPayload(myobj,mydbservice->endOfTime()); + /*? compilation error?? + }catch(const cond::Exception& er){ + std::cout<name() << std::endl; -/* + OpticalAlignInfo data; data.ID_=opto->cmsSwID(); data.type_=opto->type(); data.name_=opto->name(); @@ -660,39 +674,33 @@ OpticalAlignInfo CocoaAnalyzer::GetOptAlignInfoFromOptO( OpticalObject* opto ) const std::vector< Entry* > theCoordinateEntryVector = opto->CoordinateEntryList(); std::cout << " CocoaAnalyzer::GetOptAlignInfoFromOptO starting coord " <Mat() << entry->fitPos() << std::endl; - data.x_.error_= sqrt(Fit::GetAtWAMatrix()->Mat()->me[entry->fitPos()][entry->fitPos()]) / 100.; + std::cout << " matrix " << Fit::GetAtWAMatrix()->Mat() << " " << theCoordinateEntryVector[0]->fitPos() << std::endl; + data.x_.error_= GetEntryError( theCoordinateEntryVector[0] ) / 100.; // in cm - entry = theCoordinateEntryVector[1]; data.y_.value_= centreLocal.y() / 100.; // in cm - std::cout << " matrix " << Fit::GetAtWAMatrix()->Mat() << entry->fitPos() << std::endl; - data.y_.error_= sqrt(Fit::GetAtWAMatrix()->Mat()->me[entry->fitPos()][entry->fitPos()]) / 100.; + std::cout << " matrix " << Fit::GetAtWAMatrix()->Mat() << " " << theCoordinateEntryVector[1]->fitPos() << std::endl; + data.y_.error_= GetEntryError( theCoordinateEntryVector[1] ) / 100.; // in cm - entry = theCoordinateEntryVector[2]; data.z_.value_= centreLocal.z() / 100.; // in cm - std::cout << " matrix " << Fit::GetAtWAMatrix()->Mat() << entry->fitPos() << std::endl; - data.z_.error_= sqrt(Fit::GetAtWAMatrix()->Mat()->me[entry->fitPos()][entry->fitPos()]) / 100.; + std::cout << " matrix " << Fit::GetAtWAMatrix()->Mat() << " " << theCoordinateEntryVector[2]->fitPos() << std::endl; + data.z_.error_= GetEntryError( theCoordinateEntryVector[2] ) / 100.; // in cm //----- angles in local coordinates std::vector anglocal = opto->GetLocalRotationAngles( theCoordinateEntryVector ); - entry = theCoordinateEntryVector[3]; - data.angx_.value_= anglocal[0] / entry->ValueDimensionFactor()*180./M_PI; // in deg - std::cout << " matrix " << Fit::GetAtWAMatrix()->Mat() << entry->fitPos() << std::endl; - data.angx_.error_= sqrt(Fit::GetAtWAMatrix()->Mat()->me[entry->fitPos()][entry->fitPos()]) / entry->SigmaDimensionFactor()*180./M_PI; // in deg; + data.angx_.value_= anglocal[0] *180./M_PI; // in deg + std::cout << " matrix " << Fit::GetAtWAMatrix()->Mat() << theCoordinateEntryVector[3]->fitPos() << std::endl; + data.angx_.error_= GetEntryError( theCoordinateEntryVector[3] ) * 180./M_PI; // in deg; - entry = theCoordinateEntryVector[4]; - data.angy_.value_= anglocal[1] / entry->ValueDimensionFactor()*180./M_PI; // in deg - std::cout << " matrix " << Fit::GetAtWAMatrix()->Mat() << entry->fitPos() << std::endl; - data.angy_.error_= sqrt(Fit::GetAtWAMatrix()->Mat()->me[entry->fitPos()][entry->fitPos()]) / entry->SigmaDimensionFactor()*180./M_PI; // in deg; + data.angy_.value_= anglocal[1] * 180./M_PI; // in deg + std::cout << " matrix " << Fit::GetAtWAMatrix()->Mat() << theCoordinateEntryVector[4]->fitPos() << std::endl; + data.angy_.error_= GetEntryError( theCoordinateEntryVector[4] ) * 180./M_PI; // in deg;; - entry = theCoordinateEntryVector[5]; - data.angz_.value_= anglocal[2] / entry->ValueDimensionFactor()*180./M_PI; // in deg - std::cout << " matrix " << Fit::GetAtWAMatrix()->Mat() << entry->fitPos() << std::endl; - data.angz_.error_= sqrt(Fit::GetAtWAMatrix()->Mat()->me[entry->fitPos()][entry->fitPos()]) / entry->SigmaDimensionFactor()*180./M_PI; // in deg; + data.angz_.value_= anglocal[2] *180./M_PI; // in deg + std::cout << " matrix " << Fit::GetAtWAMatrix()->Mat() << theCoordinateEntryVector[5]->fitPos() << std::endl; + data.angz_.error_= GetEntryError( theCoordinateEntryVector[5] ) * 180./M_PI; // in deg; const std::vector< Entry* > theExtraEntryVector = opto->ExtraEntryList(); std::cout << " CocoaAnalyzer::GetOptAlignInfoFromOptO starting entry " << std::endl; @@ -710,7 +718,16 @@ OpticalAlignInfo CocoaAnalyzer::GetOptAlignInfoFromOptO( OpticalObject* opto ) } -*/ return data; +} + +double CocoaAnalyzer::GetEntryError( const Entry* entry ) +{ + if( entry->quality() > 0 ) { + return sqrt(Fit::GetAtWAMatrix()->Mat()->me[entry->fitPos()][entry->fitPos()]) / 100.; + } else { //entry not fitted, return original error + return entry->sigma(); + } } + diff --git a/trunk/Alignment/OptAlignCSV2DB/src/OptAlignDataConverter.cc b/trunk/Alignment/OptAlignCSV2DB/src/OptAlignDataConverter.cc index c53f2bd872183..ed7895e3ecf75 100644 --- a/trunk/Alignment/OptAlignCSV2DB/src/OptAlignDataConverter.cc +++ b/trunk/Alignment/OptAlignCSV2DB/src/OptAlignDataConverter.cc @@ -25,6 +25,8 @@ void OptAlignDataConverter::endJob() while (! myfile.eof() ){ std::string line; std::getline (myfile,line); + std::cout << " line read " << line << std::endl; + CSVBlankLineParser blank; if(blank.isBlank(line)){ continue; @@ -53,52 +55,71 @@ void OptAlignDataConverter::endJob() throw cms::Exception("unable to parse data :")< result=dataParser.result(); - OpticalAlignInfo* data = new OpticalAlignInfo; + OpticalAlignInfo* oaInfo = new OpticalAlignInfo; std::string theLastExtraEntryName; OpticalAlignParam* theLastExtraEntry = 0; + std::vector theExtraEntries; + int idx=0; - for(std::vector::iterator it=result.begin(); - it!=result.end(); ++it, ++idx){ + for(std::vector::iterator it=result.begin(); it!=result.end(); ++it, ++idx){ std::string fieldName=m_fieldMap.fieldName(idx); + // std::cout << " idx " << idx << " = " << fieldName << std::endl; if(fieldName=="ID"){ //std::cout<<"fieldName "<ID_=boost::any_cast(*it); + oaInfo->ID_=boost::any_cast(*it); } else if(fieldName=="type"){ //std::cout<<"fieldName "<type_=boost::any_cast(*it); + oaInfo->type_=boost::any_cast(*it); } if(fieldName=="name"){ //std::cout<<"fieldName "<name_=boost::any_cast(*it); + oaInfo->name_=boost::any_cast(*it); } if(fieldName=="centre_X"){ if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type"); - data->x_.value_=boost::any_cast(*it); + oaInfo->x_.value_=boost::any_cast(*it); } else if(fieldName=="centre_Y"){ if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type"); - data->y_.value_=boost::any_cast(*it); + oaInfo->y_.value_=boost::any_cast(*it); } else if(fieldName=="centre_Z"){ if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type"); - data->z_.value_=boost::any_cast(*it); + oaInfo->z_.value_=boost::any_cast(*it); + } else if(fieldName=="centre_sigma_X" || fieldName=="centre_error_X"){ + if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type"); + oaInfo->x_.error_=boost::any_cast(*it); + } else if(fieldName=="centre_sigma_Y" || fieldName=="centre_error_Y"){ + if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type"); + oaInfo->y_.error_=boost::any_cast(*it); + } else if(fieldName=="centre_sigma_Z" || fieldName=="centre_error_Z"){ + if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type"); + oaInfo->z_.error_=boost::any_cast(*it); } else if(fieldName=="angles_X"){ if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type"); - data->angx_.value_=boost::any_cast(*it); + oaInfo->angx_.value_=boost::any_cast(*it); } else if(fieldName=="angles_Y"){ if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type"); - data->angy_.value_=boost::any_cast(*it); + oaInfo->angy_.value_=boost::any_cast(*it); } else if(fieldName=="angles_Z"){ if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type"); - data->angz_.value_=boost::any_cast(*it); + oaInfo->angz_.value_=boost::any_cast(*it); + } else if(fieldName=="angles_sigma_X" || fieldName=="angles_error_X"){ + if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type"); + oaInfo->angx_.error_=boost::any_cast(*it); + } else if(fieldName=="angles_sigma_Y" || fieldName=="angles_error_Y"){ + if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type"); + oaInfo->angy_.error_=boost::any_cast(*it); + } else if(fieldName=="angles_sigma_Z" || fieldName=="angles_error_Z"){ + if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type"); + oaInfo->angz_.error_=boost::any_cast(*it); } else if( fieldName.substr(0,5) == "param" && fieldName.substr(fieldName.length()-4,4) == "name"){ if( m_fieldMap.fieldType(idx) != typeid(std::string) ) throw cond::Exception("unexpected type"); std::string name = boost::any_cast(*it); - OpticalAlignParam* extraEntry = new OpticalAlignParam; - extraEntry->name_ = name; - if( theLastExtraEntry != 0 ) delete theLastExtraEntry; - theLastExtraEntry = extraEntry; + theLastExtraEntry = new OpticalAlignParam; + theExtraEntries.push_back( theLastExtraEntry ); + theLastExtraEntry->name_ = name; if( name != "None" ){ theLastExtraEntryName = name; } @@ -107,12 +128,25 @@ void OptAlignDataConverter::endJob() if( boost::any_cast(*it) != -9.999E9 ){ if( theLastExtraEntryName == "None" ) throw cond::Exception("unexpected type: setting a value != -9.999E9 for a parameter that is 'None' "); theLastExtraEntry->value_ = boost::any_cast(*it); - data->extraEntries_.push_back( *theLastExtraEntry ); } - } + } else if( fieldName.substr(0,5) == "param" && ( fieldName.substr(fieldName.length()-5,5) == "sigma" || fieldName.substr(fieldName.length()-5,5) == "error") ) { + if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type"); + if( boost::any_cast(*it) != -9.999E9 ){ + if( theLastExtraEntryName == "None" ) throw cond::Exception("unexpected type: setting an error != -9.999E9 for a parameter that is 'None' "); + theLastExtraEntry->error_ = boost::any_cast(*it); + } + } // end loop to one oaInfo + } + + for( size_t kk = 0; kk < theExtraEntries.size(); kk++) { + oaInfo->extraEntries_.push_back( *(theExtraEntries[kk]) ); + delete theExtraEntries[kk]; } - myobj->opticalAlignments_.push_back(*data); - delete data; + + myobj->opticalAlignments_.push_back(*oaInfo); + std::cout << " OptAlignInfo read " << *oaInfo << std::endl; + + delete oaInfo; ++counter; } myfile.close();