ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Mods/src/CosmicCleaningMod.cc
Revision: 1.1
Committed: Sat Aug 3 11:50:09 2013 UTC (11 years, 9 months ago) by ceballos
Content type: text/plain
Branch: MAIN
Log Message:
new cleaning module

File Contents

# User Rev Content
1 ceballos 1.1 // $Id: CosmicCleaningMod.cc,v 1.0
2    
3     #include "MitPhysics/Mods/interface/CosmicCleaningMod.h"
4     #include "MitCommon/MathTools/interface/MathUtils.h"
5     #include "MitAna/DataTree/interface/Track.h"
6     #include "MitPhysics/Init/interface/ModNames.h"
7    
8     using namespace mithep;
9    
10     ClassImp(mithep::CosmicCleaningMod)
11    
12     //--------------------------------------------------------------------------------------------------
13     CosmicCleaningMod::CosmicCleaningMod(const char *name, const char *title) :
14     BaseMod(name,title),
15     fCosmicsName("random"),
16     fCleanMuonsName(ModNames::gkCleanMuonsName),
17     fCleanCosmicsName(ModNames::gkCleanCosmicsName),
18     fCosmics(0)
19     {
20     // Constructor.
21     }
22    
23     //--------------------------------------------------------------------------------------------------
24     void CosmicCleaningMod::Process()
25     {
26     // Process entries of the tree.
27    
28     // get input collection
29     const MuonCol *CleanMuons = GetObjThisEvt<MuonCol>(fCleanMuonsName);
30     LoadEventObject(fCosmicsName, fCosmics);
31    
32     // Go through all cosmics and remove cosmic overlaps with collision muons and duplicates.
33     std::vector<const Muon*> CleanCosTemp;
34    
35     if (fCosmics) {
36     for (UInt_t i=0; i<fCosmics->GetEntries(); ++i) {
37     const Muon *u = fCosmics->At(i);
38    
39     FourVectorM mom(u->Mom());
40    
41     // Check whether it overlaps with a good muon: If the muon and cosmic both have
42     // tracker tracks then compare the tracks, otherwise
43     Bool_t isMuonOverlap = kFALSE;
44     if (CleanMuons) {
45     UInt_t n = CleanMuons->GetEntries();
46     for (UInt_t j=0; j<n; ++j) {
47     Double_t deltaR = MathUtils::DeltaR(CleanMuons->At(j)->Mom(), mom);
48     if (deltaR < 0.1) {
49     isMuonOverlap = kTRUE;
50     break;
51     }
52     }
53     } else {
54     cout << "Warning: GoodMuons collection " << fCleanMuonsName << " was not found.\n";
55     }
56    
57     if (isMuonOverlap)
58     continue;
59    
60     // Check whether it overlaps with another cosmic candidate:
61     bool isCosmicOverlap = kFALSE;
62     for (UInt_t j=0; j<CleanCosTemp.size(); ++j) {
63     Double_t deltaR = MathUtils::DeltaR(CleanCosTemp[j]->Mom(), mom);
64     if (deltaR < 0.1)
65     isCosmicOverlap = kTRUE;
66     }
67    
68     if (isCosmicOverlap)
69     continue;
70    
71     // if no overlaps then add to clean cosmics
72     CleanCosTemp.push_back(fCosmics->At(i));
73     }
74     } else {
75     cout << "Warning: fCosmics collection " << fCosmicsName << " was not found.\n";
76     }
77    
78     // Fill the muon array with the contents of the vector:
79     MuonOArr *CleanCosmics = new MuonOArr;
80     CleanCosmics->SetName(fCleanCosmicsName);
81    
82     for (UInt_t j=0; j<CleanCosTemp.size(); ++j) CleanCosmics->Add(CleanCosTemp[j]);
83     CleanCosmics->Sort();
84    
85     // add to event for other modules to use
86     AddObjThisEvt(CleanCosmics);
87     }
88    
89     //--------------------------------------------------------------------------------------------------
90     void CosmicCleaningMod::SlaveBegin()
91     {
92     ReqEventObject(fCosmicsName, fCosmics, kTRUE);
93    
94     }