CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
NtupleManager Class Reference

#include <NtupleManager.h>

Public Member Functions

void BookNtuple ()
 
void BookNtuple ()
 
void FillChi2 ()
 
void FillChi2 ()
 
void FillFitParameters (MatrixMeschach *AtWAMatrix)
 
void FillFitParameters (MatrixMeschach *AtWAMatrix)
 
void FillMeasurements ()
 
void FillMeasurements ()
 
void FillNtupleTree ()
 
void FillNtupleTree ()
 
void FillOptObjects (MatrixMeschach *AtWAMatrix)
 
void FillOptObjects (MatrixMeschach *AtWAMatrix)
 
void InitNtuple ()
 
void InitNtuple ()
 
 NtupleManager ()
 
 NtupleManager ()
 
void WriteNtuple ()
 
void WriteNtuple ()
 
 ~NtupleManager ()
 
 ~NtupleManager ()
 

Static Public Member Functions

static NtupleManagergetInstance ()
 
static NtupleManagergetInstance ()
 

Private Member Functions

void GetGlobalAngles (const CLHEP::HepRotation &rmGlob, double *theta)
 
void GetGlobalAngles (const CLHEP::HepRotation &rmGlob, double *theta)
 

Private Attributes

double Chi2CalibratedParameters
 
double Chi2Measurements
 
TClonesArray * CloneCopsMeas
 
TClonesArray * CloneDistancemeter1DimMeas
 
TClonesArray * CloneDistancemeterMeas
 
TClonesArray * CloneFitParam
 
TClonesArray * CloneOptObject
 
TClonesArray * CloneSensor2DMeas
 
TClonesArray * CloneTiltmeterMeas
 
TTree * CocoaTree
 
CopsMeasCopsMeasA
 
Distancemeter1DimMeasDistancemeter1DimMeasA
 
DistancemeterMeasDistancemeterMeasA
 
FitParamFitParamA
 
int NCops
 
int NDegreesOfFreedom
 
int NDistancemeter
 
int NDistancemeter1Dim
 
int NFitParameters
 
int NOptObjects
 
int NSensor2D
 
int NTiltmeter
 
OptObjectOptObjectA
 
Sensor2DMeasSensor2DMeasA
 
TFile * theRootFile
 
TiltmeterMeasTiltmeterMeasA
 

Static Private Attributes

static NtupleManagerinstance = 0
 

Detailed Description

Definition at line 20 of file NtupleManager.h.

Constructor & Destructor Documentation

NtupleManager::NtupleManager ( )
inline

Definition at line 25 of file NtupleManager.h.

Referenced by getInstance().

25 { };
NtupleManager::~NtupleManager ( )
inline

Definition at line 26 of file NtupleManager.h.

26 { };
NtupleManager::NtupleManager ( )
inline

Definition at line 25 of file NtupleManager.h.

25 { };
NtupleManager::~NtupleManager ( )
inline

Definition at line 26 of file NtupleManager.h.

26 { };

Member Function Documentation

void NtupleManager::BookNtuple ( )

Definition at line 41 of file NtupleManager.cc.

References Chi2CalibratedParameters, Chi2Measurements, CloneCopsMeas, CloneDistancemeter1DimMeas, CloneDistancemeterMeas, CloneFitParam, CloneOptObject, CloneSensor2DMeas, CloneTiltmeterMeas, CocoaTree, NCops, NDegreesOfFreedom, NDistancemeter, NDistancemeter1Dim, NFitParameters, NOptObjects, NSensor2D, NTiltmeter, and theRootFile.

Referenced by Fit::startFit().

