CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorCellProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Castor
4 // Class: CastorCellProducer
5 //
6 
13 //
14 // Original Author: Hans Van Haevermaet, Benoit Roland
15 // Created: Wed Jul 9 14:00:40 CEST 2008
16 // $Id: CastorCellProducer.cc,v 1.7 2010/07/06 16:45:54 hvanhaev Exp $
17 //
18 //
19 
20 
21 // system include
22 #include <memory>
23 #include <vector>
24 #include <iostream>
25 #include <TMath.h>
26 #include <TRandom3.h>
27 
28 // user include
35 
36 // Castor Object include
40 
41 //
42 // class declaration
43 //
44 
46  public:
47  explicit CastorCellProducer(const edm::ParameterSet&);
49 
50  private:
51  virtual void beginJob() ;
52  virtual void produce(edm::Event&, const edm::EventSetup&);
53  virtual void endJob() ;
54 
55  // member data
57  typedef ROOT::Math::RhoZPhiPoint CellPoint;
58  typedef std::vector<reco::CastorCell> CastorCellCollection;
59  std::string input_;
60 };
61 
62 //
63 // constants, enums and typedefs
64 //
65 
66 const double MYR2D = 180/M_PI;
67 
68 //
69 // static data member definitions
70 //
71 
72 //
73 // constructor and destructor
74 //
75 
77  input_(iConfig.getUntrackedParameter<std::string>("inputprocess","castorreco"))
78 {
79  // register your products
80  produces<CastorCellCollection>();
81  // now do what ever other initialization is needed
82 }
83 
84 
86 {
87  // do anything here that needs to be done at desctruction time
88  // (e.g. close files, deallocate resources etc.)
89 }
90 
91 
92 //
93 // member functions
94 //
95 
96 // ------------ method called to produce the data ------------
97 
99 
100  using namespace edm;
101  using namespace reco;
102  using namespace TMath;
103 
104  // Produce CastorCells from CastorRecHits
105 
107  iEvent.getByLabel(input_, InputRecHits);
108 
109  std::auto_ptr<CastorCellCollection> OutputCells (new CastorCellCollection);
110 
111  // looping over all CastorRecHits
112 
113  LogDebug("CastorCellProducer")
114  <<"1. entering CastorCellProducer ";
115 
116  for (size_t i = 0; i < InputRecHits->size(); ++i) {
117  const CastorRecHit & rh = (*InputRecHits)[i];
118  int sector = rh.id().sector();
119  int module = rh.id().module();
120  double energy = rh.energy();
121  int zside = rh.id().zside();
122 
123  // define CastorCell properties
124  double zCell=0.;
125  double phiCell;
126  double rhoCell;
127 
128  // set z position of the cell
129  if (module < 3) {
130  // starting in EM section
131  if (module == 1) zCell = 14415;
132  if (module == 2) zCell = 14464;
133  } else {
134  // starting in HAD section
135  zCell = 14534 + (module - 3)*92;
136  }
137 
138  // set phi position of the cell
139  double castorphi[16];
140  for (int j = 0; j < 16; j++) {
141  castorphi[j] = -2.94524 + j*0.3927;
142  }
143  if (sector > 8) {
144  phiCell = castorphi[sector - 9];
145  } else {
146  phiCell = castorphi[sector + 7];
147  }
148 
149  // add condition to select in eta sides
150  if (zside <= 0) zCell = -1*zCell;
151 
152  // set rho position of the cell (inner radius 3.7cm, outer radius 14cm)
153  rhoCell = 88.5;
154 
155  // store cell position
156  CellPoint tempcellposition(rhoCell,zCell,phiCell);
157  Point cellposition(tempcellposition);
158 
159  LogDebug("CastorCellProducer")
160  <<"cell number: "<<i+1<<std::endl
161  <<"rho: "<<cellposition.rho()<<" phi: "<<cellposition.phi()*MYR2D<<" eta: "<<cellposition.eta()<<std::endl
162  <<"x: "<<cellposition.x()<<" y: "<<cellposition.y()<<" z: "<<cellposition.z();
163 
164  if (energy > 0.) {
165  CastorCell newCell(energy,cellposition);
166  OutputCells->push_back(newCell);
167  }
168 
169  } // end loop over CastorRecHits
170 
171  LogDebug("CastorCellProducer")
172  <<"total number of cells in the event: "<<InputRecHits->size();
173 
174  iEvent.put(OutputCells);
175 
176 
177 }
178 
179 // ------------ method called once each job just before starting event loop ------------
181  LogDebug("CastorCellProducer")
182  <<"Starting CastorCellProducer";
183 }
184 
185 // ------------ method called once each job just after ending the event loop ------------
187  LogDebug("CastorCellProducer")
188  <<"Ending CastorCellProducer";
189 }
190 
191 //define this as a plug-in
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
int sector() const
get the sector (1-16)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int module() const
get the module (1-2 for EM, 1-12 for HAD)
HcalCastorDetId id() const
get the id
Definition: CastorRecHit.h:15
virtual void produce(edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
float energy() const
Definition: CaloRecHit.h:19
int zside() const
get the z-side of the cell (1/-1)
int j
Definition: DBlmapReader.cc:9
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::vector< reco::CastorCell > CastorCellCollection
math::XYZPointD Point
#define M_PI
Definition: BFit3D.cc:3
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double > > XYZPointD
point in space with cartesian internal representation
Definition: Point3D.h:9
const double MYR2D
Definition: vlib.h:209
CastorCellProducer(const edm::ParameterSet &)
ROOT::Math::RhoZPhiPoint CellPoint