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 6 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
31 changes: 31 additions & 0 deletions DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H
#define DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H

#include <vector>
#include <numeric>
#include "FWCore/MessageLogger/interface/MessageLogger.h"
icali marked this conversation as resolved.
Show resolved Hide resolved

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

SiStripApproximateClusterv1() {}

explicit SiStripApproximateClusterv1(uint8_t avgCharge, uint16_t barycenter, uint8_t width):avgCharge_(avgCharge) {
baryWidth_ = barycenter;
baryWidth_ = baryWidth_ << 6;
if(width>0x3F) width=0x3F;
baryWidth_ += width;
}

uint16_t barycenter() const {return (uint16_t)((baryWidth_ & 0xFFC0) >> 6);}
uint8_t width() const {return (uint8_t) (baryWidth_ & 0x3F);}
icali marked this conversation as resolved.
Show resolved Hide resolved
uint16_t baryWidth() const {return baryWidth_;}
uint8_t avgCharge() const{return avgCharge_;}

private:

uint16_t baryWidth_ = 0;
icali marked this conversation as resolved.
Show resolved Hide resolved

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,32 @@
#ifndef RecoLocalTracker_SiStripClusters2ApproxClustersv1_h
#define RecoLocalTracker_SiStripClusters2ApproxClustersv1_h

#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 "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<> {
icali marked this conversation as resolved.
Show resolved Hide resolved

public:

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

private:

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

DEFINE_FWK_MODULE(SiStripClusters2ApproxClustersv1);
icali marked this conversation as resolved.
Show resolved Hide resolved
#endif

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include "RecoLocalTracker/SiStripClusterizer/interface/SiStripClusters2ApproxClustersv1.h"
#include <iostream>
icali marked this conversation as resolved.
Show resolved Hide resolved


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&){
std::unique_ptr<edmNew::DetSetVector< SiStripApproximateClusterv1 > > result(new edmNew::DetSetVector< SiStripApproximateClusterv1 > );
icali marked this conversation as resolved.
Show resolved Hide resolved

edm::Handle<edmNew::DetSetVector< SiStripCluster >> clusterCollection;
e.getByToken(clusterToken, clusterCollection);
icali marked this conversation as resolved.
Show resolved Hide resolved

uint32_t minID = 470444276;
int maxFirst = -1;

for( edmNew::DetSetVector<SiStripCluster>::const_iterator i = clusterCollection->begin(); i!=clusterCollection->end(); i++){
icali marked this conversation as resolved.
Show resolved Hide resolved

std::vector< SiStripApproximateClusterv1 > tempVec;

edmNew::DetSetVector<SiStripApproximateClusterv1>::FastFiller ff = edmNew::DetSetVector<SiStripApproximateClusterv1>::FastFiller(*result, i->id());
icali marked this conversation as resolved.
Show resolved Hide resolved

for( edmNew::DetSet<SiStripCluster>::const_iterator j = i->begin(); j!=i->end(); j++){
icali marked this conversation as resolved.
Show resolved Hide resolved

if(maxFirst<j->firstStrip()) maxFirst = j->firstStrip();
if(minID>i->id()) minID = i->id();

uint8_t width = j->amplitudes().size();
uint16_t barycenter = (uint16_t)j->barycenter();

int charge = 0;
for (unsigned k = 0; k < j->amplitudes().size(); k++) {
charge += (int)j->amplitudes()[k];
}

SiStripApproximateClusterv1 approxCluster = SiStripApproximateClusterv1( (uint8_t)(charge/width), barycenter, width );
ff.push_back(approxCluster);
icali marked this conversation as resolved.
Show resolved Hide resolved
}


}

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


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import FWCore.ParameterSet.Config as cms

SiStripApproximatedClustersDump = cms.EDAnalyzer("SiStripApproximatedClustersDump",
approximatedClustersTag = cms.InputTag("SiStripClusters2ApproxClustersv1")
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import FWCore.ParameterSet.Config as cms

SiStripClusters2ApproxClustersv1 = cms.EDProducer("SiStripClusters2ApproxClustersv1",
inputClusters = cms.InputTag("siStripClusters")
)

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,41 @@
#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>> inClusters;
event.getByToken(clusterToken, inClusters);


for (edmNew::DetSetVector<SiStripApproximateClusterv1>::const_iterator itApprox = inClusters->begin(); itApprox!= inClusters->end(); itApprox++) {
icali marked this conversation as resolved.
Show resolved Hide resolved
detId = itApprox->detId();
eventN = event.id().event();

for (edmNew::DetSet<SiStripApproximateClusterv1>::const_iterator itClusters = itApprox->begin(); itClusters!= itApprox->end(); itClusters++){

barycenter = itClusters->barycenter();
width = itClusters->width();
avCharge=itClusters->avgCharge();
outNtuple->Fill();

}
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#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/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;


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