42 {
43  theRootFile = new TFile("report.root","RECREATE","Simple ROOT Ntuple");
44 
45  CocoaTree = new TTree("CocoaTree","CocoaTree");
46 
47  CocoaTree->Branch("Chi2Measurements",&Chi2Measurements,"Chi2Measurements/D");
48  CocoaTree->Branch("Chi2CalibratedParameters",&Chi2CalibratedParameters,"Chi2CalibratedParameters/D");
49  CocoaTree->Branch("NDegreesOfFreedom",&NDegreesOfFreedom,"NDegreesOfFreedom/I");
50 
51  CloneFitParam = new TClonesArray("FitParam");
52  CocoaTree->Branch("FitParameters",&CloneFitParam,32000,2);
53  CocoaTree->Branch("NFitParameters",&NFitParameters,"NFitParameters/I");
54 
55  CloneOptObject = new TClonesArray("OptObject");
56  CocoaTree->Branch("OptObjects",&CloneOptObject,32000,2);
57  CocoaTree->Branch("NOptObjects",&NOptObjects,"NOptObjects/I");
58 
59  CloneSensor2DMeas = new TClonesArray("Sensor2DMeas");
60  CocoaTree->Branch("Sensor2DMeasurements",&CloneSensor2DMeas,32000,2);
61  CocoaTree->Branch("NSensor2D",&NSensor2D,"NSensor2D/I");
62 
63  CloneDistancemeterMeas = new TClonesArray("DistancemeterMeas");
64  CocoaTree->Branch("DistancemeterMeasurements",&CloneDistancemeterMeas,32000,2);
65  CocoaTree->Branch("NDistancemeter",&NDistancemeter,"NDistancemeter/I");
66 
67  CloneDistancemeter1DimMeas = new TClonesArray("Distancemeter1DimMeas");
68  CocoaTree->Branch("Distancemeter1DimMeasurements",&CloneDistancemeter1DimMeas,32000,2);
69  CocoaTree->Branch("NDistancemeter1Dim",&NDistancemeter1Dim,"NDistancemeter1Dim/I");
70 
71  CloneTiltmeterMeas = new TClonesArray("TiltmeterMeas");
72  CocoaTree->Branch("TiltmeterMeasurements",&CloneTiltmeterMeas,32000,2);
73  CocoaTree->Branch("NTiltmeter",&NTiltmeter,"NTiltmeter/I");
74 
75  CloneCopsMeas = new TClonesArray("CopsMeas");
76  CocoaTree->Branch("CopsMeasurements",&CloneCopsMeas,32000,2);
77  CocoaTree->Branch("NCops",&NCops,"NCops/I");
78 
79  theRootFile->Add(CocoaTree);
80 
81 // FitParametersTree = new TTree("FitParametersTree","FitParametersTree");
82 // FitParametersTree->Branch("NFitParameters",&NFitParameters,"NFitParameters/I");
83 // BookFitParameters = false;
84 // theRootFile->Add(FitParametersTree);
85 
86 // MeasurementsTree = new TTree("MeasurementsTree","MeasurementsTree");
87 // MeasurementsTree->Branch("NMeasurements",&NMeasurements,"NMeasurements/I");
88 // BookMeasurements = false;
89 // theRootFile->Add(MeasurementsTree);
90 
91 
92 }
int NDistancemeter1Dim
Definition: NtupleManager.h:66
TClonesArray * CloneFitParam
Definition: NtupleManager.h:49
TClonesArray * CloneSensor2DMeas
Definition: NtupleManager.h:51
TClonesArray * CloneOptObject
Definition: NtupleManager.h:50
TClonesArray * CloneDistancemeter1DimMeas
Definition: NtupleManager.h:53
TClonesArray * CloneTiltmeterMeas
Definition: NtupleManager.h:54
TFile * theRootFile
Definition: NtupleManager.h:43
double Chi2Measurements
Definition: NtupleManager.h:60
TClonesArray * CloneCopsMeas
Definition: NtupleManager.h:55
double Chi2CalibratedParameters
Definition: NtupleManager.h:60
TTree * CocoaTree
Definition: NtupleManager.h:45
TClonesArray * CloneDistancemeterMeas
Definition: NtupleManager.h:52
void NtupleManager::BookNtuple ( )
void NtupleManager::FillChi2 ( )
void NtupleManager::FillChi2 ( )

Definition at line 129 of file NtupleManager.cc.

References begin, Chi2CalibratedParameters, Chi2Measurements, Model::EntryList(), cuy::ii, Model::MeasurementList(), and NDegreesOfFreedom.

Referenced by Fit::fitNextEvent().

130 {
131  double chi2meas = 0;
132  double chi2cal = 0;
133  ALIint nMeas = 0, nUnk = 0;
134 
135  //----- Calculate the chi2 of measurements
136  std::vector< Measurement* >::const_iterator vmcite;
137  for ( vmcite = Model::MeasurementList().begin(); vmcite != Model::MeasurementList().end(); vmcite++) {
138  for ( ALIuint ii = 0; ii < ALIuint((*vmcite)->dim()); ii++ ){
139  nMeas++;
140  double c2 = ( (*vmcite)->value(ii) - (*vmcite)->valueSimulated(ii) ) / (*vmcite)->sigma(ii);
141  chi2meas += c2*c2;
142  }
143  }
144 
145  //----- Calculate the chi2 of calibrated parameters
146  std::vector< Entry* >::iterator veite;
147  for ( veite = Model::EntryList().begin();
148  veite != Model::EntryList().end(); veite++ ) {
149  if ( (*veite)->quality() == 2 ) nUnk++;
150  if ( (*veite)->quality() == 1 ) {
151 // std::cout << " " << (*veite)->valueDisplacementByFitting() << " "
152 // << (*veite)->value << " " << (*veite)->sigma() << std::endl;
153  double c2 = (*veite)->valueDisplacementByFitting() / (*veite)->sigma();
154  chi2cal += c2*c2;
155  }
156  }
157 
158  Chi2Measurements = chi2meas;
159  Chi2CalibratedParameters = chi2cal;
160  NDegreesOfFreedom = nMeas - nUnk;
161 
162 }
int ALIint
Definition: CocoaGlobals.h:15
int ii
Definition: cuy.py:588
static std::vector< Entry * > & EntryList()
Definition: Model.h:75
double Chi2Measurements
Definition: NtupleManager.h:60
#define begin
Definition: vmac.h:30
double Chi2CalibratedParameters
Definition: NtupleManager.h:60
static std::vector< Measurement * > & MeasurementList()
Definition: Model.h:79
unsigned int ALIuint
Definition: CocoaGlobals.h:17
void NtupleManager::FillFitParameters ( MatrixMeschach AtWAMatrix)
void NtupleManager::FillFitParameters ( MatrixMeschach AtWAMatrix)

