87 edm::LogInfo(
"UnifiedSC")<<
">>>>> Entering UnifiedSCCollectionProducer <<<<<";
102 edm::LogError(
"MissingInput") <<
"could not find clean super clusters";
128 edm::LogError(
"MissingInput")<<
"could not handle unclean super clusters!" ;
146 int uncleanSize = pUncleanSC->size();
147 int cleanSize = pCleanSC->size();
149 LogTrace(
"UnifiedSC") <<
"Size of Clean Collection: " << cleanSize
150 <<
", uncleanSize: " << uncleanSize;
154 std::vector<int> inUncleanOnlyInd;
155 std::vector<int> inCleanInd;
156 std::vector<int> inCleanOnlyInd;
157 std::vector<DetId> scUncleanSeedDetId;
158 std::vector<DetId> scCleanSeedDetId;
161 std::vector< std::pair<int, int> > basicClusterOwner;
162 std::vector< std::pair<int, int> > basicClusterOwnerUncleanOnly;
164 std::vector<int> uncleanBasicClusterIsSeed;
167 for (
int isc =0; isc< uncleanSize; ++isc) {
169 const std::vector< std::pair<DetId, float> > & uhits = unscRef->hitsAndFractions();
170 int uhitsSize = uhits.size();
171 bool foundTheSame =
false;
172 for (
int jsc=0; jsc < cleanSize; ++jsc) {
174 const std::vector<std::pair<DetId,float> > & chits = cscRef->hitsAndFractions();
175 int chitsSize = chits.size();
176 foundTheSame =
false;
177 if (unscRef->seed()->seed()==cscRef->seed()->seed() && chitsSize == uhitsSize) {
182 for (
int i=0;
i< chitsSize; ++
i) {
192 inUncleanOnlyInd.push_back(0);
193 inCleanInd.push_back(jsc);
194 scUncleanSeedDetId.push_back(unscRef->seed()->seed());
199 basicClusters.push_back(**bciter);
201 basicClusterOwner.push_back( std::make_pair(isc,0) );
206 if (not foundTheSame) {
208 inUncleanOnlyInd.push_back(1);
209 scUncleanSeedDetId.push_back(unscRef->seed()->seed());
213 basicClustersUncleanOnly.push_back(**bciter);
214 basicClusterOwnerUncleanOnly.push_back( std::make_pair(isc,0) );
219 int inCleanSize = inCleanInd.size();
223 for (
int jsc =0; jsc< cleanSize; ++jsc) {
225 bool takenAlready =
false;
226 for (
int j=0;
j< inCleanSize; ++
j) {
227 if (jsc == inCleanInd[
j]) { takenAlready =
true ;
break;}
230 inCleanOnlyInd.push_back(0);
231 scCleanSeedDetId.push_back(
DetId(0));
234 inCleanOnlyInd.push_back(1);
236 scCleanSeedDetId.push_back(cscRef->seed()->seed());
239 basicClusters.push_back(**bciter);
240 basicClusterOwner.push_back( std::make_pair(jsc,1) );
252 for (reco::BasicClusterCollection::const_iterator bc = pCleanBC->begin();
256 bool foundTheSame =
false;
257 for (reco::BasicClusterCollection::const_iterator cleanonly_bc = basicClusters.begin();
258 cleanonly_bc!=basicClusters.end();
261 const std::vector<std::pair<DetId,float> > & chits = bc->hitsAndFractions();
262 int chitsSize = chits.size();
264 const std::vector<std::pair<DetId,float> > & uhits = cleanonly_bc->hitsAndFractions();
265 int uhitsSize = uhits.size();
268 if (cleanonly_bc->seed()==bc->seed() && chitsSize == uhitsSize) {
270 for (
int i=0;
i< chitsSize; ++
i) {
283 basicClusters.push_back(*bc);
284 LogTrace(
"UnifiedSC")<<
"found BC to add that was not associated to any SC";
294 int bcSize = (int) basicClusterOwner.size();
295 int bcSizeUncleanOnly = (int) basicClustersUncleanOnly.size();
297 LogTrace(
"UnifiedSC") <<
"Found cleaned SC: " << cleanSize
298 <<
" uncleaned SC: " << uncleanSize ;
301 std::auto_ptr< reco::BasicClusterCollection>
303 basicClusters_p->assign(basicClusters.begin(), basicClusters.end());
308 edm::LogWarning(
"MissingInput")<<
"could not handle the new BasicClusters!";
313 LogTrace(
"UnifiedSC")<<
"Got the BasicClusters from the event again" ;
316 std::auto_ptr< reco::BasicClusterCollection>
318 basicClustersUncleanOnly_p->assign(basicClustersUncleanOnly.begin(),
319 basicClustersUncleanOnly.end());
322 if (!(bccHandleUncleanOnly.
isValid())) {
324 edm::LogWarning(
"MissingInput")<<
"could not handle the new BasicClusters (Unclean Only)!" ;
328 LogTrace(
"UnifiedSC")<<
"Got the BasicClusters from the event again (Unclean Only)" ;
336 for (
int isc=0; isc< uncleanSize; ++isc) {
340 if (inUncleanOnlyInd[isc] == 1) {
341 for (
int jbc=0; jbc< bcSizeUncleanOnly; ++jbc) {
342 std::pair<int, int> theBcOwner = basicClusterOwnerUncleanOnly[jbc];
343 if (theBcOwner.first == isc && theBcOwner.second == 0) {
346 if (scUncleanSeedDetId[isc] == currentClu->seed()) {
354 for (
int jbc=0; jbc< bcSize; ++jbc) {
355 std::pair<int, int> theBcOwner = basicClusterOwner[jbc];
356 if (theBcOwner.first == isc && theBcOwner.second == 0) {
359 if (scUncleanSeedDetId[isc] == currentClu->seed()) {
368 seed, clusterPtrVector );
370 if (inUncleanOnlyInd[isc] == 1) {
373 superClustersUncleanOnly.push_back(newSC);
378 superClusters.push_back(newSC);
390 for (
int jsc=0; jsc< cleanSize; ++jsc) {
393 if (inCleanOnlyInd[jsc] == 0)
continue;
397 for (
int jbc=0; jbc< bcSize; ++jbc) {
398 std::pair<int, int> theBcOwner = basicClusterOwner[jbc];
399 if (theBcOwner.first == jsc && theBcOwner.second == 1) {
402 if (scCleanSeedDetId[jsc] == currentClu->seed()) {
409 seed, clusterPtrVector );
413 superClusters.push_back(newSC);
423 LogTrace(
"UnifiedSC")<<
"New SC collection was created";
425 std::auto_ptr< reco::SuperClusterCollection>
427 superClusters_p->assign(superClusters.begin(), superClusters.end());
431 LogTrace(
"UnifiedSC") <<
"Clusters (Basic/Super) added to the Event! :-)";
433 std::auto_ptr< reco::SuperClusterCollection>
435 superClustersUncleanOnly_p->assign(superClustersUncleanOnly.begin(),
436 superClustersUncleanOnly.end());
444 LogTrace(
"UnifiedSC") <<
"Clean Collection SC ";
445 for (
int i=0;
i < cleanSize; ++
i) {
447 LogTrace(
"UnifiedSC") <<
" >>> clean #" <<
i <<
"; Energy: " << cscRef->energy()
448 <<
" eta: " << cscRef->eta()
449 <<
" sc seed detid: " << cscRef->seed()->seed().rawId()
453 LogTrace(
"UnifiedSC") <<
"Unclean Collection SC ";
454 for (
int i=0;
i < uncleanSize; ++
i) {
456 LogTrace(
"UnifiedSC") <<
" >>> unclean #" <<
i <<
"; Energy: " << uscRef->energy()
457 <<
" eta: " << uscRef->eta()
458 <<
" sc seed detid: " << uscRef->seed()->seed().rawId();
461 LogTrace(
"UnifiedSC")<<
"The new SC clean collection with size "<< superClusters.size() << std::endl;
463 int new_unclean = 0, new_clean=0;
464 for (
int i=0;
i < (int) superClusters.size(); ++
i) {
466 LogTrace(
"UnifiedSC") <<
"SC was got" << std::endl
467 <<
" ---> energy: " << nsc.
energy() << std::endl
468 <<
" ---> eta: " << nsc.
eta() << std::endl
469 <<
" ---> inClean: " << nsc.
isInClean() << std::endl
470 <<
" ---> id: " << nsc.
seed()->seed().rawId() << std::endl
471 <<
" >>> newSC #" <<
i <<
"; Energy: " << nsc.
energy()
472 <<
" eta: " << nsc.
eta() <<
" isClean="
474 <<
" sc seed detid: " << nsc.
seed()->seed().rawId();
479 LogTrace(
"UnifiedSC")<<
"The new SC unclean only collection with size "<< superClustersUncleanOnly.size();
480 for (
int i=0;
i < (int) superClustersUncleanOnly.size(); ++
i) {
482 LogTrace (
"UnifiedSC") <<
" >>> newSC #" <<
i <<
"; Energy: " << nsc.
energy()
483 <<
" eta: " << nsc.
eta() <<
" isClean="
485 <<
" sc seed detid: " << nsc.
seed()->seed().rawId();
489 if ( (new_unclean != uncleanSize) || (new_clean != cleanSize) ) {
490 LogTrace(
"UnifiedSC") <<
">>>>!!!!!! MISMATCH: new unclean/ old unclean= "
491 << new_unclean <<
" / " << uncleanSize
492 <<
", new clean/ old clean" << new_clean <<
" / " << cleanSize;
T getParameter(std::string const &) const
std::string scCollection_
virtual void produce(edm::Event &, const edm::EventSetup &)
edm::InputTag uncleanScCollection_
void push_back(Ptr< T > const &iPtr)
edm::Ptr< CaloCluster > CaloClusterPtr
double eta() const
pseudorapidity of cluster centroid
edm::InputTag uncleanBcCollection_
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_
edm::InputTag cleanBcCollection_
double energy() const
cluster energy
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
UnifiedSCCollectionProducer(const edm::ParameterSet &ps)
const CaloClusterPtr & seed() const
seed BasicCluster
~UnifiedSCCollectionProducer()
edm::InputTag cleanScCollection_
std::string bcCollectionUncleanOnly_