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 17 of file CocoaDaqReaderRoot.cc.

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

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

Definition at line 54 of file CocoaDaqReaderRoot.cc.

References theFile.

55 {
56  theFile->Close();
57 }

Member Function Documentation

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

Reimplemented from CocoaDaqReader.

Definition at line 257 of file CocoaDaqReaderRoot.cc.

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

Referenced by ReadEvent().

258 {
259  if ( ALIUtils::debug >= 3) std::cout << "@@@ CocoaDaqReaderRoot::BuildMeasurementsFromOptAlign " << std::endl;
260 
261  //set date and time of current measurement
262  // if( wordlist[0] == "DATE:" ) {
263  // Measurement::setCurrentDate( wordlist );
264  // }
265 
266  //---------- loop measurements read from ROOT and check for corresponding measurement in Model
267  // ALIint nMeasModel = Model::MeasurementList().size();
268  ALIint nMeasRoot = measList.size();
269  if(ALIUtils::debug >= 4) {
270  std::cout << " Building " << nMeasRoot << " measurements from ROOT file " << std::endl;
271  }
272 
273  //--- Loop to Measurements in Model and check for corresponding measurement in ROOT
274  std::vector< Measurement* >::const_iterator vmcite;
275  for( vmcite = Model::MeasurementList().begin(); vmcite != Model::MeasurementList().end(); ++vmcite ) {
276  ALIint fcolon = (*vmcite)->name().find(':');
277  ALIstring oname = (*vmcite)->name();
278  oname = oname.substr(fcolon+1,oname.length());
279 
280  //---------- loop measurements read from ROOT
281  ALIint ii;
282  for(ii = 0; ii < nMeasRoot; ii++) {
283  OpticalAlignMeasurementInfo measInfo = measList[ii];
284  std::cout << " measurement name ROOT " << measInfo.name_ << " Model= " << (*vmcite)->name() << " short " << oname << std::endl;
285 
286  if( oname == measInfo.name_ ) {
287  //-------- Measurement found, fill data
288  //---- Check that type is the same
289  if( (*vmcite)->type() != measInfo.type_ ) {
290  std::cerr << "!!! Measurement from ROOT file: type in file is "
291  <<measInfo.type_ << " and should be " << (*vmcite)->type() << std::endl;
292  exit(1);
293  }
294 
295  std::cout << " NOBJECTS IN MEAS " << (*vmcite)->OptOList().size() << " NMEAS " << Model::MeasurementList().size() << std::endl;
296 
297  std::vector<OpticalAlignParam> measValues = measInfo.values_;
298 
299  for( size_t jj= 0; jj < measValues.size(); jj++ ){
300  (*vmcite)->fillData( jj, &(measValues[jj]) );
301  }
302 
303  std::cout << " NOBJECTS IN MEAS after " << (*vmcite)->OptOList().size() << " NMEAS " << Model::MeasurementList().size() << std::endl;
304 
305  break;
306  }
307  }
308  if (ii==nMeasRoot) {
309  std::cerr << "!!! Reading measurement from file: measurement not found! Type in list is " << oname << std::endl;
310  exit(1);
311  }
312  }
313 
314 }
int ALIint
Definition: CocoaGlobals.h:15
static ALIint debug
Definition: ALIUtils.h:36
ii
Definition: cuy.py:588
#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:79
OpticalAlignMeasurementInfo CocoaDaqReaderRoot::GetMeasFromDist ( AliDaqDistance dist)
private

Definition at line 231 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().

232 {
234 
235  meas.type_ = "DISTANCEMETER";
236  meas.name_ = std::string(dist->GetID().Data());
237  //- std::vector<std::string> measObjectNames_;
238  std::vector<bool> isSimu;
239  for( size_t jj = 0; jj < 2; jj++ ){
240  isSimu.push_back(false);
241  }
242  meas.isSimulatedValue_ = isSimu;
243  std::vector<OpticalAlignParam> paramList;
244  OpticalAlignParam oaParam;
245  oaParam.name_ = "D:";
246  oaParam.value_ = dist->GetDistance()/100.;
247  oaParam.error_ = dist->GetDistanceError()/100.;
248  paramList.push_back(oaParam);
249 
250  meas.values_ = paramList;
251 
252  return meas;
253 }
Float_t GetDistanceError() const
Float_t GetDistance() const
std::vector< OpticalAlignParam > values_
OpticalAlignMeasurementInfo CocoaDaqReaderRoot::GetMeasFromPosition2D ( AliDaqPosition2D pos2D)
private

