CMS 3D CMS Logo

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

#include <CocoaDaqReaderRoot.h>

Inheritance diagram for CocoaDaqReaderRoot:
CocoaDaqReader

Public Member Functions

void BuildMeasurementsFromOptAlign (std::vector< OpticalAlignMeasurementInfo > &measList) override
 
 CocoaDaqReaderRoot (const std::string &m_inFileName)
 
int GetNEvents () const
 
bool ReadEvent (int nev) override
 
bool ReadNextEvent () override
 
 ~CocoaDaqReaderRoot () override
 
- Public Member Functions inherited from CocoaDaqReader
 CocoaDaqReader ()
 
int GetNEvents () const
 
virtual ~CocoaDaqReader ()
 

Private Member Functions

OpticalAlignMeasurementInfo GetMeasFromDist (AliDaqDistance *dist)
 
OpticalAlignMeasurementInfo GetMeasFromPosition2D (AliDaqPosition2D *pos2D)
 
OpticalAlignMeasurementInfo GetMeasFromPositionCOPS (AliDaqPositionCOPS *posCOPS)
 
OpticalAlignMeasurementInfo GetMeasFromTilt (AliDaqTilt *tilt)
 

Private Attributes

int nev
 
int nextEvent
 
CocoaDaqRootEventtheEvent
 
TFile * theFile
 
TTree * theTree
 

Additional Inherited Members

- Static Public Member Functions inherited from CocoaDaqReader
static CocoaDaqReaderGetDaqReader ()
 
static void SetDaqReader (CocoaDaqReader *reader)
 
- Protected Attributes inherited from CocoaDaqReader
int nev
 
int nextEvent
 

Detailed Description

Definition at line 13 of file CocoaDaqReaderRoot.h.

Constructor & Destructor Documentation

CocoaDaqReaderRoot::CocoaDaqReaderRoot ( const std::string &  m_inFileName)

Definition at line 16 of file CocoaDaqReaderRoot.cc.

References MicroEventContent_cff::branch, beam_dqm_sourceclient-live_cfg::cerr, gather_cfg::cout, ALIUtils::debug, cppFunctionSkipper::exception, nev, nextEvent, CocoaDaqReader::SetDaqReader(), theEvent, theFile, and theTree.

16  {
17  if (ALIUtils::debug >= 3)
18  std::cout << " CocoaDaqReaderRoot opening file: " << m_inFileName << std::endl;
19  // Open root file
20  theFile = new TFile(m_inFileName.c_str());
21  if (!theTree) {
22  std::cerr << " CocoaDaqReaderRoot TTree file not found " << m_inFileName << std::endl;
23  throw std::exception();
24  }
25 
26  // Read TTree named "CocoaDaq" in memory. !! SHOULD BE CALLED Alignment_Cocoa
27  theTree = (TTree*)theFile->Get("CocoaDaq");
28  // theTree = (TTree*)theFile->Get("Alignment_Link_Cocoa");
29 
30  if (!theTree) {
31  std::cerr << " CocoaDaqReaderRoot TTree in file " << m_inFileName << " should be called 'CocoaDaq' " << std::endl;
32  throw std::exception();
33  }
34  TBranch* branch = theTree->GetBranch("Alignment_Cocoa");
35 
36  nev = branch->GetEntries(); // number of entries in Tree
37  //if ( ALIUtils::debug >= 2) std::cout << "CocoaDaqReaderRoot::CocoaDaqReaderRoot: number of entries in Tree " << nev << std::endl;
38 
39  nextEvent = 0;
40 
41  // Event object must be created before setting the branch address
43 
44  // link pointer to Tree branch
45  theTree->SetBranchAddress("Alignment_Cocoa", &theEvent); // !! SHOULD BE CALLED Alignment_Cocoa
46  // theTree->SetBranchAddress("Alignment_Link", &theEvent); // !! SHOULD BE CALLED Alignment_Cocoa
47 
49 }
static ALIint debug
Definition: ALIUtils.h:34
CocoaDaqRootEvent * theEvent
static void SetDaqReader(CocoaDaqReader *reader)
CocoaDaqReaderRoot::~CocoaDaqReaderRoot ( )
override