Definition at line 166 of file NtupleManager.cc.

References begin, CloneOptObject, gather_cfg::cout, Model::EntryList(), FitParamA, FitParam::FittedSigma, FitParam::FittedValue, for(), FittedEntry::getEntryName(), FittedEntry::getName(), FittedEntry::getOptOName(), FittedEntry::getOrder(), FittedEntry::getOrigSigma(), FittedEntry::getOrigValue(), FittedEntry::getQuality(), FittedEntry::getSigma(), FittedEntry::getValue(), reco::if(), cuy::ii, FitParam::InitialSigma, FitParam::InitialValue, MatrixMeschach::Mat(), FitParam::Name, OptObject::Name, NFitParameters, NOptObjects, FitParam::OptObjectIndex, FitParam::Quality, and mathSSE::sqrt().

Referenced by Fit::fitNextEvent().

167 {
168 
169 // double ParValue[1000], ParError[1000];
170  int theMinEntryQuality = 1;
171  int ii = 0;
172  std::vector<Entry*>::const_iterator vecite;
173  for ( vecite = Model::EntryList().begin();
174  vecite != Model::EntryList().end(); vecite++ ) {
175 
176  //--- Only for good quality parameters (='unk')
177  if ( (*vecite)->quality() >= theMinEntryQuality ) {
178 
179  ALIint ipos = (*vecite)->fitPos();
180  FittedEntry* fe = new FittedEntry( (*vecite), ipos, sqrt(AtWAMatrix->Mat()->me[ipos][ipos]));
181 // if (!BookFitParameters) {
182 // CocoaTree->Branch("NFitParameters",&NFitParameters,"NFitParameters/I:");
183 // ALIstring partype = fe->getName() + "/D";
184 // FitParametersTree->Branch(fe->getName().c_str(), &ParValue[ii], partype.c_str());
185 // ALIstring parerrname = fe->getName() + "_err";
186 // ALIstring parerrtype = parerrname + "/D";
187 // FitParametersTree->Branch(parerrname.c_str(), &ParError[ii], parerrtype.c_str());
188 // }
189 // ParValue[ii] = fe->getValue();
190 // ParError[ii] = fe->getSigma();
191  std::cout << "EEE " << (*vecite)->ValueDimensionFactor() << " " << (*vecite)->SigmaDimensionFactor() << " " << fe->getOptOName() << " " << fe->getEntryName() << " " << fe->getName() << " " << fe->getOrder() << " " << fe->getQuality() << " " << (*vecite)->type() << " " << std::endl;
192  FitParamA = new( (*CloneFitParam)[ii] ) FitParam();
193  FitParamA->Name = fe->getName();
194  if (fe->getQuality()==1) FitParamA->Quality = "Calibrated";
195  else if (fe->getQuality()==2) FitParamA->Quality = "Unknown";
196  for (int no = 0; no<NOptObjects; no++) {
197  OptObject* optobj = (OptObject*) CloneOptObject->At(no);
198  if (optobj->Name==fe->getOptOName()) FitParamA->OptObjectIndex = no;
199  }
200  float DF = 1.;
201  if ((*vecite)->type()=="centre" || (*vecite)->type()=="length") DF = 1000.;
202  FitParamA->InitialValue = DF*fe->getOrigValue()*(*vecite)->ValueDimensionFactor();
203  FitParamA->InitialSigma = DF*fe->getOrigSigma()*(*vecite)->SigmaDimensionFactor();
204  FitParamA->FittedValue = DF*fe->getValue()*(*vecite)->ValueDimensionFactor();
205  FitParamA->FittedSigma = DF*fe->getSigma()*(*vecite)->SigmaDimensionFactor();
206  ii++;
207 
208  }
209 
210  }
211 // BookFitParameters = true;
212  NFitParameters = ii;
213 // FitParametersTree->Fill();
214 
215  /*
216  //---------- Loop sets of entries
217  std::vector< FittedEntriesSet* > theFittedEntriesSets;
218  std::vector< FittedEntriesSet* >::const_iterator vfescite;
219  std::vector< FittedEntry* >::const_iterator vfecite;
220  ALIint jj = 1;
221  for( vfescite = theFittedEntriesSets.begin(); vfescite != theFittedEntriesSets.end(); vfescite++) {
222  //---------- Loop entries
223  if( vfescite == theFittedEntriesSets.begin() ) {
224  //----- dump entries names if first set
225  ALIint ii = 0;
226  for( vfecite = ((*vfescite)->FittedEntries()).begin(); vfecite != ((*vfescite)->FittedEntries()).end(); vfecite++) {
227  ALIstring partype = (*vfecite)->getName() + "/D";
228  FitParametersTree->Branch((*vfecite)->getName().c_str(), &ParValue[ii], partype.c_str());
229  ALIstring parerrname = (*vfecite)->getName() + "_err";
230  ALIstring parerrtype = parerrname + "/D";
231  FitParametersTree->Branch(parerrname.c_str(), &ParError[ii], parerrtype.c_str());
232  ii++;
233  }
234  }
235  ALIint ii = 0;
236  for( vfecite = ((*vfescite)->FittedEntries()).begin(); vfecite != ((*vfescite)->FittedEntries()).end(); vfecite++) {
237  ParValue[ii] = (*vfecite)->getValue();
238  ParError[ii] = (*vfecite)->getSigma();
239  ii++;
240  }
241  NFitParameters = ii;
242  FitParametersTree->Fill();
243  jj++;
244  }
245  */
246 
247 }
ALIdouble getOrigValue() const
Definition: FittedEntry.h:45
ALIint getQuality() const
Definition: FittedEntry.h:54
TString Name
Definition: NtupleObjects.h:23
ALIstring getOptOName() const
Definition: FittedEntry.h:30
int ALIint
Definition: CocoaGlobals.h:15
ALIstring getName() const
Definition: FittedEntry.h:36
double FittedValue
Definition: NtupleObjects.h:20
int ii
Definition: cuy.py:588
static std::vector< Entry * > & EntryList()
Definition: Model.h:75
TClonesArray * CloneOptObject
Definition: NtupleManager.h:50
int OptObjectIndex
Definition: NtupleObjects.h:25
double InitialSigma
Definition: NtupleObjects.h:21
FitParam * FitParamA
Definition: NtupleManager.h:49
ALIdouble getOrigSigma() const
Definition: FittedEntry.h:48
T sqrt(T t)
Definition: SSEVec.h:48
ALIdouble getSigma() const
Definition: FittedEntry.h:42
TString Name
Definition: NtupleObjects.h:39
const MAT * Mat() const
ALIstring getEntryName() const
Definition: FittedEntry.h:33
for(const auto &pset:thresholds)
ALIint getOrder() const
Definition: FittedEntry.h:51
#define begin
Definition: vmac.h:30
double InitialValue
Definition: NtupleObjects.h:19
if(dp >Float(M_PI)) dp-
TString Quality
Definition: NtupleObjects.h:24
tuple cout
Definition: gather_cfg.py:121
ALIdouble getValue() const
Definition: FittedEntry.h:39
double FittedSigma
Definition: NtupleObjects.h:22
void NtupleManager::FillMeasurements ( )

