13 #include "TDirectory.h"
15 #include "TLorentzVector.h"
16 #include "TInterpreter.h"
100 std::array<int, 3>
fillTree(std::vector<math::XYZTLorentzVector>& vecL1,
101 std::vector<math::XYZTLorentzVector>& vecL3,
103 std::vector<spr::propagatedTrackDirection>& trkCaloDirections,
104 std::vector<spr::propagatedTrackID>& trkCaloDets,
123 const std::vector<DetId>& ids,
124 std::vector<double>& edet,
126 std::vector<unsigned int>* detIds,
127 std::vector<double>* hitEnergies);
207 theTrackQuality_(iConfig.getParameter<
std::
string>(
"trackQuality")),
208 processName_(iConfig.getParameter<
std::
string>(
"processName")),
209 l1Filter_(iConfig.getParameter<
std::
string>(
"l1Filter")),
210 l2Filter_(iConfig.getParameter<
std::
string>(
"l2Filter")),
211 l3Filter_(iConfig.getParameter<
std::
string>(
"l3Filter")),
212 a_coneR_(iConfig.getParameter<double>(
"coneRadius")),
213 a_mipR_(iConfig.getParameter<double>(
"coneRadiusMIP")),
214 a_mipR2_(iConfig.getParameter<double>(
"coneRadiusMIP2")),
215 a_mipR3_(iConfig.getParameter<double>(
"coneRadiusMIP3")),
216 a_mipR4_(iConfig.getParameter<double>(
"coneRadiusMIP4")),
217 a_mipR5_(iConfig.getParameter<double>(
"coneRadiusMIP5")),
218 pTrackMin_(iConfig.getParameter<double>(
"minimumTrackP")),
219 eEcalMax_(iConfig.getParameter<double>(
"maximumEcalEnergy")),
220 maxRestrictionP_(iConfig.getParameter<double>(
"maxTrackP")),
221 slopeRestrictionP_(iConfig.getParameter<double>(
"slopeTrackP")),
222 hcalScale_(iConfig.getUntrackedParameter<double>(
"hHcalScale", 1.0)),
223 eIsolate1_(iConfig.getParameter<double>(
"isolationEnergyTight")),
224 eIsolate2_(iConfig.getParameter<double>(
"isolationEnergyLoose")),
225 pTrackLow_(iConfig.getParameter<double>(
"momentumLow")),
226 pTrackHigh_(iConfig.getParameter<double>(
"momentumHigh")),
227 prescaleLow_(iConfig.getParameter<
int>(
"prescaleLow")),
228 prescaleHigh_(iConfig.getParameter<
int>(
"prescaleHigh")),
229 useRaw_(iConfig.getUntrackedParameter<
int>(
"useRaw", 0)),
230 dataType_(iConfig.getUntrackedParameter<
int>(
"dataType", 0)),
231 mode_(iConfig.getUntrackedParameter<
int>(
"outMode", 11)),
232 ignoreTrigger_(iConfig.getUntrackedParameter<
bool>(
"ignoreTriggers",
false)),
233 useL1Trigger_(iConfig.getUntrackedParameter<
bool>(
"useL1Trigger",
false)),
234 unCorrect_(iConfig.getUntrackedParameter<
bool>(
"unCorrect",
false)),
235 collapseDepth_(iConfig.getUntrackedParameter<
bool>(
"collapseDepth",
false)),
236 hitEthrEB_(iConfig.getParameter<double>(
"EBHitEnergyThreshold")),
237 hitEthrEE0_(iConfig.getParameter<double>(
"EEHitEnergyThreshold0")),
238 hitEthrEE1_(iConfig.getParameter<double>(
"EEHitEnergyThreshold1")),
239 hitEthrEE2_(iConfig.getParameter<double>(
"EEHitEnergyThreshold2")),
240 hitEthrEE3_(iConfig.getParameter<double>(
"EEHitEnergyThreshold3")),
241 hitEthrEELo_(iConfig.getParameter<double>(
"EEHitEnergyThresholdLow")),
242 hitEthrEEHi_(iConfig.getParameter<double>(
"EEHitEnergyThresholdHigh")),
243 triggerEvent_(iConfig.getParameter<
edm::
InputTag>(
"labelTriggerEvent")),
244 theTriggerResultsLabel_(iConfig.getParameter<
edm::
InputTag>(
"labelTriggerResult")),
245 labelGenTrack_(iConfig.getParameter<
std::
string>(
"labelTrack")),
246 labelRecVtx_(iConfig.getParameter<
std::
string>(
"labelVertex")),
247 labelEB_(iConfig.getParameter<
std::
string>(
"labelEBRecHit")),
248 labelEE_(iConfig.getParameter<
std::
string>(
"labelEERecHit")),
249 labelHBHE_(iConfig.getParameter<
std::
string>(
"labelHBHERecHit")),
250 labelTower_(iConfig.getParameter<
std::
string>(
"labelCaloTower")),
251 l1TrigName_(iConfig.getUntrackedParameter<
std::
string>(
"l1TrigName",
"L1_SingleJet60")),
252 oldID_(iConfig.getUntrackedParameter<
std::
vector<
int>>(
"oldID")),
253 newDepth_(iConfig.getUntrackedParameter<
std::
vector<
int>>(
"newDepth")),
254 hep17_(iConfig.getUntrackedParameter<
bool>(
"hep17")),
262 const double isolationRadius(28.9), innerR(10.0), outerR(30.0);
288 for (
unsigned int k = 0;
k <
oldID_.size(); ++
k) {
298 tok_bs_ = consumes<reco::BeamSpot>(labelBS);
303 tok_alg_ = consumes<BXVector<GlobalAlgBlk>>(algTag);
305 if (modnam.empty()) {
327 tok_ddrec_ = esConsumes<HcalDDDRecConstants, HcalRecNumberingRecord, edm::Transition::BeginRun>();
328 tok_bFieldH_ = esConsumes<MagneticField, IdealMagneticFieldRecord>();
330 tok_sevlv_ = esConsumes<EcalSeverityLevelAlgo, EcalSeverityLevelAlgoRcd>();
331 tok_geom_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
333 tok_htopo_ = esConsumes<HcalTopology, HcalRecNumberingRecord>();
334 tok_resp_ = esConsumes<HcalRespCorrs, HcalRespCorrsRcd>();
337 <<
"Parameters read from config file \n"
361 for (
unsigned int k = 0;
k <
oldID_.size(); ++
k)
365 for (
int i = 0;
i < 10;
i++)
367 for (
int i = 0;
i < 8; ++
i)
375 unsigned int k1(0), k2(0);
392 <<
" Luminosity " <<
iEvent.luminosityBlock() <<
" Bunch " <<
iEvent.bunchCrossing();
405 respCorrs->
setTopo(theHBHETopology);
415 if (!trkCollection.
isValid()) {
434 if (recVtxs.
isValid() && !(recVtxs->empty())) {
436 for (
unsigned int k = 0;
k < recVtxs->size(); ++
k) {
437 if (!((*recVtxs)[
k].isFake()) && ((*recVtxs)[
k].ndof() > 4)) {
457 if (!barrelRecHitsHandle.
isValid()) {
463 if (!endcapRecHitsHandle.
isValid()) {
469 if (!
hbhe.isValid()) {
477 std::vector<spr::propagatedTrackDirection> trkCaloDirections;
479 std::vector<spr::propagatedTrackID> trkCaloDets;
481 std::vector<math::XYZTLorentzVector> vecL1, vecL3;
506 for (
const auto& decision : finalDecisions) {
507 if (decision.first.find(
l1TrigName_) != std::string::npos) {
514 <<
" from a list of " << finalDecisions.size() <<
" decisions";
524 for (
unsigned int iHLT = 0; iHLT <
triggerResults->size(); iHLT++) {
545 std::array<int, 3> ntksave{{0, 0, 0}};
573 if (!triggerEventHandle.
isValid()) {
580 std::vector<std::string>
modules;
583 for (
unsigned int iHLT = 0; iHLT <
triggerResults->size(); iHLT++) {
588 std::vector<math::XYZTLorentzVector> vecL2;
592 for (
unsigned int ifilter = 0; ifilter <
triggerEvent.sizeFilters(); ++ifilter) {
593 std::vector<int>
Keys;
596 for (
unsigned int imodule = 0; imodule < moduleLabels.size(); imodule++) {
597 if (
label.find(moduleLabels[imodule]) != std::string::npos) {
601 for (
unsigned int ifiltrKey = 0; ifiltrKey <
triggerEvent.filterKeys(ifilter).size(); ++ifiltrKey) {
614 <<
"key " << ifiltrKey <<
" : pt " << TO.
pt() <<
" eta " << TO.
eta() <<
" phi " << TO.
phi()
615 <<
" mass " << TO.
mass() <<
" Id " << TO.
id();
620 <<
"sizes " << vecL1.size() <<
":" << vecL2.size() <<
":" << vecL3.size();
628 for (
unsigned int i = 0;
i < vecL2.size();
i++) {
629 double dr =
dR(vecL1[0], vecL2[
i]);
635 mindRvec1 = vecL2[
i];
639 edm::LogVerbatim(
"HcalIsoTrack") <<
"L2 object closest to L1 " << mindRvec1 <<
" at Dr " << mindR1;
642 if (!vecL1.empty()) {
649 if (!vecL3.empty()) {
693 tree =
fs->
make<TTree>(
"CalibTree",
"CalibTree");
695 tree->Branch(
"t_Run", &
t_Run,
"t_Run/I");
710 tree->Branch(
"t_p", &
t_p,
"t_p/D");
711 tree->Branch(
"t_pt", &
t_pt,
"t_pt/D");
712 tree->Branch(
"t_phi", &
t_phi,
"t_phi/D");
734 t_DetIds =
new std::vector<unsigned int>();
735 t_DetIds1 =
new std::vector<unsigned int>();
736 t_DetIds3 =
new std::vector<unsigned int>();
741 tree->Branch(
"t_DetIds",
"std::vector<unsigned int>", &
t_DetIds);
744 tree->Branch(
"t_DetIds1",
"std::vector<unsigned int>", &
t_DetIds1);
745 tree->Branch(
"t_DetIds3",
"std::vector<unsigned int>", &
t_DetIds3);
749 tree2 =
fs->
make<TTree>(
"EventInfo",
"Event Information");
779 <<
" init flag " <<
flag <<
" change flag " << changed_;
786 for (
unsigned itrig = 0; itrig <
trigNames_.size(); itrig++) {
788 if (triggerindx >=
n) {
790 <<
"the current menu";
808 std::vector<std::string>
trig = {
"HLT_PFJet40",
818 desc.add<std::vector<std::string>>(
"triggers",
trig);
825 desc.add<
double>(
"minTrackPt", 1.0);
826 desc.add<
double>(
"maxDxyPV", 0.02);
827 desc.add<
double>(
"maxDzPV", 0.02);
828 desc.add<
double>(
"maxChi2", 5.0);
829 desc.add<
double>(
"maxDpOverP", 0.1);
830 desc.add<
int>(
"minOuterHit", 4);
831 desc.add<
int>(
"minLayerCrossed", 8);
832 desc.add<
int>(
"maxInMiss", 0);
833 desc.add<
int>(
"maxOutMiss", 0);
835 desc.add<
double>(
"minimumTrackP", 20.0);
836 desc.add<
double>(
"coneRadius", 34.98);
838 desc.add<
double>(
"coneRadiusMIP", 14.0);
839 desc.add<
double>(
"coneRadiusMIP2", 18.0);
840 desc.add<
double>(
"coneRadiusMIP3", 20.0);
841 desc.add<
double>(
"coneRadiusMIP4", 22.0);
842 desc.add<
double>(
"coneRadiusMIP5", 24.0);
843 desc.add<
double>(
"maximumEcalEnergy", 2.0);
845 desc.add<
double>(
"maxTrackP", 8.0);
846 desc.add<
double>(
"slopeTrackP", 0.05090504066);
847 desc.add<
double>(
"isolationEnergyTight", 2.0);
848 desc.add<
double>(
"isolationEnergyLoose", 10.0);
850 desc.add<
double>(
"EBHitEnergyThreshold", 0.08);
851 desc.add<
double>(
"EEHitEnergyThreshold0", 0.30);
852 desc.add<
double>(
"EEHitEnergyThreshold1", 0.00);
853 desc.add<
double>(
"EEHitEnergyThreshold2", 0.00);
854 desc.add<
double>(
"EEHitEnergyThreshold3", 0.00);
855 desc.add<
double>(
"EEHitEnergyThresholdLow", 0.30);
856 desc.add<
double>(
"EEHitEnergyThresholdHigh", 0.30);
858 desc.add<
double>(
"momentumLow", 40.0);
859 desc.add<
double>(
"momentumHigh", 60.0);
860 desc.add<
int>(
"prescaleLow", 1);
861 desc.add<
int>(
"prescaleHigh", 1);
878 desc.addUntracked<
int>(
"useRaw", 0);
879 desc.addUntracked<
bool>(
"ignoreTriggers",
false);
880 desc.addUntracked<
bool>(
"useL1Trigger",
false);
881 desc.addUntracked<
double>(
"hcalScale", 1.0);
882 desc.addUntracked<
int>(
"dataType", 0);
883 desc.addUntracked<
bool>(
"unCorrect",
false);
884 desc.addUntracked<
bool>(
"collapseDepth",
false);
886 desc.addUntracked<
int>(
"outMode", 11);
887 std::vector<int>
dummy;
888 desc.addUntracked<std::vector<int>>(
"oldID",
dummy);
889 desc.addUntracked<std::vector<int>>(
"newDepth",
dummy);
890 desc.addUntracked<
bool>(
"hep17",
false);
891 descriptions.
add(
"HcalIsoTrkAnalyzer",
desc);
895 std::vector<math::XYZTLorentzVector>& vecL3,
897 std::vector<spr::propagatedTrackDirection>& trkCaloDirections,
898 std::vector<spr::propagatedTrackID>& trkCaloDets,
910 int nSave(0),
nLoose(0), nTight(0);
912 std::vector<spr::propagatedTrackDirection>::const_iterator trkDetItr;
913 unsigned int nTracks(0), nselTracks(0);
914 t_nTrk = trkCaloDirections.size();
916 for (trkDetItr = trkCaloDirections.begin(),
nTracks = 0; trkDetItr != trkCaloDirections.end();
918 const reco::Track* pTrack = &(*(trkDetItr->trkItr));
922 << pTrack->
eta() <<
"|" << pTrack->
phi() <<
"|" << pTrack->
p();
925 for (
unsigned int k = 0;
k < vecL3.size(); ++
k) {
926 double dr =
dR(vecL3[
k], v4);
931 t_mindR1 = (!vecL1.empty()) ?
dR(vecL1[0], v4) : 999;
936 if (trkDetItr->okHCAL) {
940 if (
t_p > 40.0 &&
t_p <= 60.0)
947 oneCutParameters.
maxDzPV = 100;
950 bool qltyFlag =
spr::goodTrack(pTrack, leadPV, oneCutParameters,
false);
953 oneCutParameters.
maxDzPV = 100;
965 edm::LogVerbatim(
"HcalIsoTrack") <<
"qltyFlag|okECAL|okHCAL : " << qltyFlag <<
"|" << trkDetItr->okECAL <<
"|"
966 << trkDetItr->okHCAL <<
" eIsolation " << eIsolation;
968 t_qltyFlag = (qltyFlag && trkDetItr->okECAL && trkDetItr->okHCAL);
973 std::vector<DetId> eIds;
974 std::vector<double> eHit;
978 trkDetItr->pointHCAL,
979 trkDetItr->pointECAL,
981 trkDetItr->directionECAL,
985 for (
unsigned int k = 0;
k < eIds.size(); ++
k) {
995 std::vector<DetId> eIds2;
996 std::vector<double> eHit2;
1000 trkDetItr->pointHCAL,
1001 trkDetItr->pointECAL,
1003 trkDetItr->directionECAL,
1007 for (
unsigned int k = 0;
k < eIds2.size(); ++
k) {
1017 std::vector<DetId> eIds3;
1018 std::vector<double> eHit3;
1020 barrelRecHitsHandle,
1021 endcapRecHitsHandle,
1022 trkDetItr->pointHCAL,
1023 trkDetItr->pointECAL,
1025 trkDetItr->directionECAL,
1029 for (
unsigned int k = 0;
k < eIds3.size(); ++
k) {
1039 std::vector<DetId> eIds4;
1040 std::vector<double> eHit4;
1042 barrelRecHitsHandle,
1043 endcapRecHitsHandle,
1044 trkDetItr->pointHCAL,
1045 trkDetItr->pointECAL,
1047 trkDetItr->directionECAL,
1051 for (
unsigned int k = 0;
k < eIds4.size(); ++
k) {
1061 std::vector<DetId> eIds5;
1062 std::vector<double> eHit5;
1064 barrelRecHitsHandle,
1065 endcapRecHitsHandle,
1066 trkDetItr->pointHCAL,
1067 trkDetItr->pointECAL,
1069 trkDetItr->directionECAL,
1073 for (
unsigned int k = 0;
k < eIds5.size(); ++
k) {
1084 const DetId cellE(trkDetItr->detIdECAL);
1086 barrelRecHitsHandle,
1087 endcapRecHitsHandle,
1099 barrelRecHitsHandle,
1100 endcapRecHitsHandle,
1111 if (e11x11P.second && e15x15P.second) {
1112 t_eAnnular = (e15x15P.first - e11x11P.first);
1114 t_eAnnular = -(e15x15P.first - e11x11P.first);
1117 const DetId cellH(trkDetItr->detIdHCAL);
1119 theHBHETopology, cellH,
hbhe, 2, 2,
false,
true, -100.0, -100.0, -100.0, -100.0, -100.0, 100.0);
1121 theHBHETopology, cellH,
hbhe, 3, 3,
false,
true, -100.0, -100.0, -100.0, -100.0, -100.0, 100.0);
1125 <<
" Annular E (Ecal) " << e11x11P.first <<
":" << e15x15P.first <<
":"
1136 int nRecHits(-999), nRecHits1(-999), nRecHits3(-999);
1137 std::vector<DetId> ids, ids1, ids3;
1138 std::vector<double> edet0, edet1, edet3;
1141 trkDetItr->pointHCAL,
1142 trkDetItr->pointECAL,
1144 trkDetItr->directionHCAL,
1150 for (
unsigned k = 0;
k < ids.size(); ++
k)
1158 trkDetItr->pointHCAL,
1159 trkDetItr->pointECAL,
1161 trkDetItr->directionHCAL,
1167 for (
unsigned k = 0;
k < ids1.size(); ++
k)
1175 trkDetItr->pointHCAL,
1176 trkDetItr->pointECAL,
1178 trkDetItr->directionHCAL,
1184 for (
unsigned k = 0;
k < ids3.size(); ++
k)
1195 << pTrack->
eta() <<
"|" <<
t_phi <<
"|" <<
t_p <<
" Generator Level p "
1200 for (
unsigned int ll = 0; ll <
t_DetIds->size(); ll++) {
1204 for (
unsigned int ll = 0; ll <
t_DetIds1->size(); ll++) {
1208 for (
unsigned int ll = 0; ll <
t_DetIds3->size(); ll++) {
1258 std::array<int, 3>
i3{{nSave,
nLoose, nTight}};
1270 double mindR(999.9);
1275 pmom =
p.momentum().R();
1283 std::vector<double> sumPFNallSMDQH2;
1289 for (
const auto& pf_it : (*
tower)) {
1294 hadder += pf_it.hadEt();
1296 sumPFNallSMDQH2.emplace_back(hadder);
1301 std::sort(sumPFNallSMDQH2.begin(), sumPFNallSMDQH2.end());
1302 if (sumPFNallSMDQH2.size() % 2)
1303 evt_smdq = sumPFNallSMDQH2[(sumPFNallSMDQH2.size() - 1) / 2];
1305 evt_smdq = (sumPFNallSMDQH2[sumPFNallSMDQH2.size() / 2] + sumPFNallSMDQH2[(sumPFNallSMDQH2.size() - 2) / 2]) / 2.;
1331 for (
unsigned int k = 0;
k <
oldID_.size(); ++
k) {
1341 const std::vector<DetId>& ids,
1342 std::vector<double>& edet,
1344 std::vector<unsigned int>* detIds,
1345 std::vector<double>* hitEnergies) {
1348 for (
unsigned int k = 0;
k < ids.size(); ++
k) {
1355 for (
const auto& en : edet)
1359 edm::LogWarning(
"HcalIsoTrack") <<
"Check inconsistent energies: " << indx <<
" " << eHcal <<
":" << ehcal
1360 <<
" from " << ids.size() <<
" cells";
1364 std::map<HcalDetId, double> hitMap;
1365 for (
unsigned int k = 0;
k < ids.size(); ++
k) {
1367 auto itr = hitMap.find(
id);
1368 if (
itr == hitMap.end()) {
1369 hitMap[
id] = edet[
k];
1371 (
itr->second) += edet[
k];
1374 detIds->reserve(hitMap.size());
1375 hitEnergies->reserve(hitMap.size());
1376 for (
const auto&
hit : hitMap) {
1377 detIds->emplace_back(
hit.first.rawId());
1378 hitEnergies->emplace_back(
hit.second);
1381 detIds->reserve(ids.size());
1382 hitEnergies->reserve(ids.size());
1383 for (
unsigned int k = 0;
k < ids.size(); ++
k) {
1384 detIds->emplace_back(ids[
k].rawId());
1385 hitEnergies->emplace_back(edet[
k]);
1389 edm::LogVerbatim(
"HcalIsoTrack") <<
"Input to storeEnergy with " << ids.size() <<
" cells";
1390 for (
unsigned int k = 0;
k < ids.size(); ++
k)
1392 edm::LogVerbatim(
"HcalIsoTrack") <<
"Output of storeEnergy with " << detIds->size() <<
" cells and Etot " << eHcal;
1393 for (
unsigned int k = 0;
k < detIds->size(); ++
k)