CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
FittedEntriesManager Class Reference

#include <FittedEntriesManager.h>

Public Member Functions

void AddFittedEntriesSet (FittedEntriesSet *fents)
 
 FittedEntriesManager ()
 
std::vector< FittedEntriesSet * > getFittedEntriesSets () const
 
void MakeHistos ()
 
 ~FittedEntriesManager ()
 

Static Public Member Functions

static FittedEntriesManagergetInstance ()
 

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 FittedEntriesManagerinstance = nullptr
 

Detailed Description

Definition at line 17 of file FittedEntriesManager.h.

Constructor & Destructor Documentation

FittedEntriesManager::FittedEntriesManager ( )
inline

Definition at line 22 of file FittedEntriesManager.h.

Referenced by getInstance().

22 { };
FittedEntriesManager::~FittedEntriesManager ( )
inline

Definition at line 23 of file FittedEntriesManager.h.

References AddFittedEntriesSet(), getInstance(), and MakeHistos().

23 { };

Member Function Documentation

void FittedEntriesManager::AddFittedEntriesSet ( FittedEntriesSet fents)

Definition at line 33 of file FittedEntriesManager.cc.

References theFittedEntriesSets.

Referenced by Fit::fitNextEvent(), MakeHistos(), and ~FittedEntriesManager().

34 {
35  theFittedEntriesSets.push_back( fents );
36 
37 }
std::vector< FittedEntriesSet * > theFittedEntriesSets
ALIstring FittedEntriesManager::createFileName ( const ALIstring optoName,
const ALIstring entryName 
)
private

Definition at line 163 of file FittedEntriesManager.cc.

References gather_cfg::cout, ALIUtils::debug, corrVsCorr::filename, and pickleFileParser::slash.

Referenced by getFittedEntriesSets(), and MakeHistos().

164 {
165  // std::cout << "in createFileName " << optoName << " " << entryName << std::endl;
167  //- std::cout << "o" << optoName << " e " << entryName << std::endl;
168  /* ALIint last_slash = optoName.rfind('/');
169  ALIint size = optoName.length();
170  //- std::cout << last_slash << " " << size << "optoname " << optoName << std::endl;
171 
172  filename = optoName.substr( last_slash+1, size );
173  */
174  //----- substitute '/' by '.' in opto name
175  filename = optoName.substr( 2, optoName.size() ); // skip the first 's/'
176  ALIint slash = -1;
177  for(;;){
178  slash = filename.find('/', slash+1);
179  if( slash == -1 ) break;
180  filename[slash] = '.';
181  }
182 
183  //----- Check if there is a ' ' in entry (should not happen now)
184  ALIint space = entryName.rfind(' ');
185  filename.append(".");
186  ALIstring en = entryName;
187  if( space != -1) en[space] = '_';
188 
189  //----- Merge opto and entry names
190  // now it is not used as filename filename.append( en + ".out");
191  filename.append( en);
192  if( ALIUtils::debug >= 3) std::cout << "filename " << filename << std::endl;
193 
194  return filename;
195 
196 }
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:36
std::string ALIstring
Definition: CocoaGlobals.h:9
void FittedEntriesManager::dumpEntriesSubstraction ( std::ofstream &  fout,
FittedEntriesSet fes,
ALIint  order1,
ALIint  order2 
)
private

Definition at line 204 of file FittedEntriesManager.cc.

References begin, gather_cfg::cout, ALIUtils::debug, FittedEntriesSet::FittedEntries(), FittedEntry::getSigma(), FittedEntry::getValue(), mathSSE::sqrt(), and heppy_batch::val.

Referenced by getFittedEntriesSets().

205 {
206 
207  //---------- Found order of entry1 and entry2 in FittedEntriesSet fes
208  // (the order will be the same for every FittedEntriesSet
209  //std::vector< FittedEntriesSet* >::const_iterator vfescite = theFittedEntriesSets.begin();
210  /* std::vector< FittedEntry* >::const_iterator vfecite;
211  ALIint order1, order2;
212  ALIint jj=0;
213  for( vfecite = (fes.FittedEntries()).begin(); vfecite != (fes.FittedEntries()).end(); vfecite++) {
214  ALIstring entryTemp = (*vfecite)->OptOName() + "/" + (*vfecite)->EntryName();
215  if(entryTemp == entry1) order1 = jj;
216  if(entryTemp == entry2) order2 = jj;
217  jj++;
218  }
219  */
220 
221  FittedEntry* fe1 = *((fes.FittedEntries()).begin() + order1);
222  FittedEntry* fe2 = *((fes.FittedEntries()).begin() + order2);
223  //-------- Substract values of entry1 and entry2 (with errors)
224  ALIdouble val1 = fe1->getValue();
225  ALIdouble val2 = fe2->getValue();
226  ALIdouble sig1 = fe1->getSigma();
227  ALIdouble sig2 = fe2->getSigma();
228  ALIdouble val = val1 - val2;
229  ALIdouble sig = sqrt( sig1*sig1 + sig2*sig2);
230  //- std::cout << "CHECK " << val1 << " "<< val2 << " "<< sig1 << " "<< sig2 << std::endl;
231  fout << std::setprecision(6) <<std::setw(8) << val << " +- " << sig << " ";
232  if( ALIUtils::debug >= 3) std::cout << " FITTEDENTRY:" << std::setprecision(5) << std::setw(8) << val << " +- " << sig << std::endl;
233 
234 
235 }
long double ALIdouble
Definition: CocoaGlobals.h:11
static ALIint debug
Definition: ALIUtils.h:36
T sqrt(T t)
Definition: SSEVec.h:18
ALIdouble getSigma() const
Definition: FittedEntry.h:42
std::vector< FittedEntry * > & FittedEntries()
#define begin
Definition: vmac.h:32
ALIdouble getValue() const
Definition: FittedEntry.h:39
void FittedEntriesManager::GetDifferentBetweenLasers ( )
private