Definition at line 307 of file NtupleManager.cc.

References TiltmeterMeas::AngError, TiltmeterMeas::Angle, begin, CloneOptObject, CopsMeasA, createTree::dd, DistancemeterMeas::DisError, Distancemeter1DimMeas::DisError, DistancemeterMeas::Distance, Distancemeter1DimMeas::Distance, Distancemeter1DimMeasA, DistancemeterMeasA, i, prof2calltree::last, Model::MeasurementList(), OptObject::Name, Sensor2DMeas::Name, DistancemeterMeas::Name, Distancemeter1DimMeas::Name, TiltmeterMeas::Name, CopsMeas::Name, NCops, NDistancemeter, NDistancemeter1Dim, NOptObjects, NSensor2D, NTiltmeter, Sensor2DMeas::OptObjectIndex, DistancemeterMeas::OptObjectIndex, Distancemeter1DimMeas::OptObjectIndex, TiltmeterMeas::OptObjectIndex, CopsMeas::OptObjectIndex, Sensor2DMeas::PosError, CopsMeas::PosError, Sensor2DMeas::Position, CopsMeas::Position, Sensor2DMeasA, TiltmeterMeas::SimulatedAngle, DistancemeterMeas::SimulatedDistance, Distancemeter1DimMeas::SimulatedDistance, Sensor2DMeas::SimulatedPosition, CopsMeas::SimulatedPosition, contentValuesCheck::ss, TiltmeterMeasA, and groupFilesInBlocks::tt.

Referenced by Fit::fitNextEvent().

