ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/Morgan/src/ClusterAnalyzer.cc
Revision: 1.5
Committed: Wed Jun 10 11:17:06 2009 UTC (15 years, 10 months ago) by lethuill
Content type: text/plain
Branch: MAIN
CVS Tags: all_2_2_9_03, all_2_2_9_02, all_2_2_9_01
Branch point for: CMSSW_2_2_X_br
Changes since 1.4: +48 -36 lines
Log Message:
Better protection against missing collection / Cleaning data format selection / Last iteration for migration to PAT of Photons

File Contents

# User Rev Content
1 lethuill 1.3 #include "../interface/ClusterAnalyzer.h"
2 mlethuil 1.1
3     using namespace std;
4     using namespace reco;
5     using namespace edm;
6    
7 lethuill 1.4 ClusterAnalyzer::ClusterAnalyzer(const edm::ParameterSet& producersNames, int verbosity):verbosity_(verbosity), iClus_(0)
8 mlethuil 1.1 {
9 lethuill 1.5 dataType_ = producersNames.getUntrackedParameter<string>("dataType","unknown");
10     allowMissingCollection_ = producersNames.getUntrackedParameter<bool>("allowMissingCollection", false);
11 mlethuil 1.1 }
12 lethuill 1.4
13    
14 mlethuil 1.1 ClusterAnalyzer::~ClusterAnalyzer()
15     {
16     }
17    
18 lethuill 1.4
19 lethuill 1.5 bool ClusterAnalyzer::process(const edm::Event& iEvent, TRootEvent* rootEvent, EcalClusterLazyTools* lazyTools, TClonesArray* rootClusters, const string moduleLabel, const string instanceName, const int clusterType)
20 mlethuil 1.1 {
21 lethuill 1.5
22     unsigned int nBasicClusters=0;
23    
24     edm::Handle<reco::BasicClusterCollection> basicClustersHandle;
25     const reco::BasicClusterCollection *basicClusters = 0;
26     try
27     {
28     iEvent.getByLabel(moduleLabel, instanceName, basicClustersHandle);
29     nBasicClusters = basicClustersHandle->size();
30     basicClusters = basicClustersHandle.product();
31     }
32     catch (cms::Exception& exception)
33     {
34     if ( !allowMissingCollection_ )
35     {
36     cout << " ##### ERROR IN ClusterAnalyzer::process => reco::BasicCluster collection is missing #####"<<endl;
37     throw exception;
38     }
39     if(verbosity_>1) cout << " ===> No reco::BasicCluster collection, skip basic clusters info" << endl;
40     return false;
41     }
42    
43    
44     if(verbosity_>1) cout << endl << " Producer: " << moduleLabel << " : " << instanceName << " - Number of BasicClusters (type " << clusterType << ") = " << nBasicClusters << std::endl;
45    
46     Int_t iClusType=0;
47    
48     for( reco::BasicClusterCollection::const_iterator aClus = basicClusters->begin(); aClus != basicClusters->end(); aClus++)
49     {
50     TRootCluster localClus( aClus->energy(), aClus->eta(), aClus->phi(), aClus->x(), aClus->y(), aClus->z(), clusterType);
51     localClus.setE3x3( lazyTools->e3x3(*aClus) );
52     localClus.setE5x5( lazyTools->e5x5(*aClus) );
53     localClus.setEmax( lazyTools->eMax(*aClus) );
54     localClus.setE2nd( lazyTools->e2nd(*aClus) );
55     localClus.setNxtals( (aClus->getHitsByDetId()).size() );
56     localClus.setUid( (aClus->getHitsByDetId())[0] );
57    
58     new( (*rootClusters)[iClus_] ) TRootCluster(localClus);
59     if(verbosity_>3) cout << " ["<< setw(3) << iClus_ << "] " << localClus << endl;
60    
61     iClus_++;
62     iClusType++;
63     }
64     rootEvent->setNBasicClusters(clusterType,iClusType);
65     return true;
66 mlethuil 1.1 }