Skip to content

Commit 380a801

Browse files
committed
Merge branch 'dev' into pvec
2 parents 8e8a9f6 + 11e254b commit 380a801

File tree

117 files changed

+2515
-1327
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+2515
-1327
lines changed

Common/SimConfig/include/SimConfig/SimConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ class SimConfig
180180
SimConfigData mConfigData; //!
181181

182182
// adjust/overwrite some option settings when collision context is used
183-
void adjustFromCollContext();
183+
void adjustFromCollContext(std::string const& collcontextfile, std::string const& prefix);
184184

185185
ClassDefNV(SimConfig, 1);
186186
};

Common/SimConfig/src/SimConfig.cxx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,17 @@ bool SimConfig::resetFromParsedMap(boost::program_options::variables_map const&
256256
mConfigData.mFilterNoHitEvents = true;
257257
}
258258
mConfigData.mFromCollisionContext = vm["fromCollContext"].as<std::string>();
259-
adjustFromCollContext();
259+
// we decompose the argument to fetch
260+
// (a) collision contextfilename
261+
// (b) sim prefix to use from the context
262+
auto pos = mConfigData.mFromCollisionContext.find(':');
263+
std::string collcontextfile{mConfigData.mFromCollisionContext};
264+
std::string simprefix{mConfigData.mOutputPrefix};
265+
if (pos != std::string::npos) {
266+
collcontextfile = mConfigData.mFromCollisionContext.substr(0, pos);
267+
simprefix = mConfigData.mFromCollisionContext.substr(pos + 1);
268+
}
269+
adjustFromCollContext(collcontextfile, simprefix);
260270

