00001
00002
00003
00004
00005
00006
00007
00008 #include "RecoLocalMuon/CSCValidation/src/CSCValidation.h"
00009
00010 using namespace std;
00011 using namespace edm;
00012
00013
00015
00017 CSCValidation::CSCValidation(const ParameterSet& pset){
00018
00019
00020 rootFileName = pset.getUntrackedParameter<string>("rootFileName","valHists.root");
00021 isSimulation = pset.getUntrackedParameter<bool>("isSimulation",false);
00022 writeTreeToFile = pset.getUntrackedParameter<bool>("writeTreeToFile",true);
00023 detailedAnalysis = pset.getUntrackedParameter<bool>("detailedAnalysis",false);
00024 useDigis = pset.getUntrackedParameter<bool>("useDigis",true);
00025 useTrigger = pset.getUntrackedParameter<bool>("useTrigger",false);
00026
00027
00028 stripDigiTag = pset.getParameter<edm::InputTag>("stripDigiTag");
00029 wireDigiTag = pset.getParameter<edm::InputTag>("wireDigiTag");
00030 compDigiTag = pset.getParameter<edm::InputTag>("compDigiTag");
00031 cscRecHitTag = pset.getParameter<edm::InputTag>("cscRecHitTag");
00032 cscSegTag = pset.getParameter<edm::InputTag>("cscSegTag");
00033 saMuonTag = pset.getParameter<edm::InputTag>("saMuonTag");
00034 l1aTag = pset.getParameter<edm::InputTag>("l1aTag");
00035 simHitTag = pset.getParameter<edm::InputTag>("simHitTag");
00036
00037
00038 makeOccupancyPlots = pset.getUntrackedParameter<bool>("makeOccupancyPlots",true);
00039 makeStripPlots = pset.getUntrackedParameter<bool>("makeStripPlots",true);
00040 makeWirePlots = pset.getUntrackedParameter<bool>("makeWirePlots",true);
00041 makeRecHitPlots = pset.getUntrackedParameter<bool>("makeRecHitPlots",true);
00042 makeSimHitPlots = pset.getUntrackedParameter<bool>("makeSimHitPlots",true);
00043 makeSegmentPlots = pset.getUntrackedParameter<bool>("makeSegmentPlots",true);
00044 makePedNoisePlots = pset.getUntrackedParameter<bool>("makePedNoisePlots",true);
00045 makeEfficiencyPlots = pset.getUntrackedParameter<bool>("makeEfficiencyPlots",true);
00046 makeGasGainPlots = pset.getUntrackedParameter<bool>("makeGasGainPlots",true);
00047 makeAFEBTimingPlots = pset.getUntrackedParameter<bool>("makeAFEBTimingPlots",true);
00048 makeCompTimingPlots = pset.getUntrackedParameter<bool>("makeCompTimingPlots",true);
00049 makeADCTimingPlots = pset.getUntrackedParameter<bool>("makeADCTimingPlots",true);
00050 makeRHNoisePlots = pset.getUntrackedParameter<bool>("makeRHNoisePlots",false);
00051 makeCalibPlots = pset.getUntrackedParameter<bool>("makeCalibPlots",false);
00052 makeTriggerPlots = pset.getUntrackedParameter<bool>("makeTriggerPlots",false);
00053 makeStandalonePlots = pset.getUntrackedParameter<bool>("makeStandalonePlots",false);
00054
00055
00056 nEventsAnalyzed = 0;
00057 rhTreeCount = 0;
00058 segTreeCount = 0;
00059
00060
00061 theFile = new TFile(rootFileName.c_str(), "RECREATE");
00062 theFile->cd();
00063
00064
00065 histos = new CSCValHists();
00066
00067
00068 hOWires = new TH2I("hOWires","Wire Digi Occupancy",36,0.5,36.5,20,0.5,20.5);
00069 hOStrips = new TH2I("hOStrips","Strip Digi Occupancy",36,0.5,36.5,20,0.5,20.5);
00070 hORecHits = new TH2I("hORecHits","RecHit Occupancy",36,0.5,36.5,20,0.5,20.5);
00071 hOSegments = new TH2I("hOSegments","Segments Occupancy",36,0.5,36.5,20,0.5,20.5);
00072
00073
00074 hSSTE = new TH1F("hSSTE","hSSTE",40,0,40);
00075 hRHSTE = new TH1F("hRHSTE","hRHSTE",40,0,40);
00076 hSEff = new TH1F("hSEff","Segment Efficiency",20,0.5,20.5);
00077 hRHEff = new TH1F("hRHEff","recHit Efficiency",20,0.5,20.5);
00078
00079 const int nChambers = 36;
00080 const int nTypes = 18;
00081 float nCH_min = 0.5;
00082 float nCh_max = float(nChambers) + 0.5;
00083 float nT_min = 0.5;
00084 float nT_max = float(nTypes) + 0.5;
00085
00086 hSSTE2 = new TH2F("hSSTE2","hSSTE2",nChambers,nCH_min,nCh_max, nTypes, nT_min, nT_max);
00087 hRHSTE2 = new TH2F("hRHSTE2","hRHSTE2",nChambers,nCH_min,nCh_max, nTypes, nT_min, nT_max);
00088 hStripSTE2 = new TH2F("hStripSTE2","hStripSTE2",nChambers,nCH_min,nCh_max, nTypes, nT_min, nT_max);
00089 hWireSTE2 = new TH2F("hWireSTE2","hWireSTE2",nChambers,nCH_min,nCh_max, nTypes, nT_min, nT_max);
00090
00091
00092 hEffDenominator = new TH2F("hEffDenominator","hEffDenominator",nChambers,nCH_min,nCh_max, nTypes, nT_min, nT_max);
00093 hSEff2 = new TH2F("hSEff2","Segment Efficiency 2D",nChambers,nCH_min,nCh_max, nTypes, nT_min, nT_max);
00094 hRHEff2 = new TH2F("hRHEff2","recHit Efficiency 2D",nChambers,nCH_min,nCh_max, nTypes, nT_min, nT_max);
00095
00096 hStripEff2 = new TH2F("hStripEff2","strip Efficiency 2D",nChambers,nCH_min,nCh_max, nTypes, nT_min, nT_max);
00097 hWireEff2 = new TH2F("hWireEff2","wire Efficiency 2D",nChambers,nCH_min,nCh_max, nTypes, nT_min, nT_max);
00098
00099 hSensitiveAreaEvt = new TH2F("hSensitiveAreaEvt","events in sensitive area",nChambers,nCH_min,nCh_max, nTypes, nT_min, nT_max);
00100
00101
00102 if (writeTreeToFile) histos->setupTrees();
00103
00104
00105 }
00106
00108
00110 CSCValidation::~CSCValidation(){
00111
00112
00113 histoEfficiency(hRHSTE,hRHEff);
00114 histoEfficiency(hSSTE,hSEff);
00115 hSEff2->Divide(hSSTE2,hEffDenominator,1.,1.,"B");
00116 hRHEff2->Divide(hRHSTE2,hEffDenominator,1.,1.,"B");
00117 hStripEff2->Divide(hStripSTE2,hEffDenominator,1.,1.,"B");
00118 hWireEff2->Divide(hWireSTE2,hEffDenominator,1.,1.,"B");
00119
00120 histos->insertPlot(hSEff,"hSEff","Efficiency");
00121 histos->insertPlot(hRHEff,"hRHEff","Efficiency");
00122
00123 histos->insertPlot(hSEff2,"hSEff2","Efficiency");
00124 histos->insertPlot(hRHEff2,"hRHEff2","Efficiency");
00125 histos->insertPlot(hStripEff2,"hStripff2","Efficiency");
00126 histos->insertPlot(hWireEff2,"hWireff2","Efficiency");
00127
00128 histos->insertPlot(hSensitiveAreaEvt,"","Efficiency");
00129
00130
00131 histos->insertPlot(hOWires,"hOWires","Digis");
00132 histos->insertPlot(hOStrips,"hOStrips","Digis");
00133 histos->insertPlot(hORecHits,"hORecHits","recHits");
00134 histos->insertPlot(hOSegments,"hOSegments","Segments");
00135
00136
00137
00138 histos->writeHists(theFile);
00139 if (writeTreeToFile) histos->writeTrees(theFile);
00140 theFile->Close();
00141
00142 }
00143
00145
00147 void CSCValidation::analyze(const Event & event, const EventSetup& eventSetup){
00148
00149
00150 nEventsAnalyzed++;
00151
00152
00153
00154
00155
00156 edm::Handle<CSCWireDigiCollection> wires;
00157 edm::Handle<CSCStripDigiCollection> strips;
00158 edm::Handle<CSCComparatorDigiCollection> compars;
00159 if (useDigis){
00160 event.getByLabel(stripDigiTag,strips);
00161 event.getByLabel(wireDigiTag,wires);
00162 event.getByLabel(compDigiTag,compars);
00163 }
00164
00165
00166 ESHandle<CSCGeometry> cscGeom;
00167 eventSetup.get<MuonGeometryRecord>().get(cscGeom);
00168
00169
00170 Handle<CSCRecHit2DCollection> recHits;
00171 event.getByLabel(cscRecHitTag,recHits);
00172
00173
00174 Handle<PSimHitContainer> simHits;
00175 if (isSimulation) event.getByLabel(simHitTag, simHits);
00176
00177
00178 Handle<CSCSegmentCollection> cscSegments;
00179 event.getByLabel(cscSegTag, cscSegments);
00180
00181
00182 edm::Handle<L1MuGMTReadoutCollection> pCollection;
00183 if (makeTriggerPlots){
00184 event.getByLabel(l1aTag,pCollection);
00185 }
00186
00187
00188 Handle<reco::TrackCollection> saMuons;
00189 if (makeStandalonePlots) event.getByLabel(saMuonTag,saMuons);
00190
00191
00192
00194
00196
00197
00198 if (nEventsAnalyzed == 1 && makeCalibPlots) doCalibrations(eventSetup);
00199
00200
00201 bool CSCL1A = false;
00202 if (makeTriggerPlots) CSCL1A = doTrigger(pCollection);
00203
00204
00205 if (makeOccupancyPlots) doOccupancies(strips,wires,recHits,cscSegments);
00206
00207
00208 if (makeStripPlots && useDigis) doStripDigis(strips);
00209
00210
00211 if (makeWirePlots && useDigis) doWireDigis(wires);
00212
00213
00214 if (makeRecHitPlots) doRecHits(recHits,strips,cscGeom);
00215
00216
00217 if (isSimulation && makeSimHitPlots) doSimHits(recHits,simHits);
00218
00219
00220 if (makeSegmentPlots) doSegments(cscSegments,cscGeom);
00221
00222
00223 if (makePedNoisePlots && useDigis) doPedestalNoise(strips);
00224
00225
00226 if (makeEfficiencyPlots) doEfficiencies(wires,strips, recHits, cscSegments,cscGeom);
00227
00228
00229 if (makeGasGainPlots && useDigis) doGasGain(*wires,*strips,*recHits);
00230
00231
00232 if (makeAFEBTimingPlots && useDigis) doAFEBTiming(*wires);
00233
00234
00235 if (makeCompTimingPlots && useDigis) doCompTiming(*compars);
00236
00237
00238 if (makeADCTimingPlots && useDigis) doADCTiming(*strips,*recHits);
00239
00240
00241 if (makeRHNoisePlots && useDigis) doNoiseHits(recHits,cscSegments,cscGeom,strips);
00242
00243
00244 if (makeStandalonePlots) doStandalone(saMuons);
00245
00246 }
00247
00248
00249
00250
00251
00252
00253
00254 void CSCValidation::doOccupancies(edm::Handle<CSCStripDigiCollection> strips, edm::Handle<CSCWireDigiCollection> wires,
00255 edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<CSCSegmentCollection> cscSegments){
00256
00257 bool wireo[2][4][4][36];
00258 bool stripo[2][4][4][36];
00259 bool rechito[2][4][4][36];
00260 bool segmento[2][4][4][36];
00261
00262 bool hasWires = false;
00263 bool hasStrips = false;
00264 bool hasRecHits = false;
00265 bool hasSegments = false;
00266
00267 for (int e = 0; e < 2; e++){
00268 for (int s = 0; s < 4; s++){
00269 for (int r = 0; r < 4; r++){
00270 for (int c = 0; c < 36; c++){
00271 wireo[e][s][r][c] = false;
00272 stripo[e][s][r][c] = false;
00273 rechito[e][s][r][c] = false;
00274 segmento[e][s][r][c] = false;
00275 }
00276 }
00277 }
00278 }
00279
00280 if (useDigis){
00281
00282 for (CSCWireDigiCollection::DigiRangeIterator wi=wires->begin(); wi!=wires->end(); wi++) {
00283 CSCDetId id = (CSCDetId)(*wi).first;
00284 int kEndcap = id.endcap();
00285 int kRing = id.ring();
00286 int kStation = id.station();
00287 int kChamber = id.chamber();
00288 std::vector<CSCWireDigi>::const_iterator wireIt = (*wi).second.first;
00289 std::vector<CSCWireDigi>::const_iterator lastWire = (*wi).second.second;
00290 for( ; wireIt != lastWire; ++wireIt){
00291 if (!wireo[kEndcap-1][kStation-1][kRing-1][kChamber-1]){
00292 wireo[kEndcap-1][kStation-1][kRing-1][kChamber-1] = true;
00293 hOWires->Fill(kChamber,typeIndex(id));
00294 histos->fill1DHist(chamberSerial(id),"hOWireSerial","Wire Occupancy by Chamber Serial",601,-0.5,600.5,"Digis");
00295 hasWires = true;
00296 }
00297 }
00298 }
00299
00300
00301 for (CSCStripDigiCollection::DigiRangeIterator si=strips->begin(); si!=strips->end(); si++) {
00302 CSCDetId id = (CSCDetId)(*si).first;
00303 int kEndcap = id.endcap();
00304 int kRing = id.ring();
00305 int kStation = id.station();
00306 int kChamber = id.chamber();
00307 std::vector<CSCStripDigi>::const_iterator stripIt = (*si).second.first;
00308 std::vector<CSCStripDigi>::const_iterator lastStrip = (*si).second.second;
00309 for( ; stripIt != lastStrip; ++stripIt) {
00310 std::vector<int> myADCVals = stripIt->getADCCounts();
00311 bool thisStripFired = false;
00312 float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
00313 float threshold = 13.3 ;
00314 float diff = 0.;
00315 for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
00316 diff = (float)myADCVals[iCount]-thisPedestal;
00317 if (diff > threshold) { thisStripFired = true; }
00318 }
00319 if (thisStripFired) {
00320 if (!stripo[kEndcap-1][kStation-1][kRing-1][kChamber-1]){
00321 stripo[kEndcap-1][kStation-1][kRing-1][kChamber-1] = true;
00322 hOStrips->Fill(kChamber,typeIndex(id));
00323 histos->fill1DHist(chamberSerial(id),"hOStripSerial","Strip Occupancy by Chamber Serial",601,-0.5,600.5,"Digis");
00324 hasStrips = true;
00325 }
00326 }
00327 }
00328 }
00329 }
00330
00331
00332 CSCRecHit2DCollection::const_iterator recIt;
00333 for (recIt = recHits->begin(); recIt != recHits->end(); recIt++) {
00334 CSCDetId idrec = (CSCDetId)(*recIt).cscDetId();
00335 int kEndcap = idrec.endcap();
00336 int kRing = idrec.ring();
00337 int kStation = idrec.station();
00338 int kChamber = idrec.chamber();
00339 if (!rechito[kEndcap-1][kStation-1][kRing-1][kChamber-1]){
00340 rechito[kEndcap-1][kStation-1][kRing-1][kChamber-1] = true;
00341 histos->fill1DHist(chamberSerial(idrec),"hORecHitsSerial","RecHit Occupancy by Chamber Serial",601,-0.5,600.5,"recHits");
00342 hORecHits->Fill(kChamber,typeIndex(idrec));
00343 hasRecHits = true;
00344 }
00345 }
00346
00347
00348 for(CSCSegmentCollection::const_iterator segIt=cscSegments->begin(); segIt != cscSegments->end(); segIt++) {
00349 CSCDetId id = (CSCDetId)(*segIt).cscDetId();
00350 int kEndcap = id.endcap();
00351 int kRing = id.ring();
00352 int kStation = id.station();
00353 int kChamber = id.chamber();
00354 if (!segmento[kEndcap-1][kStation-1][kRing-1][kChamber-1]){
00355 segmento[kEndcap-1][kStation-1][kRing-1][kChamber-1] = true;
00356 histos->fill1DHist(chamberSerial(id),"hOSegmentsSerial","Segment Occupancy by Chamber Serial",601,-0.5,600.5,"Segments");
00357 hOSegments->Fill(kChamber,typeIndex(id));
00358 hasSegments = true;
00359 }
00360 }
00361
00362
00363 histos->fill1DHist(0,"hCSCOccupancy","overall CSC occupancy",6,-0.5,5.5,"GeneralHists");
00364 if (hasWires) histos->fill1DHist(1,"hCSCOccupancy","overall CSC occupancy",6,-0.5,5.5,"GeneralHists");
00365 if (hasStrips) histos->fill1DHist(2,"hCSCOccupancy","overall CSC occupancy",6,-0.5,5.5,"GeneralHists");
00366 if (hasWires && hasStrips) histos->fill1DHist(3,"hCSCOccupancy","overall CSC occupancy",6,-0.5,5.5,"GeneralHists");
00367 if (hasRecHits) histos->fill1DHist(4,"hCSCOccupancy","overall CSC occupancy",6,-0.5,5.5,"GeneralHists");
00368 if (hasSegments) histos->fill1DHist(5,"hCSCOccupancy","overall CSC occupancy",6,-0.5,5.5,"GeneralHists");
00369
00370 }
00371
00372
00373
00374
00375
00376
00377
00378 bool CSCValidation::doTrigger(edm::Handle<L1MuGMTReadoutCollection> pCollection){
00379
00380 vector<L1MuGMTReadoutRecord> L1Mrec = pCollection->getRecords();
00381 vector<L1MuGMTReadoutRecord>::const_iterator igmtrr;
00382
00383 bool csc_l1a = false;
00384 bool dt_l1a = false;
00385 bool rpcf_l1a = false;
00386 bool rpcb_l1a = false;
00387 bool beamHaloTrigger = false;
00388
00389 int myBXNumber = -1000;
00390
00391 for(igmtrr=L1Mrec.begin(); igmtrr!=L1Mrec.end(); igmtrr++) {
00392 std::vector<L1MuRegionalCand>::const_iterator iter1;
00393 std::vector<L1MuRegionalCand> rmc;
00394
00395
00396 int icsc = 0;
00397 rmc = igmtrr->getCSCCands();
00398 for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
00399 if ( !(*iter1).empty() ) {
00400 icsc++;
00401 int kQuality = (*iter1).quality();
00402 if (kQuality == 1) beamHaloTrigger = true;
00403 }
00404 }
00405 if (igmtrr->getBxInEvent() == 0 && icsc>0) csc_l1a = true;
00406 if (igmtrr->getBxInEvent() == 0 ) { myBXNumber = igmtrr->getBxNr(); }
00407
00408
00409 int idt = 0;
00410 rmc = igmtrr->getDTBXCands();
00411 for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
00412 if ( !(*iter1).empty() ) {
00413 idt++;
00414 }
00415 }
00416 if(igmtrr->getBxInEvent()==0 && idt>0) dt_l1a = true;
00417
00418
00419 int irpcb = 0;
00420 rmc = igmtrr->getBrlRPCCands();
00421 for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
00422 if ( !(*iter1).empty() ) {
00423 irpcb++;
00424 }
00425 }
00426 if(igmtrr->getBxInEvent()==0 && irpcb>0) rpcb_l1a = true;
00427
00428
00429 int irpcf = 0;
00430 rmc = igmtrr->getFwdRPCCands();
00431 for(iter1=rmc.begin(); iter1!=rmc.end(); iter1++) {
00432 if ( !(*iter1).empty() ) {
00433 irpcf++;
00434 }
00435 }
00436 if(igmtrr->getBxInEvent()==0 && irpcf>0) rpcf_l1a = true;
00437
00438 }
00439
00440
00441 if (csc_l1a) histos->fill1DHist(myBXNumber,"vtBXNumber","BX Number",4001,-0.5,4000.5,"Trigger");
00442 if (csc_l1a) histos->fill1DHist(1,"vtBits","trigger bits",11,-0.5,10.5,"Trigger");
00443 if (dt_l1a) histos->fill1DHist(2,"vtBits","trigger bits",11,-0.5,10.5,"Trigger");
00444 if (rpcb_l1a) histos->fill1DHist(3,"vtBits","trigger bits",11,-0.5,10.5,"Trigger");
00445 if (rpcf_l1a) histos->fill1DHist(4,"vtBits","trigger bits",11,-0.5,10.5,"Trigger");
00446 if (beamHaloTrigger) histos->fill1DHist(8,"vtBits","trigger bits",11,-0.5,10.5,"Trigger");
00447
00448 if (csc_l1a) {
00449 histos->fill1DHist(1,"vtCSCY","trigger bits",11,-0.5,10.5,"Trigger");
00450 if (dt_l1a) histos->fill1DHist(2,"vtCSCY","trigger bits",11,-0.5,10.5,"Trigger");
00451 if (rpcb_l1a) histos->fill1DHist(3,"vtCSCY","trigger bits",11,-0.5,10.5,"Trigger");
00452 if (rpcf_l1a) histos->fill1DHist(4,"vtCSCY","trigger bits",11,-0.5,10.5,"Trigger");
00453 if ( dt_l1a || rpcb_l1a || rpcf_l1a) histos->fill1DHist(5,"vtCSCY","trigger bits",11,-0.5,10.5,"Trigger");
00454 if (!(dt_l1a || rpcb_l1a || rpcf_l1a)) histos->fill1DHist(6,"vtCSCY","trigger bits",11,-0.5,10.5,"Trigger");
00455 } else {
00456 histos->fill1DHist(1,"vtCSCN","trigger bits",11,-0.5,10.5,"Trigger");
00457 if (dt_l1a) histos->fill1DHist(2,"vtCSCN","trigger bits",11,-0.5,10.5,"Trigger");
00458 if (rpcb_l1a) histos->fill1DHist(3,"vtCSCN","trigger bits",11,-0.5,10.5,"Trigger");
00459 if (rpcf_l1a) histos->fill1DHist(4,"vtCSCN","trigger bits",11,-0.5,10.5,"Trigger");
00460 if ( dt_l1a || rpcb_l1a || rpcf_l1a) histos->fill1DHist(5,"vtCSCN","trigger bits",11,-0.5,10.5,"Trigger");
00461 if (!(dt_l1a || rpcb_l1a || rpcf_l1a)) histos->fill1DHist(6,"vtCSCN","trigger bits",11,-0.5,10.5,"Trigger");
00462 }
00463
00464
00465
00466 if (csc_l1a) return true;
00467
00468 return false;
00469
00470 }
00471
00472
00473
00474
00475
00476
00477
00478 void CSCValidation::doCalibrations(const edm::EventSetup& eventSetup){
00479
00480
00481 if (nEventsAnalyzed == 1){
00482
00483 LogDebug("Calibrations") << "Loading Calibrations...";
00484
00485
00486 edm::ESHandle<CSCDBGains> hGains;
00487 eventSetup.get<CSCDBGainsRcd>().get( hGains );
00488 const CSCDBGains* pGains = hGains.product();
00489
00490 edm::ESHandle<CSCDBCrosstalk> hCrosstalk;
00491 eventSetup.get<CSCDBCrosstalkRcd>().get( hCrosstalk );
00492 const CSCDBCrosstalk* pCrosstalk = hCrosstalk.product();
00493
00494 edm::ESHandle<CSCDBNoiseMatrix> hNoiseMatrix;
00495 eventSetup.get<CSCDBNoiseMatrixRcd>().get( hNoiseMatrix );
00496 const CSCDBNoiseMatrix* pNoiseMatrix = hNoiseMatrix.product();
00497
00498 edm::ESHandle<CSCDBPedestals> hPedestals;
00499 eventSetup.get<CSCDBPedestalsRcd>().get( hPedestals );
00500 const CSCDBPedestals* pPedestals = hPedestals.product();
00501
00502 LogDebug("Calibrations") << "Calibrations Loaded!";
00503
00504 for (int i = 0; i < 400; i++){
00505 int bin = i+1;
00506 histos->fillCalibHist(pGains->gains[i].gain_slope,"hCalibGainsS","Gains Slope",400,0,400,bin,"Calib");
00507 histos->fillCalibHist(pCrosstalk->crosstalk[i].xtalk_slope_left,"hCalibXtalkSL","Xtalk Slope Left",400,0,400,bin,"Calib");
00508 histos->fillCalibHist(pCrosstalk->crosstalk[i].xtalk_slope_right,"hCalibXtalkSR","Xtalk Slope Right",400,0,400,bin,"Calib");
00509 histos->fillCalibHist(pCrosstalk->crosstalk[i].xtalk_intercept_left,"hCalibXtalkIL","Xtalk Intercept Left",400,0,400,bin,"Calib");
00510 histos->fillCalibHist(pCrosstalk->crosstalk[i].xtalk_intercept_right,"hCalibXtalkIR","Xtalk Intercept Right",400,0,400,bin,"Calib");
00511 histos->fillCalibHist(pPedestals->pedestals[i].ped,"hCalibPedsP","Peds",400,0,400,bin,"Calib");
00512 histos->fillCalibHist(pPedestals->pedestals[i].rms,"hCalibPedsR","Peds RMS",400,0,400,bin,"Calib");
00513 histos->fillCalibHist(pNoiseMatrix->matrix[i].elem33,"hCalibNoise33","Noise Matrix 33",400,0,400,bin,"Calib");
00514 histos->fillCalibHist(pNoiseMatrix->matrix[i].elem34,"hCalibNoise34","Noise Matrix 34",400,0,400,bin,"Calib");
00515 histos->fillCalibHist(pNoiseMatrix->matrix[i].elem35,"hCalibNoise35","Noise Matrix 35",400,0,400,bin,"Calib");
00516 histos->fillCalibHist(pNoiseMatrix->matrix[i].elem44,"hCalibNoise44","Noise Matrix 44",400,0,400,bin,"Calib");
00517 histos->fillCalibHist(pNoiseMatrix->matrix[i].elem45,"hCalibNoise45","Noise Matrix 45",400,0,400,bin,"Calib");
00518 histos->fillCalibHist(pNoiseMatrix->matrix[i].elem46,"hCalibNoise46","Noise Matrix 46",400,0,400,bin,"Calib");
00519 histos->fillCalibHist(pNoiseMatrix->matrix[i].elem55,"hCalibNoise55","Noise Matrix 55",400,0,400,bin,"Calib");
00520 histos->fillCalibHist(pNoiseMatrix->matrix[i].elem56,"hCalibNoise56","Noise Matrix 56",400,0,400,bin,"Calib");
00521 histos->fillCalibHist(pNoiseMatrix->matrix[i].elem57,"hCalibNoise57","Noise Matrix 57",400,0,400,bin,"Calib");
00522 histos->fillCalibHist(pNoiseMatrix->matrix[i].elem66,"hCalibNoise66","Noise Matrix 66",400,0,400,bin,"Calib");
00523 histos->fillCalibHist(pNoiseMatrix->matrix[i].elem67,"hCalibNoise67","Noise Matrix 67",400,0,400,bin,"Calib");
00524 histos->fillCalibHist(pNoiseMatrix->matrix[i].elem77,"hCalibNoise77","Noise Matrix 77",400,0,400,bin,"Calib");
00525
00526
00527 }
00528
00529 }
00530
00531
00532 }
00533
00534
00535
00536
00537
00538
00539
00540
00541 void CSCValidation::doWireDigis(edm::Handle<CSCWireDigiCollection> wires){
00542
00543 int nWireGroupsTotal = 0;
00544 for (CSCWireDigiCollection::DigiRangeIterator dWDiter=wires->begin(); dWDiter!=wires->end(); dWDiter++) {
00545 CSCDetId id = (CSCDetId)(*dWDiter).first;
00546 std::vector<CSCWireDigi>::const_iterator wireIter = (*dWDiter).second.first;
00547 std::vector<CSCWireDigi>::const_iterator lWire = (*dWDiter).second.second;
00548 for( ; wireIter != lWire; ++wireIter) {
00549 int myWire = wireIter->getWireGroup();
00550 int myTBin = wireIter->getTimeBin();
00551 nWireGroupsTotal++;
00552 histos->fill1DHistByType(myWire,"hWireWire","Wiregroup Numbers Fired",id,113,-0.5,112.5,"Digis");
00553 histos->fill1DHistByType(myTBin,"hWireTBin","Wire TimeBin Fired",id,17,-0.5,16.5,"Digis");
00554 histos->fillProfile(chamberSerial(id),myTBin,"hWireTBinProfile","Wire TimeBin Fired",601,-0.5,600.5,-0.5,16.5,"Digis");
00555 if (detailedAnalysis){
00556 histos->fill1DHistByLayer(myWire,"hWireWire","Wiregroup Numbers Fired",id,113,-0.5,112.5,"WireNumberByLayer");
00557 histos->fill1DHistByLayer(myTBin,"hWireTBin","Wire TimeBin Fired",id,17,-0.5,16.5,"WireTimeByLayer");
00558 }
00559 }
00560 }
00561
00562
00563 if (nWireGroupsTotal == 0) nWireGroupsTotal = -1;
00564
00565 histos->fill1DHist(nWireGroupsTotal,"hWirenGroupsTotal","Wires Fired Per Event",41,-0.5,40.5,"Digis");
00566
00567 }
00568
00569
00570
00571
00572
00573
00574
00575 void CSCValidation::doStripDigis(edm::Handle<CSCStripDigiCollection> strips){
00576
00577 int nStripsFired = 0;
00578 for (CSCStripDigiCollection::DigiRangeIterator dSDiter=strips->begin(); dSDiter!=strips->end(); dSDiter++) {
00579 CSCDetId id = (CSCDetId)(*dSDiter).first;
00580 std::vector<CSCStripDigi>::const_iterator stripIter = (*dSDiter).second.first;
00581 std::vector<CSCStripDigi>::const_iterator lStrip = (*dSDiter).second.second;
00582 for( ; stripIter != lStrip; ++stripIter) {
00583 int myStrip = stripIter->getStrip();
00584 std::vector<int> myADCVals = stripIter->getADCCounts();
00585 bool thisStripFired = false;
00586 float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
00587 float threshold = 13.3 ;
00588 float diff = 0.;
00589 for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
00590 diff = (float)myADCVals[iCount]-thisPedestal;
00591 if (diff > threshold) { thisStripFired = true; }
00592 }
00593 if (thisStripFired) {
00594 nStripsFired++;
00595
00596 histos->fill1DHistByType(myStrip,"hStripStrip","Strip Number",id,81,-0.5,80.5,"Digis");
00597 if (detailedAnalysis){
00598 histos->fill1DHistByLayer(myStrip,"hStripStrip","Strip Number",id,81,-0.5,80.5,"StripNumberByLayer");
00599 }
00600 }
00601 }
00602 }
00603
00604 if (nStripsFired == 0) nStripsFired = -1;
00605
00606 histos->fill1DHist(nStripsFired,"hStripNFired","Fired Strips per Event",101,-0.5,100.5,"Digis");
00607
00608 }
00609
00610
00611
00612
00613
00614
00615
00616 void CSCValidation::doPedestalNoise(edm::Handle<CSCStripDigiCollection> strips){
00617
00618 for (CSCStripDigiCollection::DigiRangeIterator dPNiter=strips->begin(); dPNiter!=strips->end(); dPNiter++) {
00619 CSCDetId id = (CSCDetId)(*dPNiter).first;
00620 std::vector<CSCStripDigi>::const_iterator pedIt = (*dPNiter).second.first;
00621 std::vector<CSCStripDigi>::const_iterator lStrip = (*dPNiter).second.second;
00622 for( ; pedIt != lStrip; ++pedIt) {
00623 int myStrip = pedIt->getStrip();
00624 std::vector<int> myADCVals = pedIt->getADCCounts();
00625 float TotalADC = getSignal(*strips, id, myStrip);
00626 bool thisStripFired = false;
00627 float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
00628 float thisSignal = (1./6)*(myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
00629 float threshold = 13.3;
00630 if(id.station() == 1 && id.ring() == 4)
00631 {
00632 if(myStrip <= 16) myStrip += 64;
00633 }
00634 if (TotalADC > threshold) { thisStripFired = true;}
00635 if (!thisStripFired){
00636 float ADC = thisSignal - thisPedestal;
00637 histos->fill1DHist(ADC,"hStripPed","Pedestal Noise Distribution",50,-25.,25.,"PedestalNoise");
00638 histos->fill1DHistByType(ADC,"hStripPedME","Pedestal Noise Distribution",id,50,-25.,25.,"PedestalNoise");
00639 histos->fillProfile(chamberSerial(id),ADC,"hStripPedMEProfile","Wire TimeBin Fired",601,-0.5,600.5,-25,25,"PedestalNoise");
00640 if (detailedAnalysis){
00641 histos->fill1DHistByLayer(ADC,"hStripPedME","Pedestal Noise Distribution",id,50,-25.,25.,"PedestalNoiseByLayer");
00642 }
00643 }
00644 }
00645 }
00646
00647 }
00648
00649
00650
00651
00652
00653
00654
00655
00656 void CSCValidation::doRecHits(edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<CSCStripDigiCollection> strips, edm::ESHandle<CSCGeometry> cscGeom){
00657
00658
00659 int nRecHits = recHits->size();
00660
00661
00662
00663
00664 int iHit = 0;
00665
00666
00667 CSCRecHit2DCollection::const_iterator dRHIter;
00668 for (dRHIter = recHits->begin(); dRHIter != recHits->end(); dRHIter++) {
00669 iHit++;
00670
00671
00672 CSCDetId idrec = (CSCDetId)(*dRHIter).cscDetId();
00673 int kEndcap = idrec.endcap();
00674 int kRing = idrec.ring();
00675 int kStation = idrec.station();
00676 int kChamber = idrec.chamber();
00677 int kLayer = idrec.layer();
00678
00679
00680 LocalPoint rhitlocal = (*dRHIter).localPosition();
00681 float xreco = rhitlocal.x();
00682 float yreco = rhitlocal.y();
00683 LocalError rerrlocal = (*dRHIter).localPositionError();
00684
00685 float xxerr = rerrlocal.xx();
00686 float yyerr = rerrlocal.yy();
00687 float xyerr = rerrlocal.xy();
00688
00689 float stpos = (*dRHIter).positionWithinStrip();
00690 float sterr = (*dRHIter).errorWithinStrip();
00691
00692
00693 CSCRecHit2D::ChannelContainer hitstrips = (*dRHIter).channels();
00694 int nStrips = hitstrips.size();
00695 int centerid = nStrips/2 + 1;
00696 int centerStrip = hitstrips[centerid - 1];
00697
00698
00699 CSCRecHit2D::ADCContainer adcs = (*dRHIter).adcs();
00700 int adcsize = adcs.size();
00701 float rHSumQ = 0;
00702 float sumsides = 0;
00703 for (int i = 0; i < adcsize; i++){
00704 if (i != 3 && i != 7 && i != 11){
00705 rHSumQ = rHSumQ + adcs[i];
00706 }
00707 if (adcsize == 12 && (i < 3 || i > 7) && i < 12){
00708 sumsides = sumsides + adcs[i];
00709 }
00710 }
00711 float rHratioQ = sumsides/rHSumQ;
00712 if (adcsize != 12) rHratioQ = -99;
00713
00714
00715 float rHtime = 0;
00716 if (useDigis){
00717 rHtime = getTiming(*strips, idrec, centerStrip);
00718 }
00719 else{
00720 rHtime = (*dRHIter).tpeak()/50.;
00721 }
00722
00723
00724 const CSCLayer* csclayer = cscGeom->layer( idrec );
00725
00726
00727 GlobalPoint rhitglobal= csclayer->toGlobal(rhitlocal);
00728 float grecx = rhitglobal.x();
00729 float grecy = rhitglobal.y();
00730
00731
00732 if (writeTreeToFile && rhTreeCount < 1500000){
00733 histos->fillRechitTree(xreco, yreco, grecx, grecy, kEndcap, kStation, kRing, kChamber, kLayer);
00734 rhTreeCount++;
00735 }
00736
00737
00738 if (kStation == 1 && (kRing == 1 || kRing == 4)) histos->fill1DHistByType(rHSumQ,"hRHSumQ","Sum 3x3 recHit Charge",idrec,125,0,4000,"recHits");
00739 else histos->fill1DHistByType(rHSumQ,"hRHSumQ","Sum 3x3 recHit Charge",idrec,125,0,2000,"recHits");
00740 histos->fill1DHistByType(rHratioQ,"hRHRatioQ","Charge Ratio (Ql+Qr)/Qt",idrec,120,-0.1,1.1,"recHits");
00741 histos->fill1DHistByType(rHtime,"hRHTiming","recHit Timing",idrec,100,0,10,"recHits");
00742 histos->fill2DHistByStation(grecx,grecy,"hRHGlobal","recHit Global Position",idrec,100,-800.,800.,100,-800.,800.,"recHits");
00743 histos->fill1DHistByType(sqrt(xxerr),"hRHxerr","RecHit Error on Local X",idrec,100,-0.1,2,"recHits");
00744 histos->fill1DHistByType(sqrt(yyerr),"hRHyerr","RecHit Error on Local Y",idrec,100,-0.1,2,"recHits");
00745 histos->fill1DHistByType(xyerr,"hRHxyerr","Corr. RecHit XY Error",idrec,100,-1,2,"recHits");
00746 histos->fill1DHistByType(stpos,"hRHstpos","Reconstructed Position on Strip",idrec,120,-0.6,0.6,"recHits");
00747 histos->fill1DHistByType(sterr,"hRHsterr","Estimated Error on Strip Measurement",idrec,120,-0.05,0.25,"recHits");
00748 histos->fillProfile(chamberSerial(idrec),rHSumQ,"hRHSumQProfile","Sum 3x3 recHit Charge",601,-0.5,600.5,0,4000,"recHits");
00749 histos->fillProfile(chamberSerial(idrec),rHtime,"hRHTimingProfile","recHit Timing",601,-0.5,600.5,-1,11,"recHits");
00750 if (detailedAnalysis){
00751 if (kStation == 1 && (kRing == 1 || kRing == 4)) histos->fill1DHistByLayer(rHSumQ,"hRHSumQ","Sum 3x3 recHit Charge",idrec,125,0,4000,"RHQByLayer");
00752 else histos->fill1DHistByLayer(rHSumQ,"hRHSumQ","Sum 3x3 recHit Charge",idrec,125,0,2000,"RHQByLayer");
00753 histos->fill1DHistByLayer(rHratioQ,"hRHRatioQ","Charge Ratio (Ql+Qr)/Qt",idrec,120,-0.1,1.1,"RHQByLayer");
00754 histos->fill1DHistByLayer(rHtime,"hRHTiming","recHit Timing",idrec,100,0,10,"RHTimingByLayer");
00755 histos->fill2DHistByLayer(xreco,yreco,"hRHLocalXY","recHit Local Position",idrec,50,-100.,100.,75,-150.,150.,"RHLocalXYByLayer");
00756 histos->fill1DHistByLayer(sqrt(xxerr),"hRHxerr","RecHit Error on Local X",idrec,100,-0.1,2,"RHErrorsByLayer");
00757 histos->fill1DHistByLayer(sqrt(yyerr),"hRHyerr","RecHit Error on Local Y",idrec,100,-0.1,2,"RHErrorsByLayer");
00758 histos->fill1DHistByType(stpos,"hRHstpos","Reconstructed Position on Strip",idrec,120,-0.6,0.6,"RHStripPosByLayer");
00759 histos->fill1DHistByType(sterr,"hRHsterr","Estimated Error on Strip Measurement",idrec,120,-0.05,0.25,"RHStripPosByLayer");
00760 }
00761
00762 }
00763
00764 if (nRecHits == 0) nRecHits = -1;
00765
00766 histos->fill1DHist(nRecHits,"hRHnrechits","recHits per Event (all chambers)",41,-0.5,40.5,"recHits");
00767
00768 }
00769
00770
00771
00772
00773
00774
00775
00776 void CSCValidation::doSimHits(edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<PSimHitContainer> simHits){
00777
00778 CSCRecHit2DCollection::const_iterator dSHrecIter;
00779 for (dSHrecIter = recHits->begin(); dSHrecIter != recHits->end(); dSHrecIter++) {
00780
00781 CSCDetId idrec = (CSCDetId)(*dSHrecIter).cscDetId();
00782 LocalPoint rhitlocal = (*dSHrecIter).localPosition();
00783 float xreco = rhitlocal.x();
00784 float yreco = rhitlocal.y();
00785 float simHitXres = -99;
00786 float simHitYres = -99;
00787 float mindiffX = 99;
00788 float mindiffY = 10;
00789
00790 PSimHitContainer::const_iterator dSHsimIter;
00791 for (dSHsimIter = simHits->begin(); dSHsimIter != simHits->end(); dSHsimIter++){
00792
00793 CSCDetId sId = (CSCDetId)(*dSHsimIter).detUnitId();
00794
00795
00796 if (sId == idrec && abs((*dSHsimIter).particleType()) == 13){
00797
00798 LocalPoint sHitlocal = (*dSHsimIter).localPosition();
00799
00800
00801 if ((sHitlocal.x() - xreco) < mindiffX && (sHitlocal.y() - yreco) < mindiffY){
00802 simHitXres = (sHitlocal.x() - xreco);
00803 simHitYres = (sHitlocal.y() - yreco);
00804 mindiffX = (sHitlocal.x() - xreco);
00805 }
00806 }
00807 }
00808
00809 histos->fill1DHistByType(simHitXres,"hRHResid","SimHitX - Reconstructed X",idrec,100,-1.0,1.0,"Resolution");
00810 }
00811
00812 }
00813
00814
00815
00816
00817
00818
00819
00820 void CSCValidation::doSegments(edm::Handle<CSCSegmentCollection> cscSegments, edm::ESHandle<CSCGeometry> cscGeom){
00821
00822
00823 int nSegments = cscSegments->size();
00824
00825
00826
00827
00828 int iSegment = 0;
00829 for(CSCSegmentCollection::const_iterator dSiter=cscSegments->begin(); dSiter != cscSegments->end(); dSiter++) {
00830 iSegment++;
00831
00832 CSCDetId id = (CSCDetId)(*dSiter).cscDetId();
00833 int kEndcap = id.endcap();
00834 int kRing = id.ring();
00835 int kStation = id.station();
00836 int kChamber = id.chamber();
00837
00838
00839 float chisq = (*dSiter).chi2();
00840 int nhits = (*dSiter).nRecHits();
00841 int nDOF = 2*nhits-4;
00842 double chisqProb = ChiSquaredProbability( (double)chisq, nDOF );
00843 LocalPoint localPos = (*dSiter).localPosition();
00844 float segX = localPos.x();
00845 float segY = localPos.y();
00846 LocalVector segDir = (*dSiter).localDirection();
00847 double theta = segDir.theta();
00848
00849
00850
00851 std::vector<CSCRecHit2D> theseRecHits = (*dSiter).specificRecHits();
00852 int nRH = (*dSiter).nRecHits();
00853 int jRH = 0;
00854 HepMatrix sp(6,1);
00855 HepMatrix se(6,1);
00856 for ( vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++) {
00857 jRH++;
00858 CSCDetId idRH = (CSCDetId)(*iRH).cscDetId();
00859 int kRing = idRH.ring();
00860 int kStation = idRH.station();
00861 int kLayer = idRH.layer();
00862
00863
00864 CSCRecHit2D::ChannelContainer hitstrips = (*iRH).channels();
00865 int nStrips = hitstrips.size();
00866 int centerid = nStrips/2 + 1;
00867 int centerStrip = hitstrips[centerid - 1];
00868
00869
00870 if (nRH == 6){
00871 float stpos = (*iRH).positionWithinStrip();
00872 se(kLayer,1) = (*iRH).errorWithinStrip();
00873
00874 if (kStation == 1 && (kRing == 1 || kRing == 4)) sp(kLayer,1) = stpos + centerStrip;
00875 else{
00876 if (kLayer == 1 || kLayer == 3 || kLayer == 5) sp(kLayer,1) = stpos + centerStrip;
00877 if (kLayer == 2 || kLayer == 4 || kLayer == 6) sp(kLayer,1) = stpos - 0.5 + centerStrip;
00878 }
00879 }
00880
00881 }
00882
00883 float residual = -99;
00884
00885 if (nRH == 6){
00886 float expected = fitX(sp,se);
00887 residual = expected - sp(3,1);
00888 }
00889
00890
00891 float globX = 0.;
00892 float globY = 0.;
00893 float globZ = 0.;
00894 float globpPhi = 0.;
00895 float globR = 0.;
00896 float globTheta = 0.;
00897 float globPhi = 0.;
00898 const CSCChamber* cscchamber = cscGeom->chamber(id);
00899 if (cscchamber) {
00900 GlobalPoint globalPosition = cscchamber->toGlobal(localPos);
00901 globX = globalPosition.x();
00902 globY = globalPosition.y();
00903 globZ = globalPosition.z();
00904 globpPhi = globalPosition.phi();
00905 globR = sqrt(globX*globX + globY*globY);
00906 GlobalVector globalDirection = cscchamber->toGlobal(segDir);
00907 globTheta = globalDirection.theta();
00908 globPhi = globalDirection.phi();
00909 }
00910
00911
00912
00913 if (writeTreeToFile && segTreeCount < 1500000){
00914 histos->fillSegmentTree(segX, segY, globX, globY, kEndcap, kStation, kRing, kChamber);
00915 segTreeCount++;
00916 }
00917
00918
00919 histos->fill2DHistByStation(globX,globY,"hSGlobal","Segment Global Positions;global x (cm)",id,100,-800.,800.,100,-800.,800.,"Segments");
00920 histos->fill1DHistByType(nhits,"hSnHits","N hits on Segments",id,8,-0.5,7.5,"Segments");
00921 histos->fill1DHistByType(theta,"hSTheta","local theta segments",id,128,-3.2,3.2,"Segments");
00922 histos->fill1DHistByType(residual,"hSResid","Fitted Position on Strip - Reconstructed for Layer 3",id,100,-0.5,0.5,"Resolution");
00923 histos->fill1DHistByType((chisq/nDOF),"hSChiSq","segments chi-squared/ndof",id,110,-0.05,1.05,"Segments");
00924 histos->fill1DHistByType(chisqProb,"hSChiSqProb","segments chi-squared probability",id,110,-0.05,1.05,"Segments");
00925 histos->fill1DHist(globTheta,"hSGlobalTheta","segment global theta",64,0,1.6,"Segments");
00926 histos->fill1DHist(globPhi,"hSGlobalPhi","segment global phi",128,-3.2,3.2,"Segments");
00927 histos->fillProfile(chamberSerial(id),nhits,"hSnHitsProfile","N hits on Segments",601,-0.5,600.5,-0.5,7.5,"Segments");
00928 histos->fillProfile(chamberSerial(id),residual,"hSResidProfile","Fitted Position on Strip - Reconstructed for Layer 3",601,-0.5,600.5,-0.5,0.5,"Resolution");
00929 if (detailedAnalysis){
00930 histos->fill1DHistByChamber(nhits,"hSnHits","N hits on Segments",id,8,-0.5,7.5,"HitsOnSegmentByChamber");
00931 histos->fill1DHistByChamber(theta,"hSTheta","local theta segments",id,128,-3.2,3.2,"DetailedSegments");
00932 histos->fill1DHistByChamber(residual,"hSResid","Fitted Position on Strip - Reconstructed for Layer 3",id,100,-0.5,0.5,"DetailedResolution");
00933 histos->fill1DHistByChamber((chisq/nDOF),"hSChiSq","segments chi-squared probability",id,110,-0.05,1.05,"SegChi2ByChamber");
00934 histos->fill1DHistByChamber(chisqProb,"hSChiSqProb","segments chi-squared probability",id,110,-0.05,1.05,"SegChi2ByChamber");
00935 }
00936
00937 }
00938
00939 if (nSegments == 0) nSegments = -1;
00940
00941 histos->fill1DHist(nSegments,"hSnSegments","Segments per Event",11,-0.5,10.5,"Segments");
00942
00943 }
00944
00945
00946
00947
00948
00949
00950
00951 void CSCValidation::doStandalone(Handle<reco::TrackCollection> saMuons){
00952
00953 int nSAMuons = saMuons->size();
00954 histos->fill1DHist(nSAMuons,"trNSAMuons","N Standalone Muons per Event",6,-0.5,5.5,"STAMuons");
00955
00956 for(reco::TrackCollection::const_iterator muon = saMuons->begin(); muon != saMuons->end(); ++ muon ) {
00957 float preco = muon->p();
00958 float ptreco = muon->pt();
00959 int n = muon->recHitsSize();
00960
00961
00962 int nDTHits = 0;
00963 int nCSCHits = 0;
00964 for (trackingRecHit_iterator hit = muon->recHitsBegin(); hit != muon->recHitsEnd(); ++hit ) {
00965 const DetId detId( (*hit)->geographicalId() );
00966 if (detId.det() == DetId::Muon) {
00967 if (detId.subdetId() == MuonSubdetId::DT) {
00968
00969
00970 nDTHits++;
00971 }
00972 else if (detId.subdetId() == MuonSubdetId::CSC) {
00973
00974
00975 nCSCHits++;
00976 }
00977 }
00978 }
00979
00980
00981 histos->fill1DHist(n,"trN","N hits on a STA Muon Track",51,-0.5,50.5,"STAMuons");
00982 histos->fill1DHist(nDTHits,"trNDT","N DT hits on a STA Muon Track",51,-0.5,50.5,"STAMuons");
00983 histos->fill1DHist(nCSCHits,"trNCSC","N CSC hits on a STA Muon Track",51,-0.5,50.5,"STAMuons");
00984 histos->fill1DHist(preco,"trP","STA Muon Momentum",100,0,1000,"STAMuons");
00985 histos->fill1DHist(ptreco,"trPT","STA Muon pT",100,0,20,"STAMuons");
00986
00987 }
00988
00989 }
00990
00991
00992
00993
00994
00995
00996 int CSCValidation::chamberSerial( CSCDetId id ) {
00997 int st = id.station();
00998 int ri = id.ring();
00999 int ch = id.chamber();
01000 int ec = id.endcap();
01001 int kSerial = ch;
01002 if (st == 1 && ri == 1) kSerial = ch;
01003 if (st == 1 && ri == 2) kSerial = ch + 36;
01004 if (st == 1 && ri == 3) kSerial = ch + 72;
01005 if (st == 1 && ri == 4) kSerial = ch;
01006 if (st == 2 && ri == 1) kSerial = ch + 108;
01007 if (st == 2 && ri == 2) kSerial = ch + 126;
01008 if (st == 3 && ri == 1) kSerial = ch + 162;
01009 if (st == 3 && ri == 2) kSerial = ch + 180;
01010 if (st == 4 && ri == 1) kSerial = ch + 216;
01011 if (st == 4 && ri == 2) kSerial = ch + 234;
01012 if (ec == 2) kSerial = kSerial + 300;
01013 return kSerial;
01014 }
01015
01016
01017
01018
01019
01020
01021
01022
01023 float CSCValidation::fitX(HepMatrix points, HepMatrix errors){
01024
01025 float S = 0;
01026 float Sx = 0;
01027 float Sy = 0;
01028 float Sxx = 0;
01029 float Sxy = 0;
01030 float sigma2 = 0;
01031
01032 for (int i=1;i<7;i++){
01033 if (i != 3){
01034 sigma2 = errors(i,1)*errors(i,1);
01035 S = S + (1/sigma2);
01036 Sy = Sy + (points(i,1)/sigma2);
01037 Sx = Sx + ((i)/sigma2);
01038 Sxx = Sxx + (i*i)/sigma2;
01039 Sxy = Sxy + (((i)*points(i,1))/sigma2);
01040 }
01041 }
01042
01043 float delta = S*Sxx - Sx*Sx;
01044 float intercept = (Sxx*Sy - Sx*Sxy)/delta;
01045 float slope = (S*Sxy - Sx*Sy)/delta;
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056 return (intercept + slope*3);
01057
01058 }
01059
01060
01061
01062
01063
01064
01065
01066 float CSCValidation::getTiming(const CSCStripDigiCollection& stripdigis, CSCDetId idRH, int centerStrip){
01067
01068 float ADC[8];
01069 for (int i = 0; i < 8; i++){
01070 ADC[i] = 0;
01071 }
01072 float timing = 0;
01073 float peakADC = 0;
01074 int peakTime = 0;
01075
01076 if (idRH.station() == 1 && idRH.ring() == 4){
01077 while(centerStrip> 16) centerStrip -= 16;
01078 }
01079
01080
01081 CSCStripDigiCollection::DigiRangeIterator gTstripIter;
01082
01083 for (gTstripIter = stripdigis.begin(); gTstripIter != stripdigis.end(); gTstripIter++){
01084 CSCDetId id = (CSCDetId)(*gTstripIter).first;
01085 if (id == idRH){
01086 vector<CSCStripDigi>::const_iterator STiter = (*gTstripIter).second.first;
01087 vector<CSCStripDigi>::const_iterator lastS = (*gTstripIter).second.second;
01088 for ( ; STiter != lastS; ++STiter ) {
01089 int thisStrip = STiter->getStrip();
01090 if (thisStrip == (centerStrip)){
01091 float diff = 0;
01092 vector<int> myADCVals = STiter->getADCCounts();
01093 float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01094 for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
01095 diff = (float)myADCVals[iCount]-thisPedestal;
01096 ADC[iCount] = diff;
01097 if (diff > peakADC){
01098 peakADC = diff;
01099 peakTime = iCount;
01100 }
01101 }
01102 }
01103 }
01104
01105 }
01106
01107 }
01108
01109 if (detailedAnalysis){
01110 float normADC;
01111 for (int i = 0; i < 8; i++){
01112 normADC = ADC[i]/ADC[peakTime];
01113 histos->fillProfileByChamber(i,normADC,"hSignalProfile","Normalized Signal Profile",idRH,8,-0.5,7.5,-0.1,1.1,"StripSignalProfile");
01114 }
01115 histos->fill1DHistByLayer(ADC[0],"hSigProPed","ADC in first time bin",idRH,400,-300,100,"StripSignalProfile");
01116 histos->fillProfile(chamberSerial(idRH),ADC[0],"hSigProPedProfile","ADC in first time bin",601,-0.5,600.5,-150,100,"StripSignalProfile");
01117 }
01118
01119
01120 timing = (ADC[2]*2 + ADC[3]*3 + ADC[4]*4 + ADC[5]*5 + ADC[6]*6)/(ADC[2] + ADC[3] + ADC[4] + ADC[5] + ADC[6]);
01121
01122 return timing;
01123
01124 }
01125
01126
01127
01128
01129
01130
01131 void CSCValidation::doEfficiencies(edm::Handle<CSCWireDigiCollection> wires, edm::Handle<CSCStripDigiCollection> strips,
01132 edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<CSCSegmentCollection> cscSegments,
01133 edm::ESHandle<CSCGeometry> cscGeom){
01134
01135 bool allWires[2][4][4][36][6];
01136 bool allStrips[2][4][4][36][6];
01137 bool AllRecHits[2][4][4][36][6];
01138 bool AllSegments[2][4][4][36];
01139
01140
01141 for(int iE = 0;iE<2;iE++){
01142 for(int iS = 0;iS<4;iS++){
01143 for(int iR = 0; iR<4;iR++){
01144 for(int iC =0;iC<36;iC++){
01145 AllSegments[iE][iS][iR][iC] = false;
01146
01147 for(int iL=0;iL<6;iL++){
01148 allWires[iE][iS][iR][iC][iL] = false;
01149 allStrips[iE][iS][iR][iC][iL] = false;
01150 AllRecHits[iE][iS][iR][iC][iL] = false;
01151 }
01152 }
01153 }
01154 }
01155 }
01156
01157 if (useDigis){
01158
01159 for (CSCWireDigiCollection::DigiRangeIterator dWDiter=wires->begin(); dWDiter!=wires->end(); dWDiter++) {
01160 CSCDetId idrec = (CSCDetId)(*dWDiter).first;
01161 std::vector<CSCWireDigi>::const_iterator wireIter = (*dWDiter).second.first;
01162 std::vector<CSCWireDigi>::const_iterator lWire = (*dWDiter).second.second;
01163 for( ; wireIter != lWire; ++wireIter) {
01164 allWires[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber() -1][idrec.layer() -1] = true;
01165 break;
01166 }
01167 }
01168
01169
01170 for (CSCStripDigiCollection::DigiRangeIterator dSDiter=strips->begin(); dSDiter!=strips->end(); dSDiter++) {
01171 CSCDetId idrec = (CSCDetId)(*dSDiter).first;
01172 std::vector<CSCStripDigi>::const_iterator stripIter = (*dSDiter).second.first;
01173 std::vector<CSCStripDigi>::const_iterator lStrip = (*dSDiter).second.second;
01174 for( ; stripIter != lStrip; ++stripIter) {
01175 std::vector<int> myADCVals = stripIter->getADCCounts();
01176 bool thisStripFired = false;
01177 float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01178 float threshold = 13.3 ;
01179 float diff = 0.;
01180 for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
01181 diff = (float)myADCVals[iCount]-thisPedestal;
01182 if (diff > threshold) {
01183 thisStripFired = true;
01184 break;
01185 }
01186 }
01187 if(thisStripFired){
01188 allStrips[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber() -1][idrec.layer() -1] = true;
01189 break;
01190 }
01191 }
01192 }
01193 }
01194
01195
01196 for (CSCRecHit2DCollection::const_iterator recEffIt = recHits->begin(); recEffIt != recHits->end(); recEffIt++) {
01197
01198 CSCDetId idrec = (CSCDetId)(*recEffIt).cscDetId();
01199 AllRecHits[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber() -1][idrec.layer() -1] = true;
01200
01201 }
01202
01203 std::vector <uint> seg_ME2(2,0) ;
01204 std::vector <uint> seg_ME3(2,0) ;
01205 std::vector < pair <CSCDetId, CSCSegment> > theSegments(4);
01206
01207 for(CSCSegmentCollection::const_iterator segEffIt=cscSegments->begin(); segEffIt != cscSegments->end(); segEffIt++) {
01208 CSCDetId idseg = (CSCDetId)(*segEffIt).cscDetId();
01209
01210
01211
01212 AllSegments[idseg.endcap() -1][idseg.station() -1][idseg.ring() -1][idseg.chamber() -1] = true;
01213
01214
01215
01216 if(2==idseg.station() || 3==idseg.station()){
01217 uint seg_tmp ;
01218 if(2==idseg.station()){
01219 ++seg_ME2[idseg.endcap() -1];
01220 seg_tmp = seg_ME2[idseg.endcap() -1];
01221 }
01222 else{
01223 ++seg_ME3[idseg.endcap() -1];
01224 seg_tmp = seg_ME3[idseg.endcap() -1];
01225 }
01226
01227 if(1== seg_tmp&& 6==(*segEffIt).nRecHits() && (*segEffIt).chi2()/(*segEffIt).degreesOfFreedom()<3.){
01228 pair <CSCDetId, CSCSegment> specSeg = make_pair( (CSCDetId)(*segEffIt).cscDetId(),*segEffIt);
01229 theSegments[2*(idseg.endcap()-1)+(idseg.station() -2)] = specSeg;
01230 }
01231 }
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249 }
01250
01251 for(int iE = 0;iE<2;iE++){
01252 for(int iS = 0;iS<4;iS++){
01253 for(int iR = 0; iR<4;iR++){
01254 for(int iC =0;iC<36;iC++){
01255 int NumberOfLayers = 0;
01256 for(int iL=0;iL<6;iL++){
01257 if(AllRecHits[iE][iS][iR][iC][iL]){
01258 NumberOfLayers++;
01259 }
01260 }
01261 int bin = 0;
01262 if (iS==0) bin = iR+1+(iE*10);
01263 else bin = (iS+1)*2 + (iR+1) + (iE*10);
01264 if(NumberOfLayers>1){
01265
01266 if(AllSegments[iE][iS][iR][iC]){
01267
01268 hSSTE->AddBinContent(bin);
01269 }
01270
01271 hSSTE->AddBinContent(20+bin);
01272
01273 }
01274 if(AllSegments[iE][iS][iR][iC]){
01275 if(NumberOfLayers==6){
01276
01277 hRHSTE->AddBinContent(bin);;
01278 }
01279
01280 hRHSTE->AddBinContent(20+bin);;
01281 }
01282 }
01283 }
01284 }
01285 }
01286
01287
01288 std::vector < pair <CSCDetId, CSCSegment> * > theSeg;
01289 if(1==seg_ME2[0]) theSeg.push_back(&theSegments[0]);
01290 if(1==seg_ME3[0]) theSeg.push_back(&theSegments[1]);
01291 if(1==seg_ME2[1]) theSeg.push_back(&theSegments[2]);
01292 if(1==seg_ME3[1]) theSeg.push_back(&theSegments[3]);
01293
01294
01295
01296
01297 std::map <std::string, float> chamberTypes;
01298 chamberTypes["ME1/a"] = 0.5;
01299 chamberTypes["ME1/b"] = 1.5;
01300 chamberTypes["ME1/2"] = 2.5;
01301 chamberTypes["ME1/3"] = 3.5;
01302 chamberTypes["ME2/1"] = 4.5;
01303 chamberTypes["ME2/2"] = 5.5;
01304 chamberTypes["ME3/1"] = 6.5;
01305 chamberTypes["ME3/2"] = 7.5;
01306 chamberTypes["ME4/1"] = 8.5;
01307
01308 if(theSeg.size()){
01309 std::map <int , GlobalPoint> extrapolatedPoint;
01310 std::map <int , GlobalPoint>::iterator it;
01311 const std::vector<CSCChamber*> ChamberContainer = cscGeom->chambers();
01312
01313 for(unsigned int nCh=0;nCh<ChamberContainer.size();nCh++){
01314 const CSCChamber *cscchamber = ChamberContainer[nCh];
01315 pair <CSCDetId, CSCSegment> * thisSegment = 0;
01316 for(uint iSeg =0;iSeg<theSeg.size();++iSeg ){
01317 if(cscchamber->id().endcap() == theSeg[iSeg]->first.endcap()){
01318 if(1==cscchamber->id().station() || 3==cscchamber->id().station() ){
01319 if(2==theSeg[iSeg]->first.station()){
01320 thisSegment = theSeg[iSeg];
01321 }
01322 }
01323 else if (2==cscchamber->id().station() || 4==cscchamber->id().station()){
01324 if(3==theSeg[iSeg]->first.station()){
01325 thisSegment = theSeg[iSeg];
01326 }
01327 }
01328 }
01329 }
01330
01331 if(thisSegment){
01332 CSCSegment * seg = &(thisSegment->second);
01333 const CSCChamber *segChamber = cscGeom->chamber(thisSegment->first);
01334 LocalPoint localCenter(0.,0.,0);
01335 GlobalPoint cscchamberCenter = cscchamber->toGlobal(localCenter);
01336
01337 it = extrapolatedPoint.find(int(cscchamberCenter.z()));
01338 if(it==extrapolatedPoint.end()){
01339 GlobalPoint segPos = segChamber->toGlobal(seg->localPosition());
01340 GlobalVector segDir = segChamber->toGlobal(seg->localDirection());
01341 double paramaterLine = lineParametrization(segPos.z(),cscchamberCenter.z() , segDir.z());
01342 double xExtrapolated = extrapolate1D(segPos.x(),segDir.x(), paramaterLine);
01343 double yExtrapolated = extrapolate1D(segPos.y(),segDir.y(), paramaterLine);
01344 GlobalPoint globP (xExtrapolated, yExtrapolated, cscchamberCenter.z());
01345 extrapolatedPoint[int(cscchamberCenter.z())] = globP;
01346 }
01347
01348 LocalPoint extrapolatedPointLocal = cscchamber->toLocal(extrapolatedPoint[int(cscchamberCenter.z())]);
01349 const CSCLayer *layer_p = cscchamber->layer(1);
01350 const CSCLayerGeometry *layerGeom = layer_p->geometry ();
01351 const std::vector<float> layerBounds = layerGeom->parameters ();
01352 float shiftFromEdge = 15.;
01353 float shiftFromDeadZone = 10.;
01354
01355 bool pass = withinSensitiveRegion(extrapolatedPointLocal, layerBounds,
01356 cscchamber->id().station(), cscchamber->id().ring(),
01357 shiftFromEdge, shiftFromDeadZone);
01358 if(pass){
01359
01360
01361
01362
01363
01364 int nRHLayers = 0;
01365 for(int iL =0;iL<6;++iL){
01366 if(AllRecHits[cscchamber->id().endcap()-1]
01367 [cscchamber->id().station()-1]
01368 [cscchamber->id().ring()-1][cscchamber->id().chamber()-1][iL]){
01369 ++nRHLayers;
01370 }
01371 }
01372
01373 float verticalScale = chamberTypes[cscchamber->specs()->chamberTypeName()];
01374 if(cscchamberCenter.z()<0){
01375 verticalScale = - verticalScale;
01376 }
01377 verticalScale +=9.5;
01378 hSensitiveAreaEvt->Fill(float(cscchamber->id().chamber()),verticalScale);
01379 if(nRHLayers>1){
01380
01381
01382
01383
01384 hEffDenominator->Fill(float(cscchamber->id().chamber()),verticalScale);
01385
01386 if(AllSegments[cscchamber->id().endcap()-1]
01387 [cscchamber->id().station()-1]
01388 [cscchamber->id().ring()-1][cscchamber->id().chamber()-1]){
01389 hSSTE2->Fill(float(cscchamber->id().chamber()),float(verticalScale));
01390 }
01391
01392 for(int iL =0;iL<6;++iL){
01393 float weight = 1./6.;
01394
01395
01396 if(AllRecHits[cscchamber->id().endcap()-1]
01397 [cscchamber->id().station()-1]
01398 [cscchamber->id().ring()-1][cscchamber->id().chamber()-1][iL]){
01399 hRHSTE2->Fill(float(cscchamber->id().chamber()),float(verticalScale),weight);
01400 }
01401 if (useDigis){
01402
01403 if(allWires[cscchamber->id().endcap()-1]
01404 [cscchamber->id().station()-1]
01405 [cscchamber->id().ring()-1][cscchamber->id().chamber()-1][iL]){
01406
01407 hWireSTE2->Fill(float(cscchamber->id().chamber()),float(verticalScale),weight);
01408 }
01409
01410 if(allStrips[cscchamber->id().endcap()-1]
01411 [cscchamber->id().station()-1]
01412 [cscchamber->id().ring()-1][cscchamber->id().chamber()-1][iL]){
01413
01414 hStripSTE2->Fill(float(cscchamber->id().chamber()),float(verticalScale),weight);
01415 }
01416 }
01417 }
01418 }
01419 }
01420 }
01421 }
01422 }
01423
01424
01425
01426 }
01427
01428 void CSCValidation::getEfficiency(float bin, float Norm, std::vector<float> &eff){
01429
01430 float Efficiency = 0.;
01431 float EffError = 0.;
01432 if(fabs(Norm)>0.000000001){
01433 Efficiency = bin/Norm;
01434 if(bin<Norm){
01435 EffError = sqrt( (1.-Efficiency)*Efficiency/Norm );
01436 }
01437 }
01438 eff[0] = Efficiency;
01439 eff[1] = EffError;
01440 }
01441
01442 void CSCValidation::histoEfficiency(TH1F *readHisto, TH1F *writeHisto){
01443 std::vector<float> eff(2);
01444 int Nbins = readHisto->GetSize()-2;
01445 std::vector<float> bins(Nbins);
01446 std::vector<float> Efficiency(Nbins);
01447 std::vector<float> EffError(Nbins);
01448 float Num = 1;
01449 float Den = 1;
01450 for (int i=0;i<20;i++){
01451 Num = readHisto->GetBinContent(i+1);
01452 Den = readHisto->GetBinContent(i+21);
01453 getEfficiency(Num, Den, eff);
01454 Efficiency[i] = eff[0];
01455 EffError[i] = eff[1];
01456 writeHisto->SetBinContent(i+1, Efficiency[i]);
01457 writeHisto->SetBinError(i+1, EffError[i]);
01458 }
01459 }
01460
01461 bool CSCValidation::withinSensitiveRegion(LocalPoint localPos, const std::vector<float> layerBounds, int station, int ring, float shiftFromEdge, float shiftFromDeadZone){
01462
01463 bool pass = false;
01464
01465 float y_center = 0.;
01466 double yUp = layerBounds[3] + y_center;
01467 double yDown = - layerBounds[3] + y_center;
01468 double xBound1Shifted = layerBounds[0] - shiftFromEdge;
01469 double xBound2Shifted = layerBounds[1] - shiftFromEdge;
01470 double lineSlope = (yUp - yDown)/(xBound2Shifted-xBound1Shifted);
01471 double lineConst = yUp - lineSlope*xBound2Shifted;
01472 double yBorder = lineSlope*abs(localPos.x()) + lineConst;
01473
01474
01475 std::vector <float> deadZoneCenter(6);
01476 float cutZone = shiftFromDeadZone;
01477
01478 if(station>1 && station<5){
01479 if(2==ring){
01480 deadZoneCenter[0]= -162.48 ;
01481 deadZoneCenter[1] = -81.8744;
01482 deadZoneCenter[2] = -21.18165;
01483 deadZoneCenter[3] = 39.51105;
01484 deadZoneCenter[4] = 100.2939;
01485 deadZoneCenter[5] = 160.58;
01486
01487 if(localPos.y() >yBorder &&
01488 ((localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone) ||
01489 (localPos.y()> deadZoneCenter[1] + cutZone && localPos.y()< deadZoneCenter[2] - cutZone) ||
01490 (localPos.y()> deadZoneCenter[2] + cutZone && localPos.y()< deadZoneCenter[3] - cutZone) ||
01491 (localPos.y()> deadZoneCenter[3] + cutZone && localPos.y()< deadZoneCenter[4] - cutZone) ||
01492 (localPos.y()> deadZoneCenter[4] + cutZone && localPos.y()< deadZoneCenter[5] - cutZone))){
01493 pass = true;
01494 }
01495 }
01496 else if(1==ring){
01497 if(2==station){
01498 deadZoneCenter[0]= -95.80 ;
01499 deadZoneCenter[1] = -27.47;
01500 deadZoneCenter[2] = 33.67;
01501 deadZoneCenter[3] = 90.85;
01502 }
01503 else if(3==station){
01504 deadZoneCenter[0]= -89.305 ;
01505 deadZoneCenter[1] = -39.705;
01506 deadZoneCenter[2] = 20.195;
01507 deadZoneCenter[3] = 77.395;
01508 }
01509 else if(4==station){
01510 deadZoneCenter[0]= -75.645;
01511 deadZoneCenter[1] = -26.055;
01512 deadZoneCenter[2] = 23.855;
01513 deadZoneCenter[3] = 70.575;
01514 }
01515 if(localPos.y() >yBorder &&
01516 ((localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone) ||
01517 (localPos.y()> deadZoneCenter[1] + cutZone && localPos.y()< deadZoneCenter[2] - cutZone) ||
01518 (localPos.y()> deadZoneCenter[2] + cutZone && localPos.y()< deadZoneCenter[3] - cutZone))){
01519 pass = true;
01520 }
01521 }
01522 }
01523 else if(1==station){
01524 if(3==ring){
01525 deadZoneCenter[0]= -83.155 ;
01526 deadZoneCenter[1] = -22.7401;
01527 deadZoneCenter[2] = 27.86665;
01528 deadZoneCenter[3] = 81.005;
01529 if(localPos.y() > yBorder &&
01530 ((localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone) ||
01531 (localPos.y()> deadZoneCenter[1] + cutZone && localPos.y()< deadZoneCenter[2] - cutZone) ||
01532 (localPos.y()> deadZoneCenter[2] + cutZone && localPos.y()< deadZoneCenter[3] - cutZone))){
01533 pass = true;
01534 }
01535 }
01536 else if(2==ring){
01537 deadZoneCenter[0]= -86.285 ;
01538 deadZoneCenter[1] = -32.88305;
01539 deadZoneCenter[2] = 32.867423;
01540 deadZoneCenter[3] = 88.205;
01541 if(localPos.y() > (yBorder) &&
01542 ((localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone) ||
01543 (localPos.y()> deadZoneCenter[1] + cutZone && localPos.y()< deadZoneCenter[2] - cutZone) ||
01544 (localPos.y()> deadZoneCenter[2] + cutZone && localPos.y()< deadZoneCenter[3] - cutZone))){
01545 pass = true;
01546 }
01547 }
01548 else{
01549 deadZoneCenter[0]= -81.0;
01550 deadZoneCenter[1] = 81.0;
01551 if(localPos.y() > (yBorder) &&
01552 (localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone )){
01553 pass = true;
01554 }
01555 }
01556 }
01557 return pass;
01558 }
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569 float CSCValidation::getSignal(const CSCStripDigiCollection& stripdigis, CSCDetId idCS, int centerStrip){
01570
01571 float SigADC[5];
01572 float TotalADC = 0;
01573 SigADC[0] = 0;
01574 SigADC[1] = 0;
01575 SigADC[2] = 0;
01576 SigADC[3] = 0;
01577 SigADC[4] = 0;
01578
01579
01580
01581 CSCStripDigiCollection::DigiRangeIterator sIt;
01582
01583 for (sIt = stripdigis.begin(); sIt != stripdigis.end(); sIt++){
01584 CSCDetId id = (CSCDetId)(*sIt).first;
01585 if (id == idCS){
01586
01587
01588 vector<CSCStripDigi>::const_iterator digiItr = (*sIt).second.first;
01589 vector<CSCStripDigi>::const_iterator last = (*sIt).second.second;
01590 for ( ; digiItr != last; ++digiItr ) {
01591 int thisStrip = digiItr->getStrip();
01592 if (thisStrip == (centerStrip)){
01593 std::vector<int> myADCVals = digiItr->getADCCounts();
01594 float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01595 float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01596 SigADC[0] = thisSignal - 6*thisPedestal;
01597 }
01598
01599 if (thisStrip == (centerStrip+1)){
01600 std::vector<int> myADCVals = digiItr->getADCCounts();
01601 float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01602 float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01603 SigADC[1] = thisSignal - 6*thisPedestal;
01604 }
01605 if (thisStrip == (centerStrip+2)){
01606 std::vector<int> myADCVals = digiItr->getADCCounts();
01607 float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01608 float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01609 SigADC[2] = thisSignal - 6*thisPedestal;
01610 }
01611 if (thisStrip == (centerStrip-1)){
01612 std::vector<int> myADCVals = digiItr->getADCCounts();
01613 float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01614 float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01615 SigADC[3] = thisSignal - 6*thisPedestal;
01616 }
01617 if (thisStrip == (centerStrip-2)){
01618 std::vector<int> myADCVals = digiItr->getADCCounts();
01619 float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01620 float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01621 SigADC[4] = thisSignal - 6*thisPedestal;
01622 }
01623 }
01624 TotalADC = 0.2*(SigADC[0]+SigADC[1]+SigADC[2]+SigADC[3]+SigADC[4]);
01625 }
01626 }
01627 return TotalADC;
01628 }
01629
01630
01631
01632
01633
01634
01635 void CSCValidation::doNoiseHits(edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<CSCSegmentCollection> cscSegments,
01636 edm::ESHandle<CSCGeometry> cscGeom, edm::Handle<CSCStripDigiCollection> strips){
01637
01638 CSCRecHit2DCollection::const_iterator recIt;
01639 for (recIt = recHits->begin(); recIt != recHits->end(); recIt++) {
01640
01641 CSCDetId idrec = (CSCDetId)(*recIt).cscDetId();
01642
01643
01644 AllRechits.insert(pair<CSCDetId , CSCRecHit2D>(idrec,*recIt));
01645
01646
01647 CSCRecHit2D::ChannelContainer hitstrips = (*recIt).channels();
01648 int nStrips = hitstrips.size();
01649
01650 int centerid = nStrips/2 + 1;
01651 int centerStrip = hitstrips[centerid - 1];
01652
01653 float rHsignal = getthisSignal(*strips, idrec, centerStrip);
01654 histos->fill1DHist(rHsignal,"hrHSignal", "Signal in the 4th time bin for centre strip",1100,-99,1000,"recHits");
01655
01656 }
01657
01658 for(CSCSegmentCollection::const_iterator it=cscSegments->begin(); it != cscSegments->end(); it++) {
01659
01660 std::vector<CSCRecHit2D> theseRecHits = (*it).specificRecHits();
01661 for ( vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++) {
01662 CSCDetId idRH = (CSCDetId)(*iRH).cscDetId();
01663 LocalPoint lpRH = (*iRH).localPosition();
01664 float xrec = lpRH.x();
01665 float yrec = lpRH.y();
01666 float zrec = lpRH.z();
01667 bool RHalreadyinMap = false;
01668
01669 multimap<CSCDetId , CSCRecHit2D>::iterator segRHit;
01670 segRHit = SegRechits.find(idRH);
01671 if (segRHit != SegRechits.end()){
01672 for( ; segRHit != SegRechits.upper_bound(idRH); ++segRHit){
01673
01674 LocalPoint lposRH = (segRHit->second).localPosition();
01675 float xpos = lposRH.x();
01676 float ypos = lposRH.y();
01677 float zpos = lposRH.z();
01678 if ( xrec == xpos && yrec == ypos && zrec == zpos){
01679 RHalreadyinMap = true;
01680
01681 break;}
01682 }
01683 }
01684 if(!RHalreadyinMap){ SegRechits.insert(pair<CSCDetId , CSCRecHit2D>(idRH,*iRH));}
01685 }
01686 }
01687
01688 findNonAssociatedRecHits(cscGeom,strips);
01689
01690 }
01691
01692
01693
01694
01695
01696
01697
01698 void CSCValidation::findNonAssociatedRecHits(edm::ESHandle<CSCGeometry> cscGeom, edm::Handle<CSCStripDigiCollection> strips){
01699
01700 for(multimap<CSCDetId , CSCRecHit2D>::iterator allRHiter = AllRechits.begin();allRHiter != AllRechits.end(); ++allRHiter){
01701 CSCDetId idRH = allRHiter->first;
01702 LocalPoint lpRH = (allRHiter->second).localPosition();
01703 float xrec = lpRH.x();
01704 float yrec = lpRH.y();
01705 float zrec = lpRH.z();
01706
01707 bool foundmatch = false;
01708 multimap<CSCDetId , CSCRecHit2D>::iterator segRHit;
01709 segRHit = SegRechits.find(idRH);
01710 if (segRHit != SegRechits.end()){
01711 for( ; segRHit != SegRechits.upper_bound(idRH); ++segRHit){
01712
01713 LocalPoint lposRH = (segRHit->second).localPosition();
01714 float xpos = lposRH.x();
01715 float ypos = lposRH.y();
01716 float zpos = lposRH.z();
01717
01718 if ( xrec == xpos && yrec == ypos && zrec == zpos){
01719 foundmatch = true;}
01720
01721 float d = 0.;
01722 float dclose =1000.;
01723
01724 if ( !foundmatch) {
01725
01726 d = sqrt(pow(xrec-xpos,2)+pow(yrec-ypos,2)+pow(zrec-zpos,2));
01727 if (d < dclose) {
01728 dclose = d;
01729 if( distRHmap.find((allRHiter->second)) == distRHmap.end() ) {
01730 distRHmap.insert(make_pair(allRHiter->second,dclose) );
01731 }
01732 else {
01733
01734 distRHmap.erase(allRHiter->second);
01735 distRHmap.insert(make_pair(allRHiter->second,dclose));
01736 }
01737 }
01738 }
01739 }
01740 }
01741 if(!foundmatch){NonAssociatedRechits.insert(pair<CSCDetId , CSCRecHit2D>(idRH,allRHiter->second));}
01742 }
01743
01744 for(map<CSCRecHit2D,float,ltrh>::iterator iter = distRHmap.begin();iter != distRHmap.end(); ++iter){
01745 histos->fill1DHist(iter->second,"hdistRH","Distance of Non Associated RecHit from closest Segment RecHit",500,0.,100.,"NonAssociatedRechits");
01746 }
01747
01748 for(multimap<CSCDetId , CSCRecHit2D>::iterator iter = NonAssociatedRechits.begin();iter != NonAssociatedRechits.end(); ++iter){
01749 CSCDetId idrec = iter->first;
01750 int kEndcap = idrec.endcap();
01751 int cEndcap = idrec.endcap();
01752 if (kEndcap == 2)cEndcap = -1;
01753 int kRing = idrec.ring();
01754 int kStation = idrec.station();
01755 int kChamber = idrec.chamber();
01756 int kLayer = idrec.layer();
01757
01758
01759 LocalPoint rhitlocal = (iter->second).localPosition();
01760 float xreco = rhitlocal.x();
01761 float yreco = rhitlocal.y();
01762
01763
01764 CSCRecHit2D::ChannelContainer hitstrips = (iter->second).channels();
01765 int nStrips = hitstrips.size();
01766 int centerid = nStrips/2 + 1;
01767 int centerStrip = hitstrips[centerid - 1];
01768
01769
01770
01771
01772 CSCRecHit2D::ADCContainer adcs = (iter->second).adcs();
01773 int adcsize = adcs.size();
01774 float rHSumQ = 0;
01775 float sumsides = 0;
01776 for (int i = 0; i < adcsize; i++){
01777 if (i != 3 && i != 7 && i != 11){
01778 rHSumQ = rHSumQ + adcs[i];
01779 }
01780 if (adcsize == 12 && (i < 3 || i > 7) && i < 12){
01781 sumsides = sumsides + adcs[i];
01782 }
01783 }
01784 float rHratioQ = sumsides/rHSumQ;
01785 if (adcsize != 12) rHratioQ = -99;
01786
01787
01788
01789 float rHtime = getTiming(*strips, idrec, centerStrip);
01790
01791
01792 int rHwidth = getWidth(*strips, idrec, centerStrip);
01793
01794
01795
01796 const CSCLayer* csclayer = cscGeom->layer( idrec );
01797
01798
01799 GlobalPoint rhitglobal= csclayer->toGlobal(rhitlocal);
01800 float grecx = rhitglobal.x();
01801 float grecy = rhitglobal.y();
01802
01803
01804
01805
01806 int kCodeBroad = cEndcap * ( 4*(kStation-1) + kRing) ;
01807 int kCodeNarrow = cEndcap * ( 100*(kRing-1) + kChamber) ;
01808
01809
01810 histos->fill1DHist(kCodeBroad,"hNARHCodeBroad","broad scope code for recHits",33,-16.5,16.5,"NonAssociatedRechits");
01811 if (kStation == 1) histos->fill1DHist(kCodeNarrow,"hNARHCodeNarrow1","narrow scope recHit code station 1",801,-400.5,400.5,"NonAssociatedRechits");
01812 if (kStation == 2) histos->fill1DHist(kCodeNarrow,"hNARHCodeNarrow2","narrow scope recHit code station 2",801,-400.5,400.5,"NonAssociatedRechits");
01813 if (kStation == 3) histos->fill1DHist(kCodeNarrow,"hNARHCodeNarrow3","narrow scope recHit code station 3",801,-400.5,400.5,"NonAssociatedRechits");
01814 if (kStation == 4) histos->fill1DHist(kCodeNarrow,"hNARHCodeNarrow4","narrow scope recHit code station 4",801,-400.5,400.5,"NonAssociatedRechits");
01815 histos->fill1DHistByType(kLayer,"hNARHLayer","RecHits per Layer",idrec,8,-0.5,7.5,"NonAssociatedRechits");
01816 histos->fill1DHistByType(xreco,"hNARHX","Local X of recHit",idrec,160,-80.,80.,"NonAssociatedRechits");
01817 histos->fill1DHistByType(yreco,"hNARHY","Local Y of recHit",idrec,60,-180.,180.,"NonAssociatedRechits");
01818 if (kStation == 1 && (kRing == 1 || kRing == 4)) histos->fill1DHistByType(rHSumQ,"hNARHSumQ","Sum 3x3 recHit Charge",idrec,250,0,4000,"NonAssociatedRechits");
01819 else histos->fill1DHistByType(rHSumQ,"hNARHSumQ","Sum 3x3 recHit Charge",idrec,250,0,2000,"NonAssociatedRechits");
01820 histos->fill1DHistByType(rHratioQ,"hNARHRatioQ","Ratio (Ql+Qr)/Qt)",idrec,120,-0.1,1.1,"NonAssociatedRechits");
01821 histos->fill1DHistByType(rHtime,"hNARHTiming","recHit Timing",idrec,100,0,10,"NonAssociatedRechits");
01822 histos->fill2DHistByStation(grecx,grecy,"hNARHGlobal","recHit Global Position",idrec,400,-800.,800.,400,-800.,800.,"NonAssociatedRechits");
01823 histos->fill1DHistByType(rHwidth,"hNARHwidth","width for Non associated recHit",idrec,21,-0.5,20.5,"NonAssociatedRechits");
01824
01825 }
01826
01827 for(multimap<CSCDetId , CSCRecHit2D>::iterator iter = SegRechits.begin();iter != SegRechits.end(); ++iter){
01828 CSCDetId idrec = iter->first;
01829 int kEndcap = idrec.endcap();
01830 int cEndcap = idrec.endcap();
01831 if (kEndcap == 2)cEndcap = -1;
01832 int kRing = idrec.ring();
01833 int kStation = idrec.station();
01834 int kChamber = idrec.chamber();
01835 int kLayer = idrec.layer();
01836
01837
01838 LocalPoint rhitlocal = (iter->second).localPosition();
01839 float xreco = rhitlocal.x();
01840 float yreco = rhitlocal.y();
01841
01842
01843 CSCRecHit2D::ChannelContainer hitstrips = (iter->second).channels();
01844 int nStrips = hitstrips.size();
01845 int centerid = nStrips/2 + 1;
01846 int centerStrip = hitstrips[centerid - 1];
01847
01848
01849
01850
01851 CSCRecHit2D::ADCContainer adcs = (iter->second).adcs();
01852 int adcsize = adcs.size();
01853 float rHSumQ = 0;
01854 float sumsides = 0;
01855 for (int i = 0; i < adcsize; i++){
01856 if (i != 3 && i != 7 && i != 11){
01857 rHSumQ = rHSumQ + adcs[i];
01858 }
01859 if (adcsize == 12 && (i < 3 || i > 7) && i < 12){
01860 sumsides = sumsides + adcs[i];
01861 }
01862 }
01863 float rHratioQ = sumsides/rHSumQ;
01864 if (adcsize != 12) rHratioQ = -99;
01865
01866
01867
01868 float rHtime = getTiming(*strips, idrec, centerStrip);
01869
01870
01871 int rHwidth = getWidth(*strips, idrec, centerStrip);
01872
01873
01874
01875 const CSCLayer* csclayer = cscGeom->layer( idrec );
01876
01877
01878 GlobalPoint rhitglobal= csclayer->toGlobal(rhitlocal);
01879 float grecx = rhitglobal.x();
01880 float grecy = rhitglobal.y();
01881
01882
01883 int kCodeBroad = cEndcap * ( 4*(kStation-1) + kRing) ;
01884 int kCodeNarrow = cEndcap * ( 100*(kRing-1) + kChamber) ;
01885
01886
01887 histos->fill1DHist(kCodeBroad,"hSegRHCodeBroad","broad scope code for recHits",33,-16.5,16.5,"AssociatedRechits");
01888 if (kStation == 1) histos->fill1DHist(kCodeNarrow,"hSegRHCodeNarrow1","narrow scope recHit code station 1",801,-400.5,400.5,"AssociatedRechits");
01889 if (kStation == 2) histos->fill1DHist(kCodeNarrow,"hSegRHCodeNarrow2","narrow scope recHit code station 2",801,-400.5,400.5,"AssociatedRechits");
01890 if (kStation == 3) histos->fill1DHist(kCodeNarrow,"hSegRHCodeNarrow3","narrow scope recHit code station 3",801,-400.5,400.5,"AssociatedRechits");
01891 if (kStation == 4) histos->fill1DHist(kCodeNarrow,"hSegRHCodeNarrow4","narrow scope recHit code station 4",801,-400.5,400.5,"AssociatedRechits");
01892 histos->fill1DHistByType(kLayer,"hSegRHLayer","RecHits per Layer",idrec,8,-0.5,7.5,"AssociatedRechits");
01893 histos->fill1DHistByType(xreco,"hSegRHX","Local X of recHit",idrec,160,-80.,80.,"AssociatedRechits");
01894 histos->fill1DHistByType(yreco,"hSegRHY","Local Y of recHit",idrec,60,-180.,180.,"AssociatedRechits");
01895 if (kStation == 1 && (kRing == 1 || kRing == 4)) histos->fill1DHistByType(rHSumQ,"hSegRHSumQ","Sum 3x3 recHit Charge",idrec,250,0,4000,"AssociatedRechits");
01896 else histos->fill1DHistByType(rHSumQ,"hSegRHSumQ","Sum 3x3 recHit Charge",idrec,250,0,2000,"AssociatedRechits");
01897 histos->fill1DHistByType(rHratioQ,"hSegRHRatioQ","Ratio (Ql+Qr)/Qt)",idrec,120,-0.1,1.1,"AssociatedRechits");
01898 histos->fill1DHistByType(rHtime,"hSegRHTiming","recHit Timing",idrec,100,0,10,"AssociatedRechits");
01899 histos->fill2DHistByStation(grecx,grecy,"hSegRHGlobal","recHit Global Position",idrec,400,-800.,800.,400,-800.,800.,"AssociatedRechits");
01900 histos->fill1DHistByType(rHwidth,"hSegRHwidth","width for Non associated recHit",idrec,21,-0.5,20.5,"AssociatedRechits");
01901
01902 }
01903
01904 distRHmap.clear();
01905 AllRechits.clear();
01906 SegRechits.clear();
01907 NonAssociatedRechits.clear();
01908 }
01909
01910
01911
01912 float CSCValidation::getthisSignal(const CSCStripDigiCollection& stripdigis, CSCDetId idRH, int centerStrip){
01913
01914 CSCStripDigiCollection::DigiRangeIterator sIt;
01915 float thisADC = 0.;
01916 bool foundRHid = false;
01917
01918 for (sIt = stripdigis.begin(); sIt != stripdigis.end(); sIt++){
01919 CSCDetId id = (CSCDetId)(*sIt).first;
01920
01921 if (id == idRH){
01922 foundRHid = true;
01923 vector<CSCStripDigi>::const_iterator digiItr = (*sIt).second.first;
01924 vector<CSCStripDigi>::const_iterator last = (*sIt).second.second;
01925
01926 int St = idRH.station();
01927 int Rg = idRH.ring();
01928 if (St == 1 && Rg == 4){
01929 while(centerStrip> 16) centerStrip -= 16;
01930 }
01931 for ( ; digiItr != last; ++digiItr ) {
01932 int thisStrip = digiItr->getStrip();
01933
01934 std::vector<int> myADCVals = digiItr->getADCCounts();
01935 float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01936 float Signal = (float) myADCVals[3];
01937 if (thisStrip == (centerStrip)){
01938 thisADC = Signal-thisPedestal;
01939
01940
01941
01942
01943 }
01944 if (thisStrip == (centerStrip+1)){
01945 std::vector<int> myADCVals = digiItr->getADCCounts();
01946 }
01947 if (thisStrip == (centerStrip-1)){
01948 std::vector<int> myADCVals = digiItr->getADCCounts();
01949 }
01950 }
01951 }
01952 }
01953
01954 return thisADC;
01955 }
01956
01957
01958
01959
01960
01961
01962
01963 int CSCValidation::getWidth(const CSCStripDigiCollection& stripdigis, CSCDetId idRH, int centerStrip){
01964
01965 int width = 1;
01966 int widthpos = 0;
01967 int widthneg = 0;
01968
01969
01970 CSCStripDigiCollection::DigiRangeIterator sIt;
01971
01972 for (sIt = stripdigis.begin(); sIt != stripdigis.end(); sIt++){
01973 CSCDetId id = (CSCDetId)(*sIt).first;
01974 if (id == idRH){
01975 vector<CSCStripDigi>::const_iterator digiItr = (*sIt).second.first;
01976 vector<CSCStripDigi>::const_iterator first = (*sIt).second.first;
01977 vector<CSCStripDigi>::const_iterator last = (*sIt).second.second;
01978 vector<CSCStripDigi>::const_iterator it = (*sIt).second.first;
01979 vector<CSCStripDigi>::const_iterator itr = (*sIt).second.first;
01980
01981 int St = idRH.station();
01982 int Rg = idRH.ring();
01983 if (St == 1 && Rg == 4){
01984 while(centerStrip> 16) centerStrip -= 16;
01985 }
01986 for ( ; digiItr != last; ++digiItr ) {
01987 int thisStrip = digiItr->getStrip();
01988 if (thisStrip == (centerStrip)){
01989 it = digiItr;
01990 for( ; it != last; ++it ) {
01991 int strip = it->getStrip();
01992 std::vector<int> myADCVals = it->getADCCounts();
01993 float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01994 if(((float)myADCVals[3]-thisPedestal) < 6 || widthpos == 10 || it==last){break;}
01995 if(strip != centerStrip){ widthpos += 1;
01996 }
01997 }
01998 itr = digiItr;
01999 for( ; itr != first; --itr) {
02000 int strip = itr->getStrip();
02001 std::vector<int> myADCVals = itr->getADCCounts();
02002 float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
02003 if(((float)myADCVals[3]-thisPedestal) < 6 || widthneg == 10 || itr==first){break;}
02004 if(strip != centerStrip) {widthneg += 1 ;
02005 }
02006 }
02007 }
02008 }
02009 }
02010 }
02011
02012 width = width + widthneg + widthpos ;
02013
02014 return width;
02015 }
02016
02017
02018
02019
02020
02021
02022
02023 void CSCValidation::doGasGain(const CSCWireDigiCollection& wirecltn,
02024 const CSCStripDigiCollection& strpcltn,
02025 const CSCRecHit2DCollection& rechitcltn) {
02026 float y;
02027 int channel=0,mult,wire,layer,idlayer,idchamber,ring;
02028 int wire_strip_rechit_present;
02029 string name,title,endcapstr;
02030 ostringstream ss;
02031 CSCIndexer indexer;
02032 std::map<int,int>::iterator intIt;
02033
02034 m_single_wire_layer.clear();
02035
02036 if(nEventsAnalyzed==1) {
02037
02038
02039
02040 m_wire_hvsegm.clear();
02041 std::map<int,std::vector<int> >::iterator intvecIt;
02042
02043 int csctype[10]= {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
02044 int hvsegm_layer[10]={1, 1, 3, 3, 3, 5, 3, 5, 3, 5};
02045 int id;
02046 nmbhvsegm.clear();
02047 for(int i=0;i<10;i++) nmbhvsegm.push_back(hvsegm_layer[i]);
02048
02049 std::vector<int> zer_1_1a(49,0);
02050 id=csctype[0];
02051 if(m_wire_hvsegm.find(id) == m_wire_hvsegm.end()) m_wire_hvsegm[id]=zer_1_1a;
02052 intvecIt=m_wire_hvsegm.find(id);
02053 for(int wire=1;wire<=48;wire++) intvecIt->second[wire]=1;
02054
02055
02056 std::vector<int> zer_1_1b(49,0);
02057 id=csctype[1];
02058 if(m_wire_hvsegm.find(id) == m_wire_hvsegm.end()) m_wire_hvsegm[id]=zer_1_1b;
02059 intvecIt=m_wire_hvsegm.find(id);
02060 for(int wire=1;wire<=48;wire++) intvecIt->second[wire]=1;
02061
02062
02063 std::vector<int> zer_1_2(65,0);
02064 id=csctype[2];
02065 if(m_wire_hvsegm.find(id) == m_wire_hvsegm.end()) m_wire_hvsegm[id]=zer_1_2;
02066 intvecIt=m_wire_hvsegm.find(id);
02067 for(int wire=1;wire<=24;wire++) intvecIt->second[wire]=1;
02068 for(int wire=25;wire<=48;wire++) intvecIt->second[wire]=2;
02069 for(int wire=49;wire<=64;wire++) intvecIt->second[wire]=3;
02070
02071
02072 std::vector<int> zer_1_3(33,0);
02073 id=csctype[3];
02074 if(m_wire_hvsegm.find(id) == m_wire_hvsegm.end()) m_wire_hvsegm[id]=zer_1_3;
02075 intvecIt=m_wire_hvsegm.find(id);
02076 for(int wire=1;wire<=12;wire++) intvecIt->second[wire]=1;
02077 for(int wire=13;wire<=22;wire++) intvecIt->second[wire]=2;
02078 for(int wire=23;wire<=32;wire++) intvecIt->second[wire]=3;
02079
02080
02081 std::vector<int> zer_2_1(113,0);
02082 id=csctype[4];
02083 if(m_wire_hvsegm.find(id) == m_wire_hvsegm.end()) m_wire_hvsegm[id]=zer_2_1;
02084 intvecIt=m_wire_hvsegm.find(id);
02085 for(int wire=1;wire<=44;wire++) intvecIt->second[wire]=1;
02086 for(int wire=45;wire<=80;wire++) intvecIt->second[wire]=2;
02087 for(int wire=81;wire<=112;wire++) intvecIt->second[wire]=3;
02088
02089
02090 std::vector<int> zer_2_2(65,0);
02091 id=csctype[5];
02092 if(m_wire_hvsegm.find(id) == m_wire_hvsegm.end()) m_wire_hvsegm[id]=zer_2_2;
02093 intvecIt=m_wire_hvsegm.find(id);
02094 for(int wire=1;wire<=16;wire++) intvecIt->second[wire]=1;
02095 for(int wire=17;wire<=28;wire++) intvecIt->second[wire]=2;
02096 for(int wire=29;wire<=40;wire++) intvecIt->second[wire]=3;
02097 for(int wire=41;wire<=52;wire++) intvecIt->second[wire]=4;
02098 for(int wire=53;wire<=64;wire++) intvecIt->second[wire]=5;
02099
02100
02101 std::vector<int> zer_3_1(97,0);
02102 id=csctype[6];
02103 if(m_wire_hvsegm.find(id) == m_wire_hvsegm.end()) m_wire_hvsegm[id]=zer_3_1;
02104 intvecIt=m_wire_hvsegm.find(id);
02105 for(int wire=1;wire<=32;wire++) intvecIt->second[wire]=1;
02106 for(int wire=33;wire<=64;wire++) intvecIt->second[wire]=2;
02107 for(int wire=65;wire<=96;wire++) intvecIt->second[wire]=3;
02108
02109
02110 std::vector<int> zer_3_2(65,0);
02111 id=csctype[7];
02112 if(m_wire_hvsegm.find(id) == m_wire_hvsegm.end()) m_wire_hvsegm[id]=zer_3_2;
02113 intvecIt=m_wire_hvsegm.find(id);
02114 for(int wire=1;wire<=16;wire++) intvecIt->second[wire]=1;
02115 for(int wire=17;wire<=28;wire++) intvecIt->second[wire]=2;
02116 for(int wire=29;wire<=40;wire++) intvecIt->second[wire]=3;
02117 for(int wire=41;wire<=52;wire++) intvecIt->second[wire]=4;
02118 for(int wire=53;wire<=64;wire++) intvecIt->second[wire]=5;
02119
02120
02121 std::vector<int> zer_4_1(97,0);
02122 id=csctype[8];
02123 if(m_wire_hvsegm.find(id) == m_wire_hvsegm.end()) m_wire_hvsegm[id]=zer_4_1;
02124 intvecIt=m_wire_hvsegm.find(id);
02125 for(int wire=1;wire<=32;wire++) intvecIt->second[wire]=1;
02126 for(int wire=33;wire<=64;wire++) intvecIt->second[wire]=2;
02127 for(int wire=65;wire<=96;wire++) intvecIt->second[wire]=3;
02128
02129
02130 std::vector<int> zer_4_2(65,0);
02131 id=csctype[9];
02132 if(m_wire_hvsegm.find(id) == m_wire_hvsegm.end()) m_wire_hvsegm[id]=zer_4_2;
02133 intvecIt=m_wire_hvsegm.find(id);
02134 for(int wire=1;wire<=16;wire++) intvecIt->second[wire]=1;
02135 for(int wire=17;wire<=28;wire++) intvecIt->second[wire]=2;
02136 for(int wire=29;wire<=40;wire++) intvecIt->second[wire]=3;
02137 for(int wire=41;wire<=52;wire++) intvecIt->second[wire]=4;
02138 for(int wire=53;wire<=64;wire++) intvecIt->second[wire]=5;
02139
02140 }
02141
02142
02143
02144 wire_strip_rechit_present=0;
02145 if(wirecltn.begin() != wirecltn.end())
02146 wire_strip_rechit_present= wire_strip_rechit_present+1;
02147 if(strpcltn.begin() != strpcltn.end())
02148 wire_strip_rechit_present= wire_strip_rechit_present+2;
02149 if(rechitcltn.begin() != rechitcltn.end())
02150 wire_strip_rechit_present= wire_strip_rechit_present+4;
02151
02152 if(wire_strip_rechit_present==7) {
02153
02154
02155
02156
02157
02158 CSCWireDigiCollection::DigiRangeIterator wiredetUnitIt;
02159
02160 for(wiredetUnitIt=wirecltn.begin();wiredetUnitIt!=wirecltn.end();
02161 ++wiredetUnitIt) {
02162 const CSCDetId id = (*wiredetUnitIt).first;
02163 idlayer=indexer.dbIndex(id, channel);
02164 idchamber=idlayer/10;
02165 layer=id.layer();
02166
02167 mult=0; wire=0;
02168 const CSCWireDigiCollection::Range& range = (*wiredetUnitIt).second;
02169 for(CSCWireDigiCollection::const_iterator digiIt =
02170 range.first; digiIt!=range.second; ++digiIt){
02171 wire=(*digiIt).getWireGroup();
02172 mult++;
02173 }
02174
02175
02176 if(mult==1) {
02177 if(m_single_wire_layer.find(idlayer) == m_single_wire_layer.end())
02178 m_single_wire_layer[idlayer]=wire;
02179 }
02180 }
02181
02182
02183 CSCRecHit2DCollection::const_iterator recIt;
02184 CSCRecHit2D::ADCContainer m_adc;
02185 CSCRecHit2D::ChannelContainer m_strip;
02186 for(recIt = rechitcltn.begin(); recIt != rechitcltn.end(); ++recIt) {
02187 CSCDetId id = (CSCDetId)(*recIt).cscDetId();
02188 idlayer=indexer.dbIndex(id, channel);
02189 idchamber=idlayer/10;
02190 layer=id.layer();
02191
02192 if(m_single_wire_layer.find(idlayer) != m_single_wire_layer.end()) {
02193
02194
02195 m_strip=(CSCRecHit2D::ChannelContainer)(*recIt).channels();
02196 if(m_strip.size()==3) {
02197
02198 m_adc=(CSCRecHit2D::ADCContainer)(*recIt).adcs();
02199 std::vector<float> adc_left,adc_center,adc_right;
02200 int binmx=0;
02201 float adcmax=0.0;
02202 unsigned k=0;
02203
02204 for(int i=0;i<3;i++)
02205 for(int j=0;j<4;j++){
02206 if(m_adc[k]>adcmax) {adcmax=m_adc[k]; binmx=j;}
02207 if(i==0) adc_left.push_back(m_adc[k]);
02208 if(i==1) adc_center.push_back(m_adc[k]);
02209 if(i==2) adc_right.push_back(m_adc[k]);
02210 k=k+1;
02211 }
02212 float adc_3_3_sum=0.0;
02213 for(int j=binmx-1;j<=binmx+1;j++) {
02214 adc_3_3_sum=adc_3_3_sum+adc_left[j]
02215 +adc_center[j]
02216 +adc_right[j];
02217 }
02218
02219 if(adc_3_3_sum > 0.0 && adc_3_3_sum < 2000.0) {
02220
02221
02222 int flag=0;
02223 if(id.station()==1 && id.ring()==4 && m_strip[1]>16) flag=1;
02224
02225 if(flag==0) {
02226
02227 wire= m_single_wire_layer[idlayer];
02228 int chambertype=id.iChamberType(id.station(),id.ring());
02229 int hvsgmtnmb=m_wire_hvsegm[chambertype][wire];
02230 int nmbofhvsegm=nmbhvsegm[chambertype-1];
02231 int location= (layer-1)*nmbofhvsegm+hvsgmtnmb;
02232 float x=location;
02233
02234 ss<<"gas_gain_rechit_adc_3_3_sum_location_ME_"<<idchamber;
02235 name=ss.str(); ss.str("");
02236 if(id.endcap()==1) endcapstr = "+";
02237 ring=id.ring();
02238 if(id.station()==1 && id.ring()==4) ring=1;
02239 if(id.endcap()==2) endcapstr = "-";
02240 ss<<"Gas Gain Rechit ADC3X3 Sum ME"<<endcapstr<<
02241 id.station()<<"/"<<ring<<"/"<<id.chamber();
02242 title=ss.str(); ss.str("");
02243 x=location;
02244 y=adc_3_3_sum;
02245 histos->fill2DHist(x,y,name.c_str(),title.c_str(),30,1.0,31.0,50,0.0,2000.0,"GasGain");
02246
02247
02248
02249
02250
02251
02252
02253 }
02254 }
02255 }
02256 }
02257 }
02258 }
02259 }
02260
02261
02262
02263
02264
02265
02266 void CSCValidation::doAFEBTiming(const CSCWireDigiCollection& wirecltn) {
02267 ostringstream ss;
02268 string name,title,endcapstr;
02269 float x,y;
02270 int wire,wiretbin,nmbwiretbin,layer,afeb,idlayer,idchamber;
02271 int channel=0;
02272 CSCIndexer indexer;
02273
02274 if(wirecltn.begin() != wirecltn.end()) {
02275
02276
02277
02278
02279
02280
02281 CSCWireDigiCollection::DigiRangeIterator wiredetUnitIt;
02282 for(wiredetUnitIt=wirecltn.begin();wiredetUnitIt!=wirecltn.end();
02283 ++wiredetUnitIt) {
02284 const CSCDetId id = (*wiredetUnitIt).first;
02285 idlayer=indexer.dbIndex(id, channel);
02286 idchamber=idlayer/10;
02287 layer=id.layer();
02288
02289 if (id.endcap() == 1) endcapstr = "+";
02290 if (id.endcap() == 2) endcapstr = "-";
02291
02292
02293
02294 const CSCWireDigiCollection::Range& range = (*wiredetUnitIt).second;
02295 for(CSCWireDigiCollection::const_iterator digiIt =
02296 range.first; digiIt!=range.second; ++digiIt){
02297 wire=(*digiIt).getWireGroup();
02298 wiretbin=(*digiIt).getTimeBin();
02299 nmbwiretbin=(*digiIt).getTimeBinsOn().size();
02300 afeb=3*((wire-1)/8)+(layer+1)/2;
02301
02302
02303 x=afeb;
02304 y=wiretbin;
02305 ss<<"afeb_time_bin_vs_afeb_occupancy_ME_"<<idchamber;
02306 name=ss.str(); ss.str("");
02307 ss<<"Time Bin vs AFEB Occupancy ME"<<endcapstr<<id.station()<<"/"<<id.ring()<<"/"<< id.chamber();
02308 title=ss.str(); ss.str("");
02309 histos->fill2DHist(x,y,name.c_str(),title.c_str(),42,1.,43.,16,0.,16.,"AFEBTiming");
02310
02311
02312 x=afeb;
02313 y=nmbwiretbin;
02314 ss<<"nmb_afeb_time_bins_vs_afeb_ME_"<<idchamber;
02315 name=ss.str(); ss.str("");
02316 ss<<"Number of Time Bins vs AFEB ME"<<endcapstr<<id.station()<<"/"<<id.ring()<<"/"<< id.chamber();
02317 title=ss.str();
02318 ss.str("");
02319 histos->fill2DHist(x,y,name.c_str(),title.c_str(),42,1.,43.,16,0.,16.,"AFEBTiming");
02320
02321 }
02322 }
02323 }
02324 }
02325
02326
02327
02328
02329
02330
02331 void CSCValidation::doCompTiming(const CSCComparatorDigiCollection& compars) {
02332
02333 ostringstream ss; string name,title,endcap;
02334 float x,y;
02335 int strip,tbin,layer,cfeb,idlayer,idchamber,idum;
02336 int channel=0;
02337 CSCIndexer indexer;
02338
02339 if(compars.begin() != compars.end()) {
02340
02341
02342
02343
02344
02345
02346 CSCComparatorDigiCollection::DigiRangeIterator compdetUnitIt;
02347 for(compdetUnitIt=compars.begin();compdetUnitIt!=compars.end();
02348 ++compdetUnitIt) {
02349 const CSCDetId id = (*compdetUnitIt).first;
02350 idlayer=indexer.dbIndex(id, channel);
02351 idchamber=idlayer/10;
02352 layer=id.layer();
02353
02354 if (id.endcap() == 1) endcap = "+";
02355 if (id.endcap() == 2) endcap = "-";
02356
02357 const CSCComparatorDigiCollection::Range& range =
02358 (*compdetUnitIt).second;
02359 for(CSCComparatorDigiCollection::const_iterator digiIt =
02360 range.first; digiIt!=range.second; ++digiIt){
02361 strip=(*digiIt).getStrip();
02362
02363
02364
02365
02366
02367 idum=indexer.dbIndex(id, strip);
02368
02369 tbin=(*digiIt).getTimeBin();
02370 cfeb=(strip-1)/16+1;
02371
02372
02373
02374 x=cfeb;
02375 y=tbin;
02376 ss<<"comp_time_bin_vs_cfeb_occupancy_ME_"<<idchamber;
02377 name=ss.str(); ss.str("");
02378 ss<<"Comparator Time Bin vs CFEB Occupancy ME"<<endcap<<
02379 id.station()<<"/"<< id.ring()<<"/"<< id.chamber();
02380 title=ss.str(); ss.str("");
02381 histos->fill2DHist(x,y,name.c_str(),title.c_str(),5,1.,6.,16,0.,16.,"CompTiming");
02382
02383 }
02384 }
02385 }
02386 }
02387
02388
02389
02390
02391
02392
02393 void CSCValidation::doADCTiming(const CSCStripDigiCollection& strpcltn,
02394 const CSCRecHit2DCollection& rechitcltn) {
02395 float adc_3_3_sum,adc_3_3_wtbin,x,y;
02396 int cfeb,idchamber,ring;
02397
02398 string name,title,endcapstr;
02399 ostringstream ss;
02400 std::vector<float> zer(6,0.0);
02401
02402 CSCIndexer indexer;
02403 std::map<int,int>::iterator intIt;
02404
02405 if(rechitcltn.begin() != rechitcltn.end()) {
02406
02407
02408
02409
02410 CSCRecHit2DCollection::const_iterator recIt;
02411 CSCRecHit2D::ADCContainer m_adc;
02412 CSCRecHit2D::ChannelContainer m_strip;
02413 for(recIt = rechitcltn.begin(); recIt != rechitcltn.end(); ++recIt) {
02414 CSCDetId id = (CSCDetId)(*recIt).cscDetId();
02415
02416 m_strip=(CSCRecHit2D::ChannelContainer)(*recIt).channels();
02417 if(m_strip.size()==3) {
02418
02419 m_adc=(CSCRecHit2D::ADCContainer)(*recIt).adcs();
02420 std::vector<float> adc_left,adc_center,adc_right;
02421 int binmx=0;
02422 float adcmax=0.0;
02423 unsigned k=0;
02424
02425 for(int i=0;i<3;i++)
02426 for(int j=0;j<4;j++){
02427 if(m_adc[k]>adcmax) {adcmax=m_adc[k]; binmx=j;}
02428 if(i==0) adc_left.push_back(m_adc[k]);
02429 if(i==1) adc_center.push_back(m_adc[k]);
02430 if(i==2) adc_right.push_back(m_adc[k]);
02431 k=k+1;
02432 }
02433
02434 adc_3_3_sum=0.0;
02435 for(int j=binmx-1;j<=binmx+1;j++) {
02436 adc_3_3_sum=adc_3_3_sum+adc_left[j]
02437 +adc_center[j]
02438 +adc_right[j];
02439 }
02440
02441
02442 if(adc_3_3_sum > 100.0) {
02443
02444 int centerStrip=m_strip[1];
02445
02446 int flag=0;
02447 if(id.station()==1 && id.ring()==4 && centerStrip>16) flag=1;
02448
02449 if(flag==0) {
02450 adc_3_3_wtbin=getTiming(strpcltn, id, centerStrip);
02451 idchamber=indexer.dbIndex(id, centerStrip)/10;
02452
02453
02454
02455
02456
02457
02458
02459 ss<<"adc_3_3_weight_time_bin_vs_cfeb_occupancy_ME_"<<idchamber;
02460 name=ss.str(); ss.str("");
02461
02462 string endcapstr;
02463 if(id.endcap() == 1) endcapstr = "+";
02464 if(id.endcap() == 2) endcapstr = "-";
02465 ring=id.ring(); if(id.ring()==4) ring=1;
02466 ss<<"ADC 3X3 Weighted Time Bin vs CFEB Occupancy ME"
02467 <<endcapstr<<id.station()<<"/"<<ring<<"/"<<id.chamber();
02468 title=ss.str(); ss.str("");
02469
02470 cfeb=(centerStrip-1)/16+1;
02471 x=cfeb; y=adc_3_3_wtbin;
02472 histos->fill2DHist(x,y,name.c_str(),title.c_str(),5,1.,6.,40,0.,8.,"ADCTiming");
02473 }
02474 }
02475 }
02476 }
02477 }
02478 }
02479
02480
02481 void CSCValidation::endJob() {
02482
02483 std::cout<<"Events in "<<nEventsAnalyzed<<std::endl;
02484 }
02485
02486 DEFINE_FWK_MODULE(CSCValidation);
02487