diff --git a/[refs] b/[refs] index 433e1a3d87f36..2f0b8a8559e18 100644 --- a/[refs] +++ b/[refs] @@ -1,3 +1,3 @@ --- refs/heads/gh-pages: 09c786f70121f131b3715aaf3464996502bbeb7e -"refs/heads/CMSSW_7_1_X": 96fa02802b722c0ee6cf5b1236b4b005289bb1ea +"refs/heads/CMSSW_7_1_X": c48430cf10ee1dbe19616d42776a128e00c42705 diff --git a/trunk/CalibTracker/SiStripCommon/BuildFile b/trunk/CalibTracker/SiStripCommon/BuildFile index 9566a8e05eb89..33695f7d33b03 100644 --- a/trunk/CalibTracker/SiStripCommon/BuildFile +++ b/trunk/CalibTracker/SiStripCommon/BuildFile @@ -1,15 +1,7 @@ - - - - - - + + - - - - - - + + diff --git a/trunk/CalibTracker/SiStripCommon/interface/ShallowClustersProducer.h b/trunk/CalibTracker/SiStripCommon/interface/ShallowClustersProducer.h new file mode 100644 index 0000000000000..873713e73c200 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/interface/ShallowClustersProducer.h @@ -0,0 +1,40 @@ +#ifndef SHALLOW_CLUSTERS_PRODUCER +#define SHALLOW_CLUSTERS_PRODUCER + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "DataFormats/Common/interface/DetSetVector.h" +class SiStripClusterInfo; +class SiStripProcessedRawDigi; + +class ShallowClustersProducer : public edm::EDProducer { + + public: + + explicit ShallowClustersProducer(const edm::ParameterSet&); + + private: + + edm::InputTag theClustersLabel; + std::string Prefix; + void produce( edm::Event &, const edm::EventSetup & ); + + struct moduleVars { + moduleVars(uint32_t); + int subdetid, side, layerwheel, stringringrod, petal, stereo; + uint32_t module; + }; + + struct NearDigis { + NearDigis(const SiStripClusterInfo&); + NearDigis(const SiStripClusterInfo&, const edm::DetSetVector&); + float max, left, right, first, last, Lleft, Rright; + float etaX() const {return (left+right)/max/2.;} + float eta() const {return right>left ? max/(max+right) : left/(left+max);} + float etaasymm() const {return right>left ? (right-max)/(right+max) : (max-left)/(max+left);} + float outsideasymm() const {return (last-first)/(last+first);} + }; + +}; + +#endif diff --git a/trunk/CalibTracker/SiStripCommon/interface/ShallowDigisProducer.h b/trunk/CalibTracker/SiStripCommon/interface/ShallowDigisProducer.h new file mode 100644 index 0000000000000..fa2787cb369e0 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/interface/ShallowDigisProducer.h @@ -0,0 +1,39 @@ +#ifndef SHALLOW_DIGIS_PRODUCER +#define SHALLOW_DIGIS_PRODUCER + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/ESHandle.h" +class SiStripNoises; + +class ShallowDigisProducer : public edm::EDProducer { + + public: + + explicit ShallowDigisProducer(const edm::ParameterSet&); + + private: + struct products { + std::auto_ptr > id; + std::auto_ptr > subdet; + std::auto_ptr > strip; + std::auto_ptr > adc; + std::auto_ptr > noise; + products() + : id(new std::vector()), + subdet(new std::vector()), + strip(new std::vector()), + adc(new std::vector()), + noise(new std::vector()) {} + }; + std::vector inputTags; + edm::ESHandle noiseHandle; + + void produce(edm::Event&, const edm::EventSetup&); + template bool findInput(edm::Handle&, const edm::Event&); + template void recordDigis(const T &, products&); + void insert(products&, edm::Event&); + +}; + +#endif diff --git a/trunk/CalibTracker/SiStripCommon/interface/ShallowEventDataProducer.h b/trunk/CalibTracker/SiStripCommon/interface/ShallowEventDataProducer.h new file mode 100644 index 0000000000000..97e284456fd21 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/interface/ShallowEventDataProducer.h @@ -0,0 +1,14 @@ +#ifndef SHALLOW_EVENTDATA_PRODUCER +#define SHALLOW_EVENTDATA_PRODUCER + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" + +class ShallowEventDataProducer : public edm::EDProducer { + public: + explicit ShallowEventDataProducer(const edm::ParameterSet&); + private: + void produce( edm::Event &, const edm::EventSetup & ); +}; + +#endif diff --git a/trunk/CalibTracker/SiStripCommon/interface/ShallowExampleProducer.h b/trunk/CalibTracker/SiStripCommon/interface/ShallowExampleProducer.h new file mode 100644 index 0000000000000..6981cdee578f2 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/interface/ShallowExampleProducer.h @@ -0,0 +1,14 @@ +#ifndef SHALLOW_EXAMPLE_PRODUCER +#define SHALLOW_EXAMPLE_PRODUCER + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" + +class ShallowExampleProducer : public edm::EDProducer { +public: + explicit ShallowExampleProducer(const edm::ParameterSet&); +private: + void produce( edm::Event &, const edm::EventSetup & ); +}; + +#endif diff --git a/trunk/CalibTracker/SiStripCommon/interface/ShallowRechitClustersProducer.h b/trunk/CalibTracker/SiStripCommon/interface/ShallowRechitClustersProducer.h new file mode 100644 index 0000000000000..1d4c30e6ef6d4 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/interface/ShallowRechitClustersProducer.h @@ -0,0 +1,18 @@ +#ifndef SHALLOW_RECHITCLUSTERS_PRODUCER +#define SHALLOW_RECHITCLUSTERS_PRODUCER + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" + +class ShallowRechitClustersProducer : public edm::EDProducer { +public: + explicit ShallowRechitClustersProducer(const edm::ParameterSet&); +private: + std::string Suffix; + std::string Prefix; + edm::InputTag theClustersLabel; + std::vector inputTags; + void produce( edm::Event &, const edm::EventSetup & ); +}; + +#endif diff --git a/trunk/CalibTracker/SiStripCommon/interface/ShallowSimTracksProducer.h b/trunk/CalibTracker/SiStripCommon/interface/ShallowSimTracksProducer.h new file mode 100644 index 0000000000000..e2c952a9bf04a --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/interface/ShallowSimTracksProducer.h @@ -0,0 +1,23 @@ +#ifndef SHALLOW_SIMTRACKS_PRODUCER +#define SHALLOW_SIMTRACKS_PRODUCER + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" + +class ShallowSimTracksProducer : public edm::EDProducer { + + public: + + explicit ShallowSimTracksProducer(const edm::ParameterSet&); + + private: + + const std::string Prefix; + const std::string Suffix; + const edm::InputTag trackingParticles_tag; + const edm::ESInputTag associator_tag; + const edm::InputTag tracks_tag; + void produce( edm::Event &, const edm::EventSetup & ); + +}; +#endif diff --git a/trunk/CalibTracker/SiStripCommon/interface/ShallowSimhitClustersProducer.h b/trunk/CalibTracker/SiStripCommon/interface/ShallowSimhitClustersProducer.h new file mode 100644 index 0000000000000..e7e42e1a1f506 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/interface/ShallowSimhitClustersProducer.h @@ -0,0 +1,23 @@ +#ifndef SHALLOW_SIMHITCLUSTERS_PRODUCER +#define SHALLOW_SIMHITCLUSTERS_PRODUCER + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "CalibTracker/SiStripCommon/interface/ShallowTools.h" +class SiStripCluster; + +class ShallowSimhitClustersProducer : public edm::EDProducer { + public: + explicit ShallowSimhitClustersProducer(const edm::ParameterSet&); + private: + std::vector inputTags; + edm::InputTag theClustersLabel; + std::string Prefix; + + void produce( edm::Event &, const edm::EventSetup & ); + shallow::CLUSTERMAP::const_iterator match_cluster(const unsigned&, + const float&, + const shallow::CLUSTERMAP&, + const edmNew::DetSetVector& ) const; +}; +#endif diff --git a/trunk/CalibTracker/SiStripCommon/interface/ShallowTools.h b/trunk/CalibTracker/SiStripCommon/interface/ShallowTools.h new file mode 100644 index 0000000000000..4af5ddd56eef8 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/interface/ShallowTools.h @@ -0,0 +1,24 @@ +#ifndef USERCODE_SHALLOWTOOLS_SHALLOWTOOLS +#define USERCODE_SHALLOWTOOLS_SHALLOWTOOLS + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/TrackReco/interface/Track.h" + +class StripGeomDetUnit; +class MagneticField; +class SiStripLorentzAngle; +class Event; +namespace edm {class InputTag;} + +namespace shallow { + +typedef std::map, unsigned int> CLUSTERMAP; + +CLUSTERMAP make_cluster_map( const edm::Event& , edm::InputTag&); +LocalVector drift( const StripGeomDetUnit*, const MagneticField&, const SiStripLorentzAngle&); +int findTrackIndex(const edm::Handle >& h, const reco::Track* t); + +} + +#endif diff --git a/trunk/CalibTracker/SiStripCommon/interface/ShallowTrackClustersProducer.h b/trunk/CalibTracker/SiStripCommon/interface/ShallowTrackClustersProducer.h new file mode 100644 index 0000000000000..08d06a933a742 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/interface/ShallowTrackClustersProducer.h @@ -0,0 +1,18 @@ +#ifndef SHALLOW_TRACKCLUSTERS_PRODUCER +#define SHALLOW_TRACKCLUSTERS_PRODUCER + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" + +class ShallowTrackClustersProducer : public edm::EDProducer { +public: + explicit ShallowTrackClustersProducer(const edm::ParameterSet&); +private: + edm::InputTag theTracksLabel; + edm::InputTag theClustersLabel; + std::string Suffix; + std::string Prefix; + + void produce( edm::Event &, const edm::EventSetup & ); +}; +#endif diff --git a/trunk/CalibTracker/SiStripCommon/interface/ShallowTracksProducer.h b/trunk/CalibTracker/SiStripCommon/interface/ShallowTracksProducer.h new file mode 100644 index 0000000000000..c3d53670b13a0 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/interface/ShallowTracksProducer.h @@ -0,0 +1,16 @@ +#ifndef SHALLOW_TRACKS_PRODUCER +#define SHALLOW_TRACKS_PRODUCER + +#include "FWCore/Framework/interface/EDProducer.h" +#include "FWCore/Framework/interface/Frameworkfwd.h" + +class ShallowTracksProducer : public edm::EDProducer { +public: + explicit ShallowTracksProducer(const edm::ParameterSet&); +private: + edm::InputTag theTracksLabel; + std::string Prefix; + std::string Suffix; + void produce( edm::Event &, const edm::EventSetup & ); +}; +#endif diff --git a/trunk/CalibTracker/SiStripCommon/interface/ShallowTree.h b/trunk/CalibTracker/SiStripCommon/interface/ShallowTree.h new file mode 100644 index 0000000000000..e5770fbfc665b --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/interface/ShallowTree.h @@ -0,0 +1,73 @@ +#ifndef Shallow_Tree_h +#define Shallow_Tree_h + +/** \class ShallowTree + * + * Makes a tree out of C++ standard types and vectors of C++ standard types + * + * This class, which is an EDAnalyzer, takes the same "keep" and + * "drop" outputCommands parameter as the PoolOutputSource, making a + * tree of the selected variables, which it obtains from the EDM + * tree. + * + * See the file python/test_cfg.py for an example configuration. + * + * See the file doc/README for more detailed documentation, including + * advantages, disadvantages, and use philosophy. + * + * $Date: 2008/08/23 16:46:29 $ + * $Revision: 1.1 $ + * \author Burt Betchart - University of Rochester + */ + +#include "FWCore/Framework/interface/Frameworkfwd.h" +#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/ServiceRegistry/interface/Service.h" +#include "PhysicsTools/UtilAlgos/interface/TFileService.h" + +#include +#include +#include + +class ShallowTree : public edm::EDAnalyzer { +private: + virtual void beginJob(const edm::EventSetup&); + virtual void analyze(const edm::Event&, const edm::EventSetup&); + virtual void endJob(){} + + class BranchConnector { + public: + virtual ~BranchConnector() {}; + virtual void connect(const edm::Event&) = 0; + }; + + template + class TypedBranchConnector : public BranchConnector { + private: + std::string ml; //module label + std::string pin; //product instance name + T object_; + T* object_ptr_; + public: + TypedBranchConnector(edm::BranchDescription const*, std::string, TTree*); + void connect(const edm::Event&); + }; + + edm::Service fs; + TTree * tree; + std::vector connectors; + edm::ParameterSet pset; + +public: + explicit ShallowTree(const edm::ParameterSet& iConfig) : pset(iConfig) {} + + enum LEAFTYPE {BOOL=1, BOOL_V, + SHORT, SHORT_V, U_SHORT, U_SHORT_V, + INT, INT_V, U_INT, U_INT_V, + FLOAT, FLOAT_V, DOUBLE, DOUBLE_V, + LONG, LONG_V, U_LONG, U_LONG_V }; +}; + +#endif diff --git a/trunk/CalibTracker/SiStripCommon/plugins/BuildFile b/trunk/CalibTracker/SiStripCommon/plugins/BuildFile index cb8a260aaab14..168acfe328b6e 100644 --- a/trunk/CalibTracker/SiStripCommon/plugins/BuildFile +++ b/trunk/CalibTracker/SiStripCommon/plugins/BuildFile @@ -1,8 +1,7 @@ - - - - - + + + + diff --git a/trunk/CalibTracker/SiStripCommon/plugins/SealModules.cc b/trunk/CalibTracker/SiStripCommon/plugins/SealModules.cc index 6a709cd8f96a6..887dd2f1e4b1e 100644 --- a/trunk/CalibTracker/SiStripCommon/plugins/SealModules.cc +++ b/trunk/CalibTracker/SiStripCommon/plugins/SealModules.cc @@ -1,5 +1,4 @@ #include "FWCore/PluginManager/interface/ModuleDef.h" - #include "FWCore/Framework/interface/MakerMacros.h" //#include "FWCore/Framework/interface/ModuleFactory.h" //#include "FWCore/Framework/interface/eventsetupdata_registration_macro.h" @@ -16,3 +15,23 @@ DEFINE_ANOTHER_FWK_SERVICE(SiStripDetInfoFileReader); #include "CalibTracker/SiStripCommon/interface/TkDetMap.h" DEFINE_ANOTHER_FWK_SERVICE(TkDetMap); + +#include "CalibTracker/SiStripCommon/interface/ShallowTree.h" +#include "CalibTracker/SiStripCommon/interface/ShallowEventDataProducer.h" +#include "CalibTracker/SiStripCommon/interface/ShallowDigisProducer.h" +#include "CalibTracker/SiStripCommon/interface/ShallowClustersProducer.h" +#include "CalibTracker/SiStripCommon/interface/ShallowTrackClustersProducer.h" +#include "CalibTracker/SiStripCommon/interface/ShallowRechitClustersProducer.h" +#include "CalibTracker/SiStripCommon/interface/ShallowSimhitClustersProducer.h" +#include "CalibTracker/SiStripCommon/interface/ShallowTracksProducer.h" +#include "CalibTracker/SiStripCommon/interface/ShallowSimTracksProducer.h" + +DEFINE_ANOTHER_FWK_MODULE(ShallowTree); +DEFINE_ANOTHER_FWK_MODULE(ShallowEventDataProducer); +DEFINE_ANOTHER_FWK_MODULE(ShallowDigisProducer); +DEFINE_ANOTHER_FWK_MODULE(ShallowClustersProducer); +DEFINE_ANOTHER_FWK_MODULE(ShallowTrackClustersProducer); +DEFINE_ANOTHER_FWK_MODULE(ShallowRechitClustersProducer); +DEFINE_ANOTHER_FWK_MODULE(ShallowSimhitClustersProducer); +DEFINE_ANOTHER_FWK_MODULE(ShallowTracksProducer); +DEFINE_ANOTHER_FWK_MODULE(ShallowSimTracksProducer); diff --git a/trunk/CalibTracker/SiStripCommon/plugins/ShallowClustersProducer.cc b/trunk/CalibTracker/SiStripCommon/plugins/ShallowClustersProducer.cc new file mode 100644 index 0000000000000..3918f8512ec4a --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/plugins/ShallowClustersProducer.cc @@ -0,0 +1,256 @@ +#include "CalibTracker/SiStripCommon/interface/ShallowClustersProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "AnalysisDataFormats/SiStripClusterInfo/interface/SiStripClusterInfo.h" +#include "AnalysisDataFormats/SiStripClusterInfo/interface/SiStripProcessedRawDigi.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/SiStripDetId/interface/TECDetId.h" +#include "DataFormats/SiStripDetId/interface/TIBDetId.h" +#include "DataFormats/SiStripDetId/interface/TIDDetId.h" +#include "DataFormats/SiStripDetId/interface/TOBDetId.h" +#include "boost/foreach.hpp" + +ShallowClustersProducer::ShallowClustersProducer(const edm::ParameterSet& iConfig) + : theClustersLabel(iConfig.getParameter("Clusters")), + Prefix(iConfig.getParameter("Prefix") ) +{ + produces > ( Prefix + "number" ); + produces > ( Prefix + "width" ); + produces > ( Prefix + "variance" ); + produces > ( Prefix + "barystrip" ); + produces > ( Prefix + "middlestrip" ); + produces > ( Prefix + "charge" ); + produces > ( Prefix + "noise" ); + produces > ( Prefix + "ston" ); + produces > ( Prefix + "seedstrip" ); + produces > ( Prefix + "seedindex" ); + produces > ( Prefix + "seedcharge" ); + produces > ( Prefix + "seednoise" ); + produces > ( Prefix + "seedgain" ); + produces > ( Prefix + "qualityisbad" ); + + produces > ( Prefix + "rawchargeC" ); + produces > ( Prefix + "rawchargeL" ); + produces > ( Prefix + "rawchargeR" ); + produces > ( Prefix + "rawchargeLL" ); + produces > ( Prefix + "rawchargeRR" ); + produces > ( Prefix + "eta" ); + produces > ( Prefix + "foldedeta" ); + produces > ( Prefix + "etaX" ); + produces > ( Prefix + "etaasymm" ); + produces > ( Prefix + "outsideasymm"); + produces > ( Prefix + "neweta"); + produces > ( Prefix + "newetaerr"); + + produces > ( Prefix + "detid" ); + produces > ( Prefix + "subdetid" ); + produces > ( Prefix + "module" ); + produces > ( Prefix + "side" ); + produces > ( Prefix + "layerwheel" ); + produces > ( Prefix + "stringringrod" ); + produces > ( Prefix + "petal" ); + produces > ( Prefix + "stereo" ); + +} + +void ShallowClustersProducer:: +produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + std::auto_ptr > number ( new std::vector(7,0) ); + std::auto_ptr > width ( new std::vector() ); + std::auto_ptr > variance ( new std::vector() ); + std::auto_ptr > barystrip ( new std::vector() ); + std::auto_ptr > middlestrip ( new std::vector() ); + std::auto_ptr > charge ( new std::vector() ); + std::auto_ptr > noise ( new std::vector() ); + std::auto_ptr > ston ( new std::vector() ); + std::auto_ptr > seedstrip ( new std::vector() ); + std::auto_ptr > seedindex ( new std::vector() ); + std::auto_ptr > seedcharge ( new std::vector() ); + std::auto_ptr > seednoise ( new std::vector() ); + std::auto_ptr > seedgain ( new std::vector() ); + std::auto_ptr > qualityisbad ( new std::vector() ); + + std::auto_ptr > rawchargeC ( new std::vector() ); + std::auto_ptr > rawchargeL ( new std::vector() ); + std::auto_ptr > rawchargeR ( new std::vector() ); + std::auto_ptr > rawchargeLL ( new std::vector() ); + std::auto_ptr > rawchargeRR ( new std::vector() ); + std::auto_ptr > etaX ( new std::vector() ); + std::auto_ptr > eta ( new std::vector() ); + std::auto_ptr > foldedeta ( new std::vector() ); + std::auto_ptr > etaasymm ( new std::vector() ); + std::auto_ptr > outsideasymm ( new std::vector() ); + std::auto_ptr > neweta ( new std::vector() ); + std::auto_ptr > newetaerr ( new std::vector() ); + + std::auto_ptr > detid ( new std::vector() ); + std::auto_ptr > subdetid ( new std::vector() ); + std::auto_ptr > side ( new std::vector() ); + std::auto_ptr > module ( new std::vector() ); + std::auto_ptr > layerwheel ( new std::vector() ); + std::auto_ptr > stringringrod ( new std::vector() ); + std::auto_ptr > petal ( new std::vector() ); + std::auto_ptr > stereo ( new std::vector()); + + edm::Handle > clusters; + iEvent.getByLabel(theClustersLabel, clusters); + + edm::Handle > rawProcessedDigis; + iEvent.getByLabel("siStripProcessedRawDigis", "", rawProcessedDigis); + + BOOST_FOREACH( const edmNew::DetSet ds, *clusters) { + const moduleVars moduleV(ds.detId()); + BOOST_FOREACH( const SiStripCluster cluster, ds) { + const SiStripClusterInfo info(cluster, iSetup); + const NearDigis digis = rawProcessedDigis.isValid() ? NearDigis(info, *rawProcessedDigis) : NearDigis(info); + + (number->at(0))++; + (number->at(moduleV.subdetid))++; + width->push_back( cluster.amplitudes().size() ); + barystrip->push_back( cluster.barycenter() ); + variance->push_back( info.variance() ); + middlestrip->push_back( info.firstStrip() + info.width()/2.0 ); + charge->push_back( info.charge() ); + noise->push_back( info.noiseRescaledByGain() ); + ston->push_back( info.signalOverNoise() ); + seedstrip->push_back( info.maxStrip() ); + seedindex->push_back( info.maxIndex() ); + seedcharge->push_back( info.maxCharge() ); + seednoise->push_back( info.stripNoisesRescaledByGain().at(info.maxIndex()) ); + seedgain->push_back( info.stripGains().at(info.maxIndex()) ); + qualityisbad->push_back( info.IsAnythingBad() ); + + rawchargeC->push_back( digis.max ); + rawchargeL->push_back( digis.left ); + rawchargeR->push_back( digis.right ); + rawchargeLL->push_back( digis.Lleft ); + rawchargeRR->push_back( digis.Rright ); + etaX->push_back( digis.etaX() ); + eta->push_back( digis.eta() ); + etaasymm->push_back( digis.etaasymm() ); + outsideasymm->push_back( digis.outsideasymm() ); + neweta->push_back( (digis.last-digis.first)/info.charge() ); + newetaerr->push_back( (sqrt(digis.last+digis.first))/pow(info.charge(),1.5) ); + + detid->push_back( ds.detId() ); + subdetid->push_back( moduleV.subdetid ); + side->push_back( moduleV.side ); + module->push_back( moduleV.module ); + layerwheel->push_back( moduleV.layerwheel ); + stringringrod->push_back( moduleV.stringringrod ); + petal->push_back( moduleV.petal ); + stereo->push_back( moduleV.stereo ); + } + } + + iEvent.put( number, Prefix + "number" ); + iEvent.put( width, Prefix + "width" ); + iEvent.put( variance, Prefix + "variance" ); + iEvent.put( barystrip, Prefix + "barystrip" ); + iEvent.put( middlestrip, Prefix + "middlestrip" ); + iEvent.put( charge, Prefix + "charge" ); + iEvent.put( noise, Prefix + "noise" ); + iEvent.put( ston, Prefix + "ston" ); + iEvent.put( seedstrip, Prefix + "seedstrip" ); + iEvent.put( seedindex, Prefix + "seedindex" ); + iEvent.put( seedcharge, Prefix + "seedcharge" ); + iEvent.put( seednoise, Prefix + "seednoise" ); + iEvent.put( seedgain, Prefix + "seedgain" ); + iEvent.put( qualityisbad, Prefix + "qualityisbad" ); + + iEvent.put( rawchargeC, Prefix + "rawchargeC" ); + iEvent.put( rawchargeL, Prefix + "rawchargeL" ); + iEvent.put( rawchargeR, Prefix + "rawchargeR" ); + iEvent.put( rawchargeLL, Prefix + "rawchargeLL" ); + iEvent.put( rawchargeRR, Prefix + "rawchargeRR" ); + iEvent.put( etaX, Prefix + "etaX" ); + iEvent.put( eta, Prefix + "eta" ); + iEvent.put( foldedeta, Prefix + "foldedeta" ); + iEvent.put( etaasymm, Prefix + "etaasymm" ); + iEvent.put( outsideasymm, Prefix + "outsideasymm" ); + iEvent.put( neweta, Prefix + "neweta" ); + iEvent.put( newetaerr, Prefix + "newetaerr" ); + + iEvent.put( detid, Prefix + "detid" ); + iEvent.put( subdetid, Prefix + "subdetid" ); + iEvent.put( module, Prefix + "module" ); + iEvent.put( side, Prefix + "side" ); + iEvent.put( layerwheel, Prefix + "layerwheel" ); + iEvent.put( stringringrod, Prefix + "stringringrod" ); + iEvent.put( petal, Prefix + "petal" ); + iEvent.put( stereo, Prefix + "stereo" ); + +} + +ShallowClustersProducer::NearDigis:: +NearDigis(const SiStripClusterInfo& info) { + max = info.maxCharge(); + left = info.maxIndex() > uint16_t(0) ? info.stripCharges().at(info.maxIndex()-1) : 0 ; + Lleft = info.maxIndex() > uint16_t(1) ? info.stripCharges().at(info.maxIndex()-2) : 0 ; + right= unsigned(info.maxIndex()+1) < info.stripCharges().size() ? info.stripCharges().at(info.maxIndex()+1) : 0 ; + Rright= unsigned(info.maxIndex()+2) < info.stripCharges().size() ? info.stripCharges().at(info.maxIndex()+2) : 0 ; + first = info.stripCharges().at(0); + last = info.stripCharges().at(info.width()-1); +} + +ShallowClustersProducer::NearDigis:: +NearDigis(const SiStripClusterInfo& info, const edm::DetSetVector& rawProcessedDigis) { + edm::DetSetVector::const_iterator digiframe = rawProcessedDigis.find(info.detId()); + if( digiframe != rawProcessedDigis.end()) { + max = digiframe->data.at(info.maxStrip()).adc() ; + left = info.maxStrip() > uint16_t(0) ? digiframe->data.at(info.maxStrip()-1).adc() : 0 ; + Lleft = info.maxStrip() > uint16_t(1) ? digiframe->data.at(info.maxStrip()-2).adc() : 0 ; + right = unsigned(info.maxStrip()+1) < digiframe->data.size() ? digiframe->data.at(info.maxStrip()+1).adc() : 0 ; + Rright = unsigned(info.maxStrip()+2) < digiframe->data.size() ? digiframe->data.at(info.maxStrip()+2).adc() : 0 ; + first = digiframe->data.at(info.firstStrip()).adc(); + last = digiframe->data.at(info.firstStrip()+info.width() - 1).adc(); + } else { + *this = NearDigis(info); + } +} + +ShallowClustersProducer::moduleVars:: +moduleVars(uint32_t detid) { + SiStripDetId subdet(detid); + subdetid = subdet.subDetector(); + if( SiStripDetId::TIB == subdetid ) { + TIBDetId tib(detid); + module = tib.module(); + side = (tib.isZMinusSide())?-1:1; + layerwheel = tib.layer(); + stringringrod = tib.stringNumber(); + stereo = tib.isStereo() ? 1 : 0; + } else + if( SiStripDetId::TID == subdetid ) { + TIDDetId tid(detid); + module = tid.moduleNumber(); + side = (tid.isZMinusSide())?-1:1; + layerwheel = tid.wheel(); + stringringrod = tid.ringNumber(); + stereo = tid.isStereo() ? 1 : 0; + } else + if( SiStripDetId::TOB == subdetid ) { + TOBDetId tob(detid); + module = tob.module(); + side = (tob.isZMinusSide())?-1:1; + layerwheel = tob.layer(); + stringringrod = tob.rodNumber(); + stereo = tob.isStereo() ? 1 : 0; + } else + if( SiStripDetId::TEC == subdetid ) { + TECDetId tec(detid); + module = tec.module(); + side = (tec.isZMinusSide())?-1:1; + layerwheel = tec.wheel(); + stringringrod = tec.ringNumber(); + petal = tec.petalNumber(); + stereo = tec.isStereo() ? 1 : 0; + } else { + module = 0; + side = 0; + layerwheel=-1; + stringringrod = -1; + petal=-1; + } +} diff --git a/trunk/CalibTracker/SiStripCommon/plugins/ShallowDigisProducer.cc b/trunk/CalibTracker/SiStripCommon/plugins/ShallowDigisProducer.cc new file mode 100644 index 0000000000000..7547fbbda7cc7 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/plugins/ShallowDigisProducer.cc @@ -0,0 +1,72 @@ +#include "CalibTracker/SiStripCommon/interface/ShallowDigisProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "DataFormats/Common/interface/DetSetVector.h" +#include "DataFormats/Common/interface/DetSetVectorNew.h" +#include "DataFormats/SiStripDigi/interface/SiStripDigi.h" +#include "CondFormats/DataRecord/interface/SiStripNoisesRcd.h" +#include "CondFormats/SiStripObjects/interface/SiStripNoises.h" +#include "boost/foreach.hpp" + +ShallowDigisProducer::ShallowDigisProducer(const edm::ParameterSet& conf) + : inputTags(conf.getParameter >("DigiProducersList")) +{ + produces >("id"); + produces >("subdet"); + produces >("strip"); + produces >("adc"); + produces >("noise"); +} + +void ShallowDigisProducer:: +insert(products& p, edm::Event& e) { + e.put(p.id, "id"); + e.put(p.subdet, "subdet"); + e.put(p.strip, "strip"); + e.put(p.adc, "adc"); + e.put(p.noise, "noise"); +} + +template +inline +void ShallowDigisProducer:: +recordDigis(const T& digiCollection, products& p) { + BOOST_FOREACH(const typename T::value_type set, digiCollection) { + SiStripNoises::Range detNoiseRange = noiseHandle->getRange(set.detId()); + BOOST_FOREACH(const SiStripDigi digi, set) { + p.id->push_back(set.detId()); + p.subdet->push_back((set.detId()>>25)&0x7); + p.strip->push_back(digi.strip()); + p.adc->push_back(digi.adc()); + p.noise->push_back(noiseHandle->getNoise( digi.strip(), detNoiseRange)); + } + } +} + +void ShallowDigisProducer:: +produce(edm::Event& e, const edm::EventSetup& es) { + products p; + edm::Handle< edm::DetSetVector > inputOld; + edm::Handle< edmNew::DetSetVector > inputNew; + es.get().get(noiseHandle); + if( findInput(inputOld, e) ) recordDigis(*inputOld, p); else + if( findInput(inputNew, e) ) recordDigis(*inputNew, p); else + edm::LogWarning("Input Not Found"); + insert(p,e); +} + +template +inline +bool ShallowDigisProducer:: +findInput(edm::Handle& handle, const edm::Event& e) { + BOOST_FOREACH( const edm::InputTag inputTag, inputTags) { + e.getByLabel(inputTag, handle); + if( handle.isValid() && !handle->empty() ) { + LogDebug("Input") << inputTag; + return true; + } + } + return false; +} diff --git a/trunk/CalibTracker/SiStripCommon/plugins/ShallowEventDataProducer.cc b/trunk/CalibTracker/SiStripCommon/plugins/ShallowEventDataProducer.cc new file mode 100644 index 0000000000000..9164648dfdd8e --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/plugins/ShallowEventDataProducer.cc @@ -0,0 +1,16 @@ +#include "CalibTracker/SiStripCommon/interface/ShallowEventDataProducer.h" +#include "FWCore/Framework/interface/Event.h" + +ShallowEventDataProducer::ShallowEventDataProducer(const edm::ParameterSet& iConfig) { + produces ( "run" ); + produces ( "event" ); +} + +void ShallowEventDataProducer:: +produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + std::auto_ptr run ( new unsigned int(iEvent.id().run() ) ); + std::auto_ptr event ( new unsigned int(iEvent.id().event() ) ); + + iEvent.put( run, "run" ); + iEvent.put( event, "event" ); +} diff --git a/trunk/CalibTracker/SiStripCommon/plugins/ShallowRechitClustersProducer.cc b/trunk/CalibTracker/SiStripCommon/plugins/ShallowRechitClustersProducer.cc new file mode 100644 index 0000000000000..2b5ddc9849f11 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/plugins/ShallowRechitClustersProducer.cc @@ -0,0 +1,81 @@ +#include "CalibTracker/SiStripCommon/interface/ShallowRechitClustersProducer.h" + +#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h" + +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h" +#include "Geometry/CommonTopologies/interface/StripTopology.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" + +#include "CalibTracker/SiStripCommon/interface/ShallowTools.h" +#include "boost/foreach.hpp" + +ShallowRechitClustersProducer::ShallowRechitClustersProducer(const edm::ParameterSet& iConfig) + : Suffix ( iConfig.getParameter("Suffix") ), + Prefix ( iConfig.getParameter("Prefix") ), + theClustersLabel( iConfig.getParameter("Clusters")), + inputTags ( iConfig.getParameter >("InputTags")) +{ + produces > ( Prefix + "strip" + Suffix ); + produces > ( Prefix + "merr" + Suffix ); + produces > ( Prefix + "localx" + Suffix ); + produces > ( Prefix + "localy" + Suffix ); + produces > ( Prefix + "localxerr" + Suffix ); + produces > ( Prefix + "localyerr" + Suffix ); + produces > ( Prefix + "globalx" + Suffix ); + produces > ( Prefix + "globaly" + Suffix ); + produces > ( Prefix + "globalz" + Suffix ); +} + +void ShallowRechitClustersProducer:: +produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + shallow::CLUSTERMAP clustermap = shallow::make_cluster_map(iEvent,theClustersLabel); + + int size = clustermap.size(); + std::auto_ptr > strip ( new std::vector(size, -10000 )); + std::auto_ptr > merr ( new std::vector(size, -10000 )); + std::auto_ptr > localx ( new std::vector(size, -10000 )); + std::auto_ptr > localy ( new std::vector(size, -10000 )); + std::auto_ptr > localxerr ( new std::vector(size, -1 )); + std::auto_ptr > localyerr ( new std::vector(size, -1 )); + std::auto_ptr > globalx ( new std::vector(size, -10000 )); + std::auto_ptr > globaly ( new std::vector(size, -10000 )); + std::auto_ptr > globalz ( new std::vector(size, -10000 )); + + edm::ESHandle theTrackerGeometry; iSetup.get().get( theTrackerGeometry ); + + BOOST_FOREACH(const edm::InputTag& input, inputTags ) { edm::Handle recHits; iEvent.getByLabel(input, recHits); + BOOST_FOREACH( const SiStripRecHit2DCollection::value_type& ds, *recHits) { + BOOST_FOREACH( const SiStripRecHit2D& hit, ds) { + + shallow::CLUSTERMAP::iterator cluster = clustermap.find( std::make_pair(hit.geographicalId().rawId(), hit.cluster()->firstStrip() ) ); + if(cluster != clustermap.end() ) { + const StripGeomDetUnit* theStripDet = dynamic_cast( theTrackerGeometry->idToDet( hit.geographicalId() ) ); + unsigned int i = cluster->second; + strip->at(i) = theStripDet->specificTopology().strip(hit.localPosition()); + merr->at(i) = sqrt(theStripDet->specificTopology().measurementError(hit.localPosition(), hit.localPositionError()).uu()); + localx->at(i) = hit.localPosition().x(); + localy->at(i) = hit.localPosition().y(); + localxerr->at(i) = sqrt(hit.localPositionError().xx()); + localyerr->at(i) = sqrt(hit.localPositionError().yy()); + globalx->at(i) = theStripDet->toGlobal(hit.localPosition()).x(); + globaly->at(i) = theStripDet->toGlobal(hit.localPosition()).y(); + globalz->at(i) = theStripDet->toGlobal(hit.localPosition()).z(); + } + else {throw cms::Exception("cluster not found");} + } + } + } + + iEvent.put( strip, Prefix + "strip" + Suffix ); + iEvent.put( merr, Prefix + "merr" + Suffix ); + iEvent.put( localx , Prefix + "localx" + Suffix ); + iEvent.put( localy , Prefix + "localy" + Suffix ); + iEvent.put( localxerr , Prefix + "localxerr" + Suffix ); + iEvent.put( localyerr , Prefix + "localyerr" + Suffix ); + iEvent.put( globalx , Prefix + "globalx" + Suffix ); + iEvent.put( globaly , Prefix + "globaly" + Suffix ); + iEvent.put( globalz , Prefix + "globalz" + Suffix ); +} diff --git a/trunk/CalibTracker/SiStripCommon/plugins/ShallowSimTracksProducer.cc b/trunk/CalibTracker/SiStripCommon/plugins/ShallowSimTracksProducer.cc new file mode 100644 index 0000000000000..3a0300c88f08a --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/plugins/ShallowSimTracksProducer.cc @@ -0,0 +1,99 @@ +#include "CalibTracker/SiStripCommon/interface/ShallowSimTracksProducer.h" +#include "CalibTracker/SiStripCommon/interface/ShallowTools.h" + +#include "FWCore/Framework/interface/Event.h" +#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" +#include "SimTracker/Records/interface/TrackAssociatorRecord.h" +#include "SimTracker/TrackAssociation/interface/TrackAssociatorByChi2.h" +#include "SimTracker/TrackAssociation/interface/TrackAssociatorByHits.h" +#include "DataFormats/RecoCandidate/interface/TrackAssociation.h" + +#include "FWCore/MessageLogger/interface/MessageLogger.h" + +ShallowSimTracksProducer::ShallowSimTracksProducer(const edm::ParameterSet& conf) + : Prefix( conf.getParameter("Prefix") ), + Suffix( conf.getParameter("Suffix") ), + trackingParticles_tag( conf.getParameter("TrackingParticles")), + associator_tag( conf.getParameter("Associator")), + tracks_tag( conf.getParameter("Tracks")) +{ + produces > ( Prefix + "multi" + Suffix ); + produces > ( Prefix + "type" + Suffix ); + produces > ( Prefix + "charge" + Suffix ); + produces > ( Prefix + "momentum" + Suffix ); + produces > ( Prefix + "pt" + Suffix ); + produces > ( Prefix + "theta" + Suffix ); + produces > ( Prefix + "phi" + Suffix ); + produces > ( Prefix + "eta" + Suffix ); + produces > ( Prefix + "qoverp" + Suffix ); + produces > ( Prefix + "vx" + Suffix ); + produces > ( Prefix + "vy" + Suffix ); + produces > ( Prefix + "vz" + Suffix ); +} + + +void ShallowSimTracksProducer:: +produce(edm::Event& event, const edm::EventSetup& setup) { + + edm::Handle > tracks ; event.getByLabel( tracks_tag, tracks); + edm::Handle trackingParticles ; event.getByLabel( trackingParticles_tag, trackingParticles ); + edm::ESHandle associator ; setup.get().get( associator_tag, associator); + + unsigned size = tracks->size(); + std::auto_ptr > multi ( new std::vector(size, 0)); + std::auto_ptr > type ( new std::vector (size, 0)); + std::auto_ptr > charge ( new std::vector (size, 0)); + std::auto_ptr > momentum ( new std::vector (size, -1)); + std::auto_ptr > pt ( new std::vector (size, -1)); + std::auto_ptr > theta ( new std::vector (size,-1000)); + std::auto_ptr > phi ( new std::vector (size,-1000)); + std::auto_ptr > eta ( new std::vector (size,-1000)); + std::auto_ptr > dxy ( new std::vector (size,-1000)); + std::auto_ptr > dsz ( new std::vector (size,-1000)); + std::auto_ptr > qoverp ( new std::vector (size,-1000)); + std::auto_ptr > vx ( new std::vector (size,-1000)); + std::auto_ptr > vy ( new std::vector (size,-1000)); + std::auto_ptr > vz ( new std::vector (size,-1000)); + + reco::RecoToSimCollection associations = associator->associateRecoToSim( tracks, trackingParticles, &event ); + + for( reco::RecoToSimCollection::const_iterator association = associations.begin(); + association != associations.end(); association++) { + + const reco::Track* track = association->key.get(); + const int matches = association->val.size(); + if(matches>0) { + const TrackingParticle* tparticle = association->val[0].first.get(); + unsigned i = shallow::findTrackIndex(tracks, track); + + multi->at(i) = matches; + type->at(i) = tparticle->pdgId(); + charge->at(i)= tparticle->charge(); + momentum->at(i)=tparticle->p() ; + pt->at(i) = tparticle->pt() ; + theta->at(i) = tparticle->theta() ; + phi->at(i) = tparticle->phi() ; + eta->at(i) = tparticle->eta() ; + qoverp->at(i)= tparticle->charge()/tparticle->p(); + + const TrackingVertex* tvertex = tparticle->parentVertex().get(); + vx->at(i) = tvertex->position().x(); + vy->at(i) = tvertex->position().y(); + vz->at(i) = tvertex->position().z(); + } + } + + event.put( multi ,Prefix + "multi" + Suffix ); + event.put( type ,Prefix + "type" + Suffix ); + event.put( charge ,Prefix + "charge" + Suffix ); + event.put( momentum ,Prefix + "momentum" + Suffix ); + event.put( pt ,Prefix + "pt" + Suffix ); + event.put( theta ,Prefix + "theta" + Suffix ); + event.put( phi ,Prefix + "phi" + Suffix ); + event.put( eta ,Prefix + "eta" + Suffix ); + event.put( qoverp ,Prefix + "qoverp" + Suffix ); + event.put( vx ,Prefix + "vx" + Suffix ); + event.put( vy ,Prefix + "vy" + Suffix ); + event.put( vz ,Prefix + "vz" + Suffix ); + +} diff --git a/trunk/CalibTracker/SiStripCommon/plugins/ShallowSimhitClustersProducer.cc b/trunk/CalibTracker/SiStripCommon/plugins/ShallowSimhitClustersProducer.cc new file mode 100644 index 0000000000000..04d29b0c22328 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/plugins/ShallowSimhitClustersProducer.cc @@ -0,0 +1,126 @@ +#include "CalibTracker/SiStripCommon/interface/ShallowSimhitClustersProducer.h" + +#include "CalibTracker/SiStripCommon/interface/ShallowTools.h" +#include "SimDataFormats/TrackingHit/interface/PSimHit.h" +#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" + +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "CondFormats/SiStripObjects/interface/SiStripLorentzAngle.h" +#include "CondFormats/DataRecord/interface/SiStripLorentzAngleRcd.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h" +#include "Geometry/CommonTopologies/interface/StripTopology.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "boost/foreach.hpp" + +ShallowSimhitClustersProducer::ShallowSimhitClustersProducer(const edm::ParameterSet& iConfig) + : inputTags( iConfig.getParameter >("InputTags") ), + theClustersLabel( iConfig.getParameter("Clusters")), + Prefix( iConfig.getParameter("Prefix") ) +{ + produces > ( Prefix + "hits" ); + produces > ( Prefix + "strip" ); + produces > ( Prefix + "localtheta" ); + produces > ( Prefix + "localphi" ); + produces > ( Prefix + "localx" ); + produces > ( Prefix + "localy" ); + produces > ( Prefix + "localz" ); + produces > ( Prefix + "momentum" ); + produces > ( Prefix + "energyloss" ); + produces > ( Prefix + "time" ); + produces > ( Prefix + "particle" ); + produces > ( Prefix + "process" ); +} + +void ShallowSimhitClustersProducer:: +produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + shallow::CLUSTERMAP clustermap = shallow::make_cluster_map(iEvent,theClustersLabel); + + int size = clustermap.size(); + std::auto_ptr > hits ( new std::vector (size, 0) ); + std::auto_ptr > strip ( new std::vector (size, -100) ); + std::auto_ptr > localtheta ( new std::vector (size, -100) ); + std::auto_ptr > localphi ( new std::vector (size, -100) ); + std::auto_ptr > localx ( new std::vector (size, -100) ); + std::auto_ptr > localy ( new std::vector (size, -100) ); + std::auto_ptr > localz ( new std::vector (size, -100) ); + std::auto_ptr > momentum ( new std::vector (size, 0) ); + std::auto_ptr > energyloss ( new std::vector (size, -1) ); + std::auto_ptr > time ( new std::vector (size, -1) ); + std::auto_ptr > particle ( new std::vector (size,-500) ); + std::auto_ptr > process ( new std::vector (size,0) ); + + edm::ESHandle theTrackerGeometry; iSetup.get().get( theTrackerGeometry ); + edm::ESHandle magfield; iSetup.get().get(magfield); + edm::ESHandle SiStripLorentzAngle; iSetup.get().get(SiStripLorentzAngle); + edm::Handle > clusters; iEvent.getByLabel("siStripClusters", "", clusters); + + BOOST_FOREACH( const edm::InputTag inputTag, inputTags ) { edm::Handle > simhits; iEvent.getByLabel(inputTag, simhits); + BOOST_FOREACH( const PSimHit hit, *simhits ) { + + const uint32_t id = hit.detUnitId(); + const StripGeomDetUnit* theStripDet = dynamic_cast( theTrackerGeometry->idToDet( id ) ); + const LocalVector drift = shallow::drift(theStripDet, *magfield, *SiStripLorentzAngle); + + const float driftedstrip_ = theStripDet->specificTopology().strip( hit.localPosition()+0.5*drift ); + const float hitstrip_ = theStripDet->specificTopology().strip( hit.localPosition() ); + + shallow::CLUSTERMAP::const_iterator cluster = match_cluster( id, driftedstrip_, clustermap, *clusters); + if(cluster != clustermap.end()) { + unsigned i = cluster->second; + hits->at(i)+=1; + if(hits->at(i) == 1) { + strip->at(i) = hitstrip_; + localtheta->at(i) = hit.thetaAtEntry(); + localphi->at(i) = hit.phiAtEntry(); + localx->at(i) = hit.localPosition().x(); + localy->at(i) = hit.localPosition().y(); + localz->at(i) = hit.localPosition().z(); + momentum->at(i) = hit.pabs(); + energyloss->at(i) = hit.energyLoss(); + time->at(i) = hit.timeOfFlight(); + particle->at(i) = hit.particleType(); + process->at(i) = hit.processType(); + } + } + } + } + + iEvent.put( hits, Prefix + "hits" ); + iEvent.put( strip, Prefix + "strip" ); + iEvent.put( localtheta, Prefix + "localtheta" ); + iEvent.put( localphi, Prefix + "localphi" ); + iEvent.put( localx, Prefix + "localx" ); + iEvent.put( localy, Prefix + "localy" ); + iEvent.put( localz, Prefix + "localz" ); + iEvent.put( momentum, Prefix + "momentum" ); + iEvent.put( energyloss, Prefix + "energyloss" ); + iEvent.put( time, Prefix + "time" ); + iEvent.put( particle, Prefix + "particle" ); + iEvent.put( process, Prefix + "process" ); +} + +shallow::CLUSTERMAP::const_iterator ShallowSimhitClustersProducer:: +match_cluster( const unsigned& id, const float& strip_, const shallow::CLUSTERMAP& clustermap, const edmNew::DetSetVector& clusters) const { + shallow::CLUSTERMAP::const_iterator cluster = clustermap.end(); + edmNew::DetSetVector::const_iterator clustersDetSet = clusters.find(id); + if( clustersDetSet != clusters.end() ) { + edmNew::DetSet::const_iterator left, right=clustersDetSet->begin(); + while( right != clustersDetSet->end() && strip_ > right->barycenter() ) + right++; + left = right-1; + if(right!=clustersDetSet->end() && right!=clustersDetSet->begin()) { + unsigned firstStrip = (right->barycenter()-strip_) < (strip_-left->barycenter()) ? right->firstStrip() : left->firstStrip(); + cluster = clustermap.find( std::make_pair( id, firstStrip)); + } + else if(right != clustersDetSet->begin()) + cluster = clustermap.find( std::make_pair( id, left->firstStrip())); + else + cluster = clustermap.find( std::make_pair( id, right->firstStrip())); + } + return cluster; +} + diff --git a/trunk/CalibTracker/SiStripCommon/plugins/ShallowTrackClustersProducer.cc b/trunk/CalibTracker/SiStripCommon/plugins/ShallowTrackClustersProducer.cc new file mode 100644 index 0000000000000..ff2533d7ca46f --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/plugins/ShallowTrackClustersProducer.cc @@ -0,0 +1,203 @@ +#include "CalibTracker/SiStripCommon/interface/ShallowTrackClustersProducer.h" + +#include "CalibTracker/SiStripCommon/interface/ShallowTools.h" + +#include "TrackingTools/PatternTools/interface/Trajectory.h" +#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h" +#include "TrackingTools/TrackFitters/interface/TrajectoryStateCombiner.h" +#include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h" + +#include "MagneticField/Engine/interface/MagneticField.h" +#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h" +#include "CondFormats/SiStripObjects/interface/SiStripLorentzAngle.h" +#include "CondFormats/DataRecord/interface/SiStripLorentzAngleRcd.h" +#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h" +#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h" +#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h" +#include "Geometry/CommonTopologies/interface/StripTopology.h" +#include "FWCore/Framework/interface/ESHandle.h" +#include "FWCore/Framework/interface/Event.h" +#include "boost/foreach.hpp" + + +ShallowTrackClustersProducer::ShallowTrackClustersProducer(const edm::ParameterSet& iConfig) + : theTracksLabel( iConfig.getParameter("Tracks") ), + theClustersLabel( iConfig.getParameter("Clusters") ), + Suffix ( iConfig.getParameter("Suffix") ), + Prefix ( iConfig.getParameter("Prefix") ) +{ + produces > ( Prefix + "trackmulti" + Suffix ); + produces > ( Prefix + "trackindex" + Suffix ); + produces > ( Prefix + "localtheta" + Suffix ); + produces > ( Prefix + "localphi" + Suffix ); + produces > ( Prefix + "localpitch" + Suffix ); + produces > ( Prefix + "localx" + Suffix ); + produces > ( Prefix + "localy" + Suffix ); + produces > ( Prefix + "localz" + Suffix ); + produces > ( Prefix + "strip" + Suffix ); + produces > ( Prefix + "globaltheta" + Suffix ); + produces > ( Prefix + "globalphi" + Suffix ); + produces > ( Prefix + "globalx" + Suffix ); + produces > ( Prefix + "globaly" + Suffix ); + produces > ( Prefix + "globalz" + Suffix ); + produces > ( Prefix + "insidistance"+ Suffix ); + produces > ( Prefix + "covered" + Suffix ); + produces > ( Prefix + "projwidth" + Suffix ); + produces > ( Prefix + "BdotY" + Suffix ); + + produces > ( Prefix + "rhlocalx" + Suffix ); + produces > ( Prefix + "rhlocaly" + Suffix ); + produces > ( Prefix + "rhlocalxerr" + Suffix ); + produces > ( Prefix + "rhlocalyerr" + Suffix ); + produces > ( Prefix + "rhglobalx" + Suffix ); + produces > ( Prefix + "rhglobaly" + Suffix ); + produces > ( Prefix + "rhglobalz" + Suffix ); + produces > ( Prefix + "rhstrip" + Suffix ); + produces > ( Prefix + "rhmerr" + Suffix ); + + produces > ( Prefix + "ubstrip" + Suffix ); + produces > ( Prefix + "ubmerr" + Suffix ); + + produces > ( Prefix + "driftx" + Suffix ); + produces > ( Prefix + "drifty" + Suffix ); + produces > ( Prefix + "driftz" + Suffix ); + produces > ( Prefix + "globalZofunitlocalY" + Suffix ); +} + +void ShallowTrackClustersProducer:: +produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + shallow::CLUSTERMAP clustermap = shallow::make_cluster_map(iEvent,theClustersLabel); + + int size = clustermap.size(); + std::auto_ptr > trackmulti ( new std::vector(size, 0) ); + std::auto_ptr > trackindex ( new std::vector (size, -1) ); + std::auto_ptr > localtheta ( new std::vector (size, -100) ); + std::auto_ptr > localphi ( new std::vector (size, -100) ); + std::auto_ptr > localpitch ( new std::vector (size, -100) ); + std::auto_ptr > localx ( new std::vector (size, -100) ); + std::auto_ptr > localy ( new std::vector (size, -100) ); + std::auto_ptr > localz ( new std::vector (size, -100) ); + std::auto_ptr > strip ( new std::vector (size, -100) ); + std::auto_ptr > globaltheta ( new std::vector (size, -100) ); + std::auto_ptr > globalphi ( new std::vector (size, -100) ); + std::auto_ptr > globalx ( new std::vector (size, -10000) ); + std::auto_ptr > globaly ( new std::vector (size, -10000) ); + std::auto_ptr > globalz ( new std::vector (size, -10000) ); + std::auto_ptr > insidistance ( new std::vector (size, -1) ); + std::auto_ptr > projwidth ( new std::vector (size, -1000) ); + std::auto_ptr > BdotY ( new std::vector (size, -1000) ); + std::auto_ptr > covered ( new std::vector (size, -1000) ); + std::auto_ptr > rhlocalx ( new std::vector(size, -10000 )); + std::auto_ptr > rhlocaly ( new std::vector(size, -10000 )); + std::auto_ptr > rhlocalxerr ( new std::vector(size, -1 )); + std::auto_ptr > rhlocalyerr ( new std::vector(size, -1 )); + std::auto_ptr > rhglobalx ( new std::vector(size, -10000 )); + std::auto_ptr > rhglobaly ( new std::vector(size, -10000 )); + std::auto_ptr > rhglobalz ( new std::vector(size, -10000 )); + std::auto_ptr > rhstrip ( new std::vector(size, -10000 )); + std::auto_ptr > rhmerr ( new std::vector(size, -10000 )); + std::auto_ptr > ubstrip ( new std::vector(size, -10000 )); + std::auto_ptr > ubmerr ( new std::vector(size, -10000 )); + std::auto_ptr > driftx ( new std::vector(size, -10000 )); + std::auto_ptr > drifty ( new std::vector(size, -10000 )); + std::auto_ptr > driftz ( new std::vector(size, -10000 )); + std::auto_ptr > globalZofunitlocalY ( new std::vector(size, -1000)); + + edm::ESHandle theTrackerGeometry; iSetup.get().get( theTrackerGeometry ); + edm::ESHandle magfield; iSetup.get().get(magfield); + edm::ESHandle SiStripLorentzAngle; iSetup.get().get(SiStripLorentzAngle); + + edm::Handle > tracks; iEvent.getByLabel(theTracksLabel, tracks); + edm::Handle associations; iEvent.getByLabel(theTracksLabel, associations); + + TrajectoryStateCombiner combiner; + + for( TrajTrackAssociationCollection::const_iterator association = associations->begin(); + association != associations->end(); association++) { + const Trajectory* traj = association->key.get(); + const reco::Track* track = association->val.get(); + + BOOST_FOREACH( const TrajectoryMeasurement measurement, traj->measurements() ) { + const TrajectoryStateOnSurface tsos = measurement.updatedState(); + const TrajectoryStateOnSurface unbiased = combiner(measurement.forwardPredictedState(), measurement.backwardPredictedState()); + const SiStripRecHit2D* hit = dynamic_cast ( measurement.recHit()->hit() ); + + if(!hit) continue; + shallow::CLUSTERMAP::const_iterator cluster = clustermap.find( std::make_pair(hit->geographicalId().rawId(), hit->cluster()->firstStrip() )); + if(cluster == clustermap.end() ) throw cms::Exception("Logic Error") << "Cluster not found: this could be a configuration error" << std::endl; + + unsigned i = cluster->second; + if( 0 == (trackmulti->at(i))++ ) { + const StripGeomDetUnit* theStripDet = dynamic_cast( theTrackerGeometry->idToDet( hit->geographicalId() ) ); + LocalVector drift = shallow::drift( theStripDet, *magfield, *SiStripLorentzAngle); + + trackindex->at(i) = shallow::findTrackIndex(tracks, track); + localtheta->at(i) = (theStripDet->toLocal(tsos.globalDirection())).theta(); + localphi->at(i) = (theStripDet->toLocal(tsos.globalDirection())).phi(); + localpitch->at(i) = (theStripDet->specificTopology()).localPitch(theStripDet->toLocal(tsos.globalPosition())); + localx->at(i) = (theStripDet->toLocal(tsos.globalPosition())).x(); + localy->at(i) = (theStripDet->toLocal(tsos.globalPosition())).y(); + localz->at(i) = (theStripDet->toLocal(tsos.globalPosition())).z(); + strip->at(i) = (theStripDet->specificTopology()).strip(theStripDet->toLocal(tsos.globalPosition())); + globaltheta->at(i) = tsos.globalDirection().theta(); + globalphi->at(i) = tsos.globalDirection().phi(); + globalx->at(i) = tsos.globalPosition().x(); + globaly->at(i) = tsos.globalPosition().y(); + globalz->at(i) = tsos.globalPosition().z(); + insidistance->at(i) = 1./fabs(cos(localtheta->at(i))); + projwidth->at(i) = tan(localtheta->at(i))*cos(localphi->at(i)); + BdotY->at(i) = (theStripDet->surface()).toLocal( magfield->inTesla(theStripDet->surface().position())).y(); + covered->at(i) = drift.z()/localpitch->at(i) * fabs(projwidth->at(i) - drift.x()/drift.z()); + rhlocalx->at(i) = hit->localPosition().x(); + rhlocaly->at(i) = hit->localPosition().y(); + rhlocalxerr->at(i) = sqrt(hit->localPositionError().xx()); + rhlocalyerr->at(i) = sqrt(hit->localPositionError().yy()); + rhglobalx->at(i) = theStripDet->toGlobal(hit->localPosition()).x(); + rhglobaly->at(i) = theStripDet->toGlobal(hit->localPosition()).y(); + rhglobalz->at(i) = theStripDet->toGlobal(hit->localPosition()).z(); + rhstrip->at(i) = theStripDet->specificTopology().strip(hit->localPosition()); + rhmerr->at(i) = sqrt(theStripDet->specificTopology().measurementError(hit->localPosition(), hit->localPositionError()).uu()); + ubstrip->at(i) = theStripDet->specificTopology().strip(unbiased.localPosition()); + ubmerr->at(i) = sqrt(theStripDet->specificTopology().measurementError(unbiased.localPosition(), unbiased.localError().positionError()).uu()); + driftx->at(i) = drift.x(); + drifty->at(i) = drift.y(); + driftz->at(i) = drift.z(); + globalZofunitlocalY->at(i) = (theStripDet->toGlobal(LocalVector(0,1,0))).z(); + } + } + } + + iEvent.put(trackmulti, Prefix + "trackmulti" + Suffix ); + iEvent.put(trackindex, Prefix + "trackindex" + Suffix ); + iEvent.put(localtheta, Prefix + "localtheta" + Suffix ); + iEvent.put(localphi, Prefix + "localphi" + Suffix ); + iEvent.put(localpitch, Prefix + "localpitch" + Suffix ); + iEvent.put(localx, Prefix + "localx" + Suffix ); + iEvent.put(localy, Prefix + "localy" + Suffix ); + iEvent.put(localz, Prefix + "localz" + Suffix ); + iEvent.put(strip, Prefix + "strip" + Suffix ); + iEvent.put(globaltheta, Prefix + "globaltheta" + Suffix ); + iEvent.put(globalphi, Prefix + "globalphi" + Suffix ); + iEvent.put(globalx, Prefix + "globalx" + Suffix ); + iEvent.put(globaly, Prefix + "globaly" + Suffix ); + iEvent.put(globalz, Prefix + "globalz" + Suffix ); + iEvent.put(insidistance,Prefix + "insidistance"+ Suffix ); + iEvent.put(covered, Prefix + "covered" + Suffix ); + iEvent.put(projwidth, Prefix + "projwidth" + Suffix ); + iEvent.put(BdotY, Prefix + "BdotY" + Suffix ); + iEvent.put(rhlocalx, Prefix + "rhlocalx" + Suffix ); + iEvent.put(rhlocaly, Prefix + "rhlocaly" + Suffix ); + iEvent.put(rhlocalxerr, Prefix + "rhlocalxerr" + Suffix ); + iEvent.put(rhlocalyerr, Prefix + "rhlocalyerr" + Suffix ); + iEvent.put(rhglobalx, Prefix + "rhglobalx" + Suffix ); + iEvent.put(rhglobaly, Prefix + "rhglobaly" + Suffix ); + iEvent.put(rhglobalz, Prefix + "rhglobalz" + Suffix ); + iEvent.put(rhstrip, Prefix + "rhstrip" + Suffix ); + iEvent.put(rhmerr, Prefix + "rhmerr" + Suffix ); + iEvent.put(ubstrip, Prefix + "ubstrip" + Suffix ); + iEvent.put(ubmerr, Prefix + "ubmerr" + Suffix ); + iEvent.put( driftx, Prefix + "driftx" + Suffix ); + iEvent.put( drifty, Prefix + "drifty" + Suffix ); + iEvent.put( driftz, Prefix + "driftz" + Suffix ); + iEvent.put( globalZofunitlocalY, Prefix + "globalZofunitlocalY" + Suffix ); +} diff --git a/trunk/CalibTracker/SiStripCommon/plugins/ShallowTracksProducer.cc b/trunk/CalibTracker/SiStripCommon/plugins/ShallowTracksProducer.cc new file mode 100644 index 0000000000000..df51fe6213cf4 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/plugins/ShallowTracksProducer.cc @@ -0,0 +1,126 @@ +#include "CalibTracker/SiStripCommon/interface/ShallowTracksProducer.h" + +#include "FWCore/Framework/interface/Event.h" +#include "DataFormats/TrackReco/interface/Track.h" +#include "DataFormats/TrackReco/interface/TrackFwd.h" +#include "TrackingTools/PatternTools/interface/Trajectory.h" +#include "boost/foreach.hpp" + +ShallowTracksProducer::ShallowTracksProducer(const edm::ParameterSet& iConfig) + : theTracksLabel( iConfig.getParameter("Tracks") ), + Prefix ( iConfig.getParameter("Prefix") ), + Suffix ( iConfig.getParameter("Suffix") ) +{ + produces ( Prefix + "number" + Suffix ); + produces > ( Prefix + "chi2" + Suffix ); + produces > ( Prefix + "ndof" + Suffix ); + produces > ( Prefix + "chi2ndof" + Suffix ); + produces > ( Prefix + "charge" + Suffix ); + produces > ( Prefix + "momentum" + Suffix ); + produces > ( Prefix + "pt" + Suffix ); + produces > ( Prefix + "pterr" + Suffix ); + produces > ( Prefix + "hitsvalid" + Suffix ); + produces > ( Prefix + "hitslost" + Suffix ); + produces > ( Prefix + "theta" + Suffix ); + produces > ( Prefix + "thetaerr" + Suffix ); + produces > ( Prefix + "phi" + Suffix ); + produces > ( Prefix + "phierr" + Suffix ); + produces > ( Prefix + "eta" + Suffix ); + produces > ( Prefix + "etaerr" + Suffix ); + produces > ( Prefix + "dxy" + Suffix ); + produces > ( Prefix + "dxyerr" + Suffix ); + produces > ( Prefix + "dsz" + Suffix ); + produces > ( Prefix + "dszerr" + Suffix ); + produces > ( Prefix + "qoverp" + Suffix ); + produces > ( Prefix + "qoverperr" + Suffix ); + produces > ( Prefix + "vx" + Suffix ); + produces > ( Prefix + "vy" + Suffix ); + produces > ( Prefix + "vz" + Suffix ); +} + +void ShallowTracksProducer:: +produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + std::auto_ptr number ( new unsigned int(0) ); + std::auto_ptr > chi2 ( new std::vector() ); + std::auto_ptr > ndof ( new std::vector() ); + std::auto_ptr > chi2ndof ( new std::vector() ); + std::auto_ptr > charge ( new std::vector() ); + std::auto_ptr > momentum ( new std::vector() ); + std::auto_ptr > pt ( new std::vector() ); + std::auto_ptr > pterr ( new std::vector() ); + std::auto_ptr > hitsvalid ( new std::vector() ); + std::auto_ptr > hitslost ( new std::vector() ); + std::auto_ptr > theta ( new std::vector() ); + std::auto_ptr > thetaerr ( new std::vector() ); + std::auto_ptr > phi ( new std::vector() ); + std::auto_ptr > phierr ( new std::vector() ); + std::auto_ptr > eta ( new std::vector() ); + std::auto_ptr > etaerr ( new std::vector() ); + std::auto_ptr > dxy ( new std::vector() ); + std::auto_ptr > dxyerr ( new std::vector() ); + std::auto_ptr > dsz ( new std::vector() ); + std::auto_ptr > dszerr ( new std::vector() ); + std::auto_ptr > qoverp ( new std::vector() ); + std::auto_ptr > qoverperr ( new std::vector() ); + std::auto_ptr > vx ( new std::vector() ); + std::auto_ptr > vy ( new std::vector() ); + std::auto_ptr > vz ( new std::vector() ); + + edm::Handle > tracks; iEvent.getByLabel(theTracksLabel, tracks); + + *number = tracks->size(); + BOOST_FOREACH( const reco::Track track, *tracks) { + chi2->push_back( track.chi2() ); + ndof->push_back( track.ndof() ); + chi2ndof->push_back( track.chi2()/track.ndof() ); + charge->push_back( track.charge() ); + momentum->push_back( track.p() ); + pt->push_back( track.pt() ); + pterr->push_back( track.ptError() ); + hitsvalid->push_back( track.numberOfValidHits() ); + hitslost->push_back( track.numberOfLostHits() ); + theta->push_back( track.theta() ); + thetaerr->push_back( track.thetaError() ); + phi->push_back( track.phi() ); + phierr->push_back( track.phiError() ); + eta->push_back( track.eta() ); + etaerr->push_back( track.etaError() ); + dxy->push_back( track.dxy() ); + dxyerr->push_back( track.dxyError() ); + dsz->push_back( track.dsz() ); + dszerr->push_back( track.dszError() ); + qoverp->push_back( track.qoverp() ); + qoverperr->push_back( track.qoverpError() ); + vx->push_back( track.vx() ); + vy->push_back( track.vy() ); + vz->push_back( track.vz() ); + } + + iEvent.put(number, Prefix + "number" + Suffix ); + iEvent.put(chi2, Prefix + "chi2" + Suffix ); + iEvent.put(ndof, Prefix + "ndof" + Suffix ); + iEvent.put(chi2ndof, Prefix + "chi2ndof" + Suffix ); + iEvent.put(charge, Prefix + "charge" + Suffix ); + iEvent.put(momentum, Prefix + "momentum" + Suffix ); + iEvent.put(pt, Prefix + "pt" + Suffix ); + iEvent.put(pterr, Prefix + "pterr" + Suffix ); + iEvent.put(hitsvalid, Prefix + "hitsvalid" + Suffix ); + iEvent.put(hitslost, Prefix + "hitslost" + Suffix ); + iEvent.put(theta, Prefix + "theta" + Suffix ); + iEvent.put(thetaerr, Prefix + "thetaerr" + Suffix ); + iEvent.put(phi, Prefix + "phi" + Suffix ); + iEvent.put(phierr, Prefix + "phierr" + Suffix ); + iEvent.put(eta, Prefix + "eta" + Suffix ); + iEvent.put(etaerr, Prefix + "etaerr" + Suffix ); + iEvent.put(dxy, Prefix + "dxy" + Suffix ); + iEvent.put(dxyerr, Prefix + "dxyerr" + Suffix ); + iEvent.put(dsz, Prefix + "dsz" + Suffix ); + iEvent.put(dszerr, Prefix + "dszerr" + Suffix ); + iEvent.put(qoverp, Prefix + "qoverp" + Suffix ); + iEvent.put(qoverperr, Prefix + "qoverperr" + Suffix ); + iEvent.put(vx, Prefix + "vx" + Suffix ); + iEvent.put(vy, Prefix + "vy" + Suffix ); + iEvent.put(vz, Prefix + "vz" + Suffix ); + +} + diff --git a/trunk/CalibTracker/SiStripCommon/plugins/ShallowTree.cc b/trunk/CalibTracker/SiStripCommon/plugins/ShallowTree.cc new file mode 100644 index 0000000000000..59e5e61aeea88 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/plugins/ShallowTree.cc @@ -0,0 +1,119 @@ +#include "CalibTracker/SiStripCommon/interface/ShallowTree.h" + +#include "FWCore/Framework/interface/ConstProductRegistry.h" +#include "FWCore/Framework/interface/GroupSelector.h" +#include "FWCore/Framework/interface/GroupSelectorRules.h" +#include "DataFormats/Provenance/interface/Selections.h" + +#include +#include "boost/foreach.hpp" +#include + +void ShallowTree:: +analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + BOOST_FOREACH( BranchConnector* connector, connectors) + connector->connect(iEvent); + tree->Fill(); +} + +template +void ShallowTree::TypedBranchConnector:: +connect(const edm::Event& iEvent) { + edm::Handle handle_; + iEvent.getByLabel(ml, pin, handle_); + object_ = *handle_; +} + +template +ShallowTree::TypedBranchConnector:: +TypedBranchConnector(edm::BranchDescription const* desc, + std::string t, + TTree * tree) + : ml( desc->moduleLabel() ), + pin( desc->productInstanceName() ) +{ + object_ptr_ = &object_; + std::string s=pin+t; + if(t!="") { tree->Branch(pin.c_str(), object_ptr_, s.c_str() );} //raw type + else { tree->Branch(pin.c_str(), &object_ptr_ );} //vector +} + +void ShallowTree:: +beginJob(const edm::EventSetup&) { + tree = fs->make("tree", ""); + + std::map leafmap; + leafmap["bool"] = BOOL; leafmap["bools"] = BOOL_V; + leafmap["short int"] = SHORT; leafmap["shorts"] = SHORT_V; + leafmap["ushort int"]= U_SHORT; leafmap["ushorts"] = U_SHORT_V; + leafmap["int"] = INT; leafmap["ints"] = INT_V; + leafmap["uint"] = U_INT; leafmap["uints"] = U_INT_V; + leafmap["float"] = FLOAT; leafmap["floats"] = FLOAT_V; + leafmap["double"] = DOUBLE; leafmap["doubles"] = DOUBLE_V; + leafmap["lint"] = LONG; leafmap["longs"] = LONG_V; + leafmap["ulint"] = U_LONG; leafmap["ulongs"] = U_LONG_V; + + edm::Service reg; + edm::Selections allBranches = reg->allBranchDescriptions(); + edm::GroupSelectorRules groupSelectorRules_(pset, "outputCommands", "ShallowTree"); + edm::GroupSelector groupSelector_; + groupSelector_.initialize(groupSelectorRules_, allBranches); + + std::set branchnames; + + BOOST_FOREACH( const edm::Selections::value_type& selection, allBranches) { + if(groupSelector_.selected(*selection)) { + + //Check for duplicate branch names + if (branchnames.find( selection->productInstanceName()) != branchnames.end() ) { + throw edm::Exception(edm::errors::Configuration) + << "More than one branch named: " + << selection->productInstanceName() << std::endl + << "Exception thrown from ShallowTree::beginJob" << std::endl; + } + else { + branchnames.insert( selection->productInstanceName() ); + } + + //Create ShallowTree branch + switch(leafmap.find( selection->friendlyClassName() )->second) { + case BOOL : connectors.push_back( new TypedBranchConnector (selection, "/O", tree) ); break; + case BOOL_V : connectors.push_back( new TypedBranchConnector >(selection, "", tree) ); break; + case INT : connectors.push_back( new TypedBranchConnector (selection, "/I", tree) ); break; + case INT_V : connectors.push_back( new TypedBranchConnector >(selection, "", tree) ); break; + case U_INT : connectors.push_back( new TypedBranchConnector (selection, "/i", tree) ); break; + case U_INT_V : connectors.push_back( new TypedBranchConnector >(selection, "", tree) ); break; + case SHORT : connectors.push_back( new TypedBranchConnector (selection, "/S", tree) ); break; + case SHORT_V : connectors.push_back( new TypedBranchConnector >(selection, "", tree) ); break; + case U_SHORT : connectors.push_back( new TypedBranchConnector (selection, "/s", tree) ); break; + case U_SHORT_V: connectors.push_back( new TypedBranchConnector >(selection, "", tree) ); break; + case FLOAT : connectors.push_back( new TypedBranchConnector (selection, "/F", tree) ); break; + case FLOAT_V : connectors.push_back( new TypedBranchConnector >(selection, "", tree) ); break; + case DOUBLE : connectors.push_back( new TypedBranchConnector (selection, "/D", tree) ); break; + case DOUBLE_V : connectors.push_back( new TypedBranchConnector >(selection, "", tree) ); break; + case LONG : connectors.push_back( new TypedBranchConnector (selection, "/L", tree) ); break; + case LONG_V : connectors.push_back( new TypedBranchConnector >(selection, "", tree) ); break; + case U_LONG : connectors.push_back( new TypedBranchConnector (selection, "/l", tree) ); break; + case U_LONG_V : connectors.push_back( new TypedBranchConnector >(selection, "", tree) ); break; + default: + { + std::string leafstring = ""; + typedef std::pair pair_t; + BOOST_FOREACH( const pair_t& leaf, leafmap) + leafstring+= "\t" + leaf.first + "\n"; + + throw edm::Exception(edm::errors::Configuration) + << "class ShallowTree does not handle leaves of type " << selection->className() << " like\n" + << selection->friendlyClassName() << "_" + << selection->moduleLabel() << "_" + << selection->productInstanceName() << "_" + << selection->processName() << std::endl + << "Valid leaf types are (friendlyClassName):\n" + << leafstring + << "Exception thrown from ShallowTree::beginJob\n"; + } + } + } + } +} + diff --git a/trunk/CalibTracker/SiStripCommon/python/ShallowClustersProducer_cfi.py b/trunk/CalibTracker/SiStripCommon/python/ShallowClustersProducer_cfi.py new file mode 100644 index 0000000000000..299ebe17503bc --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/python/ShallowClustersProducer_cfi.py @@ -0,0 +1,7 @@ +import FWCore.ParameterSet.Config as cms + +shallowClusters = cms.EDProducer("ShallowClustersProducer", + Clusters=cms.InputTag("siStripClusters"), + Prefix=cms.string("cluster"), + ) + diff --git a/trunk/CalibTracker/SiStripCommon/python/ShallowDigisProducer_cfi.py b/trunk/CalibTracker/SiStripCommon/python/ShallowDigisProducer_cfi.py new file mode 100644 index 0000000000000..4b7bf2380d255 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/python/ShallowDigisProducer_cfi.py @@ -0,0 +1,10 @@ +import FWCore.ParameterSet.Config as cms + +shallowDigis = cms.EDProducer("ShallowDigisProducer", + DigiProducersList = cms.VInputTag( + cms.InputTag('siStripDigis','ZeroSuppressed'), + cms.InputTag('siStripZeroSuppression','VirginRaw'), + cms.InputTag('siStripZeroSuppression','ProcessedRaw'), + cms.InputTag('siStripZeroSuppression','ScopeMode')) + ) + diff --git a/trunk/CalibTracker/SiStripCommon/python/ShallowEventDataProducer_cfi.py b/trunk/CalibTracker/SiStripCommon/python/ShallowEventDataProducer_cfi.py new file mode 100644 index 0000000000000..32e76796cf7c3 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/python/ShallowEventDataProducer_cfi.py @@ -0,0 +1,3 @@ +import FWCore.ParameterSet.Config as cms + +shallowEventRun = cms.EDProducer("ShallowEventDataProducer") diff --git a/trunk/CalibTracker/SiStripCommon/python/ShallowRechitClustersProducer_cfi.py b/trunk/CalibTracker/SiStripCommon/python/ShallowRechitClustersProducer_cfi.py new file mode 100644 index 0000000000000..a7f5148eaacd2 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/python/ShallowRechitClustersProducer_cfi.py @@ -0,0 +1,13 @@ +import FWCore.ParameterSet.Config as cms + +shallowRechitClusters = cms.EDProducer("ShallowRechitClustersProducer", + Prefix=cms.string("cluster"), + Suffix=cms.string(""), + Clusters=cms.InputTag("siStripClusters"), + InputTags= cms.VInputTag( + cms.InputTag('siStripMatchedRecHits:rphiRecHit'), + cms.InputTag('siStripMatchedRecHits:stereoRecHit'), + cms.InputTag('siStripMatchedRecHits:rphiRecHitUnmatched'), + cms.InputTag('siStripMatchedRecHits:stereoRecHitUnmatched') + ) + ) diff --git a/trunk/CalibTracker/SiStripCommon/python/ShallowSimTracksProducer_cfi.py b/trunk/CalibTracker/SiStripCommon/python/ShallowSimTracksProducer_cfi.py new file mode 100644 index 0000000000000..879007ee73d89 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/python/ShallowSimTracksProducer_cfi.py @@ -0,0 +1,11 @@ +import FWCore.ParameterSet.Config as cms + +from SimTracker.TrackAssociation.TrackAssociatorByHits_cfi import * + +shallowSimTracks = cms.EDProducer("ShallowSimTracksProducer", + Associator=cms.ESInputTag('TrackAssociatorByHits:TrackAssociatorByHits'), + TrackingParticles=cms.InputTag("mergedtruth:MergedTrackTruth"), + Tracks=cms.InputTag("generalTracks",""), + Prefix=cms.string("strack"), + Suffix=cms.string("")) + diff --git a/trunk/CalibTracker/SiStripCommon/python/ShallowSimhitClustersProducer_cfi.py b/trunk/CalibTracker/SiStripCommon/python/ShallowSimhitClustersProducer_cfi.py new file mode 100644 index 0000000000000..954f461e50bb2 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/python/ShallowSimhitClustersProducer_cfi.py @@ -0,0 +1,15 @@ +import FWCore.ParameterSet.Config as cms + +shallowSimhitClusters = cms.EDProducer("ShallowSimhitClustersProducer", + Prefix = cms.string("sim"), + Clusters = cms.InputTag("siStripClusters"), + InputTags = cms.VInputTag( + cms.InputTag('g4SimHits:TrackerHitsTECHighTof'), + cms.InputTag('g4SimHits:TrackerHitsTECLowTof'), + cms.InputTag('g4SimHits:TrackerHitsTIDHighTof'), + cms.InputTag('g4SimHits:TrackerHitsTIDLowTof'), + cms.InputTag('g4SimHits:TrackerHitsTIBHighTof'), + cms.InputTag('g4SimHits:TrackerHitsTIBLowTof'), + cms.InputTag('g4SimHits:TrackerHitsTOBHighTof'), + cms.InputTag('g4SimHits:TrackerHitsTOBLowTof') + )) diff --git a/trunk/CalibTracker/SiStripCommon/python/ShallowTrackClustersProducer_cfi.py b/trunk/CalibTracker/SiStripCommon/python/ShallowTrackClustersProducer_cfi.py new file mode 100644 index 0000000000000..05309d3b437c6 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/python/ShallowTrackClustersProducer_cfi.py @@ -0,0 +1,7 @@ +import FWCore.ParameterSet.Config as cms + +shallowTrackClusters = cms.EDProducer("ShallowTrackClustersProducer", + Tracks=cms.InputTag("generalTracks",""), + Clusters=cms.InputTag("siStripClusters"), + Prefix=cms.string("tsos"), + Suffix=cms.string("")) diff --git a/trunk/CalibTracker/SiStripCommon/python/ShallowTracksProducer_cfi.py b/trunk/CalibTracker/SiStripCommon/python/ShallowTracksProducer_cfi.py new file mode 100644 index 0000000000000..24f5d01220fa5 --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/python/ShallowTracksProducer_cfi.py @@ -0,0 +1,7 @@ +import FWCore.ParameterSet.Config as cms + +shallowTracks = cms.EDProducer("ShallowTracksProducer", + Tracks=cms.InputTag("generalTracks",""), + Prefix=cms.string("track"), + Suffix=cms.string("")) + diff --git a/trunk/CalibTracker/SiStripCommon/python/theBigNtupleMC_cfi.py b/trunk/CalibTracker/SiStripCommon/python/theBigNtupleMC_cfi.py new file mode 100644 index 0000000000000..793fe3e852c6e --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/python/theBigNtupleMC_cfi.py @@ -0,0 +1,31 @@ +import FWCore.ParameterSet.Config as cms + +from CalibTracker.SiStripCommon.ShallowEventDataProducer_cfi import * +from CalibTracker.SiStripCommon.ShallowClustersProducer_cfi import * +from CalibTracker.SiStripCommon.ShallowTrackClustersProducer_cfi import * +from CalibTracker.SiStripCommon.ShallowRechitClustersProducer_cfi import * +from CalibTracker.SiStripCommon.ShallowSimhitClustersProducer_cfi import * +from CalibTracker.SiStripCommon.ShallowTracksProducer_cfi import * +from CalibTracker.SiStripCommon.ShallowSimTracksProducer_cfi import * + +shallowTree = cms.EDAnalyzer("ShallowTree", + outputCommands = cms.untracked.vstring( + 'drop *', + 'keep *_shallowEventRun_*_*', + 'keep *_shallowClusters_*_*', + 'keep *_shallowRechitClusters_*_*', + 'keep *_shallowTracks_*_*', + 'keep *_shallowTrackClusters_*_*', + 'keep *_shallowSimhitClusters_*_*', + 'keep *_shallowSimTracks_*_*' + )) + +theBigNtuple = cms.Sequence( (shallowEventRun + + shallowClusters + + shallowRechitClusters + + shallowSimhitClusters + + shallowTrackClusters + + shallowTracks + + shallowSimTracks) * + shallowTree + ) diff --git a/trunk/CalibTracker/SiStripCommon/python/theBigNtuple_cfi.py b/trunk/CalibTracker/SiStripCommon/python/theBigNtuple_cfi.py new file mode 100644 index 0000000000000..b63316264ae6f --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/python/theBigNtuple_cfi.py @@ -0,0 +1,25 @@ +import FWCore.ParameterSet.Config as cms + +from CalibTracker.SiStripCommon.ShallowEventDataProducer_cfi import * +from CalibTracker.SiStripCommon.ShallowClustersProducer_cfi import * +from CalibTracker.SiStripCommon.ShallowTrackClustersProducer_cfi import * +from CalibTracker.SiStripCommon.ShallowRechitClustersProducer_cfi import * +from CalibTracker.SiStripCommon.ShallowTracksProducer_cfi import * + +shallowTree = cms.EDAnalyzer("ShallowTree", + outputCommands = cms.untracked.vstring( + 'drop *', + 'keep *_shallowEventRun_*_*', + 'keep *_shallowClusters_*_*', + 'keep *_shallowRechitClusters_*_*', + 'keep *_shallowTracks_*_*', + 'keep *_shallowTrackClusters_*_*' + )) + +theBigNtuple = cms.Sequence( (shallowEventRun + + shallowClusters + + shallowRechitClusters + + shallowTracks + + shallowTrackClusters) * + shallowTree + ) diff --git a/trunk/CalibTracker/SiStripCommon/src/ShallowTools.cc b/trunk/CalibTracker/SiStripCommon/src/ShallowTools.cc new file mode 100644 index 0000000000000..e3fc718230cab --- /dev/null +++ b/trunk/CalibTracker/SiStripCommon/src/ShallowTools.cc @@ -0,0 +1,48 @@ + +#include "CalibTracker/SiStripCommon/interface/ShallowTools.h" + +#include "FWCore/Framework/interface/Event.h" +#include "DataFormats/SiStripCluster/interface/SiStripCluster.h" +#include "MagneticField/Engine/interface/MagneticField.h" +#include "CondFormats/SiStripObjects/interface/SiStripLorentzAngle.h" +#include "Geometry/TrackerGeometryBuilder/interface/StripGeomDetUnit.h" +#include "boost/foreach.hpp" + + +namespace shallow { + +CLUSTERMAP +make_cluster_map( const edm::Event& iEvent, edm::InputTag& clusterLabel) { + CLUSTERMAP clustermap; + edm::Handle > clusters; + iEvent.getByLabel(clusterLabel, clusters); + + unsigned int clusterindex = 0; + BOOST_FOREACH(const edmNew::DetSet& ds, *clusters) + BOOST_FOREACH(const SiStripCluster& cluster, ds) + clustermap.insert( std::make_pair( std::make_pair(ds.detId(),cluster.firstStrip()), + clusterindex++)); + return clustermap; +} + +int +findTrackIndex(const edm::Handle >& tracks, const reco::Track* track) { + edm::View::const_iterator + it = tracks->begin(), + end = tracks->end(); + //Compare addresses + for(; it!=end; it++) { if (&(*it)==track) { return it - tracks->begin(); } } + return -2; +} + +LocalVector +drift( const StripGeomDetUnit* stripDet, const MagneticField& magfield, const SiStripLorentzAngle& lorentzAngle ) { + LocalVector lbfield=( stripDet->surface()).toLocal( magfield.inTesla(stripDet->surface().position())); + float tanLorentzAnglePerTesla = lorentzAngle.getLorentzAngle(stripDet->geographicalId()); + float driftz = stripDet->specificSurface().bounds().thickness(); + float driftx =-tanLorentzAnglePerTesla * lbfield.y() * driftz; + float drifty = tanLorentzAnglePerTesla * lbfield.x() * driftz; + return LocalVector(driftx,drifty,driftz); +} + +}