CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
EBCosmicTask Class Reference

#include <EBCosmicTask.h>

Inheritance diagram for EBCosmicTask:
edm::EDAnalyzer

Public Member Functions

 EBCosmicTask (const edm::ParameterSet &ps)
 Constructor. More...
 
virtual ~EBCosmicTask ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 Analyze. More...
 
void beginJob (void)
 BeginJob. More...
 
void beginRun (const edm::Run &r, const edm::EventSetup &c)
 BeginRun. More...
 
void cleanup (void)
 Cleanup. More...
 
void endJob (void)
 EndJob. More...
 
void endRun (const edm::Run &r, const edm::EventSetup &c)
 EndRun. More...
 
void reset (void)
 Reset. More...
 
void setup (void)
 Setup. More...
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Private Attributes

DQMStoredqmStore_
 
edm::InputTag EcalRawDataCollection_
 
edm::InputTag EcalRecHitCollection_
 
edm::InputTag EcalUncalibratedRecHitCollection_
 
bool enableCleanup_
 
int ievt_
 
bool init_
 
double maxJitter_
 
MonitorElementmeCutMap_ [36]
 
bool mergeRuns_
 
MonitorElementmeSelMap_ [36]
 
MonitorElementmeSpectrum_ [2][36]
 
double minJitter_
 
std::string prefixME_
 
double threshold_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

Definition at line 20 of file EBCosmicTask.h.

Constructor & Destructor Documentation

EBCosmicTask::EBCosmicTask ( const edm::ParameterSet ps)

Constructor.

Definition at line 29 of file EBCosmicTask.cc.

References dqmStore_, EcalRawDataCollection_, EcalRecHitCollection_, EcalUncalibratedRecHitCollection_, enableCleanup_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), i, init_, maxJitter_, mergeRuns_, meSelMap_, meSpectrum_, minJitter_, cppFunctionSkipper::operator, prefixME_, and threshold_.

