Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 16255
b: "refs/heads/CMSSW_7_1_X"
c: a0fd40a
h: "refs/heads/CMSSW_7_1_X"
i:
  16253: ec5dbf3
  16251: 41daf36
  16247: 1ee3314
  16239: c31076a
  16223: e25de7e
  16191: 32eb27a
  16127: 4d4c116
v: v3
  • Loading branch information
Pedro Arce committed Nov 7, 2006
1 parent e650d7b commit c35e920
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 68 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
refs/heads/gh-pages: 09c786f70121f131b3715aaf3464996502bbeb7e
"refs/heads/CMSSW_7_1_X": ac85cc5434e187058adb68333a78d63ccb48a418
"refs/heads/CMSSW_7_1_X": a0fd40ac30bb660dab87bd6e7b0c831865bb046d
6 changes: 4 additions & 2 deletions trunk/Alignment/CocoaApplication/interface/CocoaAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

class Event;
class EventSetup;
class Entry;
//#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

Expand Down Expand Up @@ -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,
Expand Down
107 changes: 62 additions & 45 deletions trunk/Alignment/CocoaApplication/src/CocoaAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<OpticalAlignMeasurementInfo> 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();
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
Expand All @@ -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<cond::service::PoolDBOutputService> mydbservice;
if( mydbservice.isAvailable() ){
// try{
mydbservice->newValidityForNewPayload<OpticalAlignments>(myobj,mydbservice->endOfTime());
/* }std::catch(const cond::Exception& er){
std::cout<<er.what()<<std::endl;
}catch(const std::exception& er){
std::cout<<"caught std::exception "<<er.what()<<std::endl;
}catch(...){
std::cout<<"Funny error"<<std::endl;
}*/
mydbservice->newValidityForNewPayload<OpticalAlignments>(myobj,mydbservice->endOfTime());
/*? compilation error??
}catch(const cond::Exception& er){
std::cout<<er.what()<<std::endl;
}catch(const std::exception& er){
std::cout<<"caught std::exception "<<er.what()<<std::endl;
}catch(...){
std::cout<<"Funny error"<<std::endl;
}
*/
}

std::cout << "@@@@ OPTICALALIGNMENTS WRITTEN TO DB "
<< *myobj
<< std::endl;
//? gives unreadable error??? std::cout << "@@@@ OPTICALALIGNMENTS WRITTEN TO DB " << *myobj << std::endl;

return TRUE;
}


//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
OpticalAlignInfo CocoaAnalyzer::GetOptAlignInfoFromOptO( OpticalObject* opto )
{
OpticalAlignInfo data;
std::cout << " CocoaAnalyzer::GetOptAlignInfoFromOptO " << opto->name() << std::endl;
/*
OpticalAlignInfo data;
data.ID_=opto->cmsSwID();
data.type_=opto->type();
data.name_=opto->name();
Expand All @@ -660,39 +674,33 @@ OpticalAlignInfo CocoaAnalyzer::GetOptAlignInfoFromOptO( OpticalObject* opto )
const std::vector< Entry* > theCoordinateEntryVector = opto->CoordinateEntryList();
std::cout << " CocoaAnalyzer::GetOptAlignInfoFromOptO starting coord " <<std::endl;

Entry* entry = theCoordinateEntryVector[0];
data.x_.value_= centreLocal.x() / 100.; // in cm
std::cout << " matrix " << Fit::GetAtWAMatrix() << std::endl;
std::cout << " matrix " << Fit::GetAtWAMatrix()->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<double> 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;
Expand All @@ -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();
}
}

74 changes: 54 additions & 20 deletions trunk/Alignment/OptAlignCSV2DB/src/OptAlignDataConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -53,52 +55,71 @@ void OptAlignDataConverter::endJob()
throw cms::Exception("unable to parse data :")<<line;
}
std::vector<boost::any> result=dataParser.result();
OpticalAlignInfo* data = new OpticalAlignInfo;
OpticalAlignInfo* oaInfo = new OpticalAlignInfo;
std::string theLastExtraEntryName;
OpticalAlignParam* theLastExtraEntry = 0;
std::vector<OpticalAlignParam*> theExtraEntries;

int idx=0;
for(std::vector<boost::any>::iterator it=result.begin();
it!=result.end(); ++it, ++idx){
for(std::vector<boost::any>::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 "<<fieldName<<" field type "<<m_fieldMap.fieldTypeName(idx)<<std::endl;
if( m_fieldMap.fieldType(idx)!= typeid(int) ) throw cond::Exception("unexpected type");
data->ID_=boost::any_cast<int>(*it);
oaInfo->ID_=boost::any_cast<int>(*it);
} else if(fieldName=="type"){
//std::cout<<"fieldName "<<fieldName<<" field type "<<m_fieldMap.fieldTypeName(idx)<<std::endl;
if( m_fieldMap.fieldType(idx)!= typeid(std::string) ) throw cond::Exception("unexpected type");
data->type_=boost::any_cast<std::string>(*it);
oaInfo->type_=boost::any_cast<std::string>(*it);
}
if(fieldName=="name"){
//std::cout<<"fieldName "<<fieldName<<" field type "<<m_fieldMap.fieldTypeName(idx)<<std::endl;
if( m_fieldMap.fieldType(idx)!= typeid(std::string) ) throw cond::Exception("unexpected type");
data->name_=boost::any_cast<std::string>(*it);
oaInfo->name_=boost::any_cast<std::string>(*it);
}
if(fieldName=="centre_X"){
if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type");
data->x_.value_=boost::any_cast<double>(*it);
oaInfo->x_.value_=boost::any_cast<double>(*it);
} else if(fieldName=="centre_Y"){
if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type");
data->y_.value_=boost::any_cast<double>(*it);
oaInfo->y_.value_=boost::any_cast<double>(*it);
} else if(fieldName=="centre_Z"){
if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type");
data->z_.value_=boost::any_cast<double>(*it);
oaInfo->z_.value_=boost::any_cast<double>(*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<double>(*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<double>(*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<double>(*it);
} else if(fieldName=="angles_X"){
if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type");
data->angx_.value_=boost::any_cast<double>(*it);
oaInfo->angx_.value_=boost::any_cast<double>(*it);
} else if(fieldName=="angles_Y"){
if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type");
data->angy_.value_=boost::any_cast<double>(*it);
oaInfo->angy_.value_=boost::any_cast<double>(*it);
} else if(fieldName=="angles_Z"){
if( m_fieldMap.fieldType(idx) != typeid(float) ) throw cond::Exception("unexpected type");
data->angz_.value_=boost::any_cast<double>(*it);
oaInfo->angz_.value_=boost::any_cast<double>(*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<double>(*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<double>(*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<double>(*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<std::string>(*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;
}
Expand All @@ -107,12 +128,25 @@ void OptAlignDataConverter::endJob()
if( boost::any_cast<double>(*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<double>(*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<double>(*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<double>(*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();
Expand Down

0 comments on commit c35e920

Please sign in to comment.