CMS 3D CMS Logo

Public Member Functions | Private Attributes

cms::MinBias Class Reference

#include <MinBias.h>

Inheritance diagram for cms::MinBias:
edm::EDAnalyzer

List of all members.

Public Member Functions

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

Private Attributes

bool allowMissingInputs_
int depth
float eta
std::string fOutputFileName
const CaloGeometrygeo
std::string hbheLabel_
std::string hfLabel_
std::string hoLabel_
TFile * hOutputFile
int ieta
int ievent
int iphi
float mom1
float mom2
float mom3
float mom4
int mydet
int mysubd
TTree * myTree
float occup
float phi
std::map< DetId, double > theFillDetMap0
std::map< DetId, double > theFillDetMap1
std::map< DetId, double > theFillDetMap2
std::map< DetId, double > theFillDetMap3
std::map< DetId, double > theFillDetMap4

Detailed Description

Definition at line 42 of file MinBias.h.


Constructor & Destructor Documentation

cms::MinBias::MinBias ( const edm::ParameterSet iConfig) [explicit]

Definition at line 9 of file MinBias.cc.

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

{
  // get names of modules, producing object collections
  hbheLabel_= iConfig.getParameter<std::string>("hbheInput");
  hoLabel_=iConfig.getParameter<std::string>("hoInput");
  hfLabel_=iConfig.getParameter<std::string>("hfInput");
  allowMissingInputs_=iConfig.getUntrackedParameter<bool>("AllowMissingInputs",false);
  // get name of output file with histogramms
  fOutputFileName = iConfig.getUntrackedParameter<std::string>("HistOutFile"); 

}
cms::MinBias::~MinBias ( )

Definition at line 22 of file MinBias.cc.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

}

Member Function Documentation

void cms::MinBias::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 104 of file MinBias.cc.

References gather_cfg::cout, cond::rpcobgas::detid, edm::EventSetup::get(), edm::Event::getByLabel(), DetId::Hcal, edm::HandleBase::isValid(), funct::pow(), and edm::ESHandle< T >::product().

{

   using namespace edm;
   if(ievent == 0 ){ 
   edm::ESHandle<CaloGeometry> pG;
   iSetup.get<CaloGeometryRecord>().get(pG);
   geo = pG.product();
   std::vector<DetId> did =  geo->getValidDetIds();

   for(std::vector<DetId>::const_iterator id=did.begin(); id != did.end(); id++)
   {
      if( (*id).det() == DetId::Hcal ) {
      theFillDetMap0[*id] = 0.;
      theFillDetMap1[*id] = 0.;
      theFillDetMap2[*id] = 0.;
      theFillDetMap3[*id] = 0.;
      theFillDetMap4[*id] = 0.;
   }
   }
   }


 
  if (!hbheLabel_.empty()) {
    edm::Handle<HBHERecHitCollection> hbhe;
    iEvent.getByLabel(hbheLabel_,hbhe);
    if (!hbhe.isValid()) {
      // can't find it!
      if (!allowMissingInputs_) {
        *hbhe;  // will throw the proper exception      
      }
    } else {
      for(HBHERecHitCollection::const_iterator hbheItr = (*hbhe).begin();
          hbheItr != (*hbhe).end(); ++hbheItr)
        {
          DetId id = (hbheItr)->detid();
          if( (*hbheItr).energy() > 0. ) std::cout<<" Energy = "<<(*hbheItr).energy()<<std::endl;
          theFillDetMap0[id] = theFillDetMap0[id]+ 1.;
          theFillDetMap1[id] = theFillDetMap1[id]+(*hbheItr).energy();
          theFillDetMap2[id] = theFillDetMap2[id]+pow((*hbheItr).energy(),2);
          theFillDetMap3[id] = theFillDetMap3[id]+pow((*hbheItr).energy(),3);
          theFillDetMap4[id] = theFillDetMap4[id]+pow((*hbheItr).energy(),4);
        }
    }
  }

  if (!hoLabel_.empty()) {
    edm::Handle<HORecHitCollection> ho;
    iEvent.getByLabel(hoLabel_,ho);
    if (!ho.isValid()) {
      // can't find it!
      if (!allowMissingInputs_) {
        *ho;  // will throw the proper exception
      }
  } else {
      for(HORecHitCollection::const_iterator hoItr = (*ho).begin();
          hoItr != (*ho).end(); ++hoItr)
        {
          DetId id = (hoItr)->detid();
          theFillDetMap0[id] = theFillDetMap0[id]+ 1.;
          theFillDetMap1[id] = theFillDetMap1[id]+(*hoItr).energy();
          theFillDetMap2[id] = theFillDetMap2[id]+pow((*hoItr).energy(),2);
          theFillDetMap3[id] = theFillDetMap3[id]+pow((*hoItr).energy(),3);
          theFillDetMap4[id] = theFillDetMap4[id]+pow((*hoItr).energy(),4);
        }
    }
  }

  if (!hfLabel_.empty()) {
    edm::Handle<HFRecHitCollection> hf;
    iEvent.getByLabel(hfLabel_,hf);
    if (!hf.isValid()) {
      // can't find it!
      if (!allowMissingInputs_) {
        *hf;  // will throw the proper exception
      }
  } else {
      for(HFRecHitCollection::const_iterator hfItr = (*hf).begin();
          hfItr != (*hf).end(); ++hfItr)
        {  
          DetId id = (hfItr)->detid();
          theFillDetMap0[id] = theFillDetMap0[id]+ 1.;
          theFillDetMap1[id] = theFillDetMap1[id]+(*hfItr).energy();
          theFillDetMap2[id] = theFillDetMap2[id]+pow((*hfItr).energy(),2);
          theFillDetMap3[id] = theFillDetMap3[id]+pow((*hfItr).energy(),3);
          theFillDetMap4[id] = theFillDetMap4[id]+pow((*hfItr).energy(),4);
        }
    }
  }
  
}
void cms::MinBias::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 30 of file MinBias.cc.