Definition at line 126 of file FittedEntriesManager.cc.

References gather_cfg::cout, ALIUtils::debug, M_PI, Model::OptOList(), and LightRay::startLightRay().

Referenced by MakeHistos().

127 {
128 
129  std::vector< OpticalObject* > optoList = Model::OptOList();
130  std::vector< OpticalObject* >::const_iterator ite;
131  std::map< ALIstring, LightRay* > lrays;
132 
133  for( ite = optoList.begin(); ite != optoList.end(); ++ite ){
134  if( (*ite)->type() == "laser" ){
135  LightRay* lightray = new LightRay;
136  lightray->startLightRay( *ite );
137  lrays[(*ite)->parent()->name()] = lightray;
138  }
139  }
140 
141  std::map< ALIstring, LightRay* >::const_iterator lite1, lite2;
142  for( lite1 = lrays.begin(); lite1 != lrays.end(); ++lite1 ){
143  lite2 = lite1; ++lite2;
144  for( ; lite2 != lrays.end(); ++lite2 ){
145  if( lite1 == lite2 ) continue;
146  CLHEP::Hep3Vector dirdiff = ((*lite1).second->direction() - (*lite2).second->direction());
147  if(ALIUtils::debug >= 0) {
148  std::cout << "LASER DIFF " << (*lite1).first << " & " << (*lite2).first << " " << dirdiff.mag()*180./M_PI << "o " << dirdiff.mag() << " rad " << dirdiff << std::endl;
149 
150  (*lite1).second->dumpData(ALIstring(" laser ") + (*lite1).first );
151  (*lite2).second->dumpData(ALIstring(" laser ") + (*lite2).first );
152  }
153  }
154 
155  }
156 
157 }
static ALIint debug
Definition: ALIUtils.h:36
#define M_PI
static std::vector< OpticalObject * > & OptOList()
Definition: Model.h:71
std::string ALIstring
Definition: CocoaGlobals.h:9
void startLightRay(OpticalObject *opto)
Definition: LightRay.cc:28
std::vector< FittedEntriesSet* > FittedEntriesManager::getFittedEntriesSets ( ) const
inline

Definition at line 29 of file FittedEntriesManager.h.

References createFileName(), dumpEntriesSubstraction(), groupFilesInBlocks::fout, and theFittedEntriesSets.

29  {
30  return theFittedEntriesSets; }
std::vector< FittedEntriesSet * > theFittedEntriesSets
FittedEntriesManager * FittedEntriesManager::getInstance ( )
static

Definition at line 22 of file FittedEntriesManager.cc.

References FittedEntriesManager(), and instance.

Referenced by Fit::fitNextEvent(), Fit::startFit(), and ~FittedEntriesManager().

23 {
24  if(!instance) {
26  }
27  return instance;
28 }
static FittedEntriesManager * instance
void FittedEntriesManager::MakeHistos ( )

Definition at line 44 of file FittedEntriesManager.cc.

References AddFittedEntriesSet(), begin, gather_cfg::cout, createFileName(), ALIUtils::debug, ALIUtils::dumpDimensions(), end, corrVsCorr::filename, groupFilesInBlocks::fout, GetDifferentBetweenLasers(), GlobalOptionMgr::getInstance(), GlobalOptionMgr::GlobalOptions(), cuy::ii, findQualityFiles::jj, findQualityFiles::size, and theFittedEntriesSets.

Referenced by Fit::startFit(), and ~FittedEntriesManager().

