00001 #include "Validation/CSCRecHits/src/CSCRecHit2DValidation.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
00004 #include "DQMServices/Core/interface/DQMStore.h"
00005
00006
00007
00008 CSCRecHit2DValidation::CSCRecHit2DValidation(DQMStore* dbe, const edm::InputTag & inputTag)
00009 : CSCBaseValidation(dbe, inputTag),
00010 theNPerEventPlot( dbe_->book1D("CSCRecHitsPerEvent", "Number of CSC Rec Hits per event", 100, 0, 500) )
00011 {
00012 dbe_->setCurrentFolder("CSCRecHitsV/CSCRecHitTask");
00013
00014 for(int i = 0; i < 10; ++i)
00015 {
00016 char title1[200], title2[200], title3[200], title4[200], title5[200], title6[200], title7[200], title8[200], title9[200];
00017 sprintf(title1, "CSCRecHitResolution%d", i+1);
00018 sprintf(title2, "CSCRecHitPull%d", i+1);
00019 sprintf(title3, "CSCRecHitYResolution%d", i+1);
00020 sprintf(title4, "CSCRecHitYPull%d", i+1);
00021 sprintf(title5, "CSCRecHitPosInStrip%d", i+1);
00022 sprintf(title6, "CSCSimHitPosInStrip%d", i+1);
00023 sprintf(title7, "CSCRecHit%d", i+1);
00024 sprintf(title8, "CSCSimHit%d", i+1);
00025 sprintf(title9, "CSCTPeak%d", i+1);
00026
00027
00028 theResolutionPlots[i] = dbe_->book1D(title1, title1, 100, -0.2, 0.2);
00029 thePullPlots[i] = dbe_->book1D(title2, title2, 100, -3, 3);
00030 theYResolutionPlots[i] = dbe_->book1D(title3, title3, 100, -5, 5);
00031 theYPullPlots[i] = dbe_->book1D(title4, title4, 100, -3, 3);
00032 theRecHitPosInStrip[i] = dbe_->book1D(title5, title5, 100, -2, 2);
00033 theSimHitPosInStrip[i] = dbe_->book1D(title6, title6, 100, -2, 2);
00034 theScatterPlots[i] = dbe->book2D(title7, title7, 200, -20, 20, 200, -250, 250);
00035 theSimHitScatterPlots[i] = dbe->book2D(title8, title8, 200, -20, 20, 200, -250, 250);
00036 theTPeaks[i] = dbe->book1D(title9, title9, 200, 0, 400);
00037 }
00038
00039 }
00040
00041 CSCRecHit2DValidation::~CSCRecHit2DValidation()
00042 {
00043 for(int i = 0; i < 10; ++i)
00044 {
00045 edm::LogInfo("CSCRecHitValidation") << "Resolution of " << theResolutionPlots[i]->getName() << " is " << theResolutionPlots[i]->getRMS();
00046 edm::LogInfo("CSCRecHitValidation") << "Peak Time is " << theTPeaks[i]->getMean();
00047 }
00048 }
00049
00050
00051 void CSCRecHit2DValidation::analyze(const edm::Event&e, const edm::EventSetup& eventSetup)
00052 {
00053
00054 edm::Handle<CSCRecHit2DCollection> hRecHits;
00055 e.getByLabel(theInputTag, hRecHits);
00056 const CSCRecHit2DCollection * cscRecHits = hRecHits.product();
00057
00058 unsigned nPerEvent = 0;
00059
00060 for(CSCRecHit2DCollection::const_iterator recHitItr = cscRecHits->begin();
00061 recHitItr != cscRecHits->end(); recHitItr++)
00062 {
00063 ++nPerEvent;
00064 int detId = (*recHitItr).cscDetId().rawId();
00065 edm::PSimHitContainer simHits = theSimHitMap->hits(detId);
00066 const CSCLayer * layer = findLayer(detId);
00067 int chamberType = layer->chamber()->specs()->chamberType();
00068 theTPeaks[chamberType-1]->Fill(recHitItr->tpeak());
00069 if(simHits.size() == 1)
00070 {
00071 plotResolution(simHits[0], *recHitItr, layer, chamberType);
00072 }
00073 float localX = recHitItr->localPosition().x();
00074 float localY = recHitItr->localPosition().y();
00075
00076
00077 float globalR = layer->toGlobal(LocalPoint(0.,0.,0.)).perp();
00078 GlobalPoint axisThruChamber(globalR+localY, localX, 0.);
00079 float localPhi = axisThruChamber.phi().degrees();
00080
00081 theScatterPlots[chamberType-1]->Fill( localPhi, localY);
00082 }
00083 theNPerEventPlot->Fill(nPerEvent);
00084 return;
00085
00086 std::vector<int> layersWithSimHits = theSimHitMap->detsWithHits();
00087 for(unsigned i = 0; i < layersWithSimHits.size(); ++i)
00088 {
00089 edm::PSimHitContainer simHits = theSimHitMap->hits(layersWithSimHits[i]);
00090 for(edm::PSimHitContainer::const_iterator hitItr = simHits.begin(); hitItr != simHits.end(); ++hitItr)
00091 {
00092 const CSCLayer * layer = findLayer(layersWithSimHits[i]);
00093 int chamberType = layer->chamber()->specs()->chamberType();
00094 float localX = hitItr->localPosition().x();
00095 float localY = hitItr->localPosition().y();
00096
00097
00098 float globalR = layer->toGlobal(LocalPoint(0.,0.,0.)).perp();
00099 GlobalPoint axisThruChamber(globalR+localY, localX, 0.);
00100 float localPhi = axisThruChamber.phi().degrees();
00101
00102 theSimHitScatterPlots[chamberType-1]->Fill( localPhi, localY);
00103 }
00104 }
00105
00106 }
00107
00108
00109 void CSCRecHit2DValidation::plotResolution(const PSimHit & simHit, const CSCRecHit2D & recHit,
00110 const CSCLayer * layer, int chamberType)
00111 {
00112 GlobalPoint simHitPos = layer->toGlobal(simHit.localPosition());
00113 GlobalPoint recHitPos = layer->toGlobal(recHit.localPosition());
00114
00115 double dphi = recHitPos.phi() - simHitPos.phi();
00116 double rdphi = recHitPos.perp() * dphi;
00117 theResolutionPlots[chamberType-1]->Fill( rdphi );
00118 thePullPlots[chamberType-1]->Fill( rdphi/ sqrt(recHit.localPositionError().xx()) );
00119 double dy = recHit.localPosition().y() - simHit.localPosition().y();
00120 theYResolutionPlots[chamberType-1]->Fill( dy );
00121 theYPullPlots[chamberType-1]->Fill( dy/ sqrt(recHit.localPositionError().yy()) );
00122
00123 const CSCLayerGeometry * layerGeometry = layer->geometry();
00124 float recStrip = layerGeometry->strip(recHit.localPosition());
00125 float simStrip = layerGeometry->strip(simHit.localPosition());
00126 theRecHitPosInStrip[chamberType-1]->Fill( recStrip - int(recStrip) );
00127 theSimHitPosInStrip[chamberType-1]->Fill( simStrip - int(simStrip) );
00128 }
00129