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

SiStripApproximateCluster reduced data format for HI #33546

Merged
merged 19 commits into from
May 25, 2021
Merged
Show file tree
Hide file tree
Changes from 11 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
32 changes: 32 additions & 0 deletions DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H
#define DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H

#include <numeric>
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"

class SiStripApproximateClusterv1 {
icali marked this conversation as resolved.
Show resolved Hide resolved
public:

SiStripApproximateClusterv1() {}
explicit SiStripApproximateClusterv1(const SiStripCluster& cluster){
barycenter_=static_cast<uint16_t>(cluster.barycenter());
width_=cluster.size();
icali marked this conversation as resolved.
Show resolved Hide resolved
avgCharge_ = static_cast<uint8_t>(cluster.charge()/cluster.size());
icali marked this conversation as resolved.
Show resolved Hide resolved
}

explicit SiStripApproximateClusterv1(uint8_t avgCharge, uint16_t barycenter, uint8_t width):avgCharge_(avgCharge) {
barycenter_ = barycenter;
width_ = width;
if(width_>0x3F) width_=0x3F;
}

uint16_t barycenter() const {return barycenter_;}
icali marked this conversation as resolved.
Show resolved Hide resolved
uint8_t width() const {return width_;}
uint8_t avgCharge() const{return avgCharge_;}

private:
uint16_t barycenter_ = 0;
uint8_t width_=0;
uint8_t avgCharge_ = 0;
};
#endif // DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H
2 changes: 2 additions & 0 deletions DataFormats/SiStripCluster/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "DataFormats/Common/interface/DetSetVectorNew.h"
#include "DataFormats/Common/interface/Ref.h"
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h"

#include "DataFormats/Common/interface/ContainerMask.h"

#endif // SISTRIPCLUSTER_CLASSES_H
17 changes: 17 additions & 0 deletions DataFormats/SiStripCluster/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,21 @@
<class name="edm::Wrapper<edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<SiStripCluster>,SiStripCluster,edmNew::DetSetVector<SiStripCluster>::FindForDetSetVector> > >" />


<class name="SiStripApproximateClusterv1"/>
<class name="edmNew::DetSetVector<SiStripApproximateClusterv1>"/>
<class name="edm::Wrapper<edmNew::DetSetVector<SiStripApproximateClusterv1>>"/>

<class name="std::vector<SiStripApproximateClusterv1>"/>

<class name="edm::Ref<edmNew::DetSetVector<SiStripApproximateClusterv1>, SiStripApproximateClusterv1, edmNew::DetSetVector<SiStripApproximateClusterv1>::FindForDetSetVector>"/>


<class name="edm::ContainerMask<edmNew::DetSetVector<SiStripApproximateClusterv1> >"/>
<class name="edm::Wrapper<edm::ContainerMask<edmNew::DetSetVector<SiStripApproximateClusterv1> > >"/>


<class name="std::vector<edm::Ref<edmNew::DetSetVector<SiStripApproximateClusterv1>,SiStripApproximateClusterv1,edmNew::DetSetVector<SiStripApproximateClusterv1>::FindForDetSetVector> >" />
<class name="edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<SiStripApproximateClusterv1>,SiStripApproximateClusterv1,edmNew::DetSetVector<SiStripApproximateClusterv1>::FindForDetSetVector> >" />
<class name="edm::Wrapper<edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<SiStripApproximateClusterv1>,SiStripApproximateClusterv1,edmNew::DetSetVector<SiStripApproximateClusterv1>::FindForDetSetVector> > >" />

</lcgdict>
3 changes: 3 additions & 0 deletions RecoLocalTracker/SiStripClusterizer/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<use name="CalibFormats/SiStripObjects"/>
<use name="CalibTracker/Records"/>
<use name="RecoLocalTracker/Records"/>
<use name="CommonTools/UtilAlgos"/>
<use name="CommonTools/Utils"/>
<use name="root"/>
icali marked this conversation as resolved.
Show resolved Hide resolved
<export>
<lib name="1"/>
</export>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@


#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h"
#include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
#include "DataFormats/Common/interface/DetSetVectorNew.h"
#include "DataFormats/Common/interface/DetSetVector.h"


#include <vector>
#include <memory>

class SiStripClusters2ApproxClustersv1: public edm::stream::EDProducer<> {

public:

explicit SiStripClusters2ApproxClustersv1(const edm::ParameterSet& conf);
void produce(edm::Event&, const edm::EventSetup&) override;

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:

edm::InputTag inputClusters;
edm::EDGetTokenT< edmNew::DetSetVector<SiStripCluster> > clusterToken;
};



SiStripClusters2ApproxClustersv1::SiStripClusters2ApproxClustersv1(const edm::ParameterSet& conf){
inputClusters = conf.getParameter< edm::InputTag >("inputClusters");

clusterToken = consumes< edmNew::DetSetVector< SiStripCluster > >(inputClusters);
produces< edmNew::DetSetVector< SiStripApproximateClusterv1 > >();

}

