Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

Commit

Permalink
works veto
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiemiddleton committed Jan 5, 2022
1 parent c34e701 commit 52e3ebc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
6 changes: 5 additions & 1 deletion include/Hcal/HcalWABVetoProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ class HcalWABVetoProcessor : public framework::Producer {
double maxnClusters_{0.};
double maxMeanHitsPerCluster_{0.};
double maxMeanEnergyPerCluster_{0.};

std::string outputCollName_;
std::string inputHCALClusterCollName_;
std::string inputHCALHitCollName_;
std::string inputECALHitCollName_;

}; // HcalWABVetoProcessor
} // namespace hcal

Expand Down
7 changes: 6 additions & 1 deletion python/hcal.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ def __init__(self,name = 'hcalWABVeto') :
self.n_clusters = 6.0;
self.mean_hits_per_cluster = 30.0;
self.mean_energy_per_cluster = 0.4;


self.inputHCALHitCollName = "HcalRecHits";
self.inputECALHitCollName = "EcalRecHits" ;
self.outputCollName = "HcalWABVetoes";
self.inputHCALClusterCollName = "HcalClusters"

class HcalOldDigiProducer(ldmxcfg.Producer) :
"""Configuration for Digitization producer in the HCal
Sets all parameters to reasonable defaults.
Expand Down
26 changes: 18 additions & 8 deletions src/Hcal/HcalWABVetoProcessor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,41 @@ namespace hcal {
maxnClusters_ = parameters.getParameter<double>("n_clusters");
maxMeanHitsPerCluster_ = parameters.getParameter<double>("mean_hits_per_cluster");
maxMeanEnergyPerCluster_ = parameters.getParameter<double>("mean_energy_per_cluster");
outputCollName_ = parameters.getParameter<std::string>("outputCollName");
inputHCALClusterCollName_ = parameters.getParameter<std::string>("inputHCALClusterCollName");
inputHCALHitCollName_ = parameters.getParameter<std::string>("inputHCALHitCollName");
inputECALHitCollName_ = parameters.getParameter<std::string>("inputECALHitCollName");
}

void HcalWABVetoProcessor::produce(framework::Event &event) {

// Get the collection of sim particles from the event
//HCAL:
const std::vector<ldmx::HcalHit> hcalRecHits =
event.getCollection<ldmx::HcalHit>("HcalRecHits");
event.getCollection<ldmx::HcalHit>(inputHCALHitCollName_);
//ECAL:
const std::vector<ldmx::EcalHit> ecalRecHits =
event.getCollection<ldmx::EcalHit>("EcalRecHits");
event.getCollection<ldmx::EcalHit>(inputECALHitCollName_);
//Clusters:
const std::vector<ldmx::HcalCluster> hcalClusters =
event.getCollection<ldmx::HcalCluster>("HcalClusters");
event.getCollection<ldmx::HcalCluster>(inputHCALClusterCollName_);

// Loop over all of the Hcal hits and calculate to total photoelectrons
// in the event.
float totalHCALEnergy{0};
float totalECALEnergy{0};
float maxPE{-1000};
const ldmx::HcalHit *maxPEHit;
for (const ldmx::HcalHit &hcalHit : hcalRecHits) {
if (hcalHit.isNoise()==0){
totalHCALEnergy += hcalHit.getPE();
}

// Find the maximum PE in the list
if (maxPE < hcalHit.getPE()) {
maxPE = hcalHit.getPE();
maxPEHit = &hcalHit;
}
}

for (const ldmx::EcalHit &ecalHit : ecalRecHits) {
Expand All @@ -61,12 +73,11 @@ namespace hcal {
for (const ldmx::HcalCluster &hcalCluster : hcalClusters) {
nClusters += 1;
energies.push_back(hcalCluster.getEnergy());
std::cout<<"cluster energy "<<hcalCluster.getEnergy()<<std::endl;
nhits.push_back(hcalCluster.getNHits());
}
double meanEnergy = std::accumulate(energies.begin(), energies.end(), 0.0) / energies.size();
double meanNhits = std::accumulate(nhits.begin(), nhits.end(), 0.0) / nhits.size();
std::cout<<totalECALEnergy + (1/25)*totalHCALEnergy<<" "<<nClusters<<" "<<meanEnergy<<" "<<meanNhits<<std::endl;

bool passesEnergyCombo = (totalECALEnergy + (1/25)*totalHCALEnergy < maxtotalEnergyCompare_ );
bool passesnClusters = (nClusters < maxnClusters_);
bool passesNHits = (meanEnergy < maxMeanHitsPerCluster_ );
Expand All @@ -76,16 +87,15 @@ namespace hcal {
bool passesVeto = (passesEnergyCombo and passesnClusters and passesNHits and passesEnergy);
ldmx::HcalVetoResult result;
result.setVetoResult(passesVeto);
//result.setMaxPEHit(*maxPEHit);TODO
std::cout<<"passes"<<passesVeto<<std::endl;
result.setMaxPEHit(*maxPEHit);
if (passesVeto) {
setStorageHint(framework::hint_shouldKeep);

} else {
setStorageHint(framework::hint_shouldDrop);
}

event.add("HcalVeto", result);
event.add(outputCollName_, result);

}
} // namespace hcal
Expand Down

0 comments on commit 52e3ebc

Please sign in to comment.