References eta(), and phi.

{
   hOutputFile   = new TFile( fOutputFileName.c_str(), "RECREATE" ) ; 
   myTree = new TTree("RecJet","RecJet Tree");
   myTree->Branch("mydet",  &mydet, "mydet/I");
   myTree->Branch("mysubd",  &mysubd, "mysubd/I");
   myTree->Branch("depth",  &depth, "depth/I");
   myTree->Branch("ieta",  &ieta, "ieta/I");
   myTree->Branch("iphi",  &iphi, "iphi/I");
   myTree->Branch("eta",  &eta, "eta/F");
   myTree->Branch("phi",  &phi, "phi/F");
   myTree->Branch("mom1",  &mom1, "mom1/F");
   myTree->Branch("mom2",  &mom2, "mom2/F");
   myTree->Branch("mom3",  &mom3, "mom3/F");
   myTree->Branch("mom4",  &mom4, "mom4/F");

   ievent = 0;

}
void cms::MinBias::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 50 of file MinBias.cc.

References gather_cfg::cout, HcalDetId::depth(), eta(), PV3DBase< T, PVType, FrameType >::eta(), DetId::Hcal, i, HcalDetId::ieta(), HcalDetId::iphi(), PV3DBase< T, PVType, FrameType >::phi(), phi, pos, funct::pow(), and HcalDetId::subdet().

