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 16 of file FittedEntriesManager.h.

Constructor & Destructor Documentation

◆ FittedEntriesManager()

FittedEntriesManager::FittedEntriesManager ( )
inline

Definition at line 19 of file FittedEntriesManager.h.

Referenced by getInstance().

19 {};

◆ ~FittedEntriesManager()

FittedEntriesManager::~FittedEntriesManager ( )
inline

Definition at line 20 of file FittedEntriesManager.h.

20 {};

Member Function Documentation

◆ AddFittedEntriesSet()

void FittedEntriesManager::AddFittedEntriesSet ( FittedEntriesSet fents)

Definition at line 32 of file FittedEntriesManager.cc.

References theFittedEntriesSets.

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

32 { theFittedEntriesSets.push_back(fents); }
std::vector< FittedEntriesSet * > theFittedEntriesSets

◆ createFileName()

ALIstring FittedEntriesManager::createFileName ( const ALIstring optoName,
const ALIstring entryName 
)
private

Definition at line 164 of file FittedEntriesManager.cc.

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

Referenced by 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)
180  break;
181  filename[slash] = '.';
182  }
183 
184  //----- Check if there is a ' ' in entry (should not happen now)
185  ALIint space = entryName.rfind(' ');
186  filename.append(".");
187  ALIstring en = entryName;
188  if (space != -1)
189  en[space] = '_';
190 
191  //----- Merge opto and entry names
192  // now it is not used as filename filename.append( en + ".out");
193  filename.append(en);
194  if (ALIUtils::debug >= 3)
195  std::cout << "filename " << filename << std::endl;
196 
197  return filename;
198 }
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:34
std::string ALIstring
Definition: CocoaGlobals.h:9

◆ dumpEntriesSubstraction()

void FittedEntriesManager::dumpEntriesSubstraction ( std::ofstream &  fout,
FittedEntriesSet fes,
ALIint  order1,
ALIint  order2 
)
private

Definition at line 204 of file FittedEntriesManager.cc.

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

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

◆ GetDifferentBetweenLasers()

void FittedEntriesManager::GetDifferentBetweenLasers ( )
private

Definition at line 129 of file FittedEntriesManager.cc.

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

Referenced by MakeHistos().

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

◆ getFittedEntriesSets()

std::vector<FittedEntriesSet*> FittedEntriesManager::getFittedEntriesSets ( ) const
inline

Definition at line 26 of file FittedEntriesManager.h.

References theFittedEntriesSets.

26 { return theFittedEntriesSets; }
std::vector< FittedEntriesSet * > theFittedEntriesSets

◆ getInstance()

FittedEntriesManager * FittedEntriesManager::getInstance ( )
static

Definition at line 22 of file FittedEntriesManager.cc.

References FittedEntriesManager(), and instance.

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

22  {
23  if (!instance) {
25  }
26  return instance;
27 }
static FittedEntriesManager * instance

◆ MakeHistos()

void FittedEntriesManager::MakeHistos ( )

Definition at line 38 of file FittedEntriesManager.cc.

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

Referenced by Fit::startFit().

38  {
39  //----------- Get
40  //----------- Loop entries
41  //- vfescite = theFittedEntriesSets.begin();
42  // std::vector< FittedEntry* > vfe = theFittedEntriesSets.begin()->FittedEntries();
43  // std::vector< FittedEntry* >::const_iterator vfecite2;
44  //-- Number of fitted entries (equal for all Fitted Entries Sets )
45  if (ALIUtils::debug >= 5)
46  std::cout << "No sets2 " << theFittedEntriesSets.size() << " No ent "
47  << ((*(theFittedEntriesSets.begin()))->FittedEntries()).size() << std::endl;
48  std::ofstream fout;
49  std::ofstream fout2;
50  fout.open("fittedEntries.out");
51  fout2.open("longFittedEntries.out");
52  //---------- Dump dimensions
55 
56  AddFittedEntriesSet(new FittedEntriesSet(theFittedEntriesSets)); //add a new set that averages all the others
57 
58  //---------- Loop sets of entries
59  std::vector<FittedEntriesSet*>::const_iterator vfescite;
60  std::vector<FittedEntry*>::const_iterator vfecite;
61  ALIint jj = 1;
62  for (vfescite = theFittedEntriesSets.begin(); vfescite != theFittedEntriesSets.end(); ++vfescite) {
63  //---------- Loop entries
64  if (vfescite == theFittedEntriesSets.begin()) {
65  //----- dump entries names if first set
66  fout << " ";
67  ALIint ii = 0;
68  for (vfecite = ((*vfescite)->FittedEntries()).begin(); vfecite != ((*vfescite)->FittedEntries()).end();
69  ++vfecite) {
70  ALIstring filename = createFileName((*vfecite)->getOptOName(), (*vfecite)->getEntryName());
71  fout << ii << ": " << std::setw(13) << filename << " ";
72  ;
73  if (ALIUtils::debug >= 3)
74  std::cout << ii << ": " << std::setw(13) << filename << " = " << (*vfecite)->getName() << std::endl;
75  if (ALIUtils::debug >= 3)
76  std::cout << filename << " ";
77  if (ALIUtils::debug >= 3)
78  std::cout << "OPENING FITTED ENTRIES file " << filename << std::endl;
79  ii++;
80  }
81  // fout << std::setw(17) << "2:-4:";
82  fout << std::endl;
83  if (ALIUtils::debug >= 3)
84  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)
104  std::cout << " FITTEDENTRY:" << std::setprecision(5) << std::setw(8) << (*vfecite)->getValue() << " +- "
105  << (*vfecite)->getSigma() << std::endl;
106 
107  ALIstring filename = createFileName((*vfecite)->getOptOName(), (*vfecite)->getEntryName());
108  fout2 << std::setprecision(8) << std::setw(10) << filename << " " << (*vfecite)->getValue() << " "
109  << (*vfecite)->getSigma() << " ";
110  ii++;
111  }
112  // dumpEntriesSubstraction( fout, *(*vfescite), 2, 4);
113  fout << std::endl;
114  fout2 << std::endl;
115  if (ALIUtils::debug >= 3)
116  std::cout << std::endl;
117  jj++;
118  }
119  fout.close();
120  fout2.close();
121 
123 }
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:34
static GlobalOptionMgr * getInstance()
ii
Definition: cuy.py:589
std::map< ALIstring, ALIdouble, std::less< ALIstring > > & GlobalOptions()
std::vector< FittedEntriesSet * > theFittedEntriesSets
std::string ALIstring
Definition: CocoaGlobals.h:9
static void dumpDimensions(std::ofstream &fout)
Definition: ALIUtils.cc:308

Member Data Documentation

◆ instance

FittedEntriesManager * FittedEntriesManager::instance = nullptr
staticprivate

Definition at line 33 of file FittedEntriesManager.h.

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

◆ theFittedEntriesSets

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

Definition at line 34 of file FittedEntriesManager.h.

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