Definition at line 127 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().

128 {
130 
131  meas.type_ = "SENSOR2D";
132  meas.name_ = std::string(pos2D->GetID().Data());
133  //- std::vector<std::string> measObjectNames_;
134  std::vector<bool> isSimu;
135  for( size_t jj = 0; jj < 2; jj++ ){
136  isSimu.push_back(false);
137  }
138  meas.isSimulatedValue_ = isSimu;
139  std::vector<OpticalAlignParam> paramList;
140  OpticalAlignParam oaParam1;
141  oaParam1.name_ = "H:";
142  oaParam1.value_ = pos2D->GetX()/100.;
143  oaParam1.error_ = pos2D->GetXerror()/100.;
144  paramList.push_back(oaParam1);
145 
146  OpticalAlignParam oaParam2;
147  oaParam2.name_ = "V:";
148  oaParam2.value_ = pos2D->GetY()/100.;
149  oaParam2.error_ = pos2D->GetYerror()/100.;
150  paramList.push_back(oaParam2);
151 
152  meas.values_ = paramList;
153 
154  return meas;
155 }
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 159 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().

160 {
162 
163  meas.type_ = "COPS";
164  meas.name_ = std::string(posCOPS->GetID().Data());
165  //- std::vector<std::string> measObjectNames_;
166  std::vector<bool> isSimu;
167  for( size_t jj = 0; jj < 4; jj++ ){
168  isSimu.push_back(false);
169  }
170  meas.isSimulatedValue_ = isSimu;
171 
172  std::vector<OpticalAlignParam> paramList;
173  OpticalAlignParam oaParam1;
174  oaParam1.name_ = "U:";
175  oaParam1.value_ = posCOPS->GetUp()/100.;
176  oaParam1.error_ = posCOPS->GetUpError()/100.;
177  paramList.push_back(oaParam1);
178 
179  OpticalAlignParam oaParam2;
180  oaParam2.name_ = "U:";
181  oaParam2.value_ = posCOPS->GetDown()/100.;
182  oaParam2.error_ = posCOPS->GetDownError()/100.;
183  paramList.push_back(oaParam2);
184 
185  OpticalAlignParam oaParam3;
186  oaParam3.name_ = "U:";
187  oaParam3.value_ = posCOPS->GetRight()/100.;
188  oaParam3.error_ = posCOPS->GetRightError()/100.;
189  paramList.push_back(oaParam3);
190 
191  OpticalAlignParam oaParam4;
192  oaParam4.name_ = "U:";
193  oaParam4.value_ = posCOPS->GetLeft()/100.;
194  oaParam4.error_ = posCOPS->GetLeftError()/100.;
195  paramList.push_back(oaParam4);
196 
197  meas.values_ = paramList;
198 
199  return meas;
200 
201 }
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 204 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().

205 {
207 
208  meas.type_ = "TILTMETER";
209  meas.name_ = std::string(tilt->GetID().Data());
210  //- std::vector<std::string> measObjectNames_;
211  std::vector<bool> isSimu;
212  for( size_t jj = 0; jj < 2; jj++ ){
213  isSimu.push_back(false);
214  }
215  meas.isSimulatedValue_ = isSimu;
216  std::vector<OpticalAlignParam> paramList;
217  OpticalAlignParam oaParam;
218  oaParam.name_ = "T:";
219  oaParam.value_ = tilt->GetTilt();
220  oaParam.error_ = tilt->GetTiltError();
221  paramList.push_back(oaParam);
222 
223  meas.values_ = paramList;
224 
225  return meas;
226 
227 }
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 67 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, gen::n, nextEvent, theEvent, and theTree.

