CMS 3D CMS Logo

Public Member Functions | Private Attributes | Static Private Attributes

GlobalTest Class Reference

#include <GlobalTest.h>

Inheritance diagram for GlobalTest:
edm::EDAnalyzer

List of all members.

Public Member Functions

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

Private Attributes

MonitorElementcaloEnergyEBH_ [nMaxH]
MonitorElementcaloEnergyEEH_ [nMaxH]
DQMStoredbe_
std::string filename_
TFile * histfile_
char * labels [nrHistos]
int maxbunch_
int minbunch_
MonitorElementnrPileupsH_ [nMaxH]
MonitorElementnrTracksH_ [nMaxH]
MonitorElementnrVerticesH_ [nMaxH]
MonitorElementtrackPartIdH_ [nMaxH]

Static Private Attributes

static const int nMaxH = 10
static const int nrHistos = 6

Detailed Description

Description: test suite for Mixing Module

Definition at line 38 of file GlobalTest.h.


Constructor & Destructor Documentation

GlobalTest::GlobalTest ( const edm::ParameterSet iConfig) [explicit]

Definition at line 47 of file GlobalTest.cc.

References gather_cfg::cout, filename_, maxbunch_, and minbunch_.

                                                    :
filename_(iConfig.getParameter<std::string>("fileName")),
minbunch_(iConfig.getParameter<int>("minBunch")),maxbunch_(iConfig.getParameter<int>("maxBunch")), dbe_(0)
{
  std::cout << "Constructed GlobalTest, filename: "<<filename_<<" minbunch: "<<minbunch_<<", maxbunch: "<<maxbunch_<<std::endl;

}
GlobalTest::~GlobalTest ( )

Definition at line 55 of file GlobalTest.cc.

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

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 128 of file GlobalTest.cc.

References caloEnergyEBH_, caloEnergyEEH_, MonitorElement::Fill(), edm::Event::getByLabel(), edm::Event::getByType(), i, maxbunch_, minbunch_, nrTracksH_, nrVerticesH_, and trackPartIdH_.

