//***************************************************************************** // File: Level3SummaryWriterModule.cc // ---------------------------------------------------------------------------- // Type: Class implementation source // Package: Level3Mods // Class: Level3SummaryWriterModule // Language: Standard C++ // Project: CDF Run II Offline Software Upgrade // OrigAuth: Kevin McFarland, Gilles de Lentdecker, Beate Heineman // Company: Fermilab //============================================================================= //***************************************************************************** // Revisions: // 02/18/2005 (dldecker) // Modify the clusters used by EM CesAvgChi2 (=> version 2, no new variable) // 12/20/2004 (dldecker) // Use PadTrack (refitted) SVX track (=> version 4, no new variable) // 07/31/2003 (dldecker) // Add d0 Significance for SVX track (=> version 2, with 8 variables) // 08/29/2003 (dldecker) // remove temporarily d0 Significance (dependence prob) but keep version at 2 // because of a change in the cut on Si axial layers //============================================================================= // Declarations and Definitions //============================================================================= //------------------------ // String Header First -- //------------------------ #include //----------------------- // This Class's Header -- //----------------------- #include "Level3Mods/Level3SummaryWriterModule.hh" //------------- // C Headers -- //------------- #include #include //--------------- // C++ Headers -- //--------------- #include #include //------------------------------- // Collaborating Class Headers -- //------------------------------- #include "AbsEnv/AbsEnv.hh" #include "Calor/CprWireCollectionMaker.hh" #include "Electron/emobj_alg.hh" #include "ElectronObjects/CdfEmObject.hh" #include "ElectronObjects/CdfEmObjectView.hh" #include "MuonObjects/CdfMuon.hh" #include "MuonObjects/CdfMuonView.hh" #include "JetObjects/CdfJetColl.hh" #include "MetObjects/CdfMet.hh" #include "RRL3/GrowResultList.hh" #include "TrackingObjects/Storable/CdfTrackColl.hh" #include "TrackingObjects/Storable/CdfTrackView.hh" #include "TrackingObjects/Tracks/track_cut.hh" #include "TauObjects/CdfTau.hh" #include "TauObjects/CdfTauCollection.hh" #include "rcp/Manager.hpp" #include "rcp/RCPValue.hpp" #include "HepTuple/HepHist1D.h" #include "Level3Objects/L3SummaryObject.hh" // ------------------------------------------------- // -- Declarations of variables defined elsewhere -- // ------------------------------------------------- //----------------------------------------------------------------------- // Local Macros, Typedefs, Structures, Unions and Forward Declarations -- //----------------------------------------------------------------------- static const char rcsid[] = "$Id: Level3SummaryWriterModule.cc"; //---------------- // Constructors -- //---------------- Level3SummaryWriterModule::Level3SummaryWriterModule(const char* const theName, const char* const theDescription) : HepHistModule(theName,theDescription), // _Jet4Et ("jet4Et",this,8.0), _Jet7Et ("jet7Et",this,8.0), _TrackPt ("trackPt",this,1.2), _EmObjectEt("emObjectEt",this,1.5), _MuonPt ("muonPt",this,1.2), _TauPt ("tauPt",this,5.0), _SiTrackPt ("SitrackPt",this,1.2), _SiNbLayers ("PhiLayersSiHits",this,3) { // ------------------------------------------------------------------- // Electron menu : // ------------------------------------------------------------------- _commonMenu.initialize("commonMenu",this); _commonMenu.initTitle("commonMenu"); commands()->append(&_commonMenu); //common _Jet4Et.addDescription( " Specifies the Et cut applied to Jets of cone 0.4 for storing them in the L3 Summary bank.\n\ Default for Jet4Et is 8.0 GeV " ); _Jet7Et.addDescription( " Specifies the Et cut applied to Jets of cone 0.7 for storing them in the L3 Summary bank.\n\ Default for Jet7Et is 8.0 GeV " ); _TrackPt.addDescription( " Specifies the Pt cut applied to tracks for storing them in the L3 Summary bank.\n\ Default for TrackPt is 1.2 GeV " ); _EmObjectEt.addDescription( " Specifies the Et cut applied to CdfEmObjects for storing them in the L3 Summary bank.\n\ Default for EmObjectEt is 1.5 GeV " ); _MuonPt.addDescription( " Specifies the Pt cut applied to muons for storing them in the L3 Summary bank.\n\ Default for MuonPt is 1.2 GeV " ); _TauPt.addDescription( " Specifies the Pt cut applied to taus for storing them in the L3 Summary bank.\n\ Default for TauPt is 5.0 GeV " ); _SiTrackPt.addDescription( " Specifies the Pt cut applied to SVX tracks for storing them in the L3 Summary bank.\n\ Default for SiTrackPt is 1.2 GeV " ); _SiNbLayers.addDescription( " Specifies the min nbr of layers with SiHits for storing them in the L3 Summary bank.\n\ Default for SiNbLayers is 3 " ); _commonMenu.commands()->append(&_Jet4Et); _commonMenu.commands()->append(&_Jet7Et); _commonMenu.commands()->append(&_TrackPt); _commonMenu.commands()->append(&_EmObjectEt); _commonMenu.commands()->append(&_MuonPt); _commonMenu.commands()->append(&_TauPt); _commonMenu.commands()->append(&_SiTrackPt); _commonMenu.commands()->append(&_SiNbLayers); } //-------------- // Destructor -- //-------------- Level3SummaryWriterModule::~Level3SummaryWriterModule( ) { } //-------------- // Operations -- //-------------- AppResult Level3SummaryWriterModule::beginJob( AbsEvent* aJob ) { // std::cout << "begin Job"<hist1D("nbr of floats",1100,0.,1100.,2001); _nbrbytes = &manager->hist1D("nbr of bytes",800,0.,3200.,2002); _nbrofElec = &manager->hist1D("# of elec",20,0.,20.,600); _nbrofMuon = &manager->hist1D("# of muons",20,0.,20.,601); _nbrofTau = &manager->hist1D("# of taus",20,0.,20.,602); _nbrofJet4 = &manager->hist1D("# of jet4",20,0.,20.,603); _nbrofJet7 = &manager->hist1D("# of jet7",20,0.,20.,604); _nbrofTrack = &manager->hist1D("# of tracks",100,0.,100.,605); _nbrofSVXTk = &manager->hist1D("# of SVXtracks",100,0.,100.,606); _pTMuon = &manager->hist1D("muon pt",100,-50.,50.,800); _curvMuon = &manager->hist1D("muon curvature",100,-0.01,0.01,801); _etaMuon = &manager->hist1D("muon eta",50,-2.5,2.5,802); _phi0Muon = &manager->hist1D("muon phi0",100,0.,10.,803); _d0Muon = &manager->hist1D("muon d0",100,-5.,5.,804); _z0Muon = &manager->hist1D("muon z0",100,-50.,50.,805); _emMuon = &manager->hist1D("muon em",50,0.,25.,806); _hadMuon = &manager->hist1D("muon had",50,0.,25.,807); _dxCmu = &manager->hist1D("dx CMU",100,-75.,75.,808); _chixCmu = &manager->hist1D("chix CMU",50,-250.,250.,809); _chixPosCmu = &manager->hist1D("chixPosCMU",50,-250.,250.,814); _dxCmp = &manager->hist1D("dx CMP",100,-500.,500.,810); _chixCmp = &manager->hist1D("chix CMP",100,-500.,500.,811); _chixPosCmp = &manager->hist1D("chixPosCMP",50,-250.,250.,815); _dxCmx = &manager->hist1D("dx CMX",100,-250.,250.,812); _chixCmx = &manager->hist1D("chix CMX",100,-500.,500.,813); _chixPosCmx = &manager->hist1D("chixPosCMX",50,-250.,250.,816); _eletElec = &manager->hist1D("elec emet",100,0.,50.,700); _phetElec = &manager->hist1D("phot emet",100,0.,50.,723); _etaElec = &manager->hist1D("elec eta",50,-2.5,2.5,701); _eta2Elec = &manager->hist1D("elec eta2",50,-2.5,2.5,751); _pTElec = &manager->hist1D("elec pt",100,-50.,50.,702); _curvElec = &manager->hist1D("elec curvature",100,-0.01,0.01,722); _Z0Elec = &manager->hist1D("elec z0",100,-50.,50.,703); _Phi0Elec = &manager->hist1D("elec phi0",100,0.,10.,704); _D0Elec = &manager->hist1D("elec D0",100,-5.,5.,705); _lambdaElec = &manager->hist1D("E- Tk lambda",100,0.,10.,726); _hadem2Elec = &manager->hist1D("elec hadem2",50,0.,2.5,706); _hadem3Elec = &manager->hist1D("elec hadem3",50,0.,2.5,707); _delxElec = &manager->hist1D("elec delx",100,0.,10.,708); _delzElec = &manager->hist1D("elec delz",100,0.,10.,709); _ChiSElec = &manager->hist1D("elec ChiS",100,0.,50.,710); _ChiWElec = &manager->hist1D("elec ChiW",100,0.,50.,711); _LshrCesElec = &manager->hist1D("elec LshrCes",100,0.,50.,712); _LshrEl2Elec = &manager->hist1D("elec LshrEl2",50,0.,5.,713); _LshrEl3Elec = &manager->hist1D("elec LshrEl3",50,0.,5.,714); _SeedIetaElec = &manager->hist1D("elec SeedIeta",100,0.,50.,715); _SeedIphi = &manager->hist1D("elec SeedIphi",100,0.,50.,716); _elIso4Elec = &manager->hist1D("elec Iso4",100,0.,50.,724); _phIso4Elec = &manager->hist1D("phot Iso4",100,0.,50.,725); _CesZElec = &manager->hist1D("elec CesZ",100,0.,500.,718); _CesAvgChi2Elec = &manager->hist1D("elec CesAvgChi2",100,0.,50.,719); _etJet4 = &manager->hist1D("Jet4 et",100,0.,50.,901); _etaJet4 = &manager->hist1D("Jet4 eta",50,-2.5,2.5,902); _phiJet4 = &manager->hist1D("Jet4 phi",100,0.,50.,903); _etJet7 = &manager->hist1D("Jet7 et",100,0.,50.,1001); _etaJet7 = &manager->hist1D("Jet7 eta",50,2.5,2.5,1002); _phiJet7 = &manager->hist1D("Jet7 phi",100,0.,50.,1003); _ptTrack = &manager->hist1D("Track pt",100,-50.,50.,1004); _curvTrack = &manager->hist1D("Track curvature",100,-0.01,0.01,1044); _z0Track = &manager->hist1D("Track z0",100,-50.,50.,1005); _d0Track = &manager->hist1D("Track d0",100,-10.,10.,1006); _phi0Track = &manager->hist1D("Track phi0",100,0.,10.,1007); _lambdaTrack = &manager->hist1D("Track lambda",100,0.,10.,1008); _ptAllSiTrack = &manager->hist1D("AllSiTrack pt",100,0.,50.,1204); _ptSiTrack = &manager->hist1D("SiTrack pt",100,-50.,50.,1104); _curvSiTrack = &manager->hist1D("SiTrack curvature",100,-0.01,0.01,1144); _z0SiTrack = &manager->hist1D("SiTrack z0",100,-50.,50.,1105); _d0SiTrack = &manager->hist1D("SiTrack d0",100,-10.,10.,1106); _phi0SiTrack = &manager->hist1D("SiTrack phi0",100,0.,10.,1107); _lambdaSiTrack = &manager->hist1D("SiTrack lambda",100,0.,10.,1108); _D0SignificanceSiTrack = &manager->hist1D("D0Significance",100,-50.,50.,1109); _met = &manager->hist1D("Missing Et",100,0.,50.,1009); _metphi = &manager->hist1D("MEt Phi",100,0.,10.,1010); _etSum = &manager->hist1D("Et Sum",100,0.,500.,1011); _exSum = &manager->hist1D("MEtXSum",100,-50.,50.,1111); _eySum = &manager->hist1D("MEtYSum",100,-50.,50.,1211); _metSum = &manager->hist1D("MEtSum",100,0.,50.,1311); _ptTau = &manager->hist1D("Tau pt",100,0.,100.,1012); _etaTau = &manager->hist1D("Tau eta",50,-2.5,2.5,1013); _phiTau = &manager->hist1D("Tau phi",100,-10.,10.,1014); _cluMass = &manager->hist1D("Tau Cluster Mass",100,0.,20.,1015); _tracksMass = &manager->hist1D("Tau Tk Mass",100,0.,10.,1016); _nbrSeeds = &manager->hist1D("Tau Ch Tk Seeds",25,0.,25.,1017); // std::cout << " HISTOS BOOKED"<accumulate(nele); // muon : content[1][0] = 1; content[1][1] = nmu; content[1][2] = 16; content[1][3] = 1; if(createHistos()) _nbrofMuon->accumulate(nmu); // jet4 : content[2][0] = 2; content[2][1] = njet4; content[2][2] = 3; content[2][3] = 0; if(createHistos()) _nbrofJet4->accumulate(njet4); // jet7 : content[3][0] = 3; content[3][1] = njet7; content[3][2] = 3; content[3][3] = 0; if(createHistos()) _nbrofJet7->accumulate(njet7); // Tracks : content[4][0] = 4; content[4][1] = ntrack; content[4][2] = 7; content[4][3] = 2; if(createHistos()) _nbrofTrack->accumulate(ntrack); // SVXTracks : content[5][0] = 5; content[5][1] = nSiTrack; content[5][2] = 8; content[5][3] = 4; if(createHistos()) _nbrofSVXTk->accumulate(nSiTrack); // Missing Et : content[6][0] = 6; content[6][1] = nmet; content[6][2] = 4; content[6][3] = 1; // tau : content[7][0] = 7; content[7][1] = ntau; content[7][2] = 6; content[7][3] = 0; if(createHistos()) _nbrofTau->accumulate(ntau); L3SummaryObject::indexType myShort; L3SummaryObject::headerType aBlock; myShort.clear(); int icount = 0; int total = 0; int totalbytes = 0; for (int i = 0; i < 8; i++){ icount++; aBlock.blockId = content[i][0]; aBlock.nEntries = content[i][1]; aBlock.entryLength = content[i][2]; aBlock.blockVersion = content[i][3]; total = total + (aBlock.nEntries * aBlock.entryLength); myShort.push_back(aBlock); } totalbytes = total * 4 + 137; if(createHistos()) _nbrfloats->accumulate(total); if(createHistos()) _nbrbytes->accumulate(totalbytes); Handle theL3Sum(new L3SummaryObject); size_t _size_t = total; theL3Sum->assignBufferLength(_size_t); theL3Sum->assignBuffer(&bigArray[0]); theL3Sum->assignIndex(myShort); theL3Sum->set_description(" "); // APPEND L3SUMMARY (StorableObject called L3SummaryObject) TO EVENT RECORD anEvent->append(theL3Sum); } return AppResult::OK; } bool Level3SummaryWriterModule::fillElectron( AbsEvent* anEvent) { CdfEmObjectView_h emObjectView; bool foundView = 0; if (CdfEmObjectView::defEmObjects(emObjectView) == CdfEmObjectView::OK) { foundView = 1; } else if (_verbose.value()) { ERRLOG(ELwarning,"Level3SummaryWriterModule") << "Could not find EmObject view" << endmsg; } nele=0; if(foundView) { if (_verbose.value()) std::cout << "Found the CdfEmObjectView" << std::endl; for (CdfEmObjectView::const_iterator emIter = emObjectView->contents().begin(); emIter != emObjectView->contents().end(); ++emIter) { if (nele > 49) { ERRLOG(ELwarning,"Level3SummaryWriterModule") << "More than 50 electrons" << endmsg; break; } if (_verbose.value()) std::cout << "looping through em object" << std::endl; const EmCluster* cluster = (*emIter)->getEmCluster(); const EmCluster* cluster1 = (*emIter)->getEmCluster(); // use ZVertex = 0 (???? maybe not ideal in the end) //cluster->setVertexZ(0.0); //float emet = cluster->emEt(); float iso = -999; iso = cluster->totalIsolationEt4(); //For the Photon group cluster1->setVertexZ(0.0); float phet = cluster1->emEt(); //For the electron group float elet = (*emIter)->fourMomentum("DEFAULT").et(); if ((elet>_EmObjectEt.value()) || (phet>_EmObjectEt.value())) { // track pt and some other track parameters float trackPt=-9999; float trackZ0=-9999; float trackPhi0=-9999; float trackD0=-9999; float trackcurv=-9999; float tracklambda=-9999; float signedpt=-9999; float thecharge=0; CdfEmObject::Track_link maxPtTrk = (*emIter)->maxPtTrack(); if (maxPtTrk.is_nonnull()) { trackPt = maxPtTrk->pt(); thecharge = maxPtTrk->charge(); signedpt = maxPtTrk->pt()*maxPtTrk->charge(); trackcurv = maxPtTrk->curvature(); trackZ0 = maxPtTrk->z0(); trackPhi0 = maxPtTrk->phi0(); trackD0 = maxPtTrk->d0(); tracklambda = maxPtTrk->lambda(); } //had/em float hadem2=cluster->hadEmTriggerTower(); float hadem3=cluster->hadEm(); //eta float eta =cluster->emEtaDetector(); // CES quantities float delx=-999; float delz=-999; float ChiS=-999; float ChiW=-999; float CesAvgChi2 = -999; float CesZ = 999; ValueVectorLink strip_cluster; ValueVectorLink wire_cluster; std::string collTag; // make CES quantities for photons collTag = "UNBIASED"; const CdfEmObject::Ces_CollType& assocCes = (*emIter)->matchingCesClusters( collTag ); //CdfEmObject::Ces_link strip_cluster2; //CdfEmObject::Ces_link wire_cluster2; ValueVectorLink strip_cluster2; ValueVectorLink wire_cluster2; CdfEmObject::Ces_CollType::const_iterator ci(assocCes.contents().begin( )); CdfEmObject::Ces_CollType::const_iterator ciEnd(assocCes.contents().end()); //typedef ValueVectorLink Ces_link; //typedef IndexViewVector Ces_CollType; for ( ; ci != ciEnd; ++ci) { if ((*ci)->view() == CesCluster::WIRE) { if(wire_cluster.is_nonnull()) { if( (*ci)->energy() > wire_cluster->energy() ) { wire_cluster2 = wire_cluster; wire_cluster = *ci; } else if(wire_cluster2.is_nonnull()) { if( (*ci)->energy() > wire_cluster2->energy() ) { wire_cluster2 = *ci; } } else { wire_cluster2 = *ci; } } else { wire_cluster = *ci; } } else { if(strip_cluster.is_nonnull()) { if( (*ci)->energy() > strip_cluster->energy() ) { strip_cluster2 = strip_cluster; strip_cluster = *ci; } else if(strip_cluster2.is_nonnull()) { if( (*ci)->energy() > strip_cluster2->energy() ) { strip_cluster2 = *ci; } } else { strip_cluster2 = *ci; } } else { strip_cluster = *ci; } } // end of View if if (strip_cluster.is_nonnull()){ CesZ = strip_cluster->fitted_position(); //jobby: still need to check this } if (strip_cluster.is_nonnull()&&wire_cluster.is_nonnull()){ CesAvgChi2 = (scaleCesChisq(strip_cluster->chi2_strip() , cluster->emEnergy()) +scaleCesChisq(wire_cluster->chi2_strip() , cluster->emEnergy()))/2; } } // end loop over UNBIASED CES clusters ////////////////////// // track based clusters wire_cluster = (*emIter)->bestMatchingCesCluster(CesCluster::WIRE ,"TRACK"); strip_cluster = (*emIter)->bestMatchingCesCluster(CesCluster::STRIP,"TRACK"); if (wire_cluster.is_nonnull() && trackPt>0) { //delx = fabs(wire_cluster->dist_track_cluster()); delx = emobj_alg::TrackLocalCoord::xdiff( *(*emIter) ); ChiW = scaleCesChisq(wire_cluster->chi2_strip() , cluster->emEnergy()); } if (strip_cluster.is_nonnull() && trackPt>0) { //delz = fabs(strip_cluster->dist_track_cluster()); delz = fabs(emobj_alg::TrackLocalCoord::zdiff( *(*emIter))); ChiS = scaleCesChisq(strip_cluster->chi2_strip() , cluster->emEnergy()); } // Implementation before february 2005 // now unbiased cluster // wire_cluster = (*emIter)->bestMatchingCesCluster(CesCluster::WIRE ,"UNBIASED"); //strip_cluster = (*emIter)->bestMatchingCesCluster(CesCluster::STRIP,"UNBIASED"); //float CesZ = 999; // if (strip_cluster.is_nonnull()){ // CesZ = strip_cluster->fitted_position(); //jobby: still need to check this // } //if (strip_cluster.is_nonnull()&&wire_cluster.is_nonnull()){ // CesAvgChi2= (scaleCesChisq(strip_cluster->chi2_strip() , cluster->emEnergy())+ // scaleCesChisq(wire_cluster->chi2_strip() , cluster->emEnergy()))/2; //} // New method is now before the track based clusters // Lshr float LshrCes= -999; float LshrEl2= -999; float LshrEl3= -999; /* if(fabs(CesZ) < 230.0) LshrCes = emobj_alg::CalculateLshr::lshr( *cluster, CesZ, 0.0, 3); LshrEl3 = LshrEl3 = (*emIter)->lshr(); LshrEl2 = (*emIter)->lshr(2); */ if(fabs(CesZ) < 230.0) LshrCes = emobj_alg::CalculateLshr::lshrUnbiased( *(*emIter),3); LshrEl3 = emobj_alg::CalculateLshr::lshrTrack(*(*emIter),3); LshrEl2 = emobj_alg::CalculateLshr::lshrTrack(*(*emIter),2); float SeedIeta=cluster->seedEtaAddr(); float SeedIphi=cluster->seedPhiAddr(); //float elIso4 = cluster->totalIsolationEt4(); float elIso4 = iso; // Iso for Vertex at (0.0) float phIso4 = cluster1->totalIsolationEt4(); nele++; // now fill the array bigArray[counter]=elet; if(createHistos()) _eletElec->accumulate(elet); counter++; bigArray[counter]=eta; if(createHistos()) _etaElec->accumulate(eta); counter++; bigArray[counter] = signedpt; // bigArray[counter]=trackPt; if(createHistos()) _pTElec->accumulate(signedpt); counter++; // bigArray[counter]=trackcurv; if(createHistos()) _curvElec->accumulate(trackPt); // counter++; bigArray[counter]=trackZ0; if(createHistos()) _Z0Elec->accumulate(trackZ0); counter++; bigArray[counter]=trackPhi0; if(createHistos()) _Phi0Elec->accumulate(trackPhi0); counter++; bigArray[counter]=trackD0; if(createHistos()) _D0Elec->accumulate(trackD0); counter++; bigArray[counter]=hadem2; if(createHistos()) _hadem2Elec->accumulate(hadem2); counter++; bigArray[counter]=hadem3; if(createHistos()) _hadem3Elec->accumulate(hadem3); counter++; bigArray[counter]=delx; if(createHistos()) _delxElec->accumulate(delx); counter++; bigArray[counter]=delz; if(createHistos()) _delzElec->accumulate(delz); counter++; bigArray[counter]=ChiS; if(createHistos()) _ChiSElec->accumulate(ChiS); counter++; bigArray[counter]=ChiW; if(createHistos()) _ChiWElec->accumulate(ChiW); counter++; bigArray[counter]=LshrCes; if(createHistos()) _LshrCesElec->accumulate(LshrCes); counter++; bigArray[counter]=LshrEl2; if(createHistos()) _LshrEl2Elec->accumulate(LshrEl2); counter++; bigArray[counter]=LshrEl3; if(createHistos()) _LshrEl3Elec->accumulate(LshrEl3); counter++; bigArray[counter]=SeedIeta; if(createHistos()) _SeedIetaElec->accumulate(SeedIeta); counter++; bigArray[counter]=SeedIphi; if(createHistos()) _SeedIphi->accumulate(SeedIphi); counter++; bigArray[counter]=elIso4; if(createHistos()) _elIso4Elec->accumulate(elIso4); counter++; bigArray[counter]=CesZ; if(createHistos()) _CesZElec->accumulate(CesZ); counter++; bigArray[counter]=CesAvgChi2; if(createHistos()) _CesAvgChi2Elec->accumulate(CesAvgChi2); counter++; bigArray[counter]=phet; if(createHistos()) _phetElec->accumulate(phet); counter++; bigArray[counter]=tracklambda; if(createHistos()) _lambdaElec->accumulate(tracklambda); counter++; bigArray[counter]=phIso4; if(createHistos()) _phIso4Elec->accumulate(phIso4); counter++; } } // loop over CdfEmObjects } // if we found a cdfemobject else { std::cerr << " Error in Level3SummaryWriterModule : EmObjects requested but could not find CdfEmObjectView" << std::endl; return false; } // return true; } bool Level3SummaryWriterModule::fillMuon( AbsEvent* anEvent) { nmu=0; bool foundMuonView=false; CdfMuonView_h muons; if ( CdfMuonView::defMuons(muons) ) foundMuonView = true ; else if (_verbose.value()){ ERRLOG( ELwarning,"Level3SummaryWriterModule" ) << "Could not find CdfMuonView" << endmsg ; return false; } if ( foundMuonView ) { for ( CdfMuonView::const_iterator imu = muons->contents().begin() ; imu != muons->contents().end() ; ++imu) { if (nmu > 49) { ERRLOG(ELwarning,"Level3SummaryWriterModule") << "More than 50 muons" << endmsg; break; } const CdfMuon& muon = **imu; float pt = muon.bestTrack()->pt(); if (pt>_MuonPt.value()){ float cur = muon.bestTrack()->curvature(); float eta = muon.bestTrack()->pseudoRapidity(); float d0 = muon.bestTrack()->d0(); float z0 = muon.bestTrack()->z0(); float phi0= muon.bestTrack()->phi0(); float em = muon.emEnergy(); float had = muon.hadronEnergy(); float dxCmu=-99; // float dzCmu=-99; float chixCmu=-99; float chixPosCmu=-9999; if (muon.hasCmu()) { dxCmu =muon.cmu().dx(); // dzCmu =muon.cmu().dz(); chixCmu=muon.cmu().chsqX(); chixPosCmu=muon.cmu().chsqXPosition(); } float dxCmp=-99; float chixCmp=-99; float chixPosCmp=-9999; if (muon.hasCmp()) { dxCmp =muon.cmp().dx(); chixCmp=muon.cmp().chsqX(); chixPosCmp=muon.cmp().chsqXPosition(); } float dxCmx=-99; float chixCmx=-99; float chixPosCmx=-9999; if (muon.hasCmx()) { dxCmx =muon.cmx().dx(); chixCmx=muon.cmx().chsqX(); chixPosCmx=muon.cmx().chsqXPosition(); } float thecharge = muon.bestTrack()->charge(); float signedpt = (muon.bestTrack()->pt())*(muon.bestTrack()->charge()); bigArray[counter] = signedpt; // bigArray[counter]=pt; if(createHistos()) _pTMuon->accumulate(pt); counter++; //bigArray[counter]=cur; if(createHistos()) _curvMuon->accumulate(signedpt); //counter++; bigArray[counter]=eta; if(createHistos()) _etaMuon->accumulate(eta); counter++; bigArray[counter]=phi0; if(createHistos()) _phi0Muon->accumulate(phi0); counter++; bigArray[counter]=d0; if(createHistos()) _d0Muon->accumulate(d0); counter++; bigArray[counter]=z0; if(createHistos()) _z0Muon->accumulate(z0); counter++; bigArray[counter]=em; if(createHistos()) _emMuon->accumulate(em); counter++; bigArray[counter]=had; if(createHistos()) _hadMuon->accumulate(had); counter++; bigArray[counter]=dxCmu; if(createHistos()) _dxCmu->accumulate(dxCmu); counter++; bigArray[counter]=chixCmu; if(createHistos()) _chixCmu->accumulate(chixCmu); counter++; bigArray[counter]=dxCmp; if(createHistos()) _dxCmp->accumulate(dxCmp); counter++; bigArray[counter]=chixCmp; if(createHistos()) _chixCmp->accumulate(chixCmp); counter++; bigArray[counter]=dxCmx; if(createHistos()) _dxCmx->accumulate(dxCmx); counter++; bigArray[counter]=chixCmx; if(createHistos()) _chixCmx->accumulate(chixCmx); counter++; bigArray[counter]=chixPosCmu; if(createHistos()) _chixPosCmu->accumulate(chixPosCmu); counter++; bigArray[counter]=chixPosCmp; if(createHistos()) _chixPosCmp->accumulate(chixPosCmp); counter++; bigArray[counter]=chixPosCmx; if(createHistos()) _chixPosCmx->accumulate(chixPosCmx); counter++; nmu++; } if (counter > 15000) { ERRLOG(ELwarning,"Level3SummaryWriterModule") << "More than 15,000 floats" << endmsg; break; } } } return true; } bool Level3SummaryWriterModule::fillJet( AbsEvent* anEvent, float cone) { CdfJetColl_ch jetCollHandle; float jetEtMin=0; std::string description; if ((cone > 0.399)&&(cone < 0.401)) { description = "JetCluModule-cone0.4"; jetEtMin=_Jet4Et.value(); } else if ((cone > 0.699)&&(cone < 0.701)) { description = "JetCluModule-cone0.7"; jetEtMin=_Jet7Et.value(); } else if (_verbose.value()){ ERRLOG(ELwarning,"Level3SummaryWriterModule") << "Jet cone size not supported" << endmsg; return false; } CdfJetColl::Error jetStatus = CdfJetColl::find(jetCollHandle,description); if(jetStatus != CdfJetColl::ERROR){ JetList jets = jetCollHandle->contents(); for(ConstJetIter iter = jets.begin(); iter != jets.end(); iter++) { if ((njet4 > 19) || (njet7 > 19)) { ERRLOG(ELwarning,"Level3SummaryWriterModule") << "More than 40 jets" << endmsg; break; } if(iter->et() > jetEtMin) { if ((cone > 0.399)&&(cone < 0.401)) { bigArray[counter]=iter->et(); if(createHistos()) _etJet4->accumulate(iter->et()); counter++; bigArray[counter]=iter->eta(); if(createHistos()) _etaJet4->accumulate(iter->eta()); counter++; bigArray[counter]=iter->phi(); if(createHistos()) _phiJet4->accumulate(iter->phi()); counter++; njet4++; } else if ((cone > 0.699)&&(cone < 0.701)) { bigArray[counter]=iter->et(); if(createHistos()) _etJet7->accumulate(iter->et()); counter++; bigArray[counter]=iter->eta(); if(createHistos()) _etaJet7->accumulate(iter->eta()); counter++; bigArray[counter]=iter->phi(); if(createHistos()) _phiJet7->accumulate(iter->phi()); counter++; njet7++; } } if (counter > 15000) { ERRLOG(ELwarning,"Level3SummaryWriterModule") << "More than 15,000 floats" << endmsg; break; } } } return true; } bool Level3SummaryWriterModule::fillSiTrack( AbsEvent* anEvent) { nSiTrack = 0; CdfTrackView_h trackView; CdfTrackView::Error SiTrackStatus = CdfTrackView::defTracks( trackView, "L3" ); if (SiTrackStatus != CdfTrackColl::ERROR){ CdfTrackView_h allTracks; //loop over defTracks for (CdfTrackView::iterator trackIter = trackView->contents().begin(); trackIter != trackView->contents().end();trackIter++) { if (nSiTrack > 199) { ERRLOG(ELwarning,"Level3SummaryWriterModule") << "More than 200 SVX tracks" << endmsg; break; } if( !(*trackIter)->usedSI() ){ if (allTracks.is_null ()) { // get ALL tracks if (CdfTrackView::allTracks (allTracks) != CdfTrackView::OK) { ERRLOG (ELwarning, "Level3TrackSummaryWriterModule") << "Could not get allTracks view " << endmsg; return AppResult::OK; } } CdfTrackView::const_iterator track_i = allTracks->contents ().begin (); for (; track_i != allTracks->contents ().end (); track_i++) { if ((*track_i)->parent ().is_undefined ()) { continue; // has no parent } if ((*track_i)->parent ()->id () == (*trackIter)->id () && (*track_i)->usedSI ()) { // match *trackIter = *track_i; break; } } // if ((*trackIter)->numSIHits()){ int amask = 0; int nlphi = 0; // NEW IMPLEMENTATION int nsvxaxl=0; for (int il=1; il<=5; il++) if ((*trackIter)->hasSIHit (il,0,1) || (*trackIter)->hasSIHit (il,1,1)) nsvxaxl++; if (((*trackIter)->pt()>_SiTrackPt.value()) && (nsvxaxl >= _SiNbLayers.value())) { int mask0 = 0; int mask1 = 0; int mask2 = 0; int mask3 = 0; int tracking_algo = 0; tracking_algo = (*trackIter)->algorithm().value(); // std::cout << " algo, usedSI " << tracking_algo << " " // << (*trackIter)->usedSI() << endl; mask0 |= (((*trackIter)->usedSI()) & 65535); mask1 |= (tracking_algo << 16 | mask0 ); mask2 |= ((((*trackIter)->usedSI()) >> 16) & 65535); mask3 |= ((mask2 << 16) | mask1 ); //std::cout << " mask1 " << mask1 << endl; //std::cout << "at extraction : " << endl; //int out1 = 0; //int out2 = 0; //out1 |= (mask1 & 65535); //out2 |= ((mask1) >> 16 & 255); //std::cout << out1 << " " << out2 << endl; //std::cout << endl; //Filling the array for SVX : float thecharge = (*trackIter)->charge(); float thecurvature = (*trackIter)->curvature(); float signedpt = (*trackIter)->pt()*(*trackIter)->charge(); bigArray[counter] = signedpt; //bigArray[counter]=(*trackIter)->pt(); if(createHistos()) _ptSiTrack->accumulate((*trackIter)->pt()); counter++; //bigArray[counter]=(*trackIter)->curvature(); if(createHistos())_curvSiTrack->accumulate((*trackIter)->curvature()); //counter++; bigArray[counter]=(*trackIter)->z0(); if(createHistos()) _z0SiTrack->accumulate((*trackIter)->z0()); counter++; bigArray[counter]=(*trackIter)->d0(); if(createHistos()) _d0SiTrack->accumulate((*trackIter)->d0()); counter++; bigArray[counter]=(*trackIter)->phi0(); if(createHistos()) _phi0SiTrack->accumulate((*trackIter)->phi0()); counter++; bigArray[counter]=(*trackIter)->lambda(); if(createHistos()) _lambdaSiTrack->accumulate((*trackIter)->lambda()); counter++; bigArray[counter] = mask1; counter++; bigArray[counter] = mask2; counter++; // D0 Significance float trackD0Significance = -9999; trackD0Significance = (*trackIter)->d0SignificanceWRT(_mBeamSpot.position()); bigArray[counter] = trackD0Significance; if(createHistos()) _D0SignificanceSiTrack->accumulate(trackD0Significance); counter++; nSiTrack++; } else if(createHistos()) _ptAllSiTrack->accumulate((*trackIter)->pt()); } if (counter > 15000) { ERRLOG(ELwarning,"Level3SummaryWriterModule") << "More than 15,000 floats" << endmsg; break; } } return true; } else if (_verbose.value()) ERRLOG( ELwarning,"Level3SummaryWriterModule" ) << "Could not find CdfTrackColl" << endmsg ; return true; } bool Level3SummaryWriterModule::fillTrack( AbsEvent* anEvent) { ntrack=0; CdfTrackView_h trackView; CdfTrackView::Error trackStatus = CdfTrackView::defTracks( trackView, "L3" ); if (trackStatus != CdfTrackView::OK){ if (_verbose.value()) ERRLOG( ELwarning,"Level3SummaryWriterModule" ) << "Could not find CdfTrackView" << endmsg ; return false; } for (CdfTrackView::iterator trackIter = trackView->contents().begin(); trackIter != trackView->contents().end();trackIter++) { if ( ntrack > 199) { ERRLOG(ELwarning,"Level3SummaryWriterModule") << "More than 200 COT tracks" << endmsg; break; } if ((*trackIter)->pt()>_TrackPt.value()) { // now store the five track parameters float thecharge = (*trackIter)->charge(); float thecurvature = (*trackIter)->curvature(); float signedpt = (*trackIter)->pt()*(*trackIter)->charge(); bigArray[counter] = signedpt; if(createHistos()) _ptTrack->accumulate(signedpt); // bigArray[counter]=(*trackIter)->pt(); // if(createHistos()) _ptTrack->accumulate((*trackIter)->pt()); counter++; // bigArray[counter]=(*trackIter)->curvature(); if(createHistos()) _curvTrack->accumulate((*trackIter)->curvature()); // counter++; bigArray[counter]=(*trackIter)->z0(); if(createHistos()) _z0Track->accumulate((*trackIter)->z0()); counter++; bigArray[counter]=(*trackIter)->d0(); if(createHistos()) _d0Track->accumulate((*trackIter)->d0()); counter++; bigArray[counter]=(*trackIter)->phi0(); if(createHistos()) _phi0Track->accumulate((*trackIter)->phi0()); counter++; bigArray[counter]=(*trackIter)->lambda(); if(createHistos()) _lambdaTrack->accumulate((*trackIter)->lambda()); counter++; int tracking_algo = 0; tracking_algo = (*trackIter)->algorithm().value(); int mask3 = 0; int mask4 = 0; for (int j=0;j<4;j++) { mask3 |= ((*trackIter)->numCTHits(j)&0xF)<< 4*j; } for (int j=4;j<8;j++) { mask4 |= ((*trackIter)->numCTHits(j)&0xF)<< 4*(j-4); } // std::cout << " COT's " << endl; // std::cout << " algo, mask3 " << tracking_algo << " " // << mask3 << endl; mask3 |= (tracking_algo << 16 | mask3 ); //std::cout << "at extraction : " << endl; //int out1 = 0; //int out2 = 0; //out1 |= (mask3 & 65535); // out2 |= ((mask3) >> 16 & 255); // std::cout << out1 << " " << out2 << endl; //std::cout << endl; bigArray[counter] = mask3; counter++; bigArray[counter] = mask4; counter++; ntrack++; } if (counter > 15000) { ERRLOG(ELwarning,"Level3SummaryWriterModule") << "More than 15,000 floats" << endmsg; break; } } return true; } bool Level3SummaryWriterModule::fillMet( AbsEvent* anEvent) { nmet=0; CdfMet_ch metHandle; // This will return the first Met object it finds. CdfMet::Error metStatus = CdfMet::find(metHandle); if(metStatus == CdfMet::ERROR){ // This is a warning; filter does not cut on missing Et if (_verbose.value()) ERRLOG(ELwarning,"Level3SummaryWriterModule::event") << "could not find Met" << endmsg; return false; } bigArray[counter]=metHandle->exSum(); counter++; if(createHistos()) _exSum->accumulate(metHandle->exSum()); bigArray[counter]=metHandle->eySum(); counter++; if(createHistos()) _eySum->accumulate(metHandle->eySum()); if(createHistos()) _met->accumulate(metHandle->met()); bigArray[counter]=metHandle->phi(); counter++; if(createHistos()) _metphi->accumulate(metHandle->phi()); bigArray[counter]=metHandle->etSum(); counter++; if(createHistos()) _etSum->accumulate(metHandle->etSum()); float mySum = sqrt((metHandle->exSum()*metHandle->exSum())+(metHandle->eySum()*metHandle->eySum())); if(createHistos()) _metSum->accumulate(mySum); nmet++; return true; } bool Level3SummaryWriterModule::fillTau( AbsEvent* anEvent) { ntau=0; ConstHandle tauHandle; if (!CdfTauCollection::find (&tauHandle)) { if (_verbose.value()) ERRLOG(ELwarning,"Level3SummaryWriterModule::event") << "could not find Tau collection" << endmsg; return false; } else { const CdfTauCollection::CollType & taus = tauHandle->contents(); for ( CdfTauCollection::ConstIterator tau = taus.begin() ; tau != taus.end() ; ++tau ) { if ( ntau > 24) { ERRLOG(ELwarning,"Level3SummaryWriterModule") << "More than 25 taus" << endmsg; break; } bigArray[counter]=tau->pt(); counter++; if(createHistos()) _ptTau->accumulate(tau->pt()); bigArray[counter]=tau->eta(); counter++; if(createHistos()) _etaTau->accumulate(tau->eta()); bigArray[counter]=tau->phi(); counter++; if(createHistos()) _phiTau->accumulate(tau->phi()); bigArray[counter]=tau->clusterMass(); counter++; if(createHistos()) _cluMass->accumulate(tau->clusterMass()); bigArray[counter]=tau->tracksMass(); counter++; if(createHistos()) _tracksMass->accumulate(tau->tracksMass()); bigArray[counter]=tau->chargedTracksNumberSeed10To30Degree(); counter++; if(createHistos())_nbrSeeds->accumulate(tau->chargedTracksNumberSeed10To30Degree()); ntau++; } } return true; } AppResult Level3SummaryWriterModule::other( AbsEvent* ) { return AppResult::OK; } AppResult Level3SummaryWriterModule::endRun( AbsEvent* aRun ) { // std::cout << "end Run "<