29  {
30 
31  init_ = false;
32 
34 
35  prefixME_ = ps.getUntrackedParameter<std::string>("prefixME", "");
36 
37  enableCleanup_ = ps.getUntrackedParameter<bool>("enableCleanup", false);
38 
39  mergeRuns_ = ps.getUntrackedParameter<bool>("mergeRuns", false);
40 
41  EcalRawDataCollection_ = ps.getParameter<edm::InputTag>("EcalRawDataCollection");
42  EcalUncalibratedRecHitCollection_ = ps.getParameter<edm::InputTag>("EcalUncalibratedRecHitCollection");
43  EcalRecHitCollection_ = ps.getParameter<edm::InputTag>("EcalRecHitCollection");
44 
45  threshold_ = 0.12500; // typical muon energy deposit is 250 MeV
46 
47  minJitter_ = -2.0;
48  maxJitter_ = 1.5;
49 
50  for (int i = 0; i < 36; i++) {
51  meSelMap_[i] = 0;
52  meSpectrum_[0][i] = 0;
53  meSpectrum_[1][i] = 0;
54  }
55 
56 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::string prefixME_
Definition: EBCosmicTask.h:62
double threshold_
Definition: EBCosmicTask.h:78
double minJitter_
Definition: EBCosmicTask.h:79
DQMStore * dqmStore_
Definition: EBCosmicTask.h:60
edm::InputTag EcalRecHitCollection_
Definition: EBCosmicTask.h:70
edm::InputTag EcalUncalibratedRecHitCollection_
Definition: EBCosmicTask.h:69
MonitorElement * meSelMap_[36]
Definition: EBCosmicTask.h:74
MonitorElement * meSpectrum_[2][36]
Definition: EBCosmicTask.h:76
bool enableCleanup_
Definition: EBCosmicTask.h:64
edm::InputTag EcalRawDataCollection_
Definition: EBCosmicTask.h:68
double maxJitter_
Definition: EBCosmicTask.h:80
EBCosmicTask::~EBCosmicTask ( )
virtual

Destructor.

Definition at line 58 of file EBCosmicTask.cc.

58  {
59 
60 }

Member Function Documentation

void EBCosmicTask::analyze ( const edm::Event e,
const edm::EventSetup c 
)
protectedvirtual

Analyze.

Implements edm::EDAnalyzer.

Definition at line 168 of file EBCosmicTask.cc.

References EcalDCCHeaderBlock::COSMIC, EcalDCCHeaderBlock::COSMICS_GLOBAL, EcalDCCHeaderBlock::COSMICS_LOCAL, EcalBarrel, EcalRawDataCollection_, EcalRecHitCollection_, EcalUncalibratedRecHitCollection_, EBDetId::ETAPHIMODE, MonitorElement::Fill(), edm::Event::getByLabel(), i, EBDetId::ic(), ievt_, init_, ecalpyutils::ism(), Numbers::iSM(), edm::HandleBase::isValid(), LogDebug, maxJitter_, meSelMap_, meSpectrum_, minJitter_, EcalDCCHeaderBlock::MTCC, EcalDCCHeaderBlock::PHYSICS_GLOBAL, EcalDCCHeaderBlock::PHYSICS_LOCAL, environment_file_cff::runType, setup(), Numbers::subDet(), threshold_, and EBDetId::validDetId().

168  {
169 
170  bool isData = true;
171  bool enable = false;
172  int runType[36];
173  for (int i=0; i<36; i++) runType[i] = -1;
174 
176 
177  if ( e.getByLabel(EcalRawDataCollection_, dcchs) ) {
178 
179  for ( EcalRawDataCollection::const_iterator dcchItr = dcchs->begin(); dcchItr != dcchs->end(); ++dcchItr ) {
180 
181  if ( Numbers::subDet( *dcchItr ) != EcalBarrel ) continue;
182 
183  int ism = Numbers::iSM( *dcchItr, EcalBarrel );
184 
185  runType[ism-1] = dcchItr->getRunType();
186 
187  if ( dcchItr->getRunType() == EcalDCCHeaderBlock::COSMIC ||
188  dcchItr->getRunType() == EcalDCCHeaderBlock::MTCC ||
189  dcchItr->getRunType() == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
190  dcchItr->getRunType() == EcalDCCHeaderBlock::PHYSICS_GLOBAL ||
191  dcchItr->getRunType() == EcalDCCHeaderBlock::COSMICS_LOCAL ||
192  dcchItr->getRunType() == EcalDCCHeaderBlock::PHYSICS_LOCAL ) enable = true;
193 
194  }
195 
196  } else {
197 
198  isData = false; enable = true;
199  edm::LogWarning("EBCosmicTask") << EcalRawDataCollection_ << " not available";
200 
201  }
202 
203  if ( ! enable ) return;
204 
205  if ( ! init_ ) this->setup();
206 
207  ievt_++;
208 
210 
211  if ( e.getByLabel(EcalRecHitCollection_, hits) ) {
212 
213  int nebh = hits->size();
214  LogDebug("EBCosmicTask") << "event " << ievt_ << " hits collection size " << nebh;
215 
217 
218  if ( ! e.getByLabel(EcalUncalibratedRecHitCollection_, uhits) ) {
219  edm::LogWarning("EBCosmicTask") << EcalUncalibratedRecHitCollection_ << " not available";
220  }
221 
222  for ( EcalRecHitCollection::const_iterator hitItr = hits->begin(); hitItr != hits->end(); ++hitItr ) {
223 
224  EBDetId id = hitItr->id();
225 
226  int ic = id.ic();
227  int ie = (ic-1)/20 + 1;
228  int ip = (ic-1)%20 + 1;
229 
230  int ism = Numbers::iSM( id );
231 
232  float xie = ie - 0.5;
233  float xip = ip - 0.5;
234 
235  if ( isData ) {
236 
237  if ( ! ( runType[ism-1] == EcalDCCHeaderBlock::COSMIC ||
238  runType[ism-1] == EcalDCCHeaderBlock::MTCC ||
239  runType[ism-1] == EcalDCCHeaderBlock::COSMICS_GLOBAL ||
240  runType[ism-1] == EcalDCCHeaderBlock::PHYSICS_GLOBAL ||
241  runType[ism-1] == EcalDCCHeaderBlock::COSMICS_LOCAL ||
242  runType[ism-1] == EcalDCCHeaderBlock::PHYSICS_LOCAL ) ) continue;
243 
244  }
245 
246  float xval = hitItr->energy();
247  if ( xval <= 0. ) xval = 0.0;
248 
249  // look for the seeds
250  float e3x3 = 0.;
251  bool isSeed = true;
252 
253  // evaluate 3x3 matrix around a seed
254  for(int icry=0; icry<9; ++icry) {
255  unsigned int row = icry/3;
256  unsigned int column = icry%3;
257  int icryEta = id.ieta()+column-1;
258  int icryPhi = id.iphi()+row-1;
259  if ( EBDetId::validDetId(icryEta, icryPhi) ) {
260  EBDetId id3x3 = EBDetId(icryEta, icryPhi, EBDetId::ETAPHIMODE);
261  if ( hits->find(id3x3) != hits->end() ) {
262  float neighbourEnergy = hits->find(id3x3)->energy();
263  e3x3 += neighbourEnergy;
264  if ( neighbourEnergy > xval ) isSeed = false;
265  }
266  }
267  }
268 
269  // find the jitter of the seed
270  float jitter = -999.;
271  if ( isSeed ) {
272  if ( uhits.isValid() ) {
273  if ( uhits->find(id) != uhits->end() ) {
274  jitter = uhits->find(id)->jitter();
275  }
276  }
277  }
278 
279  if ( isSeed && e3x3 >= threshold_ && jitter > minJitter_ && jitter < maxJitter_ ) {
280  if ( meSelMap_[ism-1] ) meSelMap_[ism-1]->Fill(xie, xip, e3x3);
281  }
282 
283  if ( meSpectrum_[0][ism-1] ) meSpectrum_[0][ism-1]->Fill(xval);
284 
285  if ( isSeed && xval >= threshold_ && jitter > minJitter_ && jitter < maxJitter_ ) {
286  if ( meSpectrum_[1][ism-1] ) meSpectrum_[1][ism-1]->Fill(e3x3);
287  }
288 
289  }
290 
291  } else {
292 
293  edm::LogWarning("EBCosmicTask") << EcalRecHitCollection_ << " not available";
294 
295  }
296 
297 }
#define LogDebug(id)
static bool validDetId(int i, int j)
check if a valid index combination
Definition: EBDetId.cc:59
int i
Definition: DBlmapReader.cc:9
std::vector< T >::const_iterator const_iterator
void setup(void)
Setup.
Definition: EBCosmicTask.cc:95
double threshold_
Definition: EBCosmicTask.h:78
double minJitter_
Definition: EBCosmicTask.h:79
void Fill(long long x)
edm::InputTag EcalRecHitCollection_
Definition: EBCosmicTask.h:70
edm::InputTag EcalUncalibratedRecHitCollection_
Definition: EBCosmicTask.h:69
MonitorElement * meSelMap_[36]
Definition: EBCosmicTask.h:74
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
static const int ETAPHIMODE
Definition: EBDetId.h:145
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:94
MonitorElement * meSpectrum_[2][36]
Definition: EBCosmicTask.h:76
edm::InputTag EcalRawDataCollection_
Definition: EBCosmicTask.h:68
static unsigned iSM(const unsigned ism, const EcalSubdetector subdet)
Definition: Numbers.cc:246
static EcalSubdetector subDet(const EBDetId &id)
Definition: Numbers.cc:145
double maxJitter_
Definition: EBCosmicTask.h:80
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
void EBCosmicTask::beginJob ( void  )
protectedvirtual

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 62 of file EBCosmicTask.cc.

References dqmStore_, ievt_, prefixME_, DQMStore::rmdir(), and DQMStore::setCurrentFolder().

62  {
63 
64  ievt_ = 0;
65 
66  if ( dqmStore_ ) {
67  dqmStore_->setCurrentFolder(prefixME_ + "/EBCosmicTask");
68  dqmStore_->rmdir(prefixME_ + "/EBCosmicTask");
69  }
70 
71 }
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2530
std::string prefixME_
Definition: EBCosmicTask.h:62
DQMStore * dqmStore_
Definition: EBCosmicTask.h:60
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
void EBCosmicTask::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
protectedvirtual

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 73 of file EBCosmicTask.cc.

References Numbers::initGeometry(), mergeRuns_, and reset().

73  {
74 
75  Numbers::initGeometry(c, false);
76 
77  if ( ! mergeRuns_ ) this->reset();
78 
79 }
void reset(void)
Reset.
Definition: EBCosmicTask.cc:85
static void initGeometry(const edm::EventSetup &setup, bool verbose=false)
Definition: Numbers.cc:50
void EBCosmicTask::cleanup ( void  )
protected

Cleanup.

Definition at line 127 of file EBCosmicTask.cc.

References dqmStore_, edm::getName(), i, init_, meCutMap_, meSelMap_, meSpectrum_, prefixME_, DQMStore::removeElement(), and DQMStore::setCurrentFolder().

Referenced by endJob().

127  {
128 
129  if ( ! init_ ) return;
130 
131  if ( dqmStore_ ) {
132  dqmStore_->setCurrentFolder(prefixME_ + "/EBCosmicTask");
133 
134  dqmStore_->setCurrentFolder(prefixME_ + "/EBCosmicTask/Cut");
135  for (int i = 0; i < 36; i++) {
137  meCutMap_[i] = 0;
138  }
139 
140  dqmStore_->setCurrentFolder(prefixME_ + "/EBCosmicTask/Sel");
141  for (int i = 0; i < 36; i++) {
142  if ( meSelMap_[i] ) dqmStore_->removeElement( meSelMap_[i]->getName() );
143  meSelMap_[i] = 0;
144  }
145 
146  dqmStore_->setCurrentFolder(prefixME_ + "/EBCosmicTask/Spectrum");
147  for (int i = 0; i < 36; i++) {
148  if ( meSpectrum_[0][i] ) dqmStore_->removeElement( meSpectrum_[0][i]->getName() );
149  meSpectrum_[0][i] = 0;
150  if ( meSpectrum_[1][i] ) dqmStore_->removeElement( meSpectrum_[1][i]->getName() );
151  meSpectrum_[1][i] = 0;
152  }
153 
154  }
155 
156  init_ = false;
157 
158 }
int i
Definition: DBlmapReader.cc:9
std::string prefixME_
Definition: EBCosmicTask.h:62
DQMStore * dqmStore_
Definition: EBCosmicTask.h:60
void removeElement(const std::string &name)
Definition: DQMStore.cc:2572
MonitorElement * meSelMap_[36]
Definition: EBCosmicTask.h:74
std::string getName(Reflex::Type &cc)
Definition: ClassFiller.cc:18
MonitorElement * meCutMap_[36]
Definition: EBCosmicTask.h:72
MonitorElement * meSpectrum_[2][36]
Definition: EBCosmicTask.h:76
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
void EBCosmicTask::endJob ( void  )
protectedvirtual

EndJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 160 of file EBCosmicTask.cc.

References cleanup(), enableCleanup_, and ievt_.

160  {
161 
162  edm::LogInfo("EBCosmicTask") << "analyzed " << ievt_ << " events";
163 
164  if ( enableCleanup_ ) this->cleanup();
165 
166 }
void cleanup(void)
Cleanup.
bool enableCleanup_
Definition: EBCosmicTask.h:64
void EBCosmicTask::endRun ( const edm::Run r,
const edm::EventSetup c 
)
protectedvirtual

EndRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 81 of file EBCosmicTask.cc.

81  {
82 
83 }
void EBCosmicTask::reset ( void  )
protected

Reset.

Definition at line 85 of file EBCosmicTask.cc.

References i, meSelMap_, meSpectrum_, and MonitorElement::Reset().

Referenced by beginRun().

85  {
86 
87  for (int i = 0; i < 36; i++) {
88  if ( meSelMap_[i] ) meSelMap_[i]->Reset();
89  if ( meSpectrum_[0][i] ) meSpectrum_[0][i]->Reset();
90  if ( meSpectrum_[1][i] ) meSpectrum_[1][i]->Reset();
91  }
92 
93 }
int i
Definition: DBlmapReader.cc:9
MonitorElement * meSelMap_[36]
Definition: EBCosmicTask.h:74
MonitorElement * meSpectrum_[2][36]
Definition: EBCosmicTask.h:76
void Reset(void)
reset ME (ie. contents, errors, etc)
void EBCosmicTask::setup ( void  )
protected

Setup.

Definition at line 95 of file EBCosmicTask.cc.

References DQMStore::book1D(), DQMStore::bookProfile2D(), dqmStore_, i, init_, meSelMap_, meSpectrum_, mergeVDriftHistosByStation::name, prefixME_, Numbers::sEB(), MonitorElement::setAxisTitle(), and DQMStore::setCurrentFolder().

Referenced by analyze().

95  {
96 
97  init_ = true;
98 
99  std::string name;
100 
101  if ( dqmStore_ ) {
102  dqmStore_->setCurrentFolder(prefixME_ + "/EBCosmicTask");
103 
104  dqmStore_->setCurrentFolder(prefixME_ + "/EBCosmicTask/Sel");
105  for (int i = 0; i < 36; i++) {
106  name = "EBCT energy sel " + Numbers::sEB(i+1);
107  meSelMap_[i] = dqmStore_->bookProfile2D(name, name, 85, 0., 85., 20, 0., 20., 4096, 0., 4096., "s");
108  meSelMap_[i]->setAxisTitle("ieta", 1);
109  meSelMap_[i]->setAxisTitle("iphi", 2);
110  meSelMap_[i]->setAxisTitle("energy (GeV)", 3);
111  }
112 
113  dqmStore_->setCurrentFolder(prefixME_ + "/EBCosmicTask/Spectrum");
114  for (int i = 0; i < 36; i++) {
115  name = "EBCT 1x1 energy spectrum " + Numbers::sEB(i+1);
116  meSpectrum_[0][i] = dqmStore_->book1D(name, name, 100, 0., 1.5);
117  meSpectrum_[0][i]->setAxisTitle("energy (GeV)", 1);
118  name = "EBCT 3x3 energy spectrum " + Numbers::sEB(i+1);
119  meSpectrum_[1][i] = dqmStore_->book1D(name, name, 100, 0., 1.5);
120  meSpectrum_[1][i]->setAxisTitle("energy (GeV)", 1);
121  }
122 
123  }
124 
125 }
int i
Definition: DBlmapReader.cc:9
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
std::string prefixME_
Definition: EBCosmicTask.h:62
static std::string sEB(const unsigned ism)
Definition: Numbers.cc:94
DQMStore * dqmStore_
Definition: EBCosmicTask.h:60
MonitorElement * meSelMap_[36]
Definition: EBCosmicTask.h:74
MonitorElement * meSpectrum_[2][36]
Definition: EBCosmicTask.h:76
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
MonitorElement * bookProfile2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ, const char *option="s")
Definition: DQMStore.cc:1175

