92 edm::LogInfo(
"UnifiedSC")<<
">>>>> Entering UnifiedSCCollectionProducer <<<<<";
122 int uncleanSize = pUncleanSC->size();
123 int cleanSize = pCleanSC->size();
125 LogTrace(
"UnifiedSC") <<
"Size of Clean Collection: " << cleanSize
126 <<
", uncleanSize: " << uncleanSize;
130 std::vector<int> inUncleanOnlyInd;
131 std::vector<int> inCleanInd;
132 std::vector<int> inCleanOnlyInd;
133 std::vector<DetId> scUncleanSeedDetId;
134 std::vector<DetId> scCleanSeedDetId;
137 std::vector< std::pair<int, int> > basicClusterOwner;
138 std::vector< std::pair<int, int> > basicClusterOwnerUncleanOnly;
140 std::vector<int> uncleanBasicClusterIsSeed;
143 for (
int isc =0; isc< uncleanSize; ++isc) {
145 const std::vector< std::pair<DetId, float> > & uhits = unscRef->hitsAndFractions();
146 int uhitsSize = uhits.size();
147 bool foundTheSame =
false;
148 for (
int jsc=0; jsc < cleanSize; ++jsc) {
150 const std::vector<std::pair<DetId,float> > & chits = cscRef->hitsAndFractions();
151 int chitsSize = chits.size();
152 foundTheSame =
false;
153 if (unscRef->seed()->seed()==cscRef->seed()->seed() && chitsSize == uhitsSize) {
158 for (
int i=0;
i< chitsSize; ++
i) {
168 inUncleanOnlyInd.push_back(0);
169 inCleanInd.push_back(jsc);
170 scUncleanSeedDetId.push_back(unscRef->seed()->seed());
175 basicClusters.push_back(**bciter);
177 basicClusterOwner.push_back( std::make_pair(isc,0) );
182 if (not foundTheSame) {
184 inUncleanOnlyInd.push_back(1);
185 scUncleanSeedDetId.push_back(unscRef->seed()->seed());
189 basicClustersUncleanOnly.push_back(**bciter);
190 basicClusterOwnerUncleanOnly.push_back( std::make_pair(isc,0) );
195 int inCleanSize = inCleanInd.size();
199 for (
int jsc =0; jsc< cleanSize; ++jsc) {
201 bool takenAlready =
false;
202 for (
int j=0;
j< inCleanSize; ++
j) {
203 if (jsc == inCleanInd[
j]) { takenAlready =
true ;
break;}
206 inCleanOnlyInd.push_back(0);
207 scCleanSeedDetId.push_back(
DetId(0));
210 inCleanOnlyInd.push_back(1);
212 scCleanSeedDetId.push_back(cscRef->seed()->seed());
215 basicClusters.push_back(**bciter);
216 basicClusterOwner.push_back( std::make_pair(jsc,1) );
228 for (reco::BasicClusterCollection::const_iterator bc = pCleanBC->begin();
232 bool foundTheSame =
false;
233 for (reco::BasicClusterCollection::const_iterator cleanonly_bc = basicClusters.begin();
234 cleanonly_bc!=basicClusters.end();
237 const std::vector<std::pair<DetId,float> > & chits = bc->hitsAndFractions();
238 int chitsSize = chits.size();
240 const std::vector<std::pair<DetId,float> > & uhits = cleanonly_bc->hitsAndFractions();
241 int uhitsSize = uhits.size();
244 if (cleanonly_bc->seed()==bc->seed() && chitsSize == uhitsSize) {
246 for (
int i=0;
i< chitsSize; ++
i) {
259 basicClusters.push_back(*bc);
260 LogTrace(
"UnifiedSC")<<
"found BC to add that was not associated to any SC";
270 int bcSize = (int) basicClusterOwner.size();
271 int bcSizeUncleanOnly = (int) basicClustersUncleanOnly.size();
273 LogTrace(
"UnifiedSC") <<
"Found cleaned SC: " << cleanSize
274 <<
" uncleaned SC: " << uncleanSize ;
277 std::auto_ptr< reco::BasicClusterCollection>
279 basicClusters_p->assign(basicClusters.begin(), basicClusters.end());
284 edm::LogWarning(
"MissingInput")<<
"could not handle the new BasicClusters!";
289 LogTrace(
"UnifiedSC")<<
"Got the BasicClusters from the event again" ;
292 std::auto_ptr< reco::BasicClusterCollection>
294 basicClustersUncleanOnly_p->assign(basicClustersUncleanOnly.begin(),
295 basicClustersUncleanOnly.end());
298 if (!(bccHandleUncleanOnly.
isValid())) {
300 edm::LogWarning(
"MissingInput")<<
"could not handle the new BasicClusters (Unclean Only)!" ;
304 LogTrace(
"UnifiedSC")<<
"Got the BasicClusters from the event again (Unclean Only)" ;
312 for (
int isc=0; isc< uncleanSize; ++isc) {
316 if (inUncleanOnlyInd[isc] == 1) {
317 for (
int jbc=0; jbc< bcSizeUncleanOnly; ++jbc) {
318 std::pair<int, int> theBcOwner = basicClusterOwnerUncleanOnly[jbc];
319 if (theBcOwner.first == isc && theBcOwner.second == 0) {
322 if (scUncleanSeedDetId[isc] == currentClu->seed()) {
330 for (
int jbc=0; jbc< bcSize; ++jbc) {
331 std::pair<int, int> theBcOwner = basicClusterOwner[jbc];
332 if (theBcOwner.first == isc && theBcOwner.second == 0) {
335 if (scUncleanSeedDetId[isc] == currentClu->seed()) {
344 seed, clusterPtrVector );
346 if (inUncleanOnlyInd[isc] == 1) {
349 superClustersUncleanOnly.push_back(newSC);
354 superClusters.push_back(newSC);
366 for (
int jsc=0; jsc< cleanSize; ++jsc) {
369 if (inCleanOnlyInd[jsc] == 0)
continue;
373 for (
int jbc=0; jbc< bcSize; ++jbc) {
374 std::pair<int, int> theBcOwner = basicClusterOwner[jbc];
375 if (theBcOwner.first == jsc && theBcOwner.second == 1) {
378 if (scCleanSeedDetId[jsc] == currentClu->seed()) {
385 seed, clusterPtrVector );
389 superClusters.push_back(newSC);
399 LogTrace(
"UnifiedSC")<<
"New SC collection was created";
401 std::auto_ptr< reco::SuperClusterCollection>
403 superClusters_p->assign(superClusters.begin(), superClusters.end());
407 LogTrace(
"UnifiedSC") <<
"Clusters (Basic/Super) added to the Event! :-)";
409 std::auto_ptr< reco::SuperClusterCollection>
411 superClustersUncleanOnly_p->assign(superClustersUncleanOnly.begin(),
412 superClustersUncleanOnly.end());
420 LogTrace(
"UnifiedSC") <<
"Clean Collection SC ";
421 for (
int i=0;
i < cleanSize; ++
i) {
423 LogTrace(
"UnifiedSC") <<
" >>> clean #" <<
i <<
"; Energy: " << cscRef->energy()
424 <<
" eta: " << cscRef->eta()
425 <<
" sc seed detid: " << cscRef->seed()->seed().rawId()
429 LogTrace(
"UnifiedSC") <<
"Unclean Collection SC ";
430 for (
int i=0;
i < uncleanSize; ++
i) {
432 LogTrace(
"UnifiedSC") <<
" >>> unclean #" <<
i <<
"; Energy: " << uscRef->energy()
433 <<
" eta: " << uscRef->eta()
434 <<
" sc seed detid: " << uscRef->seed()->seed().rawId();
437 LogTrace(
"UnifiedSC")<<
"The new SC clean collection with size "<< superClusters.size() << std::endl;
439 int new_unclean = 0, new_clean=0;
440 for (
int i=0;
i < (int) superClusters.size(); ++
i) {
442 LogTrace(
"UnifiedSC") <<
"SC was got" << std::endl
443 <<
" ---> energy: " << nsc.
energy() << std::endl
444 <<
" ---> eta: " << nsc.
eta() << std::endl
445 <<
" ---> inClean: " << nsc.
isInClean() << std::endl
446 <<
" ---> id: " << nsc.
seed()->seed().rawId() << std::endl
447 <<
" >>> newSC #" <<
i <<
"; Energy: " << nsc.
energy()
448 <<
" eta: " << nsc.
eta() <<
" isClean="
450 <<
" sc seed detid: " << nsc.
seed()->seed().rawId();
455 LogTrace(
"UnifiedSC")<<
"The new SC unclean only collection with size "<< superClustersUncleanOnly.size();
456 for (
int i=0;
i < (int) superClustersUncleanOnly.size(); ++
i) {
458 LogTrace (
"UnifiedSC") <<
" >>> newSC #" <<
i <<
"; Energy: " << nsc.
energy()
459 <<
" eta: " << nsc.
eta() <<
" isClean="
461 <<
" sc seed detid: " << nsc.
seed()->seed().rawId();
465 if ( (new_unclean != uncleanSize) || (new_clean != cleanSize) ) {
466 LogTrace(
"UnifiedSC") <<
">>>>!!!!!! MISMATCH: new unclean/ old unclean= "
467 << new_unclean <<
" / " << uncleanSize
468 <<
", new clean/ old clean" << new_clean <<
" / " << cleanSize;
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::SuperClusterCollection > uncleanScCollection_
std::string scCollection_
virtual void produce(edm::Event &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void push_back(Ptr< T > const &iPtr)
edm::Ptr< CaloCluster > CaloClusterPtr
double eta() const
pseudorapidity of cluster centroid
void setFlags(uint32_t flags)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
std::string scCollectionUncleanOnly_
std::string bcCollection_
double energy() const
cluster energy
edm::EDGetTokenT< reco::BasicClusterCollection > uncleanBcCollection_
edm::EDGetTokenT< reco::SuperClusterCollection > cleanScCollection_
edm::EDGetTokenT< reco::BasicClusterCollection > cleanBcCollection_
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
UnifiedSCCollectionProducer(const edm::ParameterSet &ps)
const CaloClusterPtr & seed() const
seed BasicCluster
std::string bcCollectionUncleanOnly_