308 {
309  //---------- Loop Measurements
310  int ss = 0, dd = 0, d1 = 0, tt = 0, cc = 0;
311  std::vector< Measurement* >::const_iterator vmcite;
312  for ( vmcite = Model::MeasurementList().begin(); vmcite != Model::MeasurementList().end(); vmcite++) {
313  std::vector<ALIstring> optonamelist = (*vmcite)->OptONameList();
314  int last = optonamelist.size() - 1; ALIstring LastOptOName = optonamelist[last];
315  int optoind = -999;
316  for (int no = 0; no<NOptObjects; no++) {
317  OptObject* optobj = (OptObject*) CloneOptObject->At(no);
318  if (optobj->Name==LastOptOName) optoind = no;
319  }
320  //std::cout << "DimSens " << (*vmcite)->type() << " " << (*vmcite)->sigma(0) << " " << LastOptOName << " " << optoind << std::endl;
321  if ((*vmcite)->type()=="SENSOR2D") {
322  Sensor2DMeasA = new( (*CloneSensor2DMeas)[ss] ) Sensor2DMeas();
323  Sensor2DMeasA->Name = (*vmcite)->name();
324  Sensor2DMeasA->OptObjectIndex = optoind;
325  for (ALIuint i = 0; i<(*vmcite)->dim(); i++) {
326  Sensor2DMeasA->Position[i] = 1000.*(*vmcite)->value()[i];
327  Sensor2DMeasA->PosError[i] = 1000.*(*vmcite)->sigma()[i];
328  Sensor2DMeasA->SimulatedPosition[i] = 1000.*(*vmcite)->valueSimulated(i);
329  }
330  ss++;
331  }
332  if ((*vmcite)->type()=="DISTANCEMETER") {
333  DistancemeterMeasA = new( (*CloneDistancemeterMeas)[dd] ) DistancemeterMeas();
334  DistancemeterMeasA->Name = (*vmcite)->name();
336  DistancemeterMeasA->Distance = 1000.*(*vmcite)->value()[0];
337  DistancemeterMeasA->DisError = 1000.*(*vmcite)->sigma()[0];
338  DistancemeterMeasA->SimulatedDistance = 1000.*(*vmcite)->valueSimulated(0);
339  dd++;
340  }
341  if ((*vmcite)->type()=="DISTANCEMETER1DIM") {
342  Distancemeter1DimMeasA = new( (*CloneDistancemeter1DimMeas)[d1] ) Distancemeter1DimMeas();
343  Distancemeter1DimMeasA->Name = (*vmcite)->name();
345  Distancemeter1DimMeasA->Distance = 1000.*(*vmcite)->value()[0];
346  Distancemeter1DimMeasA->DisError = 1000.*(*vmcite)->sigma()[0];
347  Distancemeter1DimMeasA->SimulatedDistance = 1000.*(*vmcite)->valueSimulated(0);
348  d1++;
349 
350  }
351  if ((*vmcite)->type()=="TILTMETER") {
352  TiltmeterMeasA = new( (*CloneTiltmeterMeas)[tt] ) TiltmeterMeas();
353  TiltmeterMeasA->Name = (*vmcite)->name();
354  TiltmeterMeasA->OptObjectIndex = optoind;
355  TiltmeterMeasA->Angle = (*vmcite)->value()[0];
356  TiltmeterMeasA->AngError = (*vmcite)->sigma()[0];
357  TiltmeterMeasA->SimulatedAngle = (*vmcite)->valueSimulated(0);
358  tt++;
359  }
360  if ((*vmcite)->type()=="COPS") {
361  CopsMeasA = new( (*CloneCopsMeas)[cc] ) CopsMeas();
362  CopsMeasA->Name = (*vmcite)->name();
363  CopsMeasA->OptObjectIndex = optoind;
364  for (ALIuint i = 0; i<(*vmcite)->dim(); i++) {
365  CopsMeasA->Position[i] = 1000.*(*vmcite)->value()[i];
366  CopsMeasA->PosError[i] = 1000.*(*vmcite)->sigma()[i];
367  CopsMeasA->SimulatedPosition[i] = 1000.*(*vmcite)->valueSimulated(i);
368  }
369  cc++;
370  }
371  }
372  NSensor2D = ss;
373  NDistancemeter = dd;
374  NDistancemeter1Dim = d1;
375  NTiltmeter = tt;
376  NCops = cc;
377  // MeasurementsTree->Fill();
378 }
int i
Definition: DBlmapReader.cc:9
Distancemeter1DimMeas * Distancemeter1DimMeasA
Definition: NtupleManager.h:53
double SimulatedDistance
Definition: NtupleObjects.h:67
int NDistancemeter1Dim
Definition: NtupleManager.h:66
double SimulatedPosition[4]
double Position[2]
Definition: NtupleObjects.h:51
double SimulatedAngle
Definition: NtupleObjects.h:95
TiltmeterMeas * TiltmeterMeasA
Definition: NtupleManager.h:54
TClonesArray * CloneOptObject
Definition: NtupleManager.h:50
double SimulatedPosition[2]
Definition: NtupleObjects.h:53
TString Name
Definition: NtupleObjects.h:54
Sensor2DMeas * Sensor2DMeasA
Definition: NtupleManager.h:51
TString Name
Definition: NtupleObjects.h:39
double PosError[4]
DistancemeterMeas * DistancemeterMeasA
Definition: NtupleManager.h:52
CopsMeas * CopsMeasA
Definition: NtupleManager.h:55
double PosError[2]
Definition: NtupleObjects.h:52
#define begin
Definition: vmac.h:30
std::string ALIstring
Definition: CocoaGlobals.h:9
TString Name
double Position[4]
int OptObjectIndex
static std::vector< Measurement * > & MeasurementList()
Definition: Model.h:79
unsigned int ALIuint
Definition: CocoaGlobals.h:17
void NtupleManager::FillMeasurements ( )
void NtupleManager::FillNtupleTree ( )