void SiStripClusters2ApproxClustersv1::produce(edm::Event& e, edm::EventSetup const&){
auto result = std::make_unique<edmNew::DetSetVector< SiStripApproximateClusterv1 > >();
edm::Handle<edmNew::DetSetVector< SiStripCluster >> clusterCollection = e.getHandle(clusterToken);


for ( const auto& detClusters : *clusterCollection ) {
std::vector< SiStripApproximateClusterv1 > tempVec;
edmNew::DetSetVector<SiStripApproximateClusterv1>::FastFiller ff{*result, detClusters.id()};

for ( const auto& cluster : detClusters ) ff.push_back(SiStripApproximateClusterv1(cluster));

}

e.put(std::move(result));
}
icali marked this conversation as resolved.
Show resolved Hide resolved

void SiStripClusters2ApproxClustersv1::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("inputClusters", edm::InputTag("siStripClusters"));
descriptions.add("SiStripClusters2ApproxClustersv1", desc);
}


DEFINE_FWK_MODULE(SiStripClusters2ApproxClustersv1);
3 changes: 3 additions & 0 deletions RecoLocalTracker/SiStripClusterizer/test/SealModules.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
#include "RecoLocalTracker/SiStripClusterizer/test/StripByStripTestDriver.h"
#include "RecoLocalTracker/SiStripClusterizer/test/ClusterizerUnitTesterESProducer.h"
#include "RecoLocalTracker/SiStripClusterizer/test/ClusterRefinerTagMCmerged.h"
#include "RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h"

DEFINE_FWK_MODULE(CompareClusters);
DEFINE_FWK_MODULE(ClusterizerUnitTester);
DEFINE_FWK_MODULE(StripByStripTestDriver);
DEFINE_FWK_EVENTSETUP_MODULE(ClusterizerUnitTesterESProducer);
DEFINE_FWK_MODULE(ClusterRefinerTagMCmerged);
DEFINE_FWK_MODULE(SiStripApproximatedClustersDump);

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include "RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h"


SiStripApproximatedClustersDump::SiStripApproximatedClustersDump(const edm::ParameterSet& conf) {
inputTagClusters = conf.getParameter< edm::InputTag >("approximatedClustersTag");
clusterToken = consumes< edmNew::DetSetVector<SiStripApproximateClusterv1>>(inputTagClusters);

usesResource("TFileService");

outNtuple = fs->make<TTree>("ApproxClusters", "ApproxClusters");
outNtuple->Branch("event", &eventN, "event/i");
outNtuple->Branch("detId", &detId, "detId/i");
outNtuple->Branch("barycenter", &barycenter, "barycenter/F");
outNtuple->Branch("width", &width, "width/b");
outNtuple->Branch("charge", &avCharge, "charge/b");
}

SiStripApproximatedClustersDump::~SiStripApproximatedClustersDump() {}

void SiStripApproximatedClustersDump::analyze(const edm::Event& event, const edm::EventSetup& es) {
edm::Handle<edmNew::DetSetVector< SiStripApproximateClusterv1 >> clusterCollection = event.getHandle(clusterToken);


for ( const auto& detClusters : *clusterCollection ) {
detId = detClusters.detId();
eventN = event.id().event();

for ( const auto& cluster : detClusters ){
barycenter = cluster.barycenter();
width = cluster.width();
avCharge=cluster.avgCharge();
outNtuple->Fill();

}
}
}

void SiStripApproximatedClustersDump::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("approximatedClustersTag", edm::InputTag("SiStripClusters2ApproxClustersv1"));
descriptions.add("SiStripApproximatedClustersDump", desc);
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#ifndef RecoLocalTracker_SiStripApproximatedClustersDump_h
#define RecoLocalTracker_SiStripApproximatedClustersDump_h


// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/Common/interface/DetSet.h"
#include "DataFormats/Common/interface/DetSetVector.h"
#include "DataFormats/Common/interface/DetSetVectorNew.h"
#include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "CommonTools/Utils/interface/TFileDirectory.h"

#include <memory>
#include <iostream>

//ROOT inclusion
#include "TROOT.h"
#include "TFile.h"
#include "TNtuple.h"
#include "TTree.h"
#include "TMath.h"
#include "TList.h"
#include "TString.h"

//
// class decleration
//


class SiStripApproximatedClustersDump : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
explicit SiStripApproximatedClustersDump(const edm::ParameterSet&);
~SiStripApproximatedClustersDump() override;

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
void analyze(const edm::Event&, const edm::EventSetup&) override;

edm::InputTag inputTagClusters;
edm::EDGetTokenT< edmNew::DetSetVector<SiStripApproximateClusterv1> > clusterToken;

TTree* outNtuple;
edm::Service<TFileService> fs;

uint32_t detId;
uint16_t barycenter;
uint16_t width;
uint8_t avCharge;
edm::EventNumber_t eventN;
};
#endif
Loading