CMS 3D CMS Logo

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

#include <TreeProducerCalibSimul.h>

Inheritance diagram for TreeProducerCalibSimul:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 
 TreeProducerCalibSimul (const edm::ParameterSet &)
 
 ~TreeProducerCalibSimul ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

std::string EBRecHitCollection_
 
std::string eventHeaderCollection_
 
std::string eventHeaderProducer_
 
std::string hodoRecInfoCollection_
 
std::string hodoRecInfoProducer_
 
TreeMatrixCalibmyTree
 
int noHeader
 
int noHits
 
int noHodo
 
int noTdc
 
double posCluster_
 
std::string RecHitProducer_
 
std::string rootfile_
 
std::string tdcRecInfoCollection_
 
std::string tdcRecInfoProducer_
 
int tot_events
 
int tot_events_ok
 
std::string txtfile_
 
int xtalInBeam
 

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)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 60 of file TreeProducerCalibSimul.h.

Constructor & Destructor Documentation

TreeProducerCalibSimul::TreeProducerCalibSimul ( const edm::ParameterSet iConfig)
explicit

Definition at line 8 of file TreeProducerCalibSimul.cc.

References gather_cfg::cout, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and run_Gflash_TBH4_setup_cfg::xtalInBeam.

9 {
10  // now do what ever initialization is needed
11  xtalInBeam = iConfig.getUntrackedParameter<int>("xtalInBeam",-1000);
12  rootfile_ = iConfig.getUntrackedParameter<std::string>("rootfile","mySimMatrixTree.root");
13  txtfile_ = iConfig.getUntrackedParameter<std::string>("txtfile", "mySimMatrixTree.txt");
14  EBRecHitCollection_ = iConfig.getParameter<std::string>("EBRecHitCollection");
15  RecHitProducer_ = iConfig.getParameter<std::string>("RecHitProducer");
16  hodoRecInfoCollection_ = iConfig.getParameter<std::string>("hodoRecInfoCollection");
17  hodoRecInfoProducer_ = iConfig.getParameter<std::string>("hodoRecInfoProducer");
18  tdcRecInfoCollection_ = iConfig.getParameter<std::string>("tdcRecInfoCollection");
19  tdcRecInfoProducer_ = iConfig.getParameter<std::string>("tdcRecInfoProducer");
20  eventHeaderCollection_ = iConfig.getParameter<std::string>("eventHeaderCollection");
21  eventHeaderProducer_ = iConfig.getParameter<std::string>("eventHeaderProducer");
22 
23  // summary
24  cout << endl;
25  cout <<"Constructor" << endl;
26  cout << endl;
27  cout << "TreeProducerCalibSimul" << endl;
28  cout << "xtal in beam = " << xtalInBeam << endl;
29  cout <<"Fetching hitCollection: " << EBRecHitCollection_.c_str() << " prod by " << RecHitProducer_.c_str() <<endl;
30  cout <<"Fetching hodoCollection: " << hodoRecInfoCollection_.c_str() << " prod by " << hodoRecInfoProducer_.c_str() <<endl;
31  cout <<"Fetching tdcCollection: " << tdcRecInfoCollection_.c_str() << " prod by " << tdcRecInfoProducer_.c_str() <<endl;
32  cout <<"Fetching evHeaCollection: " << eventHeaderCollection_.c_str() << " prod by " << eventHeaderProducer_.c_str() <<endl;
33  cout << endl;
34 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
tuple cout
Definition: gather_cfg.py:41
TreeProducerCalibSimul::~TreeProducerCalibSimul ( )

Definition at line 39 of file TreeProducerCalibSimul.cc.

References gather_cfg::cout.

40 {
41  cout << endl;
42  cout << "Deleting" << endl;
43  cout << endl;
44 
45  delete myTree;
46 }
tuple cout
Definition: gather_cfg.py:41

Member Function Documentation

void TreeProducerCalibSimul::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 95 of file TreeProducerCalibSimul.cc.

References ExpressReco_HICollisions_FallBack::cerr, gather_cfg::cout, egHLT::errCodes::EBRecHits, relval_parameters_module::energy, EBDetId::ETAPHIMODE, event(), cmsCodeRules.cppFunctionSkipper::exception, edm::Event::getByLabel(), EBDetId::ic(), EBDetId::ieta(), EBDetId::iphi(), ecalpyutils::ism(), CrabTask::run, EBDetId::SMCRYSTALMODE, ExpressReco_HICollisions_FallBack::x, run_Gflash_TBH4_setup_cfg::xtalInBeam, and ExpressReco_HICollisions_FallBack::y.

96 {
97  using namespace edm;
98  using namespace cms;
99 
100  // counting events
101  tot_events++;
102 
103  if ( tot_events%5000 == 0){ cout << "event " << tot_events << endl;}
104 
105 
106  // ---------------------------------------------------------------------
107  // taking what I need: hits
108  Handle< EBRecHitCollection > pEBRecHits ;
109  const EBRecHitCollection* EBRecHits = 0 ;
110  try {
111  iEvent.getByLabel (RecHitProducer_, EBRecHitCollection_, pEBRecHits) ;
112  EBRecHits = pEBRecHits.product();
113  } catch ( std::exception& ex ) {
114  std::cout << "Error! can't get the product " << EBRecHitCollection_.c_str () << std::endl ;
115  std::cerr << "Error! can't get the product " << EBRecHitCollection_.c_str () << std::endl ;
116  }
117 
118  // taking what I need: hodoscopes
120  const EcalTBHodoscopeRecInfo* recHodo=0;
121  try {
123  recHodo = pHodo.product();
124  } catch ( std::exception& ex ) {
125  std::cout << "Error! can't get the product " << hodoRecInfoCollection_.c_str() << std::endl;
126  std::cerr << "Error! can't get the product " << hodoRecInfoCollection_.c_str() << std::endl;
127  }
128 
129  // taking what I need: tdc
131  const EcalTBTDCRecInfo* recTDC=0;
132  try {
134  recTDC = pTDC.product();
135  } catch ( std::exception& ex ) {
136  std::cout << "Error! can't get the product " << tdcRecInfoCollection_.c_str() << std::endl;
137  std::cerr << "Error! can't get the product " << tdcRecInfoCollection_.c_str() << std::endl;
138  }
139 
140  // taking what I need: event header
141  Handle<EcalTBEventHeader> pEventHeader;
142  const EcalTBEventHeader* evtHeader=0;
143  try {
144  iEvent.getByLabel( eventHeaderProducer_ , pEventHeader );
145  evtHeader = pEventHeader.product();
146  } catch ( std::exception& ex ) {
147  std::cout << "Error! can't get the event header " <<std::endl;
148  std::cerr << "Error! can't get the event header " <<std::endl;
149  }
150 
151  // checking everything is there and fine
152  if ( (!EBRecHits) || (EBRecHits->size() == 0)){ noHits++; return; }
153  if (!recTDC) { noTdc++; return; }
154  if (!recHodo) { noHodo++; return; }
155  if (!evtHeader) { noHeader++; return; }
156  tot_events_ok++;
157 
158 
159 
160  // ---------------------------------------------------------------------
161  // info on the event
162  int run = -999;
163  int tbm = -999;
164  int event = evtHeader->eventNumber();
165 
166  // ---------------------------------------------------------------------
167  // xtal-in-beam
168  int nomXtalInBeam = -999;
169  int nextXtalInBeam = -999;
170 
171  EBDetId xtalInBeamId(1,xtalInBeam, EBDetId::SMCRYSTALMODE);
172  if (xtalInBeamId==EBDetId(0)){ return; }
173  int mySupCry = xtalInBeamId.ic();
174  int mySupEta = xtalInBeamId.ieta();
175  int mySupPhi = xtalInBeamId.iphi();
176 
177 
178  // ---------------------------------------------------------------------
179  // hodoscope information
180  double x = recHodo->posX();
181  double y = recHodo->posY();
182  double sx = recHodo->slopeX();
183  double sy = recHodo->slopeY();
184  double qx = recHodo->qualX();
185  double qy = recHodo->qualY();
186 
187 
188  // ---------------------------------------------------------------------
189  // tdc information
190  double tdcOffset = recTDC->offset();
191 
192 
193  // ---------------------------------------------------------------------
194  // Find EBDetId in a 7x7 Matrix
195  EBDetId Xtals7x7[49];
196  double energy[49];
197  int crystal[49];
198  int allMatrix = 1;
199  for (unsigned int icry=0; icry<49; icry++){
200  unsigned int row = icry/7;
201  unsigned int column = icry%7;
202  try
203  {
204  Xtals7x7[icry]=EBDetId(xtalInBeamId.ieta()+column-3, xtalInBeamId.iphi()+row-3, EBDetId::ETAPHIMODE);
205 
206  if ( Xtals7x7[icry].ism() == 1){
207  energy[icry] = EBRecHits->find(Xtals7x7[icry])->energy();
208  crystal[icry] = Xtals7x7[icry].ic();
209  }
210  if ( Xtals7x7[icry].ism() != 1){
211  energy[icry] = -100.;
212  crystal[icry] = -100;
213  allMatrix = 0;
214  }
215  }
216  catch (...)
217  {
218  // can not construct 7x7 matrix
219  energy[icry] = -100.;
220  crystal[icry] = -100;
221  allMatrix = 0;
222  }
223  }
224 
225 
226  // ---------------------------------------------------------------------
227  // Looking for the max energy crystal
228  double maxEne = -999.;
229  int maxEneCry = 9999;
230  int maxEneInMatrix = -999;
231  for (int ii=0; ii<49; ii++){ if (energy[ii] > maxEne){
232  maxEne = energy[ii];
233  maxEneCry = crystal[ii];
234  maxEneInMatrix = ii;}
235  }
236 
237 
238 
239  // Position reconstruction - skipped here
240  double Xcal = -999.;
241  double Ycal = -999.;
242 
243  // filling the tree
244  myTree->fillInfo(run, event, mySupCry, maxEneCry, nomXtalInBeam, nextXtalInBeam, mySupEta, mySupPhi, tbm, x, y, Xcal, Ycal, sx, sy, qx, qy, tdcOffset, allMatrix, energy, crystal);
245  myTree->store();
246 }
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
static const int ETAPHIMODE
Definition: EBDetId.h:145
tuple cout
Definition: gather_cfg.py:41
void fillInfo(int run, int eve, int xnum, int maxX, int nomX, int nextX, int xeta, int xphi, int tbm, double xx, double yy, double ecalx, double ecaly, double sx, double sy, double qx, double qy, double tdcoff, int allm, double amp[], int cry[])
static const int SMCRYSTALMODE
Definition: EBDetId.h:146
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:47
void TreeProducerCalibSimul::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 52 of file TreeProducerCalibSimul.cc.

References gather_cfg::cout.

53 {
54  cout << endl;
55  cout << "BeginJob" << endl;
56  cout << endl;
57 
58  // tree
59  myTree = new TreeMatrixCalib(rootfile_.c_str());
60 
61  // counters
62  tot_events = 0;
63  tot_events_ok = 0;
64  noHits = 0;
65  noHodo = 0;
66  noTdc = 0;
67  noHeader = 0;
68 }
tuple cout
Definition: gather_cfg.py:41
void TreeProducerCalibSimul::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 74 of file TreeProducerCalibSimul.cc.

References gather_cfg::cout.

75 {
76  cout << endl;
77  cout << "EndJob" << endl;
78  cout << endl;
79 
80  ofstream *MyOut = new ofstream(txtfile_.c_str());
81  *MyOut << "total events: " << tot_events << endl;
82  *MyOut << "events skipped because of no hits: " << noHits << endl;
83  *MyOut << "events skipped because of no hodos: " << noHodo << endl;
84  *MyOut << "events skipped because of no tdc: " << noTdc << endl;
85  *MyOut << "events skipped because of no header: " << noHeader << endl;
86  *MyOut << "total OK events (passing the basic selection): " << tot_events_ok << endl;
87  MyOut->close();
88  delete MyOut;
89 }
tuple cout
Definition: gather_cfg.py:41

Member Data Documentation

std::string TreeProducerCalibSimul::EBRecHitCollection_
private

Definition at line 73 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::eventHeaderCollection_
private

Definition at line 79 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::eventHeaderProducer_
private

Definition at line 80 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::hodoRecInfoCollection_
private

Definition at line 75 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::hodoRecInfoProducer_
private

Definition at line 76 of file TreeProducerCalibSimul.h.

TreeMatrixCalib* TreeProducerCalibSimul::myTree
private

Definition at line 83 of file TreeProducerCalibSimul.h.

int TreeProducerCalibSimul::noHeader
private

Definition at line 91 of file TreeProducerCalibSimul.h.

int TreeProducerCalibSimul::noHits
private

Definition at line 88 of file TreeProducerCalibSimul.h.

int TreeProducerCalibSimul::noHodo
private

Definition at line 89 of file TreeProducerCalibSimul.h.

int TreeProducerCalibSimul::noTdc
private

Definition at line 90 of file TreeProducerCalibSimul.h.

double TreeProducerCalibSimul::posCluster_
private

Definition at line 81 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::RecHitProducer_
private

Definition at line 74 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::rootfile_
private

Definition at line 71 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::tdcRecInfoCollection_
private

Definition at line 77 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::tdcRecInfoProducer_
private

Definition at line 78 of file TreeProducerCalibSimul.h.

int TreeProducerCalibSimul::tot_events
private

Definition at line 86 of file TreeProducerCalibSimul.h.

int TreeProducerCalibSimul::tot_events_ok
private

Definition at line 87 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::txtfile_
private

Definition at line 72 of file TreeProducerCalibSimul.h.

int TreeProducerCalibSimul::xtalInBeam
private

Definition at line 85 of file TreeProducerCalibSimul.h.