Definition at line 52 of file CocoaDaqReaderRoot.cc.

References theFile.

52 { theFile->Close(); }

Member Function Documentation

void CocoaDaqReaderRoot::BuildMeasurementsFromOptAlign ( std::vector< OpticalAlignMeasurementInfo > &  measList)
overridevirtual

Reimplemented from CocoaDaqReader.

Definition at line 242 of file CocoaDaqReaderRoot.cc.

References begin, beam_dqm_sourceclient-live_cfg::cerr, gather_cfg::cout, ALIUtils::debug, beamvalidation::exit(), cuy::ii, findQualityFiles::jj, Model::MeasurementList(), OpticalAlignMeasurementInfo::name_, heppy_report::oname, OpticalAlignMeasurementInfo::type_, and OpticalAlignMeasurementInfo::values_.

Referenced by ReadEvent().

242  {
243  if (ALIUtils::debug >= 3)
244  std::cout << "@@@ CocoaDaqReaderRoot::BuildMeasurementsFromOptAlign " << std::endl;
245 
246  //set date and time of current measurement
247  // if( wordlist[0] == "DATE:" ) {
248  // Measurement::setCurrentDate( wordlist );
249  // }
250 
251  //---------- loop measurements read from ROOT and check for corresponding measurement in Model
252  // ALIint nMeasModel = Model::MeasurementList().size();
253  ALIint nMeasRoot = measList.size();
254  if (ALIUtils::debug >= 4) {
255  std::cout << " Building " << nMeasRoot << " measurements from ROOT file " << std::endl;
256  }
257 
258  //--- Loop to Measurements in Model and check for corresponding measurement in ROOT
259  std::vector<Measurement*>::const_iterator vmcite;
260  for (vmcite = Model::MeasurementList().begin(); vmcite != Model::MeasurementList().end(); ++vmcite) {
261  ALIint fcolon = (*vmcite)->name().find(':');
262  ALIstring oname = (*vmcite)->name();
263  oname = oname.substr(fcolon + 1, oname.length());
264 
265  //---------- loop measurements read from ROOT
266  ALIint ii;
267  for (ii = 0; ii < nMeasRoot; ii++) {
268  OpticalAlignMeasurementInfo measInfo = measList[ii];
269  std::cout << " measurement name ROOT " << measInfo.name_ << " Model= " << (*vmcite)->name() << " short " << oname
270  << std::endl;
271 
272  if (oname == measInfo.name_) {
273  //-------- Measurement found, fill data
274  //---- Check that type is the same
275  if ((*vmcite)->type() != measInfo.type_) {
276  std::cerr << "!!! Measurement from ROOT file: type in file is " << measInfo.type_ << " and should be "
277  << (*vmcite)->type() << std::endl;
278  exit(1);
279  }
280 
281  std::cout << " NOBJECTS IN MEAS " << (*vmcite)->OptOList().size() << " NMEAS "
282  << Model::MeasurementList().size() << std::endl;
283 
284  std::vector<OpticalAlignParam> measValues = measInfo.values_;
285 
286  for (size_t jj = 0; jj < measValues.size(); jj++) {
287  (*vmcite)->fillData(jj, &(measValues[jj]));
288  }
289 
290  std::cout << " NOBJECTS IN MEAS after " << (*vmcite)->OptOList().size() << " NMEAS "
291  << Model::MeasurementList().size() << std::endl;
292 
293  break;
294  }
295  }
296  if (ii == nMeasRoot) {
297  std::cerr << "!!! Reading measurement from file: measurement not found! Type in list is " << oname << std::endl;
298  exit(1);
299  }
300  }
301 }
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:34
ii
Definition: cuy.py:590
#define begin
Definition: vmac.h:32
std::string ALIstring
Definition: CocoaGlobals.h:9
std::vector< OpticalAlignParam > values_
static std::vector< Measurement * > & MeasurementList()
Definition: Model.h:88
def exit(msg="")
OpticalAlignMeasurementInfo CocoaDaqReaderRoot::GetMeasFromDist ( AliDaqDistance dist)
private

