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 Member Functions | Private Attributes
AlignmentPrescaler Class Reference

#include <AlignmentPrescaler.h>

Inheritance diagram for AlignmentPrescaler:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 AlignmentPrescaler (const edm::ParameterSet &iConfig)
 
void beginJob ()
 
void endJob ()
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
 ~AlignmentPrescaler ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

int layerFromId (const DetId &id, const TrackerTopology *tTopo) const
 

Private Attributes

unsigned int detid_
 
TFile * fpresc_
 
float hitPrescFactor_
 
TRandom3 * myrand_
 
float overlapPrescFactor_
 
std::string prescfilename_
 
std::string presctreename_
 
edm::InputTag src_
 
edm::InputTag srcQualityMap_
 
int totnhitspxl_
 
TTree * tpresc_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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 23 of file AlignmentPrescaler.h.

Constructor & Destructor Documentation

AlignmentPrescaler::AlignmentPrescaler ( const edm::ParameterSet iConfig)

Definition at line 27 of file AlignmentPrescaler.cc.

27  :
28  src_(iConfig.getParameter<edm::InputTag>("src")),
29  srcQualityMap_(iConfig.getParameter<edm::InputTag>("assomap")),
30  prescfilename_(iConfig.getParameter<std::string>("PrescFileName")),
31  presctreename_(iConfig.getParameter<std::string>("PrescTreeName"))
32 {
33  // issue the produce<>
34  produces<AliClusterValueMap>();
35  produces<AliTrackTakenClusterValueMap>();
36 
37 }
T getParameter(std::string const &) const
edm::InputTag srcQualityMap_
std::string prescfilename_
std::string presctreename_
AlignmentPrescaler::~AlignmentPrescaler ( )

Definition at line 39 of file AlignmentPrescaler.cc.

39  {
40  //
41 }

Member Function Documentation

void AlignmentPrescaler::beginJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 43 of file AlignmentPrescaler.cc.

References gather_cfg::cout, detid_, fpresc_, hitPrescFactor_, myrand_, overlapPrescFactor_, prescfilename_, presctreename_, and tpresc_.

43  {
44  //
45  std::cout<<"in AlignmentPrescaler::beginJob"<<std::flush;
46  fpresc_=new TFile(prescfilename_.c_str(),"READ");
47  tpresc_=(TTree*)fpresc_->Get(presctreename_.c_str());
48  tpresc_->BuildIndex("DetId");
49  tpresc_->SetBranchStatus("*",0);
50  tpresc_->SetBranchStatus("DetId",1);
51  tpresc_->SetBranchStatus("PrescaleFactor",1);
52  tpresc_->SetBranchStatus("PrescaleFactorOverlap",1);
53  cout<<" Branches activated "<<std::flush;
54  detid_=0;
55  hitPrescFactor_=99.0;
57 
58  tpresc_->SetBranchAddress("DetId",&detid_);
59  tpresc_->SetBranchAddress("PrescaleFactor",&hitPrescFactor_);
60  tpresc_->SetBranchAddress("PrescaleFactorOverlap",&overlapPrescFactor_);
61  cout<<" addressed "<<std::flush;
62  myrand_=new TRandom3();
63  // myrand_->SetSeed();
64  cout<<" ok "<<std::endl;
65 
66 }
std::string prescfilename_
std::string presctreename_
tuple cout
Definition: gather_cfg.py:121
void AlignmentPrescaler::endJob ( void  )
virtual

Reimplemented from edm::EDProducer.

Definition at line 68 of file AlignmentPrescaler.cc.

References fpresc_, myrand_, and tpresc_.

68  {
69 
70  delete tpresc_;
71  fpresc_->Close();
72  delete fpresc_;
73  delete myrand_;
74 }
int AlignmentPrescaler::layerFromId ( const DetId id,
const TrackerTopology tTopo 
) const
private

Definition at line 241 of file AlignmentPrescaler.cc.

References PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, TrackerTopology::pxbLayer(), TrackerTopology::pxfDisk(), TrackerTopology::pxfSide(), StripSubdetector::TEC, TrackerTopology::tecWheel(), StripSubdetector::TIB, TrackerTopology::tibLayer(), StripSubdetector::TID, TrackerTopology::tidSide(), TrackerTopology::tidWheel(), StripSubdetector::TOB, and TrackerTopology::tobLayer().

242 {
243  if ( uint32_t(id.subdetId())==PixelSubdetector::PixelBarrel ) {
244 
245  return tTopo->pxbLayer(id);
246  }
247  else if ( uint32_t(id.subdetId())==PixelSubdetector::PixelEndcap ) {
248 
249  return tTopo->pxfDisk(id) + (3*(tTopo->pxfSide(id)-1));
250  }
251  else if ( id.subdetId()==StripSubdetector::TIB ) {
252 
253  return tTopo->tibLayer(id);
254  }
255  else if ( id.subdetId()==StripSubdetector::TOB ) {
256 
257  return tTopo->tobLayer(id);
258  }
259  else if ( id.subdetId()==StripSubdetector::TEC ) {
260 
261  return tTopo->tecWheel(id) + (9*(tTopo->pxfSide(id)-1));
262  }
263  else if ( id.subdetId()==StripSubdetector::TID ) {
264 
265  return tTopo->tidWheel(id) + (3*(tTopo->tidSide(id)-1));
266  }
267  return -1;
268 
269 }//end layerfromId
unsigned int tibLayer(const DetId &id) const
unsigned int pxfDisk(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
unsigned int tidSide(const DetId &id) const
unsigned int pxbLayer(const DetId &id) const
unsigned int pxfSide(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
unsigned int tobLayer(const DetId &id) const
void AlignmentPrescaler::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
virtual

Implements edm::EDProducer.

Definition at line 76 of file AlignmentPrescaler.cc.

References gather_cfg::cout, edm::helper::Filler< Map >::fill(), TrackingRecHit::geographicalId(), edm::Event::getByLabel(), hitPrescFactor_, edm::helper::Filler< Map >::insert(), TrackingRecHit::isValid(), myrand_, overlapPrescFactor_, edm::Event::put(), DetId::rawId(), findQualityFiles::rr, src_, srcQualityMap_, DetId::subdetId(), and tpresc_.

Referenced by JSONExport.JsonExport::export(), HTMLExport.HTMLExport::export(), and HTMLExport.HTMLExportStatic::export().

76  {
77  // std::cout<<"\n\n#################\n### Starting the AlignmentPrescaler::produce ; Event: "<<iEvent.id().run() <<", "<<iEvent.id().event()<<std::endl;
79  iEvent.getByLabel(src_, Tracks);
80 
81  //take HitAssomap
83  iEvent.getByLabel(srcQualityMap_, hMap);
84  AliClusterValueMap InValMap=*hMap;
85 
86  //prepare the output of the ValueMap flagging tracks
87  std::vector<int> trackflags(Tracks->size(),0);
88 
89 
90  //int npxlhits=0;
91 
92  //loop on tracks
93  for(std::vector<reco::Track>::const_iterator ittrk = Tracks->begin(), edtrk = Tracks->end(); ittrk != edtrk; ++ittrk){
94  //loop on tracking rechits
95  // std::cout << "Loop on hits of track #" << (ittrk - Tracks->begin()) << std::endl;
96  int nhit=0;
97  int ntakenhits=0;
98  bool firstTakenHit=false;
99 
100  for (trackingRecHit_iterator ith = ittrk->recHitsBegin(), edh = ittrk->recHitsEnd(); ith != edh; ++ith) {
101  const TrackingRecHit *hit = ith->get(); // ith is an iterator on edm::Ref to rechit
102  if(! hit->isValid()){
103  nhit++;
104  continue;
105  }
106  uint32_t tmpdetid = hit->geographicalId().rawId();
107  tpresc_->GetEntryWithIndex(tmpdetid);
108 
109 
110  //-------------
111  //decide whether to take this hit or not
112  bool takeit=false;
113  int subdetId=hit->geographicalId().subdetId();
114 
115 
116  //check first if the cluster is also in the overlap asso map
117  bool isOverlapHit=false;
118  // bool first=true;
119  //ugly...
120  const SiPixelRecHit* pixelhit= dynamic_cast<const SiPixelRecHit*>(hit);
121  const SiStripRecHit1D* stripHit1D = dynamic_cast<const SiStripRecHit1D*>(hit);
122  const SiStripRecHit2D* stripHit2D = dynamic_cast<const SiStripRecHit2D*>(hit);
123 
124  AlignmentClusterFlag tmpflag(hit->geographicalId());
125  int stripType=0;
126  if(subdetId>2){// SST case
127  const std::type_info &type = typeid(*hit);
128  if (type == typeid(SiStripRecHit1D)) stripType=1;
129  else if (type == typeid(SiStripRecHit2D)) stripType=2;
130  else stripType=3;
131 
132  if(stripType==1) {
133  // const SiStripRecHit1D* stripHit1D = dynamic_cast<const SiStripRecHit1D*>(hit);
134 
135  if(stripHit1D!=0){
136  SiStripRecHit1D::ClusterRef stripclust(stripHit1D->cluster());
137  tmpflag=InValMap[stripclust];
138  tmpflag.SetDetId(hit->geographicalId());
139  if(tmpflag.isOverlap())isOverlapHit=true;
140  // std::cout<<"~*~*~* Prescale (1D) for module "<<tmpflag.detId().rawId()<<"("<<InValMap[stripclust].detId().rawId() <<") is "<<hitPrescFactor_<<std::flush;
141  // if(tmpflag.isOverlap())cout<<" (it is Overlap)"<<endl;
142  // else cout<<endl;
143 
144  }//end if striphit1D!=0
145  }
146  else if (stripType==2) {
147  //const SiStripRecHit2D* stripHit2D = dynamic_cast<const SiStripRecHit2D*>(hit);
148  if(stripHit2D!=0){
149  SiStripRecHit2D::ClusterRef stripclust(stripHit2D->cluster());
150  tmpflag=InValMap[stripclust];
151  tmpflag.SetDetId(hit->geographicalId());
152  if(tmpflag.isOverlap())isOverlapHit=true;
153  // std::cout<<"~*~*~* Prescale (2D) for module "<<tmpflag.detId().rawId()<<"("<<InValMap[stripclust].detId().rawId() <<") is "<<hitPrescFactor_<<std::flush;
154  // if(tmpflag.isOverlap())cout<<" (it is Overlap)"<<endl;
155  // else cout<<endl;
156 
157  }//end if striphit2D!=0
158  }
159  }//end if is a strip hit
160  else{
161  // const SiPixelRecHit* pixelhit= dynamic_cast<const SiPixelRecHit*>(hit);
162  if(pixelhit!=0){
163  //npxlhits++;
164  SiPixelClusterRefNew pixclust(pixelhit->cluster());
165  tmpflag=InValMap[pixclust];
166  tmpflag.SetDetId(hit->geographicalId());
167  if(tmpflag.isOverlap())isOverlapHit=true;
168  }
169  }//end else is a pixel hit
170  // tmpflag.SetDetId(hit->geographicalId());
171 
172  if( isOverlapHit ){
173  //cout<<" DetId="<<tmpdetid<<" is Overlap! "<<flush;
174  takeit=(float(myrand_->Rndm())<=overlapPrescFactor_);
175  }
176  if( !takeit ){
177  float rr=float(myrand_->Rndm());
178  takeit=(rr<=hitPrescFactor_);
179  }
180  if(takeit){//HIT TAKEN !
181  //cout<<" DetId="<<tmpdetid<<" taken!"<<flush;
182  tmpflag.SetTakenFlag();
183 
184  if(subdetId>2){
185  if(stripType==1){
186  SiStripRecHit1D::ClusterRef stripclust(stripHit1D->cluster());
187  InValMap[stripclust]=tmpflag;//.SetTakenFlag();
188  }
189  else if(stripType==2){
190  SiStripRecHit1D::ClusterRef stripclust(stripHit2D->cluster());
191  InValMap[stripclust]=tmpflag;//.SetTakenFlag();
192  }
193  else std::cout<<"Unknown type of strip hit"<<std::endl;
194  }
195  else{
196  SiPixelClusterRefNew pixclust(pixelhit->cluster());
197  InValMap[pixclust]=tmpflag;//.SetTakenFlag();
198  }
199 
200  if(!firstTakenHit){
201  firstTakenHit=true;
202  //std::cout<<"Index of the track iterator is "<< ittrk-Tracks->begin() <<endl;
203 
204  }
205  ntakenhits++;
206  }//end if take this hit
207  //cout<<endl;
208 
209  nhit++;
210  //cout<<endl;
211  }//end loop on RecHits
212  trackflags[ittrk-Tracks->begin()]=ntakenhits;
213 
214  }//end loop on tracks
215 
216 
217 
218  // totnhitspxl_+=ntakenhits;
219  //cout<<"AlignmentPrescaler::produce says that in this event "<<ntakenhits<<" pixel clusters were taken (out of "<<npxlhits<<" total pixel hits."<<endl;
220 
221 
222 
223  //save the asso map, tracks...
224  // prepare output
225  std::auto_ptr<AliClusterValueMap> OutVM( new AliClusterValueMap);
226  *OutVM=InValMap;
227 
228  iEvent.put(OutVM);
229 
230 
231  std::auto_ptr<AliTrackTakenClusterValueMap> trkVM( new AliTrackTakenClusterValueMap);
232  AliTrackTakenClusterValueMap::Filler trkmapfiller(*trkVM);
233  trkmapfiller.insert(Tracks,trackflags.begin(),trackflags.end() );
234  trkmapfiller.fill();
235  iEvent.put(trkVM);
236 
237 
238 }//end produce
type
Definition: HCALResponse.h:21
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
edm::InputTag srcQualityMap_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
bool isValid() const
tuple cout
Definition: gather_cfg.py:121
DetId geographicalId() const
Pixel Reconstructed Hit.

Member Data Documentation

unsigned int AlignmentPrescaler::detid_
private

Definition at line 46 of file AlignmentPrescaler.h.

Referenced by beginJob().

TFile* AlignmentPrescaler::fpresc_
private

Definition at line 39 of file AlignmentPrescaler.h.

Referenced by beginJob(), and endJob().

float AlignmentPrescaler::hitPrescFactor_
private

Definition at line 47 of file AlignmentPrescaler.h.

Referenced by beginJob(), and produce().

TRandom3* AlignmentPrescaler::myrand_
private

Definition at line 41 of file AlignmentPrescaler.h.

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

float AlignmentPrescaler::overlapPrescFactor_
private

Definition at line 47 of file AlignmentPrescaler.h.

Referenced by beginJob(), and produce().

std::string AlignmentPrescaler::prescfilename_
private

Definition at line 36 of file AlignmentPrescaler.h.

Referenced by beginJob().

std::string AlignmentPrescaler::presctreename_
private

Definition at line 37 of file AlignmentPrescaler.h.

Referenced by beginJob().

edm::InputTag AlignmentPrescaler::src_
private

Definition at line 33 of file AlignmentPrescaler.h.

Referenced by produce().

edm::InputTag AlignmentPrescaler::srcQualityMap_
private

Definition at line 34 of file AlignmentPrescaler.h.

Referenced by produce().

int AlignmentPrescaler::totnhitspxl_
private

Definition at line 48 of file AlignmentPrescaler.h.

TTree* AlignmentPrescaler::tpresc_
private

Definition at line 40 of file AlignmentPrescaler.h.

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