Member Data Documentation

DQMStore* EBCosmicTask::dqmStore_
private

Definition at line 60 of file EBCosmicTask.h.

Referenced by beginJob(), cleanup(), EBCosmicTask(), and setup().

edm::InputTag EBCosmicTask::EcalRawDataCollection_
private

Definition at line 68 of file EBCosmicTask.h.

Referenced by analyze(), and EBCosmicTask().

edm::InputTag EBCosmicTask::EcalRecHitCollection_
private

Definition at line 70 of file EBCosmicTask.h.

Referenced by analyze(), and EBCosmicTask().

edm::InputTag EBCosmicTask::EcalUncalibratedRecHitCollection_
private

Definition at line 69 of file EBCosmicTask.h.

Referenced by analyze(), and EBCosmicTask().

bool EBCosmicTask::enableCleanup_
private

Definition at line 64 of file EBCosmicTask.h.

Referenced by EBCosmicTask(), and endJob().

int EBCosmicTask::ievt_
private

Definition at line 58 of file EBCosmicTask.h.

Referenced by analyze(), beginJob(), and endJob().

bool EBCosmicTask::init_
private

Definition at line 82 of file EBCosmicTask.h.

Referenced by analyze(), cleanup(), EBCosmicTask(), and setup().

double EBCosmicTask::maxJitter_
private

