#include <Alignment/CocoaAnalysis/interface/FittedEntriesManager.h>
Public Member Functions | |
void | AddFittedEntriesSet (FittedEntriesSet *fents) |
FittedEntriesManager () | |
std::vector< FittedEntriesSet * > | getFittedEntriesSets () const |
void | MakeHistos () |
~FittedEntriesManager () | |
Static Public Member Functions | |
static FittedEntriesManager * | getInstance () |
Private Member Functions | |
ALIstring | createFileName (const ALIstring &optoName, const ALIstring &entryName) |
void | dumpEntriesSubstraction (std::ofstream &fout, FittedEntriesSet &fes, ALIint order1, ALIint order2) |
void | GetDifferentBetweenLasers () |
Private Attributes | |
std::vector< FittedEntriesSet * > | theFittedEntriesSets |
Static Private Attributes | |
static FittedEntriesManager * | instance = 0 |
Definition at line 17 of file FittedEntriesManager.h.
FittedEntriesManager::FittedEntriesManager | ( | ) | [inline] |
FittedEntriesManager::~FittedEntriesManager | ( | ) | [inline] |
void FittedEntriesManager::AddFittedEntriesSet | ( | FittedEntriesSet * | fents | ) |
Definition at line 34 of file FittedEntriesManager.cc.
References theFittedEntriesSets.
Referenced by Fit::fitNextEvent(), and MakeHistos().
00035 { 00036 theFittedEntriesSets.push_back( fents ); 00037 00038 }
ALIstring FittedEntriesManager::createFileName | ( | const ALIstring & | optoName, | |
const ALIstring & | entryName | |||
) | [private] |
Definition at line 164 of file FittedEntriesManager.cc.
References GenMuonPlsPt100GeV_cfg::cout, ALIUtils::debug, lat::endl(), and EgammaValidation_cff::filename.
Referenced by MakeHistos().
00165 { 00166 // std::cout << "in createFileName " << optoName << " " << entryName << std::endl; 00167 ALIstring filename; 00168 //- std::cout << "o" << optoName << " e " << entryName << std::endl; 00169 /* ALIint last_slash = optoName.rfind('/'); 00170 ALIint size = optoName.length(); 00171 //- std::cout << last_slash << " " << size << "optoname " << optoName << std::endl; 00172 00173 filename = optoName.substr( last_slash+1, size ); 00174 */ 00175 //----- substitute '/' by '.' in opto name 00176 filename = optoName.substr( 2, optoName.size() ); // skip the first 's/' 00177 ALIint slash = -1; 00178 for(;;){ 00179 slash = filename.find('/', slash+1); 00180 if( slash == -1 ) break; 00181 filename[slash] = '.'; 00182 } 00183 00184 //----- Check if there is a ' ' in entry (should not happen now) 00185 ALIint space = entryName.rfind(' '); 00186 filename.append("."); 00187 ALIstring en = entryName; 00188 if( space != -1) en[space] = '_'; 00189 00190 //----- Merge opto and entry names 00191 // now it is not used as filename filename.append( en + ".out"); 00192 filename.append( en); 00193 if( ALIUtils::debug >= 3) std::cout << "filename " << filename << std::endl; 00194 00195 return filename; 00196 00197 }
void FittedEntriesManager::dumpEntriesSubstraction | ( | std::ofstream & | fout, | |
FittedEntriesSet & | fes, | |||
ALIint | order1, | |||
ALIint | order2 | |||
) | [private] |
Definition at line 205 of file FittedEntriesManager.cc.
References begin, GenMuonPlsPt100GeV_cfg::cout, ALIUtils::debug, lat::endl(), FittedEntriesSet::FittedEntries(), FittedEntry::getSigma(), FittedEntry::getValue(), and funct::sqrt().
00206 { 00207 00208 //---------- Found order of entry1 and entry2 in FittedEntriesSet fes 00209 // (the order will be the same for every FittedEntriesSet 00210 //std::vector< FittedEntriesSet* >::const_iterator vfescite = theFittedEntriesSets.begin(); 00211 /* std::vector< FittedEntry* >::const_iterator vfecite; 00212 ALIint order1, order2; 00213 ALIint jj=0; 00214 for( vfecite = (fes.FittedEntries()).begin(); vfecite != (fes.FittedEntries()).end(); vfecite++) { 00215 ALIstring entryTemp = (*vfecite)->OptOName() + "/" + (*vfecite)->EntryName(); 00216 if(entryTemp == entry1) order1 = jj; 00217 if(entryTemp == entry2) order2 = jj; 00218 jj++; 00219 } 00220 */ 00221 00222 FittedEntry* fe1 = *((fes.FittedEntries()).begin() + order1); 00223 FittedEntry* fe2 = *((fes.FittedEntries()).begin() + order2); 00224 //-------- Substract values of entry1 and entry2 (with errors) 00225 ALIdouble val1 = fe1->getValue(); 00226 ALIdouble val2 = fe2->getValue(); 00227 ALIdouble sig1 = fe1->getSigma(); 00228 ALIdouble sig2 = fe2->getSigma(); 00229 ALIdouble val = val1 - val2; 00230 ALIdouble sig = sqrt( sig1*sig1 + sig2*sig2); 00231 //- std::cout << "CHECK " << val1 << " "<< val2 << " "<< sig1 << " "<< sig2 << std::endl; 00232 fout << std::setprecision(6) <<std::setw(8) << val << " +- " << sig << " "; 00233 if( ALIUtils::debug >= 3) std::cout << " FITTEDENTRY:" << std::setprecision(5) << std::setw(8) << val << " +- " << sig << std::endl; 00234 00235 00236 }
void FittedEntriesManager::GetDifferentBetweenLasers | ( | ) | [private] |
Definition at line 127 of file FittedEntriesManager.cc.
References GenMuonPlsPt100GeV_cfg::cout, ALIUtils::debug, lat::endl(), Model::OptOList(), and LightRay::startLightRay().
Referenced by MakeHistos().
00128 { 00129 00130 std::vector< OpticalObject* > optoList = Model::OptOList(); 00131 std::vector< OpticalObject* >::const_iterator ite; 00132 std::map< ALIstring, LightRay* > lrays; 00133 00134 for( ite = optoList.begin(); ite != optoList.end(); ite++ ){ 00135 if( (*ite)->type() == "laser" ){ 00136 LightRay* lightray = new LightRay; 00137 lightray->startLightRay( *ite ); 00138 lrays[(*ite)->parent()->name()] = lightray; 00139 } 00140 } 00141 00142 std::map< ALIstring, LightRay* >::const_iterator lite1, lite2; 00143 for( lite1 = lrays.begin(); lite1 != lrays.end(); lite1++ ){ 00144 lite2 = lite1; lite2++; 00145 for( ; lite2 != lrays.end(); lite2++ ){ 00146 if( lite1 == lite2 ) continue; 00147 Hep3Vector dirdiff = ((*lite1).second->direction() - (*lite2).second->direction()); 00148 if(ALIUtils::debug >= 0) { 00149 std::cout << "LASER DIFF " << (*lite1).first << " & " << (*lite2).first << " " << dirdiff.mag()*180./M_PI << "o " << dirdiff.mag() << " rad " << dirdiff << std::endl; 00150 00151 (*lite1).second->dumpData(ALIstring(" laser ") + (*lite1).first ); 00152 (*lite2).second->dumpData(ALIstring(" laser ") + (*lite2).first ); 00153 } 00154 } 00155 00156 } 00157 00158 }
std::vector< FittedEntriesSet* > FittedEntriesManager::getFittedEntriesSets | ( | ) | const [inline] |
Definition at line 29 of file FittedEntriesManager.h.
References theFittedEntriesSets.
00029 { 00030 return theFittedEntriesSets; }
FittedEntriesManager * FittedEntriesManager::getInstance | ( | ) | [static] |
Definition at line 23 of file FittedEntriesManager.cc.
References instance.
Referenced by Fit::fitNextEvent(), and Fit::startFit().
00024 { 00025 if(!instance) { 00026 instance = new FittedEntriesManager; 00027 } 00028 return instance; 00029 }
void FittedEntriesManager::MakeHistos | ( | ) |
Definition at line 45 of file FittedEntriesManager.cc.
References AddFittedEntriesSet(), begin, GenMuonPlsPt100GeV_cfg::cout, createFileName(), ALIUtils::debug, ALIUtils::dumpDimensions(), end, lat::endl(), EgammaValidation_cff::filename, GetDifferentBetweenLasers(), GlobalOptionMgr::getInstance(), GlobalOptionMgr::GlobalOptions(), size, and theFittedEntriesSets.
Referenced by Fit::startFit().
00046 { 00047 00048 //----------- Get 00049 //----------- Loop entries 00050 //- vfescite = theFittedEntriesSets.begin(); 00051 // std::vector< FittedEntry* > vfe = theFittedEntriesSets.begin()->FittedEntries(); 00052 // std::vector< FittedEntry* >::const_iterator vfecite2; 00053 //-- Number of fitted entries (equal for all Fitted Entries Sets ) 00054 if( ALIUtils::debug >= 5) std::cout << "No sets2 " << theFittedEntriesSets.size() << " No ent " << ( ( *(theFittedEntriesSets.begin()) )->FittedEntries() ).size() << std::endl; 00055 std::ofstream fout; 00056 std::ofstream fout2; 00057 fout.open( "fittedEntries.out" ); 00058 fout2.open( "longFittedEntries.out" ); 00059 //---------- Dump dimensions 00060 ALIUtils::dumpDimensions( fout ); 00061 ALIUtils::dumpDimensions( fout2 ); 00062 00063 AddFittedEntriesSet( new FittedEntriesSet( theFittedEntriesSets ) ); //add a new set that averages all the others 00064 00065 //---------- Loop sets of entries 00066 std::vector< FittedEntriesSet* >::const_iterator vfescite; 00067 std::vector< FittedEntry* >::const_iterator vfecite; 00068 ALIint jj = 1; 00069 for( vfescite = theFittedEntriesSets.begin(); vfescite != theFittedEntriesSets.end(); vfescite++) { 00070 //---------- Loop entries 00071 if( vfescite == theFittedEntriesSets.begin() ) { 00072 //----- dump entries names if first set 00073 fout << " "; 00074 ALIint ii = 0; 00075 for( vfecite = ((*vfescite)->FittedEntries()).begin(); vfecite != ((*vfescite)->FittedEntries()).end(); vfecite++) { 00076 ALIstring filename = createFileName( (*vfecite)->getOptOName(), (*vfecite)->getEntryName() ); 00077 fout << ii << ": " << std::setw(13) << filename << " ";; 00078 if(ALIUtils::debug >= 3) std::cout << ii << ": " << std::setw(13) << filename << " = " << (*vfecite)->getName() << std::endl; 00079 if( ALIUtils::debug >= 3) std::cout << filename << " "; 00080 if( ALIUtils::debug >= 3) std::cout << "OPENING FITTED ENTRIES file " << filename << std::endl; 00081 ii++; 00082 } 00083 // fout << std::setw(17) << "2:-4:"; 00084 fout << std::endl; 00085 if( ALIUtils::debug >= 3) std::cout << std::endl; 00086 } 00087 //----- Dump entry set number 00088 fout << jj << " "; 00089 fout2 << jj << " "; 00090 //----- Dump measurements date 00091 GlobalOptionMgr* gomgr = GlobalOptionMgr::getInstance(); 00092 if( gomgr->GlobalOptions()["DumpDateInFittedEntries"] >= 1 ) { 00093 fout << (*vfescite)->getDate() << " " << (*vfescite)->getTime() << " "; 00094 fout2 << (*vfescite)->getDate() << " " << (*vfescite)->getTime() << " "; 00095 } 00096 00097 ALIint ii = 0; 00098 for( vfecite = ((*vfescite)->FittedEntries()).begin(); vfecite != ((*vfescite)->FittedEntries()).end(); vfecite++) { 00099 // std::cout << ii << *vfescite << " FITTEDENTRY: " << vfecite << " " <<*vfecite << " " << (*vfecite)->Value() << std::endl; 00100 // if( ii == 2 || ii == 4 ) { 00101 fout << std::setprecision(8) << std::setw(10) << (*vfecite)->getValue() << " " << (*vfecite)->getSigma() << " "; 00102 //- fout << std::setw(9) << std::setprecision(6) << (*vfecite)->getValue() << " +- " << (*vfecite)->getSigma() << " "; 00103 // } 00104 if( ALIUtils::debug >= 3) std::cout << " FITTEDENTRY:" << std::setprecision(5) << std::setw(8) << (*vfecite)->getValue() << " +- " << (*vfecite)->getSigma() << std::endl; 00105 00106 ALIstring filename = createFileName( (*vfecite)->getOptOName(), (*vfecite)->getEntryName() ); 00107 fout2 << std::setprecision(8) << std::setw(10) << filename<< " " << (*vfecite)->getValue() << " " << (*vfecite)->getSigma() << " "; 00108 ii++; 00109 } 00110 // dumpEntriesSubstraction( fout, *(*vfescite), 2, 4); 00111 fout << std::endl; 00112 fout2 << std::endl; 00113 if( ALIUtils::debug >= 3) std::cout << std::endl; 00114 jj++; 00115 } 00116 fout.close(); 00117 fout2.close(); 00118 00119 GetDifferentBetweenLasers(); 00120 00121 }
FittedEntriesManager * FittedEntriesManager::instance = 0 [static, private] |
std::vector< FittedEntriesSet* > FittedEntriesManager::theFittedEntriesSets [private] |
Definition at line 38 of file FittedEntriesManager.h.
Referenced by AddFittedEntriesSet(), getFittedEntriesSets(), and MakeHistos().