Definition at line 218 of file CocoaDaqReaderRoot.cc.

References OpticalAlignParam::error_, AliDaqDistance::GetDistance(), AliDaqDistance::GetDistanceError(), AliDaqDistance::GetID(), OpticalAlignMeasurementInfo::isSimulatedValue_, findQualityFiles::jj, OpticalAlignMeasurementInfo::name_, OpticalAlignParam::name_, AlCaHLTBitMon_QueryRunRegistry::string, OpticalAlignMeasurementInfo::type_, OpticalAlignParam::value_, and OpticalAlignMeasurementInfo::values_.

Referenced by GetNEvents(), and ReadEvent().

218  {
220 
221  meas.type_ = "DISTANCEMETER";
222  meas.name_ = std::string(dist->GetID().Data());
223  //- std::vector<std::string> measObjectNames_;
224  std::vector<bool> isSimu;
225  for (size_t jj = 0; jj < 2; jj++) {
226  isSimu.push_back(false);
227  }
228  meas.isSimulatedValue_ = isSimu;
229  std::vector<OpticalAlignParam> paramList;
230  OpticalAlignParam oaParam;
231  oaParam.name_ = "D:";
232  oaParam.value_ = dist->GetDistance() / 100.;
233  oaParam.error_ = dist->GetDistanceError() / 100.;
234  paramList.push_back(oaParam);
235 
236  meas.values_ = paramList;
237 
238  return meas;
239 }
Float_t GetDistanceError() const
Float_t GetDistance() const
std::vector< OpticalAlignParam > values_
OpticalAlignMeasurementInfo CocoaDaqReaderRoot::GetMeasFromPosition2D ( AliDaqPosition2D pos2D)
private

Definition at line 121 of file CocoaDaqReaderRoot.cc.

References OpticalAlignParam::error_, AliDaqPosition2D::GetID(), AliDaqPosition2D::GetX(), AliDaqPosition2D::GetXerror(), AliDaqPosition2D::GetY(), AliDaqPosition2D::GetYerror(), OpticalAlignMeasurementInfo::isSimulatedValue_, findQualityFiles::jj, OpticalAlignMeasurementInfo::name_, OpticalAlignParam::name_, AlCaHLTBitMon_QueryRunRegistry::string, OpticalAlignMeasurementInfo::type_, OpticalAlignParam::value_, and OpticalAlignMeasurementInfo::values_.

Referenced by GetNEvents(), and ReadEvent().

121  {
123 
124  meas.type_ = "SENSOR2D";
125  meas.name_ = std::string(pos2D->GetID().Data());
126  //- std::vector<std::string> measObjectNames_;
127  std::vector<bool> isSimu;
128  for (size_t jj = 0; jj < 2; jj++) {
129  isSimu.push_back(false);
130  }
131  meas.isSimulatedValue_ = isSimu;
132  std::vector<OpticalAlignParam> paramList;
133  OpticalAlignParam oaParam1;
134  oaParam1.name_ = "H:";
135  oaParam1.value_ = pos2D->GetX() / 100.;
136  oaParam1.error_ = pos2D->GetXerror() / 100.;
137  paramList.push_back(oaParam1);
138 
139  OpticalAlignParam oaParam2;
140  oaParam2.name_ = "V:";
141  oaParam2.value_ = pos2D->GetY() / 100.;
142  oaParam2.error_ = pos2D->GetYerror() / 100.;
143  paramList.push_back(oaParam2);
144 
145  meas.values_ = paramList;
146 
147  return meas;
148 }
Float_t GetX() const
Float_t GetYerror() const
Float_t GetXerror() const
Float_t GetY() const
std::vector< OpticalAlignParam > values_
OpticalAlignMeasurementInfo CocoaDaqReaderRoot::GetMeasFromPositionCOPS ( AliDaqPositionCOPS posCOPS)
private

