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 auto basicClusters_p = std::make_unique<reco::BasicClusterCollection>();
278 basicClusters_p->assign(basicClusters.begin(), basicClusters.end());
283 edm::LogWarning(
"MissingInput")<<
"could not handle the new BasicClusters!";
288 LogTrace(
"UnifiedSC")<<
"Got the BasicClusters from the event again" ;
291 auto basicClustersUncleanOnly_p = std::make_unique<reco::BasicClusterCollection>();
292 basicClustersUncleanOnly_p->assign(basicClustersUncleanOnly.begin(),
293 basicClustersUncleanOnly.end());
296 if (!(bccHandleUncleanOnly.
isValid())) {
298 edm::LogWarning(
"MissingInput")<<
"could not handle the new BasicClusters (Unclean Only)!" ;
302 LogTrace(
"UnifiedSC")<<
"Got the BasicClusters from the event again (Unclean Only)" ;
310 for (
int isc=0; isc< uncleanSize; ++isc) {
314 if (inUncleanOnlyInd[isc] == 1) {
315 for (
int jbc=0; jbc< bcSizeUncleanOnly; ++jbc) {
316 std::pair<int, int> theBcOwner = basicClusterOwnerUncleanOnly[jbc];
317 if (theBcOwner.first == isc && theBcOwner.second == 0) {
320 if (scUncleanSeedDetId[isc] == currentClu->seed()) {
328 for (
int jbc=0; jbc< bcSize; ++jbc) {
329 std::pair<int, int> theBcOwner = basicClusterOwner[jbc];
330 if (theBcOwner.first == isc && theBcOwner.second == 0) {
333 if (scUncleanSeedDetId[isc] == currentClu->seed()) {
342 seed, clusterPtrVector );
344 if (inUncleanOnlyInd[isc] == 1) {
347 superClustersUncleanOnly.push_back(newSC);
352 superClusters.push_back(newSC);
364 for (
int jsc=0; jsc< cleanSize; ++jsc) {
367 if (inCleanOnlyInd[jsc] == 0)
continue;
371 for (
int jbc=0; jbc< bcSize; ++jbc) {
372 std::pair<int, int> theBcOwner = basicClusterOwner[jbc];
373 if (theBcOwner.first == jsc && theBcOwner.second == 1) {
376 if (scCleanSeedDetId[jsc] == currentClu->seed()) {
383 seed, clusterPtrVector );
387 superClusters.push_back(newSC);
397 LogTrace(
"UnifiedSC")<<
"New SC collection was created";
399 auto superClusters_p = std::make_unique<reco::SuperClusterCollection>();
400 superClusters_p->assign(superClusters.begin(), superClusters.end());
404 LogTrace(
"UnifiedSC") <<
"Clusters (Basic/Super) added to the Event! :-)";
406 auto superClustersUncleanOnly_p = std::make_unique<reco::SuperClusterCollection>();
407 superClustersUncleanOnly_p->assign(superClustersUncleanOnly.begin(),
408 superClustersUncleanOnly.end());
416 LogTrace(
"UnifiedSC") <<
"Clean Collection SC ";
417 for (
int i=0;
i < cleanSize; ++
i) {
419 LogTrace(
"UnifiedSC") <<
" >>> clean #" <<
i <<
"; Energy: " << cscRef->energy()
420 <<
" eta: " << cscRef->eta()
421 <<
" sc seed detid: " << cscRef->seed()->seed().rawId()
425 LogTrace(
"UnifiedSC") <<
"Unclean Collection SC ";
426 for (
int i=0;
i < uncleanSize; ++
i) {
428 LogTrace(
"UnifiedSC") <<
" >>> unclean #" <<
i <<
"; Energy: " << uscRef->energy()
429 <<
" eta: " << uscRef->eta()
430 <<
" sc seed detid: " << uscRef->seed()->seed().rawId();
433 LogTrace(
"UnifiedSC")<<
"The new SC clean collection with size "<< superClusters.size() << std::endl;
435 int new_unclean = 0, new_clean=0;
436 for (
int i=0;
i < (
int) superClusters.size(); ++
i) {
438 LogTrace(
"UnifiedSC") <<
"SC was got" << std::endl
439 <<
" ---> energy: " << nsc.
energy() << std::endl
440 <<
" ---> eta: " << nsc.
eta() << std::endl
441 <<
" ---> inClean: " << nsc.
isInClean() << std::endl
442 <<
" ---> id: " << nsc.
seed()->seed().rawId() << std::endl
443 <<
" >>> newSC #" <<
i <<
"; Energy: " << nsc.
energy()
444 <<
" eta: " << nsc.
eta() <<
" isClean=" 446 <<
" sc seed detid: " << nsc.
seed()->seed().rawId();
451 LogTrace(
"UnifiedSC")<<
"The new SC unclean only collection with size "<< superClustersUncleanOnly.size();
452 for (
int i=0;
i < (
int) superClustersUncleanOnly.size(); ++
i) {
454 LogTrace (
"UnifiedSC") <<
" >>> newSC #" <<
i <<
"; Energy: " << nsc.
energy()
455 <<
" eta: " << nsc.
eta() <<
" isClean=" 457 <<
" sc seed detid: " << nsc.
seed()->seed().rawId();
461 if ( (new_unclean != uncleanSize) || (new_clean != cleanSize) ) {
462 LogTrace(
"UnifiedSC") <<
">>>>!!!!!! MISMATCH: new unclean/ old unclean= " 463 << new_unclean <<
" / " << uncleanSize
464 <<
", new clean/ old clean" << new_clean <<
" / " << cleanSize;
T getParameter(std::string const &) const
void produce(edm::Event &, const edm::EventSetup &) override
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< reco::SuperClusterCollection > uncleanScCollection_
std::string scCollection_
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
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_