Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed non-const static for FastSimulation/L1CaloTriggerProducer/ #1421

Conversation

nclopezo
Copy link
Contributor

No description provided.

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @nclopezo (David Mendez) for CMSSW_7_0_X.

Fixed non-const static for FastSimulation/L1CaloTriggerProducer/

It involves the following packages:

FastSimulation/L1CaloTriggerProducer

@cmsbuild, @nclopezo, @giamman, @lveldere can you please review it and eventually sign? Thanks.
You can sign-off by replying to this message having '+1' in the first line of your reply.
You can reject by replying to this message having '-1' in the first line of your reply.
@ktf you are the release manager for this.

@@ -562,7 +562,7 @@
// rest are vetoed; 5=0101;7=0111;9=1001;10=1010;11=1011;13=1101;14=1110;15=1111
// --- Alternate patterns
// --- 9=1001;15=1111
static std::vector<unsigned> vetoPatterns;
std::vector<unsigned> vetoPatterns;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest changing this to

  static const std::vector<unsigned> vetoPatterns = { 5, 7, 9, 10,11,13,14,15};
    vetoPatterns.push_back(5);
    vetoPatterns.push_back(7);
    vetoPatterns.push_back(9);
    vetoPatterns.push_back(10);
    vetoPatterns.push_back(11);
    vetoPatterns.push_back(13);
    vetoPatterns.push_back(14);
    vetoPatterns.push_back(15);
  };

Where you actually move the declaration of vetoPatterns to be just before the function which uses it. This will make it a file scope static which the compiler can create and initialize outside the body of the function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the previous comment, remove the vetoPatterns.push_back(..); lines. Those were a cut-n-paste error. All you want is

static const std::vector<unsigned> vetoPatterns = { 5, 7, 9, 10,11,13,14,15};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it ok if I do this?

static const std::vector<unsigned> vetoPatterns = { 5, 7, 9, 10,11,13,14,15};

  for(std::vector<unsigned>::const_iterator i = vetoPatterns.begin();
      i != vetoPatterns.end();  i++) {
....

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will work. However a function local static requires the compiler to add a lot of overhead code in order to initialize the value in a thread-safe manner. By moving the 'static const' outside of the function you avoid all that extra work.

@cmsbuild
Copy link
Contributor

Pull request #1421 was updated. @cmsbuild, @nclopezo, @giamman, @lveldere can you please check and sign again.

@giamman
Copy link
Contributor

giamman commented Nov 13, 2013

+1

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next IBs unless changes or unless it breaks tests. @ktf can you please take care of it?

@cmsbuild
Copy link
Contributor

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next IBs unless changes or unless it breaks tests. @ktf can you please take care of it?

@ktf
Copy link
Contributor

ktf commented Nov 13, 2013

@nclopezo: Notice that in C++11 you can use the "auto" keyword in place of the iterators.

ktf added a commit that referenced this pull request Nov 13, 2013
…ionL1CaloTriggerProducer

Multithreading fixes -- Fixed non-const static for FastSimulation/L1CaloTriggerProducer
@ktf ktf merged commit 9233521 into cms-sw:CMSSW_7_0_X Nov 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants