TrackSummaryCnv_p2.cxx 8.21 KB
Newer Older
1
/*
2
  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
4
5
6
7
8
9
10
*/

#include "TrkTrackSummary/TrackSummary.h"
#include "TrkTrackSummary/InDetTrackSummary.h"
#include "TrkTrackSummary/MuonTrackSummary.h"
#include "TrkEventTPCnv/TrkTrackSummary/TrackSummaryCnv_p2.h"

void TrackSummaryCnv_p2::dbgPrint( const Trk::TrackSummary *t){
11

12
13
14
15
    std::cout << "-------------------------------------------" <<std::endl;
    std::cout << "m_idHitPattern:\t" << t->m_idHitPattern << std::endl;
    std::cout << "m_dedx        :\t" << t->m_dedx << std::endl;
    std::cout << "m_nhitsdedx   :\t" << t->m_nhitsdedx << std::endl;
16

17
    std::cout << " std::vector m_information size: "<< t->m_information.size() <<std::endl;
18
    for (std::vector<int>::const_iterator i=t->m_information.begin();i!=t->m_information.end();++i) std::cout<<"\t "<<(*i);
19
    std::cout<<std::endl;
20

21
    std::cout << " std::vector m_eProbability size: "<< t->m_eProbability.size() <<std::endl;
22
    for (std::vector<float>::const_iterator i=t->m_eProbability.begin();i!=t->m_eProbability.end();++i) std::cout<<"\t "<<(*i);
23
    std::cout<<std::endl;
24

25
    if(t->m_indetTrackSummary){
26
27
28
29
30
        std::cout << " m_indetTrackSummary->m_massdedx: "<< t->m_indetTrackSummary->massPixeldEdx();
        std::cout << " std::vector m_indetTrackSummary->m_likelihoodspixeldedx size: "<< t->m_indetTrackSummary->likelihoodsPixeldEdx().size() <<std::endl;
        for (float x : t->m_indetTrackSummary->likelihoodsPixeldEdx())
           std::cout<<"\t "<<x;
        std::cout<<std::endl;
31
    }
32
33

    if(t->m_muonTrackSummary){
34
35
36
        std::cout << " m_muonTrackSummary->m_nscatterers: "<< t->m_muonTrackSummary->nscatterers() <<std::endl;
        std::cout << " m_muonTrackSummary->m_npseudoMeasurements: "<< t->m_muonTrackSummary->npseudoMeasurements() <<std::endl;
        std::cout << " std::vector m_muonTrackSummary->m_chamberHitSummary size: "<< t->m_muonTrackSummary->chamberHitSummary().size() <<std::endl;
37
        for (const Trk::MuonTrackSummary::ChamberHitSummary& s :
38
39
40
41
42
43
44
45
46
47
48
49
50
51
               t->m_muonTrackSummary->chamberHitSummary())
        {
            std::cout<<"\t m_chId           "<<s.chamberId()        <<std::endl;
            std::cout<<"\t m_isMdt          "<<s.isMdt()            <<std::endl;
            std::cout<<"\t m_first.nhits      "<<s.mdtMl1().nhits     <<std::endl;
            std::cout<<"\t m_first.nholes     "<<s.mdtMl1().nholes    <<std::endl;
            std::cout<<"\t m_first.noutliers  "<<s.mdtMl1().noutliers <<std::endl;
            std::cout<<"\t m_first.ndeltas    "<<s.mdtMl1().ndeltas   <<std::endl;
            std::cout<<"\t m_first.ncloseHits "<<s.mdtMl1().ncloseHits<<std::endl;
            std::cout<<"\t m_second.nhits     "<<s.mdtMl2().nhits     <<std::endl;
            std::cout<<"\t m_second.nholes    "<<s.mdtMl2().nholes    <<std::endl;
            std::cout<<"\t m_second.noutliers "<<s.mdtMl2().noutliers <<std::endl;
            std::cout<<"\t m_second.ndeltas   "<<s.mdtMl2().ndeltas   <<std::endl;
            std::cout<<"\t m_second.ncloseHits"<<s.mdtMl2().ncloseHits<<std::endl;
52
53
        }
    }
54

55
56
57
58
59
60
61
62
63
}


