001
002
003
004
005
006
007
008
009
010 #include "AtlfastAlgs/DefaultReconstructedParticleMaker.h"
011 #include "AtlfastAlgs/ReconstructorFactory.h"
012 #include "AtlfastAlgs/GlobalEventData.h"
013
014
015
016 #include "AtlfastAlgs/MuonAcceptor.h"
017
018 #include "AtlfastEvent/MsgStreamDefs.h"
019 #include "AtlfastEvent/MCparticleCollection.h"
020
021 #include "AtlfastUtils/HeaderPrinter.h"
022 #include "TruthHelper/GenIMCselector.h"
023 #include "TruthHelper/IsGenType.h"
024 #include "TruthHelper/IsGenStable.h"
025 #include "AtlfastUtils/HepMC_helper/MCCuts.h"
026 #include "TruthHelper/NCutter.h"
027 #include "AtlfastUtils/FunctionObjects.h"
028
029 #include <cmath>
030
031
032 #include <algorithm>
033
034
035 #include "GaudiKernel/DataSvc.h"
036
037
038 #include "GeneratorObjects/McEventCollection.h"
039 #include "CLHEP/Units/SystemOfUnits.h"
040
041 namespace Atlfast {
042 using std::abs;
043 using std::vector;
044 using std::sort;
045
046
047
048
049 DefaultReconstructedParticleMaker::DefaultReconstructedParticleMaker
050 ( const std::string& name, ISvcLocator* pSvcLocator )
051 : Algorithm( name, pSvcLocator ),
052 m_ncutter(0),
053 m_reconstructor(0),
054 m_acceptor(0),
055 m_lnkReconstructedParticle(0),
056 m_tesIO(0),
057 m_log( messageService(), name )
058 {
059
060
061 m_particleType = 11;
062 m_mcPtMin = 0.0*GeV;
063 m_mcEtaMax = 100.0;
064 m_PtMin = 5.0*GeV;
065 m_EtaMax = 2.5;
066 m_doSmearing = true;
067 m_muSmearKey = 1;
068 m_outputLocation = "/Event/AtlfastReconstructedParticle" ;
069 m_muonResFile = "atlfastDatafiles/MuonResolutionTable.xml" ;
070 m_smearParamSchema = 1;
071 m_applyEfficiencies = false;
072 m_schemaUsesParameters = false;
073 m_detEffectsFile = "";
074
075
076
077 declareProperty( "ParticleType", m_particleType ) ;
078 declareProperty( "mcMinimumPt", m_mcPtMin ) ;
079 declareProperty( "mcMaximumEta", m_mcEtaMax ) ;
080 declareProperty( "MinimumPt", m_PtMin ) ;
081 declareProperty( "MaximumEta", m_EtaMax ) ;
082 declareProperty( "DoSmearing", m_doSmearing );
083 declareProperty( "OutputLocation", m_outputLocation ) ;
084 declareProperty( "MuonResFile", m_muonResFile ) ;
085 declareProperty( "MuonSmearKey", m_muSmearKey );
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120 declareProperty( "SmearParamArray", m_smearParamArray );
121 declareProperty( "SmearParamSchema",m_smearParamSchema );
122 declareProperty( "SchemaUsesParameters", m_schemaUsesParameters );
123
124
125 declareProperty( "ApplyEfficiencies", m_applyEfficiencies );
126
127 }
128
129
130
131
132
133 DefaultReconstructedParticleMaker::~DefaultReconstructedParticleMaker() {
134
135 m_log << MSG::INFO << "Destructor Called" << endreq;
136
137 if (m_reconstructor) {
138 m_log << MSG::INFO << "Deleting reconstructor" << endreq;
139 delete m_reconstructor;
140 }
141 if (m_acceptor) {
142 m_log << MSG::INFO << "Deleting acceptor" << endreq;
143 delete m_acceptor;
144 }
145 if (m_tesIO) {
146 m_log << MSG::INFO << "Deleting tesIO" << endreq;
147 delete m_tesIO;
148 }
149 if (m_ncutter) {
150 m_log << MSG::INFO << "Deleting truth helpers" << endreq;
151 delete m_ncutter;
152 }
153
154 if (m_lnkReconstructedParticle) delete m_lnkReconstructedParticle;
155
156 }
157
158
159
160
161
162
163 StatusCode DefaultReconstructedParticleMaker::initialize()
164 {
165
166
167
168
169
170 typedef TruthHelper::GenIMCselector Selector;
171
172 Selector* typeSelector = new TruthHelper::IsGenType( m_particleType);
173 Selector* kineSelector = new HepMC_helper::MCCuts(m_mcPtMin, m_mcEtaMax);
174 Selector* fstaSelector = new TruthHelper::IsGenStable();
175
176 vector<TruthHelper::GenIMCselector*> selectors;
177 selectors.push_back(fstaSelector);
178 selectors.push_back(typeSelector);
179 selectors.push_back(kineSelector);
180
181 m_ncutter = new TruthHelper::NCutter(selectors);
182
183 delete typeSelector;
184 delete kineSelector;
185 delete fstaSelector;
186
187
188
189
190
191
192 GlobalEventData* ged = GlobalEventData::Instance();
193 int lumi = ged->lumi();
194 int randSeed = ged->randSeed();
195 m_detEffectsFile = ged->detEffectsFileName();
196
197 m_tesIO = new TesIO(ged->mcLocation(), ged->justHardScatter());
198
199
200 if (m_doSmearing){
201 ReconstructorFactory rf(m_detEffectsFile, m_log);
202 m_reconstructor = rf.makeReconstructor( m_particleType,
203 randSeed,
204 lumi,
205 m_muSmearKey,
206 m_muonResFile,
207 m_smearParamArray,
208 m_smearParamSchema );
209 } else {
210 m_reconstructor = 0;
211 }
212
213
214 if (m_applyEfficiencies) this->getAcceptor();
215 else m_acceptor = 0;
216
217 HeaderPrinter hp("Atlfast ReconstructedParticle Maker:", m_log);
218 hp.add("Particle Type ", m_particleType);
219 hp.add("Luminosity ", lumi);
220 hp.add("Minimum four-vector Pt ", m_mcPtMin);
221 hp.add("Maximum four-vector Eta ", m_mcEtaMax);
222 hp.add("Minimum particle Pt ", m_PtMin);
223 hp.add("Maximum particle Eta ", m_EtaMax);
224 hp.add("Do Smearing ", m_doSmearing);
225 hp.add("Muon Smearing Flag ", m_muSmearKey);
226 hp.add("Random Number Seed ", randSeed);
227 hp.add("MC location ", ged->mcLocation());
228 hp.add("Output Location ", m_outputLocation);
229 hp.add("Muon Resolution File ", m_muonResFile);
230 hp.print();
231
232
233 if(m_schemaUsesParameters){
234 if(m_smearParamArray.size() == 0){
235 m_log << MSG::WARNING <<"No smearing parameters found in ATLFAST jobOptions..."<< endreq;
236 }else{
237 m_log << MSG::INFO << "Smearing Array m_smearParamArray set to: "<<
238 m_smearParamArray << endreq;
239 }
240 }else{
241 m_log << MSG::INFO << "Schema requires no input parameters"<< endreq;
242 }
243
244 return StatusCode::SUCCESS;
245 }
246
247
248
249
250
251 StatusCode DefaultReconstructedParticleMaker::finalize()
252 {
253
254 m_log << MSG::INFO << "Finalizing" << endreq;
255 return StatusCode::SUCCESS ;
256 }
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280 StatusCode DefaultReconstructedParticleMaker::execute( )
281 {
282
283 std::string mess;
284 m_log << MSG::DEBUG << "Execute() " << endreq;
285
286
287
288
289
290
291
292
293 MCparticleCollection my_MC_particles ;
294 MCparticleCollectionCIter src ;
295
296 TesIoStat stat = m_tesIO->getMC( my_MC_particles, m_ncutter ) ;
297 mess = stat? "Retrieved MC from TES ":"Failed MC retrieve from TES";
298 m_log << MSG::DEBUG << mess << endreq;
299
300
301
302
303
304
305
306 ReconstructedParticleCollection* myReconstructedParticles
307 = new ReconstructedParticleCollection ;
308
309
310
311
312
313
314 ReconstructedParticle* candidate ;
315
316
317
318 bool accept = true, accept_kinematic = true, accept_efficiency = true;
319
320 for(src = my_MC_particles.begin() ; src != my_MC_particles.end() ; ++src){
321
322 candidate = this->create( *src );
323
324
325 if (m_applyEfficiencies){
326 bool instance_check = m_acceptor ? true : false;
327 m_log << MSG::DEBUG << "Does m_acceptor point to anything sensible?: " << instance_check << endreq;
328 accept_efficiency = ( m_acceptor && m_acceptor->accept( *candidate, m_log ) ) ? true : false;
329 m_log << MSG::DEBUG << "m_acceptor && m_acceptor->accept( *candidate ) = "
330 << accept_efficiency << endreq;
331 }
332
333 accept_kinematic = this->isAcceptable( candidate );
334
335 accept = m_applyEfficiencies ?
336 accept_efficiency && accept_kinematic :
337 accept_kinematic;
338
339 if ( accept ) {
340 m_log << MSG::DEBUG << "Accepted" << endreq;
341 myReconstructedParticles->push_back( candidate );
342 }else{
343 m_log << MSG::DEBUG << "Rejected" << endreq;
344 delete candidate;
345 }
346
347 }
348
349
350
351
352
353 if( myReconstructedParticles->size() > 0 ){
354 sort( myReconstructedParticles->begin(),
355 myReconstructedParticles->end(),
356 SortAttribute::DescendingPT()
357 ) ;
358 }
359
360
361
362
363
364 stat =m_tesIO->store( myReconstructedParticles, m_outputLocation );
365 mess = stat? "Store to TES success":"Store to TES failure";
366 m_log << MSG::DEBUG << mess << endreq;
367
368 m_log << MSG::DEBUG << "Ending<-------- " << endreq;
369
370 StatusCode sc=StatusCode::SUCCESS;
371 return sc ;
372
373 }
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389 ReconstructedParticle* DefaultReconstructedParticleMaker::create ( const HepMC::GenParticle* src ){
390 HepLorentzVector evec(src->momentum().px(),
391 src->momentum().py(),
392 src->momentum().pz(),
393 src->momentum().e());
394
395 ReconstructedParticle tmpStackParticle(src->pdg_id(),evec,src);
396 ReconstructedParticle *candidate;
397
398 if(m_doSmearing){
399 candidate = new ReconstructedParticle(m_reconstructor->reconstruct(tmpStackParticle));
400 m_log << MSG::DEBUG
401 << "\n\t"
402 << "Unsmeared four-vector: "
403 << src->momentum()
404 << "\n\t"
405 << "Smeared four-vector : "
406 << candidate->momentum()
407 << endreq;
408 }
409 else{
410 candidate = new ReconstructedParticle(tmpStackParticle);
411 }
412
413 m_log << MSG::DEBUG
414 << "Created ReconstructedParticle: \n\t "
415 << candidate
416 << endreq;
417
418 return candidate ;
419 }
420
421
422
423
424
425
426
427
428
429 bool DefaultReconstructedParticleMaker::isAcceptable
430 (const ReconstructedParticle* candidate ){
431
432
433
434 if( candidate->pT() < m_PtMin ) {
435 m_log << MSG::DEBUG
436 << "Candidate failed pt cut: pt was "
437 << candidate->pT()
438 << " cut was "
439 << m_PtMin
440 << endreq;
441 return false ;
442 }
443
444 if( abs(candidate->eta()) > m_EtaMax ) {
445 m_log << MSG::DEBUG
446 << "Candidate failed max eta cut: eta was "
447 << candidate->eta()
448 << " cut was "
449 << m_EtaMax
450 << endreq;
451 return false ;
452 }
453
454 m_log << MSG::DEBUG
455 << "Candidate passed selection cuts "
456 << endreq ;
457
458 return true ;
459 }
460
461
462
463
464 void DefaultReconstructedParticleMaker::getAcceptor(){
465
466 m_log << MSG::DEBUG << "Getting an acceptor" << endreq;
467
468 if (m_particleType == 13){
469 m_acceptor = new MuonAcceptor(m_muSmearKey,m_log);
470 }else{
471 m_log << MSG::ERROR << "No Acceptor exists for this particle type!" << endreq;
472 m_acceptor = 0;
473 }
474
475 }
476
477 }
478
479
| Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems |
|
This page was automatically generated by the
LXR engine.
|
|