ATLAS Offline Software
HLTResultByteStreamTool.icc
Go to the documentation of this file.
1 // -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #include "eformat/SourceID.h"
8 #include "TrigSteeringEvent/HLTResult.h"
9 #include "GaudiKernel/MsgStream.h"
10 
11 template<class ROBF>
12 StatusCode HLT::HLTResultByteStreamTool::convert(const ROBF* rob, HLTResult*& result, MsgStream* log){
13 
14  typedef typename ROBF::lower_type RODF;
15  typedef std::vector<RODF*, DF_ALLOCATOR<RODF*> > VRODFragment;
16  //typedef std::vector<RODF*> VRODFragment;
17  const VRODFragment * vROD = & (rob->compounds());
18  EventFormat::Version formatVersion = rob->header().version();
19 
20  typename VRODFragment::const_iterator rod_it = vROD->begin();
21  typename VRODFragment::const_iterator rod_it_end = vROD->end();
22  typedef typename RODF::iterator ROD_iterator;
23 
24  StoreGateSvc* p_StoreGate;
25  StatusCode sc = service("StoreGateSvc", p_StoreGate);
26  if (sc.isFailure())
27  {
28  (*log) << MSG::ERROR
29  << "Unable to get pointer to StoreGate Service!" << endmsg;
30  } else {
31  const DataHandle<EventInfo> thisEvent;
32  sc = p_StoreGate->retrieve(thisEvent);
33  }
34  std::vector<unsigned int> l2ResultContent;
35  l2ResultContent.clear();
36  for(; rod_it!=rod_it_end;++rod_it){
37  const RODF* rod = (*rod_it);
38 
39  // get ROD source ID
40  uint32_t rodId = rod->header().source_id();
41 
42  // Check the versioning.
43  if (formatVersion != EventFormat::DEFAULT_VERSION){
44  (*log) << MSG::ERROR << " Wrong format version in BS : "
45  << formatVersion.full() << endmsg;
46  }
47 
48  EventFormat::SourceID helpHLTResultID(EventFormat::TDAQ_LVL2, EventFormat::ROD_TYPE,0);
49 
50 
51  if( rodId == helpHLTResultID.source_id() ){
52  ROD_iterator it = rod->begin() ;
53  ROD_iterator it_end = rod->end() ;
54  for(; it!=it_end;++it)
55  {
56  l2ResultContent.push_back(*it);
57  }
58  }
59  }
60 
61  if((rob->header().status()).size()==1 && (rob->header().status())[0]==0){
62  result->setBeenCreated(false);
63  result->deserialize(l2ResultContent);
64  uint32_t l1id = rob->header().specific_part().lvl1_id();
65  result->setl1id(l1id);
66  (*log) << MSG::DEBUG << " ---> Pesa Level 2 result found " << endmsg;
67  } else {
68  result->setBeenCreated(true);
69  uint32_t l1id = rob->header().specific_part().lvl1_id();
70  result->setl1id(l1id);
71  (*log) << MSG::DEBUG << " ---> Dummy Level 2 result found " << endmsg;
72  }
73 
74  return StatusCode::SUCCESS;
75 }