00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00020 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
00021 #include "DQM/SiPixelMonitorClient/interface/SiPixelMuonHLT.h"
00022 #include <string>
00023 #include <stdlib.h>
00024
00025 SiPixelMuonHLT::SiPixelMuonHLT(const edm::ParameterSet& iConfig) :
00026 conf_(iConfig)
00027 {
00028
00029 parameters_ = iConfig;
00030
00031 verbose_ = parameters_.getUntrackedParameter < bool > ("verbose", false);
00032 monitorName_ = parameters_.getUntrackedParameter < std::string > ("monitorName", "HLT/HLTMonMuon");
00033 saveOUTput_ = parameters_.getUntrackedParameter < bool > ("saveOUTput", true);
00034
00035
00036 clusterCollectionTag_ = parameters_.getUntrackedParameter < edm::InputTag > ("clusterCollectionTag", edm::InputTag ("hltSiPixelClusters"));
00037 rechitsCollectionTag_ = parameters_.getUntrackedParameter < edm::InputTag > ("rechitsCollectionTag", edm::InputTag ("hltSiPixelRecHits"));
00038 l3MuonCollectionTag_ = parameters_.getUntrackedParameter < edm::InputTag > ("l3MuonCollectionTag", edm::InputTag ("hltL3MuonCandidates"));
00040
00041 theDMBE = edm::Service<DQMStore>().operator->();
00042 edm::LogInfo ("PixelHLTDQM") << "SiPixelMuonHLT::SiPixelMuonHLT: Got DQM BackEnd interface"<<std::endl;
00043 outputFile_ = parameters_.getUntrackedParameter < std::string > ("outputFile", "");
00044 if (outputFile_.size () != 0)
00045 edm::LogWarning ("HLTMuonDQMSource") << "Muon HLT Monitoring histograms will be saved to " << outputFile_ << std::endl;
00046 else
00047 outputFile_ = "PixelHLTDQM.root";
00049 if (theDMBE != NULL) theDMBE->setCurrentFolder (monitorName_);
00050 SiPixelMuonHLT::Histo_init();
00051
00052 }
00053
00054 SiPixelMuonHLT::~SiPixelMuonHLT()
00055 {
00056
00057
00058 edm::LogInfo ("PixelHLTDQM") << "SiPixelMuonHLT::~SiPixelMuonHLT: Destructor"<<std::endl;
00059
00060 }
00061
00062 void SiPixelMuonHLT::beginJob(){
00063
00064 edm::LogInfo ("PixelHLTDQM") << " SiPixelMuonHLT::beginJob - Initialisation ... " << std::endl;
00065 eventNo = 0;
00066
00067 }
00068
00069
00070 void SiPixelMuonHLT::endJob(void){
00071 if(saveOUTput_){
00072 edm::LogInfo ("PixelHLTDQM") << " SiPixelMuonHLT::endJob - Saving Root File " << std::endl;
00073 theDMBE->save( outputFile_.c_str() );
00074 }
00075 }
00076
00077
00078
00079
00080 void SiPixelMuonHLT::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00081 {
00082
00083 edm::ESHandle<TrackerTopology> tTopoHandle;
00084 iSetup.get<IdealGeometryRecord>().get(tTopoHandle);
00085 const TrackerTopology* const tTopo = tTopoHandle.product();
00086
00087
00088 eventNo++;
00089
00090 edm::ESHandle < TrackerGeometry > TG;
00091 iSetup.get < TrackerDigiGeometryRecord > ().get (TG);
00092 const TrackerGeometry *theTrackerGeometry = TG.product ();
00093 const TrackerGeometry & theTracker (*theTrackerGeometry);
00094 edm::Handle < reco::RecoChargedCandidateCollection > l3mucands;
00095 reco::RecoChargedCandidateCollection::const_iterator cand;
00096 edm::Handle <edmNew::DetSetVector<SiPixelCluster> > clusters;
00097 edm::Handle <edmNew::DetSetVector<SiPixelRecHit> > rechits;
00098
00099 bool GotClusters = true;
00100 bool GotRecHits = true;
00101 bool GotL3Muons = true;
00102
00103 iEvent.getByLabel("hltSiPixelClusters", clusters);
00104 if(!clusters.isValid()){
00105 edm::LogInfo("PixelHLTDQM") << "No pix clusters, cannot run for event " << iEvent.eventAuxiliary ().event() <<" run: "<<iEvent.eventAuxiliary ().run() << std::endl;
00106 GotClusters = false;
00107 }
00108 iEvent.getByLabel("hltSiPixelRecHits", rechits);
00109 if(!rechits.isValid()){
00110 edm::LogInfo("PixelHLTDQM") << "No pix rechits, cannot run for event " << iEvent.eventAuxiliary ().event() <<" run: "<<iEvent.eventAuxiliary ().run() << std::endl;
00111 GotRecHits = false;
00112 }
00113 iEvent.getByLabel (l3MuonCollectionTag_, l3mucands);
00114 if(!l3mucands.isValid()){
00115 edm::LogInfo("PixelHLTDQM") << "No L3 Muons, cannot run for event " << iEvent.eventAuxiliary ().event() <<" run: "<<iEvent.eventAuxiliary ().run() << std::endl;
00116 GotL3Muons = false;
00117 }
00118
00119 if (GotClusters){
00120 if(!clusters.failedToGet ())
00121 {
00122 int NBarrel[4] = {0,0,0,0};
00123 int NEndcap[5] = {0,0,0,0,0};
00124 for (size_t i = 0; i < clusters->size(); ++i){
00125 const SiPixelCluster* clust = clusters->data(i);
00126 clust->charge();
00128 uint detID = clusters->id(i);
00129 const PixelGeomDetUnit *PixGeom = dynamic_cast < const PixelGeomDetUnit * >(theTracker.idToDet (detID));
00130 const PixelTopology *topol = dynamic_cast < const PixelTopology * >(&(PixGeom->specificTopology ()));
00131
00132 LocalPoint clustlp = topol->localPosition (MeasurementPoint(clust->x(),clust->y()));
00133 GlobalPoint clustgp = PixGeom->surface ().toGlobal (clustlp);
00134 if(PixGeom->geographicalId().subdetId() == 1){
00135 int clustLay = tTopo->pxbLayer(detID);
00136
00137 MEContainerAllBarrelEtaPhi[0]->Fill(clustgp.eta(),clustgp.phi());
00138 MEContainerAllBarrelZPhi[0]->Fill(clustgp.z(),clustgp.phi());
00139 MEContainerAllBarrelEtaPhi[clustLay]->Fill(clustgp.eta(),clustgp.phi());
00140 MEContainerAllBarrelZPhi[clustLay]->Fill(clustgp.z(),clustgp.phi());
00141
00142 MEContainerAllBarrelEta[0]->Fill(clustgp.eta());
00143 MEContainerAllBarrelZ[0]->Fill(clustgp.z());
00144 MEContainerAllBarrelEta[clustLay]->Fill(clustgp.eta());
00145 MEContainerAllBarrelZ[clustLay]->Fill(clustgp.z());
00146
00147 MEContainerAllBarrelPhi[0]->Fill(clustgp.phi());
00148 MEContainerAllBarrelPhi[clustLay]->Fill(clustgp.phi());
00149 ++NBarrel[0];
00150 ++NBarrel[clustLay];
00151 }
00153 if(PixGeom->geographicalId().subdetId() == 2){
00154 int clustDisk = tTopo->pxfDisk(detID);
00155 if( tTopo->pxfSide(detID) == 2)
00156 clustDisk = clustDisk +2;
00157 MEContainerAllEndcapXY[0]->Fill(clustgp.x(),clustgp.y());
00158 MEContainerAllEndcapXY[clustDisk]->Fill(clustgp.x(),clustgp.y());
00159 MEContainerAllEndcapPhi[0]->Fill(clustgp.phi());
00160 MEContainerAllEndcapPhi[clustDisk]->Fill(clustgp.phi());
00161 ++NEndcap[0];
00162 ++NEndcap[clustDisk];
00163 }
00164
00165 }
00166 MEContainerAllBarrelN[0]->Fill(NBarrel[0]);
00167 for (int lay = 1; lay < 4; ++lay)
00168 MEContainerAllBarrelN[lay]->Fill(NBarrel[lay]);
00169 MEContainerAllEndcapN[0]->Fill(NEndcap[0]);
00170 for (int disk = 1; disk < 5; ++disk)
00171 MEContainerAllEndcapN[disk]->Fill(NEndcap[disk]);
00172 }
00173 }
00174 bool doRecHits = false;
00175
00176 if (GotRecHits && doRecHits){
00177 if(!rechits.failedToGet ())
00178 {
00179 for (size_t i = 0; i < rechits->size(); ++i){
00180 const SiPixelRecHit* myhit = rechits->data(i);
00181 uint detID = rechits->id(i);
00182 const PixelGeomDetUnit *PixGeom = dynamic_cast < const PixelGeomDetUnit * >(theTracker.idToDet (detID));
00183
00184
00185
00186
00187 if(PixGeom->geographicalId().subdetId() == 1 && myhit->hasPositionAndError()){
00188 GlobalPoint hitgp = PixGeom->surface ().toGlobal (myhit->localPosition());
00189 edm::LogInfo("PixelHLTDQM") << " (From SiPixelRecHit) Hit Eta: " << hitgp.eta() << " Hit Phi: " << hitgp.phi() << std::endl;
00190 }
00191 }
00192 }
00193 }
00194 if(GotL3Muons){
00195 if(!l3mucands.failedToGet ())
00196 {
00197 int NBarrel[4] = {0,0,0,0};
00198 int NEndcap[5] = {0,0,0,0,0};
00199 for (cand = l3mucands->begin (); cand != l3mucands->end (); ++cand){
00200 reco::TrackRef l3tk = cand->get < reco::TrackRef > ();
00201 for (size_t hit = 0; hit < l3tk->recHitsSize (); hit++){
00202 if (l3tk->recHit (hit)->isValid () == true && l3tk->recHit (hit)->geographicalId ().det () == DetId::Tracker){
00203 int detID = l3tk->recHit(hit)->geographicalId().rawId();
00204
00205 bool IdMatch = typeid(*(l3tk->recHit(hit))) == typeid(SiPixelRecHit);
00206 if (IdMatch){
00207 const SiPixelRecHit *pixhit = dynamic_cast < const SiPixelRecHit * >(l3tk->recHit(hit).get());
00208 if((*pixhit).isValid() == true){
00209 edm::Ref<edmNew::DetSetVector<SiPixelCluster>, SiPixelCluster> const& pixclust = (*pixhit).cluster();
00210 if (!(*pixhit).cluster().isAvailable())
00211 {continue;}
00212 const PixelGeomDetUnit *PixGeom = dynamic_cast < const PixelGeomDetUnit * >(theTracker.idToDet (detID));
00213 const PixelTopology *topol = dynamic_cast < const PixelTopology * >(&(PixGeom->specificTopology ()));
00214 LocalPoint clustlp = topol->localPosition (MeasurementPoint(pixclust->x(),pixclust->y()));
00215 GlobalPoint clustgp = PixGeom->surface ().toGlobal (clustlp);
00216 if(l3tk->recHit(hit)->geographicalId().subdetId() == 1){
00217
00218 int clustLay = tTopo->pxbLayer(detID);
00219 MEContainerOnTrackBarrelEtaPhi[0]->Fill(clustgp.eta(),clustgp.phi());
00220 MEContainerOnTrackBarrelZPhi[0]->Fill(clustgp.z(),clustgp.phi());
00221 MEContainerOnTrackBarrelEtaPhi[clustLay]->Fill(clustgp.eta(),clustgp.phi());
00222 MEContainerOnTrackBarrelZPhi[clustLay]->Fill(clustgp.z(),clustgp.phi());
00223 MEContainerOnTrackBarrelEta[0]->Fill(clustgp.eta());
00224 MEContainerOnTrackBarrelZ[0]->Fill(clustgp.z());
00225 MEContainerOnTrackBarrelEta[clustLay]->Fill(clustgp.eta());
00226 MEContainerOnTrackBarrelZ[clustLay]->Fill(clustgp.z());
00227 MEContainerOnTrackBarrelPhi[0]->Fill(clustgp.phi());
00228 MEContainerOnTrackBarrelPhi[clustLay]->Fill(clustgp.phi());
00229 ++NBarrel[0];
00230 ++NBarrel[clustLay];
00231 }
00232 if(l3tk->recHit(hit)->geographicalId().subdetId() == 2){
00233 int clustDisk = tTopo->pxfDisk(detID);
00234 if( tTopo->pxfDisk(detID) == 2)
00235 clustDisk = clustDisk +2;
00236 MEContainerOnTrackEndcapXY[0]->Fill(clustgp.x(),clustgp.y());
00237 MEContainerOnTrackEndcapXY[clustDisk]->Fill(clustgp.x(),clustgp.y());
00238 MEContainerOnTrackEndcapPhi[0]->Fill(clustgp.phi());
00239 MEContainerOnTrackEndcapPhi[clustDisk]->Fill(clustgp.phi());
00240 ++NEndcap[0];
00241 ++NEndcap[clustDisk];
00242 }
00243 }
00244 }
00245 }
00246 }
00247 }
00248 MEContainerOnTrackBarrelN[0]->Fill(NBarrel[0]);
00249 for (int lay = 1; lay < 4; ++lay)
00250 MEContainerOnTrackBarrelN[lay]->Fill(NBarrel[lay]);
00251 MEContainerOnTrackEndcapN[0]->Fill(NEndcap[0]);
00252 for (int disk = 1; disk < 5; ++disk)
00253 MEContainerOnTrackEndcapN[disk]->Fill(NEndcap[disk]);
00254
00255 }
00256 }
00257 }
00258
00259 void SiPixelMuonHLT::Histo_init()
00260 {
00261 monitorName_ = monitorName_+"/SiPixel";
00262 int NBinsEta = 100;
00263 int NBinsPhi = 80;
00264 float EtaMax = 3.0;
00265 float ZMax = 28.0;
00266 int NBinsZ = 112;
00267 float PhiMax = 3.142;
00268 int NBinsN = 800;
00269 float NMax = 800.;
00270 int NBinsX = 100;
00271 int NBinsY = 100;
00272 float XMax = 20.;
00273 float YMax = 20.;
00274 std::string histoname;
00275 std::string title;
00276
00277 theDMBE->setCurrentFolder (monitorName_ + "/Barrel");
00278 std::string layerLabel[4] = {"All_Layers", "Layer1", "Layer2", "Layer3"};
00279 for (unsigned int i = 0; i < 4; i++)
00280 {
00283
00284 histoname = "EtaPhiAllBarrelMap_" + layerLabel[i];
00285 title = "#eta-#phi Pixel Barrel Cluster Occupancy Map for " + layerLabel[i];
00286 MEContainerAllBarrelEtaPhi[i] = theDMBE->book2D (histoname, title, NBinsEta, -EtaMax, EtaMax, NBinsPhi, -PhiMax, PhiMax);
00287
00288 histoname = "ZPhiAllBarrelMap_" + layerLabel[i];
00289 title = "Z-#phi Pixel Barrel Cluster Occupancy Map for " + layerLabel[i];
00290 MEContainerAllBarrelZPhi[i] = theDMBE->book2D (histoname, title, NBinsZ, -ZMax, ZMax, NBinsPhi, -PhiMax, PhiMax);
00291
00292 histoname = "EtaAllBarrelMap_" + layerLabel[i];
00293 title = "#eta Pixel Barrel Cluster Occupancy Map for " + layerLabel[i];
00294 MEContainerAllBarrelEta[i] = theDMBE->book1D (histoname, title, NBinsEta, -EtaMax, EtaMax);
00295
00296 histoname = "ZAllBarrelMap_" + layerLabel[i];
00297 title = "Z Pixel Barrel Cluster Occupancy Map for " + layerLabel[i];
00298 MEContainerAllBarrelZ[i] = theDMBE->book1D (histoname, title, NBinsZ, -ZMax, ZMax);
00299
00300 histoname = "PhiAllBarrelMap_" + layerLabel[i];
00301 title = "#phi Pixel Barrel Cluster Occupancy Map for " + layerLabel[i];
00302 MEContainerAllBarrelPhi[i] = theDMBE->book1D (histoname, title, NBinsPhi, -PhiMax, PhiMax);
00303
00304 histoname = "NAllBarrelMap_" + layerLabel[i];
00305 title = "#phi Pixel Barrel Cluster Occupancy Map for " + layerLabel[i];
00306 MEContainerAllBarrelN[i] = theDMBE->book1D (histoname, title, NBinsN, 0, NMax);
00309
00310 histoname = "EtaPhiOnTrackBarrelMap_" + layerLabel[i];
00311 title = "#eta-#phi On Track Pixel Barrel Cluster Occupancy Map for " + layerLabel[i];
00312 MEContainerOnTrackBarrelEtaPhi[i] = theDMBE->book2D (histoname, title, NBinsEta, -EtaMax, EtaMax, NBinsPhi, -PhiMax, PhiMax);
00313
00314 histoname = "ZPhiOnTrackBarrelMap_" + layerLabel[i];
00315 title = "Z-#phi On Track Pixel Barrel Cluster Occupancy Map for " + layerLabel[i];
00316 MEContainerOnTrackBarrelZPhi[i] = theDMBE->book2D (histoname, title, NBinsZ, -ZMax, ZMax, NBinsPhi, -PhiMax, PhiMax);
00317
00318 histoname = "EtaOnTrackBarrelMap_" + layerLabel[i];
00319 title = "#eta On Track Pixel Barrel Cluster Occupancy Map for " + layerLabel[i];
00320 MEContainerOnTrackBarrelEta[i] = theDMBE->book1D (histoname, title, NBinsEta, -EtaMax, EtaMax);
00321
00322 histoname = "ZOnTrackBarrelMap_" + layerLabel[i];
00323 title = "Z On Track Pixel Barrel Cluster Occupancy Map for " + layerLabel[i];
00324 MEContainerOnTrackBarrelZ[i] = theDMBE->book1D (histoname, title, NBinsZ, -ZMax, ZMax);
00325
00326 histoname = "PhiOnTrackBarrelMap_" + layerLabel[i];
00327 title = "#phi On Track Pixel Barrel Cluster Occupancy Map for " + layerLabel[i];
00328 MEContainerOnTrackBarrelPhi[i] = theDMBE->book1D (histoname, title, NBinsPhi, -PhiMax, PhiMax);
00329
00330 histoname = "NOnTrackBarrelMap_" + layerLabel[i];
00331 title = "N_{Clusters} On Track Pixel Barrel Cluster Occupancy Map for " + layerLabel[i];
00332 MEContainerOnTrackBarrelN[i] = theDMBE->book1D (histoname, title, NBinsN, 0, NMax);
00333 }
00334
00335 theDMBE->setCurrentFolder (monitorName_ + "/EndCap");
00336 std::string diskLabel[5] = {"All_Disks", "InnerPosZ", "OuterPosZ", "InnerNegZ", "OuterNegZ"};
00337 for (int i = 0;i < 5; ++i)
00338 {
00341
00342 histoname = "XYAllEndcapMap_" + diskLabel[i];
00343 title = "X-Y Pixel Endcap Cluster Occupancy Map for " + diskLabel[i];
00344 MEContainerAllEndcapXY[i] = theDMBE->book2D (histoname, title, NBinsX, -XMax, XMax, NBinsY, -YMax, YMax);
00345
00346 histoname = "PhiAllEndcapMap_" + diskLabel[i];
00347 title = "#phi Pixel Endcap Cluster Occupancy Map for " + diskLabel[i];
00348 MEContainerAllEndcapPhi[i] = theDMBE->book1D (histoname, title, NBinsPhi, -PhiMax, PhiMax);
00349
00350 histoname = "NAllEndcapMap_" + diskLabel[i];
00351 title = "#phi Pixel Endcap Cluster Occupancy Map for " + diskLabel[i];
00352 MEContainerAllEndcapN[i] = theDMBE->book1D (histoname, title, NBinsN, 0, NMax);
00355
00356 histoname = "XYOnTrackEndcapMap_" + diskLabel[i];
00357 title = "X-Y Pixel Endcap On Track Cluster Occupancy Map for " + diskLabel[i];
00358 MEContainerOnTrackEndcapXY[i] = theDMBE->book2D (histoname, title, NBinsX, -XMax, XMax, NBinsY, -YMax, YMax);
00359
00360 histoname = "PhiOnTrackEndcapMap_" + diskLabel[i];
00361 title = "#phi Pixel Endcap On Track Cluster Occupancy Map for " + diskLabel[i];
00362 MEContainerOnTrackEndcapPhi[i] = theDMBE->book1D (histoname, title, NBinsPhi, -PhiMax, PhiMax);
00363
00364 histoname = "NOnTrackEndcapMap_" + diskLabel[i];
00365 title = "#phi Pixel Endcap On Track Cluster Occupancy Map for " + diskLabel[i];
00366 MEContainerOnTrackEndcapN[i] = theDMBE->book1D (histoname, title, NBinsN, 0, NMax);
00367 }
00368 return;
00369 }
00370
00371
00372 DEFINE_FWK_MODULE(SiPixelMuonHLT);