Definition at line 114 of file NtupleManager.cc.

References CocoaTree.

Referenced by Fit::fitNextEvent().

115 {
116  CocoaTree->Fill();
117 }
TTree * CocoaTree
Definition: NtupleManager.h:45
void NtupleManager::FillNtupleTree ( )
void NtupleManager::FillOptObjects ( MatrixMeschach AtWAMatrix)

Definition at line 251 of file NtupleManager.cc.

References OptObject::AnglesGlobal, OptObject::AnglesLocal, begin, OptObject::CentreGlobal, OptObject::CentreLocal, GetGlobalAngles(), i, cuy::ii, OptObject::Name, NOptObjects, OptObjectA, Model::OptOList(), OptObject::Parent, createTree::pp, theta(), OptObject::Type, XCoor, YCoor, and ZCoor.

Referenced by Fit::fitNextEvent().

252 {
253 
254  int ii = 0;
255  std::vector< OpticalObject* >::const_iterator vecobj;
256  for ( vecobj = Model::OptOList().begin();
257  vecobj != Model::OptOList().end(); vecobj++ ) {
258  OptObjectA = new( (*CloneOptObject)[ii] ) OptObject();
259 
260  OptObjectA->Name = (*vecobj)->name();
261  OptObjectA->Type = (*vecobj)->type();
262 
263  if (!(*vecobj)->parent()) {
264  OptObjectA->Parent = ii;
265  ii++;
266  continue;
267  }
268 
269  int pp = 0;
270  std::vector< OpticalObject* >::const_iterator vecobj2;
271  for ( vecobj2 = Model::OptOList().begin();
272  vecobj2 != Model::OptOList().end(); vecobj2++ ) {
273  if ((*vecobj2)->name()==(*vecobj)->parent()->name()) {
274  OptObjectA->Parent = pp;
275  continue;
276  }
277  pp++;
278  }
279 
280  OptObjectA->CentreGlobal[0] = 1000.*(*vecobj)->centreGlobal().x();
281  OptObjectA->CentreGlobal[1] = 1000.*(*vecobj)->centreGlobal().y();
282  OptObjectA->CentreGlobal[2] = 1000.*(*vecobj)->centreGlobal().z();
283 
284  OptObjectA->CentreLocal[0] = 1000.*(*vecobj)->centreLocal().x();
285  OptObjectA->CentreLocal[1] = 1000.*(*vecobj)->centreLocal().y();
286  OptObjectA->CentreLocal[2] = 1000.*(*vecobj)->centreLocal().z();
287 
288  OptObjectA->AnglesLocal[0] = (*vecobj)->getEntryRMangle(XCoor);
289  OptObjectA->AnglesLocal[1] = (*vecobj)->getEntryRMangle(YCoor);
290  OptObjectA->AnglesLocal[2] = (*vecobj)->getEntryRMangle(ZCoor);
291 
292  double theta[3];
293  GetGlobalAngles((*vecobj)->rmGlob(), theta);
294  for (int i = 0; i<3; i++) OptObjectA->AnglesGlobal[i] = theta[i];
295 
296  ii++;
297 
298  }
299 
300  NOptObjects = ii;
301 
302 
303 }
OptObject * OptObjectA
Definition: NtupleManager.h:50
int i
Definition: DBlmapReader.cc:9
tuple pp
Definition: createTree.py:15
void GetGlobalAngles(const CLHEP::HepRotation &rmGlob, double *theta)
Geom::Theta< T > theta() const
int ii
Definition: cuy.py:588
TString Name
Definition: NtupleObjects.h:39
double AnglesLocal[3]
Definition: NtupleObjects.h:38
static std::vector< OpticalObject * > & OptOList()
Definition: Model.h:71
double CentreLocal[3]
Definition: NtupleObjects.h:37
double AnglesGlobal[3]
Definition: NtupleObjects.h:36
#define begin
Definition: vmac.h:30
double CentreGlobal[3]
Definition: NtupleObjects.h:35
TString Type
Definition: NtupleObjects.h:40
void NtupleManager::FillOptObjects ( MatrixMeschach AtWAMatrix)
void NtupleManager::GetGlobalAngles ( const CLHEP::HepRotation &  rmGlob,
double *  theta 
)
private

