79 edm::LogInfo(
"UnifiedSC") <<
">>>>> Entering UnifiedSCCollectionProducer <<<<<";
109 int uncleanSize = pUncleanSC->size();
110 int cleanSize = pCleanSC->size();
112 LogTrace(
"UnifiedSC") <<
"Size of Clean Collection: " << cleanSize <<
", uncleanSize: " << uncleanSize;
115 std::vector<int> inUncleanOnlyInd;
116 std::vector<int> inCleanInd;
117 std::vector<int> inCleanOnlyInd;
118 std::vector<DetId> scUncleanSeedDetId;
119 std::vector<DetId> scCleanSeedDetId;
122 std::vector<std::pair<int, int> > basicClusterOwner;
123 std::vector<std::pair<int, int> > basicClusterOwnerUncleanOnly;
125 std::vector<int> uncleanBasicClusterIsSeed;
128 for (
int isc = 0; isc < uncleanSize; ++isc) {
130 const std::vector<std::pair<DetId, float> >& uhits = unscRef->hitsAndFractions();
131 int uhitsSize = uhits.size();
132 bool foundTheSame =
false;
133 for (
int jsc = 0; jsc < cleanSize; ++jsc) {
135 const std::vector<std::pair<DetId, float> >& chits = cscRef->hitsAndFractions();
136 int chitsSize = chits.size();
137 foundTheSame =
false;
138 if (unscRef->seed()->seed() == cscRef->seed()->seed() && chitsSize == uhitsSize) {
143 for (
int i = 0;
i < chitsSize; ++
i) {
145 foundTheSame =
false;
152 inUncleanOnlyInd.push_back(0);
153 inCleanInd.push_back(jsc);
154 scUncleanSeedDetId.push_back(unscRef->seed()->seed());
159 basicClusters.push_back(**bciter);
161 basicClusterOwner.push_back(std::make_pair(isc, 0));
166 if (not foundTheSame) {
168 inUncleanOnlyInd.push_back(1);
169 scUncleanSeedDetId.push_back(unscRef->seed()->seed());
173 basicClustersUncleanOnly.push_back(**bciter);
174 basicClusterOwnerUncleanOnly.push_back(std::make_pair(isc, 0));
179 int inCleanSize = inCleanInd.size();
183 for (
int jsc = 0; jsc < cleanSize; ++jsc) {
185 bool takenAlready =
false;
186 for (
int j = 0;
j < inCleanSize; ++
j) {
187 if (jsc == inCleanInd[
j]) {
193 inCleanOnlyInd.push_back(0);
194 scCleanSeedDetId.push_back(
DetId(0));
197 inCleanOnlyInd.push_back(1);
199 scCleanSeedDetId.push_back(cscRef->seed()->seed());
202 basicClusters.push_back(**bciter);
203 basicClusterOwner.push_back(std::make_pair(jsc, 1));
214 for (reco::BasicClusterCollection::const_iterator bc = pCleanBC->begin(); bc != pCleanBC->end(); ++bc) {
215 bool foundTheSame =
false;
216 for (reco::BasicClusterCollection::const_iterator cleanonly_bc = basicClusters.begin();
217 cleanonly_bc != basicClusters.end();
219 const std::vector<std::pair<DetId, float> >& chits = bc->hitsAndFractions();
220 int chitsSize = chits.size();
222 const std::vector<std::pair<DetId, float> >& uhits = cleanonly_bc->hitsAndFractions();
223 int uhitsSize = uhits.size();
225 if (cleanonly_bc->seed() == bc->seed() && chitsSize == uhitsSize) {
227 for (
int i = 0;
i < chitsSize; ++
i) {
229 foundTheSame =
false;
240 basicClusters.push_back(*bc);
241 LogTrace(
"UnifiedSC") <<
"found BC to add that was not associated to any SC";
250 int bcSize = (
int)basicClusterOwner.size();
251 int bcSizeUncleanOnly = (
int)basicClustersUncleanOnly.size();
253 LogTrace(
"UnifiedSC") <<
"Found cleaned SC: " << cleanSize <<
" uncleaned SC: " << uncleanSize;
256 auto basicClusters_p = std::make_unique<reco::BasicClusterCollection>();
257 basicClusters_p->assign(basicClusters.begin(), basicClusters.end());
260 edm::LogWarning(
"MissingInput") <<
"could not handle the new BasicClusters!";
265 LogTrace(
"UnifiedSC") <<
"Got the BasicClusters from the event again";
268 auto basicClustersUncleanOnly_p = std::make_unique<reco::BasicClusterCollection>();
269 basicClustersUncleanOnly_p->assign(basicClustersUncleanOnly.begin(), basicClustersUncleanOnly.end());
272 if (!(bccHandleUncleanOnly.
isValid())) {
273 edm::LogWarning(
"MissingInput") <<
"could not handle the new BasicClusters (Unclean Only)!";
277 LogTrace(
"UnifiedSC") <<
"Got the BasicClusters from the event again (Unclean Only)";
285 for (
int isc = 0; isc < uncleanSize; ++isc) {
289 if (inUncleanOnlyInd[isc] == 1) {
290 for (
int jbc = 0; jbc < bcSizeUncleanOnly; ++jbc) {
291 std::pair<int, int> theBcOwner = basicClusterOwnerUncleanOnly[jbc];
292 if (theBcOwner.first == isc && theBcOwner.second == 0) {
295 if (scUncleanSeedDetId[isc] == currentClu->seed()) {
302 for (
int jbc = 0; jbc < bcSize; ++jbc) {
303 std::pair<int, int> theBcOwner = basicClusterOwner[jbc];
304 if (theBcOwner.first == isc && theBcOwner.second == 0) {
307 if (scUncleanSeedDetId[isc] == currentClu->seed()) {
317 if (inUncleanOnlyInd[isc] == 1) {
320 superClustersUncleanOnly.push_back(newSC);
324 superClusters.push_back(newSC);
336 for (
int jsc = 0; jsc < cleanSize; ++jsc) {
339 if (inCleanOnlyInd[jsc] == 0)
344 for (
int jbc = 0; jbc < bcSize; ++jbc) {
345 std::pair<int, int> theBcOwner = basicClusterOwner[jbc];
346 if (theBcOwner.first == jsc && theBcOwner.second == 1) {
349 if (scCleanSeedDetId[jsc] == currentClu->seed()) {
359 superClusters.push_back(newSC);
363 LogTrace(
"UnifiedSC") <<
"New SC collection was created";
365 auto superClusters_p = std::make_unique<reco::SuperClusterCollection>();
366 superClusters_p->assign(superClusters.begin(), superClusters.end());
370 LogTrace(
"UnifiedSC") <<
"Clusters (Basic/Super) added to the Event! :-)";
372 auto superClustersUncleanOnly_p = std::make_unique<reco::SuperClusterCollection>();
373 superClustersUncleanOnly_p->assign(superClustersUncleanOnly.begin(), superClustersUncleanOnly.end());
381 LogTrace(
"UnifiedSC") <<
"Clean Collection SC ";
382 for (
int i = 0;
i < cleanSize; ++
i) {
384 LogTrace(
"UnifiedSC") <<
" >>> clean #" <<
i <<
"; Energy: " << cscRef->energy() <<
" eta: " << cscRef->eta()
385 <<
" sc seed detid: " << cscRef->seed()->seed().rawId() << std::endl;
388 LogTrace(
"UnifiedSC") <<
"Unclean Collection SC ";
389 for (
int i = 0;
i < uncleanSize; ++
i) {
391 LogTrace(
"UnifiedSC") <<
" >>> unclean #" <<
i <<
"; Energy: " << uscRef->energy() <<
" eta: " << uscRef->eta()
392 <<
" sc seed detid: " << uscRef->seed()->seed().rawId();
395 LogTrace(
"UnifiedSC") <<
"The new SC clean collection with size " << superClusters.size() << std::endl;
397 int new_unclean = 0, new_clean = 0;
398 for (
int i = 0;
i < (
int)superClusters.size(); ++
i) {
400 LogTrace(
"UnifiedSC") <<
"SC was got" << std::endl
401 <<
" ---> energy: " << nsc.
energy() << std::endl
402 <<
" ---> eta: " << nsc.
eta() << std::endl
403 <<
" ---> inClean: " << nsc.
isInClean() << std::endl
404 <<
" ---> id: " << nsc.
seed()->seed().rawId() << std::endl
405 <<
" >>> newSC #" <<
i <<
"; Energy: " << nsc.
energy() <<
" eta: " << nsc.
eta()
407 <<
" sc seed detid: " << nsc.
seed()->seed().rawId();
414 LogTrace(
"UnifiedSC") <<
"The new SC unclean only collection with size " << superClustersUncleanOnly.size();
415 for (
int i = 0;
i < (
int)superClustersUncleanOnly.size(); ++
i) {
417 LogTrace(
"UnifiedSC") <<
" >>> newSC #" <<
i <<
"; Energy: " << nsc.
energy() <<
" eta: " << nsc.
eta()
419 <<
" sc seed detid: " << nsc.
seed()->seed().rawId();
425 if ((new_unclean != uncleanSize) || (new_clean != cleanSize)) {
426 LogTrace(
"UnifiedSC") <<
">>>>!!!!!! MISMATCH: new unclean/ old unclean= " << new_unclean <<
" / " << uncleanSize
427 <<
", new clean/ old clean" << new_clean <<
" / " << cleanSize;
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
const CaloClusterPtr & seed() const
seed BasicCluster
std::string bcCollectionUncleanOnly_