diff --git a/code/core/write_sdl_ntuple.cc b/code/core/write_sdl_ntuple.cc index 327a5995..4a135dc7 100644 --- a/code/core/write_sdl_ntuple.cc +++ b/code/core/write_sdl_ntuple.cc @@ -136,6 +136,23 @@ void createOptionalOutputBranches() ana.tx->createBranch>("t5_rzChiSquared"); ana.tx->createBranch>("t5_nonAnchorChiSquared"); + // Occupancy branches + ana.tx->createBranch>("module_layers"); + ana.tx->createBranch>("module_subdets"); + ana.tx->createBranch>("module_rings"); + ana.tx->createBranch>("module_rods"); + ana.tx->createBranch>("module_modules"); + ana.tx->createBranch>("module_isTilted"); + ana.tx->createBranch>("module_eta"); + ana.tx->createBranch>("module_r"); + ana.tx->createBranch>("md_occupancies"); + ana.tx->createBranch>("sg_occupancies"); + ana.tx->createBranch>("t3_occupancies"); + ana.tx->createBranch("tc_occupancies"); + ana.tx->createBranch>("t5_occupancies"); + ana.tx->createBranch("pT3_occupancies"); + ana.tx->createBranch("pT5_occupancies"); + #endif } @@ -297,10 +314,76 @@ void setOptionalOutputBranches(SDL::Event* event) setPixelQuintupletOutputBranches(event); setQuintupletOutputBranches(event); setPixelTripletOutputBranches(event); + setOccupancyBranches(event); #endif } +//________________________________________________________________________________________________________________________________ +void setOccupancyBranches(SDL::Event* 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 moduleLayer; + std::vector moduleSubdet; + std::vector moduleRing; + std::vector moduleRod; + std::vector moduleModule; + std::vector moduleEta; + std::vector moduleR; + std::vector moduleIsTilted; + std::vector trackCandidateOccupancy; + std::vector tripletOccupancy; + std::vector segmentOccupancy; + std::vector mdOccupancy; + std::vector 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]); + + if(lowerIdx < *(modulesInGPU.nLowerModules)) + { + quintupletOccupancy.push_back(quintupletsInGPU.totOccupancyQuintuplets[lowerIdx]); + tripletOccupancy.push_back(tripletsInGPU.totOccupancyTriplets[lowerIdx]); + } + } + + ana.tx->setBranch>("module_layers", moduleLayer); + ana.tx->setBranch>("module_subdets", moduleSubdet); + ana.tx->setBranch>("module_rings", moduleRing); + ana.tx->setBranch>("module_rods", moduleRod); + ana.tx->setBranch>("module_modules", moduleModule); + ana.tx->setBranch>("module_isTilted", moduleIsTilted); + ana.tx->setBranch>("module_eta", moduleEta); + ana.tx->setBranch>("module_r", moduleR); + ana.tx->setBranch>("md_occupancies", mdOccupancy); + ana.tx->setBranch>("sg_occupancies", segmentOccupancy); + ana.tx->setBranch>("t3_occupancies", tripletOccupancy); + ana.tx->setBranch("tc_occupancies", *(trackCandidatesInGPU.nTrackCandidates)); + ana.tx->setBranch("pT3_occupancies", *(pixelTripletsInGPU.totOccupancyPixelTriplets)); + ana.tx->setBranch>("t5_occupancies", quintupletOccupancy); + ana.tx->setBranch("pT5_occupancies", *(pixelQuintupletsInGPU.totOccupancyPixelQuintuplets)); +} + //________________________________________________________________________________________________________________________________ void setPixelQuintupletOutputBranches(SDL::Event* event) { diff --git a/code/core/write_sdl_ntuple.h b/code/core/write_sdl_ntuple.h index 8a3a4207..5b77e1b4 100644 --- a/code/core/write_sdl_ntuple.h +++ b/code/core/write_sdl_ntuple.h @@ -20,6 +20,7 @@ void createGnnNtupleBranches(); void fillOutputBranches(SDL::Event* event); void setOutputBranches(SDL::Event* event); void setOptionalOutputBranches(SDL::Event* event); +void setOccupancyBranches(SDL::Event* event); void setPixelQuintupletOutputBranches(SDL::Event* event); void setQuintupletOutputBranches(SDL::Event* event); void setPixelTripletOutputBranches(SDL::Event *event);