45 {
46 
47  //----------- Get
48  //----------- Loop entries
49  //- vfescite = theFittedEntriesSets.begin();
50  // std::vector< FittedEntry* > vfe = theFittedEntriesSets.begin()->FittedEntries();
51  // std::vector< FittedEntry* >::const_iterator vfecite2;
52  //-- Number of fitted entries (equal for all Fitted Entries Sets )
53  if( ALIUtils::debug >= 5) std::cout << "No sets2 " << theFittedEntriesSets.size() << " No ent " << ( ( *(theFittedEntriesSets.begin()) )->FittedEntries() ).size() << std::endl;
54  std::ofstream fout;
55  std::ofstream fout2;
56  fout.open( "fittedEntries.out" );
57  fout2.open( "longFittedEntries.out" );
58  //---------- Dump dimensions
60  ALIUtils::dumpDimensions( fout2 );
61 
62  AddFittedEntriesSet( new FittedEntriesSet( theFittedEntriesSets ) ); //add a new set that averages all the others
63 
64  //---------- Loop sets of entries
65  std::vector< FittedEntriesSet* >::const_iterator vfescite;
66  std::vector< FittedEntry* >::const_iterator vfecite;
67  ALIint jj = 1;
68  for( vfescite = theFittedEntriesSets.begin(); vfescite != theFittedEntriesSets.end(); ++vfescite) {
69  //---------- Loop entries
70  if( vfescite == theFittedEntriesSets.begin() ) {
71  //----- dump entries names if first set
72  fout << " ";
73  ALIint ii = 0;
74  for( vfecite = ((*vfescite)->FittedEntries()).begin(); vfecite != ((*vfescite)->FittedEntries()).end(); ++vfecite) {
75  ALIstring filename = createFileName( (*vfecite)->getOptOName(), (*vfecite)->getEntryName() );
76  fout << ii << ": " << std::setw(13) << filename << " ";;
77  if(ALIUtils::debug >= 3) std::cout << ii << ": " << std::setw(13) << filename << " = " << (*vfecite)->getName() << std::endl;
78  if( ALIUtils::debug >= 3) std::cout << filename << " ";
79  if( ALIUtils::debug >= 3) std::cout << "OPENING FITTED ENTRIES file " << filename << std::endl;
80  ii++;
81  }
82  // fout << std::setw(17) << "2:-4:";
83  fout << std::endl;
84  if( ALIUtils::debug >= 3) std::cout << std::endl;
85  }
86 //----- Dump entry set number
87  fout << jj << " ";
88  fout2 << jj << " ";
89 //----- Dump measurements date
91  if( gomgr->GlobalOptions()["DumpDateInFittedEntries"] >= 1 ) {
92  fout << (*vfescite)->getDate() << " " << (*vfescite)->getTime() << " ";
93  fout2 << (*vfescite)->getDate() << " " << (*vfescite)->getTime() << " ";
94  }
95 
96  ALIint ii = 0;
97  for( vfecite = ((*vfescite)->FittedEntries()).begin(); vfecite != ((*vfescite)->FittedEntries()).end(); ++vfecite) {
98  // std::cout << ii << *vfescite << " FITTEDENTRY: " << vfecite << " " <<*vfecite << " " << (*vfecite)->Value() << std::endl;
99  // if( ii == 2 || ii == 4 ) {
100  fout << std::setprecision(8) << std::setw(10) << (*vfecite)->getValue() << " " << (*vfecite)->getSigma() << " ";
101  //- fout << std::setw(9) << std::setprecision(6) << (*vfecite)->getValue() << " +- " << (*vfecite)->getSigma() << " ";
102  // }
103  if( ALIUtils::debug >= 3) std::cout << " FITTEDENTRY:" << std::setprecision(5) << std::setw(8) << (*vfecite)->getValue() << " +- " << (*vfecite)->getSigma() << std::endl;
104 
105  ALIstring filename = createFileName( (*vfecite)->getOptOName(), (*vfecite)->getEntryName() );
106  fout2 << std::setprecision(8) << std::setw(10) << filename<< " " << (*vfecite)->getValue() << " " << (*vfecite)->getSigma() << " ";
107  ii++;
108  }
109  // dumpEntriesSubstraction( fout, *(*vfescite), 2, 4);
110  fout << std::endl;
111  fout2 << std::endl;
112  if( ALIUtils::debug >= 3) std::cout << std::endl;
113  jj++;
114  }
115  fout.close();
116  fout2.close();
117 
119 
120 }
size
Write out results.
void AddFittedEntriesSet(FittedEntriesSet *fents)
ALIstring createFileName(const ALIstring &optoName, const ALIstring &entryName)
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:36
static GlobalOptionMgr * getInstance()
#define end
Definition: vmac.h:39
ii
Definition: cuy.py:589
std::vector< FittedEntriesSet * > theFittedEntriesSets
#define begin
Definition: vmac.h:32
std::string ALIstring
Definition: CocoaGlobals.h:9
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()
static void dumpDimensions(std::ofstream &fout)
Definition: ALIUtils.cc:337

Member Data Documentation

FittedEntriesManager * FittedEntriesManager::instance = nullptr
staticprivate

Definition at line 37 of file FittedEntriesManager.h.

Referenced by getInstance(), and production_tasks.Task::getname().

std::vector< FittedEntriesSet* > FittedEntriesManager::theFittedEntriesSets
private

Definition at line 38 of file FittedEntriesManager.h.

Referenced by AddFittedEntriesSet(), getFittedEntriesSets(), and MakeHistos().