00001
00002
00003
00004 #include "PhysicsTools/HepMCCandAlgos/interface/FlavorHistoryFilter.h"
00005 #include "PhysicsTools/HepMCCandAlgos/interface/FlavorHistoryProducer.h"
00006
00007 #include "FWCore/Utilities/interface/Exception.h"
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009 #include "DataFormats/Math/interface/deltaR.h"
00010
00011 #include "PhysicsTools/HepMCCandAlgos/interface/FlavorHistorySelectorUtil.h"
00012
00013 #include <vector>
00014
00015 using namespace edm;
00016 using namespace reco;
00017 using namespace std;
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 FlavorHistoryFilter::FlavorHistoryFilter(const edm::ParameterSet& iConfig) :
00032 bsrc_ ( iConfig.getParameter<edm::InputTag>("bsrc" ) ),
00033 csrc_ ( iConfig.getParameter<edm::InputTag>("csrc" ) )
00034 {
00035 if ( iConfig.exists("pathToSelect") )
00036 pathToSelect_ = iConfig.getParameter<int> ("pathToSelect");
00037 else
00038 pathToSelect_ = -1;
00039
00040
00041
00042 dr_ = iConfig.getParameter<double> ("dr" ) ;
00043 bool verbose ( iConfig.getParameter<bool> ("verbose") );
00044
00045
00046
00047
00048
00049 double dr0 = 0.0;
00050 double dr1 = dr_;
00051 double dr2 = 99999.0;
00052
00053
00054
00055 std::vector<int> me_ids;
00056 me_ids.push_back(2);
00057 me_ids.push_back(3);
00058
00059
00060 std::vector<int> ps_ids;
00061 ps_ids.push_back(1);
00062
00063
00064
00065 bb_me_ = new FlavorHistorySelectorUtil( 5,
00066 2,
00067 me_ids,
00068 dr1,
00069 dr2,
00070 verbose );
00071
00072
00073 b_me_ = new FlavorHistorySelectorUtil( 5,
00074 1,
00075 me_ids,
00076 dr0,
00077 dr0,
00078 verbose );
00079
00080
00081
00082 cc_me_ = new FlavorHistorySelectorUtil( 4,
00083 2,
00084 me_ids,
00085 dr1,
00086 dr2,
00087 verbose );
00088
00089
00090 c_me_ = new FlavorHistorySelectorUtil( 4,
00091 1,
00092 me_ids,
00093 dr0,
00094 dr0,
00095 verbose );
00096
00097
00098 b_ps_ = new FlavorHistorySelectorUtil( 5,
00099 1,
00100 ps_ids,
00101 dr0,
00102 dr1,
00103 verbose );
00104
00105
00106
00107 c_ps_ = new FlavorHistorySelectorUtil( 4,
00108 1,
00109 ps_ids,
00110 dr0,
00111 dr1,
00112 verbose );
00113
00114
00115 bb_me_comp_ = new FlavorHistorySelectorUtil( 5,
00116 2,
00117 me_ids,
00118 dr0,
00119 dr1,
00120 verbose );
00121
00122
00123 cc_me_comp_ = new FlavorHistorySelectorUtil( 4,
00124 2,
00125 me_ids,
00126 dr0,
00127 dr1,
00128 verbose );
00129
00130
00131 b_ps_comp_ = new FlavorHistorySelectorUtil( 5,
00132 2,
00133 ps_ids,
00134 dr1,
00135 dr2,
00136 verbose );
00137
00138
00139 c_ps_comp_ = new FlavorHistorySelectorUtil( 4,
00140 2,
00141 ps_ids,
00142 dr1,
00143 dr2,
00144 verbose );
00145
00146
00147
00148
00149
00150 produces<unsigned int>();
00151 }
00152
00153
00154 FlavorHistoryFilter::~FlavorHistoryFilter()
00155 {
00156
00157 if ( bb_me_ ) delete bb_me_;
00158 if ( b_me_ ) delete b_me_;
00159 if ( cc_me_ ) delete cc_me_;
00160 if ( c_me_ ) delete c_me_;
00161 if ( b_ps_ ) delete b_ps_;
00162 if ( c_ps_ ) delete c_ps_;
00163
00164 if ( bb_me_comp_ ) delete bb_me_comp_;
00165 if ( cc_me_comp_ ) delete cc_me_comp_;
00166 if ( b_ps_comp_ ) delete b_ps_comp_;
00167 if ( c_ps_comp_ ) delete c_ps_comp_;
00168
00169
00170
00171
00172 }
00173
00174
00175
00176 bool
00177 FlavorHistoryFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00178 {
00179
00180
00181 Handle<FlavorHistoryEvent > bFlavorHistoryEvent;
00182 iEvent.getByLabel(bsrc_,bFlavorHistoryEvent);
00183
00184 Handle<FlavorHistoryEvent > cFlavorHistoryEvent;
00185 iEvent.getByLabel(csrc_,cFlavorHistoryEvent);
00186
00187 std::auto_ptr<unsigned int> selection ( new unsigned int() );
00188
00189
00190 unsigned int nb = bFlavorHistoryEvent->nb();
00191
00192 unsigned int nc = cFlavorHistoryEvent->nc();
00193
00194
00195 FlavorHistory::FLAVOR_T bFlavorSource = bFlavorHistoryEvent->flavorSource();
00196 FlavorHistory::FLAVOR_T cFlavorSource = cFlavorHistoryEvent->flavorSource();
00197 FlavorHistory::FLAVOR_T flavorSource = FlavorHistory::FLAVOR_NULL;
00198
00199 unsigned int highestFlavor = 0;
00200
00201 double dr = -1;
00202
00203
00204
00205
00206
00207
00208 if ( bFlavorSource >= cFlavorSource ) {
00209 flavorSource = bFlavorHistoryEvent->flavorSource();
00210 highestFlavor = bFlavorHistoryEvent->highestFlavor();
00211 dr = bFlavorHistoryEvent->deltaR();
00212 }
00213 else {
00214 flavorSource = cFlavorHistoryEvent->flavorSource();
00215 highestFlavor = cFlavorHistoryEvent->highestFlavor();
00216 dr = cFlavorHistoryEvent->deltaR();
00217 }
00218
00219
00220 *selection = 0;
00221
00222 if ( bb_me_ ->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 1;
00223 else if ( b_me_ ->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 2;
00224 else if ( cc_me_ ->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 3;
00225 else if ( c_me_ ->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 4;
00226 else if ( b_ps_ ->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 5;
00227 else if ( c_ps_ ->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 6;
00228 else if ( bb_me_comp_->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 7;
00229 else if ( cc_me_comp_->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 8;
00230 else if ( b_ps_comp_->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 9;
00231 else if ( c_ps_comp_->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 10;
00232 else *selection = 11;
00233
00234 bool pass = false;
00235 if ( pathToSelect_ > 0 ) {
00236 pass = (*selection > 0 && *selection == static_cast<unsigned int>(pathToSelect_ ) );
00237 } else {
00238 pass = true;
00239 }
00240
00241 iEvent.put( selection );
00242
00243 return pass;
00244
00245 }
00246
00247
00248 void
00249 FlavorHistoryFilter::endJob() {
00250 }
00251
00252
00253 DEFINE_FWK_MODULE(FlavorHistoryFilter);