CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
HcalIsoTrkAnalyzer Class Reference

#include <Calibration/HcalCalibAlgos/src/HcalIsoTrkAnalyzer.cc>

Inheritance diagram for HcalIsoTrkAnalyzer:
edm::EDAnalyzer

Public Member Functions

double getDistInPlaneSimple (const GlobalPoint caloPoint, const GlobalPoint rechitPoint)
 
 HcalIsoTrkAnalyzer (const edm::ParameterSet &)
 
 ~HcalIsoTrkAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 

Private Attributes

bool allowMissingInputs_
 
double associationConeSize_
 
string AxB_
 
double calibrationConeSize_
 
UInt_t cell
 
Float_t cellEnergy
 
TClonesArray * cells
 
TRefArray * cells3x3
 
TRefArray * cellsPF
 
char dirname [50]
 
InputTag eLabel_
 
Float_t emEnergy
 
double energyECALmip
 
double energyMaxIso
 
double energyMinIso
 
Float_t etVetoJet
 
UInt_t eventNumber
 
float eventWeight
 
const CaloGeometrygeo
 
InputTag hbheLabel_
 
char hname [20]
 
InputTag hoLabel_
 
char htitle [80]
 
Int_t iEtaHit
 
ofstream input_to_L3
 
UInt_t iPhiHit
 
std::string m_ebInstance
 
std::string m_ecalLabel
 
std::string m_eeInstance
 
std::string m_hcalLabel
 
int m_histoFlag
 
std::string m_inputTrackLabel
 
double maxPNear
 
int MinNTECHitsEndcap
 
int MinNTrackHitsBarrel
 
int nIterations
 
UInt_t numberOfCells
 
string outputFileName_
 
TrackAssociatorParameters parameters_
 
Float_t probeJetEmFrac
 
TLorentzVector * probeJetP4
 
TFile * rootFile
 
UInt_t runNumber
 
double rvert
 
Float_t tagJetEmFrac
 
TLorentzVector * tagJetP4
 
Float_t targetE
 
TrackDetectorAssociator trackAssociator_
 
double trackEta
 
InputTag trackLabel1_
 
InputTag trackLabel_
 
double trackPhi
 
TTree * tree
 
Float_t xTrkEcal
 
Float_t xTrkHcal
 
Float_t yTrkEcal
 
Float_t yTrkHcal
 
Float_t zTrkEcal
 
Float_t zTrkHcal
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Description: see twiki for details: https://twiki.cern.ch/twiki/bin/view/CMS/IsoTrackAnalyzer

Implementation: <Notes on="" implementation>="">

Definition at line 98 of file HcalIsoTrkAnalyzer.cc.

Constructor & Destructor Documentation

HcalIsoTrkAnalyzer::HcalIsoTrkAnalyzer ( const edm::ParameterSet iConfig)
explicit

Definition at line 239 of file HcalIsoTrkAnalyzer.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and Parameters::parameters.