{

   const std::vector<DetId>& did =  geo->getSubdetectorGeometry( DetId::Hcal, 1 )->getValidDetIds() ;
   int i=0;
   for(std::vector<DetId>::const_iterator id=did.begin(); id != did.end(); id++)
   {
//      if( (*id).det() == DetId::Hcal ) {
      GlobalPoint pos = geo->getPosition(*id);
      mydet = ((*id).rawId()>>28)&0xF;
      mysubd = ((*id).rawId()>>25)&0x7;
      depth = HcalDetId(*id).depth();
      ieta = HcalDetId(*id).ieta();
      iphi = HcalDetId(*id).iphi();
      phi = pos.phi();
      eta = pos.eta();
      if ( theFillDetMap0[*id] > 0. )
      {
      mom1 = theFillDetMap1[*id]/theFillDetMap0[*id];
      mom2 = theFillDetMap2[*id]/theFillDetMap0[*id]-(mom1*mom1);
      mom3 = theFillDetMap3[*id]/theFillDetMap0[*id]-3.*mom1*theFillDetMap2[*id]/theFillDetMap0[*id]+
             2.*pow(mom2,3);
      mom4 = (theFillDetMap4[*id]-4.*mom1*theFillDetMap3[*id]+6.*pow(mom1,2)*theFillDetMap2[*id])/theFillDetMap0[*id]-3.*pow(mom1,4);
        
      } else
      {
       mom1 = 0.; mom2 = 0.; mom3 = 0.; mom4 = 0.; 
      }     
      std::cout<<" Detector "<<(*id).rawId()<<" mydet "<<mydet<<" "<<mysubd<<" "<<depth<<" "<<
      HcalDetId(*id).subdet()<<" "<<ieta<<" "<<iphi<<" "<<pos.eta()<<" "<<pos.phi()<<std::endl;
      std::cout<<" Energy "<<mom1<<" "<<mom2<<std::endl;
      myTree->Fill();
      i++;
//      }
   }
   std::cout<<" The number of CaloDet records "<<did.size()<<std::endl;
   std::cout<<" The number of Hcal records "<<i<<std::endl;


   std::cout << "===== Start writing user histograms =====" << std::endl;
   hOutputFile->SetCompressionLevel(2);
   hOutputFile->cd();
   myTree->Write();
   hOutputFile->Close() ;
   std::cout << "===== End writing user histograms =======" << std::endl; 
}

Member Data Documentation

Definition at line 59 of file MinBias.h.

int cms::MinBias::depth [private]

Definition at line 65 of file MinBias.h.

float cms::MinBias::eta [private]

Definition at line 66 of file MinBias.h.

std::string cms::MinBias::fOutputFileName [private]

Definition at line 58 of file MinBias.h.

const CaloGeometry* cms::MinBias::geo [private]

Definition at line 68 of file MinBias.h.

std::string cms::MinBias::hbheLabel_ [private]

Definition at line 55 of file MinBias.h.

std::string cms::MinBias::hfLabel_ [private]

Definition at line 55 of file MinBias.h.

std::string cms::MinBias::hoLabel_ [private]

Definition at line 55 of file MinBias.h.

TFile* cms::MinBias::hOutputFile [private]

Definition at line 61 of file MinBias.h.

int cms::MinBias::ieta [private]

Definition at line 65 of file MinBias.h.

int cms::MinBias::ievent [private]

Definition at line 65 of file MinBias.h.

int cms::MinBias::iphi [private]

Definition at line 65 of file MinBias.h.

float cms::MinBias::mom1 [private]

Definition at line 67 of file MinBias.h.

float cms::MinBias::mom2 [private]

Definition at line 67 of file MinBias.h.

float cms::MinBias::mom3 [private]

Definition at line 67 of file MinBias.h.

float cms::MinBias::mom4 [private]

Definition at line 67 of file MinBias.h.

int cms::MinBias::mydet [private]

Definition at line 65 of file MinBias.h.

int cms::MinBias::mysubd [private]

Definition at line 65 of file MinBias.h.

TTree* cms::MinBias::myTree [private]

Definition at line 63 of file MinBias.h.

float cms::MinBias::occup [private]

Definition at line 67 of file MinBias.h.

float cms::MinBias::phi [private]

Definition at line 66 of file MinBias.h.

std::map<DetId,double> cms::MinBias::theFillDetMap0 [private]

Definition at line 70 of file MinBias.h.

std::map<DetId,double> cms::MinBias::theFillDetMap1 [private]

Definition at line 71 of file MinBias.h.

std::map<DetId,double> cms::MinBias::theFillDetMap2 [private]

Definition at line 72 of file MinBias.h.

std::map<DetId,double> cms::MinBias::theFillDetMap3 [private]

Definition at line 73 of file MinBias.h.

std::map<DetId,double> cms::MinBias::theFillDetMap4 [private]

Definition at line 74 of file MinBias.h.