{
   using namespace edm;
   using namespace std;
   
// Get input
    edm::Handle<CrossingFrame<SimTrack> > cf_track;
    edm::Handle<CrossingFrame<SimTrack> > cf_vertex;
    edm::Handle<CrossingFrame<PCaloHit> > cf_calohitE;
    edm::Handle<CrossingFrame<PCaloHit> > cf_calohitB;
    std::string ecalsubdetb("g4SimHitsEcalHitsEB");
    std::string ecalsubdete("g4SimHitsEcalHitsEE");
    iEvent.getByType(cf_track);
    iEvent.getByType(cf_vertex);
    iEvent.getByLabel("mix",ecalsubdetb,cf_calohitB);
    iEvent.getByLabel("mix",ecalsubdete,cf_calohitE);

    // number of events/bcr ??

    // number of tracks 
    for (int i=minbunch_;i<=maxbunch_;++i) {
       nrTracksH_[i-minbunch_]->Fill(cf_track->getNrPileups(i));
    }

    // number of vertices
    for (int i=minbunch_;i<=maxbunch_;++i) {
       nrVerticesH_[i-minbunch_]->Fill(cf_vertex->getNrPileups(i));
    }

   // part id for each track
    std::auto_ptr<MixCollection<SimTrack> > coltr(new MixCollection<SimTrack>(cf_track.product()));
    MixCollection<SimTrack>::iterator cfitr;
    for (cfitr=coltr->begin(); cfitr!=coltr->end();cfitr++) {
         trackPartIdH_[cfitr.bunch()-minbunch_]->Fill(cfitr->type());
     }

    // energy sum
    double sumE[10]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
    std::auto_ptr<MixCollection<PCaloHit> > colecalb(new MixCollection<PCaloHit>(cf_calohitB.product()));
    MixCollection<PCaloHit>::iterator cfiecalb;
    for (cfiecalb=colecalb->begin(); cfiecalb!=colecalb->end();cfiecalb++) {
       sumE[cfiecalb.bunch()-minbunch_]+=cfiecalb->energy();
      //      if (cfiecal.getTrigger())    tofecalhist_sig->Fill(cfiecal->time());
      //      else    tofecalhist->Fill(cfiecal->time());
    }
    for (int i=minbunch_;i<=maxbunch_;++i) {
       caloEnergyEBH_[i-minbunch_]->Fill(sumE[i-minbunch_]);
    }
    double sumEE[10]={0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
    std::auto_ptr<MixCollection<PCaloHit> > colecale(new MixCollection<PCaloHit>(cf_calohitE.product()));
    MixCollection<PCaloHit>::iterator cfiecale;
    for (cfiecale=colecale->begin(); cfiecale!=colecale->end();cfiecale++) {
       sumEE[cfiecale.bunch()-minbunch_]+=cfiecale->energy();
      //      if (cfiecal.getTrigger())    tofecalhist_sig->Fill(cfiecal->time());
      //      else    tofecalhist->Fill(cfiecal->time());
    }
    for (int i=minbunch_;i<=maxbunch_;++i) {
       caloEnergyEEH_[i-minbunch_]->Fill(sumEE[i-minbunch_]);
    }
}
void GlobalTest::beginJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 62 of file GlobalTest.cc.

References DQMStore::book1D(), caloEnergyEBH_, caloEnergyEEH_, dbe_, i, label, labels, maxbunch_, minbunch_, nrPileupsH_, nrTracksH_, nrVerticesH_, cmsCodeRules::cppFunctionSkipper::operator, DQMStore::setCurrentFolder(), DQMStore::showDirStructure(), and trackPartIdH_.

                          {
  using namespace std;
  
  // get hold of back-end interface
  dbe_ = Service<DQMStore>().operator->(); 
  dbe_->showDirStructure();
  dbe_->setCurrentFolder("MixingV/Mixing");
  //book histos
  std::string NrPileupEvts = "NrPileupEvts";
  size_t NrPileupEvtsSize = NrPileupEvts.size() + 1;
  std::string NrVertices = "NrVertices";
  size_t NrVerticesSize = NrVertices.size() + 1;
  std::string NrTracks = "NrTracks";
  size_t NrTracksSize = NrTracks.size() + 1;
  std::string TrackPartId = "TrackPartId";
  size_t TrackPartIdSize = TrackPartId.size() + 1;
  std::string CaloEnergyEB = "CaloEnergyEB";
  size_t CaloEnergyEBSize = CaloEnergyEB.size() + 1;
  std::string CaloEnergyEE = "CaloEnergyEE";
  size_t CaloEnergyEESize = CaloEnergyEE.size() + 1;
  
  labels[0] = new char [NrPileupEvtsSize];
  strncpy(labels[0], NrPileupEvts.c_str(), NrPileupEvtsSize);
  labels[1] = new char [NrVerticesSize];
  strncpy(labels[1], NrVertices.c_str(), NrVerticesSize); 
  labels[2] = new char [NrTracksSize];
  strncpy(labels[2], NrTracks.c_str(), NrTracksSize);
  labels[3] = new char [TrackPartIdSize];
  strncpy(labels[3], TrackPartId.c_str(), TrackPartIdSize);
  labels[4] = new char [CaloEnergyEBSize];
  strncpy(labels[4], CaloEnergyEB.c_str(), CaloEnergyEBSize);
  labels[5] = new char [CaloEnergyEESize];
  strncpy(labels[5], CaloEnergyEE.c_str(), CaloEnergyEESize);
  
  //FIXME: test for max nr of histos
  for (int i=minbunch_;i<=maxbunch_;++i) {
    int ii=i-minbunch_;
    char label[50];
    sprintf(label,"%s_%d",labels[0],i);
    nrPileupsH_[ii]    = dbe_->book1D(label,label,100,0,100);
    sprintf(label,"%s_%d",labels[1],i);
    nrVerticesH_[ii]   = dbe_->book1D(label,label,100,0,5000);
    sprintf(label,"%s_%d",labels[2],i);
    nrTracksH_[ii]     = dbe_->book1D(label,label,100,0,10000);
    sprintf(label,"%s_%d",labels[3],i);
    trackPartIdH_[ii]  =  dbe_->book1D(label,label,100,0,100);
    sprintf(label,"%s_%d",labels[4],i);
    caloEnergyEBH_ [ii]  = dbe_->book1D(label,label,100,0.,1000.);
    sprintf(label,"%s_%d",labels[5],i);
    caloEnergyEEH_ [ii]  = dbe_->book1D(label,label,100,0.,1000.);
  }
} 
void GlobalTest::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 116 of file GlobalTest.cc.

References dbe_, filename_, i, labels, and DQMStore::save().

                        {
 if (filename_.size() != 0 && dbe_ ) dbe_->save(filename_);
 
 for (int i = 0; i < 6; i++) delete[] labels[i];
}

Member Data Documentation

Definition at line 59 of file GlobalTest.h.

Referenced by analyze(), and beginJob().

Definition at line 60 of file GlobalTest.h.

Referenced by analyze(), and beginJob().

Definition at line 62 of file GlobalTest.h.

Referenced by beginJob(), and endJob().

std::string GlobalTest::filename_ [private]

Definition at line 49 of file GlobalTest.h.

Referenced by endJob(), and GlobalTest().

TFile* GlobalTest::histfile_ [private]

Definition at line 52 of file GlobalTest.h.

char* GlobalTest::labels[nrHistos] [private]

Definition at line 65 of file GlobalTest.h.

Referenced by beginJob(), and endJob().

int GlobalTest::maxbunch_ [private]

Definition at line 51 of file GlobalTest.h.

Referenced by analyze(), beginJob(), and GlobalTest().

int GlobalTest::minbunch_ [private]

Definition at line 50 of file GlobalTest.h.

Referenced by analyze(), beginJob(), and GlobalTest().

const int GlobalTest::nMaxH = 10 [static, private]

Definition at line 54 of file GlobalTest.h.

const int GlobalTest::nrHistos = 6 [static, private]

Definition at line 64 of file GlobalTest.h.

Definition at line 55 of file GlobalTest.h.

Referenced by beginJob().

Definition at line 57 of file GlobalTest.h.

Referenced by analyze(), and beginJob().

Definition at line 56 of file GlobalTest.h.

Referenced by analyze(), and beginJob().

Definition at line 58 of file GlobalTest.h.

Referenced by analyze(), and beginJob().