#include <PileupInformation.h>
Public Member Functions | |
PileupInformation (const edm::ParameterSet &) | |
Private Types | |
typedef std::map < EncodedEventId, unsigned int > | EncodedEventIdToIndex |
typedef std::map< int, int > | myindex |
Private Member Functions | |
void | produce (edm::Event &, const edm::EventSetup &) |
Private Attributes | |
edm::ParameterSet | conf_ |
double | distanceCut_ |
myindex | event_index_ |
std::string | MessageCategory_ |
std::vector< int > | ntrks_highpT |
std::vector< int > | ntrks_lowpT |
edm::InputTag | PileupInfoLabel_ |
double | pTcut_1_ |
double | pTcut_2_ |
std::string | simHitLabel_ |
std::auto_ptr< MixCollection < SimTrack > > | simTracks_ |
std::auto_ptr< MixCollection < SimVertex > > | simVertexes_ |
std::vector< float > | sumpT_highpT |
std::vector< float > | sumpT_lowpT |
edm::InputTag | trackingTruth_ |
double | volumeRadius_ |
double | volumeZ_ |
std::vector< float > | zpositions |
Definition at line 29 of file PileupInformation.h.
typedef std::map<EncodedEventId, unsigned int> PileupInformation::EncodedEventIdToIndex [private] |
Definition at line 42 of file PileupInformation.h.
typedef std::map< int, int > PileupInformation::myindex [private] |
Definition at line 43 of file PileupInformation.h.
PileupInformation::PileupInformation | ( | const edm::ParameterSet & | config | ) | [explicit] |
Definition at line 20 of file PileupInformation.cc.
References distanceCut_, edm::ParameterSet::getParameter(), MessageCategory_, PileupInfoLabel_, pTcut_1_, pTcut_2_, simHitLabel_, trackingTruth_, volumeRadius_, and volumeZ_.
{ // Initialize global parameters pTcut_1_ = 0.1; pTcut_2_ = 0.5; // defaults distanceCut_ = config.getParameter<double>("vertexDistanceCut"); volumeRadius_ = config.getParameter<double>("volumeRadius"); volumeZ_ = config.getParameter<double>("volumeZ"); pTcut_1_ = config.getParameter<double>("pTcut_1"); pTcut_2_ = config.getParameter<double>("pTcut_2"); PileupInfoLabel_ = config.getParameter<std::string>("PileupMixingLabel"); trackingTruth_ = config.getParameter<std::string>("TrackingParticlesLabel"); simHitLabel_ = config.getParameter<std::string>("simHitLabel"); MessageCategory_ = "PileupInformation"; edm::LogInfo (MessageCategory_) << "Setting up PileupInformation"; edm::LogInfo (MessageCategory_) << "Vertex distance cut set to " << distanceCut_ << " mm"; edm::LogInfo (MessageCategory_) << "Volume radius set to " << volumeRadius_ << " mm"; edm::LogInfo (MessageCategory_) << "Volume Z set to " << volumeZ_ << " mm"; edm::LogInfo (MessageCategory_) << "Lower pT Threshold set to " << pTcut_1_ << " GeV"; edm::LogInfo (MessageCategory_) << "Upper pT Threshold set to " << pTcut_2_ << " GeV"; produces< std::vector<PileupSummaryInfo> >(); //produces<PileupSummaryInfo>(); }
void PileupInformation::produce | ( | edm::Event & | event, |
const edm::EventSetup & | setup | ||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 53 of file PileupInformation.cc.
References EncodedEventId::bunchCrossing(), event_index_, edm::Event::getByLabel(), PileupMixingContent::getMix_bunchCrossing(), PileupMixingContent::getMix_Ninteractions(), PileupMixingContent::getMix_TrueInteractions(), getHLTprescales::index, ntrks_highpT, ntrks_lowpT, PileupInfoLabel_, edm::Handle< T >::product(), pTcut_1_, pTcut_2_, simHitLabel_, simVertexes_, mathSSE::sqrt(), sumpT_highpT, sumpT_lowpT, trackingTruth_, and zpositions.
{ std::auto_ptr<std::vector<PileupSummaryInfo> > PSIVector(new std::vector<PileupSummaryInfo>); edm::Handle< PileupMixingContent > MixingPileup; // Get True pileup information from MixingModule event.getByLabel(PileupInfoLabel_, MixingPileup); std::vector<int> BunchCrossings; std::vector<int> Interactions_Xing; std::vector<float> TrueInteractions_Xing; const PileupMixingContent* MixInfo = MixingPileup.product(); if(MixInfo) { // extract information - way easier than counting vertices const std::vector<int> bunchCrossing = MixInfo->getMix_bunchCrossing(); const std::vector<int> interactions = MixInfo->getMix_Ninteractions(); const std::vector<float> TrueInteractions = MixInfo->getMix_TrueInteractions(); for(int ib=0; ib<(int)bunchCrossing.size(); ++ib){ // std::cout << " bcr, nint " << bunchCrossing[ib] << " " << interactions[ib] << std::endl; BunchCrossings.push_back(bunchCrossing[ib]); Interactions_Xing.push_back(interactions[ib]); TrueInteractions_Xing.push_back(TrueInteractions[ib]); } } else{ //If no Mixing Truth, work with SimVertices (probably should throw an exception, but...) // Collect all the simvertex from the crossing frame edm::Handle<CrossingFrame<SimVertex> > cfSimVertexes; if( event.getByLabel("mix", simHitLabel_, cfSimVertexes) ) { // Create a mix collection from one simvertex collection simVertexes_ = std::auto_ptr<MixCollection<SimVertex> >( new MixCollection<SimVertex>(cfSimVertexes.product()) ); int index = 0; // Solution to the problem of not having vertexId // bool FirstL = true; EncodedEventIdToIndex vertexId; EncodedEventId oldEventId; int oldBX = -1000; std::vector<int> BunchCrossings2; std::list<int> Interactions_Xing2; // Loop for finding repeated vertexId (vertexId problem hack) for (MixCollection<SimVertex>::MixItr iterator = simVertexes_->begin(); iterator != simVertexes_->end(); ++iterator, ++index) { // std::cout << " SimVtx eventid, vertexid " << iterator->eventId().event() << " " << iterator->eventId().bunchCrossing() << std::endl; if (!index || iterator->eventId() != oldEventId) { if(iterator->eventId().bunchCrossing()==0 && iterator->eventId().event()==0){ continue; } if(iterator->eventId().bunchCrossing() != oldBX) { BunchCrossings2.push_back(iterator->eventId().bunchCrossing()); Interactions_Xing2.push_back(iterator->eventId().event()); oldBX = iterator->eventId().bunchCrossing(); } else { Interactions_Xing2.pop_back(); Interactions_Xing2.push_back(iterator->eventId().event()); } oldEventId = iterator->eventId(); continue; } } std::vector<int>::iterator viter; std::list<int>::iterator liter = Interactions_Xing2.begin(); for(viter = BunchCrossings2.begin(); viter != BunchCrossings2.end(); ++viter, ++liter){ //std::cout << " bcr, nint from VTX " << (*viter) << " " << (*liter) << std::endl; BunchCrossings.push_back((*viter)); Interactions_Xing.push_back((*liter)); TrueInteractions_Xing.push_back(-1.); // no idea what the true number is } } // end of "did we find vertices?" } // end of look at SimVertices //Now, get information on valid particles that look like they could be in the tracking volume zpositions.clear(); sumpT_lowpT.clear(); sumpT_highpT.clear(); ntrks_lowpT.clear(); ntrks_highpT.clear(); event_index_.clear(); int lastEvent = 0; // zero is the true MC hard-scatter event // int lastBunchCrossing = 0; // 0 is the true bunch crossing, should always come first. edm::Handle<TrackingParticleCollection> mergedPH; edm::Handle<TrackingVertexCollection> mergedVH; bool HaveTrackingParticles = false; TrackingVertexCollection::const_iterator iVtx; TrackingVertexCollection::const_iterator iVtxTest; TrackingParticleCollection::const_iterator iTrackTest; if(event.getByLabel(trackingTruth_, mergedPH) && event.getByLabel(trackingTruth_, mergedVH)) { HaveTrackingParticles = true; iVtxTest = mergedVH->begin(); iTrackTest = mergedPH->begin(); } int nminb_vtx = 0; // bool First = true; // bool flag_new = false; std::vector<int>::iterator BXIter; std::vector<int>::iterator InteractionsIter = Interactions_Xing.begin(); std::vector<float>::iterator TInteractionsIter = TrueInteractions_Xing.begin(); // loop over the bunch crossings and interactions we have extracted for( BXIter = BunchCrossings.begin(); BXIter != BunchCrossings.end(); ++BXIter, ++InteractionsIter, ++TInteractionsIter) { //std::cout << "looking for BX: " << (*BXIter) << std::endl; if(HaveTrackingParticles) { // leave open the option of not producing TrackingParticles and just keeping # interactions for (iVtx = iVtxTest; iVtx != mergedVH->end(); ++iVtx) { if(iVtx->eventId().bunchCrossing() == (*BXIter) ) { // found first vertex in this bunch crossing if(iVtx->eventId().event() != lastEvent) { //std::cout << "BX,event " << iVtx->eventId().bunchCrossing() << " " << iVtx->eventId().event() << std::endl; float zpos = 0.; zpos = iVtx->position().z(); zpositions.push_back(zpos); //save z position of each vertex sumpT_lowpT.push_back(0.); sumpT_highpT.push_back(0.); ntrks_lowpT.push_back(0); ntrks_highpT.push_back(0); lastEvent = iVtx->eventId().event(); iVtxTest = --iVtx; // just for security // turns out events aren't sequential... save map of indices event_index_.insert(myindex::value_type(lastEvent,nminb_vtx)); ++nminb_vtx; continue; } } } // next loop over tracks to get information for (TrackingParticleCollection::const_iterator iTrack = iTrackTest; iTrack != mergedPH->end(); ++iTrack) { bool FoundTrk = false; float zpos=0.; if(iTrack->eventId().bunchCrossing() == (*BXIter) && iTrack->eventId().event() > 0 ) { FoundTrk = true; int correct_index = event_index_[iTrack->eventId().event()]; //std::cout << " track index, correct index " << iTrack->eventId().event() << " " << correct_index << std::endl; zpos = zpositions[correct_index]; if(iTrack->matchedHit()>0) { if(fabs(iTrack->parentVertex()->position().z()-zpos)<0.1) { //make sure track really comes from this vertex //std::cout << *iTrack << std::endl; float Tpx = iTrack->p4().px(); float Tpy = iTrack->p4().py(); float TpT = sqrt(Tpx*Tpx + Tpy*Tpy); if( TpT>pTcut_1_ ) { sumpT_lowpT[correct_index]+=TpT; ++ntrks_lowpT[correct_index]; } if( TpT>pTcut_2_ ){ sumpT_highpT[correct_index]+=TpT; ++ntrks_highpT[correct_index]; } } } } else{ if(FoundTrk) { iTrackTest = --iTrack; // reset so we can start over next time --iTrackTest; // just to be sure break; } } } // end of track loop } // end of check that we have TrackingParticles to begin with... // now that we have all of the track information for a given bunch crossing, // make PileupSummary for this one and move on // std::cout << "Making PSI for bunch " << lastBunchCrossing << std::endl; if(!HaveTrackingParticles) { // stick in one value so we don't have empty vectors zpositions.push_back(-999.); sumpT_lowpT.push_back(0.); sumpT_highpT.push_back(0.); ntrks_lowpT.push_back(0); ntrks_highpT.push_back(0); } PileupSummaryInfo PSI_bunch = PileupSummaryInfo( (*InteractionsIter), zpositions, sumpT_lowpT, sumpT_highpT, ntrks_lowpT, ntrks_highpT, (*BXIter), (*TInteractionsIter) ); //std::cout << " " << std::endl; //std::cout << "Adding Bunch Crossing, nint " << (*BXIter) << " " << (*InteractionsIter) << std::endl; //for(int iv = 0; iv<(*InteractionsIter); ++iv){ // std::cout << "Z position " << zpositions[iv] << std::endl; // std::cout << "ntrks_lowpT " << ntrks_lowpT[iv] << std::endl; // std::cout << "sumpT_lowpT " << sumpT_lowpT[iv] << std::endl; // std::cout << "ntrks_highpT " << ntrks_highpT[iv] << std::endl; // std::cout << "sumpT_highpT " << sumpT_highpT[iv] << std::endl; //} PSIVector->push_back(PSI_bunch); // if(HaveTrackingParticles) lastBunchCrossing = iVtx->eventId().bunchCrossing(); event_index_.clear(); zpositions.clear(); sumpT_lowpT.clear(); sumpT_highpT.clear(); ntrks_lowpT.clear(); ntrks_highpT.clear(); nminb_vtx = 0; lastEvent=0; } // end of loop over bunch crossings // put our vector of PileupSummaryInfo objects into the event. event.put(PSIVector); }
edm::ParameterSet PileupInformation::conf_ [private] |
Definition at line 40 of file PileupInformation.h.
double PileupInformation::distanceCut_ [private] |
Definition at line 53 of file PileupInformation.h.
Referenced by PileupInformation().
myindex PileupInformation::event_index_ [private] |
Definition at line 44 of file PileupInformation.h.
Referenced by produce().
std::string PileupInformation::MessageCategory_ [private] |
Definition at line 62 of file PileupInformation.h.
Referenced by PileupInformation().
std::vector<int> PileupInformation::ntrks_highpT [private] |
Definition at line 50 of file PileupInformation.h.
Referenced by produce().
std::vector<int> PileupInformation::ntrks_lowpT [private] |
Definition at line 49 of file PileupInformation.h.
Referenced by produce().
Definition at line 60 of file PileupInformation.h.
Referenced by PileupInformation(), and produce().
double PileupInformation::pTcut_1_ [private] |
Definition at line 56 of file PileupInformation.h.
Referenced by PileupInformation(), and produce().
double PileupInformation::pTcut_2_ [private] |
Definition at line 57 of file PileupInformation.h.
Referenced by PileupInformation(), and produce().
std::string PileupInformation::simHitLabel_ [private] |
Definition at line 63 of file PileupInformation.h.
Referenced by PileupInformation(), and produce().
std::auto_ptr<MixCollection<SimTrack> > PileupInformation::simTracks_ [private] |
Definition at line 64 of file PileupInformation.h.
std::auto_ptr<MixCollection<SimVertex> > PileupInformation::simVertexes_ [private] |
Definition at line 65 of file PileupInformation.h.
Referenced by produce().
std::vector<float> PileupInformation::sumpT_highpT [private] |
Definition at line 48 of file PileupInformation.h.
Referenced by produce().
std::vector<float> PileupInformation::sumpT_lowpT [private] |
Definition at line 47 of file PileupInformation.h.
Referenced by produce().
Definition at line 59 of file PileupInformation.h.
Referenced by PileupInformation(), and produce().
double PileupInformation::volumeRadius_ [private] |
Definition at line 54 of file PileupInformation.h.
Referenced by PileupInformation().
double PileupInformation::volumeZ_ [private] |
Definition at line 55 of file PileupInformation.h.
Referenced by PileupInformation().
std::vector<float> PileupInformation::zpositions [private] |
Definition at line 46 of file PileupInformation.h.
Referenced by produce().