Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Occupancy Branches Back #404

Merged
merged 3 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions code/core/write_sdl_ntuple.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,23 @@ void createOptionalOutputBranches()
ana.tx->createBranch<vector<float>>("t5_rzChiSquared");
ana.tx->createBranch<vector<float>>("t5_nonAnchorChiSquared");

// Occupancy branches
ana.tx->createBranch<vector<int>>("module_layers");
ana.tx->createBranch<vector<int>>("module_subdets");
ana.tx->createBranch<vector<int>>("module_rings");
ana.tx->createBranch<vector<int>>("module_rods");
ana.tx->createBranch<vector<int>>("module_modules");
ana.tx->createBranch<vector<bool>>("module_isTilted");
ana.tx->createBranch<vector<float>>("module_eta");
ana.tx->createBranch<vector<float>>("module_r");
ana.tx->createBranch<vector<int>>("md_occupancies");
ana.tx->createBranch<vector<int>>("sg_occupancies");
ana.tx->createBranch<vector<int>>("t3_occupancies");
ana.tx->createBranch<int>("tc_occupancies");
ana.tx->createBranch<vector<int>>("t5_occupancies");
ana.tx->createBranch<int>("pT3_occupancies");
ana.tx->createBranch<int>("pT5_occupancies");

#endif
}

Expand Down Expand Up @@ -297,10 +314,72 @@ void setOptionalOutputBranches(SDL::Event<SDL::Acc>* event)
setPixelQuintupletOutputBranches(event);
setQuintupletOutputBranches(event);
setPixelTripletOutputBranches(event);
setOccupancyBranches(event);

#endif
}

//________________________________________________________________________________________________________________________________
void setOccupancyBranches(SDL::Event<SDL::Acc>* event)
{
SDL::modules& modulesInGPU = (*event->getModules());
SDL::miniDoublets& mdsInGPU = (*event->getMiniDoublets());
SDL::segments& segmentsInGPU = (*event->getSegments());
SDL::triplets& tripletsInGPU = (*event->getTriplets());
SDL::quintuplets& quintupletsInGPU = (*event->getQuintuplets());
SDL::pixelQuintuplets& pixelQuintupletsInGPU = (*event->getPixelQuintuplets());
SDL::pixelTriplets& pixelTripletsInGPU = (*event->getPixelTriplets());
SDL::trackCandidates& trackCandidatesInGPU = (*event->getTrackCandidates());

std::vector<int> moduleLayer;
std::vector<int> moduleSubdet;
std::vector<int> moduleRing;
std::vector<int> moduleRod;
std::vector<int> moduleModule;
std::vector<float> moduleEta;
std::vector<float> moduleR;
std::vector<bool> moduleIsTilted;
std::vector<int> trackCandidateOccupancy;
std::vector<int> tripletOccupancy;
std::vector<int> segmentOccupancy;
std::vector<int> mdOccupancy;
std::vector<int> quintupletOccupancy;

for(unsigned int lowerIdx = 0; lowerIdx <= *(modulesInGPU.nLowerModules); lowerIdx++)
{
//layer = 0, subdet = 0 => pixel module
moduleLayer.push_back(modulesInGPU.layers[lowerIdx]);
moduleSubdet.push_back(modulesInGPU.subdets[lowerIdx]);
moduleRing.push_back(modulesInGPU.rings[lowerIdx]);
moduleRod.push_back(modulesInGPU.rods[lowerIdx]);
moduleEta.push_back(modulesInGPU.eta[lowerIdx]);
moduleR.push_back(modulesInGPU.r[lowerIdx]);
bool isTilted = (modulesInGPU.subdets[lowerIdx] == 5 and modulesInGPU.sides[lowerIdx] != 3);
moduleIsTilted.push_back(isTilted);
moduleModule.push_back(modulesInGPU.modules[lowerIdx]);
segmentOccupancy.push_back(segmentsInGPU.totOccupancySegments[lowerIdx]);
mdOccupancy.push_back(mdsInGPU.totOccupancyMDs[lowerIdx]);
quintupletOccupancy.push_back(quintupletsInGPU.totOccupancyQuintuplets[lowerIdx]);
tripletOccupancy.push_back(tripletsInGPU.totOccupancyTriplets[lowerIdx]);
GNiendorf marked this conversation as resolved.
Show resolved Hide resolved
}

ana.tx->setBranch<vector<int>>("module_layers", moduleLayer);
ana.tx->setBranch<vector<int>>("module_subdets", moduleSubdet);
ana.tx->setBranch<vector<int>>("module_rings", moduleRing);
ana.tx->setBranch<vector<int>>("module_rods", moduleRod);
ana.tx->setBranch<vector<int>>("module_modules", moduleModule);
ana.tx->setBranch<vector<bool>>("module_isTilted", moduleIsTilted);
ana.tx->setBranch<vector<float>>("module_eta", moduleEta);
ana.tx->setBranch<vector<float>>("module_r", moduleR);
ana.tx->setBranch<vector<int>>("md_occupancies", mdOccupancy);
ana.tx->setBranch<vector<int>>("sg_occupancies", segmentOccupancy);
ana.tx->setBranch<vector<int>>("t3_occupancies", tripletOccupancy);
ana.tx->setBranch<int>("tc_occupancies", *(trackCandidatesInGPU.nTrackCandidates));
ana.tx->setBranch<int>("pT3_occupancies", *(pixelTripletsInGPU.totOccupancyPixelTriplets));
ana.tx->setBranch<vector<int>>("t5_occupancies", quintupletOccupancy);
ana.tx->setBranch<int>("pT5_occupancies", *(pixelQuintupletsInGPU.totOccupancyPixelQuintuplets));
}

//________________________________________________________________________________________________________________________________
void setPixelQuintupletOutputBranches(SDL::Event<SDL::Acc>* event)
{
Expand Down
1 change: 1 addition & 0 deletions code/core/write_sdl_ntuple.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ void createGnnNtupleBranches();
void fillOutputBranches(SDL::Event<SDL::Acc>* event);
void setOutputBranches(SDL::Event<SDL::Acc>* event);
void setOptionalOutputBranches(SDL::Event<SDL::Acc>* event);
void setOccupancyBranches(SDL::Event<SDL::Acc>* event);
void setPixelQuintupletOutputBranches(SDL::Event<SDL::Acc>* event);
void setQuintupletOutputBranches(SDL::Event<SDL::Acc>* event);
void setPixelTripletOutputBranches(SDL::Event<SDL::Acc> *event);
Expand Down