ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/CmsHi/JetAnalysis/src/BaseHiGenJetProducer.cc
(Generate patch)

Comparing UserCode/CmsHi/JetAnalysis/src/BaseHiGenJetProducer.cc (file contents):
Revision 1.2 by yilmaz, Wed May 6 19:09:22 2009 UTC vs.
Revision 1.8 by yilmaz, Thu Aug 6 17:35:53 2009 UTC

# Line 26 | Line 26
26   #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
27   #include "Geometry/Records/interface/CaloGeometryRecord.h"
28   #include "SimDataFormats/HiGenData/interface/SubEventMap.h"
29 #include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
29   #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
30   #include "FWCore/Framework/interface/ESHandle.h"
31   #include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
# Line 38 | Line 37 | using namespace reco;
37   using namespace JetReco;
38  
39   namespace {
41  const bool debug = false;
40  
41 <   bool selectForJet(const reco::GenParticle& par){
44 <      if(par.status() != 1) return false;
41 >   bool checkHydro(GenParticleRef& p){
42  
43 <      // Below to be FIXED!!! What is a Jet???
44 <      if(abs(par.pdgId()) == 11 || abs(par.pdgId()) == 12 ||
45 <         abs(par.pdgId()) == 13 ||abs(par.pdgId()) == 14 ||
46 <         abs(par.pdgId()) == 15 ||abs(par.pdgId()) == 16
47 <         ) return false;
43 >      const Candidate* m1 = p->mother();
44 >      while(m1){
45 >         int pdg = abs(m1->pdgId());
46 >         int st = m1->status();
47 >         LogDebug("SubEventMothers")<<"Pdg ID : "<<pdg<<endl;
48 >
49 >         if(st == 3 || pdg < 9 || pdg == 21){
50 >            LogDebug("SubEventMothers")<<"Sub-Collision  Found! Pdg ID : "<<pdg<<endl;
51 >            return false;
52 >         }
53 >         const Candidate* m = m1->mother();
54 >         m1 = m;
55  
56 <         return true;
53 <   }
56 >         if(!m1) LogDebug("SubEventMothers")<<"No Mother, particle is : "<<pdg<<" with status "<<st<<endl;
57  
58 +      }
59 +      return true;
60 +   }
61 +  
62 +   const bool debug = false;
63  
64    bool makeCaloJet (const string& fTag) {
65      return fTag == "CaloJet";
# Line 83 | Line 91 | namespace {
91      fJet->setNPasses (fProtojet.nPasses ());
92    }
93  
94 <  void copyConstituents (const JetReco::InputCollection& fConstituents, const reco::GenParticleCollection& fInput, reco::Jet* fJet) {
95 <    // put constituents
96 <    for (unsigned iConstituent = 0; iConstituent < fConstituents.size (); ++iConstituent) {
97 <       fJet->addDaughter (fInput[fConstituents[iConstituent].index ()].sourceCandidatePtr(0));
98 <    }
99 <  }
100 <
94 >   void copyConstituents (const JetReco::InputCollection& fConstituents, const edm::View <Candidate>& fInput, reco::Jet* fJet) {
95 >      // put constituents
96 >      for (unsigned iConstituent = 0; iConstituent < fConstituents.size (); ++iConstituent) {
97 >         fJet->addDaughter (fInput.ptrAt (fConstituents[iConstituent].index ()));
98 >      }
99 >   }
100 >  
101   }
102  
103   namespace cms
# Line 97 | Line 105 | namespace cms
105    // Constructor takes input parameters now: to be replaced with parameter set.
106    BaseHiGenJetProducer::BaseHiGenJetProducer(const edm::ParameterSet& conf)
107      : mSrc(conf.getParameter<edm::InputTag>( "src")),
108 +      mapSrc(conf.getParameter<edm::InputTag>( "srcMap")),
109        mJetType (conf.getParameter<string>( "jetType")),
110        mVerbose (conf.getUntrackedParameter<bool>("verbose", false)),
111        mEtInputCut (conf.getParameter<double>("inputEtMin")),
112        mEInputCut (conf.getParameter<double>("inputEMin")),
113 <      skipLastSubEvent_ (conf.getUntrackedParameter<bool>("skipLastSubEvent", true)),
114 <      nHydro_(conf.getUntrackedParameter<double>("maxParticles", 2000))
113 >      ignoreHydro_ (conf.getUntrackedParameter<bool>("ignoreHydro", true)),
114 >      nMax_(conf.getUntrackedParameter<double>("maxParticles", 2000))
115    {
116      std::string alias = conf.getUntrackedParameter<string>( "alias", conf.getParameter<std::string>("@module_label"));
117      if (makeCaloJet (mJetType)) {
# Line 127 | Line 136 | namespace cms
136    {
137       using namespace reco;
138  
139 <     edm::Handle<GenParticleCollection> inputHandle;
139 >     edm::Handle< edm::View<Candidate> > inputHandle;
140       e.getByLabel(mSrc,inputHandle);
141  
142       edm::Handle<edm::SubEventMap> subs;
143 <     e.getByLabel(mSrc,subs);
143 >     e.getByLabel(mapSrc,subs);
144  
145       vector <ProtoJet> output;
146       vector<JetReco::InputCollection> inputs;
147  
139     int hydroEvent = -1;
148       vector<int> nsubparticle;
149 +     vector<int> hydroTag;
150  
151       for (unsigned i = 0; i < inputHandle->size(); ++i) {
152 <
153 <        const GenParticle & p = (*inputHandle)[i];
154 <        if(!selectForJet(p)) continue;
146 <        int subevent = (*subs)[GenParticleRef(inputHandle,i)];
152 >        
153 >        GenParticleRef pref = inputHandle->refAt(i).castTo<GenParticleRef>();
154 >        int subevent = (*subs)[pref];
155          LogDebug("SubEventJets")<<"inputs size "<<inputs.size()<<" subevent "<<subevent;
156 <
156 >        
157          if(subevent >= inputs.size()){
158 +           //      hydroTag.push_back(-1);
159 +           hydroTag.resize(subevent+1);
160 +           hydroTag[subevent] = -1;
161             inputs.resize(subevent+1);
162             nsubparticle.resize(subevent+1);
163          }
164 <        //      cout<<"inputs size "<<inputs.size()<<" subevent "<<subevent<<endl;
165 <        if(nsubparticle[subevent]< nHydro_){
166 <           (inputs[subevent]).push_back(JetReco::InputItem(&p,i));      
164 >        
165 >        if(hydroTag[subevent] != 0) hydroTag[subevent] = (int)checkHydro(pref);
166 >
167 >        if(nsubparticle[subevent]> nMax_ && hydroTag[subevent] != 1){
168 >           LogDebug("JetsInHydro")<<"More particles than maximum particles cut, although not previously identified as sub-event, Sub-Event :  "<<subevent;
169 >          
170 >           hydroTag[subevent] = 1;
171 >        }
172 >        
173 >        
174 >        if(hydroTag[subevent] != 1){
175 >           (inputs[subevent]).push_back(JetReco::InputItem(&((*inputHandle)[i]),i));
176             nsubparticle[subevent]++;
157        }else{
158           LogDebug("JetsInHydro")<<"More particles than hydro cut, Sub-Event :  "<<subevent;
159           if(subevent != hydroEvent && hydroEvent != -1){
160              edm::LogError("JetsInHydro")<<"More than one hydro event identified, Sub-Event :  "<<subevent;
161           }
162           hydroEvent = subevent;
177          }
178       }
179 <
179 >    
180       int nsub = inputs.size();
181 +
182 +     bool hydroDone = false;
183       for(int isub = 0; isub < nsub; ++isub){
184          cout<<"Processing Sub-Event : "<<isub<<endl;
185          JetReco::InputCollection & input = inputs[isub];
186 <        //      if(skipLastSubEvent_ && isub == nsub-1){
187 <        if(isub == hydroEvent){
188 <           cout<<"Sub-Event number "<<isub<<" with more than "<<input.size()<<" particles, skipped as background event."<<endl;
186 >        if(hydroTag[isub] == 1){
187 >           if(hydroDone){
188 >              throw cms::Exception("HeavyIonHydroEvent")<<"More than one Hydro sub-event found for the input, please check your MC! Second hydro id : "<<isub<<endl;
189 >           }
190 >           cout<<"Sub-Event number "<<isub<<" with more than "<<input.size()<<" particles, skipped as background event. Number of total sub-events: "<<nsub<<endl;
191 >           hydroDone = true;
192          }else{
193  
194             if (mVerbose) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines