00001
00002 #include <memory>
00003
00004
00005 #include "FWCore/Framework/interface/Frameworkfwd.h"
00006 #include "FWCore/Framework/interface/EDAnalyzer.h"
00007
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "FWCore/Framework/interface/MakerMacros.h"
00010
00011 #include "FWCore/ServiceRegistry/interface/Service.h"
00012
00013
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015
00016 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
00017
00018 #include "L1Trigger/RegionalCaloTrigger/interface/L1RCTTestAnalyzer.h"
00019
00020 using std::string;
00021 using std::cout;
00022 using std::endl;
00023
00024
00025
00026
00027 L1RCTTestAnalyzer::L1RCTTestAnalyzer(const edm::ParameterSet& iConfig) :
00028 showEmCands(iConfig.getUntrackedParameter<bool>("showEmCands")),
00029 showRegionSums(iConfig.getUntrackedParameter<bool>("showRegionSums")),
00030 ecalDigisLabel(iConfig.getParameter<edm::InputTag>("ecalDigisLabel")),
00031 hcalDigisLabel(iConfig.getParameter<edm::InputTag>("hcalDigisLabel")),
00032 rctDigisLabel(iConfig.getParameter<edm::InputTag>("rctDigisLabel"))
00033 {
00034
00035
00036 edm::Service<TFileService> fs;
00037
00038 emTree = fs->make<TTree>("emTree","L1 RCT EM tree");
00039
00040
00041
00042
00043 emTree->Branch("emRank",&emRank);
00044 emTree->Branch("emIeta",&emIeta);
00045 emTree->Branch("emIphi",&emIphi);
00046 emTree->Branch("emIso" ,&emIso);
00047
00048 h_emRank = fs->make<TH1F>( "emRank", "emRank", 64, 0., 64. );
00049 h_emRankOutOfTime = fs->make<TH1F>( "emRankOutOfTime", "emRankOutOfTime",
00050 64, 0., 64. );
00051 h_emIeta = fs->make<TH1F>( "emIeta", "emIeta", 22, 0., 22. );
00052 h_emIphi = fs->make<TH1F>( "emIphi", "emIphi", 18, 0., 18. );
00053 h_emIso = fs->make<TH1F>( "emIso", "emIso", 2, 0., 2. );
00054 h_emRankInIetaIphi = fs->make<TH2F>( "emRank2D", "emRank2D", 22, 0., 22.,
00055 18, 0., 18. );
00056 h_emIsoInIetaIphi = fs->make<TH2F>( "emIso2D", "emIso2D", 22, 0., 22.,
00057 18, 0., 18. );
00058 h_emNonIsoInIetaIphi = fs->make<TH2F>( "emNonIso2D", "emNonIso2D", 22, 0.,
00059 22., 18, 0., 18. );
00060 h_emCandTimeSample = fs->make<TH1F>( "emCandTimeSample", "emCandTimeSample",
00061 5, -2., 2.);
00062
00063 h_regionSum = fs->make<TH1F>( "regionSum", "regionSum", 100, 0., 100. );
00064 h_regionIeta = fs->make<TH1F>( "regionIeta", "regionIeta", 22, 0., 22. );
00065 h_regionIphi = fs->make<TH1F>( "regionIphi", "regionIphi", 18, 0., 18. );
00066 h_regionMip = fs->make<TH1F>( "regionMip", "regionMipBit", 2, 0., 2. );
00067 h_regionSumInIetaIphi = fs->make<TH2F>( "regionSum2D", "regionSum2D", 22,
00068 0., 22., 18, 0., 18. );
00069 h_regionFGInIetaIphi = fs->make<TH2F>( "regionFG2D", "regionFG2D", 22, 0.,
00070 22., 18, 0., 18. );
00071
00072 h_towerMip = fs->make<TH1F>( "towerMip", "towerMipBit", 2, 0., 2. );
00073
00074 h_ecalTimeSample = fs->make<TH1F>( "ecalTimeSample", "ecalTimeSample",
00075 10, 0., 10. );
00076 h_hcalTimeSample = fs->make<TH1F>( "hcalTimeSample", "hcalTimeSample",
00077 10, 0., 10. );
00078
00079
00080 }
00081
00082
00083 L1RCTTestAnalyzer::~L1RCTTestAnalyzer()
00084 {
00085
00086
00087
00088
00089 }
00090
00091
00092
00093
00094
00095
00096
00097 void
00098 L1RCTTestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00099 {
00100 using namespace edm;
00101 #ifdef THIS_IS_AN_EVENT_EXAMPLE
00102 Handle<ExampleData> pIn;
00103 iEvent.getByLabel("example",pIn);
00104 #endif
00105
00106 #ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
00107 ESHandle<SetupData> pSetup;
00108 iSetup.get<SetupRecord>().get(pSetup);
00109 #endif
00110
00111
00112 Handle<L1CaloEmCollection> rctEmCands;
00113 Handle<L1CaloRegionCollection> rctRegions;
00114 Handle<EcalTrigPrimDigiCollection> ecalColl;
00115 Handle<HcalTrigPrimDigiCollection> hcalColl;
00116
00117 L1CaloEmCollection::const_iterator em;
00118 L1CaloRegionCollection::const_iterator rgn;
00119 EcalTrigPrimDigiCollection::const_iterator ecal;
00120 HcalTrigPrimDigiCollection::const_iterator hcal;
00121
00122 iEvent.getByLabel(rctDigisLabel, rctEmCands);
00123 iEvent.getByLabel(rctDigisLabel, rctRegions);
00124 iEvent.getByLabel(ecalDigisLabel, ecalColl);
00125 iEvent.getByLabel(hcalDigisLabel, hcalColl);
00126
00127
00128 L1CaloEmCollection * myL1EmColl = new L1CaloEmCollection;
00129
00130 for (ecal=ecalColl->begin(); ecal!=ecalColl->end(); ecal++)
00131 {
00132 for (unsigned short sample = 0; sample < (*ecal).size(); sample++)
00133 {
00134 h_ecalTimeSample->Fill(sample);
00135 }
00136 }
00137
00138 for (hcal=hcalColl->begin(); hcal!=hcalColl->end(); hcal++)
00139 {
00140 h_towerMip->Fill( (*hcal).SOI_fineGrain() );
00141 for (unsigned short sample = 0; sample < (*hcal).size(); sample++)
00142 {
00143 h_hcalTimeSample->Fill(sample);
00144 }
00145 }
00146
00147 if(showEmCands)
00148 {
00149
00150 }
00151 for (em=rctEmCands->begin(); em!=rctEmCands->end(); em++){
00152
00153
00154 L1CaloEmCand * myL1EmCand = new L1CaloEmCand(*em);
00155 (*myL1EmColl).push_back(*myL1EmCand);
00156 delete myL1EmCand;
00157
00158 h_emCandTimeSample->Fill((*em).bx());
00159 if ((*em).bx() == 0)
00160 {
00161 unsigned short n_emcands = 0;
00162
00163
00164 if ((*em).rank() > 0)
00165 {
00166 h_emRank->Fill( (*em).rank() );
00167 h_emIeta->Fill( (*em).regionId().ieta() );
00168 h_emIphi->Fill( (*em).regionId().iphi() );
00169 h_emIso->Fill( (*em).isolated() );
00170 h_emRankInIetaIphi->Fill( (*em).regionId().ieta(),
00171 (*em).regionId().iphi(),
00172 (*em).rank() );
00173 if ((*em).isolated())
00174 {
00175 h_emIsoInIetaIphi->Fill( (*em).regionId().ieta(),
00176 (*em).regionId().iphi() );
00177 }
00178 else
00179 {
00180 h_emNonIsoInIetaIphi->Fill( (*em).regionId().ieta(),
00181 (*em).regionId().iphi() );
00182 }
00183 }
00184
00185 if (showEmCands)
00186 {
00187 if ((*em).rank() > 0)
00188 {
00189
00190 unsigned short rgnPhi = 999;
00191 unsigned short rgn = (unsigned short) (*em).rctRegion();
00192 unsigned short card = (unsigned short) (*em).rctCard();
00193 unsigned short crate = (unsigned short) (*em).rctCrate();
00194
00195 if (card == 6)
00196 {
00197 rgnPhi = rgn;
00198 }
00199 else if (card < 6)
00200 {
00201 rgnPhi = (card % 2);
00202 }
00203 else
00204 {
00205 std::cout << "rgnPhi not assigned (still " << rgnPhi << ") -- Weird card number! " << card ;
00206 }
00207
00208
00209 short eta_bin = (card/2) * 2 + 1;
00210 if (card < 6)
00211 {
00212 eta_bin = eta_bin + rgn;
00213 }
00214 if (crate < 9)
00215 {
00216 eta_bin = -eta_bin;
00217 }
00218 n_emcands++;
00219
00220
00221 }
00222 }
00223 }
00224 else
00225 {
00226 h_emRankOutOfTime->Fill( (*em).rank() );
00227 }
00228 }
00229 if(showEmCands)
00230 {
00231
00232 }
00233
00234
00235
00236
00237 std::sort(myL1EmColl->begin(),myL1EmColl->end(),compareEmCands);
00238 std::reverse(myL1EmColl->begin(),myL1EmColl->end());
00239 for (em=myL1EmColl->begin(); em!=myL1EmColl->end(); em++)
00240 {
00241 emRank.push_back( (*em).rank() );
00242 emIeta.push_back( (*em).regionId().ieta() );
00243 emIphi.push_back( (*em).regionId().iphi() );
00244 emIso.push_back( (*em).isolated() );
00245 }
00246 emTree->Fill();
00247
00248
00249 if(showRegionSums)
00250 {
00251 std::cout << "Regions" << std::endl;
00252 }
00253 for (rgn=rctRegions->begin(); rgn!=rctRegions->end(); rgn++)
00254 {
00255 if ((*rgn).bx() == 0)
00256 {
00257 if(showRegionSums&&(*rgn).et()>0)
00258 {
00259 std::cout << (*rgn) << std::endl;
00260 }
00261 if ( (*rgn).et() > 0 )
00262 {
00263 h_regionSum->Fill( (*rgn).et() );
00264 h_regionIeta->Fill( (*rgn).gctEta() );
00265 h_regionIphi->Fill( (*rgn).gctPhi() );
00266 h_regionSumInIetaIphi->Fill( (*rgn).gctEta(), (*rgn).gctPhi(),
00267 (*rgn).et() );
00268 h_regionFGInIetaIphi->Fill( (*rgn).gctEta(), (*rgn).gctPhi(),
00269 (*rgn).fineGrain() );
00270 }
00271 h_regionMip->Fill( (*rgn).mip() );
00272 }
00273 }
00274 if(showRegionSums)
00275 {
00276 std::cout << std::endl;
00277 }
00278
00279 emRank.clear();
00280 emIeta.clear();
00281 emIphi.clear();
00282 emIso.clear();
00283
00284 delete myL1EmColl;
00285 }
00286
00287 bool
00288 L1RCTTestAnalyzer::compareEmCands(const L1CaloEmCand& cand1, const L1CaloEmCand& cand2)
00289 {
00290 return (cand1.rank() < cand2.rank());
00291 }