Definition at line 151 of file CocoaDaqReaderRoot.cc.

References OpticalAlignParam::error_, AliDaqPositionCOPS::GetDown(), AliDaqPositionCOPS::GetDownError(), AliDaqPositionCOPS::GetID(), AliDaqPositionCOPS::GetLeft(), AliDaqPositionCOPS::GetLeftError(), AliDaqPositionCOPS::GetRight(), AliDaqPositionCOPS::GetRightError(), AliDaqPositionCOPS::GetUp(), AliDaqPositionCOPS::GetUpError(), OpticalAlignMeasurementInfo::isSimulatedValue_, findQualityFiles::jj, OpticalAlignMeasurementInfo::name_, OpticalAlignParam::name_, AlCaHLTBitMon_QueryRunRegistry::string, OpticalAlignMeasurementInfo::type_, OpticalAlignParam::value_, and OpticalAlignMeasurementInfo::values_.

Referenced by GetNEvents(), and ReadEvent().

151  {
153 
154  meas.type_ = "COPS";
155  meas.name_ = std::string(posCOPS->GetID().Data());
156  //- std::vector<std::string> measObjectNames_;
157  std::vector<bool> isSimu;
158  for (size_t jj = 0; jj < 4; jj++) {
159  isSimu.push_back(false);
160  }
161  meas.isSimulatedValue_ = isSimu;
162 
163  std::vector<OpticalAlignParam> paramList;
164  OpticalAlignParam oaParam1;
165  oaParam1.name_ = "U:";
166  oaParam1.value_ = posCOPS->GetUp() / 100.;
167  oaParam1.error_ = posCOPS->GetUpError() / 100.;
168  paramList.push_back(oaParam1);
169 
170  OpticalAlignParam oaParam2;
171  oaParam2.name_ = "U:";
172  oaParam2.value_ = posCOPS->GetDown() / 100.;
173  oaParam2.error_ = posCOPS->GetDownError() / 100.;
174  paramList.push_back(oaParam2);
175 
176  OpticalAlignParam oaParam3;
177  oaParam3.name_ = "U:";
178  oaParam3.value_ = posCOPS->GetRight() / 100.;
179  oaParam3.error_ = posCOPS->GetRightError() / 100.;
180  paramList.push_back(oaParam3);
181 
182  OpticalAlignParam oaParam4;
183  oaParam4.name_ = "U:";
184  oaParam4.value_ = posCOPS->GetLeft() / 100.;
185  oaParam4.error_ = posCOPS->GetLeftError() / 100.;
186  paramList.push_back(oaParam4);
187 
188  meas.values_ = paramList;
189 
190  return meas;
191 }
Float_t GetUpError() const
Float_t GetLeft() const
Float_t GetRight() const
Float_t GetLeftError() const
Float_t GetDownError() const
std::vector< OpticalAlignParam > values_
Float_t GetDown() const
Float_t GetUp() const
Float_t GetRightError() const
OpticalAlignMeasurementInfo CocoaDaqReaderRoot::GetMeasFromTilt ( AliDaqTilt tilt)
private

Definition at line 194 of file CocoaDaqReaderRoot.cc.

References OpticalAlignParam::error_, AliDaqTilt::GetID(), AliDaqTilt::GetTilt(), AliDaqTilt::GetTiltError(), OpticalAlignMeasurementInfo::isSimulatedValue_, findQualityFiles::jj, OpticalAlignMeasurementInfo::name_, OpticalAlignParam::name_, AlCaHLTBitMon_QueryRunRegistry::string, OpticalAlignMeasurementInfo::type_, OpticalAlignParam::value_, and OpticalAlignMeasurementInfo::values_.

