CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
TreeProducerCalibSimul Class Reference

#include <TreeProducerCalibSimul.h>

Inheritance diagram for TreeProducerCalibSimul:
edm::EDAnalyzer edm::EDConsumerBase

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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 59 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 AlCaHLTBitMon_QueryRunRegistry::string.

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
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 }

Member Function Documentation

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

Definition at line 95 of file TreeProducerCalibSimul.cc.

References gather_cfg::cout, DEFINE_FWK_MODULE, egHLT::errCodes::EBRecHits, EBDetId::ETAPHIMODE, EcalTBEventHeader::eventNumber(), edm::SortedCollection< T, SORT >::find(), edm::Event::getByLabel(), EBDetId::ic(), EBDetId::ieta(), cuy::ii, EBDetId::iphi(), ecalpyutils::ism(), EcalTBTDCRecInfo::offset(), EcalTBHodoscopeRecInfo::posX(), EcalTBHodoscopeRecInfo::posY(), edm::Handle< T >::product(), EcalTBHodoscopeRecInfo::qualX(), EcalTBHodoscopeRecInfo::qualY(), findQualityFiles::run, edm::SortedCollection< T, SORT >::size(), EcalTBHodoscopeRecInfo::slopeX(), EcalTBHodoscopeRecInfo::slopeY(), EBDetId::SMCRYSTALMODE, fftjetcommon_cfi::sx, and fftjetcommon_cfi::sy.

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  } else {
210  energy[icry] = -100.;
211  crystal[icry] = -100;
212  allMatrix = 0;
213  }
214  /*
215  catch (...)
216  {
217  // can not construct 7x7 matrix
218  energy[icry] = -100.;
219  crystal[icry] = -100;
220  allMatrix = 0;
221  }
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 }
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:464
static const int ETAPHIMODE
Definition: EBDetId.h:166
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:46
ii
Definition: cuy.py:588
T const * product() const
Definition: Handle.h:81
int eventNumber() const
Returns the event number.
iterator find(key_type k)
HLT enums.
size_type size() const
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:167
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:56
float offset() const
Definition: event.py:1
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 }
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 }

Member Data Documentation

std::string TreeProducerCalibSimul::EBRecHitCollection_
private

Definition at line 72 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::eventHeaderCollection_
private

Definition at line 78 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::eventHeaderProducer_
private

Definition at line 79 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::hodoRecInfoCollection_
private

Definition at line 74 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::hodoRecInfoProducer_
private

Definition at line 75 of file TreeProducerCalibSimul.h.

TreeMatrixCalib* TreeProducerCalibSimul::myTree
private

Definition at line 82 of file TreeProducerCalibSimul.h.

int TreeProducerCalibSimul::noHeader
private

Definition at line 90 of file TreeProducerCalibSimul.h.

int TreeProducerCalibSimul::noHits
private

Definition at line 87 of file TreeProducerCalibSimul.h.

int TreeProducerCalibSimul::noHodo
private

Definition at line 88 of file TreeProducerCalibSimul.h.

int TreeProducerCalibSimul::noTdc
private

Definition at line 89 of file TreeProducerCalibSimul.h.

double TreeProducerCalibSimul::posCluster_
private

Definition at line 80 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::RecHitProducer_
private

Definition at line 73 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::rootfile_
private

Definition at line 70 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::tdcRecInfoCollection_
private

Definition at line 76 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::tdcRecInfoProducer_
private

Definition at line 77 of file TreeProducerCalibSimul.h.

int TreeProducerCalibSimul::tot_events
private

Definition at line 85 of file TreeProducerCalibSimul.h.

int TreeProducerCalibSimul::tot_events_ok
private

Definition at line 86 of file TreeProducerCalibSimul.h.

std::string TreeProducerCalibSimul::txtfile_
private

Definition at line 71 of file TreeProducerCalibSimul.h.

int TreeProducerCalibSimul::xtalInBeam
private

Definition at line 84 of file TreeProducerCalibSimul.h.