CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Calibration/IsolatedParticles/plugins/IsolatedTracksNxN.cc

Go to the documentation of this file.
00001 // -*- C++ -*
00002 //
00003 // Package:    IsolatedTracksNxN
00004 // Class:      IsolatedTracksNxN
00005 // 
00013 //
00014 // Original Author:  Seema Sharma
00015 //         Created:  Mon Aug 10 15:30:40 CST 2009
00016 //
00017 //
00018 
00019 #include "DataFormats/TrackReco/interface/TrackBase.h"
00020 #include "Calibration/IsolatedParticles/plugins/IsolatedTracksNxN.h"
00021 
00022 #include "Calibration/IsolatedParticles/interface/CaloPropagateTrack.h"
00023 #include "Calibration/IsolatedParticles/interface/ChargeIsolation.h"
00024 #include "Calibration/IsolatedParticles/interface/eHCALMatrixExtra.h"
00025 #include "MagneticField/Engine/interface/MagneticField.h"
00026 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00027 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
00028 #include "Geometry/CaloTopology/interface/EcalTrigTowerConstituentsMap.h"
00029 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
00030 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.h"
00031 
00032 IsolatedTracksNxN::IsolatedTracksNxN(const edm::ParameterSet& iConfig) {
00033 
00034   //now do what ever initialization is needed
00035   doMC                   = iConfig.getUntrackedParameter<bool>  ("DoMC", false); 
00036   myverbose_             = iConfig.getUntrackedParameter<int>   ("Verbosity", 5          );
00037   pvTracksPtMin_         = iConfig.getUntrackedParameter<double>("PVTracksPtMin", 1.0    );
00038   debugTrks_             = iConfig.getUntrackedParameter<int>   ("DebugTracks"           );
00039   printTrkHitPattern_    = iConfig.getUntrackedParameter<bool>  ("PrintTrkHitPattern"    );
00040   minTrackP_             = iConfig.getUntrackedParameter<double>("minTrackP", 1.0        );
00041   maxTrackEta_           = iConfig.getUntrackedParameter<double>("maxTrackEta", 5.0      );
00042   debugL1Info_           = iConfig.getUntrackedParameter<bool>  ("DebugL1Info", false    );
00043   L1extraTauJetSource_   = iConfig.getParameter<edm::InputTag>  ("L1extraTauJetSource"   );
00044   L1extraCenJetSource_   = iConfig.getParameter<edm::InputTag>  ("L1extraCenJetSource"   );
00045   L1extraFwdJetSource_   = iConfig.getParameter<edm::InputTag>  ("L1extraFwdJetSource"   );
00046   L1extraMuonSource_     = iConfig.getParameter<edm::InputTag>  ("L1extraMuonSource"     );
00047   L1extraIsoEmSource_    = iConfig.getParameter<edm::InputTag>  ("L1extraIsoEmSource"    );
00048   L1extraNonIsoEmSource_ = iConfig.getParameter<edm::InputTag>  ("L1extraNonIsoEmSource" );
00049   L1GTReadoutRcdSource_  = iConfig.getParameter<edm::InputTag>  ("L1GTReadoutRcdSource"  );
00050   L1GTObjectMapRcdSource_= iConfig.getParameter<edm::InputTag>  ("L1GTObjectMapRcdSource");
00051   JetSrc_                = iConfig.getParameter<edm::InputTag>  ("JetSource");
00052   JetExtender_           = iConfig.getParameter<edm::InputTag>  ("JetExtender");
00053   tMinE_                 = iConfig.getUntrackedParameter<double>("TimeMinCutECAL", -500.);
00054   tMaxE_                 = iConfig.getUntrackedParameter<double>("TimeMaxCutECAL",  500.);
00055   tMinH_                 = iConfig.getUntrackedParameter<double>("TimeMinCutHCAL", -500.);
00056   tMaxH_                 = iConfig.getUntrackedParameter<double>("TimeMaxCutHCAL",  500.);
00057 
00058   //edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
00059   //parameters_.loadParameters( parameters );
00060   //trackAssociator_ =  new TrackDetectorAssociator();
00061   //trackAssociator_->useDefaultPropagator();
00062 
00063   if(myverbose_>=0) {
00064     std::cout <<"Parameters read from config file \n" 
00065               <<" doMC         "      << doMC
00066               <<"\t myverbose_ "      << myverbose_        
00067               <<"\t minTrackP_ "      << minTrackP_     
00068               << "\t maxTrackEta_ " << maxTrackEta_    
00069               << "\t tMinE_ " << tMinE_
00070               << "\t tMaxE_ " << tMaxE_
00071               << "\t tMinH_ " << tMinH_
00072               << "\t tMaxH_ " << tMaxH_      << "\n"
00073               << std::endl;
00074   }
00075 
00076   initL1 = false;
00077 
00078 }
00079 
00080 IsolatedTracksNxN::~IsolatedTracksNxN() {
00081   //delete  trackAssociator_;
00082 }
00083 
00084 void IsolatedTracksNxN::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
00085   //  std::cout<< tMinE_ << " " << tMaxE_ << " HCAL " << tMinH_ << " " << tMaxH_ << std::endl;
00086 
00087   edm::ESHandle<MagneticField> bFieldH;
00088   iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
00089   bField = bFieldH.product();
00090 
00091   clearTreeVectors();
00092 
00093   t_RunNo = iEvent.id().run();
00094   t_EvtNo = iEvent.id().event();
00095   t_Lumi  = iEvent.luminosityBlock();
00096   t_Bunch = iEvent.bunchCrossing();
00097 
00098   nEventProc++;
00099 
00100   edm::Handle<reco::TrackCollection> trkCollection;
00101   iEvent.getByLabel("generalTracks", trkCollection);
00102   reco::TrackCollection::const_iterator trkItr;
00103   if(debugTrks_>1){
00104     std::cout << "Track Collection: " << std::endl;
00105     std::cout << "Number of Tracks " << trkCollection->size() << std::endl;
00106   }
00107   std::string theTrackQuality = "highPurity";
00108   reco::TrackBase::TrackQuality trackQuality_=reco::TrackBase::qualityByName(theTrackQuality);
00109 
00110   //===================== save L1 Trigger information =======================
00111   // get L1TriggerReadout records
00112   edm::Handle<L1GlobalTriggerReadoutRecord> gtRecord;
00113   iEvent.getByLabel(L1GTReadoutRcdSource_,  gtRecord);
00114   
00115   // sanity check on L1 Trigger Records
00116   if (!gtRecord.isValid()) {
00117     std::cout << "\nL1GlobalTriggerReadoutRecord with \n \nnot found"
00118       "\n  --> returning false by default!\n" << std::endl;
00119   }
00120 
00121   edm::ESHandle<L1GtTriggerMenu> gtOMRec;
00122   iSetup.get<L1GtTriggerMenuRcd>().get(gtOMRec) ;
00123 
00124   // L1 decision word  
00125   const DecisionWord dWord = gtRecord->decisionWord();  
00126   unsigned int numberTriggerBits= dWord.size();
00127 
00128   // just print the L1Bit number and AlgoName in first event
00129   /*
00130   if ( !initL1){
00131     initL1=true;
00132     std::cout << "\n  Number of Trigger bits " << numberTriggerBits << "\n\n";
00133     std::cout << "\tBit \t L1 Algorithm " << std::endl;
00134 
00135     // get ObjectMaps from ObjectMapRecord
00136     const std::vector<L1GlobalTriggerObjectMap>& objMapVec =  gtOMRec->gtObjectMap();
00137     for (std::vector<L1GlobalTriggerObjectMap>::const_iterator itMap = objMapVec.begin();
00138          itMap != objMapVec.end(); ++itMap) {
00139 
00140       // Get trigger bits
00141       int itrig = (*itMap).algoBitNumber();
00142 
00143       // Get trigger names
00144       algoBitToName[itrig] = (*itMap).algoName();
00145       std::cout  << "\t" << itrig << "\t" << algoBitToName[itrig] << std::endl;      
00146 
00147       // store the algoNames as bin labels of a histogram
00148       h_L1AlgoNames->GetXaxis()->SetBinLabel(itrig+1, algoBitToName[itrig].c_str());
00149     } // end of for loop    
00150   } // end of initL1
00151   */
00152 
00153   if ( !initL1){
00154     initL1=true;
00155     //  std::cout << "\n  Number of Trigger bits " << numberTriggerBits << "\n\n";
00156     //std::cout << "\tBit \t L1 Algorithm " << std::endl;
00157     int itrig=0; 
00158     for (CItAlgo algo = (*gtOMRec.product()).gtAlgorithmMap().begin(); algo!=(*gtOMRec.product()).gtAlgorithmMap().end(); ++algo, itrig++) {
00159       //      std::cout << "Name: " << (algo->second).algoName() << " Alias: " << (algo->second).algoAlias() << std::endl;
00160       algoBitToName[itrig] = (algo->second).algoName() ;
00161     }
00162   } // end of initL1
00163   
00164   for (unsigned int iBit = 0; iBit < numberTriggerBits; ++iBit) {  
00165     bool accept = dWord[iBit];
00166     //if (accept) h_L1Results2->Fill(float(iBit));
00167     
00168     // fill the trigger map
00169     typedef std::map<std::string,bool>::value_type valType;
00170     trig_iter=l1TriggerMap.find(algoBitToName[iBit]);
00171     if (trig_iter==l1TriggerMap.end())
00172       l1TriggerMap.insert(valType(algoBitToName[iBit],accept));
00173     else
00174       trig_iter->second=accept;
00175   }
00176 
00177 
00178   // save L1 decision for each event 
00179   for (unsigned int iBit = 0; iBit < numberTriggerBits; ++iBit) {  
00180 
00181     bool accept = dWord[iBit];
00182     t_L1Decision->push_back(accept);
00183 
00184     // fill the trigger map
00185     if(debugL1Info_) std::cout << "Bit " << iBit << " " << algoBitToName[iBit] << " " << accept << std::endl;
00186 
00187     if(accept) h_L1AlgoNames->Fill(iBit);
00188   }
00189 
00190   //===================
00191 
00192   edm::Handle<reco::VertexCollection> recVtxs;
00193   iEvent.getByLabel("offlinePrimaryVertices",recVtxs);
00194   
00195   std::vector<reco::Track> svTracks;
00196   math::XYZPoint leadPV(0,0,0);
00197   double sumPtMax = -1.0;
00198   for(unsigned int ind=0; ind < recVtxs->size(); ind++) {
00199     if (!((*recVtxs)[ind].isFake())) {
00200      
00201       double vtxTrkSumPt=0.0, vtxTrkSumPtWt=0.0;
00202       int    vtxTrkNWt =0;
00203       double vtxTrkSumPtHP=0.0, vtxTrkSumPtHPWt=0.0;
00204       int    vtxTrkNHP =0, vtxTrkNHPWt =0;
00205 
00206       reco::Vertex::trackRef_iterator vtxTrack = (*recVtxs)[ind].tracks_begin();
00207       for (vtxTrack = (*recVtxs)[ind].tracks_begin(); vtxTrack!=(*recVtxs)[ind].tracks_end(); vtxTrack++) {
00208 
00209         bool trkQuality  = (*vtxTrack)->quality(trackQuality_);
00210 
00211         if((*vtxTrack)->pt()<pvTracksPtMin_) continue;
00212         
00213         vtxTrkSumPt += (*vtxTrack)->pt();
00214         if( trkQuality ) {
00215           vtxTrkSumPtHP += (*vtxTrack)->pt();
00216           vtxTrkNHP++;
00217         }
00218 
00219         double weight = (*recVtxs)[ind].trackWeight(*vtxTrack);
00220         h_PVTracksWt ->Fill(weight);
00221         if( weight>0.5) {
00222           vtxTrkSumPtWt += (*vtxTrack)->pt();
00223           vtxTrkNWt++;
00224           if( trkQuality ) {
00225             vtxTrkSumPtHPWt += (*vtxTrack)->pt();
00226             vtxTrkNHPWt++;
00227           }
00228         }
00229       }
00230 
00231       if(vtxTrkSumPt>sumPtMax) {
00232         sumPtMax = vtxTrkSumPt;
00233         leadPV = math::XYZPoint( (*recVtxs)[ind].x(),(*recVtxs)[ind].y(), (*recVtxs)[ind].z() );
00234       } 
00235 
00236       t_PVx            ->push_back( (*recVtxs)[ind].x() );
00237       t_PVy            ->push_back( (*recVtxs)[ind].y() );
00238       t_PVz            ->push_back( (*recVtxs)[ind].z() );
00239       t_PVisValid      ->push_back( (*recVtxs)[ind].isValid() );
00240       t_PVNTracks      ->push_back( (*recVtxs)[ind].tracksSize() );
00241       t_PVndof         ->push_back( (*recVtxs)[ind].ndof() );
00242       t_PVNTracksWt    ->push_back( vtxTrkNWt );
00243       t_PVTracksSumPt  ->push_back( vtxTrkSumPt );
00244       t_PVTracksSumPtWt->push_back( vtxTrkSumPtWt );
00245 
00246       t_PVNTracksHP      ->push_back( vtxTrkNHP );
00247       t_PVNTracksHPWt    ->push_back( vtxTrkNHPWt );
00248       t_PVTracksSumPtHP  ->push_back( vtxTrkSumPtHP );
00249       t_PVTracksSumPtHPWt->push_back( vtxTrkSumPtHPWt );
00250       if(myverbose_==4) {
00251         std::cout<<"PV "<<ind<<" isValid "<<(*recVtxs)[ind].isValid()<<" isFake "<<(*recVtxs)[ind].isFake()
00252                  <<" hasRefittedTracks() "<<ind<<" "<<(*recVtxs)[ind].hasRefittedTracks()
00253                  <<" refittedTrksSize "<<(*recVtxs)[ind].refittedTracks().size()
00254                  <<"  tracksSize() "<<(*recVtxs)[ind].tracksSize()<<" sumPt "<<vtxTrkSumPt
00255                  <<std::endl;
00256       }
00257     }
00258   }
00259 
00260   // Get the beamspot
00261   edm::Handle<reco::BeamSpot> beamSpotH;
00262   iEvent.getByLabel("offlineBeamSpot", beamSpotH);
00263   math::XYZPoint bspot;
00264   bspot = ( beamSpotH.isValid() ) ? beamSpotH->position() : math::XYZPoint(0, 0, 0);
00265 
00266   //===================
00267 
00268   // L1Taus 
00269   edm::Handle<l1extra::L1JetParticleCollection> l1TauHandle;
00270   iEvent.getByLabel(L1extraTauJetSource_,l1TauHandle);
00271   l1extra::L1JetParticleCollection::const_iterator itr;
00272   for(itr = l1TauHandle->begin(); itr != l1TauHandle->end(); ++itr ) {
00273     t_L1TauJetPt      ->push_back( itr->pt() );
00274     t_L1TauJetEta     ->push_back( itr->eta() );
00275     t_L1TauJetPhi     ->push_back( itr->phi() );
00276     if(debugL1Info_) {
00277       std::cout << "tauJ p/pt  " << itr->momentum() << " " << itr->pt() 
00278                 << "  eta/phi " << itr->eta() << " " << itr->phi()
00279                 << std::endl;
00280     }
00281   }
00282 
00283   // L1 Central Jets
00284   edm::Handle<l1extra::L1JetParticleCollection> l1CenJetHandle;
00285   iEvent.getByLabel(L1extraCenJetSource_,l1CenJetHandle);
00286   for( itr = l1CenJetHandle->begin();  itr != l1CenJetHandle->end(); ++itr ) {
00287     t_L1CenJetPt    ->push_back( itr->pt() );
00288     t_L1CenJetEta   ->push_back( itr->eta() );
00289     t_L1CenJetPhi   ->push_back( itr->phi() );
00290     if(debugL1Info_) {
00291       std::cout << "cenJ p/pt     " << itr->momentum() << " " << itr->pt() 
00292                 << "  eta/phi " << itr->eta() << " " << itr->phi()
00293                 << std::endl;
00294     }
00295   }
00296   
00297   // L1 Forward Jets
00298   edm::Handle<l1extra::L1JetParticleCollection> l1FwdJetHandle;
00299   iEvent.getByLabel(L1extraFwdJetSource_,l1FwdJetHandle);
00300   for( itr = l1FwdJetHandle->begin();  itr != l1FwdJetHandle->end(); ++itr ) {
00301     t_L1FwdJetPt    ->push_back( itr->pt() );
00302     t_L1FwdJetEta   ->push_back( itr->eta() );
00303     t_L1FwdJetPhi   ->push_back( itr->phi() );
00304     if(debugL1Info_) {
00305       std::cout << "fwdJ p/pt     " << itr->momentum() << " " << itr->pt() 
00306                 << "  eta/phi " << itr->eta() << " " << itr->phi()
00307                 << std::endl;
00308     }
00309   }
00310 
00311   // L1 Isolated EM onjects
00312   l1extra::L1EmParticleCollection::const_iterator itrEm;
00313   edm::Handle<l1extra::L1EmParticleCollection> l1IsoEmHandle ;
00314   iEvent.getByLabel(L1extraIsoEmSource_, l1IsoEmHandle);
00315   for( itrEm = l1IsoEmHandle->begin();  itrEm != l1IsoEmHandle->end(); ++itrEm ) {
00316     t_L1IsoEMPt     ->push_back(  itrEm->pt() );
00317     t_L1IsoEMEta    ->push_back(  itrEm->eta() );
00318     t_L1IsoEMPhi    ->push_back(  itrEm->phi() );
00319     if(debugL1Info_) {
00320       std::cout << "isoEm p/pt    " << itrEm->momentum() << " " << itrEm->pt() 
00321                 << "  eta/phi " << itrEm->eta() << " " << itrEm->phi()
00322                 << std::endl;
00323     }
00324   }
00325   
00326   // L1 Non-Isolated EM onjects
00327   edm::Handle<l1extra::L1EmParticleCollection> l1NonIsoEmHandle ;
00328   iEvent.getByLabel(L1extraNonIsoEmSource_, l1NonIsoEmHandle);
00329   for( itrEm = l1NonIsoEmHandle->begin();  itrEm != l1NonIsoEmHandle->end(); ++itrEm ) {
00330     t_L1NonIsoEMPt  ->push_back( itrEm->pt() );
00331     t_L1NonIsoEMEta ->push_back( itrEm->eta() );
00332     t_L1NonIsoEMPhi ->push_back( itrEm->phi() );
00333     if(debugL1Info_) {
00334       std::cout << "nonIsoEm p/pt " << itrEm->momentum() << " " << itrEm->pt() 
00335                 << "  eta/phi " << itrEm->eta() << " " << itrEm->phi()
00336                 << std::endl;
00337     }
00338   }
00339   
00340   // L1 Muons
00341   l1extra::L1MuonParticleCollection::const_iterator itrMu;
00342   edm::Handle<l1extra::L1MuonParticleCollection> l1MuHandle ;
00343   iEvent.getByLabel(L1extraMuonSource_, l1MuHandle);
00344   for( itrMu = l1MuHandle->begin();  itrMu != l1MuHandle->end(); ++itrMu ) {
00345     t_L1MuonPt      ->push_back( itrMu->pt() );
00346     t_L1MuonEta     ->push_back( itrMu->eta() );
00347     t_L1MuonPhi     ->push_back( itrMu->phi() );
00348     if(debugL1Info_) {
00349       std::cout << "l1muon p/pt   " << itrMu->momentum() << " " << itrMu->pt() 
00350                 << "  eta/phi " << itrMu->eta() << " " << itrMu->phi()
00351                 << std::endl;
00352     }
00353   }
00354   //=====================================================================
00355 
00356   edm::Handle<reco::CaloJetCollection> jets;
00357   iEvent.getByLabel(JetSrc_,jets);
00358   edm::Handle<reco::JetExtendedAssociation::Container> jetExtender;
00359   iEvent.getByLabel(JetExtender_,jetExtender);
00360 
00361   for(unsigned int ijet=0;ijet<(*jets).size();ijet++) {
00362     t_jetPt       ->push_back( (*jets)[ijet].pt()     );
00363     t_jetEta      ->push_back( (*jets)[ijet].eta()    );
00364     t_jetPhi      ->push_back( (*jets)[ijet].phi()    );
00365     //t_nTrksJetVtx  ->push_back( reco::JetExtendedAssociation::tracksAtVertexNumber(*jetExtender,(*jets)[ijet]) );
00366     //t_nTrksJetCalo ->push_back( reco::JetExtendedAssociation::tracksAtCaloNumber  (*jetExtender,(*jets)[ijet])   );
00367     t_nTrksJetVtx  ->push_back( -1.0);
00368     t_nTrksJetCalo ->push_back( -1.0);
00369   }
00370 
00371   //=====================================================================
00372 
00373   // get handles to calogeometry and calotopology
00374   edm::ESHandle<CaloGeometry> pG;
00375   iSetup.get<CaloGeometryRecord>().get(pG);
00376   const CaloGeometry* geo = pG.product();
00377   
00378   edm::ESHandle<CaloTopology> theCaloTopology;
00379   iSetup.get<CaloTopologyRecord>().get(theCaloTopology); 
00380   const CaloTopology *caloTopology = theCaloTopology.product();
00381   
00382   edm::ESHandle<HcalTopology> htopo;
00383   iSetup.get<IdealGeometryRecord>().get(htopo);
00384   const HcalTopology* theHBHETopology = htopo.product();
00385   
00386   edm::Handle<EcalRecHitCollection> barrelRecHitsHandle;
00387   edm::Handle<EcalRecHitCollection> endcapRecHitsHandle;
00388   iEvent.getByLabel("ecalRecHit","EcalRecHitsEB",barrelRecHitsHandle);
00389   iEvent.getByLabel("ecalRecHit","EcalRecHitsEE",endcapRecHitsHandle);
00390 
00391   // Retrieve the good/bad ECAL channels from the DB
00392   edm::ESHandle<EcalChannelStatus> ecalChStatus;
00393   iSetup.get<EcalChannelStatusRcd>().get(ecalChStatus);
00394   const EcalChannelStatus* theEcalChStatus = ecalChStatus.product();
00395 
00396   // Retrieve trigger tower map
00397   //const edm::ESHandle<EcalTrigTowerConstituentsMap> hTtmap;
00398   edm::ESHandle<EcalTrigTowerConstituentsMap> hTtmap;
00399   iSetup.get<IdealGeometryRecord>().get(hTtmap);
00400   const EcalTrigTowerConstituentsMap& ttMap = *hTtmap;
00401 
00402   edm::Handle<HBHERecHitCollection> hbhe;
00403   iEvent.getByLabel("hbhereco",hbhe);
00404   const HBHERecHitCollection Hithbhe = *(hbhe.product());
00405 
00406   //get Handles to SimTracks and SimHits
00407   edm::Handle<edm::SimTrackContainer> SimTk;
00408   if (doMC) iEvent.getByLabel("g4SimHits",SimTk);
00409   edm::SimTrackContainer::const_iterator simTrkItr;
00410 
00411   edm::Handle<edm::SimVertexContainer> SimVtx;
00412   if (doMC) iEvent.getByLabel("g4SimHits",SimVtx);
00413   edm::SimVertexContainer::const_iterator vtxItr = SimVtx->begin();
00414 
00415   //get Handles to PCaloHitContainers of eb/ee/hbhe
00416   edm::Handle<edm::PCaloHitContainer> pcaloeb;
00417   if (doMC) iEvent.getByLabel("g4SimHits", "EcalHitsEB", pcaloeb);
00418 
00419   edm::Handle<edm::PCaloHitContainer> pcaloee;
00420   if (doMC) iEvent.getByLabel("g4SimHits", "EcalHitsEE", pcaloee);
00421 
00422   edm::Handle<edm::PCaloHitContainer> pcalohh;
00423   if (doMC) iEvent.getByLabel("g4SimHits", "HcalHits", pcalohh);
00424   
00425   //associates tracker rechits/simhits to a track
00426   TrackerHitAssociator* associate=0;
00427   if (doMC) associate = new TrackerHitAssociator(iEvent);
00428   
00429   std::vector<int>  ifGood(trkCollection->size(), 1);
00430 
00431   h_nTracks->Fill(trkCollection->size());
00432   
00433   int nTracks        = 0;
00434   t_nTracks          = 0;
00435 
00436   t_nTracks = trkCollection->size();
00437 
00438   //decide the goodness of each track for this track collection
00439   for( trkItr = trkCollection->begin(),nTracks=0; trkItr != trkCollection->end(); ++trkItr, nTracks++){
00440     const reco::Track* pTrack = &(*trkItr);
00441     bool   trkQuality  = pTrack->quality(trackQuality_);
00442     if( !trkQuality ) ifGood[nTracks]=0;
00443   }
00444 
00445   // get the list of DetIds closest to the impact point of track on surface calorimeters
00446   std::vector<spr::propagatedTrackID> trkCaloDets;
00447   spr::propagateCALO(trkCollection, geo, bField, theTrackQuality, trkCaloDets, false);
00448   std::vector<spr::propagatedTrackID>::const_iterator trkDetItr;
00449 
00450   if(myverbose_>2) {
00451     for(trkDetItr = trkCaloDets.begin(); trkDetItr != trkCaloDets.end(); trkDetItr++){
00452       std::cout<<trkDetItr->trkItr->p()<<" "<<trkDetItr->trkItr->eta()<<" "<<trkDetItr->okECAL<<" ";
00453       if(trkDetItr->detIdECAL.subdetId() == EcalBarrel) std::cout << (EBDetId)trkDetItr->detIdECAL <<" ";
00454       else                                              std::cout << (EEDetId)trkDetItr->detIdECAL <<" ";
00455       std::cout<<trkDetItr->okHCAL<<" ";
00456       if(trkDetItr->okHCAL) std::cout<<(HcalDetId)trkDetItr->detIdHCAL;
00457       std::cout << std::endl;
00458     }
00459   }
00460 
00461   for(trkDetItr = trkCaloDets.begin(),nTracks=0; trkDetItr != trkCaloDets.end(); trkDetItr++,nTracks++){
00462     const reco::Track* pTrack = &(*(trkDetItr->trkItr));
00463     
00464     const reco::HitPattern& hitp = pTrack->hitPattern();
00465     int nLayersCrossed = hitp.trackerLayersWithMeasurement() ;        
00466     int nOuterHits     = hitp.stripTOBLayersWithMeasurement()+hitp.stripTECLayersWithMeasurement() ;
00467     const reco::HitPattern& hitpIn  = pTrack->trackerExpectedHitsInner();
00468     const reco::HitPattern& hitpOut = pTrack->trackerExpectedHitsOuter();
00469     
00470     double eta1        = pTrack->momentum().eta();
00471     double phi1        = pTrack->momentum().phi();
00472     double etaEcal1    = trkDetItr->etaECAL;
00473     double phiEcal1    = trkDetItr->phiECAL;
00474     double etaHcal1    = trkDetItr->etaHCAL;
00475     double phiHcal1    = trkDetItr->phiHCAL;
00476     double pt1         = pTrack->pt();
00477     double p1          = pTrack->p();
00478     double dxy1        = pTrack->dxy();
00479     double dz1         = pTrack->dz();
00480     double dxybs1      = beamSpotH.isValid() ? pTrack->dxy(bspot) : pTrack->dxy();      
00481     double dzbs1       = beamSpotH.isValid() ? pTrack->dz(bspot)  : pTrack->dz();       
00482     double dxypv1      = (recVtxs->size()>0 && !((*recVtxs)[0].isFake()))  ? pTrack->dxy(leadPV) : pTrack->dxy();       
00483     double dzpv1       = (recVtxs->size()>0 && !((*recVtxs)[0].isFake()))  ? pTrack->dz(leadPV)  : pTrack->dz();        
00484     double chisq1      = pTrack->normalizedChi2();
00485 
00486     h_recEtaPt_0->Fill(eta1, pt1);
00487     h_recEtaP_0 ->Fill(eta1, p1);
00488     h_recPt_0   ->Fill(pt1);
00489     h_recP_0    ->Fill(p1);
00490     h_recEta_0  ->Fill(eta1);
00491     h_recPhi_0  ->Fill(phi1);
00492     
00493     if(ifGood[nTracks] && nLayersCrossed>7 ) {
00494       h_recEtaPt_1->Fill(eta1, pt1);
00495       h_recEtaP_1 ->Fill(eta1, p1);
00496       h_recPt_1   ->Fill(pt1);
00497       h_recP_1    ->Fill(p1);
00498 
00499 
00500       h_recEta_1  ->Fill(eta1);
00501       h_recPhi_1  ->Fill(phi1);
00502     }
00503     
00504     if( ! ifGood[nTracks] ) continue;
00505     if( pt1>2.0 && nLayersCrossed>7) {
00506       t_trackPAll             ->push_back( p1 );
00507       t_trackEtaAll           ->push_back( eta1 );
00508       t_trackPhiAll           ->push_back( phi1 );
00509       t_trackPtAll            ->push_back( pt1 );
00510       t_trackDxyAll           ->push_back( dxy1 );      
00511       t_trackDzAll            ->push_back( dz1 );       
00512       t_trackDxyPVAll         ->push_back( dxypv1 );    
00513       t_trackDzPVAll          ->push_back( dzpv1 );     
00514       t_trackChiSqAll         ->push_back( chisq1 );    
00515     }
00516     if (doMC) {
00517       edm::SimTrackContainer::const_iterator matchedSimTrkAll = spr::matchedSimTrack(iEvent, SimTk, SimVtx, pTrack, *associate, false); 
00518       if( matchedSimTrkAll != SimTk->end())     t_trackPdgIdAll->push_back( matchedSimTrkAll->type() );
00519     }
00520     
00521     if( pt1>minTrackP_ && std::abs(eta1)<maxTrackEta_ && trkDetItr->okECAL) { 
00522       
00523       double maxNearP31x31=999.0, maxNearP25x25=999.0, maxNearP21x21=999.0, maxNearP15x15=999.0;
00524       //double maxNearP13x13=999.0, maxNearP11x11=999.0, maxNearP9x9  =999.0, maxNearP7x7  =999.0;
00525 
00526       maxNearP31x31 = spr::chargeIsolationEcal(nTracks, trkCaloDets, geo, caloTopology, 15,15);
00527       maxNearP25x25 = spr::chargeIsolationEcal(nTracks, trkCaloDets, geo, caloTopology, 12,12);
00528       maxNearP21x21 = spr::chargeIsolationEcal(nTracks, trkCaloDets, geo, caloTopology, 10,10);
00529       maxNearP15x15 = spr::chargeIsolationEcal(nTracks, trkCaloDets, geo, caloTopology,  7, 7);
00530       //maxNearP13x13 = spr::chargeIsolationEcal(nTracks, trkCaloDets, geo, caloTopology,  6, 6);
00531       //maxNearP11x11 = spr::chargeIsolationEcal(nTracks, trkCaloDets, geo, caloTopology,  5, 5);
00532       //maxNearP9x9   = spr::chargeIsolationEcal(nTracks, trkCaloDets, geo, caloTopology,  4, 4);
00533       //maxNearP7x7   = spr::chargeIsolationEcal(nTracks, trkCaloDets, geo, caloTopology,  3, 3);
00534 
00535       int iTrkEtaBin=-1, iTrkMomBin=-1;
00536       for(unsigned int ieta=0; ieta<NEtaBins; ieta++) {
00537         if(std::abs(eta1)>genPartEtaBins[ieta] && std::abs(eta1)<genPartEtaBins[ieta+1] ) iTrkEtaBin = ieta;
00538       }
00539       for(unsigned int ipt=0;  ipt<NPBins;   ipt++) {
00540         if( p1>genPartPBins[ipt] &&  p1<genPartPBins[ipt+1] )  iTrkMomBin = ipt;
00541       }
00542       if( iTrkMomBin>=0 && iTrkEtaBin>=0 ) {
00543         h_maxNearP31x31[iTrkMomBin][iTrkEtaBin]->Fill( maxNearP31x31 );
00544         h_maxNearP25x25[iTrkMomBin][iTrkEtaBin]->Fill( maxNearP25x25 );
00545         h_maxNearP21x21[iTrkMomBin][iTrkEtaBin]->Fill( maxNearP21x21 );
00546         h_maxNearP15x15[iTrkMomBin][iTrkEtaBin]->Fill( maxNearP15x15 );
00547       }
00548       if( maxNearP31x31<0.0 && nLayersCrossed>7 && nOuterHits>4) {
00549         h_recEtaPt_2->Fill(eta1, pt1);
00550         h_recEtaP_2 ->Fill(eta1, p1);
00551         h_recPt_2   ->Fill(pt1);
00552         h_recP_2    ->Fill(p1);
00553         h_recEta_2  ->Fill(eta1);
00554         h_recPhi_2  ->Fill(phi1);
00555       }
00556       
00557       // if isolated in 7x7 then store the further quantities
00558       //if( maxNearP7x7<0.0) {
00559       if( maxNearP31x31<0.0) {
00560         
00561         // get the matching simTrack
00562         double simTrackP = -1;
00563         if (doMC) {
00564           edm::SimTrackContainer::const_iterator matchedSimTrk = spr::matchedSimTrack(iEvent, SimTk, SimVtx, pTrack, *associate, false);
00565           if( matchedSimTrk != SimTk->end() )simTrackP = matchedSimTrk->momentum().P();
00566         }
00567         // get ECal Tranverse Profile
00568         //double e3x3=0, e5x5=0, e7x7=0, e9x9=0, e11x11=0, e13x13=0, e15x15=0, e21x21=0, e25x25=0, e31x31=0;
00569         //double e7x7_10Sig=0, e9x9_10Sig=0, e11x11_10Sig=0, e15x15_10Sig=0;
00570         //double e7x7_15Sig=0, e9x9_15Sig=0, e11x11_15Sig=0, e15x15_15Sig=0;
00571         //double e7x7_20Sig=0, e9x9_20Sig=0, e11x11_20Sig=0, e15x15_20Sig=0;
00572         //double e7x7_25Sig=0, e9x9_25Sig=0, e11x11_25Sig=0, e15x15_25Sig=0;
00573         //double e7x7_30Sig=0, e9x9_30Sig=0, e11x11_30Sig=0, e15x15_30Sig=0;
00574 
00575         std::pair<double, bool>  e3x3P, e5x5P, e7x7P, e9x9P, e11x11P, e13x13P, e15x15P, e21x21P, e25x25P, e31x31P;
00576         std::pair<double, bool>  e7x7_10SigP, e9x9_10SigP, e11x11_10SigP, e15x15_10SigP;
00577         std::pair<double, bool>  e7x7_15SigP, e9x9_15SigP, e11x11_15SigP, e15x15_15SigP;
00578         std::pair<double, bool>  e7x7_20SigP, e9x9_20SigP, e11x11_20SigP, e15x15_20SigP;
00579         std::pair<double, bool>  e7x7_25SigP, e9x9_25SigP, e11x11_25SigP, e15x15_25SigP;
00580         std::pair<double, bool>  e7x7_30SigP, e9x9_30SigP, e11x11_30SigP, e15x15_30SigP;
00581 
00582         spr::caloSimInfo simInfo3x3,   simInfo5x5,   simInfo7x7,   simInfo9x9;
00583         spr::caloSimInfo simInfo11x11, simInfo13x13, simInfo15x15, simInfo21x21, simInfo25x25, simInfo31x31;
00584         double trkEcalEne=0;
00585 
00586         const DetId isoCell = trkDetItr->detIdECAL;
00587         /*
00588         e3x3         = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,1,1,   -100.0, -100.0);
00589         e5x5         = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,2,2,   -100.0, -100.0);
00590         e7x7         = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,3,3,   -100.0, -100.0);
00591         e9x9         = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,4,4,   -100.0, -100.0);
00592         e11x11       = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,5,5,   -100.0, -100.0);
00593         e13x13       = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,6,6,   -100.0, -100.0);
00594         e15x15       = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,7,7,   -100.0, -100.0);
00595         e21x21       = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,10,10, -100.0, -100.0);
00596         e25x25       = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,12,12, -100.0, -100.0);
00597         e31x31       = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,15,15, -100.0, -100.0);
00598         
00599         e7x7_10Sig   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,3,3,   0.030,  0.150);
00600         e9x9_10Sig   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,4,4,   0.030,  0.150);
00601         e11x11_10Sig = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,5,5,   0.030,  0.150);
00602         e15x15_10Sig = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,7,7,   0.030,  0.150);
00603         
00604         e7x7_15Sig   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,3,3,   0.045,  0.225);
00605         e9x9_15Sig   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,4,4,   0.045,  0.225);
00606         e11x11_15Sig = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,5,5,   0.045,  0.225);
00607         e15x15_15Sig = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,7,7,   0.045,  0.225);
00608         
00609         e7x7_20Sig   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,3,3,   0.060,  0.300);
00610         e9x9_20Sig   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,4,4,   0.060,  0.300);
00611         e11x11_20Sig = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,5,5,   0.060,  0.300);
00612         e15x15_20Sig = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,7,7,   0.060,  0.300);
00613         
00614         e7x7_25Sig   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,3,3,   0.075,  0.375);
00615         e9x9_25Sig   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,4,4,   0.075,  0.375);
00616         e11x11_25Sig = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,5,5,   0.075,  0.375);
00617         e15x15_25Sig = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,7,7,   0.075,  0.375);
00618         
00619         e7x7_30Sig   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,3,3,   0.090,  0.450);
00620         e9x9_30Sig   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,4,4,   0.090,  0.450);
00621         e11x11_30Sig = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,5,5,   0.090,  0.450);
00622         e15x15_30Sig = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, geo, caloTopology,7,7,   0.090,  0.450);
00623 
00624         std::cout << "default ecal rechit " << std::endl;
00625         std::cout<<"e3x3 "<<e3x3<<" e9x9 "<<e9x9<<" e15x15 " << e15x15 << " e31x31 "<<e31x31<<std::endl;
00626         std::cout<<"e7x7_10Sig "<<e7x7_10Sig<<" e11x11_10Sig "<<e11x11_10Sig<<" e15x15_10Sig "<<e15x15_10Sig<<std::endl;
00627         std::pair<double, bool> eJunk1 = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,3,3,   0.060,  0.300, false, true);
00628         std::pair<double, bool> eJunk2 = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,3,3,   0.20,  0.45, true, true);
00629         */
00630 
00631         //e3x3P         = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,1,1,   -100.0, -100.0);
00632         //e5x5P         = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,2,2,   -100.0, -100.0);
00633 
00634         edm::ESHandle<EcalSeverityLevelAlgo> sevlv;
00635         iSetup.get<EcalSeverityLevelAlgoRcd>().get(sevlv);
00636 
00637         e7x7P         = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),3,3,   -100.0, -100.0, tMinE_,tMaxE_);
00638         e9x9P         = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),4,4,   -100.0, -100.0, tMinE_,tMaxE_);
00639         e11x11P       = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),5,5,   -100.0, -100.0, tMinE_,tMaxE_);
00640         //e13x13P       = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,6,6,   -100.0, -100.0);
00641         e15x15P       = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),7,7,   -100.0, -100.0, tMinE_,tMaxE_);
00642         //e21x21P       = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,10,10, -100.0, -100.0);
00643         //e25x25P       = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,12,12, -100.0, -100.0);
00644         //e31x31P       = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,15,15, -100.0, -100.0);
00645         
00646         e7x7_10SigP   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),3,3,   0.030,  0.150, tMinE_,tMaxE_);
00647         e9x9_10SigP   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),4,4,   0.030,  0.150, tMinE_,tMaxE_);
00648         e11x11_10SigP = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),5,5,   0.030,  0.150, tMinE_,tMaxE_);
00649         e15x15_10SigP = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),7,7,   0.030,  0.150, tMinE_,tMaxE_);
00650 
00651         /*      
00652         e7x7_15SigP   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,3,3,   0.045,  0.225);
00653         e9x9_15SigP   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,4,4,   0.045,  0.225);
00654         e11x11_15SigP = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,5,5,   0.045,  0.225);
00655         e15x15_15SigP = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,7,7,   0.045,  0.225);
00656         */
00657         e7x7_15SigP   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology, sevlv.product(),ttMap, 3,3, 0.20,0.45, tMinE_,tMaxE_);
00658         e9x9_15SigP   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology, sevlv.product(),ttMap, 4,4, 0.20,0.45, tMinE_,tMaxE_);
00659         e11x11_15SigP = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(), ttMap, 5,5, 0.20,0.45, tMinE_,tMaxE_);
00660         e15x15_15SigP = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology, sevlv.product(),ttMap, 7,7, 0.20,0.45, tMinE_,tMaxE_, false);
00661         
00662         e7x7_20SigP   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),3,3,   0.060,  0.300, tMinE_,tMaxE_);
00663         e9x9_20SigP   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),4,4,   0.060,  0.300, tMinE_,tMaxE_);
00664         e11x11_20SigP = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),5,5,   0.060,  0.300, tMinE_,tMaxE_);
00665         e15x15_20SigP = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),7,7,   0.060,  0.300, tMinE_,tMaxE_);
00666         
00667         e7x7_25SigP   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),3,3,   0.075,  0.375, tMinE_,tMaxE_);
00668         e9x9_25SigP   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),4,4,   0.075,  0.375, tMinE_,tMaxE_);
00669         e11x11_25SigP = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),5,5,   0.075,  0.375, tMinE_,tMaxE_);
00670         e15x15_25SigP = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),7,7,   0.075,  0.375, tMinE_,tMaxE_);
00671         
00672         e7x7_30SigP   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),3,3,   0.090,  0.450, tMinE_,tMaxE_);
00673         e9x9_30SigP   = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),4,4,   0.090,  0.450, tMinE_,tMaxE_);
00674         e11x11_30SigP = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),5,5,   0.090,  0.450, tMinE_,tMaxE_);
00675         e15x15_30SigP = spr::eECALmatrix(isoCell,barrelRecHitsHandle,endcapRecHitsHandle, *theEcalChStatus, geo, caloTopology,sevlv.product(),7,7,   0.090,  0.450, tMinE_,tMaxE_);
00676         if(myverbose_ == 2) {
00677           std::cout << "clean  ecal rechit " << std::endl;
00678           std::cout<<"e3x3 "<<e3x3P.first<<" e9x9 "<<e9x9P.first<<" e15x15 " << e15x15P.first << " e31x31 "<<e31x31P.first<<std::endl;
00679           std::cout<<"e7x7_10Sig "<<e7x7_10SigP.first<<" e11x11_10Sig "<<e11x11_10SigP.first<<" e15x15_10Sig "<<e15x15_10SigP.first<<std::endl;
00680         }
00681         
00682         if (doMC) {
00683           // check the energy from SimHits
00684           spr::eECALSimInfo(iEvent,isoCell,geo,caloTopology,pcaloeb,pcaloee,SimTk,SimVtx,pTrack, *associate, 1,1, simInfo3x3);
00685           spr::eECALSimInfo(iEvent,isoCell,geo,caloTopology,pcaloeb,pcaloee,SimTk,SimVtx,pTrack, *associate, 2,2, simInfo5x5);
00686           spr::eECALSimInfo(iEvent,isoCell,geo,caloTopology,pcaloeb,pcaloee,SimTk,SimVtx,pTrack, *associate, 3,3, simInfo7x7);
00687           spr::eECALSimInfo(iEvent,isoCell,geo,caloTopology,pcaloeb,pcaloee,SimTk,SimVtx,pTrack, *associate, 4,4, simInfo9x9);
00688           spr::eECALSimInfo(iEvent,isoCell,geo,caloTopology,pcaloeb,pcaloee,SimTk,SimVtx,pTrack, *associate, 5,5, simInfo11x11);
00689           spr::eECALSimInfo(iEvent,isoCell,geo,caloTopology,pcaloeb,pcaloee,SimTk,SimVtx,pTrack, *associate, 6,6, simInfo13x13);
00690           spr::eECALSimInfo(iEvent,isoCell,geo,caloTopology,pcaloeb,pcaloee,SimTk,SimVtx,pTrack, *associate, 7,7, simInfo15x15, 150.0,false);
00691           spr::eECALSimInfo(iEvent,isoCell,geo,caloTopology,pcaloeb,pcaloee,SimTk,SimVtx,pTrack, *associate, 10,10, simInfo21x21);
00692           spr::eECALSimInfo(iEvent,isoCell,geo,caloTopology,pcaloeb,pcaloee,SimTk,SimVtx,pTrack, *associate, 12,12, simInfo25x25);
00693           spr::eECALSimInfo(iEvent,isoCell,geo,caloTopology,pcaloeb,pcaloee,SimTk,SimVtx,pTrack, *associate, 15,15, simInfo31x31);
00694           
00695           trkEcalEne   = spr::eCaloSimInfo(iEvent, geo, pcaloeb,pcaloee, SimTk, SimVtx, pTrack, *associate, 150.0, false);
00696            if(myverbose_ == 1) {
00697             std::cout << "Track momentum " << pt1 << std::endl;
00698 
00699             std::cout << "ecal siminfo " << std::endl;
00700             std::cout << "simInfo3x3: " << "eTotal " << simInfo3x3.eTotal << " eMatched " << simInfo3x3.eMatched << " eRest " << simInfo3x3.eRest << " eGamma "<<simInfo3x3.eGamma << " eNeutralHad " << simInfo3x3.eNeutralHad << " eChargedHad " << simInfo3x3.eChargedHad << std::endl;
00701             std::cout << "simInfo5x5: " << "eTotal " << simInfo5x5.eTotal << " eMatched " << simInfo5x5.eMatched << " eRest " << simInfo5x5.eRest << " eGamma "<<simInfo5x5.eGamma << " eNeutralHad " << simInfo5x5.eNeutralHad << " eChargedHad " << simInfo5x5.eChargedHad << std::endl;
00702             std::cout << "simInfo7x7: " << "eTotal " << simInfo7x7.eTotal << " eMatched " << simInfo7x7.eMatched << " eRest " << simInfo7x7.eRest << " eGamma "<<simInfo7x7.eGamma << " eNeutralHad " << simInfo7x7.eNeutralHad << " eChargedHad " << simInfo7x7.eChargedHad << std::endl;
00703             std::cout << "simInfo9x9: " << "eTotal " << simInfo9x9.eTotal << " eMatched " << simInfo9x9.eMatched << " eRest " << simInfo9x9.eRest << " eGamma "<<simInfo9x9.eGamma << " eNeutralHad " << simInfo9x9.eNeutralHad << " eChargedHad " << simInfo9x9.eChargedHad << std::endl;
00704             std::cout << "simInfo11x11: " << "eTotal " << simInfo11x11.eTotal << " eMatched " << simInfo11x11.eMatched << " eRest " << simInfo11x11.eRest << " eGamma "<<simInfo11x11.eGamma << " eNeutralHad " << simInfo11x11.eNeutralHad << " eChargedHad " << simInfo11x11.eChargedHad << std::endl;
00705             std::cout << "simInfo15x15: " << "eTotal " << simInfo15x15.eTotal << " eMatched " << simInfo15x15.eMatched << " eRest " << simInfo15x15.eRest << " eGamma "<<simInfo15x15.eGamma << " eNeutralHad " << simInfo15x15.eNeutralHad << " eChargedHad " << simInfo15x15.eChargedHad << std::endl;
00706             std::cout << "simInfo31x31: " << "eTotal " << simInfo31x31.eTotal << " eMatched " << simInfo31x31.eMatched << " eRest " << simInfo31x31.eRest << " eGamma "<<simInfo31x31.eGamma << " eNeutralHad " << simInfo31x31.eNeutralHad << " eChargedHad " << simInfo31x31.eChargedHad << std::endl;
00707             std::cout << "trkEcalEne" << trkEcalEne << std::endl;
00708 
00709           }
00710         }
00711 
00712         // =======  Get HCAL information 
00713         double hcalScale=1.0;
00714         if( std::abs(pTrack->eta())<1.4 ) {
00715           hcalScale=120.0;
00716         } else {
00717           hcalScale=135.0;
00718         }
00719         
00720         double maxNearHcalP3x3=-1, maxNearHcalP5x5=-1, maxNearHcalP7x7=-1;
00721         maxNearHcalP3x3  = spr::chargeIsolationHcal(nTracks, trkCaloDets, theHBHETopology, 1,1);
00722         maxNearHcalP5x5  = spr::chargeIsolationHcal(nTracks, trkCaloDets, theHBHETopology, 2,2);
00723         maxNearHcalP7x7  = spr::chargeIsolationHcal(nTracks, trkCaloDets, theHBHETopology, 3,3);
00724 
00725         double h3x3=0,    h5x5=0,    h7x7=0;
00726         double h3x3Sig=0,    h5x5Sig=0,    h7x7Sig=0;
00727         double trkHcalEne = 0;
00728         spr::caloSimInfo hsimInfo3x3, hsimInfo5x5, hsimInfo7x7;
00729         
00730         if(trkDetItr->okHCAL) {
00731           const DetId ClosestCell(trkDetItr->detIdHCAL);
00732           // bool includeHO=false, bool algoNew=true, bool debug=false
00733           h3x3 = spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,1,1, false, true, -100.0, -100.0, -100.0, -100.0, tMinH_,tMaxH_);  
00734           h5x5 = spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,2,2, false, true, -100.0, -100.0, -100.0, -100.0, tMinH_,tMaxH_);  
00735           h7x7 = spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,3,3, false, true, -100.0, -100.0, -100.0, -100.0, tMinH_,tMaxH_);  
00736           h3x3Sig = spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,1,1, false, true, 0.7, 0.8, -100.0, -100.0, tMinH_,tMaxH_);  
00737           h5x5Sig = spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,2,2, false, true, 0.7, 0.8, -100.0, -100.0, tMinH_,tMaxH_);  
00738           h7x7Sig = spr::eHCALmatrix(theHBHETopology, ClosestCell, hbhe,3,3, false, true, 0.7, 0.8, -100.0, -100.0, tMinH_,tMaxH_);  
00739           if(myverbose_==2) {
00740             std::cout << "HCAL 3x3 " << h3x3 << " " << h3x3Sig << " 5x5 " <<  h5x5 << " " << h5x5Sig << " 7x7 " << h7x7 << " " << h7x7Sig << std::endl;
00741           }
00742           
00743           if (doMC) {
00744             spr::eHCALSimInfo(iEvent, theHBHETopology, ClosestCell, geo,pcalohh, SimTk, SimVtx, pTrack, *associate, 1,1, hsimInfo3x3);
00745             spr::eHCALSimInfo(iEvent, theHBHETopology, ClosestCell, geo,pcalohh, SimTk, SimVtx, pTrack, *associate, 2,2, hsimInfo5x5);
00746             spr::eHCALSimInfo(iEvent, theHBHETopology, ClosestCell, geo,pcalohh, SimTk, SimVtx, pTrack, *associate, 3,3, hsimInfo7x7, 150.0, false,false);
00747             trkHcalEne  = spr::eCaloSimInfo(iEvent, geo,pcalohh, SimTk, SimVtx, pTrack, *associate);
00748             if(myverbose_ == 1) {
00749               std::cout << "Hcal siminfo " << std::endl;
00750               std::cout << "hsimInfo3x3: " << "eTotal " << hsimInfo3x3.eTotal << " eMatched " << hsimInfo3x3.eMatched << " eRest " << hsimInfo3x3.eRest << " eGamma "<<hsimInfo3x3.eGamma << " eNeutralHad " << hsimInfo3x3.eNeutralHad << " eChargedHad " << hsimInfo3x3.eChargedHad << std::endl;
00751               std::cout << "hsimInfo5x5: " << "eTotal " << hsimInfo5x5.eTotal << " eMatched " << hsimInfo5x5.eMatched << " eRest " << hsimInfo5x5.eRest << " eGamma "<<hsimInfo5x5.eGamma << " eNeutralHad " << hsimInfo5x5.eNeutralHad << " eChargedHad " << hsimInfo5x5.eChargedHad << std::endl;
00752               std::cout << "hsimInfo7x7: " << "eTotal " << hsimInfo7x7.eTotal << " eMatched " << hsimInfo7x7.eMatched << " eRest " << hsimInfo7x7.eRest << " eGamma "<<hsimInfo7x7.eGamma << " eNeutralHad " << hsimInfo7x7.eNeutralHad << " eChargedHad " << hsimInfo7x7.eChargedHad << std::endl;
00753               std::cout << "trkHcalEne " << trkHcalEne << std::endl;
00754             }
00755           }
00756           
00757           // debug the ecal and hcal matrix
00758           if(myverbose_==4) {
00759             std::cout<<"Run "<<iEvent.id().run()<<"  Event "<<iEvent.id().event()<<std::endl; 
00760             std::vector<std::pair<DetId,double> > v7x7 = spr::eHCALmatrixCell(theHBHETopology, ClosestCell, hbhe,3,3, false, false);
00761             double sumv=0.0;
00762             
00763             for(unsigned int iv=0; iv<v7x7.size(); iv++) { 
00764               sumv += v7x7[iv].second;
00765             }
00766             std::cout<<"h7x7 "<<h7x7<<" v7x7 "<<sumv << " in " << v7x7.size() <<std::endl;
00767             for(unsigned int iv=0; iv<v7x7.size(); iv++) { 
00768               HcalDetId id = v7x7[iv].first;
00769               std::cout << " Cell " << iv << " 0x" << std::hex << v7x7[iv].first() << std::dec << " " << id << " Energy " << v7x7[iv].second << std::endl;
00770             }
00771           }
00772           
00773         }
00774 
00775         
00776         // ====================================================================================================
00777 
00778         // get diff between track outermost hit position and the propagation point at outermost surface of tracker      
00779         std::pair<math::XYZPoint,double> point2_TK0 = spr::propagateTrackerEnd( pTrack, bField, false);
00780         math::XYZPoint diff(pTrack->outerPosition().X()-point2_TK0.first.X(), 
00781                             pTrack->outerPosition().Y()-point2_TK0.first.Y(), 
00782                             pTrack->outerPosition().Z()-point2_TK0.first.Z() );
00783         double trackOutPosOutHitDr = diff.R();
00784         double trackL              = point2_TK0.second;
00785         //std::cout<<" propagted "<<point2_TK0.first<<" "<< point2_TK0.first.eta()<<" "<<point2_TK0.first.phi()<<std::endl;
00786         //std::cout<<" outerPosition() "<< pTrack->outerPosition() << " "<< pTrack->outerPosition().eta()<< " " << pTrack->outerPosition().phi()<< std::endl;
00787         //std::cout<<"diff " << diff << " diffR " <<diff.R()<<" diffR/L "<<diff.R()/point2_TK0.second <<std::endl;
00788 
00789         for(unsigned int ind=0;ind<recVtxs->size();ind++) {
00790           if (!((*recVtxs)[ind].isFake())) {
00791             reco::Vertex::trackRef_iterator vtxTrack = (*recVtxs)[ind].tracks_begin();
00792             if( DeltaR(eta1,phi1, (*vtxTrack)->eta(),(*vtxTrack)->phi()) < 0.01 ) t_trackPVIdx ->push_back( ind );
00793             else                                                                  t_trackPVIdx ->push_back( -1 );
00794           }
00795         }
00796 
00797         // Fill the tree Branches here 
00798         t_trackP                ->push_back( p1 );
00799         t_trackPt               ->push_back( pt1 );
00800         t_trackEta              ->push_back( eta1 );
00801         t_trackPhi              ->push_back( phi1 );
00802         t_trackEcalEta          ->push_back( etaEcal1 );
00803         t_trackEcalPhi          ->push_back( phiEcal1 );
00804         t_trackHcalEta          ->push_back( etaHcal1 );
00805         t_trackHcalPhi          ->push_back( phiHcal1 );
00806         t_trackDxy              ->push_back( dxy1 );    
00807         t_trackDz               ->push_back( dz1 );     
00808         t_trackDxyBS            ->push_back( dxybs1 );  
00809         t_trackDzBS             ->push_back( dzbs1 );   
00810         t_trackDxyPV            ->push_back( dxypv1 );  
00811         t_trackDzPV             ->push_back( dzpv1 );   
00812         t_trackChiSq            ->push_back( chisq1 );  
00813         t_trackNOuterHits       ->push_back( nOuterHits );
00814         t_NLayersCrossed        ->push_back( nLayersCrossed );
00815         
00816         t_trackHitsTOB          ->push_back( hitp.stripTOBLayersWithMeasurement()       ); 
00817         t_trackHitsTEC          ->push_back( hitp.stripTECLayersWithMeasurement()       );
00818         t_trackHitInMissTOB     ->push_back( hitpIn.stripTOBLayersWithoutMeasurement()  ); 
00819         t_trackHitInMissTEC     ->push_back( hitpIn.stripTECLayersWithoutMeasurement()  );  
00820         t_trackHitInMissTIB     ->push_back( hitpIn.stripTIBLayersWithoutMeasurement()  );  
00821         t_trackHitInMissTID     ->push_back( hitpIn.stripTIDLayersWithoutMeasurement()  );
00822         t_trackHitInMissTIBTID  ->push_back( hitpIn.stripTIBLayersWithoutMeasurement() + hitpIn.stripTIDLayersWithoutMeasurement() );  
00823 
00824         t_trackHitOutMissTOB    ->push_back( hitpOut.stripTOBLayersWithoutMeasurement() );
00825         t_trackHitOutMissTEC    ->push_back( hitpOut.stripTECLayersWithoutMeasurement() ); 
00826         t_trackHitOutMissTIB    ->push_back( hitpOut.stripTIBLayersWithoutMeasurement() );
00827         t_trackHitOutMissTID    ->push_back( hitpOut.stripTIDLayersWithoutMeasurement() );
00828         t_trackHitOutMissTOBTEC ->push_back( hitpOut.stripTOBLayersWithoutMeasurement() + hitpOut.stripTECLayersWithoutMeasurement() );
00829 
00830         t_trackHitInMeasTOB     ->push_back( hitpIn.stripTOBLayersWithMeasurement()  ); 
00831         t_trackHitInMeasTEC     ->push_back( hitpIn.stripTECLayersWithMeasurement()  );  
00832         t_trackHitInMeasTIB     ->push_back( hitpIn.stripTIBLayersWithMeasurement()  );  
00833         t_trackHitInMeasTID     ->push_back( hitpIn.stripTIDLayersWithMeasurement()  );
00834         t_trackHitOutMeasTOB    ->push_back( hitpOut.stripTOBLayersWithMeasurement() );
00835         t_trackHitOutMeasTEC    ->push_back( hitpOut.stripTECLayersWithMeasurement() ); 
00836         t_trackHitOutMeasTIB    ->push_back( hitpOut.stripTIBLayersWithMeasurement() );
00837         t_trackHitOutMeasTID    ->push_back( hitpOut.stripTIDLayersWithMeasurement() );
00838         t_trackOutPosOutHitDr   ->push_back( trackOutPosOutHitDr                     );
00839         t_trackL                ->push_back( trackL                                  );
00840 
00841         t_maxNearP31x31         ->push_back( maxNearP31x31 );
00842         //t_maxNearP25x25         ->push_back( maxNearP25x25 );
00843         t_maxNearP21x21         ->push_back( maxNearP21x21 );
00844         //t_maxNearP15x15         ->push_back( maxNearP15x15 );
00845         //t_maxNearP13x13         ->push_back( maxNearP13x13 );
00846         //t_maxNearP11x11         ->push_back( maxNearP11x11 );
00847         //t_maxNearP9x9           ->push_back( maxNearP9x9   );
00848         //t_maxNearP7x7           ->push_back( maxNearP7x7   );
00849         
00850         t_ecalSpike11x11        ->push_back( e11x11P.second );
00851         //t_e3x3                  ->push_back( e3x3P.first );
00852         //t_e5x5                  ->push_back( e5x5P.first );
00853         t_e7x7                  ->push_back( e7x7P.first );
00854         t_e9x9                  ->push_back( e9x9P.first );
00855         t_e11x11                ->push_back( e11x11P.first );
00856         //t_e13x13                ->push_back( e13x13P.first );
00857         t_e15x15                ->push_back( e15x15P.first );
00858         //t_e21x21                ->push_back( e21x21P.first );
00859         //t_e25x25                ->push_back( e25x25P.first );
00860         //t_e31x31                ->push_back( e31x31P.first );
00861 
00862         t_e7x7_10Sig            ->push_back( e7x7_10SigP.first   ); 
00863         t_e9x9_10Sig            ->push_back( e9x9_10SigP.first   ); 
00864         t_e11x11_10Sig          ->push_back( e11x11_10SigP.first ); 
00865         t_e15x15_10Sig          ->push_back( e15x15_10SigP.first );
00866         t_e7x7_15Sig            ->push_back( e7x7_15SigP.first   ); 
00867         t_e9x9_15Sig            ->push_back( e9x9_15SigP.first   ); 
00868         t_e11x11_15Sig          ->push_back( e11x11_15SigP.first ); 
00869         t_e15x15_15Sig          ->push_back( e15x15_15SigP.first );
00870         t_e7x7_20Sig            ->push_back( e7x7_20SigP.first   ); 
00871         t_e9x9_20Sig            ->push_back( e9x9_20SigP.first   ); 
00872         t_e11x11_20Sig          ->push_back( e11x11_20SigP.first ); 
00873         t_e15x15_20Sig          ->push_back( e15x15_20SigP.first );
00874         t_e7x7_25Sig            ->push_back( e7x7_25SigP.first   ); 
00875         t_e9x9_25Sig            ->push_back( e9x9_25SigP.first   ); 
00876         t_e11x11_25Sig          ->push_back( e11x11_25SigP.first ); 
00877         t_e15x15_25Sig          ->push_back( e15x15_25SigP.first );
00878         t_e7x7_30Sig            ->push_back( e7x7_30SigP.first   ); 
00879         t_e9x9_30Sig            ->push_back( e9x9_30SigP.first   ); 
00880         t_e11x11_30Sig          ->push_back( e11x11_30SigP.first ); 
00881         t_e15x15_30Sig          ->push_back( e15x15_30SigP.first );
00882 
00883         if (doMC) {
00884           //t_esim3x3               ->push_back( simInfo3x3.eTotal );
00885           //t_esim5x5               ->push_back( simInfo5x5.eTotal );
00886           t_esim7x7               ->push_back( simInfo7x7.eTotal );
00887           t_esim9x9               ->push_back( simInfo9x9.eTotal );
00888           t_esim11x11             ->push_back( simInfo11x11.eTotal );
00889           //t_esim13x13             ->push_back( simInfo13x13.eTotal );
00890           t_esim15x15             ->push_back( simInfo15x15.eTotal );
00891           //t_esim21x21             ->push_back( simInfo21x21.eTotal );
00892           //t_esim25x25             ->push_back( simInfo25x25.eTotal );
00893           //t_esim31x31             ->push_back( simInfo31x31.eTotal );
00894         
00895           //t_esim3x3Matched        ->push_back( simInfo3x3.eMatched );
00896           //t_esim5x5Matched        ->push_back( simInfo5x5.eMatched );
00897           t_esim7x7Matched        ->push_back( simInfo7x7.eMatched );
00898           t_esim9x9Matched        ->push_back( simInfo9x9.eMatched );
00899           t_esim11x11Matched      ->push_back( simInfo11x11.eMatched );
00900           //t_esim13x13Matched      ->push_back( simInfo13x13.eMatched );
00901           t_esim15x15Matched      ->push_back( simInfo15x15.eMatched );
00902           //t_esim21x21Matched      ->push_back( simInfo21x21.eMatched );
00903           //t_esim25x25Matched      ->push_back( simInfo25x25.eMatched );
00904           //t_esim31x31Matched      ->push_back( simInfo31x31.eMatched );
00905         
00906           //t_esim3x3Rest           ->push_back( simInfo3x3.eRest );
00907           //t_esim5x5Rest           ->push_back( simInfo5x5.eRest );
00908           t_esim7x7Rest           ->push_back( simInfo7x7.eRest );
00909           t_esim9x9Rest           ->push_back( simInfo9x9.eRest );
00910           t_esim11x11Rest         ->push_back( simInfo11x11.eRest );
00911           //t_esim13x13Rest         ->push_back( simInfo13x13.eRest );
00912           t_esim15x15Rest         ->push_back( simInfo15x15.eRest );
00913           //t_esim21x21Rest         ->push_back( simInfo21x21.eRest );
00914           //t_esim25x25Rest         ->push_back( simInfo25x25.eRest );
00915           //t_esim31x31Rest         ->push_back( simInfo31x31.eRest );
00916         
00917           //t_esim3x3Photon         ->push_back( simInfo3x3.eGamma );
00918           //t_esim5x5Photon         ->push_back( simInfo5x5.eGamma );
00919           t_esim7x7Photon         ->push_back( simInfo7x7.eGamma );
00920           t_esim9x9Photon         ->push_back( simInfo9x9.eGamma );
00921           t_esim11x11Photon       ->push_back( simInfo11x11.eGamma );
00922           //t_esim13x13Photon       ->push_back( simInfo13x13.eGamma );
00923           t_esim15x15Photon       ->push_back( simInfo15x15.eGamma );
00924           //t_esim21x21Photon       ->push_back( simInfo21x21.eGamma );
00925           //t_esim25x25Photon       ->push_back( simInfo25x25.eGamma );
00926           //t_esim31x31Photon       ->push_back( simInfo31x31.eGamma );
00927         
00928           //t_esim3x3NeutHad        ->push_back( simInfo3x3.eNeutralHad );
00929           //t_esim5x5NeutHad        ->push_back( simInfo5x5.eNeutralHad );
00930           t_esim7x7NeutHad        ->push_back( simInfo7x7.eNeutralHad );
00931           t_esim9x9NeutHad        ->push_back( simInfo9x9.eNeutralHad );
00932           t_esim11x11NeutHad      ->push_back( simInfo11x11.eNeutralHad );
00933           //t_esim13x13NeutHad      ->push_back( simInfo13x13.eNeutralHad );
00934           t_esim15x15NeutHad      ->push_back( simInfo15x15.eNeutralHad );
00935           //t_esim21x21NeutHad      ->push_back( simInfo21x21.eNeutralHad );
00936           //t_esim25x25NeutHad      ->push_back( simInfo25x25.eNeutralHad );
00937           //t_esim31x31NeutHad      ->push_back( simInfo31x31.eNeutralHad );
00938         
00939           //t_esim3x3CharHad        ->push_back( simInfo3x3.eChargedHad );
00940           //t_esim5x5CharHad        ->push_back( simInfo5x5.eChargedHad );
00941           t_esim7x7CharHad        ->push_back( simInfo7x7.eChargedHad );
00942           t_esim9x9CharHad        ->push_back( simInfo9x9.eChargedHad );
00943           t_esim11x11CharHad      ->push_back( simInfo11x11.eChargedHad );
00944           //t_esim13x13CharHad      ->push_back( simInfo13x13.eChargedHad );
00945           t_esim15x15CharHad      ->push_back( simInfo15x15.eChargedHad );
00946           //t_esim21x21CharHad      ->push_back( simInfo21x21.eChargedHad );
00947           //t_esim25x25CharHad      ->push_back( simInfo25x25.eChargedHad );
00948           //t_esim31x31CharHad      ->push_back( simInfo31x31.eChargedHad );
00949         
00950           t_trkEcalEne            ->push_back( trkEcalEne );
00951           t_simTrackP             ->push_back( simTrackP );
00952           t_esimPdgId             ->push_back( simInfo11x11.pdgMatched );
00953         }
00954 
00955         t_maxNearHcalP3x3       ->push_back( maxNearHcalP3x3 );
00956         t_maxNearHcalP5x5       ->push_back( maxNearHcalP5x5 );
00957         t_maxNearHcalP7x7       ->push_back( maxNearHcalP7x7 );
00958         
00959         t_h3x3                  ->push_back( h3x3 );
00960         t_h5x5                  ->push_back( h5x5 );
00961         t_h7x7                  ->push_back( h7x7 );
00962         t_h3x3Sig               ->push_back( h3x3Sig );
00963         t_h5x5Sig               ->push_back( h5x5Sig );
00964         t_h7x7Sig               ->push_back( h7x7Sig );
00965         
00966         t_infoHcal              ->push_back( trkDetItr->okHCAL );
00967         if (doMC) {
00968           t_trkHcalEne            ->push_back( hcalScale*trkHcalEne );
00969         
00970           t_hsim3x3               ->push_back( hcalScale*hsimInfo3x3.eTotal );
00971           t_hsim5x5               ->push_back( hcalScale*hsimInfo5x5.eTotal );
00972           t_hsim7x7               ->push_back( hcalScale*hsimInfo7x7.eTotal );
00973         
00974           t_hsim3x3Matched        ->push_back( hcalScale*hsimInfo3x3.eMatched );
00975           t_hsim5x5Matched        ->push_back( hcalScale*hsimInfo5x5.eMatched );
00976           t_hsim7x7Matched        ->push_back( hcalScale*hsimInfo7x7.eMatched );
00977         
00978           t_hsim3x3Rest           ->push_back( hcalScale*hsimInfo3x3.eRest );
00979           t_hsim5x5Rest           ->push_back( hcalScale*hsimInfo5x5.eRest );
00980           t_hsim7x7Rest           ->push_back( hcalScale*hsimInfo7x7.eRest );
00981         
00982           t_hsim3x3Photon         ->push_back( hcalScale*hsimInfo3x3.eGamma );
00983           t_hsim5x5Photon         ->push_back( hcalScale*hsimInfo5x5.eGamma );
00984           t_hsim7x7Photon         ->push_back( hcalScale*hsimInfo7x7.eGamma );
00985         
00986           t_hsim3x3NeutHad        ->push_back( hcalScale*hsimInfo3x3.eNeutralHad );
00987           t_hsim5x5NeutHad        ->push_back( hcalScale*hsimInfo5x5.eNeutralHad );
00988           t_hsim7x7NeutHad        ->push_back( hcalScale*hsimInfo7x7.eNeutralHad );
00989         
00990           t_hsim3x3CharHad        ->push_back( hcalScale*hsimInfo3x3.eChargedHad );
00991           t_hsim5x5CharHad        ->push_back( hcalScale*hsimInfo5x5.eChargedHad );
00992           t_hsim7x7CharHad        ->push_back( hcalScale*hsimInfo7x7.eChargedHad );
00993         }
00994         /*
00995         if(hcalScale*hsimInfo3x3.eTotal > 50.0) {
00996 
00997           std::cout << "Loosely Iso Track : eta " << eta1 << " Rec Mom " << p1 << " SimMom " << simTrackP << " h3x3 " << h3x3 << std::endl;
00998 
00999           std::cout <<"Closest cell Hcal (atHCAL) " << (HcalDetId)ClosestCell << std::endl;
01000 
01001           std::cout <<"trkHcalEne, etotal, matched, rest " <<hcalScale*trkHcalEne<<std::setw(15)<<hcalScale*hsimInfo3x3.eTotal
01002                     <<std::setw(15)<<hcalScale*hsimInfo3x3.eMatched<<std::setw(15)<<hcalScale*hsimInfo3x3.eRest
01003                     <<std::endl;
01004           unsigned int nn = t_trkHcalEne->size();
01005           std::cout <<"in Tree                           " << (*t_trkHcalEne)[nn-1] <<std::setw(15)<< (*t_hsim3x3)[nn-1]
01006                     <<std::setw(15)<< (*t_hsim3x3Matched)[nn-1] <<std::setw(15)<< (*t_hsim3x3Rest)[nn-1]
01007                     << std::endl;
01008 
01009           std::cout << "debug output \n" << std::endl;
01010           spr::caloSimInfo hsimInfo3x3_debug;
01011           spr::eHCALSimInfo(iEvent, theHBHETopology, ClosestCell, geo,pcalohh, SimTk, SimVtx, pTrack, *associate, 1,1, hsimInfo3x3_debug, 150.0, true);
01012 
01013         }
01014         */
01015 
01016 
01017       } // if loosely isolated track
01018     } // check p1/eta
01019   } // loop over track collection
01020   
01021   //if (doMC) delete associate;
01022   
01023   tree->Fill();
01024 
01025 }
01026 
01027 // ----- method called once each job just before starting event loop ----
01028 void IsolatedTracksNxN::beginJob() {
01029 
01030   nEventProc=0;
01031 
01032   //  double tempgen_TH[21] = { 1.0,  2.0,  3.0,  4.0,  5.0, 
01033  double tempgen_TH[16] = { 0.0,  1.0,  2.0,  3.0,  4.0,  
01034                            5.0,  6.0,  7.0,  9.0, 11.0, 
01035                           15.0, 20.0, 30.0, 50.0, 75.0, 100.0};
01036 
01037   for(int i=0; i<16; i++)  genPartPBins[i]  = tempgen_TH[i];
01038 
01039   double tempgen_Eta[4] = {0.0, 1.131, 1.653, 2.172};
01040 
01041   for(int i=0; i<4; i++) genPartEtaBins[i] = tempgen_Eta[i];
01042 
01043   BookHistograms();
01044 }
01045 
01046 // ----- method called once each job just after ending the event loop ----
01047 void IsolatedTracksNxN::endJob() {
01048 
01049   std::cout << "Number of Events Processed " << nEventProc << std::endl;
01050   if( h_L1AlgoNames ){
01051     int nbins=h_L1AlgoNames->GetNbinsX(); 
01052     for (int ibin=0; ibin<nbins; ++ibin){
01053       double cont = (double)h_L1AlgoNames->GetBinContent(ibin+1);
01054       if( cont>0 ) {
01055         trig_iter=l1TriggerMap.find(algoBitToName[ibin]);
01056         const char* trigName =  trig_iter->first.c_str();
01057         h_L1AlgoNames->GetXaxis()->SetBinLabel(ibin+1,trigName);
01058         std::cout<<"===============> "<<ibin+1<<" "<<trigName<<" "<<(int)cont<< std::endl;
01059       }
01060     }
01061   }
01062 }
01063 
01064 //===========================================================================================================
01065 
01066 
01067 //===========================================================================================================
01068 
01069 
01070 
01071 
01072 //---
01073 void IsolatedTracksNxN::clearTreeVectors() {
01074 
01075   t_PVx               ->clear();
01076   t_PVy               ->clear();
01077   t_PVz               ->clear();
01078   t_PVisValid         ->clear();
01079   t_PVndof            ->clear();
01080   t_PVNTracks         ->clear();
01081   t_PVNTracksWt       ->clear();
01082   t_PVTracksSumPt     ->clear();
01083   t_PVTracksSumPtWt   ->clear();
01084   t_PVNTracksHP       ->clear();
01085   t_PVNTracksHPWt     ->clear();
01086   t_PVTracksSumPtHP   ->clear();
01087   t_PVTracksSumPtHPWt ->clear();
01088 
01089   t_L1Decision        ->clear();
01090   t_L1CenJetPt        ->clear();
01091   t_L1CenJetEta       ->clear();    
01092   t_L1CenJetPhi       ->clear();
01093   t_L1FwdJetPt        ->clear();
01094   t_L1FwdJetEta       ->clear();
01095   t_L1FwdJetPhi       ->clear();
01096   t_L1TauJetPt        ->clear();
01097   t_L1TauJetEta       ->clear();     
01098   t_L1TauJetPhi       ->clear();
01099   t_L1MuonPt          ->clear();
01100   t_L1MuonEta         ->clear();     
01101   t_L1MuonPhi         ->clear();
01102   t_L1IsoEMPt         ->clear();
01103   t_L1IsoEMEta        ->clear();
01104   t_L1IsoEMPhi        ->clear();
01105   t_L1NonIsoEMPt      ->clear();
01106   t_L1NonIsoEMEta     ->clear();
01107   t_L1NonIsoEMPhi     ->clear();
01108   t_L1METPt           ->clear();
01109   t_L1METEta          ->clear();
01110   t_L1METPhi          ->clear();
01111 
01112   t_jetPt             ->clear();
01113   t_jetEta            ->clear();
01114   t_jetPhi            ->clear();
01115   t_nTrksJetCalo      ->clear();  
01116   t_nTrksJetVtx       ->clear();
01117 
01118   t_trackPAll         ->clear();
01119   t_trackEtaAll       ->clear();
01120   t_trackPhiAll       ->clear();
01121   t_trackPdgIdAll     ->clear();
01122   t_trackPtAll        ->clear();
01123   t_trackDxyAll       ->clear();
01124   t_trackDzAll        ->clear();
01125   t_trackDxyPVAll     ->clear();
01126   t_trackDzPVAll      ->clear();
01127   t_trackChiSqAll     ->clear();
01128 
01129   t_trackP            ->clear();
01130   t_trackPt           ->clear();
01131   t_trackEta          ->clear();
01132   t_trackPhi          ->clear();
01133   t_trackEcalEta      ->clear();
01134   t_trackEcalPhi      ->clear();
01135   t_trackHcalEta      ->clear();
01136   t_trackHcalPhi      ->clear();
01137   t_NLayersCrossed    ->clear();
01138   t_trackNOuterHits   ->clear();
01139   t_trackDxy          ->clear();
01140   t_trackDxyBS        ->clear();
01141   t_trackDz           ->clear();
01142   t_trackDzBS         ->clear();
01143   t_trackDxyPV        ->clear();
01144   t_trackDzPV         ->clear();
01145   t_trackChiSq        ->clear();
01146   t_trackPVIdx        ->clear();
01147   t_trackHitsTOB          ->clear(); 
01148   t_trackHitsTEC          ->clear();
01149   t_trackHitInMissTOB     ->clear(); 
01150   t_trackHitInMissTEC     ->clear();  
01151   t_trackHitInMissTIB     ->clear();  
01152   t_trackHitInMissTID     ->clear();
01153   t_trackHitInMissTIBTID  ->clear();  
01154   t_trackHitOutMissTOB    ->clear();
01155   t_trackHitOutMissTEC    ->clear(); 
01156   t_trackHitOutMissTIB    ->clear();
01157   t_trackHitOutMissTID    ->clear(); 
01158   t_trackHitOutMissTOBTEC ->clear();
01159 
01160   t_trackHitInMeasTOB     ->clear(); 
01161   t_trackHitInMeasTEC     ->clear();  
01162   t_trackHitInMeasTIB     ->clear();  
01163   t_trackHitInMeasTID     ->clear();
01164   t_trackHitOutMeasTOB    ->clear();
01165   t_trackHitOutMeasTEC    ->clear(); 
01166   t_trackHitOutMeasTIB    ->clear();
01167   t_trackHitOutMeasTID    ->clear();
01168   t_trackOutPosOutHitDr   ->clear();
01169   t_trackL                ->clear();
01170 
01171   t_maxNearP31x31     ->clear();
01172   t_maxNearP25x25     ->clear();
01173   t_maxNearP21x21     ->clear();
01174   t_maxNearP15x15     ->clear();
01175   t_maxNearP13x13     ->clear();
01176   t_maxNearP11x11     ->clear();
01177   t_maxNearP9x9       ->clear();
01178   t_maxNearP7x7       ->clear();
01179 
01180   t_ecalSpike11x11    ->clear();
01181   t_e3x3              ->clear();
01182   t_e5x5              ->clear();
01183   t_e7x7              ->clear();
01184   t_e9x9              ->clear();
01185   t_e11x11            ->clear();
01186   t_e13x13            ->clear();
01187   t_e15x15            ->clear();
01188   t_e21x21            ->clear();
01189   t_e25x25            ->clear();
01190   t_e31x31            ->clear();
01191   //  t_e11x11Xtals       ->clear();
01192 
01193   t_e7x7_10Sig        ->clear();
01194   t_e9x9_10Sig        ->clear();
01195   t_e11x11_10Sig      ->clear();
01196   t_e15x15_10Sig      ->clear();
01197   t_e7x7_15Sig        ->clear();
01198   t_e9x9_15Sig        ->clear();
01199   t_e11x11_15Sig      ->clear();
01200   t_e15x15_15Sig      ->clear();
01201   t_e7x7_20Sig        ->clear();
01202   t_e9x9_20Sig        ->clear();
01203   t_e11x11_20Sig      ->clear();
01204   t_e15x15_20Sig      ->clear();
01205   t_e7x7_25Sig        ->clear();
01206   t_e9x9_25Sig        ->clear();
01207   t_e11x11_25Sig      ->clear();
01208   t_e15x15_25Sig      ->clear();
01209   t_e7x7_30Sig        ->clear();
01210   t_e9x9_30Sig        ->clear();
01211   t_e11x11_30Sig      ->clear();
01212   t_e15x15_30Sig      ->clear();
01213 
01214   if (doMC) {
01215     t_simTrackP         ->clear();
01216     t_esimPdgId         ->clear();
01217     t_trkEcalEne        ->clear();
01218 
01219     t_esim3x3           ->clear();
01220     t_esim5x5           ->clear();
01221     t_esim7x7           ->clear();
01222     t_esim9x9           ->clear();
01223     t_esim11x11         ->clear();
01224     t_esim13x13         ->clear();
01225     t_esim15x15         ->clear();
01226     t_esim21x21         ->clear();
01227     t_esim25x25         ->clear();
01228     t_esim31x31         ->clear();
01229   
01230     t_esim3x3Matched    ->clear();
01231     t_esim5x5Matched    ->clear();
01232     t_esim7x7Matched    ->clear();
01233     t_esim9x9Matched    ->clear();
01234     t_esim11x11Matched  ->clear();
01235     t_esim13x13Matched  ->clear();
01236     t_esim15x15Matched  ->clear();
01237     t_esim21x21Matched  ->clear();
01238     t_esim25x25Matched  ->clear();
01239     t_esim31x31Matched  ->clear();
01240 
01241     t_esim3x3Rest       ->clear();
01242     t_esim5x5Rest       ->clear();
01243     t_esim7x7Rest       ->clear();
01244     t_esim9x9Rest       ->clear();
01245     t_esim11x11Rest     ->clear();
01246     t_esim13x13Rest     ->clear();
01247     t_esim15x15Rest     ->clear();
01248     t_esim21x21Rest     ->clear();
01249     t_esim25x25Rest     ->clear();
01250     t_esim31x31Rest     ->clear();
01251 
01252     t_esim3x3Photon     ->clear();
01253     t_esim5x5Photon     ->clear();
01254     t_esim7x7Photon     ->clear();
01255     t_esim9x9Photon     ->clear();
01256     t_esim11x11Photon   ->clear();
01257     t_esim13x13Photon   ->clear();
01258     t_esim15x15Photon   ->clear();
01259     t_esim21x21Photon   ->clear();
01260     t_esim25x25Photon   ->clear();
01261     t_esim31x31Photon   ->clear();
01262 
01263     t_esim3x3NeutHad    ->clear();
01264     t_esim5x5NeutHad    ->clear();
01265     t_esim7x7NeutHad    ->clear();
01266     t_esim9x9NeutHad    ->clear();
01267     t_esim11x11NeutHad  ->clear();
01268     t_esim13x13NeutHad  ->clear();
01269     t_esim15x15NeutHad  ->clear();
01270     t_esim21x21NeutHad  ->clear();
01271     t_esim25x25NeutHad  ->clear();
01272     t_esim31x31NeutHad  ->clear();
01273 
01274     t_esim3x3CharHad    ->clear();
01275     t_esim5x5CharHad    ->clear();
01276     t_esim7x7CharHad    ->clear();
01277     t_esim9x9CharHad    ->clear();
01278     t_esim11x11CharHad  ->clear();
01279     t_esim13x13CharHad  ->clear();
01280     t_esim15x15CharHad  ->clear();
01281     t_esim21x21CharHad  ->clear();
01282     t_esim25x25CharHad  ->clear();
01283     t_esim31x31CharHad  ->clear();
01284   }
01285 
01286   t_maxNearHcalP3x3   ->clear();
01287   t_maxNearHcalP5x5   ->clear();
01288   t_maxNearHcalP7x7   ->clear();
01289 
01290   t_h3x3              ->clear();
01291   t_h5x5              ->clear();
01292   t_h7x7              ->clear();
01293   t_h3x3Sig           ->clear();
01294   t_h5x5Sig           ->clear();
01295   t_h7x7Sig           ->clear();
01296 
01297   t_infoHcal          ->clear();
01298 
01299   if (doMC) {
01300     t_trkHcalEne        ->clear();
01301 
01302     t_hsim3x3           ->clear();
01303     t_hsim5x5           ->clear();
01304     t_hsim7x7           ->clear();
01305     t_hsim3x3Matched    ->clear();
01306     t_hsim5x5Matched    ->clear();
01307     t_hsim7x7Matched    ->clear();
01308     t_hsim3x3Rest       ->clear();
01309     t_hsim5x5Rest       ->clear();
01310     t_hsim7x7Rest       ->clear();
01311     t_hsim3x3Photon     ->clear();
01312     t_hsim5x5Photon     ->clear();
01313     t_hsim7x7Photon     ->clear();
01314     t_hsim3x3NeutHad    ->clear();
01315     t_hsim5x5NeutHad    ->clear();
01316     t_hsim7x7NeutHad    ->clear();
01317     t_hsim3x3CharHad    ->clear();
01318     t_hsim5x5CharHad    ->clear();
01319     t_hsim7x7CharHad    ->clear();
01320   }
01321 }
01322 
01323 void IsolatedTracksNxN::BookHistograms(){
01324 
01325   char hname[100], htit[100];
01326 
01327   TFileDirectory dir = fs->mkdir("nearMaxTrackP");
01328 
01329   for(unsigned int ieta=0; ieta<NEtaBins; ieta++) {
01330     double lowEta=-5.0, highEta= 5.0;
01331     lowEta  = genPartEtaBins[ieta];
01332     highEta = genPartEtaBins[ieta+1];
01333 
01334     for(unsigned int ipt=0; ipt<NPBins; ipt++) {
01335       double lowP=0.0, highP=300.0;
01336       lowP    = genPartPBins[ipt];
01337       highP   = genPartPBins[ipt+1];
01338       sprintf(hname, "h_maxNearP31x31_ptBin%i_etaBin%i",ipt, ieta);
01339       sprintf(htit,  "maxNearP in 31x31 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
01340       h_maxNearP31x31[ipt][ieta] = dir.make<TH1F>(hname, htit, 220, -2.0, 20.0);
01341       h_maxNearP31x31[ipt][ieta] ->Sumw2();
01342       sprintf(hname, "h_maxNearP25x25_ptBin%i_etaBin%i",ipt, ieta);
01343       sprintf(htit,  "maxNearP in 25x25 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
01344       h_maxNearP25x25[ipt][ieta] = dir.make<TH1F>(hname, htit, 220, -2.0, 20.0);
01345       h_maxNearP25x25[ipt][ieta] ->Sumw2();
01346       sprintf(hname, "h_maxNearP21x21_ptBin%i_etaBin%i",ipt, ieta);
01347       sprintf(htit,  "maxNearP in 21x21 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
01348       h_maxNearP21x21[ipt][ieta] = dir.make<TH1F>(hname, htit, 220, -2.0, 20.0);
01349       h_maxNearP21x21[ipt][ieta] ->Sumw2();
01350       sprintf(hname, "h_maxNearP15x15_ptBin%i_etaBin%i",ipt, ieta);
01351       sprintf(htit,  "maxNearP in 15x15 (%3.2f<|#eta|<%3.2f), (%2.0f<trkP<%3.0f)", lowEta, highEta, lowP, highP );
01352       h_maxNearP15x15[ipt][ieta] = dir.make<TH1F>(hname, htit, 220, -2.0, 20.0);
01353       h_maxNearP15x15[ipt][ieta] ->Sumw2();
01354      }
01355   }
01356 
01357   h_L1AlgoNames = fs->make<TH1I>("h_L1AlgoNames", "h_L1AlgoNames:Bin Labels", 128, -0.5, 127.5);  
01358 
01359   // Reconstructed Tracks
01360 
01361   h_PVTracksWt = fs->make<TH1F>("h_PVTracksWt", "h_PVTracksWt", 600, -0.1, 1.1);
01362 
01363   h_nTracks = fs->make<TH1F>("h_nTracks", "h_nTracks", 1000, -0.5, 999.5);
01364 
01365   sprintf(hname, "h_recEtaPt_0");
01366   sprintf(htit,  "h_recEtaPt (all tracks Eta vs pT)");
01367   h_recEtaPt_0 = fs->make<TH2F>(hname, htit, 30, -3.0,3.0, 15, genPartPBins);
01368 
01369   sprintf(hname, "h_recEtaP_0");
01370   sprintf(htit,  "h_recEtaP (all tracks Eta vs pT)");
01371   h_recEtaP_0 = fs->make<TH2F>(hname, htit, 30, -3.0,3.0, 15, genPartPBins);
01372 
01373   h_recPt_0  = fs->make<TH1F>("h_recPt_0",  "Pt (all tracks)",  15, genPartPBins);
01374   h_recP_0   = fs->make<TH1F>("h_recP_0",   "P  (all tracks)",  15, genPartPBins);
01375   h_recEta_0 = fs->make<TH1F>("h_recEta_0", "Eta (all tracks)", 60, -3.0,   3.0);
01376   h_recPhi_0 = fs->make<TH1F>("h_recPhi_0", "Phi (all tracks)", 100, -3.2,   3.2);
01377   //-------------------------
01378   sprintf(hname, "h_recEtaPt_1");
01379   sprintf(htit,  "h_recEtaPt (all good tracks Eta vs pT)");
01380   h_recEtaPt_1 = fs->make<TH2F>(hname, htit, 30, -3.0,3.0, 15, genPartPBins);
01381 
01382   sprintf(hname, "h_recEtaP_1");
01383   sprintf(htit,  "h_recEtaP (all good tracks Eta vs pT)");
01384   h_recEtaP_1 = fs->make<TH2F>(hname, htit, 30, -3.0, 3.0, 15, genPartPBins);
01385 
01386   h_recPt_1  = fs->make<TH1F>("h_recPt_1",  "Pt (all good tracks)",  15, genPartPBins);
01387   h_recP_1   = fs->make<TH1F>("h_recP_1",   "P  (all good tracks)",  15, genPartPBins);
01388   h_recEta_1 = fs->make<TH1F>("h_recEta_1", "Eta (all good tracks)", 60, -3.0,   3.0);
01389   h_recPhi_1 = fs->make<TH1F>("h_recPhi_1", "Phi (all good tracks)", 100, -3.2,   3.2);
01390   //-------------------------
01391   sprintf(hname, "h_recEtaPt_2");
01392   sprintf(htit,  "h_recEtaPt (charge isolation Eta vs pT)");
01393   h_recEtaPt_2 = fs->make<TH2F>(hname, htit, 30, -3.0, 3.0, 15, genPartPBins);
01394 
01395   sprintf(hname, "h_recEtaP_2");
01396   sprintf(htit,  "h_recEtaP (charge isolation Eta vs pT)");
01397   h_recEtaP_2 = fs->make<TH2F>(hname, htit, 30, -3.0, 3.0, 15, genPartPBins);
01398   
01399   h_recPt_2  = fs->make<TH1F>("h_recPt_2",  "Pt (charge isolation)",  15, genPartPBins);
01400   h_recP_2   = fs->make<TH1F>("h_recP_2",   "P  (charge isolation)",  15, genPartPBins);
01401   h_recEta_2 = fs->make<TH1F>("h_recEta_2", "Eta (charge isolation)", 60, -3.0,   3.0);
01402   h_recPhi_2 = fs->make<TH1F>("h_recPhi_2", "Phi (charge isolation)", 100, -3.2,   3.2);
01403 
01404 
01405   tree = fs->make<TTree>("tree", "tree");
01406   tree->SetAutoSave(10000);
01407 
01408 
01409   tree->Branch("t_EvtNo"              ,&t_EvtNo               ,"t_EvtNo/I");
01410   tree->Branch("t_RunNo"              ,&t_RunNo               ,"t_RunNo/I");
01411   tree->Branch("t_Lumi"               ,&t_Lumi                ,"t_Lumi/I");
01412   tree->Branch("t_Bunch"              ,&t_Bunch               ,"t_Bunch/I");
01413 
01414 
01415   t_PVx               = new std::vector<double>();
01416   t_PVy               = new std::vector<double>();
01417   t_PVz               = new std::vector<double>();
01418   t_PVisValid         = new std::vector<double>();
01419   t_PVndof            = new std::vector<double>(); 
01420   t_PVNTracks         = new std::vector<double>();
01421   t_PVNTracksWt       = new std::vector<double>();
01422   t_PVTracksSumPt     = new std::vector<double>();
01423   t_PVTracksSumPtWt   = new std::vector<double>();
01424   t_PVNTracksHP       = new std::vector<double>();
01425   t_PVNTracksHPWt     = new std::vector<double>();
01426   t_PVTracksSumPtHP   = new std::vector<double>();
01427   t_PVTracksSumPtHPWt = new std::vector<double>();
01428 
01429   tree->Branch("PVx"                  ,"vector<double>"      ,&t_PVx);
01430   tree->Branch("PVy"                  ,"vector<double>"      ,&t_PVy);
01431   tree->Branch("PVz"                  ,"vector<double>"      ,&t_PVz);
01432   tree->Branch("PVisValid"            ,"vector<double>"      ,&t_PVisValid);
01433   tree->Branch("PVndof"               ,"vector<double>"      ,&t_PVndof);
01434   tree->Branch("PVNTracks"            ,"vector<double>"      ,&t_PVNTracks);
01435   tree->Branch("PVNTracksWt"          ,"vector<double>"      ,&t_PVNTracksWt);
01436   tree->Branch("t_PVTracksSumPt"      ,"vector<double>"      ,&t_PVTracksSumPt);
01437   tree->Branch("t_PVTracksSumPtWt"    ,"vector<double>"      ,&t_PVTracksSumPtWt);
01438   tree->Branch("PVNTracksHP"          ,"vector<double>"      ,&t_PVNTracksHP);
01439   tree->Branch("PVNTracksHPWt"        ,"vector<double>"      ,&t_PVNTracksHPWt);
01440   tree->Branch("t_PVTracksSumPtHP"    ,"vector<double>"      ,&t_PVTracksSumPtHP);
01441   tree->Branch("t_PVTracksSumPtHPWt"  ,"vector<double>"      ,&t_PVTracksSumPtHPWt);
01442 
01443   //----- L1Trigger information
01444   t_L1Decision        = new std::vector<int>();
01445   t_L1CenJetPt        = new std::vector<double>();
01446   t_L1CenJetEta       = new std::vector<double>();    
01447   t_L1CenJetPhi       = new std::vector<double>();
01448   t_L1FwdJetPt        = new std::vector<double>();
01449   t_L1FwdJetEta       = new std::vector<double>();
01450   t_L1FwdJetPhi       = new std::vector<double>();
01451   t_L1TauJetPt        = new std::vector<double>();
01452   t_L1TauJetEta       = new std::vector<double>();     
01453   t_L1TauJetPhi       = new std::vector<double>();
01454   t_L1MuonPt          = new std::vector<double>();
01455   t_L1MuonEta         = new std::vector<double>();     
01456   t_L1MuonPhi         = new std::vector<double>();
01457   t_L1IsoEMPt         = new std::vector<double>();
01458   t_L1IsoEMEta        = new std::vector<double>();
01459   t_L1IsoEMPhi        = new std::vector<double>();
01460   t_L1NonIsoEMPt      = new std::vector<double>();
01461   t_L1NonIsoEMEta     = new std::vector<double>();
01462   t_L1NonIsoEMPhi     = new std::vector<double>();
01463   t_L1METPt           = new std::vector<double>();
01464   t_L1METEta          = new std::vector<double>();
01465   t_L1METPhi          = new std::vector<double>();
01466   
01467   tree->Branch("t_L1Decision",        "vector<int>",    &t_L1Decision);
01468   tree->Branch("t_L1CenJetPt",        "vector<double>", &t_L1CenJetPt);
01469   tree->Branch("t_L1CenJetEta",       "vector<double>", &t_L1CenJetEta);
01470   tree->Branch("t_L1CenJetPhi",       "vector<double>", &t_L1CenJetPhi);
01471   tree->Branch("t_L1FwdJetPt",        "vector<double>", &t_L1FwdJetPt);
01472   tree->Branch("t_L1FwdJetEta",       "vector<double>", &t_L1FwdJetEta);
01473   tree->Branch("t_L1FwdJetPhi",       "vector<double>", &t_L1FwdJetPhi);
01474   tree->Branch("t_L1TauJetPt",        "vector<double>", &t_L1TauJetPt);
01475   tree->Branch("t_L1TauJetEta",       "vector<double>", &t_L1TauJetEta);     
01476   tree->Branch("t_L1TauJetPhi",       "vector<double>", &t_L1TauJetPhi);
01477   tree->Branch("t_L1MuonPt",          "vector<double>", &t_L1MuonPt);
01478   tree->Branch("t_L1MuonEta",         "vector<double>", &t_L1MuonEta);
01479   tree->Branch("t_L1MuonPhi",         "vector<double>", &t_L1MuonPhi);
01480   tree->Branch("t_L1IsoEMPt",         "vector<double>", &t_L1IsoEMPt);
01481   tree->Branch("t_L1IsoEMEta",        "vector<double>", &t_L1IsoEMEta);
01482   tree->Branch("t_L1IsoEMPhi",        "vector<double>", &t_L1IsoEMPhi);
01483   tree->Branch("t_L1NonIsoEMPt",      "vector<double>", &t_L1NonIsoEMPt);
01484   tree->Branch("t_L1NonIsoEMEta",     "vector<double>", &t_L1NonIsoEMEta);
01485   tree->Branch("t_L1NonIsoEMPhi",     "vector<double>", &t_L1NonIsoEMPhi);
01486   tree->Branch("t_L1METPt",           "vector<double>", &t_L1METPt);
01487   tree->Branch("t_L1METEta",          "vector<double>", &t_L1METEta);
01488   tree->Branch("t_L1METPhi",          "vector<double>", &t_L1METPhi);
01489 
01490   t_jetPt            = new std::vector<double>();
01491   t_jetEta           = new std::vector<double>();
01492   t_jetPhi           = new std::vector<double>();
01493   t_nTrksJetCalo     = new std::vector<double>();  
01494   t_nTrksJetVtx      = new std::vector<double>();
01495   tree->Branch("t_jetPt",             "vector<double>",&t_jetPt);
01496   tree->Branch("t_jetEta",            "vector<double>",&t_jetEta);
01497   tree->Branch("t_jetPhi",            "vector<double>",&t_jetPhi);
01498   tree->Branch("t_nTrksJetCalo",      "vector<double>",&t_nTrksJetCalo);  
01499   tree->Branch("t_nTrksJetVtx",       "vector<double>",&t_nTrksJetVtx);
01500 
01501   t_trackPAll        = new std::vector<double>();
01502   t_trackEtaAll      = new std::vector<double>();
01503   t_trackPhiAll      = new std::vector<double>();
01504   t_trackPdgIdAll    = new std::vector<double>();
01505   t_trackPtAll       = new std::vector<double>();
01506   t_trackDxyAll      = new std::vector<double>();
01507   t_trackDzAll       = new std::vector<double>();
01508   t_trackDxyPVAll    = new std::vector<double>();
01509   t_trackDzPVAll     = new std::vector<double>();
01510   t_trackChiSqAll    = new std::vector<double>();
01511   tree->Branch("t_trackPAll",         "vector<double>", &t_trackPAll    );
01512   tree->Branch("t_trackPhiAll",       "vector<double>", &t_trackPhiAll  );
01513   tree->Branch("t_trackEtaAll",       "vector<double>", &t_trackEtaAll  );
01514   tree->Branch("t_trackPtAll",        "vector<double>", &t_trackPtAll    );
01515   tree->Branch("t_trackDxyAll",       "vector<double>", &t_trackDxyAll    );
01516   tree->Branch("t_trackDzAll",        "vector<double>", &t_trackDzAll    );
01517   tree->Branch("t_trackDxyPVAll",     "vector<double>", &t_trackDxyPVAll    );
01518   tree->Branch("t_trackDzPVAll",      "vector<double>", &t_trackDzPVAll    );
01519   tree->Branch("t_trackChiSqAll",     "vector<double>", &t_trackChiSqAll    );
01520   //tree->Branch("t_trackPdgIdAll",     "vector<double>", &t_trackPdgIdAll);
01521 
01522   t_trackP              = new std::vector<double>();
01523   t_trackPt             = new std::vector<double>();
01524   t_trackEta            = new std::vector<double>();
01525   t_trackPhi            = new std::vector<double>();
01526   t_trackEcalEta        = new std::vector<double>();
01527   t_trackEcalPhi        = new std::vector<double>();
01528   t_trackHcalEta        = new std::vector<double>();
01529   t_trackHcalPhi        = new std::vector<double>();
01530   t_trackNOuterHits     = new std::vector<int>();
01531   t_NLayersCrossed      = new std::vector<int>();
01532   t_trackDxy            = new std::vector<double>();
01533   t_trackDxyBS          = new std::vector<double>();
01534   t_trackDz             = new std::vector<double>();
01535   t_trackDzBS           = new std::vector<double>();
01536   t_trackDxyPV          = new std::vector<double>();
01537   t_trackDzPV           = new std::vector<double>();
01538   t_trackPVIdx          = new std::vector<int>();
01539   t_trackChiSq          = new std::vector<double>();
01540   t_trackHitsTOB        = new std::vector<int>(); 
01541   t_trackHitsTEC        = new std::vector<int>();
01542   t_trackHitInMissTOB   = new std::vector<int>(); 
01543   t_trackHitInMissTEC   = new std::vector<int>();  
01544   t_trackHitInMissTIB   = new std::vector<int>();  
01545   t_trackHitInMissTID   = new std::vector<int>();
01546   t_trackHitInMissTIBTID= new std::vector<int>();  
01547 
01548   t_trackHitOutMissTOB   = new std::vector<int>();
01549   t_trackHitOutMissTEC   = new std::vector<int>(); 
01550   t_trackHitOutMissTIB   = new std::vector<int>();
01551   t_trackHitOutMissTID   = new std::vector<int>();
01552   t_trackHitOutMissTOBTEC= new std::vector<int>();
01553   t_trackHitInMeasTOB    = new std::vector<int>(); 
01554   t_trackHitInMeasTEC    = new std::vector<int>();  
01555   t_trackHitInMeasTIB    = new std::vector<int>();  
01556   t_trackHitInMeasTID    = new std::vector<int>();
01557   t_trackHitOutMeasTOB   = new std::vector<int>();
01558   t_trackHitOutMeasTEC   = new std::vector<int>(); 
01559   t_trackHitOutMeasTIB   = new std::vector<int>();
01560   t_trackHitOutMeasTID   = new std::vector<int>();
01561   t_trackOutPosOutHitDr  =new std::vector<double>();
01562   t_trackL               =new std::vector<double>();
01563 
01564   tree->Branch("t_trackP",            "vector<double>", &t_trackP            );
01565   tree->Branch("t_trackPt",           "vector<double>", &t_trackPt           );
01566   tree->Branch("t_trackEta",          "vector<double>", &t_trackEta          );
01567   tree->Branch("t_trackPhi",          "vector<double>", &t_trackPhi          );
01568   tree->Branch("t_trackEcalEta",      "vector<double>", &t_trackEcalEta      );
01569   tree->Branch("t_trackEcalPhi",      "vector<double>", &t_trackEcalPhi      );
01570   tree->Branch("t_trackHcalEta",      "vector<double>", &t_trackHcalEta      );
01571   tree->Branch("t_trackHcalPhi",      "vector<double>", &t_trackHcalPhi      );
01572 
01573   tree->Branch("t_trackNOuterHits",      "vector<int>",    &t_trackNOuterHits   );
01574   tree->Branch("t_NLayersCrossed",       "vector<int>",    &t_NLayersCrossed    );
01575   tree->Branch("t_trackHitsTOB",         "vector<int>",   &t_trackHitsTOB      ); 
01576   tree->Branch("t_trackHitsTEC",         "vector<int>",   &t_trackHitsTEC      );
01577   tree->Branch("t_trackHitInMissTOB",    "vector<int>",   &t_trackHitInMissTOB ); 
01578   tree->Branch("t_trackHitInMissTEC",    "vector<int>",   &t_trackHitInMissTEC );  
01579   tree->Branch("t_trackHitInMissTIB",    "vector<int>",   &t_trackHitInMissTIB );  
01580   tree->Branch("t_trackHitInMissTID",    "vector<int>",   &t_trackHitInMissTID );
01581   tree->Branch("t_trackHitInMissTIBTID", "vector<int>",   &t_trackHitInMissTIBTID );  
01582   tree->Branch("t_trackHitOutMissTOB",   "vector<int>",   &t_trackHitOutMissTOB);
01583   tree->Branch("t_trackHitOutMissTEC",   "vector<int>",   &t_trackHitOutMissTEC); 
01584   tree->Branch("t_trackHitOutMissTIB",   "vector<int>",   &t_trackHitOutMissTIB);
01585   tree->Branch("t_trackHitOutMissTID",   "vector<int>",   &t_trackHitOutMissTID);
01586   tree->Branch("t_trackHitOutMissTOBTEC","vector<int>",   &t_trackHitOutMissTOBTEC);
01587   tree->Branch("t_trackHitInMeasTOB",    "vector<int>",   &t_trackHitInMeasTOB ); 
01588   tree->Branch("t_trackHitInMeasTEC",    "vector<int>",   &t_trackHitInMeasTEC );  
01589   tree->Branch("t_trackHitInMeasTIB",    "vector<int>",   &t_trackHitInMeasTIB );  
01590   tree->Branch("t_trackHitInMeasTID",    "vector<int>",   &t_trackHitInMeasTID );
01591   tree->Branch("t_trackHitOutMeasTOB",   "vector<int>",   &t_trackHitOutMeasTOB);
01592   tree->Branch("t_trackHitOutMeasTEC",   "vector<int>",   &t_trackHitOutMeasTEC); 
01593   tree->Branch("t_trackHitOutMeasTIB",   "vector<int>",   &t_trackHitOutMeasTIB);
01594   tree->Branch("t_trackHitOutMeasTID",   "vector<int>",   &t_trackHitOutMeasTID);
01595   tree->Branch("t_trackOutPosOutHitDr",  "vector<double>", &t_trackOutPosOutHitDr);
01596   tree->Branch("t_trackL",               "vector<double>", &t_trackL);
01597 
01598   tree->Branch("t_trackDxy",          "vector<double>", &t_trackDxy     );
01599   tree->Branch("t_trackDxyBS",        "vector<double>", &t_trackDxyBS   );
01600   tree->Branch("t_trackDz",           "vector<double>", &t_trackDz      );
01601   tree->Branch("t_trackDzBS",         "vector<double>", &t_trackDzBS    );
01602   tree->Branch("t_trackDxyPV",        "vector<double>", &t_trackDxyPV   );
01603   tree->Branch("t_trackDzPV",         "vector<double>", &t_trackDzPV    );
01604   tree->Branch("t_trackChiSq",        "vector<double>", &t_trackChiSq   );
01605   tree->Branch("t_trackPVIdx",        "vector<int>",    &t_trackPVIdx   );
01606 
01607   t_maxNearP31x31     = new std::vector<double>();
01608   t_maxNearP25x25     = new std::vector<double>();
01609   t_maxNearP21x21     = new std::vector<double>();
01610   t_maxNearP15x15     = new std::vector<double>();
01611   t_maxNearP13x13     = new std::vector<double>();
01612   t_maxNearP11x11     = new std::vector<double>();
01613   t_maxNearP9x9       = new std::vector<double>();
01614   t_maxNearP7x7       = new std::vector<double>();
01615 
01616   tree->Branch("t_maxNearP31x31",     "vector<double>", &t_maxNearP31x31);
01617   //tree->Branch("t_maxNearP25x25",     "vector<double>", &t_maxNearP25x25);
01618   tree->Branch("t_maxNearP21x21",     "vector<double>", &t_maxNearP21x21);
01619   //tree->Branch("t_maxNearP15x15",     "vector<double>", &t_maxNearP15x15);
01620   //tree->Branch("t_maxNearP13x13",     "vector<double>", &t_maxNearP13x13);
01621   //tree->Branch("t_maxNearP11x11",     "vector<double>", &t_maxNearP11x11);
01622   //tree->Branch("t_maxNearP9x9",       "vector<double>", &t_maxNearP9x9);
01623   //tree->Branch("t_maxNearP7x7",       "vector<double>", &t_maxNearP7x7);
01624 
01625   t_ecalSpike11x11    = new std::vector<int>();
01626   t_e3x3              = new std::vector<double>();
01627   t_e5x5              = new std::vector<double>();
01628   t_e7x7              = new std::vector<double>();
01629   t_e9x9              = new std::vector<double>();
01630   t_e11x11            = new std::vector<double>();
01631   t_e13x13            = new std::vector<double>();
01632   t_e15x15            = new std::vector<double>();
01633   t_e21x21            = new std::vector<double>();
01634   t_e25x25            = new std::vector<double>();
01635   t_e31x31            = new std::vector<double>();
01636   //t_e11x11Xtals       = new std::vector<std::vector<double> >(); 
01637 
01638   tree->Branch("t_ecalSpike11x11",    "vector<int>",    &t_ecalSpike11x11);
01639   //tree->Branch("t_e3x3",              "vector<double>", &t_e3x3);
01640   //tree->Branch("t_e5x5",              "vector<double>", &t_e5x5);
01641   tree->Branch("t_e7x7",              "vector<double>", &t_e7x7);
01642   tree->Branch("t_e9x9",              "vector<double>", &t_e9x9);
01643   tree->Branch("t_e11x11",            "vector<double>", &t_e11x11);
01644   //tree->Branch("t_e13x13",            "vector<double>", &t_e13x13);
01645   tree->Branch("t_e15x15",            "vector<double>", &t_e15x15);
01646   //tree->Branch("t_e21x21",            "vector<double>", &t_e21x21);
01647   //tree->Branch("t_e25x25",            "vector<double>", &t_e25x25);
01648   //tree->Branch("t_e31x31",            "vector<double>", &t_e31x31);
01649   //tree->Branch("t_e11x11Xtals",       "vector<vector<double> >", &t_e11x11Xtals);
01650 
01651   t_e7x7_10Sig        = new std::vector<double>();
01652   t_e9x9_10Sig        = new std::vector<double>();
01653   t_e11x11_10Sig      = new std::vector<double>();
01654   t_e15x15_10Sig      = new std::vector<double>();
01655   t_e7x7_15Sig        = new std::vector<double>();
01656   t_e9x9_15Sig        = new std::vector<double>();
01657   t_e11x11_15Sig      = new std::vector<double>();
01658   t_e15x15_15Sig      = new std::vector<double>();
01659   t_e7x7_20Sig        = new std::vector<double>();
01660   t_e9x9_20Sig        = new std::vector<double>();
01661   t_e11x11_20Sig      = new std::vector<double>();
01662   t_e15x15_20Sig      = new std::vector<double>();
01663   t_e7x7_25Sig        = new std::vector<double>();
01664   t_e9x9_25Sig        = new std::vector<double>();
01665   t_e11x11_25Sig      = new std::vector<double>();
01666   t_e15x15_25Sig      = new std::vector<double>();
01667   t_e7x7_30Sig        = new std::vector<double>();
01668   t_e9x9_30Sig        = new std::vector<double>();
01669   t_e11x11_30Sig      = new std::vector<double>();
01670   t_e15x15_30Sig      = new std::vector<double>();
01671 
01672   tree->Branch("t_e7x7_10Sig"        ,"vector<double>", &t_e7x7_10Sig);
01673   tree->Branch("t_e9x9_10Sig"        ,"vector<double>", &t_e9x9_10Sig);
01674   tree->Branch("t_e11x11_10Sig"      ,"vector<double>", &t_e11x11_10Sig);
01675   tree->Branch("t_e15x15_10Sig"      ,"vector<double>", &t_e15x15_10Sig);
01676   tree->Branch("t_e7x7_15Sig"        ,"vector<double>", &t_e7x7_15Sig);
01677   tree->Branch("t_e9x9_15Sig"        ,"vector<double>", &t_e9x9_15Sig);
01678   tree->Branch("t_e11x11_15Sig"      ,"vector<double>", &t_e11x11_15Sig);
01679   tree->Branch("t_e15x15_15Sig"      ,"vector<double>", &t_e15x15_15Sig);
01680   tree->Branch("t_e7x7_20Sig"        ,"vector<double>", &t_e7x7_20Sig);
01681   tree->Branch("t_e9x9_20Sig"        ,"vector<double>", &t_e9x9_20Sig);
01682   tree->Branch("t_e11x11_20Sig"      ,"vector<double>", &t_e11x11_20Sig);
01683   tree->Branch("t_e15x15_20Sig"      ,"vector<double>", &t_e15x15_20Sig);
01684   tree->Branch("t_e7x7_25Sig"        ,"vector<double>", &t_e7x7_25Sig);
01685   tree->Branch("t_e9x9_25Sig"        ,"vector<double>", &t_e9x9_25Sig);
01686   tree->Branch("t_e11x11_25Sig"      ,"vector<double>", &t_e11x11_25Sig);
01687   tree->Branch("t_e15x15_25Sig"      ,"vector<double>", &t_e15x15_25Sig);
01688   tree->Branch("t_e7x7_30Sig"        ,"vector<double>", &t_e7x7_30Sig);
01689   tree->Branch("t_e9x9_30Sig"        ,"vector<double>", &t_e9x9_30Sig);
01690   tree->Branch("t_e11x11_30Sig"      ,"vector<double>", &t_e11x11_30Sig);
01691   tree->Branch("t_e15x15_30Sig"      ,"vector<double>", &t_e15x15_30Sig);
01692 
01693   if (doMC) {
01694     t_esim3x3              = new std::vector<double>();
01695     t_esim5x5              = new std::vector<double>();
01696     t_esim7x7              = new std::vector<double>();
01697     t_esim9x9              = new std::vector<double>();
01698     t_esim11x11            = new std::vector<double>();
01699     t_esim13x13            = new std::vector<double>();
01700     t_esim15x15            = new std::vector<double>();
01701     t_esim21x21            = new std::vector<double>();
01702     t_esim25x25            = new std::vector<double>();
01703     t_esim31x31            = new std::vector<double>();
01704 
01705     t_esim3x3Matched       = new std::vector<double>();
01706     t_esim5x5Matched       = new std::vector<double>();
01707     t_esim7x7Matched       = new std::vector<double>();
01708     t_esim9x9Matched       = new std::vector<double>();
01709     t_esim11x11Matched     = new std::vector<double>();
01710     t_esim13x13Matched     = new std::vector<double>();
01711     t_esim15x15Matched     = new std::vector<double>();
01712     t_esim21x21Matched     = new std::vector<double>();
01713     t_esim25x25Matched     = new std::vector<double>();
01714     t_esim31x31Matched     = new std::vector<double>();
01715 
01716     t_esim3x3Rest          = new std::vector<double>();
01717     t_esim5x5Rest          = new std::vector<double>();
01718     t_esim7x7Rest          = new std::vector<double>();
01719     t_esim9x9Rest          = new std::vector<double>();
01720     t_esim11x11Rest        = new std::vector<double>();
01721     t_esim13x13Rest        = new std::vector<double>();
01722     t_esim15x15Rest        = new std::vector<double>();
01723     t_esim21x21Rest        = new std::vector<double>();
01724     t_esim25x25Rest        = new std::vector<double>();
01725     t_esim31x31Rest        = new std::vector<double>();
01726 
01727     t_esim3x3Photon        = new std::vector<double>();
01728     t_esim5x5Photon        = new std::vector<double>();
01729     t_esim7x7Photon        = new std::vector<double>();
01730     t_esim9x9Photon        = new std::vector<double>();
01731     t_esim11x11Photon      = new std::vector<double>();
01732     t_esim13x13Photon      = new std::vector<double>();
01733     t_esim15x15Photon      = new std::vector<double>();
01734     t_esim21x21Photon      = new std::vector<double>();
01735     t_esim25x25Photon      = new std::vector<double>();
01736     t_esim31x31Photon      = new std::vector<double>();
01737 
01738     t_esim3x3NeutHad       = new std::vector<double>();
01739     t_esim5x5NeutHad       = new std::vector<double>();
01740     t_esim7x7NeutHad       = new std::vector<double>();
01741     t_esim9x9NeutHad       = new std::vector<double>();
01742     t_esim11x11NeutHad     = new std::vector<double>();
01743     t_esim13x13NeutHad     = new std::vector<double>();
01744     t_esim15x15NeutHad     = new std::vector<double>();
01745     t_esim21x21NeutHad     = new std::vector<double>();
01746     t_esim25x25NeutHad     = new std::vector<double>();
01747     t_esim31x31NeutHad     = new std::vector<double>();
01748 
01749     t_esim3x3CharHad       = new std::vector<double>();
01750     t_esim5x5CharHad       = new std::vector<double>();
01751     t_esim7x7CharHad       = new std::vector<double>();
01752     t_esim9x9CharHad       = new std::vector<double>();
01753     t_esim11x11CharHad     = new std::vector<double>();
01754     t_esim13x13CharHad     = new std::vector<double>();
01755     t_esim15x15CharHad     = new std::vector<double>();
01756     t_esim21x21CharHad     = new std::vector<double>();
01757     t_esim25x25CharHad     = new std::vector<double>();
01758     t_esim31x31CharHad     = new std::vector<double>();
01759 
01760     t_trkEcalEne           = new std::vector<double>();
01761     t_simTrackP            = new std::vector<double>();
01762     t_esimPdgId            = new std::vector<double>();
01763 
01764     //tree->Branch("t_esim3x3",             "vector<double>", &t_esim3x3);
01765     //tree->Branch("t_esim5x5",             "vector<double>", &t_esim5x5);
01766     tree->Branch("t_esim7x7",             "vector<double>", &t_esim7x7);
01767     tree->Branch("t_esim9x9",             "vector<double>", &t_esim9x9);
01768     tree->Branch("t_esim11x11",           "vector<double>", &t_esim11x11);
01769     //tree->Branch("t_esim13x13",           "vector<double>", &t_esim13x13);
01770     tree->Branch("t_esim15x15",           "vector<double>", &t_esim15x15);
01771     //tree->Branch("t_esim21x21",           "vector<double>", &t_esim21x21);
01772     //tree->Branch("t_esim25x25",           "vector<double>", &t_esim25x25);
01773     //tree->Branch("t_esim31x31",           "vector<double>", &t_esim31x31);
01774 
01775     //tree->Branch("t_esim3x3Matched",      "vector<double>", &t_esim3x3Matched);
01776     //tree->Branch("t_esim5x5Matched",      "vector<double>", &t_esim5x5Matched);
01777     tree->Branch("t_esim7x7Matched",      "vector<double>", &t_esim7x7Matched);
01778     tree->Branch("t_esim9x9Matched",      "vector<double>", &t_esim9x9Matched);
01779     tree->Branch("t_esim11x11Matched",    "vector<double>", &t_esim11x11Matched);
01780     //tree->Branch("t_esim13x13Matched",    "vector<double>", &t_esim13x13Matched);
01781     tree->Branch("t_esim15x15Matched",    "vector<double>", &t_esim15x15Matched);
01782     //tree->Branch("t_esim21x21Matched",    "vector<double>", &t_esim21x21Matched);
01783     //tree->Branch("t_esim25x25Matched",    "vector<double>", &t_esim25x25Matched);
01784     //tree->Branch("t_esim31x31Matched",    "vector<double>", &t_esim31x31Matched);
01785 
01786     //tree->Branch("t_esim3x3Rest",         "vector<double>", &t_esim3x3Rest);
01787     //tree->Branch("t_esim5x5Rest",         "vector<double>", &t_esim5x5Rest);
01788     tree->Branch("t_esim7x7Rest",         "vector<double>", &t_esim7x7Rest);
01789     tree->Branch("t_esim9x9Rest",         "vector<double>", &t_esim9x9Rest);
01790     tree->Branch("t_esim11x11Rest",       "vector<double>", &t_esim11x11Rest);
01791     //tree->Branch("t_esim13x13Rest",       "vector<double>", &t_esim13x13Rest);
01792     tree->Branch("t_esim15x15Rest",       "vector<double>", &t_esim15x15Rest);
01793     //tree->Branch("t_esim21x21Rest",       "vector<double>", &t_esim21x21Rest);
01794     //tree->Branch("t_esim25x25Rest",       "vector<double>", &t_esim25x25Rest);
01795     //tree->Branch("t_esim31x31Rest",       "vector<double>", &t_esim31x31Rest);
01796 
01797     //tree->Branch("t_esim3x3Photon",       "vector<double>", &t_esim3x3Photon);
01798     //tree->Branch("t_esim5x5Photon",       "vector<double>", &t_esim5x5Photon);
01799     tree->Branch("t_esim7x7Photon",       "vector<double>", &t_esim7x7Photon);
01800     tree->Branch("t_esim9x9Photon",       "vector<double>", &t_esim9x9Photon);
01801     tree->Branch("t_esim11x11Photon",     "vector<double>", &t_esim11x11Photon);
01802     //tree->Branch("t_esim13x13Photon",     "vector<double>", &t_esim13x13Photon);
01803     tree->Branch("t_esim15x15Photon",     "vector<double>", &t_esim15x15Photon);
01804     //tree->Branch("t_esim21x21Photon",     "vector<double>", &t_esim21x21Photon);
01805     //tree->Branch("t_esim25x25Photon",     "vector<double>", &t_esim25x25Photon);
01806     //tree->Branch("t_esim31x31Photon",     "vector<double>", &t_esim31x31Photon);
01807 
01808     //tree->Branch("t_esim3x3NeutHad",      "vector<double>", &t_esim3x3NeutHad);
01809     //tree->Branch("t_esim5x5NeutHad",      "vector<double>", &t_esim5x5NeutHad);
01810     tree->Branch("t_esim7x7NeutHad",      "vector<double>", &t_esim7x7NeutHad);
01811     tree->Branch("t_esim9x9NeutHad",      "vector<double>", &t_esim9x9NeutHad);
01812     tree->Branch("t_esim11x11NeutHad",    "vector<double>", &t_esim11x11NeutHad);
01813     //tree->Branch("t_esim13x13NeutHad",    "vector<double>", &t_esim13x13NeutHad);
01814     tree->Branch("t_esim15x15NeutHad",    "vector<double>", &t_esim15x15NeutHad);
01815     //tree->Branch("t_esim21x21NeutHad",    "vector<double>", &t_esim21x21NeutHad);
01816     //tree->Branch("t_esim25x25NeutHad",    "vector<double>", &t_esim25x25NeutHad);
01817     //tree->Branch("t_esim31x31NeutHad",    "vector<double>", &t_esim31x31NeutHad);
01818 
01819     //tree->Branch("t_esim3x3CharHad",      "vector<double>", &t_esim3x3CharHad);
01820     //tree->Branch("t_esim5x5CharHad",      "vector<double>", &t_esim5x5CharHad);
01821     tree->Branch("t_esim7x7CharHad",      "vector<double>", &t_esim7x7CharHad);
01822     tree->Branch("t_esim9x9CharHad",      "vector<double>", &t_esim9x9CharHad);
01823     tree->Branch("t_esim11x11CharHad",    "vector<double>", &t_esim11x11CharHad);
01824     //tree->Branch("t_esim13x13CharHad",    "vector<double>", &t_esim13x13CharHad);
01825     tree->Branch("t_esim15x15CharHad",    "vector<double>", &t_esim15x15CharHad);
01826     //tree->Branch("t_esim21x21CharHad",    "vector<double>", &t_esim21x21CharHad);
01827     //tree->Branch("t_esim25x25CharHad",    "vector<double>", &t_esim25x25CharHad);
01828     //tree->Branch("t_esim31x31CharHad",    "vector<double>", &t_esim31x31CharHad);
01829 
01830     tree->Branch("t_trkEcalEne",          "vector<double>", &t_trkEcalEne);
01831     tree->Branch("t_simTrackP",           "vector<double>", &t_simTrackP);
01832     tree->Branch("t_esimPdgId",           "vector<double>", &t_esimPdgId);
01833   }
01834 
01835   t_maxNearHcalP3x3      = new std::vector<double>();
01836   t_maxNearHcalP5x5      = new std::vector<double>();
01837   t_maxNearHcalP7x7      = new std::vector<double>();
01838   t_h3x3                 = new std::vector<double>();
01839   t_h5x5                 = new std::vector<double>();
01840   t_h7x7                 = new std::vector<double>();
01841   t_h3x3Sig              = new std::vector<double>();
01842   t_h5x5Sig              = new std::vector<double>();
01843   t_h7x7Sig              = new std::vector<double>();
01844   t_infoHcal             = new std::vector<int>();
01845 
01846   if (doMC) {
01847     t_trkHcalEne           = new std::vector<double>();
01848     t_hsim3x3              = new std::vector<double>();
01849     t_hsim5x5              = new std::vector<double>();
01850     t_hsim7x7              = new std::vector<double>();
01851     t_hsim3x3Matched       = new std::vector<double>();
01852     t_hsim5x5Matched       = new std::vector<double>();
01853     t_hsim7x7Matched       = new std::vector<double>();
01854     t_hsim3x3Rest          = new std::vector<double>();
01855     t_hsim5x5Rest          = new std::vector<double>();
01856     t_hsim7x7Rest          = new std::vector<double>();
01857     t_hsim3x3Photon        = new std::vector<double>();
01858     t_hsim5x5Photon        = new std::vector<double>();
01859     t_hsim7x7Photon        = new std::vector<double>();
01860     t_hsim3x3NeutHad       = new std::vector<double>();
01861     t_hsim5x5NeutHad       = new std::vector<double>();
01862     t_hsim7x7NeutHad       = new std::vector<double>();
01863     t_hsim3x3CharHad       = new std::vector<double>();
01864     t_hsim5x5CharHad       = new std::vector<double>();
01865     t_hsim7x7CharHad       = new std::vector<double>();
01866   }
01867 
01868   tree->Branch("t_maxNearHcalP3x3",     "vector<double>", &t_maxNearHcalP3x3);
01869   tree->Branch("t_maxNearHcalP5x5",     "vector<double>", &t_maxNearHcalP5x5);
01870   tree->Branch("t_maxNearHcalP7x7",     "vector<double>", &t_maxNearHcalP7x7);
01871   tree->Branch("t_h3x3",                "vector<double>", &t_h3x3);
01872   tree->Branch("t_h5x5",                "vector<double>", &t_h5x5);
01873   tree->Branch("t_h7x7",                "vector<double>", &t_h7x7);
01874   tree->Branch("t_h3x3Sig",             "vector<double>", &t_h3x3Sig);
01875   tree->Branch("t_h5x5Sig",             "vector<double>", &t_h5x5Sig);
01876   tree->Branch("t_h7x7Sig",             "vector<double>", &t_h7x7Sig);
01877   tree->Branch("t_infoHcal",            "vector<int>",    &t_infoHcal);
01878 
01879   if (doMC) {
01880     tree->Branch("t_trkHcalEne",          "vector<double>", &t_trkHcalEne);
01881     tree->Branch("t_hsim3x3",             "vector<double>", &t_hsim3x3);
01882     tree->Branch("t_hsim5x5",             "vector<double>", &t_hsim5x5);
01883     tree->Branch("t_hsim7x7",             "vector<double>", &t_hsim7x7);
01884     tree->Branch("t_hsim3x3Matched",      "vector<double>", &t_hsim3x3Matched);
01885     tree->Branch("t_hsim5x5Matched",      "vector<double>", &t_hsim5x5Matched);
01886     tree->Branch("t_hsim7x7Matched",      "vector<double>", &t_hsim7x7Matched);
01887     tree->Branch("t_hsim3x3Rest",         "vector<double>", &t_hsim3x3Rest);
01888     tree->Branch("t_hsim5x5Rest",         "vector<double>", &t_hsim5x5Rest);
01889     tree->Branch("t_hsim7x7Rest",         "vector<double>", &t_hsim7x7Rest);
01890     tree->Branch("t_hsim3x3Photon",       "vector<double>", &t_hsim3x3Photon);
01891     tree->Branch("t_hsim5x5Photon",       "vector<double>", &t_hsim5x5Photon);
01892     tree->Branch("t_hsim7x7Photon",       "vector<double>", &t_hsim7x7Photon);
01893     tree->Branch("t_hsim3x3NeutHad",      "vector<double>", &t_hsim3x3NeutHad);
01894     tree->Branch("t_hsim5x5NeutHad",      "vector<double>", &t_hsim5x5NeutHad);
01895     tree->Branch("t_hsim7x7NeutHad",      "vector<double>", &t_hsim7x7NeutHad);
01896     tree->Branch("t_hsim3x3CharHad",      "vector<double>", &t_hsim3x3CharHad);
01897     tree->Branch("t_hsim5x5CharHad",      "vector<double>", &t_hsim5x5CharHad);
01898     tree->Branch("t_hsim7x7CharHad",      "vector<double>", &t_hsim7x7CharHad);
01899   }
01900   tree->Branch("t_nTracks",             &t_nTracks,       "t_nTracks/I");
01901 
01902 }
01903 
01904 
01905 double IsolatedTracksNxN::DeltaPhi(double v1, double v2) {
01906   // Computes the correctly normalized phi difference
01907   // v1, v2 = phi of object 1 and 2
01908   
01909   double pi    = 3.141592654;
01910   double twopi = 6.283185307;
01911   
01912   double diff = std::abs(v2 - v1);
01913   double corr = twopi - diff;
01914   if (diff < pi){ return diff;} else { return corr;} 
01915 }
01916 
01917 double IsolatedTracksNxN::DeltaR(double eta1, double phi1, double eta2, double phi2) {
01918   double deta = eta1 - eta2;
01919   double dphi = DeltaPhi(phi1, phi2);
01920   return std::sqrt(deta*deta + dphi*dphi);
01921 }
01922 
01923 void IsolatedTracksNxN::printTrack(const reco::Track* pTrack) {
01924   
01925   std::string theTrackQuality = "highPurity";
01926   reco::TrackBase::TrackQuality trackQuality_ = reco::TrackBase::qualityByName(theTrackQuality);
01927 
01928   std::cout << " Reference Point " << pTrack->referencePoint() <<"\n"
01929             << " TrackMmentum " << pTrack->momentum()
01930             << " (pt,eta,phi)(" << pTrack->pt()<<","<<pTrack->eta()<<","<<pTrack->phi()<<")"
01931             << " p " << pTrack->p() << "\n"
01932             << " Normalized chi2 " << pTrack->normalizedChi2() <<"  charge " << pTrack->charge()
01933             << " qoverp() " << pTrack->qoverp() <<"+-" << pTrack->qoverpError()
01934             << " d0 " << pTrack->d0() << "\n"
01935             << " NValidHits " << pTrack->numberOfValidHits() << "  NLostHits " << pTrack->numberOfLostHits()
01936             << " TrackQuality " << pTrack->qualityName(trackQuality_) << " " << pTrack->quality(trackQuality_) 
01937             << std::endl;
01938   
01939   if( printTrkHitPattern_ ) {
01940     const reco::HitPattern& p = pTrack->hitPattern();
01941     const reco::HitPattern& p1 = pTrack->trackerExpectedHitsInner();
01942     const reco::HitPattern& p2 = pTrack->trackerExpectedHitsOuter();
01943 
01944     std::cout<<"default " << std::endl;
01945     for (int i=0; i<p.numberOfHits(); i++) {
01946       p.printHitPattern(i, std::cout);
01947     }
01948     std::cout<<"trackerExpectedHitsInner() " << std::endl;
01949     for (int i=0; i<p1.numberOfHits(); i++) {
01950       p1.printHitPattern(i, std::cout);
01951     }
01952     std::cout<<"trackerExpectedHitsOuter() " << std::endl;
01953     for (int i=0; i<p2.numberOfHits(); i++) {
01954       p2.printHitPattern(i, std::cout);
01955     }
01956 
01957 
01958     std::cout << "\n \t trackerLayersWithMeasurement() "     << p.trackerLayersWithMeasurement() 
01959               << "\n \t pixelLayersWithMeasurement() "       << p.pixelLayersWithMeasurement() 
01960               << "\n \t stripLayersWithMeasurement() "       << p.stripLayersWithMeasurement()  
01961               << "\n \t pixelBarrelLayersWithMeasurement() " << p.pixelBarrelLayersWithMeasurement()
01962               << "\n \t pixelEndcapLayersWithMeasurement() " << p.pixelEndcapLayersWithMeasurement()
01963               << "\n \t stripTIBLayersWithMeasurement() "    << p.stripTIBLayersWithMeasurement()
01964               << "\n \t stripTIDLayersWithMeasurement() "    << p.stripTIDLayersWithMeasurement()
01965               << "\n \t stripTOBLayersWithMeasurement() "    << p.stripTOBLayersWithMeasurement()
01966               << "\n \t stripTECLayersWithMeasurement() "    << p.stripTECLayersWithMeasurement()
01967               << std::endl;
01968 
01969   }
01970 }
01971 
01972 //define this as a plug-in
01973 DEFINE_FWK_MODULE(IsolatedTracksNxN);