Referenced by GetNEvents(), and ReadEvent().

194  {
196 
197  meas.type_ = "TILTMETER";
198  meas.name_ = std::string(tilt->GetID().Data());
199  //- std::vector<std::string> measObjectNames_;
200  std::vector<bool> isSimu;
201  for (size_t jj = 0; jj < 2; jj++) {
202  isSimu.push_back(false);
203  }
204  meas.isSimulatedValue_ = isSimu;
205  std::vector<OpticalAlignParam> paramList;
206  OpticalAlignParam oaParam;
207  oaParam.name_ = "T:";
208  oaParam.value_ = tilt->GetTilt();
209  oaParam.error_ = tilt->GetTiltError();
210  paramList.push_back(oaParam);
211 
212  meas.values_ = paramList;
213 
214  return meas;
215 }
Float_t GetTilt() const
TString GetID()
Float_t GetTiltError() const
std::vector< OpticalAlignParam > values_
int CocoaDaqReaderRoot::GetNEvents ( ) const
inline
bool CocoaDaqReaderRoot::ReadEvent ( int  nev)
overridevirtual

Reimplemented from CocoaDaqReader.

Definition at line 58 of file CocoaDaqReaderRoot.cc.

References BuildMeasurementsFromOptAlign(), gather_cfg::cout, ALIUtils::debug, AliDaqPosition2D::DumpIt(), AliDaqPositionCOPS::DumpIt(), AliDaqTilt::DumpIt(), AliDaqDistance::DumpIt(), CocoaDaqRootEvent::DumpIt(), CocoaDaqRootEvent::GetArray_Dist(), CocoaDaqRootEvent::GetArray_Position2D(), CocoaDaqRootEvent::GetArray_PositionCOPS(), CocoaDaqRootEvent::GetArray_Tilt(), AliDaqPosition2D::GetID(), AliDaqPositionCOPS::GetID(), AliDaqTilt::GetID(), AliDaqDistance::GetID(), GetMeasFromDist(), GetMeasFromPosition2D(), GetMeasFromPositionCOPS(), GetMeasFromTilt(), CocoaDaqRootEvent::GetNumDist(), CocoaDaqRootEvent::GetNumPos2D(), CocoaDaqRootEvent::GetNumPosCOPS(), CocoaDaqRootEvent::GetNumTilt(), cuy::ii, dqmiodumpmetadata::n, nextEvent, theEvent, and theTree.

Referenced by ReadNextEvent().