240 {
241 
242  m_ecalLabel = iConfig.getUntrackedParameter<std::string> ("ecalRecHitsLabel","ecalRecHit");
243  m_ebInstance = iConfig.getUntrackedParameter<std::string> ("ebRecHitsInstance","EcalRecHitsEB");
244  m_eeInstance = iConfig.getUntrackedParameter<std::string> ("eeRecHitsInstance","EcalRecHitsEE");
245  m_hcalLabel = iConfig.getUntrackedParameter<std::string> ("hcalRecHitsLabel","hbhereco");
246 
247  hbheLabel_= iConfig.getParameter<edm::InputTag>("hbheInput");
248  hoLabel_=iConfig.getParameter<edm::InputTag>("hoInput");
249  eLabel_=iConfig.getParameter<edm::InputTag>("eInput");
250  trackLabel_ = iConfig.getParameter<edm::InputTag>("HcalIsolTrackInput");
251  trackLabel1_ = iConfig.getParameter<edm::InputTag>("trackInput");
252  associationConeSize_=iConfig.getParameter<double>("associationConeSize");
253  allowMissingInputs_=iConfig.getUntrackedParameter<bool>("allowMissingInputs",true);
254  outputFileName_=iConfig.getParameter<std::string>("outputFileName");
255 
256  AxB_=iConfig.getParameter<std::string>("AxB");
257  calibrationConeSize_=iConfig.getParameter<double>("calibrationConeSize");
258 
259  nIterations = iConfig.getParameter<int>("noOfIterations");
260  eventWeight = iConfig.getParameter<double>("eventWeight");
261  energyMinIso = iConfig.getParameter<double>("energyMinIso");
262  energyMaxIso = iConfig.getParameter<double>("energyMaxIso");
263  energyECALmip = iConfig.getParameter<double>("energyECALmip");
264  maxPNear = iConfig.getParameter<double>("maxPNear");
265  MinNTrackHitsBarrel = iConfig.getParameter<int>("MinNTrackHitsBarrel");
266  MinNTECHitsEndcap = iConfig.getParameter<int>("MinNTECHitsEndcap");
267 
268  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
269  parameters_.loadParameters( parameters );
271 
272 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
dictionary parameters
Definition: Parameters.py:2
void useDefaultPropagator()
use the default propagator
TrackDetectorAssociator trackAssociator_
TrackAssociatorParameters parameters_
void loadParameters(const edm::ParameterSet &)
HcalIsoTrkAnalyzer::~HcalIsoTrkAnalyzer ( )

Definition at line 274 of file HcalIsoTrkAnalyzer.cc.

275 {
276 }

Member Function Documentation

void HcalIsoTrkAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 280 of file HcalIsoTrkAnalyzer.cc.

References abs, edm::SortedCollection< T, SORT >::begin(), MaxHit_struct::depthhit, patCandidatesForDimuonsSequences_cff::ecal, EcalBarrel, EcalEndcap, edm::SortedCollection< T, SORT >::end(), PV3DBase< T, PVType, FrameType >::eta(), edm::EventID::event(), GeneralTracks_cfi::generalTracks, edm::EventSetup::get(), edm::Event::getByLabel(), CaloSubdetectorGeometry::getClosestCell(), getDistInPlaneSimple(), EBDetId::hashedIndex(), EEDetId::hashedIndex(), DetId::Hcal, HcalBarrel, HcalEndcap, MaxHit_struct::hitenergy, i, edm::EventBase::id(), HcalDetId::ieta(), MaxHit_struct::ietahitm, info, HcalDetId::iphi(), MaxHit_struct::iphihitm, PV3DBase< T, PVType, FrameType >::phi(), pos, MaxHit_struct::posMax, edm::Handle< T >::product(), edm::SortedCollection< T, SORT >::push_back(), edm::EventID::run(), inputsource_file_cfi::runNumber, mathSSE::sqrt(), reco::btau::trackEta, reco::btau::trackPhi, and diffTreeTool::tree.

281 {
282  using namespace edm;
283  using namespace std;
284 
285  vector<float> rawEnergyVec;
286  vector<int> detiphi;
287  vector<int> detieta;
288  vector<int> i3i5;
289  vector<HcalDetId> detidvec;
290  float calEnergy;
291 
294 
296  iEvent.getByLabel(trackLabel_,trackCollection);
297 
299  iEvent.getByLabel(eLabel_,ecal);
300  const EcalRecHitCollection Hitecal = *(ecal.product());
301 
303  iEvent.getByLabel(hbheLabel_,hbhe);
304  const HBHERecHitCollection Hithbhe = *(hbhe.product());
305 
307  iSetup.get<CaloGeometryRecord>().get(pG);
308  geo = pG.product();
309 
310 // rof 16.05.2008 start: include the possibility for recalibration (use "recalibrate" label for safety)
311 /*
312  edm::ESHandle <HcalRespCorrs> recalibCorrs;
313  iSetup.get<HcalRespCorrsRcd>().get("recalibrate",recalibCorrs);
314  const HcalRespCorrs* myRecalib = recalibCorrs.product();
315 */
316 // rof end
317 
318  parameters_.useEcal = true;
319  parameters_.useHcal = true;
320  parameters_.useCalo = false;
321  parameters_.useMuon = false;
322  parameters_.dREcal = 0.5;
323  parameters_.dRHcal = 0.6;
324 
325  if (trackCollection->size()==0) return;
326 
327  for (reco::TrackCollection::const_iterator trit=generalTracks->begin(); trit!=generalTracks->end(); trit++)
328  {
329  reco::IsolatedPixelTrackCandidateCollection::const_iterator isoMatched=trackCollection->begin();
330  bool matched=false;
331  for (reco::IsolatedPixelTrackCandidateCollection::const_iterator it = trackCollection->begin(); it!=trackCollection->end(); it++)
332  {
333 
334  if (abs((trit->pt() - it->pt())/it->pt()) < 0.005 && abs(trit->eta() - it->eta()) < 0.01)
335  {
336  isoMatched=it;
337  matched=true;
338  break;
339  }
340  }
341  if (!matched) continue;
342 
343  if (trit->hitPattern().numberOfValidHits()<MinNTrackHitsBarrel) continue;
344  if (fabs(trit->eta())>1.47&&trit->hitPattern().numberOfValidStripTECHits()<MinNTECHitsEndcap) continue;
345 
346  //container for used recHits
347  std::vector<int> usedHits;
348  //
349 
350  calEnergy = sqrt(trit->px()*trit->px()+trit->py()*trit->py()+trit->pz()*trit->pz()+0.14*0.14);
351 
352  trackEta = trit->eta();
353  trackPhi = trit->phi();
354 
355  double corrHCAL = 1.; //another possibility for correction. - why?
356 
357 
358  // cout << endl << " ISO TRACK E = "<< calEnergy << " ETA = " << trackEta<< " PHI = " << trackPhi << " Correction " << corrHCAL<< endl;
359 
360  rvert = sqrt(trit->vx()*trit->vx()+trit->vy()*trit->vy()+trit->vz()*trit->vz());
361 
362  //Associate track with a calorimeter
364  //*(it->track().get())
365  double etaecal=info.trkGlobPosAtEcal.eta();
366  double phiecal=info.trkGlobPosAtEcal.phi();
367 
368  double etahcal=info.trkGlobPosAtHcal.eta();
369  //double phihcal=info.trkGlobPosAtHcal.phi();
370 
371 
372 
373  xTrkEcal=info.trkGlobPosAtEcal.x();
374  yTrkEcal=info.trkGlobPosAtEcal.y();
375  zTrkEcal=info.trkGlobPosAtEcal.z();
376 
377  xTrkHcal=info.trkGlobPosAtHcal.x();
378  yTrkHcal=info.trkGlobPosAtHcal.y();
379  zTrkHcal=info.trkGlobPosAtHcal.z();
380 
382 
383  int iphitrue = -10;
384  int ietatrue = 100;
385 
386  if (etahcal<1.392)
387  {
389  // const GlobalPoint tempPoint(newx, newy, newz);
390  //const DetId tempId = gHB->getClosestCell(tempPoint);
391  const HcalDetId tempId = gHB->getClosestCell(gP);
392  ietatrue = tempId.ieta();
393  iphitrue = tempId.iphi();
394  }
395 
396  if (etahcal>1.392 && etahcal<3.0)
397  {
399  const HcalDetId tempId = gHE->getClosestCell(gP);
400  ietatrue = tempId.ieta();
401  iphitrue = tempId.iphi();
402  }
403 
404  // eecal=info.coneEnergy(parameters_.dREcal, TrackDetMatchInfo::EcalRecHits);
405 // ehcal=info.coneEnergy(parameters_.dRHcal, TrackDetMatchInfo::HcalRecHits);
406 
407  double rmin = 0.07;
408  if( fabs(etaecal) > 1.47 ) rmin = 0.07*(fabs(etaecal)-0.47)*1.2;
409  if( fabs(etaecal) > 2.2 ) rmin = 0.07*(fabs(etaecal)-0.47)*1.4;
410 
411  MaxHit_struct MaxHit;
412 
413  // Find Ecal RecHit with maximum energy and collect other information
414  MaxHit.hitenergy=-100;
415 
416  double econus = 0.;
417  float ecal_cluster = 0.;
418 
419  //clear usedHits
420  usedHits.clear();
421  //
422 
423  for (std::vector<EcalRecHit>::const_iterator ehit=Hitecal.begin(); ehit!=Hitecal.end(); ehit++)
424  {
425  //check that this hit was not considered before and push it into usedHits
426  bool hitIsUsed=false;
427  int hitHashedIndex=-10000;
428  if (ehit->id().subdetId()==EcalBarrel)
429  {
430  EBDetId did(ehit->id());
431  hitHashedIndex=did.hashedIndex();
432  }
433 
434  if (ehit->id().subdetId()==EcalEndcap)
435  {
436  EEDetId did(ehit->id());
437  hitHashedIndex=did.hashedIndex();
438  }
439  for (uint32_t i=0; i<usedHits.size(); i++)
440  {
441  if (usedHits[i]==hitHashedIndex) hitIsUsed=true;
442  }
443  if (hitIsUsed) continue;
444  usedHits.push_back(hitHashedIndex);
445  //
446 
447  if((*ehit).energy() > MaxHit.hitenergy)
448  {
449  MaxHit.hitenergy = (*ehit).energy();
450  }
451 
452  GlobalPoint pos = geo->getPosition((*ehit).detid());
453  double phihit = pos.phi();
454  double etahit = pos.eta();
455 
456  double dphi = fabs(phiecal - phihit);
457  if(dphi > 4.*atan(1.)) dphi = 8.*atan(1.) - dphi;
458  double deta = fabs(etaecal - etahit);
459  double dr = sqrt(dphi*dphi + deta*deta);
460 
461  if (dr < rmin) {
462  econus = econus + (*ehit).energy();
463  }
464 
465  if (dr < 0.13) ecal_cluster += (*ehit).energy();
466 
467  }
468  MaxHit.hitenergy=-100;
469 
470  //clear usedHits
471  usedHits.clear();
472  //
473 
474  //float dddeta = 1000.;
475  //float dddphi = 1000.;
476  //int iphitrue = 1234;
477  //int ietatrue = 1234;
478 
479  for (HBHERecHitCollection::const_iterator hhit=Hithbhe.begin(); hhit!=Hithbhe.end(); hhit++)
480  {
481 
482  //check that this hit was not considered before and push it into usedHits
483  bool hitIsUsed=false;
484  int hitHashedIndex=hhit->id().hashed_index();
485  for (uint32_t i=0; i<usedHits.size(); i++)
486  {
487  if (usedHits[i]==hitHashedIndex) hitIsUsed=true;
488  }
489  if (hitIsUsed) continue;
490  usedHits.push_back(hitHashedIndex);
491  //
492 
493  // rof 16.05.2008 start: include the possibility for recalibration
494  float recal = 1;
495  // rof end
496 
497  GlobalPoint pos = geo->getPosition(hhit->detid());
498  double phihit = pos.phi();
499  double etahit = pos.eta();
500 
501  int iphihitm = (hhit->id()).iphi();
502  int ietahitm = (hhit->id()).ieta();
503  int depthhit = (hhit->id()).depth();
504  double enehit = hhit->energy() * recal;
505 
506  if (depthhit!=1) continue;
507 
508  double dphi = fabs(info.trkGlobPosAtHcal.phi() - phihit);
509  if(dphi > 4.*atan(1.)) dphi = 8.*atan(1.) - dphi;
510  double deta = fabs(info.trkGlobPosAtHcal.eta() - etahit);
511  double dr = sqrt(dphi*dphi + deta*deta);
512 
513  /* Commented. Another way of finding true projection is implemented
514  if (deta<dddeta) {
515  ietatrue = ietahitm;
516  dddeta=deta;
517  }
518 
519  if (dphi<dddphi) {
520  iphitrue = iphihitm;
521  dddphi=dphi;
522  }*/
523 
524  if(dr<associationConeSize_)
525  {
526 
527 
528  for (HBHERecHitCollection::const_iterator hhit2=Hithbhe.begin(); hhit2!=Hithbhe.end(); hhit2++)
529  {
530  int iphihitm2 = (hhit2->id()).iphi();
531  int ietahitm2 = (hhit2->id()).ieta();
532  int depthhit2 = (hhit2->id()).depth();
533  double enehit2 = hhit2->energy() * recal;
534 
535  if ( iphihitm==iphihitm2 && ietahitm==ietahitm2 && depthhit!=depthhit2){
536 
537  enehit = enehit+enehit2;
538 
539  }
540 
541  }
542 
543  if(enehit > MaxHit.hitenergy)
544  {
545  MaxHit.hitenergy = enehit;
546  MaxHit.ietahitm = (hhit->id()).ieta();
547  MaxHit.iphihitm = (hhit->id()).iphi();
548  MaxHit.depthhit = (hhit->id()).depth();
549 
550  MaxHit.posMax = geo->getPosition(hhit->detid());
551 
552  }
553  }
554  }
555 
556 
557  Bool_t passCuts = kFALSE;
558  if(calEnergy > energyMinIso && calEnergy < energyMaxIso && isoMatched->energyIn() < energyECALmip &&
559  isoMatched->maxPtPxl() < maxPNear && abs(MaxHit.ietahitm)<30 && MaxHit.hitenergy > 0.){ passCuts = kTRUE; }
560 
561 
562 
563  if(AxB_=="5x5" || AxB_=="3x3" || AxB_=="7x7"|| AxB_=="Cone")
564  {
565 
566  //clear usedHits
567  usedHits.clear();
568  //
569 
570  for (HBHERecHitCollection::const_iterator hhit=Hithbhe.begin(); hhit!=Hithbhe.end(); hhit++)
571  {
572 
573  //check that this hit was not considered before and push it into usedHits
574  bool hitIsUsed=false;
575  int hitHashedIndex=hhit->id().hashed_index();
576  for (uint32_t i=0; i<usedHits.size(); i++)
577  {
578  if (usedHits[i]==hitHashedIndex) hitIsUsed=true;
579  }
580  if (hitIsUsed) continue;
581  usedHits.push_back(hitHashedIndex);
582  //
583 
584  int DIETA = 100;
585  if(MaxHit.ietahitm*(hhit->id()).ieta()>0)
586  {
587  DIETA = MaxHit.ietahitm - (hhit->id()).ieta();
588  }
589  if(MaxHit.ietahitm*(hhit->id()).ieta()<0)
590  {
591  DIETA = MaxHit.ietahitm - (hhit->id()).ieta();
592  DIETA = DIETA>0 ? DIETA-1 : DIETA+1;
593  }
594 
595  int DIPHI = abs(MaxHit.iphihitm - (hhit->id()).iphi());
596  DIPHI = DIPHI>36 ? 72-DIPHI : DIPHI;
597  /*AP DIPHI = DIPHI<-36 ? 72+DIPHI : DIPHI; */
598 
599  int numbercell=0;
600  if(AxB_=="3x3") numbercell = 1;
601  if(AxB_=="5x5") numbercell = 2;
602  if(AxB_=="7x7") numbercell = 3;
603  if(AxB_=="Cone") numbercell = 1000;
604 
605  if( abs(DIETA)<=numbercell && (abs(DIPHI)<=numbercell || ( abs(MaxHit.ietahitm)>=20 && abs(DIPHI)<=numbercell+1)) ) {
606 
607  // rof 16.05.2008 start: include the possibility for recalibration
608  float recal = 1;
609 
610  int iii3i5 = 0;
611 
612 
613  const GlobalPoint pos2 = geo->getPosition(hhit->detid());
614 
615  if(passCuts){
616 
617 
618  if(AxB_=="5x5" || AxB_=="3x3" || AxB_=="7x7") {
619 
620  rawEnergyVec.push_back(hhit->energy() * recal * corrHCAL);
621  detidvec.push_back(hhit->id());
622  detiphi.push_back((hhit->id()).iphi());
623  detieta.push_back((hhit->id()).ieta());
624  i3i5.push_back(iii3i5);
625 
626  }
627 
628  if (AxB_=="Cone" && getDistInPlaneSimple(gP,pos2) < calibrationConeSize_) {
629 
630  rawEnergyVec.push_back(hhit->energy() * recal * corrHCAL);
631  detidvec.push_back(hhit->id());
632  detiphi.push_back((hhit->id()).iphi());
633  detieta.push_back((hhit->id()).ieta());
634  i3i5.push_back(iii3i5);
635 
636  }
637 
638  }
639  }
640  }
641  }
642 
643  if(AxB_!="3x3" && AxB_!="5x5" && AxB_!="7x7" && AxB_!="Cone") LogWarning(" AxB ")<<" Not supported: "<< AxB_;
644 
645  if(passCuts){
646 
647  input_to_L3 << rawEnergyVec.size() << " " << calEnergy;
648 
649 
650  for (unsigned int i=0; i<rawEnergyVec.size(); i++)
651  {
652  input_to_L3 << " " << rawEnergyVec.at(i) << " " << detidvec.at(i).rawId() ;
653 
654  }
655  input_to_L3 <<endl;
656 
657  eventNumber = iEvent.id().event();
658  runNumber = iEvent.id().run();
659  iEtaHit = ietatrue;
660  iPhiHit = iphitrue;
661  emEnergy = isoMatched->energyIn();
662 // exampleP4->SetPxPyPzE(2, 1, 1, 10);
663 
664  numberOfCells=rawEnergyVec.size();
665  targetE = calEnergy;
666 
667  for (unsigned int ia=0; ia<numberOfCells; ++ia) {
668  cellEnergy = rawEnergyVec.at(ia);
669  cell = detidvec.at(ia).rawId();
670 
671  new((*cells)[ia]) TCell(cell, cellEnergy);
672 
673 
674  }
675 
676  tree->Fill();
677 
678  cells->Clear();
679 
680  }
681 
682  rawEnergyVec.clear();
683  detidvec.clear();
684  detiphi.clear();
685  detieta.clear();
686  i3i5.clear();
687 
688  try {
690  iEvent.getByLabel(hoLabel_,ho);
691  const HORecHitCollection Hitho = *(ho.product());
692 
693  //clear usedHits
694  usedHits.clear();
695  //
696 
697  for(HORecHitCollection::const_iterator hoItr=Hitho.begin(); hoItr!=Hitho.end(); hoItr++)
698  {
699 
700  //check that this hit was not considered before and push it into usedHits
701  bool hitIsUsed=false;
702  int hitHashedIndex=hoItr->id().hashed_index();
703  for (uint32_t i=0; i<usedHits.size(); i++)
704  {
705  if (usedHits[i]==hitHashedIndex) hitIsUsed=true;
706  }
707  if (hitIsUsed) continue;
708  usedHits.push_back(hitHashedIndex);
709 
710  /*AP
711  GlobalPoint pos = geo->getPosition(hoItr->detid());
712  double phihit = pos.phi();
713  double etahit = pos.eta();
714 
715  int iphihitm = (hoItr->id()).iphi();
716  int ietahitm = (hoItr->id()).ieta();
717  int depthhit = (hoItr->id()).depth();
718 
719  double dphi = fabs(trackPhi - phihit);
720  if(dphi > 4.*atan(1.)) dphi = 8.*atan(1.) - dphi;
721  double deta = fabs(trackEta - etahit);
722  double dr = sqrt(dphi*dphi + deta*deta);
723  */
724 
725  }
726  } catch (cms::Exception& e) { // can't find it!
727  if (!allowMissingInputs_) throw e;
728  }
729  }
730 }
RunNumber_t run() const
Definition: EventID.h:42
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
EventNumber_t event() const
Definition: EventID.h:44
int i
Definition: DBlmapReader.cc:9
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:73
GlobalPoint posMax
Definition: MaxHit_struct.h:11
static FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
std::vector< T >::const_iterator const_iterator
void push_back(T const &t)
#define abs(x)
Definition: mlp_lapack.h:159
Definition: TCell.h:15
TrackDetectorAssociator trackAssociator_
double getDistInPlaneSimple(const GlobalPoint caloPoint, const GlobalPoint rechitPoint)
T sqrt(T t)
Definition: SSEVec.h:28
int ieta() const
get the cell ieta
Definition: HcalDetId.h:38
const GlobalPoint & getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:68
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
const CaloGeometry * geo
const_iterator end() const
virtual DetId getClosestCell(const GlobalPoint &r) const
TrackAssociatorParameters parameters_
int iphi() const
get the cell iphi
Definition: HcalDetId.h:40
int hashedIndex() const
Definition: EEDetId.h:177
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: Handle.h:74
T eta() const
Definition: PV3DBase.h:70
edm::EventID id() const
Definition: EventBase.h:56
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
math::XYZPoint trkGlobPosAtEcal
Track position at different parts of the calorimeter.
const_iterator begin() const
void HcalIsoTrkAnalyzer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 736 of file HcalIsoTrkAnalyzer.cc.

References BuildWebpage::rootFile, inputsource_file_cfi::runNumber, and diffTreeTool::tree.

737 {
738 
739  // MyL3Algo = new MinL3AlgoUniv<HcalDetId>(eventWeight);
740 
741  input_to_L3.open("input_to_l3.txt");
742 
743  rootFile = new TFile("rootFile.root", "RECREATE");
744  tree = new TTree("hcalCalibTree", "Tree for IsoTrack Calibration");
745  cells = new TClonesArray("TCell", 10000);
746 // cells3x3 = new TRefArray;
747 // cellsPF = new TRefArray;
748 // exampleP4 = new TLorentzVector();
749  tagJetP4 = new TLorentzVector(); // dijet
750  probeJetP4 = new TLorentzVector(); // dijet
751 
752  tree->Branch("cells", &cells, 64000, 0);
753  tree->Branch("targetE", &targetE, "targetE/F");
754  tree->Branch("emEnergy", &emEnergy, "emEnergy/F");
755 
756  tree->Branch("xTrkEcal", &xTrkEcal, "xTrkEcal/F");
757  tree->Branch("yTrkEcal", &yTrkEcal, "yTrkEcal/F");
758  tree->Branch("zTrkEcal", &zTrkEcal, "zTrkEcal/F");
759  tree->Branch("xTrkHcal", &xTrkHcal, "xTrkHcal/F");
760  tree->Branch("yTrkHcal", &yTrkHcal, "yTrkHcal/F");
761  tree->Branch("zTrkHcal", &zTrkHcal, "zTrkHcal/F");
762 
763 // tree->Branch("exampleP4", "TLorentzVector", &exampleP4);
764 // tree->Branch("cells3x3", &cells3x3, 64000, 0);
765 // tree->Branch("cellsPF", &cellsPF, 64000, 0);
766  tree->Branch("iEtaHit", &iEtaHit, "iEtaHit/I");
767  tree->Branch("iPhiHit", &iPhiHit, "iPhiHit/i");
768  tree->Branch("eventNumber", &eventNumber, "eventNumber/i");
769  tree->Branch("runNumber", &runNumber, "runNumber/i");
770 
771  tree->Branch("tagJetP4", "TLorentzVector", &tagJetP4); // dijet
772  tree->Branch("probeJetP4", "TLorentzVector", &probeJetP4); // dijet
773  tree->Branch("etVetoJet", &etVetoJet, "etVetoJet/F"); // dijet
774  tree->Branch("tagJetEmFrac", &tagJetEmFrac,"tagJetEmFrac/F"); // dijet
775  tree->Branch("probeJetEmFrac", &probeJetEmFrac,"probeJetEmFrac/F"); // dijet
776 
777 }
TLorentzVector * probeJetP4
TLorentzVector * tagJetP4
void HcalIsoTrkAnalyzer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 781 of file HcalIsoTrkAnalyzer.cc.

References BuildWebpage::rootFile.

781  {
782 
783  input_to_L3.close();
784 
785  rootFile->Write();
786  rootFile->Close();
787 
788  if (cells) delete cells;
789 // if (cells3x3) delete cells3x3;
790 // if (cellsPF) delete cellsPF;
791 // if (exampleP4) delete exampleP4;
792  if (tagJetP4) delete tagJetP4; // dijet
793  if (probeJetP4) delete probeJetP4; // dijet
794 
795 }
TLorentzVector * probeJetP4
TLorentzVector * tagJetP4
double HcalIsoTrkAnalyzer::getDistInPlaneSimple ( const GlobalPoint  caloPoint,
const GlobalPoint  rechitPoint 
)

Definition at line 194 of file HcalIsoTrkAnalyzer.cc.

References Vector3DBase< T, FrameTag >::dot(), PV3DBase< T, PVType, FrameType >::mag(), Vector3DBase< T, FrameTag >::unit(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

196 {
197 
198  // Simplified version of getDistInPlane
199  // Assume track direction is origin -> point of hcal intersection
200 
201  const GlobalVector caloIntersectVector(caloPoint.x(),
202  caloPoint.y(),
203  caloPoint.z());
204 
205  const GlobalVector caloIntersectUnitVector = caloIntersectVector.unit();
206 
207  const GlobalVector rechitVector(rechitPoint.x(),
208  rechitPoint.y(),
209  rechitPoint.z());
210 
211  const GlobalVector rechitUnitVector = rechitVector.unit();
212 
213  double dotprod = caloIntersectUnitVector.dot(rechitUnitVector);
214  double rechitdist = caloIntersectVector.mag()/dotprod;
215 
216 
217  const GlobalVector effectiveRechitVector = rechitdist*rechitUnitVector;
218  const GlobalPoint effectiveRechitPoint(effectiveRechitVector.x(),
219  effectiveRechitVector.y(),
220  effectiveRechitVector.z());
221 
222 
223  GlobalVector distance_vector = effectiveRechitPoint-caloPoint;
224 
225  if (dotprod > 0.)
226  {
227  return distance_vector.mag();
228  }
229  else
230  {
231  return 999999.;
232 
233  }
234 
235 
236 }
T y() const
Definition: PV3DBase.h:57
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:107
T mag() const
Definition: PV3DBase.h:61
T z() const
Definition: PV3DBase.h:58
Vector3DBase unit() const
Definition: Vector3DBase.h:57
T x() const
Definition: PV3DBase.h:56

Member Data Documentation

bool HcalIsoTrkAnalyzer::allowMissingInputs_
private

Definition at line 132 of file HcalIsoTrkAnalyzer.cc.

double HcalIsoTrkAnalyzer::associationConeSize_
private

Definition at line 130 of file HcalIsoTrkAnalyzer.cc.

string HcalIsoTrkAnalyzer::AxB_
private

Definition at line 131 of file HcalIsoTrkAnalyzer.cc.

double HcalIsoTrkAnalyzer::calibrationConeSize_
private

Definition at line 130 of file HcalIsoTrkAnalyzer.cc.

UInt_t HcalIsoTrkAnalyzer::cell
private

Definition at line 163 of file HcalIsoTrkAnalyzer.cc.

Float_t HcalIsoTrkAnalyzer::cellEnergy
private

Definition at line 164 of file HcalIsoTrkAnalyzer.cc.

TClonesArray* HcalIsoTrkAnalyzer::cells
private

Definition at line 166 of file HcalIsoTrkAnalyzer.cc.

TRefArray* HcalIsoTrkAnalyzer::cells3x3
private

Definition at line 167 of file HcalIsoTrkAnalyzer.cc.

TRefArray* HcalIsoTrkAnalyzer::cellsPF
private

Definition at line 168 of file HcalIsoTrkAnalyzer.cc.

char HcalIsoTrkAnalyzer::dirname[50]
private

Definition at line 155 of file HcalIsoTrkAnalyzer.cc.

InputTag HcalIsoTrkAnalyzer::eLabel_
private

Definition at line 119 of file HcalIsoTrkAnalyzer.cc.

Float_t HcalIsoTrkAnalyzer::emEnergy
private

Definition at line 182 of file HcalIsoTrkAnalyzer.cc.

double HcalIsoTrkAnalyzer::energyECALmip
private

Definition at line 153 of file HcalIsoTrkAnalyzer.cc.

double HcalIsoTrkAnalyzer::energyMaxIso
private

Definition at line 152 of file HcalIsoTrkAnalyzer.cc.

double HcalIsoTrkAnalyzer::energyMinIso
private

Definition at line 152 of file HcalIsoTrkAnalyzer.cc.

Float_t HcalIsoTrkAnalyzer::etVetoJet
private

Definition at line 186 of file HcalIsoTrkAnalyzer.cc.

UInt_t HcalIsoTrkAnalyzer::eventNumber
private
float HcalIsoTrkAnalyzer::eventWeight
private

Definition at line 151 of file HcalIsoTrkAnalyzer.cc.

const CaloGeometry* HcalIsoTrkAnalyzer::geo
private

Definition at line 116 of file HcalIsoTrkAnalyzer.cc.

InputTag HcalIsoTrkAnalyzer::hbheLabel_
private

Definition at line 117 of file HcalIsoTrkAnalyzer.cc.

char HcalIsoTrkAnalyzer::hname[20]
private

Definition at line 156 of file HcalIsoTrkAnalyzer.cc.

InputTag HcalIsoTrkAnalyzer::hoLabel_
private

Definition at line 118 of file HcalIsoTrkAnalyzer.cc.

char HcalIsoTrkAnalyzer::htitle[80]
private

Definition at line 157 of file HcalIsoTrkAnalyzer.cc.

Int_t HcalIsoTrkAnalyzer::iEtaHit
private

Definition at line 171 of file HcalIsoTrkAnalyzer.cc.

ofstream HcalIsoTrkAnalyzer::input_to_L3
private

Definition at line 190 of file HcalIsoTrkAnalyzer.cc.

UInt_t HcalIsoTrkAnalyzer::iPhiHit
private

Definition at line 172 of file HcalIsoTrkAnalyzer.cc.

std::string HcalIsoTrkAnalyzer::m_ebInstance
private

Definition at line 125 of file HcalIsoTrkAnalyzer.cc.

std::string HcalIsoTrkAnalyzer::m_ecalLabel
private

Definition at line 124 of file HcalIsoTrkAnalyzer.cc.

std::string HcalIsoTrkAnalyzer::m_eeInstance
private

Definition at line 126 of file HcalIsoTrkAnalyzer.cc.

std::string HcalIsoTrkAnalyzer::m_hcalLabel
private

Definition at line 127 of file HcalIsoTrkAnalyzer.cc.

int HcalIsoTrkAnalyzer::m_histoFlag
private

Definition at line 128 of file HcalIsoTrkAnalyzer.cc.

std::string HcalIsoTrkAnalyzer::m_inputTrackLabel
private

Definition at line 123 of file HcalIsoTrkAnalyzer.cc.

double HcalIsoTrkAnalyzer::maxPNear
private

Definition at line 153 of file HcalIsoTrkAnalyzer.cc.

int HcalIsoTrkAnalyzer::MinNTECHitsEndcap
private

Definition at line 150 of file HcalIsoTrkAnalyzer.cc.

int HcalIsoTrkAnalyzer::MinNTrackHitsBarrel
private

Definition at line 150 of file HcalIsoTrkAnalyzer.cc.

int HcalIsoTrkAnalyzer::nIterations
private

Definition at line 150 of file HcalIsoTrkAnalyzer.cc.

UInt_t HcalIsoTrkAnalyzer::numberOfCells
private

Definition at line 162 of file HcalIsoTrkAnalyzer.cc.

string HcalIsoTrkAnalyzer::outputFileName_
private

Definition at line 133 of file HcalIsoTrkAnalyzer.cc.

TrackAssociatorParameters HcalIsoTrkAnalyzer::parameters_
private
Float_t HcalIsoTrkAnalyzer::probeJetEmFrac
private

Definition at line 188 of file HcalIsoTrkAnalyzer.cc.

TLorentzVector* HcalIsoTrkAnalyzer::probeJetP4
private

Definition at line 185 of file HcalIsoTrkAnalyzer.cc.

TFile* HcalIsoTrkAnalyzer::rootFile
private

Definition at line 159 of file HcalIsoTrkAnalyzer.cc.

UInt_t HcalIsoTrkAnalyzer::runNumber
private

Definition at line 170 of file HcalIsoTrkAnalyzer.cc.

double HcalIsoTrkAnalyzer::rvert
private

Definition at line 136 of file HcalIsoTrkAnalyzer.cc.

Float_t HcalIsoTrkAnalyzer::tagJetEmFrac
private

Definition at line 187 of file HcalIsoTrkAnalyzer.cc.

TLorentzVector* HcalIsoTrkAnalyzer::tagJetP4
private

Definition at line 184 of file HcalIsoTrkAnalyzer.cc.

Float_t HcalIsoTrkAnalyzer::targetE
private

Definition at line 161 of file HcalIsoTrkAnalyzer.cc.

TrackDetectorAssociator HcalIsoTrkAnalyzer::trackAssociator_
private

Definition at line 113 of file HcalIsoTrkAnalyzer.cc.

double HcalIsoTrkAnalyzer::trackEta
private

Definition at line 135 of file HcalIsoTrkAnalyzer.cc.

InputTag HcalIsoTrkAnalyzer::trackLabel1_
private

Definition at line 121 of file HcalIsoTrkAnalyzer.cc.

InputTag HcalIsoTrkAnalyzer::trackLabel_
private

Definition at line 120 of file HcalIsoTrkAnalyzer.cc.

double HcalIsoTrkAnalyzer::trackPhi
private

Definition at line 135 of file HcalIsoTrkAnalyzer.cc.

TTree* HcalIsoTrkAnalyzer::tree
private
Float_t HcalIsoTrkAnalyzer::xTrkEcal
private

Definition at line 174 of file HcalIsoTrkAnalyzer.cc.

Float_t HcalIsoTrkAnalyzer::xTrkHcal
private

Definition at line 178 of file HcalIsoTrkAnalyzer.cc.

Float_t HcalIsoTrkAnalyzer::yTrkEcal
private

Definition at line 175 of file HcalIsoTrkAnalyzer.cc.

Float_t HcalIsoTrkAnalyzer::yTrkHcal
private

Definition at line 179 of file HcalIsoTrkAnalyzer.cc.

Float_t HcalIsoTrkAnalyzer::zTrkEcal
private

Definition at line 176 of file HcalIsoTrkAnalyzer.cc.

Float_t HcalIsoTrkAnalyzer::zTrkHcal
private

Definition at line 180 of file HcalIsoTrkAnalyzer.cc.