Definition at line 382 of file NtupleManager.cc.

References alpha, beta, funct::cos(), gather_cfg::cout, alignCSCRings::e, M_PI, funct::sin(), and create_public_lumi_plots::xy.

Referenced by FillOptObjects().

383 {
384 
385  double xx = rmGlob.xx(); if (fabs(xx)<1.e-08) xx = 0.;
386  double xy = rmGlob.xy(); if (fabs(xy)<1.e-08) xy = 0.;
387  double xz = rmGlob.xz(); if (fabs(xz)<1.e-08) xz = 0.;
388  double yx = rmGlob.yx(); if (fabs(yx)<1.e-08) yx = 0.;
389  double yy = rmGlob.yy(); if (fabs(yy)<1.e-08) yy = 0.;
390  double yz = rmGlob.yz(); if (fabs(yz)<1.e-08) yz = 0.;
391  double zx = rmGlob.zx(); if (fabs(zx)<1.e-08) zx = 0.;
392  double zy = rmGlob.zy(); if (fabs(zy)<1.e-08) zy = 0.;
393  double zz = rmGlob.zz(); if (fabs(zz)<1.e-08) zz = 0.;
394 
395  double beta = asin(-zx);
396 
397  double alpha, gamma;
398  if (fabs(zx)!=1.) {
399 
400  double sinalpha = zy/cos(beta);
401  double cosalpha = zz/cos(beta);
402  if (cosalpha>=0) alpha = asin(sinalpha);
403  else alpha = M_PI - asin(sinalpha);
404  if (alpha>M_PI) alpha -= 2*M_PI;
405 
406  double singamma = yx/cos(beta);
407  double cosgamma = xx/cos(beta);
408  if (cosgamma>=0) gamma = asin(singamma);
409  else gamma = M_PI - asin(singamma);
410  if (gamma>M_PI) gamma -= 2*M_PI;
411 
412  } else {
413 
414  alpha = 0.;
415 
416  double singamma = yz/sin(beta);
417  double cosgamma = yy;
418  if (cosgamma>=0) gamma = asin(singamma);
419  else gamma = M_PI - asin(singamma);
420  if (gamma>M_PI) gamma -= 2*M_PI;
421 
422  }
423 
424  int GotGlobalAngles = 0;
425  if (fabs(xy-(sin(alpha)*sin(beta)*cos(gamma)-sin(gamma)*cos(alpha)))>1.e-08)
426  GotGlobalAngles += 1;
427  if (fabs(xz-(cos(alpha)*sin(beta)*cos(gamma)+sin(gamma)*sin(alpha)))>1.e-08)
428  GotGlobalAngles += 10;
429  if (fabs(yy-(sin(alpha)*sin(beta)*sin(gamma)+cos(gamma)*cos(alpha)))>1.e-08)
430  GotGlobalAngles += 100;
431  if (fabs(yz-(cos(alpha)*sin(beta)*sin(gamma)-cos(gamma)*sin(alpha)))>1.e-08)
432  GotGlobalAngles += 1000;
433  if (GotGlobalAngles>0)
434  std::cout << "NtupleManager Warning: cannot get global rotation: "
435  << GotGlobalAngles << std::endl;
436 
437  theta[0] = alpha;
438  theta[1] = beta;
439  theta[2] = gamma;
440 
441 }
const double beta
float alpha
Definition: AMPTWrapper.h:95
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
#define M_PI
tuple cout
Definition: gather_cfg.py:121
void NtupleManager::GetGlobalAngles ( const CLHEP::HepRotation &  rmGlob,
double *  theta 
)
private
NtupleManager * NtupleManager::getInstance ( )
static

Definition at line 29 of file NtupleManager.cc.

References instance, and NtupleManager().

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

30 {
31  if(!instance) {
32  instance = new NtupleManager;
33  }
34  return instance;
35 }
static NtupleManager * instance
Definition: NtupleManager.h:39
static NtupleManager* NtupleManager::getInstance ( )
static
void NtupleManager::InitNtuple ( )
void NtupleManager::InitNtuple ( )

Definition at line 96 of file NtupleManager.cc.

References Chi2CalibratedParameters, Chi2Measurements, CloneFitParam, NCops, NDegreesOfFreedom, NDistancemeter, NDistancemeter1Dim, NFitParameters, NOptObjects, NSensor2D, and NTiltmeter.

Referenced by Fit::fitNextEvent().

97 {
98  CloneFitParam->Clear();
99 
100  Chi2Measurements = 0.;
102  NDegreesOfFreedom = 0;
103  NFitParameters = 0;
104  NOptObjects = 0;
105  NSensor2D = 0;
106  NDistancemeter = 0;
107  NDistancemeter1Dim = 0;
108  NTiltmeter = 0;
109  NCops = 0;
110 }
int NDistancemeter1Dim
Definition: NtupleManager.h:66
TClonesArray * CloneFitParam
Definition: NtupleManager.h:49
double Chi2Measurements
Definition: NtupleManager.h:60
double Chi2CalibratedParameters
Definition: NtupleManager.h:60
void NtupleManager::WriteNtuple ( )
void NtupleManager::WriteNtuple ( )