Referenced by ReadNextEvent().

68 {
69  std::vector<OpticalAlignMeasurementInfo> measList;
70 
71  int nb = 0; // dummy, number of bytes
72  // Loop over all events
73  nb = theTree->GetEntry(nev); // read in entire event
74 
75  if ( ALIUtils::debug >= 3) std::cout << "CocoaDaqReaderRoot reading event " << nev << " " << nb << std::endl;
76  if( nb == 0 ) return false; //end of file reached??
77 
78  // Every n events, dump one to screen
79  int n = 1;
80  if(nev%n == 0 && ALIUtils::debug >= 3 ) theEvent->DumpIt();
81 
82  //if ( ALIUtils::debug >= 3) std::cout<<" CocoaDaqReaderRoot::ReadEvent "<< nev <<std::endl;
83 
84  if ( ALIUtils::debug >= 3) std::cout<<" CocoaDaqReaderRoot::ReadEvent npos2D "<< theEvent->GetNumPos2D() << " nCOPS " << theEvent->GetNumPosCOPS() << std::endl;
85 
86  for(int ii=0; ii<theEvent->GetNumPos2D(); ii++) {
88  if ( ALIUtils::debug >= 4) std::cout<<"2D sensor "<<ii<<" has ID = "<<pos2D->GetID()<< std::endl;
89  pos2D->DumpIt("2DSENSOR");
90  measList.push_back( GetMeasFromPosition2D( pos2D ) );
91  }
92  for(int ii=0; ii<theEvent->GetNumPosCOPS(); ii++) {
94  measList.push_back( GetMeasFromPositionCOPS( posCOPS ) );
95  if ( ALIUtils::debug >= 4) {
96  std::cout<<"COPS sensor "<<ii<<" has ID = "<<posCOPS->GetID()<< std::endl;
97  posCOPS->DumpIt("COPS");
98  }
99  }
100  for(int ii=0; ii<theEvent->GetNumTilt(); ii++) {
101  AliDaqTilt* tilt = (AliDaqTilt*) theEvent->GetArray_Tilt()->At(ii);
102  measList.push_back( GetMeasFromTilt( tilt ) );
103  if ( ALIUtils::debug >= 4) {
104  std::cout<<"TILT sensor "<<ii<<" has ID = "<<tilt->GetID()<< std::endl;
105  tilt->DumpIt("TILT");
106  }
107 
108  }
109  for(int ii=0; ii<theEvent->GetNumDist(); ii++) {
111  measList.push_back( GetMeasFromDist( dist ) );
112  if ( ALIUtils::debug >= 4) {
113  std::cout<<"DIST sensor "<<ii<<" has ID = "<<dist->GetID()<< std::endl;
114  dist->DumpIt("DIST");
115  }
116  }
117 
118  nextEvent = nev + 1;
119 
120  BuildMeasurementsFromOptAlign( measList );
121 
122  return true;
123 
124 }
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:36
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:588
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 60 of file CocoaDaqReaderRoot.cc.

References nextEvent, and ReadEvent().

61 {
62  return ReadEvent( nextEvent );
63 }
bool ReadEvent(int nev) override

Member Data Documentation

int CocoaDaqReaderRoot::nev
private

Definition at line 33 of file CocoaDaqReaderRoot.h.

Referenced by CocoaDaqReaderRoot(), and GetNEvents().

int CocoaDaqReaderRoot::nextEvent
private

Definition at line 34 of file CocoaDaqReaderRoot.h.

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

CocoaDaqRootEvent* CocoaDaqReaderRoot::theEvent
private

Definition at line 30 of file CocoaDaqReaderRoot.h.

Referenced by CocoaDaqReaderRoot(), and ReadEvent().

TFile* CocoaDaqReaderRoot::theFile
private

Definition at line 31 of file CocoaDaqReaderRoot.h.

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

TTree* CocoaDaqReaderRoot::theTree
private

Definition at line 32 of file CocoaDaqReaderRoot.h.

Referenced by CocoaDaqReaderRoot(), and ReadEvent().