void TrackSummaryCnv_p2::persToTrans( const Trk::TrackSummary_p2 *persObj, Trk::TrackSummary *transObj, MsgStream &/*log*/ ){
    transObj->m_information       = persObj->m_information;
    if (transObj->m_information.size() < Trk::numberOfTrackSummaryTypes)
      transObj->m_information.resize(Trk::numberOfTrackSummaryTypes,
                                     Trk::TrackSummary::SummaryTypeNotSet);

64
65
66
67
68
69
70
71
72
    if (persObj->m_information.size() <= Trk::numberOfInnermostPixelLayerHits) {
      transObj->m_information[Trk::numberOfInnermostPixelLayerHits] =
        transObj->m_information[Trk::numberOfBLayerHits];
    }

    if (persObj->m_information.size() <= Trk::numberOfInnermostPixelLayerSharedHits) {
      transObj->m_information[Trk::numberOfInnermostPixelLayerSharedHits] =
        transObj->m_information[Trk::numberOfBLayerSharedHits];
    }
73

74

75
76
77
78
79
80
81
82
83
84
85
86
87
    transObj->m_idHitPattern      = persObj->m_idHitPattern;
    transObj->m_eProbability      = persObj->m_eProbability;
    transObj->m_dedx              = persObj->m_pixeldEdx;
    transObj->m_nhitsdedx         = persObj->m_nhitsfordEdx;

    size_t s = persObj->m_indetTrackSummary.size();
    if (s){ // INDET TRACK SUMMARIES
        Trk::InDetTrackSummary *ts=new Trk::InDetTrackSummary();
        ts->m_massdedx = persObj->m_indetTrackSummary.back();
        ts->m_likelihoodspixeldedx.resize(s-1);
        for(size_t i = 0; i < (s-1); ++i)
            ts->m_likelihoodspixeldedx[i]=persObj->m_indetTrackSummary[i];

88
        transObj->m_indetTrackSummary.reset(ts);
89
    }
90
91


92
93
94
95
    s = persObj->m_muonTrackSummary.size();
    if(s){  // MUON TRACK SUMMARY
        Trk::MuonTrackSummary *ts= new Trk::MuonTrackSummary();
        std::vector<unsigned int>::const_iterator i = persObj->m_muonTrackSummary.begin();
96

97
98
        ts->m_nscatterers = *i; ++i;
        ts->m_npseudoMeasurements = *i; ++i;
99

100
        size_t size=(s-2)/12;
101
        ts->m_chamberHitSummary.reserve(size);
102
103

        for (size_t sc=0;  sc<size ; ++sc ){
104
105
            ts->m_chamberHitSummary.emplace_back(Identifier(*i), bool(*(++i)));
            ++i;
106
107
108
109
110
111
112
113
114
115
            ts->m_chamberHitSummary[sc].m_first.nhits      =(*i);++i;
            ts->m_chamberHitSummary[sc].m_first.nholes     =(*i);++i;
            ts->m_chamberHitSummary[sc].m_first.noutliers  =(*i);++i;
            ts->m_chamberHitSummary[sc].m_first.ndeltas    =(*i);++i;
            ts->m_chamberHitSummary[sc].m_first.ncloseHits =(*i);++i;
            ts->m_chamberHitSummary[sc].m_second.nhits     =(*i);++i;
            ts->m_chamberHitSummary[sc].m_second.nholes    =(*i);++i;
            ts->m_chamberHitSummary[sc].m_second.noutliers =(*i);++i;
            ts->m_chamberHitSummary[sc].m_second.ndeltas   =(*i);++i;
            ts->m_chamberHitSummary[sc].m_second.ncloseHits=(*i);++i;
116
        }
117
118

        transObj->m_muonTrackSummary.reset(ts);
119
    }
120

121
122
123
124
125
    // dbgPrint(transObj);
}


void TrackSummaryCnv_p2::transToPers( const Trk::TrackSummary    *transObj, Trk::TrackSummary_p2 *persObj, MsgStream & /*log*/ ){
126

127
    // dbgPrint(transObj);
128

129
130
131
132
133
134
135
    persObj->m_information       = transObj->m_information;
    persObj->m_idHitPattern      = transObj->m_idHitPattern;
    persObj->m_eProbability      = transObj->m_eProbability;
    persObj->m_pixeldEdx         = transObj->m_dedx;
    persObj->m_nhitsfordEdx      = transObj->m_nhitsdedx;

    if(transObj->m_indetTrackSummary){       // INDET TRACK SUMMARY
136
        size_t s = (transObj->m_indetTrackSummary->m_likelihoodspixeldedx).size();
137
138
139
140
141
142
143
144
145
        persObj->m_indetTrackSummary.reserve(s+1);
        for(size_t i = 0; i < s; ++i)
            persObj->m_indetTrackSummary.push_back(transObj->m_indetTrackSummary->m_likelihoodspixeldedx[i]);

        persObj->m_indetTrackSummary.push_back(transObj->m_indetTrackSummary->m_massdedx);
    }


    if(transObj->m_muonTrackSummary){  // MUON TRACK SUMMARY
146

147
        size_t size = transObj->m_muonTrackSummary->m_chamberHitSummary.size();
148

149
150
151
152
        persObj->m_muonTrackSummary.reserve(2 + 12 * size);
        persObj->m_muonTrackSummary.push_back(transObj->m_muonTrackSummary->m_nscatterers);
        persObj->m_muonTrackSummary.push_back(transObj->m_muonTrackSummary->m_npseudoMeasurements);

153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
        for (const Trk::MuonTrackSummary::ChamberHitSummary& s :
               transObj->m_muonTrackSummary->chamberHitSummary())
        {
            persObj->m_muonTrackSummary.push_back(s.chamberId().get_identifier32().get_compact() );
            persObj->m_muonTrackSummary.push_back(s.isMdt()  ); // these are just bits and should be compressed by us
            persObj->m_muonTrackSummary.push_back(s.mdtMl1().nhits      );
            persObj->m_muonTrackSummary.push_back(s.mdtMl1().nholes     );
            persObj->m_muonTrackSummary.push_back(s.mdtMl1().noutliers  );
            persObj->m_muonTrackSummary.push_back(s.mdtMl1().ndeltas    );
            persObj->m_muonTrackSummary.push_back(s.mdtMl1().ncloseHits );
            persObj->m_muonTrackSummary.push_back(s.mdtMl2().nhits      );
            persObj->m_muonTrackSummary.push_back(s.mdtMl2().nholes     );
            persObj->m_muonTrackSummary.push_back(s.mdtMl2().noutliers  );
            persObj->m_muonTrackSummary.push_back(s.mdtMl2().ndeltas    );
            persObj->m_muonTrackSummary.push_back(s.mdtMl2().ncloseHits );
168
169
170
171
        }

    }
}