00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <memory>
00026 #include <iostream>
00027 #include <limits>
00028 #include <utility>
00029 #include <vector>
00030 #include <algorithm>
00031 #include <functional>
00032 #include <string.h>
00033 #include <sstream>
00034 #include <fstream>
00035
00036
00037 #include "TTree.h"
00038 #include "TFile.h"
00039
00040
00041 #include "FWCore/Framework/interface/Frameworkfwd.h"
00042 #include "FWCore/Framework/interface/EDAnalyzer.h"
00043 #include "FWCore/Framework/interface/Event.h"
00044 #include "FWCore/Framework/interface/MakerMacros.h"
00045 #include "FWCore/Framework/interface/ESHandle.h"
00046 #include "FWCore/Utilities/interface/InputTag.h"
00047 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00048 #include "FWCore/ServiceRegistry/interface/Service.h"
00049 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00050 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
00051 #include <CondFormats/SiStripObjects/interface/FedChannelConnection.h>
00052 #include <CondFormats/SiStripObjects/interface/SiStripFedCabling.h>
00053 #include <CondFormats/DataRecord/interface/SiStripFedCablingRcd.h>
00054 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00055 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00056 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
00057 #include "Geometry/CommonDetUnit/interface/GeomDetUnit.h"
00058 #include <Geometry/CommonTopologies/interface/Topology.h>
00059 #include <Geometry/CommonTopologies/interface/StripTopology.h>
00060 #include <Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h>
00061 #include <Geometry/CommonTopologies/interface/PixelTopology.h>
00062 #include "DataFormats/Common/interface/Ref.h"
00063 #include "DataFormats/DetId/interface/DetId.h"
00064 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00065 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
00066 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
00067 #include "DataFormats/GeometryVector/interface/LocalVector.h"
00068 #include "DataFormats/SiStripCommon/interface/SiStripEventSummary.h"
00069 #include <DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h>
00070 #include <DataFormats/SiStripDetId/interface/SiStripDetId.h>
00071 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
00072 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00073 #include <DataFormats/SiPixelCluster/interface/SiPixelCluster.h>
00074 #include <DataFormats/TrackReco/interface/TrackFwd.h>
00075 #include <DataFormats/TrackReco/interface/Track.h>
00076 #include "DataFormats/TrackReco/interface/DeDxData.h"
00077 #include <DataFormats/TrackerRecHit2D/interface/SiTrackerMultiRecHit.h>
00078 #include <DataFormats/TrackerRecHit2D/interface/SiStripRecHit2D.h>
00079 #include <DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h>
00080 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00081 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00082 #include <DataFormats/L1GlobalTrigger/interface/L1GtFdlWord.h>
00083 #include <DataFormats/Common/interface/TriggerResults.h>
00084 #include "DataFormats/VertexReco/interface/Vertex.h"
00085 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00086 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00087 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
00088 #include <MagneticField/Engine/interface/MagneticField.h>
00089 #include <MagneticField/Records/interface/IdealMagneticFieldRecord.h>
00090 #include <RecoTracker/TransientTrackingRecHit/interface/TSiStripRecHit2DLocalPos.h>
00091 #include <RecoTracker/TransientTrackingRecHit/interface/TSiTrackerMultiRecHit.h>
00092 #include <RecoTracker/TransientTrackingRecHit/interface/TSiPixelRecHit.h>
00093 #include <RecoTracker/TransientTrackingRecHit/interface/TSiStripRecHit1D.h>
00094 #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
00095 #include <TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h>
00096 #include <TrackingTools/PatternTools/interface/Trajectory.h>
00097 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00098 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
00099 #include <RecoLocalTracker/SiStripClusterizer/interface/SiStripClusterInfo.h>
00100
00101
00102 #include "DPGAnalysis/SiStripTools/interface/EventShape.h"
00103
00104
00105
00106
00107 typedef math::XYZPoint Point;
00108
00109 class TrackerDpgAnalysis : public edm::EDAnalyzer {
00110 public:
00111 explicit TrackerDpgAnalysis(const edm::ParameterSet&);
00112 ~TrackerDpgAnalysis();
00113
00114 protected:
00115 std::vector<double> onTrackAngles(edm::Handle<edmNew::DetSetVector<SiStripCluster> >&,const std::vector<Trajectory>& );
00116 void insertMeasurement(std::multimap<const uint32_t,std::pair<LocalPoint,double> >&, const TransientTrackingRecHit*,double);
00117 std::vector<int> onTrack(edm::Handle<edmNew::DetSetVector<SiStripCluster> >&,const reco::TrackCollection&, uint32_t );
00118 void insertMeasurement(std::multimap<const uint32_t,std::pair<int,int> >&, const TrackingRecHit*,int);
00119 std::map<size_t,int> inVertex(const reco::TrackCollection&, const reco::VertexCollection&, uint32_t);
00120 std::vector<std::pair<double,double> > onTrackAngles(edm::Handle<edmNew::DetSetVector<SiPixelCluster> >&,const std::vector<Trajectory>& );
00121 void insertMeasurement(std::multimap<const uint32_t,std::pair<LocalPoint,std::pair<double,double> > >&, const TransientTrackingRecHit*,double,double);
00122 std::vector<int> onTrack(edm::Handle<edmNew::DetSetVector<SiPixelCluster> >&,const reco::TrackCollection&, uint32_t );
00123 void insertMeasurement(std::multimap<const uint32_t,std::pair<std::pair<float, float>,int> >&, const TrackingRecHit*,int);
00124 std::string toStringName(uint32_t, const TrackerTopology*);
00125 std::string toStringId(uint32_t);
00126 double sumPtSquared(const reco::Vertex&);
00127 float delay(const SiStripEventSummary&);
00128 std::map<uint32_t,float> delay(const std::vector<std::string>&);
00129
00130 private:
00131 virtual void beginRun(const edm::Run&, const edm::EventSetup&) override;
00132 virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
00133 virtual void endJob() ;
00134
00135
00136 static const int nMaxPVs_ = 50;
00137 edm::InputTag clusterLabel_, pixelclusterLabel_, dedx1Label_, dedx2Label_, dedx3Label_, pixelVertexLabel_,
00138 vertexLabel_, bsLabel_, L1Label_, HLTLabel_;
00139 std::vector<edm::InputTag> trackLabel_;
00140 edm::ESHandle<SiStripFedCabling> cabling_;
00141 edm::ESHandle<TrackerGeometry> tracker_;
00142 std::multimap<const uint32_t,const FedChannelConnection*> connections_;
00143 bool functionality_offtrackClusters_, functionality_ontrackClusters_, functionality_pixclusters_, functionality_pixvertices_,
00144 functionality_missingHits_, functionality_tracks_, functionality_vertices_, functionality_events_;
00145 TTree* clusters_;
00146 TTree* pixclusters_;
00147 std::vector<TTree*> tracks_;
00148 std::vector<TTree*> missingHits_;
00149 TTree* vertices_;
00150 TTree* pixelVertices_;
00151 TTree* event_;
00152 TTree* psumap_;
00153 TTree* readoutmap_;
00154 bool onTrack_;
00155 uint32_t vertexid_, eventid_, runid_;
00156 uint32_t globalvertexid_;
00157 uint32_t *globaltrackid_, *trackid_;
00158 float globalX_, globalY_, globalZ_;
00159 float measX_, measY_, errorX_, errorY_;
00160 float angle_, maxCharge_;
00161 float clCorrectedCharge_, clCorrectedSignalOverNoise_;
00162 float clNormalizedCharge_, clNormalizedNoise_, clSignalOverNoise_;
00163 float clBareNoise_, clBareCharge_;
00164 float clWidth_, clPosition_, thickness_, stripLength_, distance_;
00165 float eta_, phi_, chi2_;
00166 float dedx1_, dedx2_, dedx3_;
00167 uint32_t detid_, dcuId_, type_;
00168 uint16_t fecCrate_, fecSlot_, fecRing_, ccuAdd_, ccuChan_, lldChannel_, fedId_, fedCh_, fiberLength_;
00169 uint32_t nclusters_, npixClusters_, nclustersOntrack_, npixClustersOntrack_, dedxNoM_, quality_, foundhits_, lostHits_, ndof_;
00170 uint32_t *ntracks_, *ntrajs_;
00171 float *lowPixelProbabilityFraction_;
00172 uint32_t nVertices_, nPixelVertices_, nLayers_,foundhitsStrips_,foundhitsPixels_,losthitsStrips_,losthitsPixels_;
00173 uint32_t nTracks_pvtx_;
00174 uint32_t clSize_, clSizeX_, clSizeY_;
00175 float fBz_, clPositionX_, clPositionY_, alpha_, beta_, chargeCorr_;
00176 float recx_pvtx_, recy_pvtx_, recz_pvtx_,
00177 recx_err_pvtx_, recy_err_pvtx_, recz_err_pvtx_, sumptsq_pvtx_;
00178 float pterr_, etaerr_, phierr_;
00179 float dz_, dzerr_, dzCorr_, dxy_, dxyerr_, dxyCorr_;
00180 float qoverp_, xPCA_, yPCA_, zPCA_, trkWeightpvtx_;
00181 bool isValid_pvtx_, isFake_pvtx_;
00182 float charge_, p_, pt_;
00183 float bsX0_, bsY0_, bsZ0_, bsSigmaZ_, bsDxdz_, bsDydz_;
00184 float thrustValue_, thrustX_, thrustY_, thrustZ_, sphericity_, planarity_, aplanarity_, delay_;
00185 bool L1DecisionBits_[192], L1TechnicalBits_[64], HLTDecisionBits_[256];
00186 uint32_t orbit_, orbitL1_, bx_, store_, time_;
00187 uint16_t lumiSegment_, physicsDeclared_;
00188 char *moduleName_, *moduleId_, *PSUname_;
00189 std::string cablingFileName_;
00190 std::vector<std::string> delayFileNames_;
00191 edm::ParameterSet pset_;
00192 std::vector<std::string> hlNames_;
00193 HLTConfigProvider hltConfig_;
00194
00195 };
00196
00197
00198
00199
00200 TrackerDpgAnalysis::TrackerDpgAnalysis(const edm::ParameterSet& iConfig):hltConfig_()
00201 {
00202
00203 moduleName_ = new char[256];
00204 moduleId_ = new char[256];
00205 PSUname_ = new char[256];
00206 pset_ = iConfig;
00207
00208
00209 functionality_offtrackClusters_ = iConfig.getUntrackedParameter<bool>("keepOfftrackClusters",true);
00210 functionality_ontrackClusters_ = iConfig.getUntrackedParameter<bool>("keepOntrackClusters",true);
00211 functionality_pixclusters_ = iConfig.getUntrackedParameter<bool>("keepPixelClusters",true);
00212 functionality_pixvertices_ = iConfig.getUntrackedParameter<bool>("keepPixelVertices",true);
00213 functionality_missingHits_ = iConfig.getUntrackedParameter<bool>("keepMissingHits",true);
00214 functionality_tracks_ = iConfig.getUntrackedParameter<bool>("keepTracks",true);
00215 functionality_vertices_ = iConfig.getUntrackedParameter<bool>("keepVertices",true);
00216 functionality_events_ = iConfig.getUntrackedParameter<bool>("keepEvents",true);
00217
00218
00219 clusterLabel_ = iConfig.getParameter<edm::InputTag>("ClustersLabel");
00220 pixelclusterLabel_ = iConfig.getParameter<edm::InputTag>("PixelClustersLabel");
00221 trackLabel_ = iConfig.getParameter<std::vector<edm::InputTag> >("TracksLabel");
00222 dedx1Label_ = iConfig.getParameter<edm::InputTag>("DeDx1Label");
00223 dedx2Label_ = iConfig.getParameter<edm::InputTag>("DeDx2Label");
00224 dedx3Label_ = iConfig.getParameter<edm::InputTag>("DeDx3Label");
00225 vertexLabel_ = iConfig.getParameter<edm::InputTag>("vertexLabel");
00226 pixelVertexLabel_ = iConfig.getParameter<edm::InputTag>("pixelVertexLabel");
00227 bsLabel_ = iConfig.getParameter<edm::InputTag>("beamSpotLabel");
00228 L1Label_ = iConfig.getParameter<edm::InputTag>("L1Label");
00229 HLTLabel_ = iConfig.getParameter<edm::InputTag>("HLTLabel");
00230
00231
00232 ntracks_ = new uint32_t[trackLabel_.size()];
00233 ntrajs_ = new uint32_t[trackLabel_.size()];
00234 globaltrackid_ = new uint32_t[trackLabel_.size()];
00235 trackid_ = new uint32_t[trackLabel_.size()];
00236 lowPixelProbabilityFraction_ = new float[trackLabel_.size()];
00237 globalvertexid_ = iConfig.getParameter<uint32_t>("InitalCounter");
00238 for(size_t i = 0; i<trackLabel_.size();++i) {
00239 ntracks_[i]=0;
00240 ntrajs_[i]=0;
00241 globaltrackid_[i]=iConfig.getParameter<uint32_t>("InitalCounter");
00242 trackid_[i]=0;
00243 lowPixelProbabilityFraction_[i]=0;
00244 }
00245
00246
00247 edm::Service<TFileService> fileService;
00248 TFileDirectory* dir = new TFileDirectory(fileService->mkdir("trackerDPG"));
00249
00250
00251 clusters_ = dir->make<TTree>("clusters","cluster information");
00252 clusters_->Branch("eventid",&eventid_,"eventid/i");
00253 clusters_->Branch("runid",&runid_,"runid/i");
00254 for(size_t i = 0; i<trackLabel_.size(); ++i) {
00255 char buffer1[256];
00256 char buffer2[256];
00257 sprintf(buffer1,"trackid%lu",(unsigned long)i);
00258 sprintf(buffer2,"trackid%lu/i",(unsigned long)i);
00259 clusters_->Branch(buffer1,trackid_+i,buffer2);
00260 }
00261 clusters_->Branch("onTrack",&onTrack_,"onTrack/O");
00262 clusters_->Branch("clWidth",&clWidth_,"clWidth/F");
00263 clusters_->Branch("clPosition",&clPosition_,"clPosition/F");
00264 clusters_->Branch("clglobalX",&globalX_,"clglobalX/F");
00265 clusters_->Branch("clglobalY",&globalY_,"clglobalY/F");
00266 clusters_->Branch("clglobalZ",&globalZ_,"clglobalZ/F");
00267 clusters_->Branch("angle",&angle_,"angle/F");
00268 clusters_->Branch("thickness",&thickness_,"thickness/F");
00269 clusters_->Branch("maxCharge",&maxCharge_,"maxCharge/F");
00270 clusters_->Branch("clNormalizedCharge",&clNormalizedCharge_,"clNormalizedCharge/F");
00271 clusters_->Branch("clNormalizedNoise",&clNormalizedNoise_,"clNormalizedNoise/F");
00272 clusters_->Branch("clSignalOverNoise",&clSignalOverNoise_,"clSignalOverNoise/F");
00273 clusters_->Branch("clCorrectedCharge",&clCorrectedCharge_,"clCorrectedCharge/F");
00274 clusters_->Branch("clCorrectedSignalOverNoise",&clCorrectedSignalOverNoise_,"clCorrectedSignalOverNoise/F");
00275 clusters_->Branch("clBareCharge",&clBareCharge_,"clBareCharge/F");
00276 clusters_->Branch("clBareNoise",&clBareNoise_,"clBareNoise/F");
00277 clusters_->Branch("stripLength",&stripLength_,"stripLength/F");
00278 clusters_->Branch("detid",&detid_,"detid/i");
00279 clusters_->Branch("lldChannel",&lldChannel_,"lldChannel/s");
00280
00281
00282 pixclusters_ = dir->make<TTree>("pixclusters","pixel cluster information");
00283 pixclusters_->Branch("eventid",&eventid_,"eventid/i");
00284 pixclusters_->Branch("runid",&runid_,"runid/i");
00285 for(size_t i = 0; i<trackLabel_.size(); ++i) {
00286 char buffer1[256];
00287 char buffer2[256];
00288 sprintf(buffer1,"trackid%lu",(unsigned long)i);
00289 sprintf(buffer2,"trackid%lu/i",(unsigned long)i);
00290 pixclusters_->Branch(buffer1,trackid_+i,buffer2);
00291 }
00292 pixclusters_->Branch("onTrack",&onTrack_,"onTrack/O");
00293 pixclusters_->Branch("clPositionX",&clPositionX_,"clPositionX/F");
00294 pixclusters_->Branch("clPositionY",&clPositionY_,"clPositionY/F");
00295 pixclusters_->Branch("clSize",&clSize_,"clSize/i");
00296 pixclusters_->Branch("clSizeX",&clSizeX_,"clSizeX/i");
00297 pixclusters_->Branch("clSizeY",&clSizeY_,"clSizeY/i");
00298 pixclusters_->Branch("alpha",&alpha_,"alpha/F");
00299 pixclusters_->Branch("beta",&beta_,"beta/F");
00300 pixclusters_->Branch("charge",&charge_,"charge/F");
00301 pixclusters_->Branch("chargeCorr",&chargeCorr_,"chargeCorr/F");
00302 pixclusters_->Branch("clglobalX",&globalX_,"clglobalX/F");
00303 pixclusters_->Branch("clglobalY",&globalY_,"clglobalY/F");
00304 pixclusters_->Branch("clglobalZ",&globalZ_,"clglobalZ/F");
00305 pixclusters_->Branch("detid",&detid_,"detid/i");
00306
00307
00308 for(size_t i = 0; i<trackLabel_.size(); ++i) {
00309 char buffer1[256];
00310 char buffer2[256];
00311 sprintf(buffer1,"tracks%lu",(unsigned long)i);
00312 sprintf(buffer2,"track%lu information",(unsigned long)i);
00313 TTree* thetracks_ = dir->make<TTree>(buffer1,buffer2);
00314 sprintf(buffer1,"trackid%lu",(unsigned long)i);
00315 sprintf(buffer2,"trackid%lu/i",(unsigned long)i);
00316 thetracks_->Branch(buffer1,globaltrackid_+i,buffer2);
00317 thetracks_->Branch("eventid",&eventid_,"eventid/i");
00318 thetracks_->Branch("runid",&runid_,"runid/i");
00319 thetracks_->Branch("chi2",&chi2_,"chi2/F");
00320 thetracks_->Branch("eta",&eta_,"eta/F");
00321 thetracks_->Branch("etaerr",&etaerr_,"etaerr/F");
00322 thetracks_->Branch("phi",&phi_,"phi/F");
00323 thetracks_->Branch("phierr",&phierr_,"phierr/F");
00324 thetracks_->Branch("dedx1",&dedx1_,"dedx1/F");
00325 thetracks_->Branch("dedx2",&dedx2_,"dedx2/F");
00326 thetracks_->Branch("dedx3",&dedx3_,"dedx3/F");
00327 thetracks_->Branch("dedxNoM",&dedxNoM_,"dedxNoM/i");
00328 thetracks_->Branch("charge",&charge_,"charge/F");
00329 thetracks_->Branch("quality",&quality_,"quality/i");
00330 thetracks_->Branch("foundhits",&foundhits_,"foundhits/i");
00331 thetracks_->Branch("lostHits",&lostHits_,"lostHits/i");
00332 thetracks_->Branch("foundhitsStrips",&foundhitsStrips_,"foundhitsStrips/i");
00333 thetracks_->Branch("foundhitsPixels",&foundhitsPixels_,"foundhitsPixels/i");
00334 thetracks_->Branch("losthitsStrips",&losthitsStrips_,"losthitsStrips/i");
00335 thetracks_->Branch("losthitsPixels",&losthitsPixels_,"losthitsPixels/i");
00336 thetracks_->Branch("p",&p_,"p/F");
00337 thetracks_->Branch("pt",&pt_,"pt/F");
00338 thetracks_->Branch("pterr",&pterr_,"pterr/F");
00339 thetracks_->Branch("ndof",&ndof_,"ndof/i");
00340 thetracks_->Branch("dz",&dz_,"dz/F");
00341 thetracks_->Branch("dzerr",&dzerr_,"dzerr/F");
00342 thetracks_->Branch("dzCorr",&dzCorr_,"dzCorr/F");
00343 thetracks_->Branch("dxy",&dxy_,"dxy/F");
00344 thetracks_->Branch("dxyerr",&dxyerr_,"dxyerr/F");
00345 thetracks_->Branch("dxyCorr",&dxyCorr_,"dxyCorr/F");
00346 thetracks_->Branch("qoverp",&qoverp_,"qoverp/F");
00347 thetracks_->Branch("xPCA",&xPCA_,"xPCA/F");
00348 thetracks_->Branch("yPCA",&yPCA_,"yPCA/F");
00349 thetracks_->Branch("zPCA",&zPCA_,"zPCA/F");
00350 thetracks_->Branch("nLayers",&nLayers_,"nLayers/i");
00351 thetracks_->Branch("trkWeightpvtx",&trkWeightpvtx_,"trkWeightpvtx/F");
00352 thetracks_->Branch("vertexid",&vertexid_,"vertexid/i");
00353 tracks_.push_back(thetracks_);
00354 }
00355
00356
00357 for(size_t i = 0; i<trackLabel_.size(); ++i) {
00358 char buffer1[256];
00359 char buffer2[256];
00360 sprintf(buffer1,"misingHits%lu",(unsigned long)i);
00361 sprintf(buffer2,"missing hits from track collection %lu",(unsigned long)i);
00362 TTree* themissingHits_ = dir->make<TTree>(buffer1,buffer2);
00363 sprintf(buffer1,"trackid%lu",(unsigned long)i);
00364 sprintf(buffer2,"trackid%lu/i",(unsigned long)i);
00365 themissingHits_->Branch(buffer1,globaltrackid_+i,buffer2);
00366 themissingHits_->Branch("eventid",&eventid_,"eventid/i");
00367 themissingHits_->Branch("runid",&runid_,"runid/i");
00368 themissingHits_->Branch("detid",&detid_,"detid/i");
00369 themissingHits_->Branch("type",&type_,"type/i");
00370 themissingHits_->Branch("localX",&clPositionX_,"localX/F");
00371 themissingHits_->Branch("localY",&clPositionY_,"localY/F");
00372 themissingHits_->Branch("globalX",&globalX_,"globalX/F");
00373 themissingHits_->Branch("globalY",&globalY_,"globalY/F");
00374 themissingHits_->Branch("globalZ",&globalZ_,"globalZ/F");
00375 themissingHits_->Branch("measX",&measX_,"measX/F");
00376 themissingHits_->Branch("measY",&measY_,"measY/F");
00377 themissingHits_->Branch("errorX",&errorX_,"errorX/F");
00378 themissingHits_->Branch("errorY",&errorY_,"errorY/F");
00379 missingHits_.push_back(themissingHits_);
00380 }
00381
00382
00383 vertices_ = dir->make<TTree>("vertices","vertex information");
00384 vertices_->Branch("vertexid",&globalvertexid_,"vertexid/i");
00385 vertices_->Branch("eventid",&eventid_,"eventid/i");
00386 vertices_->Branch("runid",&runid_,"runid/i");
00387 vertices_->Branch("nTracks",&nTracks_pvtx_,"nTracks/i");
00388 vertices_->Branch("sumptsq",&sumptsq_pvtx_,"sumptsq/F");
00389 vertices_->Branch("isValid",&isValid_pvtx_,"isValid/O");
00390 vertices_->Branch("isFake",&isFake_pvtx_,"isFake/O");
00391 vertices_->Branch("recx",&recx_pvtx_,"recx/F");
00392 vertices_->Branch("recy",&recy_pvtx_,"recy/F");
00393 vertices_->Branch("recz",&recz_pvtx_,"recz/F");
00394 vertices_->Branch("recx_err",&recx_err_pvtx_,"recx_err/F");
00395 vertices_->Branch("recy_err",&recy_err_pvtx_,"recy_err/F");
00396 vertices_->Branch("recz_err",&recz_err_pvtx_,"recz_err/F");
00397
00398
00399 pixelVertices_ = dir->make<TTree>("pixelVertices","pixel vertex information");
00400 pixelVertices_->Branch("eventid",&eventid_,"eventid/i");
00401 pixelVertices_->Branch("runid",&runid_,"runid/i");
00402 pixelVertices_->Branch("nTracks",&nTracks_pvtx_,"nTracks/i");
00403 pixelVertices_->Branch("sumptsq",&sumptsq_pvtx_,"sumptsq/F");
00404 pixelVertices_->Branch("isValid",&isValid_pvtx_,"isValid/O");
00405 pixelVertices_->Branch("isFake",&isFake_pvtx_,"isFake/O");
00406 pixelVertices_->Branch("recx",&recx_pvtx_,"recx/F");
00407 pixelVertices_->Branch("recy",&recy_pvtx_,"recy/F");
00408 pixelVertices_->Branch("recz",&recz_pvtx_,"recz/F");
00409 pixelVertices_->Branch("recx_err",&recx_err_pvtx_,"recx_err/F");
00410 pixelVertices_->Branch("recy_err",&recy_err_pvtx_,"recy_err/F");
00411 pixelVertices_->Branch("recz_err",&recz_err_pvtx_,"recz_err/F");
00412
00413
00414 event_ = dir->make<TTree>("events","event information");
00415 event_->Branch("eventid",&eventid_,"eventid/i");
00416 event_->Branch("runid",&runid_,"runid/i");
00417 event_->Branch("L1DecisionBits",L1DecisionBits_,"L1DecisionBits[192]/O");
00418 event_->Branch("L1TechnicalBits",L1TechnicalBits_,"L1TechnicalBits[64]/O");
00419 event_->Branch("orbit",&orbit_,"orbit/i");
00420 event_->Branch("orbitL1",&orbitL1_,"orbitL1/i");
00421 event_->Branch("bx",&bx_,"bx/i");
00422 event_->Branch("store",&store_,"store/i");
00423 event_->Branch("time",&time_,"time/i");
00424 event_->Branch("delay",&delay_,"delay/F");
00425 event_->Branch("lumiSegment",&lumiSegment_,"lumiSegment/s");
00426 event_->Branch("physicsDeclared",&physicsDeclared_,"physicsDeclared/s");
00427 event_->Branch("HLTDecisionBits",HLTDecisionBits_,"HLTDecisionBits[256]/O");
00428 char buffer[256];
00429 sprintf(buffer,"ntracks[%lu]/i",(unsigned long)trackLabel_.size());
00430 event_->Branch("ntracks",ntracks_,buffer);
00431 sprintf(buffer,"ntrajs[%lu]/i",(unsigned long)trackLabel_.size());
00432 event_->Branch("ntrajs",ntrajs_,buffer);
00433 sprintf(buffer,"lowPixelProbabilityFraction[%lu]/F",(unsigned long)trackLabel_.size());
00434 event_->Branch("lowPixelProbabilityFraction",lowPixelProbabilityFraction_,buffer);
00435 event_->Branch("nclusters",&nclusters_,"nclusters/i");
00436 event_->Branch("npixClusters",&npixClusters_,"npixClusters/i");
00437 event_->Branch("nclustersOntrack",&nclustersOntrack_,"nclustersOntrack/i");
00438 event_->Branch("npixClustersOntrack",&npixClustersOntrack_,"npixClustersOntrack/i");
00439 event_->Branch("bsX0",&bsX0_,"bsX0/F");
00440 event_->Branch("bsY0",&bsY0_,"bsY0/F");
00441 event_->Branch("bsZ0",&bsZ0_,"bsZ0/F");
00442 event_->Branch("bsSigmaZ",&bsSigmaZ_,"bsSigmaZ/F");
00443 event_->Branch("bsDxdz",&bsDxdz_,"bsDxdz/F");
00444 event_->Branch("bsDydz",&bsDydz_,"bsDydz/F");
00445 event_->Branch("nVertices",&nVertices_,"nVertices/i");
00446 event_->Branch("thrustValue",&thrustValue_,"thrustValue/F");
00447 event_->Branch("thrustX",&thrustX_,"thrustX/F");
00448 event_->Branch("thrustY",&thrustY_,"thrustY/F");
00449 event_->Branch("thrustZ",&thrustZ_,"thrustZ/F");
00450 event_->Branch("sphericity",&sphericity_,"sphericity/F");
00451 event_->Branch("planarity",&planarity_,"planarity/F");
00452 event_->Branch("aplanarity",&aplanarity_,"aplanarity/F");
00453 event_->Branch("MagneticField",&fBz_,"MagneticField/F");
00454
00455
00456 cablingFileName_ = iConfig.getUntrackedParameter<std::string>("PSUFileName","PSUmapping.csv");
00457 delayFileNames_ = iConfig.getUntrackedParameter<std::vector<std::string> >("DelayFileNames",std::vector<std::string>(0));
00458 psumap_ = dir->make<TTree>("psumap","PSU map");
00459 psumap_->Branch("PSUname",PSUname_,"PSUname/C");
00460 psumap_->Branch("dcuId",&dcuId_,"dcuId/i");
00461 readoutmap_ = dir->make<TTree>("readoutMap","cabling map");
00462 readoutmap_->Branch("detid",&detid_,"detid/i");
00463 readoutmap_->Branch("dcuId",&dcuId_,"dcuId/i");
00464 readoutmap_->Branch("fecCrate",&fecCrate_,"fecCrate/s");
00465 readoutmap_->Branch("fecSlot",&fecSlot_,"fecSlot/s");
00466 readoutmap_->Branch("fecRing",&fecRing_,"fecRing/s");
00467 readoutmap_->Branch("ccuAdd",&ccuAdd_,"ccuAdd/s");
00468 readoutmap_->Branch("ccuChan",&ccuChan_,"ccuChan/s");
00469 readoutmap_->Branch("lldChannel",&lldChannel_,"lldChannel/s");
00470 readoutmap_->Branch("fedId",&fedId_,"fedId/s");
00471 readoutmap_->Branch("fedCh",&fedCh_,"fedCh/s");
00472 readoutmap_->Branch("fiberLength",&fiberLength_,"fiberLength/s");
00473 readoutmap_->Branch("moduleName",moduleName_,"moduleName/C");
00474 readoutmap_->Branch("moduleId",moduleId_,"moduleId/C");
00475 readoutmap_->Branch("delay",&delay_,"delay/F");
00476 readoutmap_->Branch("globalX",&globalX_,"globalX/F");
00477 readoutmap_->Branch("globalY",&globalY_,"globalY/F");
00478 readoutmap_->Branch("globalZ",&globalZ_,"globalZ/F");
00479 }
00480
00481 TrackerDpgAnalysis::~TrackerDpgAnalysis()
00482 {
00483 delete[] moduleName_;
00484 delete[] moduleId_;
00485 }
00486
00487
00488
00489
00490
00491
00492 void
00493 TrackerDpgAnalysis::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00494 {
00495 using namespace edm;
00496 using namespace reco;
00497 using namespace std;
00498 using reco::TrackCollection;
00499
00500
00501 eventid_ = iEvent.id().event();
00502 runid_ = iEvent.id().run();
00503 bx_ = iEvent.eventAuxiliary().bunchCrossing();
00504 orbit_ = iEvent.eventAuxiliary().orbitNumber();
00505 store_ = iEvent.eventAuxiliary().storeNumber();
00506 time_ = iEvent.eventAuxiliary().time().value();
00507 lumiSegment_ = iEvent.eventAuxiliary().luminosityBlock();
00508
00509
00510 edm::Handle<SiStripEventSummary> summary;
00511 iEvent.getByLabel( "siStripDigis", summary );
00512 if(summary.isValid())
00513 delay_ = delay(*summary.product());
00514 else
00515 delay_ = 0.;
00516
00517
00518 ESHandle<MagneticField> MF;
00519 iSetup.get<IdealMagneticFieldRecord>().get(MF);
00520 const MagneticField* theMagneticField = MF.product();
00521 fBz_ = fabs(theMagneticField->inTesla(GlobalPoint(0,0,0)).z());
00522
00523
00524 edm::Handle<L1GlobalTriggerReadoutRecord> gtrr_handle;
00525 iEvent.getByLabel(L1Label_, gtrr_handle);
00526 L1GlobalTriggerReadoutRecord const* gtrr = gtrr_handle.product();
00527 L1GtFdlWord fdlWord = gtrr->gtFdlWord();
00528 DecisionWord L1decision = fdlWord.gtDecisionWord();
00529 for(int bit=0;bit<128;++bit) {
00530 L1DecisionBits_[bit] = L1decision[bit];
00531 }
00532 DecisionWordExtended L1decisionE = fdlWord.gtDecisionWordExtended();
00533 for(int bit=0;bit<64;++bit) {
00534 L1DecisionBits_[bit+128] = L1decisionE[bit];
00535 }
00536 TechnicalTriggerWord L1technical = fdlWord.gtTechnicalTriggerWord();
00537 for(int bit=0;bit<64;++bit) {
00538 L1TechnicalBits_[bit] = L1technical[bit];
00539 }
00540 orbitL1_ = fdlWord.orbitNr();
00541 physicsDeclared_ = fdlWord.physicsDeclared();
00542 edm::Handle<edm::TriggerResults> trh;
00543 iEvent.getByLabel(HLTLabel_, trh);
00544 size_t ntrh = trh->size();
00545 for(size_t bit=0;bit<256;++bit)
00546 HLTDecisionBits_[bit] = bit<ntrh ? (bool)(trh->accept(bit)): false;
00547
00548
00549 edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00550 iEvent.getByLabel(bsLabel_,recoBeamSpotHandle);
00551 reco::BeamSpot bs = *recoBeamSpotHandle;
00552 const Point beamSpot = recoBeamSpotHandle.isValid() ?
00553 Point(recoBeamSpotHandle->x0(), recoBeamSpotHandle->y0(), recoBeamSpotHandle->z0()) :
00554 Point(0, 0, 0);
00555 if(recoBeamSpotHandle.isValid()) {
00556 bsX0_ = bs.x0();
00557 bsY0_ = bs.y0();
00558 bsZ0_ = bs.z0();
00559 bsSigmaZ_ = bs.sigmaZ();
00560 bsDxdz_ = bs.dxdz();
00561 bsDydz_ = bs.dydz();
00562 } else {
00563 bsX0_ = 0.;
00564 bsY0_ = 0.;
00565 bsZ0_ = 0.;
00566 bsSigmaZ_ = 0.;
00567 bsDxdz_ = 0.;
00568 bsDydz_ = 0.;
00569 }
00570
00571
00572 static const reco::VertexCollection s_empty_vertexColl;
00573 edm::Handle<reco::VertexCollection> vertexCollectionHandle;
00574 iEvent.getByLabel(vertexLabel_,vertexCollectionHandle);
00575 const reco::VertexCollection vertexColl = *(vertexCollectionHandle.product());
00576 nVertices_ = 0;
00577 for(reco::VertexCollection::const_iterator v=vertexColl.begin();
00578 v!=vertexColl.end(); ++v) {
00579 if(v->isValid() && !v->isFake()) ++nVertices_;
00580 }
00581
00582
00583
00584 edm::Handle<reco::VertexCollection> pixelVertexCollectionHandle;
00585 iEvent.getByLabel(pixelVertexLabel_, pixelVertexCollectionHandle);
00586 const reco::VertexCollection pixelVertexColl = *(pixelVertexCollectionHandle.product());
00587 nPixelVertices_ = pixelVertexColl.size();
00588
00589
00590 edm::Handle<edmNew::DetSetVector<SiStripCluster> > clusters;
00591 iEvent.getByLabel(clusterLabel_,clusters);
00592 edm::Handle<edmNew::DetSetVector<SiPixelCluster> > pixelclusters;
00593 iEvent.getByLabel(pixelclusterLabel_,pixelclusters );
00594
00595
00596 Handle<ValueMap<DeDxData> > dEdx1Handle;
00597 Handle<ValueMap<DeDxData> > dEdx2Handle;
00598 Handle<ValueMap<DeDxData> > dEdx3Handle;
00599 try {iEvent.getByLabel(dedx1Label_, dEdx1Handle);} catch ( cms::Exception& ) {;}
00600 try {iEvent.getByLabel(dedx2Label_, dEdx2Handle);} catch ( cms::Exception& ) {;}
00601 try {iEvent.getByLabel(dedx3Label_, dEdx3Handle);} catch ( cms::Exception& ) {;}
00602 const ValueMap<DeDxData> dEdxTrack1 = *dEdx1Handle.product();
00603 const ValueMap<DeDxData> dEdxTrack2 = *dEdx2Handle.product();
00604 const ValueMap<DeDxData> dEdxTrack3 = *dEdx3Handle.product();
00605
00606
00607 std::vector<reco::TrackCollection> trackCollection;
00608 std::vector<edm::Handle<reco::TrackCollection> > trackCollectionHandle;
00609 trackCollectionHandle.resize(trackLabel_.size());
00610 size_t index = 0;
00611 for(std::vector<edm::InputTag>::const_iterator label = trackLabel_.begin();label!=trackLabel_.end();++label,++index) {
00612 try {iEvent.getByLabel(*label,trackCollectionHandle[index]);} catch ( cms::Exception& ) {;}
00613 trackCollection.push_back(*trackCollectionHandle[index].product());
00614 ntracks_[index] = trackCollection[index].size();
00615 }
00616
00617
00618 std::vector<std::vector<Trajectory> > trajectoryCollection;
00619 std::vector<edm::Handle<std::vector<Trajectory> > > trajectoryCollectionHandle;
00620 trajectoryCollectionHandle.resize(trackLabel_.size());
00621 index = 0;
00622 for(std::vector<edm::InputTag>::const_iterator label = trackLabel_.begin();label!=trackLabel_.end();++label,++index) {
00623 try {iEvent.getByLabel(*label,trajectoryCollectionHandle[index]);} catch ( cms::Exception& ) {;}
00624 trajectoryCollection.push_back(*trajectoryCollectionHandle[index].product());
00625 ntrajs_[index] = trajectoryCollection[index].size();
00626 }
00627
00628
00629 std::vector<TrajTrackAssociationCollection> TrajToTrackMap;
00630 Handle<TrajTrackAssociationCollection> trajTrackAssociationHandle;
00631 for(std::vector<edm::InputTag>::const_iterator label = trackLabel_.begin();label!=trackLabel_.end();++label) {
00632 try {iEvent.getByLabel(*label,trajTrackAssociationHandle);} catch ( cms::Exception& ) {;}
00633 TrajToTrackMap.push_back(*trajTrackAssociationHandle.product());
00634 }
00635
00636
00637 if(!(trackCollection.size()>0 && trajectoryCollection.size()>0)) return;
00638
00639
00640 std::vector<std::map<size_t,int> > trackVertices;
00641 for(size_t i=0;i<trackLabel_.size();++i) {
00642 trackVertices.push_back(inVertex(trackCollection[0], vertexColl, globalvertexid_+1));
00643 }
00644
00645
00646 if(functionality_vertices_) {
00647 for(reco::VertexCollection::const_iterator v=vertexColl.begin();
00648 v!=vertexColl.end(); ++v) {
00649 nTracks_pvtx_ = v->tracksSize();
00650 sumptsq_pvtx_ = sumPtSquared(*v);
00651 isValid_pvtx_ = int(v->isValid());
00652 isFake_pvtx_ = int(v->isFake());
00653 recx_pvtx_ = v->x();
00654 recy_pvtx_ = v->y();
00655 recz_pvtx_ = v->z();
00656 recx_err_pvtx_ = v->xError();
00657 recy_err_pvtx_ = v->yError();
00658 recz_err_pvtx_ = v->zError();
00659 globalvertexid_++;
00660 vertices_->Fill();
00661 }
00662 }
00663
00664
00665 if(functionality_pixvertices_) {
00666 for(reco::VertexCollection::const_iterator v=pixelVertexColl.begin();
00667 v!=pixelVertexColl.end(); ++v) {
00668 nTracks_pvtx_ = v->tracksSize();
00669 sumptsq_pvtx_ = sumPtSquared(*v);
00670 isValid_pvtx_ = int(v->isValid());
00671 isFake_pvtx_ = int(v->isFake());
00672 recx_pvtx_ = v->x();
00673 recy_pvtx_ = v->y();
00674 recz_pvtx_ = v->z();
00675 recx_err_pvtx_ = v->xError();
00676 recy_err_pvtx_ = v->yError();
00677 recz_err_pvtx_ = v->zError();
00678 pixelVertices_->Fill();
00679 }
00680 }
00681
00682
00683
00684 std::vector<double> clusterOntrackAngles = onTrackAngles(clusters,trajectoryCollection[0]);
00685 std::vector<std::pair<double,double> > pixclusterOntrackAngles = onTrackAngles(pixelclusters,trajectoryCollection[0]);
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703 std::vector< std::vector<int> > stripClusterOntrackIndices;
00704 for(size_t i = 0; i<trackLabel_.size(); ++i) {
00705 stripClusterOntrackIndices.push_back(onTrack(clusters,trackCollection[i],globaltrackid_[i]+1));
00706 }
00707 std::vector< std::vector<int> > pixelClusterOntrackIndices;
00708 for(size_t i = 0; i<trackLabel_.size(); ++i) {
00709 pixelClusterOntrackIndices.push_back(onTrack(pixelclusters,trackCollection[i],globaltrackid_[i]+1));
00710 }
00711 nclustersOntrack_ = count_if(stripClusterOntrackIndices[0].begin(),stripClusterOntrackIndices[0].end(),bind2nd(not_equal_to<int>(), -1));
00712 npixClustersOntrack_ = count_if(pixelClusterOntrackIndices[0].begin(),pixelClusterOntrackIndices[0].end(),bind2nd(not_equal_to<int>(), -1));
00713
00714
00715 for (size_t coll = 0; coll<trackCollection.size(); ++coll) {
00716 uint32_t n_hits_barrel=0;
00717 uint32_t n_hits_lowprob=0;
00718 for(TrajTrackAssociationCollection::const_iterator it = TrajToTrackMap[coll].begin(); it!=TrajToTrackMap[coll].end(); ++it) {
00719 reco::TrackRef itTrack = it->val;
00720 edm::Ref<std::vector<Trajectory> > traj = it->key;
00721 eta_ = itTrack->eta();
00722 phi_ = itTrack->phi();
00723 try {
00724 dedxNoM_ = dEdxTrack1[itTrack].numberOfMeasurements();
00725 dedx1_ = dEdxTrack1[itTrack].dEdx();
00726 dedx2_ = dEdxTrack2[itTrack].dEdx();
00727 dedx3_ = dEdxTrack3[itTrack].dEdx();
00728 } catch ( cms::Exception& ) {
00729 dedxNoM_ = 0;
00730 dedx1_ = 0.;
00731 dedx2_ = 0.;
00732 dedx3_ = 0.;
00733 }
00734 charge_ = itTrack->charge();
00735 quality_ = itTrack->qualityMask();
00736 foundhits_ = itTrack->found();
00737 lostHits_ = itTrack->lost();
00738 foundhitsStrips_ = itTrack->hitPattern().numberOfValidStripHits();
00739 foundhitsPixels_ = itTrack->hitPattern().numberOfValidPixelHits();
00740 losthitsStrips_ = itTrack->hitPattern().numberOfLostStripHits();
00741 losthitsPixels_ = itTrack->hitPattern().numberOfLostPixelHits();
00742 p_ = itTrack->p();
00743 pt_ = itTrack->pt();
00744 chi2_ = itTrack->chi2();
00745 ndof_ = (uint32_t)itTrack->ndof();
00746 dz_ = itTrack->dz();
00747 dzerr_ = itTrack->dzError();
00748 dzCorr_ = itTrack->dz(beamSpot);
00749 dxy_ = itTrack->dxy();
00750 dxyerr_ = itTrack->dxyError();
00751 dxyCorr_ = itTrack->dxy(beamSpot);
00752 pterr_ = itTrack->ptError();
00753 etaerr_ = itTrack->etaError();
00754 phierr_ = itTrack->phiError();
00755 qoverp_ = itTrack->qoverp();
00756 xPCA_ = itTrack->vertex().x();
00757 yPCA_ = itTrack->vertex().y();
00758 zPCA_ = itTrack->vertex().z();
00759 nLayers_ = uint32_t(itTrack->hitPattern().trackerLayersWithMeasurement());
00760 try {
00761 if(vertexColl.size()>0 && !vertexColl.begin()->isFake()) {
00762 trkWeightpvtx_ = vertexColl.begin()->trackWeight(itTrack);
00763 } else
00764 trkWeightpvtx_ = 0.;
00765 } catch ( cms::Exception& ) {
00766 trkWeightpvtx_ = 0.;
00767 }
00768 globaltrackid_[coll]++;
00769 std::map<size_t,int>::const_iterator theV = trackVertices[coll].find(itTrack.key());
00770 vertexid_ = (theV!=trackVertices[coll].end()) ? theV->second : 0;
00771
00772 Trajectory::DataContainer const & measurements = traj->measurements();
00773 if(functionality_missingHits_) {
00774 for(Trajectory::DataContainer::const_iterator it = measurements.begin(); it!=measurements.end(); ++it) {
00775 TrajectoryMeasurement::ConstRecHitPointer rechit = it->recHit();
00776 if(!rechit->isValid()) {
00777
00778 detid_ = rechit->geographicalId();
00779
00780 type_ = rechit->getType();
00781
00782 LocalPoint local = it->predictedState().localPosition();
00783 clPositionX_ = local.x();
00784 clPositionY_ = local.y();
00785
00786 GlobalPoint global = it->predictedState().globalPosition();
00787 globalX_ = global.x();
00788 globalY_ = global.y();
00789 globalZ_ = global.z();
00790
00791 measX_ = 0;
00792 measY_ = 0;
00793 if(type_ != TrackingRecHit::inactive ) {
00794 const GeomDetUnit* gdu = static_cast<const GeomDetUnit*>(tracker_->idToDetUnit(detid_));
00795 if(gdu && gdu->type().isTracker()) {
00796 const Topology& topo = gdu->topology();
00797 MeasurementPoint meas = topo.measurementPosition(local);
00798 measX_ = meas.x();
00799 measY_ = meas.y();
00800 }
00801 }
00802
00803 LocalError error = it->predictedState().localError().positionError();
00804 errorX_ = error.xx();
00805 errorY_ = error.yy();
00806
00807 missingHits_[coll]->Fill();
00808 }
00809 }
00810 }
00811
00812 for(trackingRecHit_iterator it = itTrack->recHitsBegin(); it!=itTrack->recHitsEnd(); ++it) {
00813 const TrackingRecHit* hit = &(**it);
00814 const SiPixelRecHit* pixhit = dynamic_cast<const SiPixelRecHit*>(hit);
00815 if(pixhit) {
00816 DetId detId = pixhit->geographicalId();
00817 if(detId.subdetId()==PixelSubdetector::PixelBarrel) {
00818 ++n_hits_barrel;
00819 double proba = pixhit->clusterProbability(0);
00820 if(proba<=0.0) ++n_hits_lowprob;
00821 }
00822 }
00823 }
00824
00825 if(functionality_tracks_) tracks_[coll]->Fill();
00826 }
00827 lowPixelProbabilityFraction_[coll] = n_hits_barrel>0 ? (float)n_hits_lowprob/n_hits_barrel : -1.;
00828 }
00829
00830
00831 nclusters_ = 0;
00832 std::vector<double>::const_iterator angleIt = clusterOntrackAngles.begin();
00833 uint32_t localCounter = 0;
00834 for (edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter=clusters->begin(); DSViter!=clusters->end();DSViter++ ) {
00835 edmNew::DetSet<SiStripCluster>::const_iterator begin=DSViter->begin();
00836 edmNew::DetSet<SiStripCluster>::const_iterator end =DSViter->end();
00837 uint32_t detid = DSViter->id();
00838 nclusters_ += DSViter->size();
00839 if(functionality_offtrackClusters_||functionality_ontrackClusters_) {
00840 for(edmNew::DetSet<SiStripCluster>::const_iterator iter=begin;iter!=end;++iter,++angleIt,++localCounter) {
00841 SiStripClusterInfo* siStripClusterInfo = new SiStripClusterInfo(*iter,iSetup,detid,std::string(""));
00842
00843 for(size_t i=0; i< trackLabel_.size(); ++i) {
00844 trackid_[i] = stripClusterOntrackIndices[i][localCounter];
00845 }
00846 onTrack_ = (trackid_[0] != (uint32_t)-1);
00847 clWidth_ = siStripClusterInfo->width();
00848 clPosition_ = siStripClusterInfo->baryStrip();
00849 angle_ = *angleIt;
00850 thickness_ = ((((DSViter->id()>>25)&0x7f)==0xd) ||
00851 ((((DSViter->id()>>25)&0x7f)==0xe) && (((DSViter->id()>>5)&0x7)>4))) ? 500 : 300;
00852 stripLength_ = static_cast<const StripGeomDetUnit*>(tracker_->idToDet(detid))->specificTopology().stripLength();
00853 int nstrips = static_cast<const StripGeomDetUnit*>(tracker_->idToDet(detid))->specificTopology().nstrips();
00854 maxCharge_ = siStripClusterInfo->maxCharge();
00855
00856 clNormalizedCharge_ = siStripClusterInfo->charge() ;
00857 clNormalizedNoise_ = siStripClusterInfo->noiseRescaledByGain() ;
00858 clSignalOverNoise_ = siStripClusterInfo->signalOverNoise() ;
00859
00860 clCorrectedCharge_ = clNormalizedCharge_ * fabs(cos(angle_));
00861 clCorrectedSignalOverNoise_ = clSignalOverNoise_ * fabs(cos(angle_));
00862
00863 clBareNoise_ = siStripClusterInfo->noise();
00864 clBareCharge_ = clSignalOverNoise_*clBareNoise_;
00865
00866 const StripGeomDetUnit* sgdu = static_cast<const StripGeomDetUnit*>(tracker_->idToDet(detid));
00867 Surface::GlobalPoint gp = sgdu->surface().toGlobal(sgdu->specificTopology().localPosition(MeasurementPoint(clPosition_,0)));
00868 globalX_ = gp.x();
00869 globalY_ = gp.y();
00870 globalZ_ = gp.z();
00871
00872 detid_ = detid;
00873 lldChannel_ = 1+(int(floor(iter->barycenter()))/256);
00874 if(lldChannel_==2 && nstrips==512) lldChannel_=3;
00875 if((functionality_offtrackClusters_&&!onTrack_)||(functionality_ontrackClusters_&&onTrack_)) clusters_->Fill();
00876 delete siStripClusterInfo;
00877 }
00878 }
00879 }
00880
00881
00882 npixClusters_ = 0;
00883 std::vector<std::pair<double,double> >::const_iterator pixAngleIt = pixclusterOntrackAngles.begin();
00884 localCounter = 0;
00885 for (edmNew::DetSetVector<SiPixelCluster>::const_iterator DSViter=pixelclusters->begin(); DSViter!=pixelclusters->end();DSViter++ ) {
00886 edmNew::DetSet<SiPixelCluster>::const_iterator begin=DSViter->begin();
00887 edmNew::DetSet<SiPixelCluster>::const_iterator end =DSViter->end();
00888 uint32_t detid = DSViter->id();
00889 npixClusters_ += DSViter->size();
00890 if(functionality_pixclusters_) {
00891 for(edmNew::DetSet<SiPixelCluster>::const_iterator iter=begin;iter!=end;++iter,++pixAngleIt,++localCounter) {
00892
00893 for(size_t i=0; i< trackLabel_.size(); ++i) {
00894 trackid_[i] = pixelClusterOntrackIndices[i][localCounter];
00895 }
00896 onTrack_ = (trackid_[0] != (uint32_t)-1);
00897 clPositionX_ = iter->x();
00898 clPositionY_ = iter->y();
00899 clSize_ = iter->size();
00900 clSizeX_ = iter->sizeX();
00901 clSizeY_ = iter->sizeY();
00902 alpha_ = pixAngleIt->first;
00903 beta_ = pixAngleIt->second;
00904 charge_ = (iter->charge())/1000.;
00905 chargeCorr_ = charge_ * sqrt( 1.0 / ( 1.0/pow( tan(alpha_), 2 ) + 1.0/pow( tan(beta_), 2 ) + 1.0 ))/1000.;
00906
00907 const PixelGeomDetUnit* pgdu = static_cast<const PixelGeomDetUnit*>(tracker_->idToDet(detid));
00908 Surface::GlobalPoint gp = pgdu->surface().toGlobal(pgdu->specificTopology().localPosition(MeasurementPoint(clPositionX_,clPositionY_)));
00909 globalX_ = gp.x();
00910 globalY_ = gp.y();
00911 globalZ_ = gp.z();
00912
00913 detid_ = detid;
00914
00915 pixclusters_->Fill();
00916 }
00917 }
00918 }
00919
00920
00921 EventShape shape(trackCollection[0]);
00922 math::XYZTLorentzVectorF thrust = shape.thrust();
00923 thrustValue_ = thrust.t();
00924 thrustX_ = thrust.x();
00925 thrustY_ = thrust.y();
00926 thrustZ_ = thrust.z();
00927 sphericity_ = shape.sphericity();
00928 planarity_ = shape.planarity();
00929 aplanarity_ = shape.aplanarity();
00930
00931
00932 if(functionality_events_) event_->Fill();
00933
00934 }
00935
00936
00937 void
00938 TrackerDpgAnalysis::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
00939 {
00940
00941
00942 edm::ESHandle<TrackerTopology> tTopoHandle;
00943 iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
00944 const TrackerTopology* const tTopo = tTopoHandle.product();
00945
00946
00947 iSetup.get<TrackerDigiGeometryRecord>().get(tracker_);
00948
00949
00950 bool changed (true);
00951 if (hltConfig_.init(iRun,iSetup,HLTLabel_.process(),changed)) {
00952 if (changed) {
00953 hlNames_=hltConfig_.triggerNames();
00954 }
00955 }
00956 int i=0;
00957 for(std::vector<std::string>::const_iterator it = hlNames_.begin(); it<hlNames_.end();++it) {
00958 std::cout << (i++) << " = " << (*it) << std::endl;
00959 }
00960
00961
00962
00963 std::map<uint32_t,float> delayMap = delay(delayFileNames_);
00964 TrackerMap tmap("Delays");
00965
00966
00967 iSetup.get<SiStripFedCablingRcd>().get( cabling_ );
00968 const std::vector< uint16_t > & feds = cabling_->feds() ;
00969 for(std::vector< uint16_t >::const_iterator fedid = feds.begin();fedid<feds.end();++fedid) {
00970 const std::vector< FedChannelConnection > & connections = cabling_->connections(*fedid);
00971 for(std::vector< FedChannelConnection >::const_iterator conn=connections.begin();conn<connections.end();++conn) {
00972
00973 if(conn->isConnected())
00974 connections_.insert(std::make_pair(conn->detId(),new FedChannelConnection(*conn)));
00975
00976 if(conn->isConnected()) {
00977 detid_ = conn->detId();
00978 strncpy(moduleName_,toStringName(detid_,tTopo).c_str(),256);
00979 strncpy(moduleId_,toStringId(detid_).c_str(),256);
00980 lldChannel_ = conn->lldChannel();
00981 dcuId_ = conn->dcuId();
00982 fecCrate_ = conn->fecCrate();
00983 fecSlot_ = conn->fecSlot();
00984 fecRing_ = conn->fecRing();
00985 ccuAdd_ = conn->ccuAddr();
00986 ccuChan_ = conn->ccuChan();
00987 fedId_ = conn->fedId();
00988 fedCh_ = conn->fedCh();
00989 fiberLength_ = conn->fiberLength();
00990 delay_ = delayMap[dcuId_];
00991 const StripGeomDetUnit* sgdu = static_cast<const StripGeomDetUnit*>(tracker_->idToDet(detid_));
00992 Surface::GlobalPoint gp = sgdu->surface().toGlobal(LocalPoint(0,0));
00993 globalX_ = gp.x();
00994 globalY_ = gp.y();
00995 globalZ_ = gp.z();
00996 readoutmap_->Fill();
00997 tmap.fill_current_val(detid_,delay_);
00998 }
00999 }
01000 }
01001 if(delayMap.size()) tmap.save(true, 0, 0, "delaymap.png");
01002
01003
01004 ifstream cablingFile(cablingFileName_.c_str());
01005 if(cablingFile.is_open()) {
01006 char buffer[1024];
01007 cablingFile.getline(buffer,1024);
01008 while(!cablingFile.eof()) {
01009 std::istringstream line(buffer);
01010 std::string name;
01011
01012 line >> name;
01013 strncpy(PSUname_,name.c_str(),256);
01014 while(!line.eof()) {
01015 line >> dcuId_;
01016 psumap_->Fill();
01017 }
01018 cablingFile.getline(buffer,1024);
01019 }
01020 } else {
01021 edm::LogWarning("BadConfig") << " The PSU file does not exist. The psumap tree will not be filled."
01022 << std::endl << " Looking for " << cablingFileName_.c_str() << "."
01023 << std::endl << " Please specify a valid filename through the PSUFileName untracked parameter.";
01024 }
01025 }
01026
01027
01028 void
01029 TrackerDpgAnalysis::endJob() {
01030 for(size_t i = 0; i<tracks_.size();++i) {
01031 char buffer[256];
01032 sprintf(buffer,"trackid%lu",(unsigned long)i);
01033 if(tracks_[i]->GetEntries()) tracks_[i]->BuildIndex(buffer,"eventid");
01034 }
01035
01036
01037
01038
01039
01040
01041
01042 if(vertices_->GetEntries()) vertices_->BuildIndex("vertexid","eventid");
01043 if(event_->GetEntries()) event_->BuildIndex("runid","eventid");
01044 if(psumap_->GetEntries()) psumap_->BuildIndex("dcuId");
01045 if(readoutmap_->GetEntries()) readoutmap_->BuildIndex("detid","lldChannel");
01046 }
01047
01048 std::vector<double> TrackerDpgAnalysis::onTrackAngles(edm::Handle<edmNew::DetSetVector<SiStripCluster> >& clusters,
01049 const std::vector<Trajectory>& trajVec )
01050 {
01051 std::vector<double> result;
01052
01053 std::multimap<const uint32_t,std::pair<LocalPoint,double> > onTrackPositions;
01054 for(std::vector<Trajectory>::const_iterator traj = trajVec.begin(); traj< trajVec.end(); ++traj) {
01055 Trajectory::DataContainer measurements = traj->measurements();
01056 for(Trajectory::DataContainer::iterator meas = measurements.begin(); meas!= measurements.end(); ++meas) {
01057 double tla = meas->updatedState().localDirection().theta();
01058 insertMeasurement(onTrackPositions,&(*(meas->recHit())),tla);
01059 }
01060 }
01061
01062 double angle = 0.;
01063 for (edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter=clusters->begin(); DSViter!=clusters->end();DSViter++ ) {
01064 edmNew::DetSet<SiStripCluster>::const_iterator begin=DSViter->begin();
01065 edmNew::DetSet<SiStripCluster>::const_iterator end =DSViter->end();
01066 std::pair< std::multimap<uint32_t,std::pair<LocalPoint,double> >::const_iterator,
01067 std::multimap<uint32_t,std::pair<LocalPoint,double> >::const_iterator> range =
01068 onTrackPositions.equal_range(DSViter->id());
01069 const GeomDetUnit* gdu = static_cast<const GeomDetUnit*>(tracker_->idToDet(DSViter->id()));
01070 for(edmNew::DetSet<SiStripCluster>::const_iterator iter=begin;iter!=end;++iter) {
01071 angle = 0.;
01072 for(std::multimap<uint32_t,std::pair<LocalPoint,double> >::const_iterator cl = range.first; cl!= range.second; ++cl) {
01073 if(fabs(gdu->topology().measurementPosition(cl->second.first).x()-iter->barycenter())<2) {
01074 angle = cl->second.second;
01075 }
01076 }
01077 result.push_back(angle);
01078 }
01079 }
01080 return result;
01081 }
01082
01083 void TrackerDpgAnalysis::insertMeasurement(std::multimap<const uint32_t,std::pair<LocalPoint,double> >& collection,const TransientTrackingRecHit* hit , double tla)
01084 {
01085 if(!hit) return;
01086 const TSiTrackerMultiRecHit* multihit=dynamic_cast<const TSiTrackerMultiRecHit*>(hit);
01087 const TSiStripRecHit2DLocalPos* singlehit=dynamic_cast<const TSiStripRecHit2DLocalPos*>(hit);
01088 const TSiStripRecHit1D* hit1d=dynamic_cast<const TSiStripRecHit1D*>(hit);
01089 if(hit1d) {
01090 collection.insert(std::make_pair(hit1d->geographicalId().rawId(),std::make_pair(hit1d->localPosition(),tla)));
01091 } else if(singlehit) {
01092 collection.insert(std::make_pair(singlehit->geographicalId().rawId(),std::make_pair(singlehit->localPosition(),tla)));
01093 }
01094 else if(multihit){
01095 std::vector< const TrackingRecHit * > childs = multihit->recHits();
01096 for(std::vector<const TrackingRecHit*>::const_iterator it=childs.begin();it!=childs.end();++it) {
01097 insertMeasurement(collection,dynamic_cast<const TransientTrackingRecHit*>(*it),tla);
01098 }
01099 }
01100 }
01101
01102 std::vector<int> TrackerDpgAnalysis::onTrack(edm::Handle<edmNew::DetSetVector<SiStripCluster> >& clusters,
01103 const reco::TrackCollection& trackVec, uint32_t firstTrack )
01104 {
01105 std::vector<int> result;
01106
01107 std::multimap<const uint32_t,std::pair<int,int> > onTrackPositions;
01108 uint32_t trackid = firstTrack;
01109 for(reco::TrackCollection::const_iterator itTrack = trackVec.begin(); itTrack!=trackVec.end();++itTrack,++trackid) {
01110 for(trackingRecHit_iterator it = itTrack->recHitsBegin(); it!=itTrack->recHitsEnd(); ++it) {
01111 const TrackingRecHit* hit = &(**it);
01112 insertMeasurement(onTrackPositions,hit,trackid);
01113 }
01114 }
01115
01116 int thetrackid = -1;
01117 for (edmNew::DetSetVector<SiStripCluster>::const_iterator DSViter=clusters->begin(); DSViter!=clusters->end();DSViter++ ) {
01118 edmNew::DetSet<SiStripCluster>::const_iterator begin=DSViter->begin();
01119 edmNew::DetSet<SiStripCluster>::const_iterator end =DSViter->end();
01120 std::pair< std::multimap<uint32_t,std::pair<int,int> >::const_iterator,
01121 std::multimap<uint32_t,std::pair<int,int> >::const_iterator> range =
01122 onTrackPositions.equal_range(DSViter->id());
01123 for(edmNew::DetSet<SiStripCluster>::const_iterator iter=begin;iter!=end;++iter) {
01124 thetrackid = -1;
01125 for(std::multimap<uint32_t,std::pair<int,int> >::const_iterator cl = range.first; cl!= range.second; ++cl) {
01126 if(fabs(cl->second.first-iter->barycenter())<2) {
01127 thetrackid = cl->second.second;
01128 }
01129 }
01130 result.push_back(thetrackid);
01131 }
01132 }
01133 return result;
01134 }
01135
01136 void TrackerDpgAnalysis::insertMeasurement(std::multimap<const uint32_t,std::pair<int, int> >& collection,const TrackingRecHit* hit , int trackid)
01137 {
01138 if(!hit) return;
01139 const SiTrackerMultiRecHit* multihit=dynamic_cast<const SiTrackerMultiRecHit*>(hit);
01140 const SiStripRecHit2D* singlehit=dynamic_cast<const SiStripRecHit2D*>(hit);
01141 const SiStripRecHit1D* hit1d=dynamic_cast<const SiStripRecHit1D*>(hit);
01142 if(hit1d) {
01143 collection.insert(std::make_pair(hit1d->geographicalId().rawId(),std::make_pair(int(hit1d->cluster()->barycenter()),trackid)));
01144 } else if(singlehit) {
01145 collection.insert(std::make_pair(singlehit->geographicalId().rawId(),std::make_pair(int(singlehit->cluster()->barycenter()),trackid)));
01146 }
01147 else if(multihit){
01148 std::vector< const TrackingRecHit * > childs = multihit->recHits();
01149 for(std::vector<const TrackingRecHit*>::const_iterator it=childs.begin();it!=childs.end();++it) {
01150 insertMeasurement(collection,*it,trackid);
01151 }
01152 }
01153 }
01154
01155 std::map<size_t,int> TrackerDpgAnalysis::inVertex(const reco::TrackCollection& tracks, const reco::VertexCollection& vertices, uint32_t firstVertex)
01156 {
01157
01158 std::map<size_t,int> output;
01159 uint32_t vertexid = firstVertex;
01160 for(reco::VertexCollection::const_iterator v = vertices.begin(); v!=vertices.end(); ++v,++vertexid) {
01161 reco::Vertex::trackRef_iterator it = v->tracks_begin();
01162 reco::Vertex::trackRef_iterator lastTrack = v->tracks_end();
01163 for(;it!=lastTrack;++it) {
01164 output[it->key()] = vertexid;
01165 }
01166 }
01167 return output;
01168 }
01169
01170 std::vector<std::pair<double,double> > TrackerDpgAnalysis::onTrackAngles(edm::Handle<edmNew::DetSetVector<SiPixelCluster> >& clusters,
01171 const std::vector<Trajectory>& trajVec )
01172 {
01173 std::vector<std::pair<double,double> > result;
01174
01175 std::multimap<const uint32_t,std::pair<LocalPoint,std::pair<double,double> > > onTrackPositions;
01176 for(std::vector<Trajectory>::const_iterator traj = trajVec.begin(); traj< trajVec.end(); ++traj) {
01177 Trajectory::DataContainer measurements = traj->measurements();
01178 for(Trajectory::DataContainer::iterator meas = measurements.begin(); meas!= measurements.end(); ++meas) {
01179 LocalVector localDir = meas->updatedState().localDirection();
01180 double alpha = atan2(localDir.z(), localDir.x());
01181 double beta = atan2(localDir.z(), localDir.y());
01182 insertMeasurement(onTrackPositions,&(*(meas->recHit())),alpha,beta);
01183 }
01184 }
01185
01186 double alpha = 0.;
01187 double beta = 0.;
01188 for (edmNew::DetSetVector<SiPixelCluster>::const_iterator DSViter=clusters->begin(); DSViter!=clusters->end();DSViter++ ) {
01189 edmNew::DetSet<SiPixelCluster>::const_iterator begin=DSViter->begin();
01190 edmNew::DetSet<SiPixelCluster>::const_iterator end =DSViter->end();
01191 for(edmNew::DetSet<SiPixelCluster>::const_iterator iter=begin;iter!=end;++iter) {
01192 alpha = 0.;
01193 beta = 0.;
01194 std::pair< std::multimap<uint32_t,std::pair<LocalPoint,std::pair<double, double> > >::const_iterator,
01195 std::multimap<uint32_t,std::pair<LocalPoint,std::pair<double, double> > >::const_iterator> range =
01196 onTrackPositions.equal_range(DSViter->id());
01197 const GeomDetUnit* gdu = static_cast<const GeomDetUnit*>(tracker_->idToDet(DSViter->id()));
01198 for(std::multimap<uint32_t,std::pair<LocalPoint,std::pair<double, double> > >::const_iterator cl = range.first; cl!= range.second; ++cl) {
01199 if(fabs(gdu->topology().measurementPosition(cl->second.first).x()-iter->x())<2 &&
01200 fabs(gdu->topology().measurementPosition(cl->second.first).y()-iter->y())<2 ) {
01201 alpha = cl->second.second.first;
01202 beta = cl->second.second.second;
01203 }
01204 }
01205 result.push_back(std::make_pair(alpha,beta));
01206 }
01207 }
01208 return result;
01209 }
01210
01211 void TrackerDpgAnalysis::insertMeasurement(std::multimap<const uint32_t,std::pair<LocalPoint,std::pair<double,double> > >& collection,const TransientTrackingRecHit* hit , double alpha, double beta)
01212 {
01213 if(!hit) return;
01214 const TSiPixelRecHit* pixhit = dynamic_cast<const TSiPixelRecHit*>(hit);
01215 if(pixhit) {
01216 collection.insert(std::make_pair(pixhit->geographicalId().rawId(),std::make_pair(pixhit->localPosition(),std::make_pair(alpha,beta))));
01217 }
01218 }
01219
01220 std::vector<int> TrackerDpgAnalysis::onTrack(edm::Handle<edmNew::DetSetVector<SiPixelCluster> >& clusters,
01221 const reco::TrackCollection& trackVec, uint32_t firstTrack )
01222 {
01223 std::vector<int> result;
01224
01225 std::multimap<const uint32_t,std::pair<std::pair<float, float>,int> > onTrackPositions;
01226 uint32_t trackid = firstTrack;
01227 for(reco::TrackCollection::const_iterator itTrack = trackVec.begin(); itTrack!=trackVec.end();++itTrack,++trackid) {
01228 for(trackingRecHit_iterator it = itTrack->recHitsBegin(); it!=itTrack->recHitsEnd(); ++it) {
01229 const TrackingRecHit* hit = &(**it);
01230 insertMeasurement(onTrackPositions,hit,trackid);
01231 }
01232 }
01233
01234 int thetrackid = -1;
01235 for (edmNew::DetSetVector<SiPixelCluster>::const_iterator DSViter=clusters->begin(); DSViter!=clusters->end();DSViter++ ) {
01236 edmNew::DetSet<SiPixelCluster>::const_iterator begin=DSViter->begin();
01237 edmNew::DetSet<SiPixelCluster>::const_iterator end =DSViter->end();
01238 for(edmNew::DetSet<SiPixelCluster>::const_iterator iter=begin;iter!=end;++iter) {
01239 thetrackid = -1;
01240 std::pair< std::multimap<uint32_t,std::pair<std::pair<float, float>,int> >::const_iterator,
01241 std::multimap<uint32_t,std::pair<std::pair<float, float>,int> >::const_iterator> range =
01242 onTrackPositions.equal_range(DSViter->id());
01243 for(std::multimap<uint32_t,std::pair<std::pair<float, float>,int> >::const_iterator cl = range.first; cl!= range.second; ++cl) {
01244 if((fabs(cl->second.first.first-iter->x())<2)&&(fabs(cl->second.first.second-iter->y())<2)) {
01245 thetrackid = cl->second.second;
01246 }
01247 }
01248 result.push_back(thetrackid);
01249 }
01250 }
01251 return result;
01252 }
01253
01254 void TrackerDpgAnalysis::insertMeasurement(std::multimap<const uint32_t,std::pair<std::pair<float, float>, int> >& collection,const TrackingRecHit* hit , int trackid)
01255 {
01256 if(!hit) return;
01257 const SiPixelRecHit* pixhit = dynamic_cast<const SiPixelRecHit*>(hit);
01258 if(pixhit) {
01259 collection.insert(std::make_pair(pixhit->geographicalId().rawId(),std::make_pair(std::make_pair(pixhit->cluster()->x(),pixhit->cluster()->y()),trackid)));
01260 }
01261 }
01262
01263 std::string TrackerDpgAnalysis::toStringName(uint32_t rawid, const TrackerTopology* tTopo) {
01264 SiStripDetId detid(rawid);
01265 std::string out;
01266 std::stringstream output;
01267 switch(detid.subDetector()) {
01268 case 3:
01269 {
01270 output << "TIB";
01271
01272 output << (tTopo->tibIsZPlusSide(rawid) ? "+" : "-");
01273 output << " layer ";
01274 output << tTopo->tibLayer(rawid);
01275 output << ", string ";
01276 output << tTopo->tibString(rawid);
01277 output << (tTopo->tibIsExternalString(rawid) ? " external" : " internal");
01278 output << ", module ";
01279 output << tTopo->tibModule(rawid);
01280 if(tTopo->tibIsDoubleSide(rawid)) {
01281 output << " (double)";
01282 } else {
01283 output << (tTopo->tibIsRPhi(rawid) ? " (rphi)" : " (stereo)");
01284 }
01285 break;
01286 }
01287 case 4:
01288 {
01289 output << "TID";
01290
01291 output << (tTopo->tidIsZPlusSide(rawid) ? "+" : "-");
01292 output << " disk ";
01293 output << tTopo->tidWheel(rawid);
01294 output << ", ring ";
01295 output << tTopo->tidRing(rawid);
01296 output << (tTopo->tidIsFrontRing(rawid) ? " front" : " back");
01297 output << ", module ";
01298 output << tTopo->tidModule(rawid);
01299 if(tTopo->tidIsDoubleSide(rawid)) {
01300 output << " (double)";
01301 } else {
01302 output << (tTopo->tidIsRPhi(rawid) ? " (rphi)" : " (stereo)");
01303 }
01304 break;
01305 }
01306 case 5:
01307 {
01308 output << "TOB";
01309
01310 output << (tTopo->tobIsZPlusSide(rawid) ? "+" : "-");
01311 output << " layer ";
01312 output << tTopo->tobLayer(rawid);
01313 output << ", rod ";
01314 output << tTopo->tobRod(rawid);
01315 output << ", module ";
01316 output << tTopo->tobModule(rawid);
01317 if(tTopo->tobIsDoubleSide(rawid)) {
01318 output << " (double)";
01319 } else {
01320 output << (tTopo->tobIsRPhi(rawid) ? " (rphi)" : " (stereo)");
01321 }
01322 break;
01323 }
01324 case 6:
01325 {
01326 output << "TEC";
01327
01328 output << (tTopo->tecIsZPlusSide(rawid) ? "+" : "-");
01329 output << " disk ";
01330 output << tTopo->tecWheel(rawid);
01331 output << " sector ";
01332 output << tTopo->tecPetalNumber(rawid);
01333 output << (tTopo->tecIsFrontPetal(rawid) ? " Front Petal" : " Back Petal");
01334 output << ", module ";
01335 output << tTopo->tecRing(rawid);
01336 output << tTopo->tecModule(rawid);
01337 if(tTopo->tecIsDoubleSide(rawid)) {
01338 output << " (double)";
01339 } else {
01340 output << (tTopo->tecIsRPhi(rawid) ? " (rphi)" : " (stereo)");
01341 }
01342 break;
01343 }
01344 default:
01345 {
01346 output << "UNKNOWN";
01347 }
01348 }
01349 out = output.str();
01350 return out;
01351 }
01352
01353 std::string TrackerDpgAnalysis::toStringId(uint32_t rawid) {
01354 std::string out;
01355 std::stringstream output;
01356 output << rawid << " (0x" << std::hex << rawid << std::dec << ")";
01357 out = output.str();
01358 return out;
01359 }
01360
01361 double TrackerDpgAnalysis::sumPtSquared(const reco::Vertex & v) {
01362 double sum = 0.;
01363 double pT;
01364 for (reco::Vertex::trackRef_iterator it = v.tracks_begin(); it != v.tracks_end(); it++) {
01365 pT = (**it).pt();
01366 sum += pT*pT;
01367 }
01368 return sum;
01369 }
01370
01371 float TrackerDpgAnalysis::delay(const SiStripEventSummary& summary) {
01372 float delay = const_cast<SiStripEventSummary&>(summary).ttcrx();
01373 uint32_t latencyCode = (const_cast<SiStripEventSummary&>(summary).layerScanned()>>24)&0xff;
01374 int latencyShift = latencyCode & 0x3f;
01375 if(latencyShift>32) latencyShift -=64;
01376 if((latencyCode>>6)==2) latencyShift -= 3;
01377 if((latencyCode>>6)==1) latencyShift += 3;
01378 float correctedDelay = delay - (latencyShift*25.);
01379 return correctedDelay;
01380 }
01381
01382 std::map<uint32_t,float> TrackerDpgAnalysis::delay(const std::vector<std::string>& files) {
01383
01384 uint32_t dcuid;
01385 float delay;
01386 std::map<uint32_t,float> delayMap;
01387
01388 for(std::vector<std::string>::const_iterator file=files.begin();file<files.end();++file){
01389
01390 std::ifstream cablingFile(file->c_str());
01391 if(cablingFile.is_open()) {
01392 char buffer[1024];
01393
01394 cablingFile.getline(buffer,1024);
01395 while(!cablingFile.eof()) {
01396 std::string line(buffer);
01397 size_t pos = line.find("dcuid");
01398
01399 if(pos != std::string::npos) {
01400
01401 std::string dcuids = line.substr(pos+7,line.find(" ",pos)-pos-8);
01402 std::istringstream dcuidstr(dcuids);
01403 dcuidstr >> std::hex >> dcuid;
01404
01405 pos = line.find("difpll");
01406 std::string diffs = line.substr(pos+8,line.find(" ",pos)-pos-9);
01407 std::istringstream diffstr(diffs);
01408 diffstr >> delay;
01409
01410 delayMap[dcuid] = delay;
01411 }
01412
01413 cablingFile.getline(buffer,1024);
01414 }
01415 } else {
01416 edm::LogWarning("BadConfig") << " The delay file does not exist. The delay map will not be filled properly."
01417 << std::endl << " Looking for " << file->c_str() << "."
01418 << std::endl << " Please specify valid filenames through the DelayFileNames untracked parameter.";
01419 }
01420 }
01421 return delayMap;
01422 }
01423
01424
01425 DEFINE_FWK_MODULE(TrackerDpgAnalysis);