Definition at line 80 of file EBCosmicTask.h.

Referenced by analyze(), and EBCosmicTask().

MonitorElement* EBCosmicTask::meCutMap_[36]
private

Definition at line 72 of file EBCosmicTask.h.

Referenced by cleanup().

bool EBCosmicTask::mergeRuns_
private

Definition at line 66 of file EBCosmicTask.h.

Referenced by beginRun(), and EBCosmicTask().

MonitorElement* EBCosmicTask::meSelMap_[36]
private

Definition at line 74 of file EBCosmicTask.h.

Referenced by analyze(), cleanup(), EBCosmicTask(), reset(), and setup().

MonitorElement* EBCosmicTask::meSpectrum_[2][36]
private

Definition at line 76 of file EBCosmicTask.h.

Referenced by analyze(), cleanup(), EBCosmicTask(), reset(), and setup().

double EBCosmicTask::minJitter_
private

Definition at line 79 of file EBCosmicTask.h.

Referenced by analyze(), and EBCosmicTask().

std::string EBCosmicTask::prefixME_
private

Definition at line 62 of file EBCosmicTask.h.

Referenced by beginJob(), cleanup(), EBCosmicTask(), and setup().

double EBCosmicTask::threshold_
private

Definition at line 78 of file EBCosmicTask.h.

Referenced by analyze(), and EBCosmicTask().