otsdaq  v2_00_00
Event.cxx
1 /****************************************************************************
2 ** Authors: Dario Menasce, Stefano Terzo
3 **
4 ** I.N.F.N. Milan-Bicocca
5 ** Piazza della Scienza 3, Edificio U2
6 ** Milano, 20126
7 **
8 ****************************************************************************/
9 
10 #include "otsdaq-core/MonicelliInterface/Event.h"
11 #include <sstream>
12 //#include "HManager.h"
13 
14 //#define MINIMUM_TRACK_POINTS 6
15 #define WINDOW 0.005
16 
17 using namespace monicelli;
18 
19 ClassImp(Event)
20 
21 //================================================================================
22 Event::Event (void)
23 {
24  //STDLINE("Empty constructor",ACWhite) ;
25  //theAlignedHitsCandidate_ = new alignedHitsCandidate(this);
26 }
27 
28 //================================================================================
29 Event::~Event(void)
30 {
31 // STDLINE("Event::~Event",ACRed);
32 }
33 
34 //================================================================================
35 void Event::setRawData (int trig, const plaqMapDef& theRawData)
36 {
37  theRawData_ = theRawData;
38  trig_ = trig ;
39 }
40 //================================================================================
41 void Event::clear (void )
42 {
43  trig_=0 ;
44  theRawData_.clear() ;
45  clusters_.clear() ;
46  clustersHits_.clear() ;
47  trackCandidates_.clear() ;
48  fittedTracksChi2_.clear() ;
49  fittedTrackResiduals_.clear() ;
50  fittedTracks_.clear() ;
51  fittedTracksCovariance_.clear() ;
52 }
53 //================================================================
54 Event::residualsMapDef Event::makeFittedTrackDeviations (int trackNumber)
55 {
56  std::stringstream ss_;
57  fittedTrackDeviations_.clear();
58  if ( trackCandidates_.size() != fittedTracks_.size() )
59  {
60  ss_.str("");
61  ss_ << "track candidates size: " << trackCandidates_.size()
62  << " fitted tracks size: " << fittedTracks_.size() ;
63  //STDLINE(ss_.str(),ACYellow)
64  }
65 
66  if( trackNumber < 0 )
67  {
68  for( unsigned int i=0; i < trackCandidates_.size(); i++ )
69  {
70  this->makeSingleTrackDeviations(i);
71  }
72  }
73  else
74  {
75  this->makeSingleTrackDeviations(trackNumber);
76  }
77 
78  return fittedTrackDeviations_;
79 }
80 
81 //================================================================
82 void Event::makeSingleTrackDeviations( int trackNum )
83 {
84  for(Event::alignedHitsCandidateMapDef::iterator pit = trackCandidates_[trackNum].begin(); pit!= trackCandidates_[trackNum].end() ; pit++)
85  {
86  double resX = ( (*pit).second["x"] - fittedTracks_[trackNum][0]*(*pit).second["z"] - fittedTracks_[trackNum][1] ) ;
87  double resY = ( (*pit).second["y"] - fittedTracks_[trackNum][2]*(*pit).second["z"] - fittedTracks_[trackNum][3] ) ;
88  fittedTrackDeviations_[trackNum][(*pit).first] = std::make_pair(resX, resY);
89  }
90 }
91 
92 //================================================================
93 void Event::setClustersHits(const clustersHitsMapDef& clustersHits)
94 {
95  clustersHits_ = clustersHits ;
96 }
97 
98 //================================================================
99 void Event::setClusters(const clustersMapDef& clusters)
100 {
101  clusters_ = clusters;
102 }
103 
104 //================================================================
105 void Event::addUnconstrainedFittedTrack(unsigned int trackN, std::string detector, const vectorDef& fittedTrack, const matrixDef& covarianceMatrix, double fittedTrackChi2)
106 {
107  while(unconstrainedFittedTracks_.size() <= trackN)
108  {
109  unconstrainedFittedTracks_ .push_back(std::map<std::string,vectorDef>());
110  unconstrainedFittedTracksCovariance_.push_back(std::map<std::string,matrixDef>());
111  unconstrainedFittedTracksChi2_ .push_back(std::map<std::string,double>());
112  }
113  unconstrainedFittedTracks_ [trackN][detector] = fittedTrack;
114  unconstrainedFittedTracksCovariance_[trackN][detector] = covarianceMatrix;
115  unconstrainedFittedTracksChi2_ [trackN][detector] = fittedTrackChi2;
116 }