25 {
26 MsgStream log(
msgSvc(), name() );
27
28 m_EventTag = initialEventTag;
29
30 if ( ( m_EventTag & 0xF ) == 1 ) return StatusCode::SUCCESS;
31
33 if ( !mcParticles )
34 {
35 log << MSG::ERROR << "Can not open McParticleCollection" << endmsg;
36 return StatusCode::SUCCESS;
37 }
38
39 if ( m_EventTag == 0 )
40 {
41 for ( Event::McParticleCol::iterator it = mcParticles->begin(); it != mcParticles->end();
42 it++ )
43 {
44
45 long int pdg =
abs( ( *it )->particleProperty() );
46 if ( ( ( pdg % 1000 ) / 10 ) == 44 )
47 {
48 m_EventTag = ( (int)( pdg == 443 ) ) * 4 + ( (int)( pdg == 100443 ) ) * 5 +
49 ( (int)( pdg == 30443 ) ) * 6 + ( (int)( pdg == 9000443 ) ) * 7 +
50 ( (int)( pdg == 9010443 ) ) * 8 + ( (int)( pdg == 9020443 ) ) * 9;
51 break;
52 }
53 }
54 }
55
56 if ( m_EventTag == 0 )
57 {
58 m_EventTag = 2;
59 for ( Event::McParticleCol::iterator it = mcParticles->begin(); it != mcParticles->end();
60 it++ )
61 {
62 if ( ( *it )->decayInFlight() || ( *it )->primaryParticle() ) continue;
63 long int pdg =
abs( ( *it )->particleProperty() );
64 if ( pdg == 11 )
65 {
66 m_EventTag |= 0X20;
67 break;
68 }
69 else if ( pdg == 13 )
70 {
71 m_EventTag |= 0X30;
72 break;
73 }
74 else if ( pdg == 15 )
75 {
76 m_EventTag |= 0X40;
77 break;
78 }
79 else if ( ( pdg > 0 ) && ( pdg < 9 ) )
80 {
81 m_EventTag |= 0X50;
82 break;
83 }
84 }
85 }
86
87 if ( ( ( m_EventTag & 0xf ) > 3 ) && ( ( m_EventTag & 0xf ) < 9 ) )
88 {
89 m_EventTag &= 0xf;
90
91 for ( Event::McParticleCol::iterator it = mcParticles->begin(); it != mcParticles->end();
92 it++ )
93 {
94 long int pdg = ( *it )->particleProperty();
95 if ( ( ( pdg % 1000 ) / 10 ) != 44 ) continue;
96
97 m_EventTag |= ( m_EventTagSvc->getCharmDecayType( *it ) ) << 4;
98 m_EventTag |= ( m_EventTagSvc->getChainCode( *it ) ) << 8;
99
100 break;
101 }
102 }
103 else if ( ( m_EventTag & 0xf ) == 0x2 )
104 {
105
106 int ncha = 0;
107 int nneu = 0;
108 for ( Event::McParticleCol::iterator it = mcParticles->begin(); it != mcParticles->end();
109 it++ )
110 {
111 long int pdg =
abs( ( *it )->particleProperty() );
112 bool good = ( !( *it )->decayInFlight() ) && ( !( *it )->primaryParticle() );
113 ncha += ( (int)( good && ( ( pdg == 11 ) || ( pdg == 13 ) || ( pdg == 211 ) ||
114 ( pdg == 321 ) || ( pdg == 2212 ) || ( pdg == 1011 ) ) ) );
115 nneu += ( (int)( good && ( ( pdg == 111 ) || ( pdg == 310 ) || ( pdg == 130 ) ||
116 ( pdg == 2112 ) ) ) );
117
118
119
120
121
122 }
123 m_EventTag |= ( ( ncha & 0xF ) << 8 );
124 m_EventTag |= ( ( nneu & 0xF ) << 12 );
125 if ( ( m_EventTag & 0xf0 ) == 0x40 )
126 {
127
128 for ( Event::McParticleCol::iterator it = mcParticles->begin(); it != mcParticles->end();
129 it++ )
130 {
131 long int pdg = ( *it )->particleProperty();
132
133 if ( pdg == -15 )
134 {
135 m_EventTag |= ( m_EventTagSvc->getDecayCode( *it ) ) << 16;
136
137 }
138 else if ( pdg == 15 )
139 {
140 m_EventTag |= ( m_EventTagSvc->getDecayCode( *it ) ) << 24;
141
142 }
143 }
144 }
145 }
146
147 SmartDataPtr<Event::EventHeader> evHead( eventSvc(), EventModel::EventHeader );
148 if ( !evHead )
149 {
150 log << MSG::ERROR << " Can not to retreave EventHeader" << endmsg;
151 return StatusCode::SUCCESS;
152 }
153 evHead->setEventTag( m_EventTag );
154
155 return StatusCode::SUCCESS;
156}
_EXTERN_ std::string McParticleCol