Definition at line 121 of file NtupleManager.cc.

References theRootFile.

Referenced by Fit::startFit().

122 {
123  theRootFile->Write();
124  theRootFile->Close();
125 }
TFile * theRootFile
Definition: NtupleManager.h:43

Member Data Documentation

double NtupleManager::Chi2CalibratedParameters
private

Definition at line 60 of file NtupleManager.h.

Referenced by BookNtuple(), FillChi2(), and InitNtuple().

double NtupleManager::Chi2Measurements
private

Definition at line 60 of file NtupleManager.h.

Referenced by BookNtuple(), FillChi2(), and InitNtuple().

TClonesArray * NtupleManager::CloneCopsMeas
private

Definition at line 55 of file NtupleManager.h.

Referenced by BookNtuple().

TClonesArray * NtupleManager::CloneDistancemeter1DimMeas
private

Definition at line 53 of file NtupleManager.h.

Referenced by BookNtuple().

TClonesArray * NtupleManager::CloneDistancemeterMeas
private

Definition at line 52 of file NtupleManager.h.

Referenced by BookNtuple().

TClonesArray * NtupleManager::CloneFitParam
private

Definition at line 49 of file NtupleManager.h.

Referenced by BookNtuple(), and InitNtuple().

TClonesArray * NtupleManager::CloneOptObject
private

Definition at line 50 of file NtupleManager.h.

Referenced by BookNtuple(), FillFitParameters(), and FillMeasurements().

TClonesArray * NtupleManager::CloneSensor2DMeas
private

Definition at line 51 of file NtupleManager.h.

Referenced by BookNtuple().

TClonesArray * NtupleManager::CloneTiltmeterMeas
private

Definition at line 54 of file NtupleManager.h.

Referenced by BookNtuple().

TTree * NtupleManager::CocoaTree
private

Definition at line 45 of file NtupleManager.h.

Referenced by BookNtuple(), and FillNtupleTree().

CopsMeas * NtupleManager::CopsMeasA
private

Definition at line 55 of file NtupleManager.h.

Referenced by FillMeasurements().

Distancemeter1DimMeas * NtupleManager::Distancemeter1DimMeasA
private

Definition at line 53 of file NtupleManager.h.

Referenced by FillMeasurements().

DistancemeterMeas * NtupleManager::DistancemeterMeasA
private

Definition at line 52 of file NtupleManager.h.

Referenced by FillMeasurements().

FitParam * NtupleManager::FitParamA
private

Definition at line 49 of file NtupleManager.h.

Referenced by FillFitParameters().

NtupleManager * NtupleManager::instance = 0
staticprivate

Definition at line 39 of file NtupleManager.h.

Referenced by getInstance().

int NtupleManager::NCops
private

Definition at line 68 of file NtupleManager.h.

Referenced by BookNtuple(), FillMeasurements(), and InitNtuple().

int NtupleManager::NDegreesOfFreedom
private

Definition at line 61 of file NtupleManager.h.

Referenced by BookNtuple(), FillChi2(), and InitNtuple().

int NtupleManager::NDistancemeter
private

Definition at line 65 of file NtupleManager.h.

Referenced by BookNtuple(), FillMeasurements(), and InitNtuple().

int NtupleManager::NDistancemeter1Dim
private

Definition at line 66 of file NtupleManager.h.

Referenced by BookNtuple(), FillMeasurements(), and InitNtuple().

int NtupleManager::NFitParameters
private

Definition at line 62 of file NtupleManager.h.

Referenced by BookNtuple(), FillFitParameters(), and InitNtuple().

int NtupleManager::NOptObjects
private
int NtupleManager::NSensor2D
private

Definition at line 64 of file NtupleManager.h.

Referenced by BookNtuple(), FillMeasurements(), and InitNtuple().

int NtupleManager::NTiltmeter
private

Definition at line 67 of file NtupleManager.h.

Referenced by BookNtuple(), FillMeasurements(), and InitNtuple().

OptObject * NtupleManager::OptObjectA
private

Definition at line 50 of file NtupleManager.h.

Referenced by FillOptObjects().

Sensor2DMeas * NtupleManager::Sensor2DMeasA
private

Definition at line 51 of file NtupleManager.h.

Referenced by FillMeasurements().

TFile * NtupleManager::theRootFile
private

Definition at line 43 of file NtupleManager.h.

Referenced by BookNtuple(), and WriteNtuple().

TiltmeterMeas * NtupleManager::TiltmeterMeasA
private

Definition at line 54 of file NtupleManager.h.

Referenced by FillMeasurements().