58  {
59  std::vector<OpticalAlignMeasurementInfo> measList;
60 
61  int nb = 0; // dummy, number of bytes
62  // Loop over all events
63  nb = theTree->GetEntry(nev); // read in entire event
64 
65  if (ALIUtils::debug >= 3)
66  std::cout << "CocoaDaqReaderRoot reading event " << nev << " " << nb << std::endl;
67  if (nb == 0)
68  return false; //end of file reached??
69 
70  // Every n events, dump one to screen
71  int n = 1;
72  if (nev % n == 0 && ALIUtils::debug >= 3)
73  theEvent->DumpIt();
74 
75  //if ( ALIUtils::debug >= 3) std::cout<<" CocoaDaqReaderRoot::ReadEvent "<< nev <<std::endl;
76 
77  if (ALIUtils::debug >= 3)
78  std::cout << " CocoaDaqReaderRoot::ReadEvent npos2D " << theEvent->GetNumPos2D() << " nCOPS "
79  << theEvent->GetNumPosCOPS() << std::endl;
80 
81  for (int ii = 0; ii < theEvent->GetNumPos2D(); ii++) {
83  if (ALIUtils::debug >= 4)
84  std::cout << "2D sensor " << ii << " has ID = " << pos2D->GetID() << std::endl;
85  pos2D->DumpIt("2DSENSOR");
86  measList.push_back(GetMeasFromPosition2D(pos2D));
87  }
88  for (int ii = 0; ii < theEvent->GetNumPosCOPS(); ii++) {
90  measList.push_back(GetMeasFromPositionCOPS(posCOPS));
91  if (ALIUtils::debug >= 4) {
92  std::cout << "COPS sensor " << ii << " has ID = " << posCOPS->GetID() << std::endl;
93  posCOPS->DumpIt("COPS");
94  }
95  }
96  for (int ii = 0; ii < theEvent->GetNumTilt(); ii++) {
97  AliDaqTilt* tilt = (AliDaqTilt*)theEvent->GetArray_Tilt()->At(ii);
98  measList.push_back(GetMeasFromTilt(tilt));
99  if (ALIUtils::debug >= 4) {
100  std::cout << "TILT sensor " << ii << " has ID = " << tilt->GetID() << std::endl;
101  tilt->DumpIt("TILT");
102  }
103  }
104  for (int ii = 0; ii < theEvent->GetNumDist(); ii++) {
106  measList.push_back(GetMeasFromDist(dist));
107  if (ALIUtils::debug >= 4) {
108  std::cout << "DIST sensor " << ii << " has ID = " << dist->GetID() << std::endl;
109  dist->DumpIt("DIST");
110  }
111  }
112 
113  nextEvent = nev + 1;
114 
116 
117  return true;
118 }
void DumpIt(const TString &Name)
TClonesArray * GetArray_Tilt() const
OpticalAlignMeasurementInfo GetMeasFromTilt(AliDaqTilt *tilt)
OpticalAlignMeasurementInfo GetMeasFromDist(AliDaqDistance *dist)
TClonesArray * GetArray_PositionCOPS() const
static ALIint debug
Definition: ALIUtils.h:34
TString GetID()
TClonesArray * GetArray_Position2D() const
int GetNumTilt() const
CocoaDaqRootEvent * theEvent
int GetNumPos2D() const
void DumpIt(const TString &Name)
OpticalAlignMeasurementInfo GetMeasFromPositionCOPS(AliDaqPositionCOPS *posCOPS)
ii
Definition: cuy.py:590
TClonesArray * GetArray_Dist() const
int GetNumDist() const
void BuildMeasurementsFromOptAlign(std::vector< OpticalAlignMeasurementInfo > &measList) override
void DumpIt(const TString &Name)
OpticalAlignMeasurementInfo GetMeasFromPosition2D(AliDaqPosition2D *pos2D)
void DumpIt(const TString &Name)
int GetNumPosCOPS() const
bool CocoaDaqReaderRoot::ReadNextEvent ( )
overridevirtual

Implements CocoaDaqReader.

Definition at line 55 of file CocoaDaqReaderRoot.cc.

References nextEvent, and ReadEvent().

55 { return ReadEvent(nextEvent); }
bool ReadEvent(int nev) override

Member Data Documentation

int CocoaDaqReaderRoot::nev
private

Definition at line 34 of file CocoaDaqReaderRoot.h.

Referenced by CocoaDaqReaderRoot(), and GetNEvents().

int CocoaDaqReaderRoot::nextEvent
private

Definition at line 35 of file CocoaDaqReaderRoot.h.

Referenced by CocoaDaqReaderRoot(), ReadEvent(), and ReadNextEvent().

CocoaDaqRootEvent* CocoaDaqReaderRoot::theEvent
private

Definition at line 31 of file CocoaDaqReaderRoot.h.

Referenced by CocoaDaqReaderRoot(), and ReadEvent().

TFile* CocoaDaqReaderRoot::theFile
private

Definition at line 32 of file CocoaDaqReaderRoot.h.

Referenced by CocoaDaqReaderRoot(), and ~CocoaDaqReaderRoot().

TTree* CocoaDaqReaderRoot::theTree
private

Definition at line 33 of file CocoaDaqReaderRoot.h.

Referenced by CocoaDaqReaderRoot(), and ReadEvent().