261271
// analyse vertex options
262272
if (!parseVertexModeString(vm["vertexMode"].as<std::string>(), mConfigData.mVertexMode)) {
@@ -323,28 +333,28 @@ bool SimConfig::parseFieldString(std::string const& fieldstring, int& fieldvalue
323333
return true;
324334
}
325335

326-
void SimConfig::adjustFromCollContext()
336+
void SimConfig::adjustFromCollContext(std::string const& collcontextfile, std::string const& prefix)
327337
{
328338
// When we use pregenerated collision contexts, some options
329339
// need to be auto-adjusted. Do so and inform about this in the logs.
330-
if (mConfigData.mFromCollisionContext == "") {
340+
if (collcontextfile == "") {
331341
return;
332342
}
333343

334-
auto context = o2::steer::DigitizationContext::loadFromFile(mConfigData.mFromCollisionContext);
344+
auto context = o2::steer::DigitizationContext::loadFromFile(collcontextfile);
335345
if (context) {
336346
// find the events belonging to a source that corresponds to a sim prefix
337-
LOG(info) << "Looking up simprefixes " << mConfigData.mOutputPrefix;
338-
int sourceid = context->findSimPrefix(mConfigData.mOutputPrefix);
347+
LOG(info) << "Looking up simprefixes " << prefix;
348+
int sourceid = context->findSimPrefix(prefix);
339349
if (sourceid == -1) {
340-
LOG(error) << "Could not find collisions with sim prefix " << mConfigData.mOutputPrefix << " in the collision context. The collision contet specifies the following prefixes:";
341-
for (auto& prefix : context->getSimPrefixes()) {
342-
LOG(info) << prefix;
350+
LOG(error) << "Could not find collisions with sim prefix " << prefix << " in the collision context. The collision context specifies the following prefixes:";
351+
for (auto& sp : context->getSimPrefixes()) {
352+
LOG(info) << sp;
343353
}
344354
LOG(fatal) << "Aborting due to prefix error";
345355
} else {
346356
auto collisionmap = context->getCollisionIndicesForSource(sourceid);
347-
LOG(info) << "Found " << collisionmap.size() << " events in the collisioncontext for prefix " << mConfigData.mOutputPrefix;
357+
LOG(info) << "Found " << collisionmap.size() << " events in the collisioncontext for prefix " << prefix;
348358

349359
// check if collisionmap is dense (otherwise it will get screwed up with order/indexing in ROOT output)
350360
bool good = true;
@@ -368,7 +378,7 @@ void SimConfig::adjustFromCollContext()
368378
LOG(info) << "Setting number of events to simulate to " << mConfigData.mNEvents;
369379
}
370380
} else {
371-
LOG(fatal) << "Could not open collision context file " << mConfigData.mFromCollisionContext;
381+
LOG(fatal) << "Could not open collision context file " << collcontextfile;
372382
}
373383
}
374384

Common/Utils/include/CommonUtils/RootSerializableKeyValueStore.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,11 @@ class RootSerializableKeyValueStore
144144
/// print list of keys, values (and optionally type information)
145145
void print(bool includetypeinfo = false) const;
146146

147+
/// resets store to the store of another object
147148
void copyFrom(RootSerializableKeyValueStore const& other)
148149
{
149-
for (auto& p : other.mStore) {
150-
if (mStore.find(p.first) == mStore.end()) {
151-
mStore.insert(std::pair<std::string, SerializedInfo>(p.first, SerializedInfo(p.second)));
152-
}
153-
}
150+
mStore.clear();
151+
mStore = other.mStore;
154152
}
155153

156154
private:

DataFormats/Detectors/GlobalTracking/include/DataFormatsGlobalTracking/RecoContainer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,7 @@ struct RecoContainer {
340340
o2::ctp::LumiInfo mCTPLumi;
341341

342342
gsl::span<const unsigned char> clusterShMapTPC; ///< externally set TPC clusters sharing map
343+
gsl::span<const unsigned int> occupancyMapTPC; ///< externally set TPC clusters occupancy map
343344

344345
std::unique_ptr<o2::tpc::internal::getWorkflowTPCInput_ret> inputsTPCclusters; // special struct for TPC clusters access
345346
std::unique_ptr<o2::trd::RecoInputContainer> inputsTRD; // special struct for TRD tracklets, trigger records
@@ -371,7 +372,7 @@ struct RecoContainer {
371372

372373
void addITSClusters(o2::framework::ProcessingContext& pc, bool mc);
373374
void addMFTClusters(o2::framework::ProcessingContext& pc, bool mc);
374-
void addTPCClusters(o2::framework::ProcessingContext& pc, bool mc, bool shmap);
375+
void addTPCClusters(o2::framework::ProcessingContext& pc, bool mc, bool shmap, bool occmap);
375376
void addTPCTriggers(o2::framework::ProcessingContext& pc);
376377
void addTOFClusters(o2::framework::ProcessingContext& pc, bool mc);
377378
void addHMPClusters(o2::framework::ProcessingContext& pc, bool mc);

DataFormats/Detectors/GlobalTracking/src/RecoContainer.cxx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ void DataRequest::requestTPCTracks(bool mc)
119119
addInput({"trackTPCClRefs", "TPC", "CLUSREFS", 0, Lifetime::Timeframe});
120120
if (requestMap.find("clusTPC") != requestMap.end()) {
121121
addInput({"clusTPCshmap", "TPC", "CLSHAREDMAP", 0, Lifetime::Timeframe});
122+
addInput({"clusTPCoccmap", "TPC", "TPCOCCUPANCYMAP", 0, Lifetime::Timeframe});
122123
}
123124
if (mc) {
124125
addInput({"trackTPCMCTR", "TPC", "TRACKSMCLBL", 0, Lifetime::Timeframe});
@@ -255,6 +256,7 @@ void DataRequest::requestTPCClusters(bool mc)
255256
}
256257
if (requestMap.find("trackTPC") != requestMap.end()) {
257258
addInput({"clusTPCshmap", "TPC", "CLSHAREDMAP", 0, Lifetime::Timeframe});
259+
addInput({"clusTPCoccmap", "TPC", "TPCOCCUPANCYMAP", 0, Lifetime::Timeframe});
258260
}
259261
if (mc) {
260262
addInput({"clusTPCMC", ConcreteDataTypeMatcher{"TPC", "CLNATIVEMCLBL"}, Lifetime::Timeframe});
@@ -678,7 +680,8 @@ void RecoContainer::collectData(ProcessingContext& pc, const DataRequest& reques
678680

679681
req = reqMap.find("clusTPC");
680682
if (req != reqMap.end()) {
681-
addTPCClusters(pc, req->second, reqMap.find("trackTPC") != reqMap.end());
683+
auto tracksON = reqMap.find("trackTPC") != reqMap.end();
684+
addTPCClusters(pc, req->second, tracksON, tracksON);
682685
}
683686

684687
req = reqMap.find("trigTPC");
@@ -1060,12 +1063,15 @@ void RecoContainer::addMFTClusters(ProcessingContext& pc, bool mc)
10601063
}
10611064

10621065
//__________________________________________________________
1063-
void RecoContainer::addTPCClusters(ProcessingContext& pc, bool mc, bool shmap)
1066+
void RecoContainer::addTPCClusters(ProcessingContext& pc, bool mc, bool shmap, bool occmap)
10641067
{
10651068
inputsTPCclusters = o2::tpc::getWorkflowTPCInput(pc, 0, mc);
10661069
if (shmap) {
10671070
clusterShMapTPC = pc.inputs().get<gsl::span<unsigned char>>("clusTPCshmap");
10681071
}
1072+
if (occmap) {
1073+
occupancyMapTPC = pc.inputs().get<gsl::span<unsigned int>>("clusTPCoccmap");
1074+
}
10691075
}
10701076

10711077
//__________________________________________________________

DataFormats/simulation/include/SimulationDataFormat/MCEventHeader.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ class MCEventHeader : public FairMCEventHeader
142142
return ref;
143143
};
144144

145+
void print() const;
146+
145147
/// prints a summary of info keys/types attached to this header
146148
void printInfo() const
147149
{

DataFormats/simulation/src/MCEventHeader.cxx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "FairRootManager.h"
1616
#include <TFile.h>
1717
#include <TTree.h>
18+
#include <iostream>
1819

1920
namespace o2
2021
{
@@ -61,6 +62,21 @@ void MCEventHeader::extractFileFromKinematics(std::string_view kinefilename, std
6162
}
6263
}
6364

65+
void MCEventHeader::print() const
66+
{
67+
// print some used parts from FairMCEventHeader
68+
std::cout << "RunID " << fRunId << "\n";
69+
std::cout << "EventID " << fEventId << "\n";
70+
std::cout << "Vertex-X " << fX << "\n";
71+
std::cout << "Vertex-Y " << fY << "\n";
72+
std::cout << "Vertex-Z " << fZ << "\n";
73+
std::cout << "Vertex-T " << fT << "\n";
74+
std::cout << "Impact-B " << fB << "\n";
75+
std::cout << "NPrim " << fNPrim << "\n";
76+
// print meta-fields
77+
printInfo();
78+
}
79+
6480
/** alternative implementations below
6581
6682
void MCEventHeader::extractFileFromKinematics(std::string_view kinefilename, std::string_view targetfilename) {

Detectors/Align/Workflow/src/BarrelAlignmentSpec.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "TPCCalibration/VDriftHelper.h"
3939
#include "TPCCalibration/CorrectionMapsLoader.h"
4040
#include "GPUO2Interface.h"
41+
#include "GPUO2InterfaceUtils.h"
4142
#include "GPUParam.h"
4243
#include "Headers/DataHeader.h"
4344
#include "Framework/ConfigParamRegistry.h"

Detectors/Base/include/DetectorsBase/Detector.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include <typeinfo>
3030
#include <type_traits>
3131
#include <string>
32-
#include <TMessage.h>
3332
#include "CommonUtils/ShmManager.h"
3433
#include "CommonUtils/ShmAllocator.h"
3534
#include <sys/shm.h>
@@ -42,9 +41,7 @@
4241

4342
#include <fairmq/FwdDecls.h>
4443

45-
namespace o2
46-
{
47-
namespace base
44+
namespace o2::base
4845
{
4946

5047
/// This is the basic class for any AliceO2 detector module, whether it is
@@ -260,17 +257,12 @@ T decodeShmMessage(fair::mq::Parts& dataparts, int index, bool*& busy)
260257
}
261258

262259
// this goes into the source
263-
void attachMessageBufferToParts(fair::mq::Parts& parts, fair::mq::Channel& channel,
264-
void* data, size_t size, void (*func_ptr)(void* data, void* hint), void* hint);
260+
void attachMessageBufferToParts(fair::mq::Parts& parts, fair::mq::Channel& channel, void* data, TClass* cl);
265261

266262
template <typename Container>
267263
void attachTMessage(Container const& hits, fair::mq::Channel& channel, fair::mq::Parts& parts)
268264
{
269-
TMessage* tmsg = new TMessage();
270-
tmsg->WriteObjectAny((void*)&hits, TClass::GetClass(typeid(hits)));
271-
attachMessageBufferToParts(
272-
parts, channel, tmsg->Buffer(), tmsg->BufferSize(),
273-
[](void* data, void* hint) { delete static_cast<TMessage*>(hint); }, tmsg);
265+
attachMessageBufferToParts(parts, channel, (void*)&hits, TClass::GetClass(typeid(hits)));
274266
}
275267

276268
void* decodeTMessageCore(fair::mq::Parts& dataparts, int index);
@@ -746,7 +738,6 @@ class DetImpl : public o2::base::Detector
746738

747739
ClassDefOverride(DetImpl, 0);
748740
};
749-
} // namespace base
750-
} // namespace o2
741+
} // namespace o2::base
751742

752743
#endif

Detectors/Base/src/Detector.cxx

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "DetectorsBase/MaterialManager.h"
1818
#include "DetectorsCommonDataFormats/DetID.h"
1919
#include "Field/MagneticField.h"
20+
#include "Framework/TMessageSerializer.h"
2021
#include "TString.h" // for TString
2122
#include "TGeoManager.h"
2223

@@ -196,16 +197,19 @@ int Detector::registerSensitiveVolumeAndGetVolID(std::string const& name)
196197
#include <fairmq/Message.h>
197198
#include <fairmq/Parts.h>
198199
#include <fairmq/Channel.h>
199-
namespace o2
200-
{
201-
namespace base
200+
namespace o2::base
202201
{
203202
// this goes into the source
204-
void attachMessageBufferToParts(fair::mq::Parts& parts, fair::mq::Channel& channel, void* data, size_t size,
205-
void (*free_func)(void* data, void* hint), void* hint)
203+
void attachMessageBufferToParts(fair::mq::Parts& parts, fair::mq::Channel& channel, void* data, TClass* cl)
206204
{
207-
std::unique_ptr<fair::mq::Message> message(channel.NewMessage(data, size, free_func, hint));
208-
parts.AddPart(std::move(message));
205+
auto msg = channel.Transport()->CreateMessage(4096, fair::mq::Alignment{64});
206+
// This will serialize the data directly into the message buffer, without any further
207+
// buffer or copying. Notice how the message will have 8 bytes of header and then
208+
// the serialized data as TBufferFile. In principle one could construct a serialized TMessage payload
209+
// however I did not manage to get it to work for every case.
210+
o2::framework::FairOutputTBuffer buffer(*msg);
211+
o2::framework::TMessageSerializer::serialize(buffer, data, cl);
212+
parts.AddPart(std::move(msg));
209213
}
210214
void attachDetIDHeaderMessage(int id, fair::mq::Channel& channel, fair::mq::Parts& parts)
211215
{
@@ -246,17 +250,14 @@ void* decodeShmCore(fair::mq::Parts& dataparts, int index, bool*& busy)
246250

247251
void* decodeTMessageCore(fair::mq::Parts& dataparts, int index)
248252
{
249-
class TMessageWrapper : public TMessage
250-
{
251-
public:
252-
TMessageWrapper(void* buf, Int_t len) : TMessage(buf, len) { ResetBit(kIsOwner); }
253-
~TMessageWrapper() override = default;
254-
};
255253
auto rawmessage = std::move(dataparts.At(index));
256-
auto message = std::make_unique<TMessageWrapper>(rawmessage->GetData(), rawmessage->GetSize());
257-
return message.get()->ReadObjectAny(message.get()->GetClass());
254+
o2::framework::FairInputTBuffer buffer((char*)rawmessage->GetData(), rawmessage->GetSize());
255+
buffer.InitMap();
256+
auto* cl = buffer.ReadClass();
257+
buffer.SetBufferOffset(0);
258+
buffer.ResetMap();
259+
return buffer.ReadObjectAny(cl);
258260
}
259261

260-
} // namespace base
261-
} // namespace o2
262+
} // namespace o2::base
262263
ClassImp(o2::base::Detector);

0 commit comments

Comments
 (0)