00001 #include "CSCTFanalyzer.h" 00002 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h" 00003 #include "DataFormats/L1CSCTrackFinder/interface/L1CSCTrackCollection.h" 00004 00005 CSCTFanalyzer::CSCTFanalyzer(edm::ParameterSet const& pset):edm::EDAnalyzer(){ 00006 verbose = pset.getUntrackedParameter<unsigned int>("verbose",0); 00007 dataTrackProducer = pset.getUntrackedParameter<edm::InputTag>("dataTrackProducer",edm::InputTag("csctfDigis")); 00008 emulTrackProducer = pset.getUntrackedParameter<edm::InputTag>("emulTrackProducer",edm::InputTag("csctfTrackDigis")); 00009 lctProducer = pset.getUntrackedParameter<edm::InputTag>("lctProducer",edm::InputTag("csctfDigis")); 00010 file = new TFile("qwe.root","RECREATE"); 00011 tree = new TTree("dy","QWE"); 00012 tree->Branch("nDataMuons", &nDataMuons, "nDataMuons/I"); 00013 tree->Branch("dphi1", &dphi1, "dphi1/I"); 00014 tree->Branch("dphi2", &dphi2, "dphi2/I"); 00015 tree->Branch("dphi3", &dphi3, "dphi3/I"); 00016 tree->Branch("deta1", &deta1, "deta1/I"); 00017 tree->Branch("deta2", &deta2, "deta2/I"); 00018 tree->Branch("deta3", &deta3, "deta3/I"); 00019 tree->Branch("dpt1", &dpt1, "dpt1/I"); 00020 tree->Branch("dpt2", &dpt2, "dpt2/I"); 00021 tree->Branch("dpt3", &dpt3, "dpt3/I"); 00022 tree->Branch("dch1", &dch1, "dch1/I"); 00023 tree->Branch("dch2", &dch2, "dch2/I"); 00024 tree->Branch("dch3", &dch3, "dch3/I"); 00025 tree->Branch("dbx1", &dbx1, "dbx1/I"); 00026 tree->Branch("dbx2", &dbx2, "dbx2/I"); 00027 tree->Branch("dbx3", &dbx3, "dbx3/I"); 00028 00029 tree->Branch("nEmulMuons", &nEmulMuons, "nEmulMuons/I"); 00030 tree->Branch("ephi1", &ephi1, "ephi1/I"); 00031 tree->Branch("ephi2", &ephi2, "ephi2/I"); 00032 tree->Branch("ephi3", &ephi3, "ephi3/I"); 00033 tree->Branch("eeta1", &eeta1, "eeta1/I"); 00034 tree->Branch("eeta2", &eeta2, "eeta2/I"); 00035 tree->Branch("eeta3", &eeta3, "eeta3/I"); 00036 tree->Branch("ept1", &ept1, "ept1/I"); 00037 tree->Branch("ept2", &ept2, "ept2/I"); 00038 tree->Branch("ept3", &ept3, "ept3/I"); 00039 tree->Branch("ech1", &ech1, "ech1/I"); 00040 tree->Branch("ech2", &ech2, "ech2/I"); 00041 tree->Branch("ech3", &ech3, "ech3/I"); 00042 tree->Branch("ebx1", &ebx1, "ebx1/I"); 00043 tree->Branch("ebx2", &ebx2, "ebx2/I"); 00044 tree->Branch("ebx3", &ebx3, "ebx3/I"); 00045 00046 } 00047 00048 void CSCTFanalyzer::endJob(void){ 00049 tree->Write(); 00050 file->Write(); 00051 file->Close(); 00052 } 00053 00054 void CSCTFanalyzer::analyze(edm::Event const& e, edm::EventSetup const& es){ 00055 if( lctProducer.label() != "null" ){ 00056 edm::Handle<CSCCorrelatedLCTDigiCollection> LCTs; 00057 e.getByLabel(lctProducer.label(),lctProducer.instance(), LCTs); 00058 00059 for(CSCCorrelatedLCTDigiCollection::DigiRangeIterator csc=LCTs.product()->begin(); csc!=LCTs.product()->end(); csc++){ 00060 int lctId=0; 00061 00062 CSCCorrelatedLCTDigiCollection::Range range1 = LCTs.product()->get((*csc).first); 00063 for(CSCCorrelatedLCTDigiCollection::const_iterator lct=range1.first; lct!=range1.second; lct++,lctId++){ 00064 int station = (*csc).first.station()-1; 00065 int cscId = (*csc).first.triggerCscId()-1; 00066 int sector = (*csc).first.triggerSector()-1 + ( (*csc).first.endcap()==1 ? 0 : 6 ); 00067 int subSector = CSCTriggerNumbering::triggerSubSectorFromLabels((*csc).first); 00068 int tbin = lct->getBX(); 00069 int fpga = ( subSector ? subSector-1 : station+1 ); 00070 if((verbose&1)==1) 00071 std::cout<<"LCT in station="<<(station+1)<<" sector="<<(sector+1)<<" cscId="<<(cscId+1)<<" bx="<<tbin<<std::endl; 00072 } 00073 } 00074 } 00075 00076 nDataMuons = 0; nEmulMuons = 0; 00077 dphi1=-1; deta1=-1; dpt1=-1; dch1=-1, dbx1=-10; 00078 dphi2=-1; deta2=-1; dpt2=-1; dch2=-1, dbx2=-10; 00079 dphi3=-1; deta3=-1; dpt3=-1; dch3=-1, dbx3=-10; 00080 ephi1=-1; eeta1=-1; ept1=-1; ech1=-1, ebx1=-10; 00081 ephi2=-1; eeta2=-1; ept2=-1; ech2=-1, ebx2=-10; 00082 ephi3=-1; eeta3=-1; ept3=-1; ech3=-1, ebx3=-10; 00083 00084 if( dataTrackProducer.label() != "null" ){ 00085 edm::Handle<L1CSCTrackCollection> tracks; 00086 e.getByLabel(dataTrackProducer.label(),dataTrackProducer.instance(),tracks); 00087 for(L1CSCTrackCollection::const_iterator trk=tracks.product()->begin(); trk!=tracks.product()->end(); trk++){ 00088 switch(nDataMuons){ 00089 case 0: 00090 dphi1 = trk->first.localPhi(); 00091 deta1 = trk->first.eta_packed(); 00092 dpt1 = trk->first.pt_packed(); 00093 dch1 = trk->first.charge_packed(); 00094 dbx1 = trk->first.BX(); 00095 break; 00096 case 1: 00097 dphi2 = trk->first.localPhi(); 00098 deta2 = trk->first.eta_packed(); 00099 dpt2 = trk->first.pt_packed(); 00100 dch2 = trk->first.charge_packed(); 00101 dbx2 = trk->first.BX(); 00102 break; 00103 case 2: 00104 dphi3 = trk->first.localPhi(); 00105 deta3 = trk->first.eta_packed(); 00106 dpt3 = trk->first.pt_packed(); 00107 dch3 = trk->first.charge_packed(); 00108 dbx3 = trk->first.BX(); 00109 break; 00110 default: break; 00111 } 00112 if( (verbose&2)==2 ) 00113 std::cout<<"Data: TRK in endcap="<<trk->first.endcap()<<" sector="<<trk->first.sector()<<" bx="<<trk->first.BX() 00114 <<" (rank="<<trk->first.rank() 00115 <<" localPhi="<<trk->first.localPhi() 00116 <<" me1D="<<trk->first.me1ID() 00117 <<" me2D="<<trk->first.me2ID() 00118 <<" me3D="<<trk->first.me3ID() 00119 <<" me4D="<<trk->first.me4ID() 00120 <<" mb1D="<<trk->first.mb1ID() 00121 <<")"<<std::endl; 00122 nDataMuons++; 00123 } 00124 } 00125 00126 if( emulTrackProducer.label() != "null" ){ 00127 edm::Handle<L1CSCTrackCollection> tracks; 00128 e.getByLabel(emulTrackProducer.label(),emulTrackProducer.instance(),tracks); 00129 for(L1CSCTrackCollection::const_iterator trk=tracks.product()->begin(); trk!=tracks.product()->end(); trk++){ 00130 switch(nEmulMuons){ 00131 case 0: 00132 ephi1 = trk->first.localPhi(); 00133 eeta1 = trk->first.eta_packed(); 00134 ept1 = trk->first.pt_packed(); 00135 ech1 = trk->first.charge_packed(); 00136 ebx1 = trk->first.BX(); 00137 break; 00138 case 1: 00139 ephi2 = trk->first.localPhi(); 00140 eeta2 = trk->first.eta_packed(); 00141 ept2 = trk->first.pt_packed(); 00142 ech2 = trk->first.charge_packed(); 00143 ebx2 = trk->first.BX(); 00144 break; 00145 case 2: 00146 ephi3 = trk->first.localPhi(); 00147 eeta3 = trk->first.eta_packed(); 00148 ept3 = trk->first.pt_packed(); 00149 ech3 = trk->first.charge_packed(); 00150 ebx3 = trk->first.BX(); 00151 break; 00152 default: break; 00153 } 00154 if( (verbose&2)==2 ) 00155 std::cout<<"Emulator: TRK in endcap="<<trk->first.endcap()<<" sector="<<trk->first.sector()<<" bx="<<trk->first.BX() 00156 <<" (rank="<<trk->first.rank() 00157 <<" localPhi="<<trk->first.localPhi() 00158 <<" me1D="<<trk->first.me1ID() 00159 <<" me2D="<<trk->first.me2ID() 00160 <<" me3D="<<trk->first.me3ID() 00161 <<" me4D="<<trk->first.me4ID() 00162 <<" mb1D="<<trk->first.mb1ID() 00163 <<")"<<std::endl; 00164 nEmulMuons++; 00165 } 00166 } 00167 00168 tree->Fill(); 00169 }