CMS 3D CMS Logo

L1RCTTestAnalyzer.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 
4 // user include files
7 
10 
12 
14 
16 
18 
19 using std::cout;
20 using std::endl;
21 using std::string;
22 
23 //
24 // constructors and destructor
25 //
27  : showEmCands(iConfig.getUntrackedParameter<bool>("showEmCands")),
28  showRegionSums(iConfig.getUntrackedParameter<bool>("showRegionSums")),
29  ecalDigisLabel(iConfig.getParameter<edm::InputTag>("ecalDigisLabel")),
30  hcalDigisLabel(iConfig.getParameter<edm::InputTag>("hcalDigisLabel")),
31  rctDigisLabel(iConfig.getParameter<edm::InputTag>("rctDigisLabel")) {
32  // now do what ever initialization is needed
33 
35 
36  emTree = fs->make<TTree>("emTree", "L1 RCT EM tree");
37  // emTree->Branch("emRank",emRank,"emRank/I");
38  // emTree->Branch("emIeta",emIeta,"emIeta/I");
39  // emTree->Branch("emIphi",emIphi,"emIphi/I");
40  // emTree->Branch("emIso" ,emIso ,"emIso/I");
41  emTree->Branch("emRank", &emRank);
42  emTree->Branch("emIeta", &emIeta);
43  emTree->Branch("emIphi", &emIphi);
44  emTree->Branch("emIso", &emIso);
45 
46  h_emRank = fs->make<TH1F>("emRank", "emRank", 64, 0., 64.);
47  h_emRankOutOfTime = fs->make<TH1F>("emRankOutOfTime", "emRankOutOfTime", 64, 0., 64.);
48  h_emIeta = fs->make<TH1F>("emIeta", "emIeta", 22, 0., 22.);
49  h_emIphi = fs->make<TH1F>("emIphi", "emIphi", 18, 0., 18.);
50  h_emIso = fs->make<TH1F>("emIso", "emIso", 2, 0., 2.);
51  h_emRankInIetaIphi = fs->make<TH2F>("emRank2D", "emRank2D", 22, 0., 22., 18, 0., 18.);
52  h_emIsoInIetaIphi = fs->make<TH2F>("emIso2D", "emIso2D", 22, 0., 22., 18, 0., 18.);
53  h_emNonIsoInIetaIphi = fs->make<TH2F>("emNonIso2D", "emNonIso2D", 22, 0., 22., 18, 0., 18.);
54  h_emCandTimeSample = fs->make<TH1F>("emCandTimeSample", "emCandTimeSample", 5, -2., 2.);
55 
56  h_regionSum = fs->make<TH1F>("regionSum", "regionSum", 100, 0., 100.);
57  h_regionIeta = fs->make<TH1F>("regionIeta", "regionIeta", 22, 0., 22.);
58  h_regionIphi = fs->make<TH1F>("regionIphi", "regionIphi", 18, 0., 18.);
59  h_regionMip = fs->make<TH1F>("regionMip", "regionMipBit", 2, 0., 2.);
60  h_regionSumInIetaIphi = fs->make<TH2F>("regionSum2D", "regionSum2D", 22, 0., 22., 18, 0., 18.);
61  h_regionFGInIetaIphi = fs->make<TH2F>("regionFG2D", "regionFG2D", 22, 0., 22., 18, 0., 18.);
62 
63  h_towerMip = fs->make<TH1F>("towerMip", "towerMipBit", 2, 0., 2.);
64 
65  h_ecalTimeSample = fs->make<TH1F>("ecalTimeSample", "ecalTimeSample", 10, 0., 10.);
66  h_hcalTimeSample = fs->make<TH1F>("hcalTimeSample", "hcalTimeSample", 10, 0., 10.);
67 
68  // get names of modules, producing object collections
69 }
70 
72  // do anything here that needs to be done at destruction time
73  // (e.g. close files, deallocate resources etc.)
74 }
75 
76 //
77 // member functions
78 //
79 
80 // ------------ method called to produce the data ------------
82  using namespace edm;
83 #ifdef THIS_IS_AN_EVENT_EXAMPLE
85  iEvent.getByLabel("example", pIn);
86 #endif
87 
88 #ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
89  ESHandle<SetupData> pSetup;
90  iSetup.get<SetupRecord>().get(pSetup);
91 #endif
92 
93  // as in L1GctTestAnalyzer.cc
94  Handle<L1CaloEmCollection> rctEmCands;
98 
99  L1CaloEmCollection::const_iterator em;
100  L1CaloRegionCollection::const_iterator rgn;
103 
104  iEvent.getByLabel(rctDigisLabel, rctEmCands);
105  iEvent.getByLabel(rctDigisLabel, rctRegions);
106  iEvent.getByLabel(ecalDigisLabel, ecalColl);
107  iEvent.getByLabel(hcalDigisLabel, hcalColl);
108 
109  // for sorting later
110  L1CaloEmCollection *myL1EmColl = new L1CaloEmCollection;
111 
112  for (ecal = ecalColl->begin(); ecal != ecalColl->end(); ecal++) {
113  for (unsigned short sample = 0; sample < (*ecal).size(); sample++) {
114  h_ecalTimeSample->Fill(sample);
115  }
116  }
117 
118  for (hcal = hcalColl->begin(); hcal != hcalColl->end(); hcal++) {
119  h_towerMip->Fill((*hcal).SOI_fineGrain());
120  for (unsigned short sample = 0; sample < (*hcal).size(); sample++) {
121  h_hcalTimeSample->Fill(sample);
122  }
123  }
124 
125  if (showEmCands) {
126  // std::cout << std::endl << "L1 RCT EmCand objects" << std::endl;
127  }
128  for (em = rctEmCands->begin(); em != rctEmCands->end(); em++) {
129  // std::cout << "(Analyzer)\n" << (*em) << std::endl;
130 
131  L1CaloEmCand *myL1EmCand = new L1CaloEmCand(*em);
132  (*myL1EmColl).push_back(*myL1EmCand);
133  delete myL1EmCand;
134 
135  h_emCandTimeSample->Fill((*em).bx());
136  if ((*em).bx() == 0) {
137  unsigned short n_emcands = 0;
138  // std::cout << std::endl << "rank: " << (*em).rank() ;
139 
140  if ((*em).rank() > 0) {
141  h_emRank->Fill((*em).rank());
142  h_emIeta->Fill((*em).regionId().ieta());
143  h_emIphi->Fill((*em).regionId().iphi());
144  h_emIso->Fill((*em).isolated());
145  h_emRankInIetaIphi->Fill((*em).regionId().ieta(), (*em).regionId().iphi(), (*em).rank());
146  if ((*em).isolated()) {
147  h_emIsoInIetaIphi->Fill((*em).regionId().ieta(), (*em).regionId().iphi());
148  } else {
149  h_emNonIsoInIetaIphi->Fill((*em).regionId().ieta(), (*em).regionId().iphi());
150  }
151  }
152 
153  if (showEmCands) {
154  if ((*em).rank() > 0) {
155  // std::cout << std::endl << "rank: " << (*em).rank();
156  unsigned short rgnPhi = 999;
157  unsigned short rgn = (unsigned short)(*em).rctRegion();
158  unsigned short card = (unsigned short)(*em).rctCard();
159  unsigned short crate = (unsigned short)(*em).rctCrate();
160 
161  if (card == 6) {
162  rgnPhi = rgn;
163  } else if (card < 6) {
164  rgnPhi = (card % 2);
165  } else {
166  std::cout << "rgnPhi not assigned (still " << rgnPhi << ") -- Weird card number! " << card;
167  }
168 
169  // unsigned short phi_bin = ((crate % 9) * 2) + rgnPhi;
170  short eta_bin = (card / 2) * 2 + 1;
171  if (card < 6) {
172  eta_bin = eta_bin + rgn;
173  }
174  if (crate < 9) {
175  eta_bin = -eta_bin;
176  }
177  n_emcands++;
178 
179  // std::cout << /* "rank: " << (*em).rank() << */ "
180  // eta_bin: " << eta_bin << " phi_bin: " << phi_bin << ". crate: "
181  // << crate << " card: " << card << " region: " << rgn << ".
182  // isolated: " << (*em).isolated();
183  }
184  }
185  } else {
186  h_emRankOutOfTime->Fill((*em).rank());
187  }
188  }
189  if (showEmCands) {
190  // std::cout << std::endl;
191  }
192 
193  // next: SORT THESE GUYS so they're entered into the tree highest first
194  // std::sort(rctEmCands->begin(),rctEmCands->end(),compareEmCands);
195  // for (em=rctEmCands->begin(); em!=rctEmCands->end(); em++)
196  std::sort(myL1EmColl->begin(), myL1EmColl->end(), compareEmCands);
197  std::reverse(myL1EmColl->begin(), myL1EmColl->end()); // whoops!
198  for (em = myL1EmColl->begin(); em != myL1EmColl->end(); em++) {
199  emRank.push_back((*em).rank());
200  emIeta.push_back((*em).regionId().ieta());
201  emIphi.push_back((*em).regionId().iphi());
202  emIso.push_back((*em).isolated());
203  }
204  emTree->Fill();
205 
206  if (showRegionSums) {
207  std::cout << "Regions" << std::endl;
208  }
209  for (rgn = rctRegions->begin(); rgn != rctRegions->end(); rgn++) {
210  if ((*rgn).bx() == 0) {
211  if (showRegionSums && (*rgn).et() > 0) {
212  std::cout << /* "(Analyzer)\n" << */ (*rgn) << std::endl;
213  }
214  if ((*rgn).et() > 0) {
215  h_regionSum->Fill((*rgn).et());
216  h_regionIeta->Fill((*rgn).gctEta());
217  h_regionIphi->Fill((*rgn).gctPhi());
218  h_regionSumInIetaIphi->Fill((*rgn).gctEta(), (*rgn).gctPhi(), (*rgn).et());
219  h_regionFGInIetaIphi->Fill((*rgn).gctEta(), (*rgn).gctPhi(), (*rgn).fineGrain());
220  }
221  h_regionMip->Fill((*rgn).mip());
222  }
223  }
224  if (showRegionSums) {
225  std::cout << std::endl;
226  }
227 
228  emRank.clear();
229  emIeta.clear();
230  emIphi.clear();
231  emIso.clear();
232 
233  delete myL1EmColl;
234 }
235 
237  return (cand1.rank() < cand2.rank());
238 }
l1RctEmulDigis_ECALGREN1_cff.ecalDigisLabel
ecalDigisLabel
Definition: l1RctEmulDigis_ECALGREN1_cff.py:8
L1RCTTestAnalyzer::h_hcalTimeSample
TH1F * h_hcalTimeSample
Definition: L1RCTTestAnalyzer.h:104
electrons_cff.bool
bool
Definition: electrons_cff.py:372
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
simplePhotonAnalyzer_cfi.sample
sample
Definition: simplePhotonAnalyzer_cfi.py:12
L1RCTTestAnalyzer::h_ecalTimeSample
TH1F * h_ecalTimeSample
Definition: L1RCTTestAnalyzer.h:103
unpackData-CaloStage1.rctDigisLabel
rctDigisLabel
Definition: unpackData-CaloStage1.py:168
L1RCTTestAnalyzer::h_emIphi
TH1F * h_emIphi
Definition: L1RCTTestAnalyzer.h:84
L1RCTTestAnalyzer::h_emIso
TH1F * h_emIso
Definition: L1RCTTestAnalyzer.h:85
hcal
Definition: ConfigurationDatabase.cc:13
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
l1RctEmulDigis_ECALGREN1_cff.hcalDigisLabel
hcalDigisLabel
Definition: l1RctEmulDigis_ECALGREN1_cff.py:4
L1RCTTestAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: L1RCTTestAnalyzer.cc:81
L1RCTTestAnalyzer::h_towerMip
TH1F * h_towerMip
Definition: L1RCTTestAnalyzer.h:101
L1RCTTestAnalyzer::emIeta
std::vector< int > emIeta
Definition: L1RCTTestAnalyzer.h:77
EDAnalyzer.h
L1RCTTestAnalyzer::compareEmCands
static bool compareEmCands(const L1CaloEmCand &cand1, const L1CaloEmCand &cand2)
Definition: L1RCTTestAnalyzer.cc:236
L1RCTTestAnalyzer::h_emNonIsoInIetaIphi
TH2F * h_emNonIsoInIetaIphi
Definition: L1RCTTestAnalyzer.h:89
edm::Handle
Definition: AssociativeIterator.h:50
groupFilesInBlocks.reverse
reverse
Definition: groupFilesInBlocks.py:131
L1RCTTestAnalyzer::h_regionSumInIetaIphi
TH2F * h_regionSumInIetaIphi
Definition: L1RCTTestAnalyzer.h:96
patCandidatesForDimuonsSequences_cff.hcal
hcal
Definition: patCandidatesForDimuonsSequences_cff.py:37
L1RCTTestAnalyzer::h_emCandTimeSample
TH1F * h_emCandTimeSample
Definition: L1RCTTestAnalyzer.h:90
MakerMacros.h
L1CaloEmCollection
std::vector< L1CaloEmCand > L1CaloEmCollection
Definition: L1CaloCollections.h:10
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
L1RCTTestAnalyzer::h_emIsoInIetaIphi
TH2F * h_emIsoInIetaIphi
Definition: L1RCTTestAnalyzer.h:88
L1RCTTestAnalyzer::h_regionMip
TH1F * h_regionMip
Definition: L1RCTTestAnalyzer.h:95
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
Service.h
edm::ESHandle
Definition: DTSurvey.h:22
L1RCTTestAnalyzer::h_regionIphi
TH1F * h_regionIphi
Definition: L1RCTTestAnalyzer.h:94
L1RCTTestAnalyzer::emRank
std::vector< int > emRank
Definition: L1RCTTestAnalyzer.h:76
L1RCTTestAnalyzer::h_emRankInIetaIphi
TH2F * h_emRankInIetaIphi
Definition: L1RCTTestAnalyzer.h:86
L1RCTTestAnalyzer::h_emRank
TH1F * h_emRank
Definition: L1RCTTestAnalyzer.h:81
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
L1RCTTestAnalyzer::~L1RCTTestAnalyzer
~L1RCTTestAnalyzer() override
Definition: L1RCTTestAnalyzer.cc:71
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
L1RCTTestAnalyzer::h_emRankOutOfTime
TH1F * h_emRankOutOfTime
Definition: L1RCTTestAnalyzer.h:82
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
L1RCTTestAnalyzer::rctDigisLabel
edm::InputTag rctDigisLabel
Definition: L1RCTTestAnalyzer.h:69
edm::Service< TFileService >
L1CaloCollections.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
L1RCTTestAnalyzer::hcalDigisLabel
edm::InputTag hcalDigisLabel
Definition: L1RCTTestAnalyzer.h:68
get
#define get
L1RCTTestAnalyzer_cfi.showEmCands
showEmCands
Definition: L1RCTTestAnalyzer_cfi.py:5
L1RCTTestAnalyzer::h_emIeta
TH1F * h_emIeta
Definition: L1RCTTestAnalyzer.h:83
L1RCTTestAnalyzer::L1RCTTestAnalyzer
L1RCTTestAnalyzer(const edm::ParameterSet &)
Definition: L1RCTTestAnalyzer.cc:26
L1RCTTestAnalyzer_cfi.showRegionSums
showRegionSums
Definition: L1RCTTestAnalyzer_cfi.py:8
L1RCTTestAnalyzer::h_regionIeta
TH1F * h_regionIeta
Definition: L1RCTTestAnalyzer.h:93
L1RCTTestAnalyzer::showRegionSums
bool showRegionSums
Definition: L1RCTTestAnalyzer.h:66
Frameworkfwd.h
L1RCTTestAnalyzer::h_regionFGInIetaIphi
TH2F * h_regionFGInIetaIphi
Definition: L1RCTTestAnalyzer.h:99
L1RCTTestAnalyzer::ecalDigisLabel
edm::InputTag ecalDigisLabel
Definition: L1RCTTestAnalyzer.h:67
L1RCTTestAnalyzer::emIso
std::vector< int > emIso
Definition: L1RCTTestAnalyzer.h:79
L1RCTTestAnalyzer::emIphi
std::vector< int > emIphi
Definition: L1RCTTestAnalyzer.h:78
L1CaloEmCand::rank
unsigned rank() const
get rank bits
Definition: L1CaloEmCand.h:42
bsc_activity_cfg.ecal
ecal
Definition: bsc_activity_cfg.py:25
L1RCTTestAnalyzer::emTree
TTree * emTree
Definition: L1RCTTestAnalyzer.h:71
ParameterSet.h
L1RCTTestAnalyzer::showEmCands
bool showEmCands
Definition: L1RCTTestAnalyzer.h:65
edm::Event
Definition: Event.h:73
L1CaloEmCand
Level-1 Region Calorimeter Trigger EM candidate.
Definition: L1CaloEmCand.h:17
L1RCTTestAnalyzer.h
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64
L1RCTTestAnalyzer::h_regionSum
TH1F * h_regionSum
Definition: L1RCTTestAnalyzer.h:92